Upgrade to 4.0.0
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Kirby\Cms\File;
|
||||
use Kirby\Cms\Files;
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return [
|
||||
@@ -18,6 +19,12 @@ return [
|
||||
'sort'
|
||||
],
|
||||
'props' => [
|
||||
/**
|
||||
* Filters pages by a query. Sorting will be disabled
|
||||
*/
|
||||
'query' => function (string|null $query = null) {
|
||||
return $query;
|
||||
},
|
||||
/**
|
||||
* Filters all files by template and also sets the template, which will be used for all uploads
|
||||
*/
|
||||
@@ -49,10 +56,17 @@ return [
|
||||
return $this->parentModel();
|
||||
},
|
||||
'files' => function () {
|
||||
$files = $this->parent->files()->template($this->template);
|
||||
if ($this->query !== null) {
|
||||
$files = $this->parent->query($this->query, Files::class) ?? new Files([]);
|
||||
} else {
|
||||
$files = $this->parent->files();
|
||||
}
|
||||
|
||||
// filter out all protected files
|
||||
$files = $files->filter('isReadable', true);
|
||||
// filter files by template
|
||||
$files = $files->template($this->template);
|
||||
|
||||
// filter out all protected and hidden files
|
||||
$files = $files->filter('isListable', true);
|
||||
|
||||
// search
|
||||
if ($this->search === true && empty($this->searchterm()) === false) {
|
||||
|
@@ -7,6 +7,9 @@ return [
|
||||
'headline',
|
||||
],
|
||||
'props' => [
|
||||
'icon' => function (string $icon = null) {
|
||||
return $icon;
|
||||
},
|
||||
'text' => function ($text = null) {
|
||||
return I18n::translate($text, $text);
|
||||
},
|
||||
@@ -25,6 +28,7 @@ return [
|
||||
],
|
||||
'toArray' => function () {
|
||||
return [
|
||||
'icon' => $this->icon,
|
||||
'label' => $this->headline,
|
||||
'text' => $this->text,
|
||||
'theme' => $this->theme
|
||||
|
@@ -20,7 +20,7 @@ return [
|
||||
return in_array($layout, $layouts) ? $layout : 'list';
|
||||
},
|
||||
/**
|
||||
* The size option controls the size of cards. By default cards are auto-sized and the cards grid will always fill the full width. With a size you can disable auto-sizing. Available sizes: `tiny`, `small`, `medium`, `large`, `huge`
|
||||
* The size option controls the size of cards. By default cards are auto-sized and the cards grid will always fill the full width. With a size you can disable auto-sizing. Available sizes: `tiny`, `small`, `medium`, `large`, `huge`, `full`
|
||||
*/
|
||||
'size' => function (string $size = 'auto') {
|
||||
return $size;
|
||||
|
@@ -39,6 +39,10 @@ return [
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->query !== null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->sortBy !== null) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
use Kirby\Cms\Blueprint;
|
||||
use Kirby\Cms\Page;
|
||||
use Kirby\Cms\Pages;
|
||||
use Kirby\Cms\Site;
|
||||
use Kirby\Exception\InvalidArgumentException;
|
||||
use Kirby\Toolkit\A;
|
||||
@@ -29,6 +30,12 @@ return [
|
||||
'create' => function ($create = null) {
|
||||
return $create;
|
||||
},
|
||||
/**
|
||||
* Filters pages by a query. Sorting will be disabled
|
||||
*/
|
||||
'query' => function (string|null $query = null) {
|
||||
return $query;
|
||||
},
|
||||
/**
|
||||
* Filters pages by their status. Available status settings: `draft`, `unlisted`, `listed`, `published`, `all`.
|
||||
*/
|
||||
@@ -43,11 +50,23 @@ return [
|
||||
|
||||
return $status;
|
||||
},
|
||||
/**
|
||||
* Filters the list by single template.
|
||||
*/
|
||||
'template' => function (string|array $template = null) {
|
||||
return $template;
|
||||
},
|
||||
/**
|
||||
* Filters the list by templates and sets template options when adding new pages to the section.
|
||||
*/
|
||||
'templates' => function ($templates = null) {
|
||||
return A::wrap($templates ?? $this->template);
|
||||
},
|
||||
/**
|
||||
* Excludes the selected templates.
|
||||
*/
|
||||
'templatesIgnore' => function ($templates = null) {
|
||||
return A::wrap($templates);
|
||||
}
|
||||
],
|
||||
'computed' => [
|
||||
@@ -64,13 +83,17 @@ return [
|
||||
return $parent;
|
||||
},
|
||||
'pages' => function () {
|
||||
$pages = match ($this->status) {
|
||||
'draft' => $this->parent->drafts(),
|
||||
'listed' => $this->parent->children()->listed(),
|
||||
'published' => $this->parent->children(),
|
||||
'unlisted' => $this->parent->children()->unlisted(),
|
||||
default => $this->parent->childrenAndDrafts()
|
||||
};
|
||||
if ($this->query !== null) {
|
||||
$pages = $this->parent->query($this->query, Pages::class) ?? new Pages([]);
|
||||
} else {
|
||||
$pages = match ($this->status) {
|
||||
'draft' => $this->parent->drafts(),
|
||||
'listed' => $this->parent->children()->listed(),
|
||||
'published' => $this->parent->children(),
|
||||
'unlisted' => $this->parent->children()->unlisted(),
|
||||
default => $this->parent->childrenAndDrafts()
|
||||
};
|
||||
}
|
||||
|
||||
// filters pages that are protected and not in the templates list
|
||||
// internal `filter()` method used instead of foreach loop that previously included `unset()`
|
||||
@@ -78,13 +101,26 @@ return [
|
||||
// also it has been tested that there is no performance difference
|
||||
// even in 0.1 seconds on 100k virtual pages
|
||||
$pages = $pages->filter(function ($page) {
|
||||
// remove all protected pages
|
||||
if ($page->isReadable() === false) {
|
||||
// remove all protected and hidden pages
|
||||
if ($page->isListable() === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$intendedTemplate = $page->intendedTemplate()->name();
|
||||
|
||||
// filter by all set templates
|
||||
if ($this->templates && in_array($page->intendedTemplate()->name(), $this->templates) === false) {
|
||||
if (
|
||||
$this->templates &&
|
||||
in_array($intendedTemplate, $this->templates) === false
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// exclude by all ignored templates
|
||||
if (
|
||||
$this->templatesIgnore &&
|
||||
in_array($intendedTemplate, $this->templatesIgnore) === true
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -216,6 +252,11 @@ return [
|
||||
$templates = $this->kirby()->blueprints();
|
||||
}
|
||||
|
||||
// excludes ignored templates
|
||||
if ($templatesIgnore = $this->templatesIgnore) {
|
||||
$templates = array_diff($templates, $templatesIgnore);
|
||||
}
|
||||
|
||||
// convert every template to a usable option array
|
||||
// for the template select box
|
||||
foreach ($templates as $template) {
|
||||
|
Reference in New Issue
Block a user