Upgrade to 3.3.0

This commit is contained in:
Bastian Allgeier
2019-11-05 09:35:58 +01:00
parent 447a9dd266
commit a431716732
186 changed files with 3068 additions and 1458 deletions

View File

@@ -32,6 +32,9 @@ return [
'database' => 'Kirby\Database\Database',
'db' => 'Kirby\Database\Db',
// exceptions
'errorpageexception' => 'Kirby\Exception\ErrorPageException',
// http classes
'cookie' => 'Kirby\Http\Cookie',
'header' => 'Kirby\Http\Header',

View File

@@ -7,7 +7,7 @@ return function () {
// csrf token check
if ($auth->type() === 'session' && $auth->csrf() === false) {
throw new PermissionException('Unauthenticated', 403);
throw new PermissionException('Unauthenticated');
}
// get user from session or basic auth
@@ -19,5 +19,5 @@ return function () {
return $user;
}
throw new PermissionException('Unauthenticated', 403);
throw new PermissionException('Unauthenticated');
};

View File

@@ -27,8 +27,7 @@ return [
*/
'languages' => [
'model' => 'language',
'type' => 'Kirby\Cms\Languages',
'view' => 'compact'
'type' => 'Kirby\Cms\Languages'
],
/**

View File

@@ -48,13 +48,16 @@ return [
return $file->next();
},
'nextWithTemplate' => function (File $file) {
$files = $file->templateSiblings()->sortBy('sort', 'asc');
$files = $file->templateSiblings()->sortBy('sort', 'asc', 'filename', 'asc');
$index = $files->indexOf($file);
return $files->nth($index + 1);
},
'niceSize' => function (File $file) {
return $file->niceSize();
},
'options' => function (File $file) {
return $file->permissions()->toArray();
return $file->panelOptions();
},
'panelIcon' => function (File $file) {
return $file->panelIcon();
@@ -69,32 +72,23 @@ return [
return $file->prev();
},
'prevWithTemplate' => function (File $file) {
$files = $file->templateSiblings()->sortBy('sort', 'asc');
$files = $file->templateSiblings()->sortBy('sort', 'asc', 'filename', 'asc');
$index = $files->indexOf($file);
return $files->nth($index - 1);
},
'niceSize' => function (File $file) {
return $file->niceSize();
},
'panelIcon' => function (File $file) {
return $file->panelIcon();
},
'panelImage' => function (File $file) {
return $file->panelImage();
},
'parent' => function (File $file) {
return $file->parent();
},
'parents' => function (File $file) {
return $file->parents()->flip();
},
'template' => function (File $file) {
return $file->template();
},
'size' => function (File $file) {
return $file->size();
},
'template' => function (File $file) {
return $file->template();
},
'thumbs' => function ($file) {
if ($file->isResizable() === false) {
return null;

View File

@@ -31,12 +31,14 @@ return [
],
'type' => 'Kirby\Cms\Language',
'views' => [
'compact' => [
'default' => [
'code',
'default',
'direction',
'locale',
'name',
'rules',
'direction'
'url'
]
]
];

View File

@@ -27,7 +27,7 @@ return [
return $page->errors();
},
'files' => function (Page $page) {
return $page->files()->sortBy('sort', 'asc');
return $page->files()->sortBy('sort', 'asc', 'filename', 'asc');
},
'hasChildren' => function (Page $page) {
return $page->hasChildren();
@@ -56,7 +56,7 @@ return [
return $page->num();
},
'options' => function (Page $page) {
return $page->permissions()->toArray();
return $page->panelOptions(['preview']);
},
'panelIcon' => function (Page $page) {
return $page->panelIcon();

View File

@@ -24,7 +24,7 @@ return [
return $site->drafts();
},
'files' => function (Site $site) {
return $site->files()->sortBy('sort', 'asc');
return $site->files()->sortBy('sort', 'asc', 'filename', 'asc');
},
'options' => function (Site $site) {
return $site->permissions()->toArray();

View File

@@ -98,7 +98,7 @@ return [
'isInstalled',
'isLocal',
'kirbytext',
'languages' => 'compact',
'languages',
'license',
'multilang',
'requirements',

View File

@@ -24,7 +24,7 @@ return [
return $user->email();
},
'files' => function (User $user) {
return $user->files()->sortBy('sort', 'asc');
return $user->files()->sortBy('sort', 'asc', 'filename', 'asc');
},
'id' => function (User $user) {
return $user->id();
@@ -39,7 +39,7 @@ return [
return $user->next();
},
'options' => function (User $user) {
return $user->permissions()->toArray();
return $user->panelOptions();
},
'permissions' => function (User $user) {
return $user->role()->permissions()->toArray();

View File

@@ -27,7 +27,7 @@ return [
'pattern' => '(:all)/files',
'method' => 'GET',
'action' => function (string $path) {
return $this->parent($path)->files()->sortBy('sort', 'asc');
return $this->parent($path)->files()->sortBy('sort', 'asc', 'filename', 'asc');
}
],
[

View File

@@ -6,6 +6,7 @@ use Kirby\Cms\Filename;
use Kirby\Cms\FileVersion;
use Kirby\Cms\Template;
use Kirby\Data\Data;
use Kirby\Http\Server;
use Kirby\Image\Darkroom;
use Kirby\Text\Markdown;
use Kirby\Text\SmartyPants;
@@ -26,6 +27,30 @@ return [
return $url;
},
/**
* Object and variable dumper
* to help with debugging.
*
* @param \Kirby\Cms\App $kirby Kirby instance
* @param mixed $variable
* @param bool $echo
* @return string
*/
'dump' => function (App $kirby, $variable, bool $echo = true) {
if (Server::cli() === true) {
$output = print_r($variable, true) . PHP_EOL;
} else {
$output = '<pre>' . print_r($variable, true) . '</pre>';
}
if ($echo === true) {
echo $output;
}
return $output;
},
/**
* Modify URLs for file objects
*

View File

@@ -99,10 +99,13 @@ return [
$field = $this->field();
return $field->filepicker([
'query' => $field->query(),
'image' => $field->image(),
'info' => $field->info(),
'text' => $field->text()
'image' => $field->image(),
'info' => $field->info(),
'limit' => $field->limit(),
'page' => $this->requestQuery('page'),
'query' => $field->query(),
'search' => $this->requestQuery('search'),
'text' => $field->text()
]);
}
],

View File

@@ -15,7 +15,8 @@ return [
'text' => function () {
if ($text = $this->text) {
$text = $this->model()->toString($text);
return kirbytext($text);
$text = $this->kirby()->kirbytext($text);
return $text;
}
}
],

View File

@@ -1,40 +1,14 @@
<?php
use Kirby\Cms\FilePicker;
return [
'methods' => [
'filepicker' => function (array $params = []) {
// fetch the parent model
$model = $this->model();
$params['model'] = $this->model();
// find the right default query
if (empty($params['query']) === false) {
$query = $params['query'];
} elseif (is_a($model, 'Kirby\Cms\File') === true) {
$query = 'file.siblings';
} else {
$query = $model::CLASS_ALIAS . '.files';
}
// fetch all files for the picker
$files = $model->query($query, 'Kirby\Cms\Files');
$data = [];
// prepare the response for each file
foreach ($files as $index => $file) {
if (empty($params['map']) === false) {
$data[] = $params['map']($file);
} else {
$data[] = $file->panelPickerData([
'image' => $params['image'] ?? [],
'info' => $params['info'] ?? false,
'model' => $model,
'text' => $params['text'] ?? '{{ file.filename }}',
]);
}
}
return $data;
return (new FilePicker($params))->toArray();
}
]
];

View File

@@ -1,49 +1,14 @@
<?php
use Kirby\Cms\PagePicker;
return [
'methods' => [
'pagepicker' => function (array $params = []) {
$query = $params['query'] ?? null;
$model = $this->model();
$site = $this->kirby()->site();
// inject the current model
$params['model'] = $this->model();
if ($query) {
$pages = $model->query($query, 'Kirby\Cms\Pages');
$self = null;
} else {
if (!$parent = $site->find($params['parent'] ?? null)) {
$parent = $site;
}
$pages = $parent->children();
$self = [
'id' => $parent->id() == '' ? null : $parent->id(),
'title' => $parent->title()->value(),
'parent' => is_a($parent->parent(), 'Kirby\Cms\Page') === true ? $parent->parent()->id() : null,
];
}
$children = [];
foreach ($pages as $index => $page) {
if ($page->isReadable() === true) {
if (empty($params['map']) === false) {
$children[] = $params['map']($page);
} else {
$children[] = $page->panelPickerData([
'image' => $params['image'] ?? [],
'info' => $params['info'] ?? false,
'model' => $model,
'text' => $params['text'] ?? null,
]);
}
}
}
return [
'model' => $self,
'pages' => $children
];
return (new PagePicker($params))->toArray();
}
]
];

View File

@@ -53,6 +53,13 @@ return [
return $query;
},
/**
* Enable/disable the search field in the picker
*/
'search' => function (bool $search = true) {
return $search;
},
/**
* Main text for each item
*/

View File

@@ -1,44 +1,13 @@
<?php
use Kirby\Cms\UserPicker;
return [
'methods' => [
'userpicker' => function (array $params = []) {
$params['model'] = $this->model();
// fetch the parent model
$model = $this->model();
// find the right default query
if (empty($params['query']) === false) {
$query = $params['query'];
} elseif (is_a($model, 'Kirby\Cms\User') === true) {
$query = 'user.siblings';
} else {
$query = 'kirby.users';
}
// fetch all users for the picker
$users = $model->query($query, 'Kirby\Cms\Users');
$data = [];
if (!$users) {
return [];
}
// prepare the response for each user
foreach ($users->sortBy('username', 'asc') as $index => $user) {
if (empty($params['map']) === false) {
$data[] = $params['map']($user);
} else {
$data[] = $user->panelPickerData([
'image' => $params['image'] ?? [],
'info' => $params['info'] ?? false,
'model' => $model,
'text' => $params['text'] ?? '{{ user.username }}',
]);
}
}
return $data;
return (new UserPicker($params))->toArray();
}
]
];

View File

@@ -43,6 +43,13 @@ return [
return $size;
},
/**
* Optionally include subpages of pages
*/
'subpages' => function (bool $subpages = true) {
return $subpages;
},
'value' => function ($value = null) {
return $this->toPages($value);
},
@@ -86,11 +93,15 @@ return [
$field = $this->field();
return $field->pagepicker([
'image' => $field->image(),
'info' => $field->info(),
'parent' => $this->requestQuery('parent'),
'query' => $field->query(),
'text' => $field->text()
'image' => $field->image(),
'info' => $field->info(),
'limit' => $field->limit(),
'page' => $this->requestQuery('page'),
'parent' => $this->requestQuery('parent'),
'query' => $field->query(),
'search' => $this->requestQuery('search'),
'subpages' => $field->subpages(),
'text' => $field->text()
]);
}
]

View File

@@ -84,6 +84,10 @@ return [
return $this->rows($this->value);
},
'fields' => function () {
if (empty($this->fields) === true) {
throw new Exception('Please provide some fields for the structure');
}
return $this->form()->fields()->toArray();
},
'columns' => function () {

View File

@@ -75,17 +75,20 @@ return [
$field = $this->field();
return $field->userpicker([
'query' => $field->query(),
'image' => $field->image(),
'info' => $field->info(),
'text' => $field->text()
'image' => $field->image(),
'info' => $field->info(),
'limit' => $field->limit(),
'page' => $this->requestQuery('page'),
'query' => $field->query(),
'search' => $this->requestQuery('search'),
'text' => $field->text()
]);
}
]
];
},
'save' => function ($value = null) {
return A::pluck($value, 'email');
return A::pluck($value, 'id');
},
'validations' => [
'max',

View File

@@ -5,7 +5,6 @@ use Kirby\Cms\Asset;
use Kirby\Cms\Html;
use Kirby\Cms\Response;
use Kirby\Cms\Url;
use Kirby\Http\Server;
use Kirby\Toolkit\Escape;
use Kirby\Toolkit\F;
use Kirby\Toolkit\I18n;
@@ -55,7 +54,7 @@ function collection(string $name)
* Checks / returns a CSRF token
*
* @param string $check Pass a token here to compare it to the one in the session
* @return string|boolean Either the token or a boolean check result
* @return string|bool Either the token or a boolean check result
*/
function csrf(string $check = null)
{
@@ -89,7 +88,7 @@ function csrf(string $check = null)
* @param string|array $options Pass an array of attributes for the link tag or a media attribute string
* @return string|null
*/
function css($url, $options = null)
function css($url, $options = null): ?string
{
if (is_array($url) === true) {
$links = array_map(function ($url) use ($options) {
@@ -121,27 +120,33 @@ function css($url, $options = null)
return '<link ' . attr($attr) . '>';
}
/**
* Triggers a deprecation warning if debug mode is active
*
* @param string $message
* @return bool Whether the warning was triggered
*/
function deprecated(string $message): bool
{
if (App::instance()->option('debug') === true) {
return trigger_error($message, E_USER_DEPRECATED) === true;
}
return false;
}
/**
* Simple object and variable dumper
* to help with debugging.
*
* @param mixed $variable
* @param boolean $echo
* @param bool $echo
* @return string
*/
function dump($variable, bool $echo = true): string
{
if (Server::cli() === true) {
$output = print_r($variable, true) . PHP_EOL;
} else {
$output = '<pre>' . print_r($variable, true) . '</pre>';
}
if ($echo === true) {
echo $output;
}
return $output;
$kirby = App::instance();
return $kirby->component('dump')($kirby, $variable, $echo);
}
/**
@@ -159,10 +164,10 @@ function e($condition, $value, $alternative = null)
/**
* Escape context specific output
*
* @param string $string Untrusted data
* @param string $context Location of output
* @param boolean $strict Whether to escape an extended set of characters (HTML attributes only)
* @return string Escaped data
* @param string $string Untrusted data
* @param string $context Location of output
* @param bool $strict Whether to escape an extended set of characters (HTML attributes only)
* @return string Escaped data
*/
function esc($string, $context = 'html', $strict = false)
{
@@ -177,9 +182,9 @@ function esc($string, $context = 'html', $strict = false)
/**
* Shortcut for $kirby->request()->get()
*
* @param mixed $key The key to look for. Pass false or null to return the entire request array.
* @param mixed $default Optional default value, which should be returned if no element has been found
* @return mixed
* @param mixed $key The key to look for. Pass false or null to return the entire request array.
* @param mixed $default Optional default value, which should be returned if no element has been found
* @return mixed
*/
function get($key = null, $default = null)
{
@@ -206,7 +211,7 @@ function gist(string $url, string $file = null): string
* Urls can be relative or absolute.
*
* @param string $url
* @param integer $code
* @param int $code
* @return void
*/
function go(string $url = null, int $code = 302)
@@ -348,9 +353,9 @@ function invalid(array $data = [], array $rules = [], array $messages = [])
*
* @param string|array $url
* @param string|array $options
* @return void
* @return string|null
*/
function js($url, $options = null)
function js($url, $options = null): ?string
{
if (is_array($url) === true) {
$scripts = array_map(function ($url) use ($options) {
@@ -589,7 +594,7 @@ function r($condition, $value, $alternative = null)
* by the defined step
*
* @param string $date
* @param integer $step
* @param int $step
* @return string|null
*/
function timestamp(string $date = null, int $step = null): ?string
@@ -671,7 +676,7 @@ function smartypants(string $text = null): string
*
* @param string|array $name
* @param array|object $data
* @param boolean $return
* @param bool $return
* @return string
*/
function snippet($name, $data = [], bool $return = false)
@@ -693,11 +698,20 @@ function snippet($name, $data = [], bool $return = false)
* Includes an SVG file by absolute or
* relative file path.
*
* @param string $file
* @return string
* @param string|\Kirby\Cms\File $file
* @return string|false
*/
function svg(string $file)
function svg($file)
{
// support for Kirby's file objects
if (is_a($file, 'Kirby\Cms\File') === true && $file->extension() === 'svg') {
return $file->read();
}
if (is_string($file) === false) {
return false;
}
$extension = F::extension($file);
// check for valid svg files
@@ -721,9 +735,9 @@ function svg(string $file)
/**
* Returns translate string for key from translation file
*
* @param string|array $key
* @param string|null $fallback
* @return mixed
* @param string|array $key
* @param string|null $fallback
* @return mixed
*/
function t($key, string $fallback = null)
{
@@ -733,9 +747,9 @@ function t($key, string $fallback = null)
/**
* Translates a count
*
* @param string|array $key
* @param int $count
* @return mixed
* @param string|array $key
* @param int $count
* @return mixed
*/
function tc($key, int $count)
{
@@ -825,7 +839,7 @@ function video(string $url, array $options = [], array $attr = []): string
*/
function vimeo(string $url, array $options = [], array $attr = []): string
{
return Html::video($url, $options, $attr);
return Html::vimeo($url, $options, $attr);
}
/**
@@ -851,5 +865,5 @@ function widont(string $string = null): string
*/
function youtube(string $url, array $options = [], array $attr = []): string
{
return Html::video($url, $options, $attr);
return Html::youtube($url, $options, $attr);
}

View File

@@ -28,7 +28,7 @@ return function (App $app) {
* Converts the field value into a proper boolean and inverts it
*
* @param \Kirby\Cms\Field $field
* @return boolean
* @return bool
*/
'isFalse' => function (Field $field): bool {
return $field->toBool() === false;
@@ -38,7 +38,7 @@ return function (App $app) {
* Converts the field value into a proper boolean
*
* @param \Kirby\Cms\Field $field
* @return boolean
* @return bool
*/
'isTrue' => function (Field $field): bool {
return $field->toBool() === true;
@@ -49,7 +49,7 @@ return function (App $app) {
*
* @param string $validator
* @param mixed ...$arguments A list of optional validator arguments
* @return boolean
* @return bool
*/
'isValid' => function (Field $field, string $validator, ...$arguments): bool {
return V::$validator($field->value, ...$arguments);
@@ -193,7 +193,7 @@ return function (App $app) {
* @param \Kirby\Cms\Field $field
* @return \Kirby\Cms\Page|null
*/
'toPage' => function (Field $field) use ($app) {
'toPage' => function (Field $field) {
return $field->toPages()->first();
},
@@ -254,7 +254,7 @@ return function (App $app) {
* @param \Kirby\Cms\Field $field
* @return \Kirby\Cms\User|null
*/
'toUser' => function (Field $field) use ($app) {
'toUser' => function (Field $field) {
return $field->toUsers()->first();
},
@@ -305,7 +305,7 @@ return function (App $app) {
*
* @param \Kirby\Cms\Field $field
* @param int $cahrs
* @param boolean $strip
* @param bool $strip
* @param string $rep
* @return \Kirby\Cms\Field
*/
@@ -325,6 +325,17 @@ return function (App $app) {
return $field;
},
/**
* Converts all line breaks in the field content to `<br>` tags.
*
* @param \Kirby\Cms\Field $field
* @return \Kirby\Cms\Field
*/
'nl2br' => function (Field $field) {
$field->value = nl2br($field->value, false);
return $field;
},
/**
* Converts the field content from Markdown/Kirbytext to valid HTML
*
@@ -372,6 +383,23 @@ return function (App $app) {
return $field;
},
/**
* Strips all block-level HTML elements from the field value,
* it can be safely placed inside of other inline elements
* without the risk of breaking the HTML structure.
*
* @param \Kirby\Cms\Field $field
* @return \Kirby\Cms\Field
*/
'inline' => function (Field $field) {
// List of valid inline elements taken from: https://developer.mozilla.org/de/docs/Web/HTML/Inline_elemente
// Obsolete elements, script tags, image maps and form elements have
// been excluded for safety reasons and as they are most likely not
// needed in most cases.
$field->value = strip_tags($field->value, '<b><i><small><abbr><cite><code><dfn><em><kbd><strong><samp><var><a><bdo><br><img><q><span><sub><sup>');
return $field;
},
/**
* Converts the field content to lowercase
*

View File

@@ -11,18 +11,11 @@ return [
return $roots['kirby'] . '/i18n';
},
'i18n:translations' => function (array $roots) {
return $roots['translations'];
return $roots['i18n'] . '/translations';
},
'i18n:rules' => function (array $roots) {
return $roots['i18n'] . '/rules';
},
/**
* @deprecated 3.2.0 Use `i18n:translations` instead
* @TODO move logic over to i18n:translations before removing
*/
'translations' => function (array $roots) {
return $roots['i18n'] . '/translations';
},
// index
'index' => function (array $roots) {

View File

@@ -1,12 +1,12 @@
<?php
use Kirby\Cms\LanguageRoutes;
use Kirby\Cms\Media;
use Kirby\Cms\Panel;
use Kirby\Cms\PanelPlugins;
use Kirby\Cms\PluginAssets;
use Kirby\Http\Response\Redirect;
use Kirby\Http\Router\Route;
use Kirby\Toolkit\F;
use Kirby\Toolkit\Str;
return function ($kirby) {
@@ -63,7 +63,7 @@ return function ($kirby) {
[
'pattern' => $media . '/plugins/(:any)/(:any)/(:all).(css|gif|js|jpg|png|svg|webp|woff2|woff)',
'env' => 'media',
'action' => function (string $provider, string $pluginName, string $filename, string $extension) use ($kirby) {
'action' => function (string $provider, string $pluginName, string $filename, string $extension) {
return PluginAssets::resolve($provider . '/' . $pluginName, $filename . '.' . $extension);
}
],
@@ -102,7 +102,7 @@ return function ($kirby) {
[
'pattern' => $media . '/assets/(:all)/(:any)/(:any)',
'env' => 'media',
'action' => function ($path, $hash, $filename) use ($kirby) {
'action' => function ($path, $hash, $filename) {
return Media::thumb($path, $hash, $filename);
}
]
@@ -110,73 +110,7 @@ return function ($kirby) {
// Multi-language setup
if ($kirby->multilang() === true) {
// Multi-language home
$after[] = [
'pattern' => '',
'method' => 'ALL',
'env' => 'site',
'action' => function () use ($kirby) {
$home = $kirby->site()->homePage();
// language detection on the home page with / as URL
if ($home && $kirby->url() !== $home->url()) {
if ($kirby->option('languages.detect') === true) {
return $kirby
->response()
->redirect($kirby->detectedLanguage()->url());
} else {
return $kirby
->response()
->redirect($kirby->site()->url());
}
// default home page
} else {
return $kirby->defaultLanguage()->router()->call();
}
}
];
foreach ($kirby->languages() as $language) {
$after[] = [
'pattern' => trim($language->pattern() . '/(:all?)', '/'),
'method' => 'ALL',
'env' => 'site',
'action' => function ($path = null) use ($kirby, $language) {
return $language->router()->call($path);
}
];
}
// fallback route for unprefixed default language URLs.
$after[] = [
'pattern' => '(:all)',
'method' => 'ALL',
'env' => 'site',
'action' => function (string $path) use ($kirby) {
// check for content representations or files
$extension = F::extension($path);
// try to redirect prefixed pages
if (empty($extension) === true && $page = $kirby->page($path)) {
$url = $kirby->request()->url([
'query' => null,
'params' => null,
'fragment' => null
]);
if ($url->toString() !== $page->url()) {
return $kirby
->response()
->redirect($page->url());
}
}
return $kirby->defaultLanguage()->router()->call($path);
}
];
$after = LanguageRoutes::create($kirby);
} else {
// Single-language home

View File

@@ -15,6 +15,12 @@ return [
'parent',
],
'props' => [
/**
* Enables/disables reverse sorting
*/
'flip' => function (bool $flip = false) {
return $flip;
},
/**
* Image options to control the source and look of file previews
*/
@@ -83,6 +89,11 @@ return [
$files = $files->sortBy('sort', 'asc', 'filename', 'asc');
}
// flip
if ($this->flip === true) {
$files = $files->flip();
}
// apply the default pagination
$files = $files->paginate([
'page' => $this->page,
@@ -168,6 +179,10 @@ return [
return false;
}
if ($this->flip === true) {
return false;
}
return true;
},
'upload' => function () {

View File

@@ -19,7 +19,6 @@ return [
if ($this->text) {
$text = $this->model()->toString($this->text);
$text = $this->kirby()->kirbytext($text);
return $text;
}
},

View File

@@ -14,7 +14,9 @@ return [
'computed' => [
'help' => function () {
if ($this->help) {
return $this->model()->toString($this->help);
$help = $this->model()->toString($this->help);
$help = $this->kirby()->kirbytext($help);
return $help;
}
}
]

View File

@@ -14,7 +14,7 @@ return [
* Sets the default page for the pagination. This will overwrite default pagination.
*/
'page' => function (int $page = null) {
return get('page', $page ?? 1);
return get('page', $page);
},
],
'methods' => [

View File

@@ -20,7 +20,13 @@ return [
* Optional array of templates that should only be allowed to add.
*/
'create' => function ($add = null) {
return A::wrap($add);
return $add;
},
/**
* Enables/disables reverse sorting
*/
'flip' => function (bool $flip = false) {
return $flip;
},
/**
* Image options to control the source and look of page previews
@@ -122,6 +128,11 @@ return [
$pages = $pages->sortBy(...$pages::sortArgs($this->sortBy));
}
// flip
if ($this->flip === true) {
$pages = $pages->flip();
}
// pagination
$pages = $pages->paginate([
'page' => $this->page,
@@ -188,6 +199,10 @@ return [
];
},
'add' => function () {
if ($this->create === false) {
return false;
}
if (in_array($this->status, ['draft', 'all']) === false) {
return false;
}
@@ -222,13 +237,17 @@ return [
return false;
}
if ($this->flip === true) {
return false;
}
return true;
}
],
'methods' => [
'blueprints' => function () {
$blueprints = [];
$templates = empty($this->create) === false ? $this->create : $this->templates;
$templates = empty($this->create) === false ? A::wrap($this->create) : $this->templates;
if (empty($templates) === true) {
$templates = $this->kirby()->blueprints();

View File

@@ -98,7 +98,6 @@ return [
'linkclass',
'rel',
'target',
'text',
'title',
'width'
],