From 85a25d0adc1e93610a0268189f737b51a3d84273 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 19 Apr 2017 17:08:56 -0600 Subject: [PATCH 1/6] Fix for Gantry5 init'ing theme as well as Admin plugin --- CHANGELOG.md | 6 +++++ system/src/Grav/Common/Themes.php | 40 ++++++++++++++++++------------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fabcb1377..8e8079092 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.2.4 +## 04/xx/2017 + +1. [](#bugfix) + * Allow multiple calls to `Themes::initTheme()` without throwing errors + # v1.2.3 ## 04/19/2017 diff --git a/system/src/Grav/Common/Themes.php b/system/src/Grav/Common/Themes.php index bfe31e01c..492c86610 100644 --- a/system/src/Grav/Common/Themes.php +++ b/system/src/Grav/Common/Themes.php @@ -24,6 +24,8 @@ class Themes extends Iterator /** @var Config */ protected $config; + protected $inited = false; + /** * Themes constructor. * @@ -51,25 +53,29 @@ class Themes extends Iterator public function initTheme() { - /** @var Themes $themes */ - $themes = $this->grav['themes']; + if ($this->inited === false) { + /** @var Themes $themes */ + $themes = $this->grav['themes']; - try { - $instance = $themes->load(); - } catch (\InvalidArgumentException $e) { - throw new \RuntimeException($this->current() . ' theme could not be found'); + try { + $instance = $themes->load(); + } catch (\InvalidArgumentException $e) { + throw new \RuntimeException($this->current() . ' theme could not be found'); + } + + if ($instance instanceof EventSubscriberInterface) { + /** @var EventDispatcher $events */ + $events = $this->grav['events']; + + $events->addSubscriber($instance); + } + + $this->grav['theme'] = $instance; + + $this->grav->fireEvent('onThemeInitialized'); + + $this->inited = true; } - - if ($instance instanceof EventSubscriberInterface) { - /** @var EventDispatcher $events */ - $events = $this->grav['events']; - - $events->addSubscriber($instance); - } - - $this->grav['theme'] = $instance; - - $this->grav->fireEvent('onThemeInitialized'); } /** From 13b3b9875e1a42ec222b9d2266e2c147cede07a1 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 20 Apr 2017 11:02:54 -0600 Subject: [PATCH 2/6] Should address uery strings at the root of multilang sites #1436 --- CHANGELOG.md | 3 ++- system/src/Grav/Common/Language/Language.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e8079092..c5e51b27f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ 1. [](#bugfix) * Allow multiple calls to `Themes::initTheme()` without throwing errors - + * Fixed querystrings in root pages with multi-lang enabled [#1436](https://github.com/getgrav/grav/issues/1436) + # v1.2.3 ## 04/19/2017 diff --git a/system/src/Grav/Common/Language/Language.php b/system/src/Grav/Common/Language/Language.php index dbf2b95ba..31fad6681 100644 --- a/system/src/Grav/Common/Language/Language.php +++ b/system/src/Grav/Common/Language/Language.php @@ -170,7 +170,7 @@ class Language */ public function setActiveFromUri($uri) { - $regex = '/(^\/(' . $this->getAvailable() . '))(?:\/.*|$)/i'; + $regex = '/(^\/(' . $this->getAvailable() . '))(?:\/|\?|$)/i'; // if languages set if ($this->enabled()) { @@ -178,7 +178,7 @@ class Language if (preg_match($regex, $uri, $matches)) { $this->lang_in_url = true; $this->active = $matches[2]; - $uri = preg_replace("/\\" . $matches[1] . "/", '', $matches[0], 1); + $uri = preg_replace("/\\" . $matches[1] . "/", '', $uri, 1); // store in session if different if ($this->config->get('system.session.enabled', false) From f6d910f226be258c88479a2ac7cb67e89cdc09eb Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 21 Apr 2017 22:18:36 -0600 Subject: [PATCH 3/6] Added support for `showModular` option in `Pages::getList()` --- system/blueprints/config/system.yaml | 3 ++- system/src/Grav/Common/Page/Pages.php | 15 +++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/system/blueprints/config/system.yaml b/system/blueprints/config/system.yaml index 2badbf131..7c6b0fb0f 100644 --- a/system/blueprints/config/system.yaml +++ b/system/blueprints/config/system.yaml @@ -12,12 +12,13 @@ form: fields: home.alias: type: pages - size: medium + size: large classes: fancy label: PLUGIN_ADMIN.HOME_PAGE show_all: false show_modular: false show_root: false + show_slug: true help: PLUGIN_ADMIN.HOME_PAGE_HELP home.hide_in_urls: diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index 279d7024d..457701ce3 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -552,14 +552,17 @@ class Pages * Get list of route/title of all pages. * * @param Page $current - * @param int $level + * @param int $level * @param bool $rawRoutes * + * @param bool $showAll + * @param bool $showFullpath + * @param bool $showSlug + * @param bool $showModular + * @param bool $limitLevels * @return array - * - * @throws \RuntimeException */ - public function getList(Page $current = null, $level = 0, $rawRoutes = false, $showAll = true, $showFullpath = false, $showSlug = false, $limitLevels = false) + public function getList(Page $current = null, $level = 0, $rawRoutes = false, $showAll = true, $showFullpath = false, $showSlug = false, $showModular = false, $limitLevels = false) { if (!$current) { if ($level) { @@ -594,8 +597,8 @@ class Pages if ($limitLevels == false || ($level+1 < $limitLevels)) { foreach ($current->children() as $next) { - if ($showAll || $next->routable()) { - $list = array_merge($list, $this->getList($next, $level + 1, $rawRoutes, $showAll, $showFullpath, $showSlug, $limitLevels)); + if ($showAll || $next->routable() || ($next->modular() && $showModular)) { + $list = array_merge($list, $this->getList($next, $level + 1, $rawRoutes, $showAll, $showFullpath, $showSlug, $showModular, $limitLevels)); } } } From 34281a14a40b74c2936dbcf00bb2aa0e9cc02820 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 21 Apr 2017 22:20:16 -0600 Subject: [PATCH 4/6] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5e51b27f..47439d9c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ 1. [](#bugfix) * Allow multiple calls to `Themes::initTheme()` without throwing errors * Fixed querystrings in root pages with multi-lang enabled [#1436](https://github.com/getgrav/grav/issues/1436) + * Allow support for `Pages::getList()` with `show_modular` option [#1080](https://github.com/getgrav/grav-plugin-admin/issues/1080) # v1.2.3 ## 04/19/2017 From e5a522a2fe81d3c0439b33525ed7d2592e8963b8 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 24 Apr 2017 15:00:31 -0600 Subject: [PATCH 5/6] Added `ignores` to install options for `Installer::sophisticatedInstall()` #1447 --- CHANGELOG.md | 2 ++ system/src/Grav/Common/GPM/Installer.php | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47439d9c6..b89d314d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # v1.2.4 ## 04/xx/2017 +1. [](#improved) + * Added optional ignores for `Installer::sophisticatedInstall()` [#1447](https://github.com/getgrav/grav/issues/1447) 1. [](#bugfix) * Allow multiple calls to `Themes::initTheme()` without throwing errors * Fixed querystrings in root pages with multi-lang enabled [#1436](https://github.com/getgrav/grav/issues/1436) diff --git a/system/src/Grav/Common/GPM/Installer.php b/system/src/Grav/Common/GPM/Installer.php index 0e6352147..1f8a2626e 100644 --- a/system/src/Grav/Common/GPM/Installer.php +++ b/system/src/Grav/Common/GPM/Installer.php @@ -58,6 +58,7 @@ class Installer 'sophisticated' => false, 'theme' => false, 'install_path' => '', + 'ignores' => [], 'exclude_checks' => [self::EXISTS, self::NOT_FOUND, self::IS_LINK] ]; @@ -134,7 +135,7 @@ class Installer self::moveInstall($extracted, $install_path); } } else { - self::sophisticatedInstall($extracted, $install_path); + self::sophisticatedInstall($extracted, $install_path, $options['ignores']); } Folder::delete($tmp); @@ -280,11 +281,11 @@ class Installer * * @return bool */ - public static function sophisticatedInstall($source_path, $install_path) + public static function sophisticatedInstall($source_path, $install_path, $ignores = []) { foreach (new \DirectoryIterator($source_path) as $file) { - if ($file->isLink() || $file->isDot()) { + if ($file->isLink() || $file->isDot() || in_array($file->getBasename(),$ignores)) { continue; } @@ -296,7 +297,7 @@ class Installer if ($file->getBasename() == 'bin') { foreach (glob($path . DS . '*') as $bin_file) { - @chmod($bin_file, 0755); + @chmod($bin_file, 0755); } } } else { From e4ffc8d3decf8a1d140a78d914a312a56e8702ef Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 24 Apr 2017 15:31:57 -0600 Subject: [PATCH 6/6] Prepare for release --- CHANGELOG.md | 2 +- system/defines.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b89d314d9..5e4599da1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # v1.2.4 -## 04/xx/2017 +## 04/24/2017 1. [](#improved) * Added optional ignores for `Installer::sophisticatedInstall()` [#1447](https://github.com/getgrav/grav/issues/1447) diff --git a/system/defines.php b/system/defines.php index 6e79ce7cf..156371ba2 100644 --- a/system/defines.php +++ b/system/defines.php @@ -8,7 +8,7 @@ // Some standard defines define('GRAV', true); -define('GRAV_VERSION', '1.2.3'); +define('GRAV_VERSION', '1.2.4'); define('GRAV_TESTING', false); define('DS', '/');