diff --git a/modules/backend/classes/BackendHelper.php b/modules/backend/classes/BackendHelper.php index cc1a8b5db..60dfd700e 100644 --- a/modules/backend/classes/BackendHelper.php +++ b/modules/backend/classes/BackendHelper.php @@ -2,7 +2,6 @@ use URL; use Config; -use Session; use Request; use October\Rain\Router\Helper as RouterHelper; @@ -29,9 +28,8 @@ class BackendHelper */ public function skinAsset($path = null) { - $path = RouterHelper::normalizeUrl($path); - $skinPath = Skin::getActive()->skinPath; - return URL::asset($skinPath . $path); + $skinPath = Skin::getActive()->getPath($path, true); + return URL::asset($skinPath); } /** diff --git a/modules/backend/classes/Controller.php b/modules/backend/classes/Controller.php index dee0402d9..b4dcd6b8a 100644 --- a/modules/backend/classes/Controller.php +++ b/modules/backend/classes/Controller.php @@ -127,7 +127,7 @@ class Controller extends Extendable * Define layout and view paths */ $this->layout = 'default'; - $this->layoutPath = ['modules/backend/layouts']; + $this->layoutPath = Skin::getActive()->getLayoutPaths(); // Option A: (@todo Determine which is faster by benchmark) // $relativePath = strtolower(str_replace('\\', '/', get_called_class())); diff --git a/modules/backend/classes/Skin.php b/modules/backend/classes/Skin.php index e2ded69a6..501066f20 100644 --- a/modules/backend/classes/Skin.php +++ b/modules/backend/classes/Skin.php @@ -1,6 +1,9 @@ skinPath = str_replace('\\', '/', get_called_class()); + $this->defaultSkinPath = PATH_BASE . '/modules/backend'; + + /* + * Guess the skin path + */ + $class = get_called_class(); + $classFolder = strtolower(Str::getRealClass($class)); + $classFile = realpath(dirname(File::fromClass($class))); + $this->skinPath = $classFile + ? $classFile . '/' . $classFolder + : $this->defaultSkinPath; + + $this->publicSkinPath = File::localToPublic($this->skinPath); + $this->defaultPublicSkinPath = File::localToPublic($this->defaultSkinPath); + + traceLog($this->skinPath); + } + + /** + * Looks up a path to a skin-based file, if it doesn't exist, the default path is used. + * @param string $path + * @param boolean $isPublic + * @return string + */ + public function getPath($path = null, $isPublic = false) + { + $path = RouterHelper::normalizeUrl($path); + $assetFile = $this->skinPath . $path; + + if (File::isFile($assetFile)) { + return $isPublic + ? $this->publicSkinPath . $path + : $this->skinPath . $path; + } + else { + return $isPublic + ? $this->defaultPublicSkinPath . $path + : $this->defaultSkinPath . $path; + } + } + + /** + * Returns an array of paths where skin layouts can be found. + * @return array + */ + public function getLayoutPaths() + { + return [$this->skinPath.'/layouts', $this->defaultSkinPath.'/layouts']; } /** diff --git a/modules/backend/layouts/_head.htm b/modules/backend/layouts/_head.htm index 178b8fc56..6110f8f23 100644 --- a/modules/backend/layouts/_head.htm +++ b/modules/backend/layouts/_head.htm @@ -1,78 +1,78 @@ - + <?= $this->pageTitle ?> | October CMS - - + + - - - - - - - - - - - + + + + + + + + + + + - - - - + + + + - - - - - + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +