From 0fa53d5f5d79d2855cacd0656bc38727423b6c3d Mon Sep 17 00:00:00 2001 From: Sommerregen Date: Sun, 4 Oct 2015 17:55:51 +0200 Subject: [PATCH 1/2] Load language files according to stream configurations --- system/src/Grav/Common/Config/Config.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/system/src/Grav/Common/Config/Config.php b/system/src/Grav/Common/Config/Config.php index 0cafeb7a0..9e69e994c 100644 --- a/system/src/Grav/Common/Config/Config.php +++ b/system/src/Grav/Common/Config/Config.php @@ -366,14 +366,16 @@ class Config extends Data // Load languages. $this->languages = new Languages; - - if (isset($languageFiles['user/plugins'])) { - foreach ((array) $languageFiles['user/plugins'] as $plugin => $item) { - $lang_file = CompiledYamlFile::instance($item['file']); - $content = $lang_file->content(); - $this->languages->mergeRecursive($content); + $pluginPaths = str_ireplace(GRAV_ROOT . '/', '', array_reverse($plugins)); + foreach ($pluginPaths as $path) { + if (isset($languageFiles[$path])) { + foreach ((array) $languageFiles[$path] as $plugin => $item) { + $lang_file = CompiledYamlFile::instance($item['file']); + $content = $lang_file->content(); + $this->languages->mergeRecursive($content); + } + unset($languageFiles[$path]); } - unset($languageFiles['user/plugins']); } foreach ($languageFiles as $location) { From f332cee5686fc96240c4b5a6cef820c1914a4ea2 Mon Sep 17 00:00:00 2001 From: Sommerregen Date: Tue, 6 Oct 2015 19:16:41 +0200 Subject: [PATCH 2/2] Load plugins and themes from multiple directories --- system/src/Grav/Common/Plugins.php | 21 ++++++++++++--------- system/src/Grav/Common/Themes.php | 26 ++++++++++++++------------ 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/system/src/Grav/Common/Plugins.php b/system/src/Grav/Common/Plugins.php index addf33ad8..93da156bc 100644 --- a/system/src/Grav/Common/Plugins.php +++ b/system/src/Grav/Common/Plugins.php @@ -94,18 +94,21 @@ class Plugins extends Iterator { $list = array(); $locator = Grav::instance()['locator']; - $iterator = new \DirectoryIterator($locator->findResource('plugins://', false)); - /** @var \DirectoryIterator $directory */ - foreach ($iterator as $directory) { - if (!$directory->isDir() || $directory->isDot()) { - continue; + $plugins = (array) $locator->findResources('plugins://', false); + foreach ($plugins as $path) { + $iterator = new \DirectoryIterator($path); + + /** @var \DirectoryIterator $directory */ + foreach ($iterator as $directory) { + if (!$directory->isDir() || $directory->isDot()) { + continue; + } + + $type = $directory->getBasename(); + $list[$type] = self::get($type); } - - $type = $directory->getBasename(); - $list[$type] = self::get($type); } - ksort($list); return $list; diff --git a/system/src/Grav/Common/Themes.php b/system/src/Grav/Common/Themes.php index 3691e22ae..3d3733b2c 100644 --- a/system/src/Grav/Common/Themes.php +++ b/system/src/Grav/Common/Themes.php @@ -60,18 +60,21 @@ class Themes extends Iterator { $list = array(); $locator = Grav::instance()['locator']; - $iterator = new \DirectoryIterator($locator->findResource('themes://', false)); - /** @var \DirectoryIterator $directory */ - foreach ($iterator as $directory) { - if (!$directory->isDir() || $directory->isDot()) { - continue; + $themes = (array) $locator->findResources('themes://', false); + foreach ($themes as $path) { + $iterator = new \DirectoryIterator($path); + + /** @var \DirectoryIterator $directory */ + foreach ($iterator as $directory) { + if (!$directory->isDir() || $directory->isDot()) { + continue; + } + + $type = $directory->getBasename(); + $list[$type] = self::get($type); } - - $type = $directory->getBasename(); - $list[$type] = self::get($type); } - ksort($list); return $list; @@ -96,9 +99,8 @@ class Themes extends Iterator // Find thumbnail. $thumb = "themes://{$name}/thumbnail.jpg"; - - if (file_exists($thumb)) { - $blueprint->set('thumbnail', $this->grav['base_url'] . "/user/themes/{$name}/thumbnail.jpg"); + if ($path = $this->grav['locator']->findResource($thumb, false)) { + $blueprint->set('thumbnail', $this->grav['base_url'] . '/' . $path); } // Load default configuration.