diff options
| author | 2021-08-04 12:26:18 +0200 | |
|---|---|---|
| committer | 2021-08-04 12:26:18 +0200 | |
| commit | fce021aad63e437536de0651a70b566d39221119 (patch) | |
| tree | 37622a50e62d8da6526d28adeb3b54a9cc33c5c2 /app/FreshRSS.php | |
| parent | 15358f9d4b2f336e7d774443b046f244e3a0ffe3 (diff) | |
Themes incl javascript files (#3739)
* it works
* optimized
Diffstat (limited to 'app/FreshRSS.php')
| -rw-r--r-- | app/FreshRSS.php | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/app/FreshRSS.php b/app/FreshRSS.php index 17ff9ab21..54caef3bc 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -92,24 +92,36 @@ class FreshRSS extends Minz_FrontController { Minz_Translate::init($language); } + private static function getThemeFileUrl($theme_id, $filename) { + $filetime = @filemtime(PUBLIC_PATH . '/themes/' . $theme_id . '/' . $filename); + return '/themes/' . $theme_id . '/' . $filename . '?' . $filetime; + } + public static function loadStylesAndScripts() { $theme = FreshRSS_Themes::load(FreshRSS_Context::$user_conf->theme); if ($theme) { foreach(array_reverse($theme['files']) as $file) { - if ($file[0] === '_') { - $theme_id = 'base-theme'; - $filename = substr($file, 1); - } else { - $theme_id = $theme['id']; - $filename = $file; - } - if (_t('gen.dir') === 'rtl') { - $filename = substr($filename, 0, -4); - $filename = $filename . '.rtl.css'; + switch (substr($file, -3)) { + case '.js': + $theme_id = $theme['id']; + $filename = $file; + Minz_View::prependScript(Minz_Url::display(FreshRSS::getThemeFileUrl($theme_id, $filename))); + break; + case '.css': + default: + if ($file[0] === '_') { + $theme_id = 'base-theme'; + $filename = substr($file, 1); + } else { + $theme_id = $theme['id']; + $filename = $file; + } + if (_t('gen.dir') === 'rtl') { + $filename = substr($filename, 0, -4); + $filename = $filename . '.rtl.css'; + } + Minz_View::prependStyle(Minz_Url::display(FreshRSS::getThemeFileUrl($theme_id, $filename))); } - $filetime = @filemtime(PUBLIC_PATH . '/themes/' . $theme_id . '/' . $filename); - $url = '/themes/' . $theme_id . '/' . $filename . '?' . $filetime; - Minz_View::prependStyle(Minz_Url::display($url)); } } //Use prepend to insert before extensions. Added in reverse order. |
