From 9ed73e0cbaf4538eecb160e58f819c40e077ed0f Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Sat, 30 May 2015 15:54:47 +1000 Subject: [PATCH] Updates for new symbolizePath API, requires latest rain lib code Backend layouts can now be provided by plugins --- modules/backend/classes/Controller.php | 19 +++++++++++-------- modules/system/classes/CombineAssets.php | 5 +++-- modules/system/traits/ConfigMaker.php | 2 +- modules/system/traits/ViewMaker.php | 4 ++-- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/modules/backend/classes/Controller.php b/modules/backend/classes/Controller.php index a09dc5d1e..1ba0d4d21 100644 --- a/modules/backend/classes/Controller.php +++ b/modules/backend/classes/Controller.php @@ -137,19 +137,22 @@ class Controller extends Extendable /* * Define layout and view paths */ - $this->layout = 'default'; + $this->layout = $this->layout ?: 'default'; $this->layoutPath = Skin::getActive()->getLayoutPaths(); - - // Option A: (@todo Determine which is faster by benchmark) - // $relativePath = strtolower(str_replace('\\', '/', get_called_class())); - // $this->viewPath = $this->configPath = ['modules/' . $relativePath, 'plugins/' . $relativePath]; - - // Option B: $this->viewPath = $this->configPath = $this->guessViewPath(); + /* + * Add layout paths from the plugin / module context + */ + $relativePath = dirname(dirname(strtolower(str_replace('\\', '/', get_called_class())))); + $this->layoutPath[] = '~/modules/' . $relativePath . '/layouts'; + $this->layoutPath[] = '~/plugins/' . $relativePath . '/layouts'; + parent::__construct(); - // Media Manager widget is available on all back-end pages + /* + * Media Manager widget is available on all back-end pages + */ $manager = new MediaManager($this, 'ocmediamanager'); $manager->bindToController(); } diff --git a/modules/system/classes/CombineAssets.php b/modules/system/classes/CombineAssets.php index 6e8b2139a..53718d7df 100644 --- a/modules/system/classes/CombineAssets.php +++ b/modules/system/classes/CombineAssets.php @@ -317,7 +317,7 @@ class CombineAssets $filesSalt = null; foreach ($assets as $asset) { $filters = $this->getFilters(File::extension($asset)) ?: []; - $path = File::symbolizePath($asset) ?: $this->localPath . $asset; + $path = File::symbolizePath($asset, null) ?: $this->localPath . $asset; $files[] = new FileAsset($path, $filters, public_path()); $filesSalt .= $this->localPath . $asset; } @@ -326,8 +326,9 @@ class CombineAssets $collection = new AssetCollection($files, [], $filesSalt); $collection->setTargetPath($this->getTargetPath($rewritePath)); - if ($this->storagePath === null) + if ($this->storagePath === null) { return $collection; + } $cache = new FilesystemCache($this->storagePath); $cachedCollection = new AssetCache($collection, $cache); diff --git a/modules/system/traits/ConfigMaker.php b/modules/system/traits/ConfigMaker.php index 3cf5bf6f0..55d22f893 100644 --- a/modules/system/traits/ConfigMaker.php +++ b/modules/system/traits/ConfigMaker.php @@ -136,7 +136,7 @@ trait ConfigMaker $configPath = $this->configPath; } - $fileName = File::symbolizePath($fileName, $fileName); + $fileName = File::symbolizePath($fileName); if (File::isLocalPath($fileName) || realpath($fileName) !== false) { return $fileName; diff --git a/modules/system/traits/ViewMaker.php b/modules/system/traits/ViewMaker.php index 830f970a5..97e1dfe58 100644 --- a/modules/system/traits/ViewMaker.php +++ b/modules/system/traits/ViewMaker.php @@ -162,7 +162,7 @@ trait ViewMaker $viewPath = $this->viewPath; } - $fileName = File::symbolizePath($fileName, $fileName); + $fileName = File::symbolizePath($fileName); if (File::isLocalPath($fileName) || realpath($fileName) !== false) { return $fileName; @@ -173,7 +173,7 @@ trait ViewMaker } foreach ($viewPath as $path) { - $_fileName = $path . '/' . $fileName; + $_fileName = File::symbolizePath($path) . '/' . $fileName; if (File::isFile($_fileName)) { break; }