From fce021aad63e437536de0651a70b566d39221119 Mon Sep 17 00:00:00 2001 From: maTh Date: Wed, 4 Aug 2021 12:26:18 +0200 Subject: Themes incl javascript files (#3739) * it works * optimized --- app/FreshRSS.php | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'app/FreshRSS.php') 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. -- cgit v1.2.3