try to show HTTPS-encrypted theme files for HTTPS-encrypted pages

This commit is contained in:
Evan Prodromou 2010-10-14 00:46:32 -04:00
parent 40c64388e6
commit d91f894ccb
1 changed files with 55 additions and 38 deletions

View File

@ -116,6 +116,36 @@ class Theme
protected function relativeThemePath($group, $fallbackSubdir, $name) protected function relativeThemePath($group, $fallbackSubdir, $name)
{ {
if (StatusNet::isHTTPS()) {
$sslserver = common_config($group, 'sslserver');
if (empty($sslserver)) {
$server = common_config('site', 'server');
$path = common_config('site', 'path') . '/';
if ($fallbackSubdir) {
$path .= $fallbackSubdir . '/';
}
} else {
$server = $sslserver;
$path = common_config($group, 'sslpath');
if (empty($path)) {
$path = common_config($group, 'path');
}
}
if ($path[strlen($path)-1] != '/') {
$path .= '/';
}
if ($path[0] != '/') {
$path = '/'.$path;
}
return 'https://'.$server.$path.$name;
} else {
$path = common_config($group, 'path'); $path = common_config($group, 'path');
if (empty($path)) { if (empty($path)) {
@ -139,23 +169,10 @@ class Theme
$server = common_config('site', 'server'); $server = common_config('site', 'server');
} }
$ssl = common_config($group, 'ssl'); return 'http://'.$server.$path.$name;
if (is_null($ssl)) { // null -> guess
if (common_config('site', 'ssl') == 'always' &&
!common_config($group, 'server')) {
$ssl = true;
} else {
$ssl = false;
} }
} }
$protocol = ($ssl) ? 'https' : 'http';
$path = $protocol . '://'.$server.$path.$name;
return $path;
}
/** /**
* Gets the full local filename of a file in this theme. * Gets the full local filename of a file in this theme.
* *