Explorar o código

use Theme from project

Piotr Labudda %!s(int64=8) %!d(string=hai) anos
pai
achega
5562b4e112
Modificáronse 2 ficheiros con 13 adicións e 5 borrados
  1. 7 5
      SE/se-lib/Theme.php
  2. 6 0
      SE/se-lib/ThemeDefault.php

+ 7 - 5
SE/se-lib/Theme.php

@@ -9,11 +9,13 @@ class Theme {
 		DBG::log($_theme, 'array', "Theme::getInstance()...");
 		if (null !== $_theme) return $_theme;
 		try {
-			$themeName = ''; // TODO: read from config - theme
-			// $themeName = 'Bocian'; // TODO: DBG
-			DBG::log("Theme::getInstance({$themeName})");
-			$clsName = ($themeName) ? "Theme_{$themeName}" : "ThemeDefault";
-			Lib::loadClass($clsName);
+			$clsName = "ThemeDefault";
+			if ($activeProjectName = Config::getProjectName()) {
+				$activeProjectPath = Config::getProjectPath();
+				$clsName = "Theme_{$activeProjectName}";
+				require_once "{$activeProjectPath}/theme/{$activeProjectName}.php";
+			}
+			DBG::log("Theme::getInstance() '{$clsName}'");
 			$_theme = new $clsName();
 		} catch (Exception $e) {
 			DBG::log($e);

+ 6 - 0
SE/se-lib/ThemeDefault.php

@@ -48,4 +48,10 @@ class ThemeDefault {
 		include APP_PATH_WWW . '/se-lib/tmpl/defaultPage.php';
 	}
 
+	function asset($relativeUrl) {
+		if ('ThemeDefault' === get_class($this)) return $relativeUrl;
+		$projName = substr(get_class($this), strlen('Theme_'));
+		return "projects/{$projName}/theme/{$relativeUrl}";
+	}
+
 }