Prechádzať zdrojové kódy

Themes incl javascript files (#3739)

* it works

* optimized
maTh 4 rokov pred
rodič
commit
fce021aad6
1 zmenil súbory, kde vykonal 25 pridanie a 13 odobranie
  1. 25 13
      app/FreshRSS.php

+ 25 - 13
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.