Refactor the tree system

Each element of the tree now only has one parent, not a parent array.

- Creating an elements doesn't necessarily rely on an existing file
- Moving elements unregisters elements from the previous parent
- Moved some helpers to the builder instead of Entry
This commit is contained in:
Stéphane Goetz
2015-07-18 20:52:14 +02:00
parent 3235c49acd
commit aa5602a0fb
7 changed files with 210 additions and 134 deletions

View File

@ -11,8 +11,7 @@ class MarkdownPage extends \Todaymade\Daux\Format\Base\MarkdownPage
if ($this->title === 'index') {
$minimum_parent_dir_size = ($this->params['multilanguage']) ? 2 : 1;
if (count($this->file->getParents()) >= $minimum_parent_dir_size) {
$parents = $this->file->getParents();
$this->title = end($parents)->getTitle();
$this->title = $this->file->getParent()->getTitle();
} else {
$this->homepage = ($this->file->getName() === '_index');
$this->title = $this->params['title'];

View File

@ -107,7 +107,7 @@ class Template
'href' => $base_page . $link,
'class' => ($current_url === $link) ? 'active' : ''
];
} else if ($node instanceof Directory) {
} elseif ($node instanceof Directory) {
$link = ($path === '') ? $url : $path . '/' . $url;
$folder = [