Upgrade to 3.0.3

This commit is contained in:
Bastian Allgeier
2019-03-05 10:55:03 +01:00
parent 8e3d86a590
commit 418db4b09b
40 changed files with 704 additions and 144 deletions

View File

@@ -2,6 +2,8 @@
namespace Kirby\Cms;
use Kirby\Toolkit\F;
/**
* The Pages collection contains
* any number and mixture of page objects
@@ -199,18 +201,33 @@ class Pages extends Collection
*/
public function findById($id)
{
$id = trim($id, '/');
$page = $this->get($id);
// remove trailing or leading slashes
$id = trim($id, '/');
// strip extensions from the id
if (strpos($id, '.') !== false) {
$info = pathinfo($id);
if ($info['dirname'] !== '.') {
$id = $info['dirname'] . '/' . $info['filename'];
} else {
$id = $info['filename'];
}
}
// try the obvious way
if ($page = $this->get($id)) {
return $page;
}
$multiLang = App::instance()->multilang();
if ($multiLang === true) {
$page = $this->findBy('slug', $id);
if ($multiLang === true && $page = $this->findBy('slug', $id)) {
return $page;
}
if (!$page) {
$start = is_a($this->parent, 'Kirby\Cms\Page') === true ? $this->parent->id() : '';
$page = $this->findByIdRecursive($id, $start, $multiLang);
}
$start = is_a($this->parent, 'Kirby\Cms\Page') === true ? $this->parent->id() : '';
$page = $this->findByIdRecursive($id, $start, $multiLang);
return $page;
}