From e4ff2ea39db83b0269982b6824467640a7a44b9d Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 25 Sep 2014 12:16:54 -0600 Subject: [PATCH 1/3] new visibile() and routable() filters to Collections --- system/src/Grav/Common/Page/Collection.php | 36 ++++++++++++++++++++++ system/src/Grav/Common/Page/Page.php | 9 ++---- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/system/src/Grav/Common/Page/Collection.php b/system/src/Grav/Common/Page/Collection.php index 9aed0e089..234047d91 100644 --- a/system/src/Grav/Common/Page/Collection.php +++ b/system/src/Grav/Common/Page/Collection.php @@ -192,4 +192,40 @@ class Collection extends Iterator public function currentPosition($path) { return array_search($path, array_keys($this->items)); } + + /** + * Creates new collection with only visible pages + * + * @return Collection The collection with only visible pages + */ + public function visible() + { + $visible = []; + + foreach ($this->items as $path => $slug) { + $page = $this->pages->get($path); + if ($page->visible()) { + $visible[$path] = $slug; + } + } + return new static($visible, $this->params, $this->pages); + } + + /** + * Creates new collection with only routable pages + * + * @return Collection The collection with only routable pages + */ + public function routable() + { + $routable = []; + + foreach (array_keys($this->items) as $path => $slug) { + $page = $this->pages->get($path); + if ($page->routable()) { + $routable[$path] = $slug; + } + } + return new static($routable, $this->params, $this->pages); + } } diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 1ca0c793f..3776df4cc 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -1650,17 +1650,14 @@ class Page $parent = $this->parent(); // Extract visible children from the parent page. - $visible = array(); + $list = array(); /** @var Page $page */ - foreach ($parent as $page) { + foreach ($parent->children()->visible() as $page) { if ($page->order()) { - $visible[$page->slug] = $page->path(); + $list[$page->slug] = $page->path(); } } - // List only visible pages. - $list = array_intersect($visible, $pages->sort($parent)); - // If page was moved, take it out of the list. if ($this->_action == 'move') { unset($list[$this->slug()]); From ac3b0ba3ec4422719d637d7042aca4e8ea91c581 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Thu, 25 Sep 2014 23:31:59 +0300 Subject: [PATCH 2/3] Fix saving page as a new type --- system/src/Grav/Common/Page/Page.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 3776df4cc..fe216dfc6 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -1694,6 +1694,13 @@ class Page Folder::copy($this->_original->path(), $this->path()); } + if ($this->name() != $this->_original->name()) { + $path = $this->path(); + if (is_file($path . '/' . $this->_original->name())) { + rename($path . '/' . $this->_original->name(), $path . '/' . $this->name()); + } + } + $this->_action = null; $this->_original = null; } From a6d46ebcd76ff1660ce908ba219ac5e2fde97817 Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Thu, 25 Sep 2014 15:34:29 -0700 Subject: [PATCH 3/3] Forcing 2 space indentation on all yaml files --- .editorconfig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.editorconfig b/.editorconfig index 808ae5806..685c06357 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,3 +11,8 @@ trim_trailing_whitespace = true insert_final_newline = true indent_style = space indent_size = 4 + +# 2 space indentation +[*.yaml, *.yml] +indent_style = space +indent_size = 2