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

View File

@ -116,44 +116,61 @@ class Theme
protected function relativeThemePath($group, $fallbackSubdir, $name) protected function relativeThemePath($group, $fallbackSubdir, $name)
{ {
$path = common_config($group, 'path'); if (StatusNet::isHTTPS()) {
if (empty($path)) { $sslserver = common_config($group, 'sslserver');
$path = common_config('site', 'path') . '/';
if ($fallbackSubdir) {
$path .= $fallbackSubdir . '/';
}
}
if ($path[strlen($path)-1] != '/') { if (empty($sslserver)) {
$path .= '/'; $server = common_config('site', 'server');
} $path = common_config('site', 'path') . '/';
if ($fallbackSubdir) {
if ($path[0] != '/') { $path .= $fallbackSubdir . '/';
$path = '/'.$path; }
}
$server = common_config($group, 'server');
if (empty($server)) {
$server = common_config('site', 'server');
}
$ssl = common_config($group, 'ssl');
if (is_null($ssl)) { // null -> guess
if (common_config('site', 'ssl') == 'always' &&
!common_config($group, 'server')) {
$ssl = true;
} else { } else {
$ssl = false; $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');
if (empty($path)) {
$path = common_config('site', 'path') . '/';
if ($fallbackSubdir) {
$path .= $fallbackSubdir . '/';
}
}
if ($path[strlen($path)-1] != '/') {
$path .= '/';
}
if ($path[0] != '/') {
$path = '/'.$path;
}
$server = common_config($group, 'server');
if (empty($server)) {
$server = common_config('site', 'server');
}
return 'http://'.$server.$path.$name;
} }
$protocol = ($ssl) ? 'https' : 'http';
$path = $protocol . '://'.$server.$path.$name;
return $path;
} }
/** /**