mirror of
https://github.com/getgrav/grav.git
synced 2026-02-22 22:51:13 +01:00
Merge branch 'develop' into feature/gpm
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()]);
|
||||
@@ -1697,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user