Update Kirby and dependencies

This commit is contained in:
Paul Nicoué 2022-08-31 15:02:43 +02:00
parent 503b339974
commit 399fa20902
439 changed files with 66915 additions and 64442 deletions

View file

@ -0,0 +1,36 @@
<?php
use Kirby\Toolkit\I18n;
return [
'props' => [
/**
* Image options to control the source and look of preview
*/
'image' => function ($image = null) {
return $image ?? [];
},
/**
* Optional info text setup. Info text is shown on the right (lists, cardlets) or below (cards) the title.
*/
'info' => function ($info = null) {
return I18n::translate($info, $info);
},
/**
* Setup for the main text in the list or cards. By default this will display the title.
*/
'text' => function ($text = '{{ model.title }}') {
return I18n::translate($text, $text);
}
],
'methods' => [
'link' => function () {
$modelLink = $this->model->panel()->url(true);
$parentLink = $this->parent->panel()->url(true);
if ($modelLink !== $parentLink) {
return $parentLink;
}
}
]
];

View file

@ -3,19 +3,19 @@
use Kirby\Toolkit\I18n;
return [
'props' => [
/**
* Sets the text for the empty state box
*/
'empty' => function ($empty = null) {
return I18n::translate($empty, $empty);
}
],
'computed' => [
'empty' => function () {
if ($this->empty) {
return $this->model()->toSafeString($this->empty);
}
}
]
'props' => [
/**
* Sets the text for the empty state box
*/
'empty' => function ($empty = null) {
return I18n::translate($empty, $empty);
}
],
'computed' => [
'empty' => function () {
if ($this->empty) {
return $this->model()->toSafeString($this->empty);
}
}
]
];

View file

@ -1,34 +1,42 @@
<?php
use Kirby\Cms\Helpers;
use Kirby\Toolkit\I18n;
return [
'props' => [
/**
* The headline for the section. This can be a simple string or a template with additional info from the parent page.
* @todo deprecate in 3.7
*/
'headline' => function ($headline = null) {
return I18n::translate($headline, $headline);
},
/**
* label is the new official replacement for headline
*/
'label' => function ($label = null) {
return I18n::translate($label, $label);
}
],
'computed' => [
'headline' => function () {
if ($this->headline) {
return $this->model()->toString($this->headline);
}
'props' => [
/**
* The headline for the section. This can be a simple string or a template with additional info from the parent page.
* @todo remove in 3.9.0
*/
'headline' => function ($headline = null) {
// TODO: add deprecation notive in 3.8.0
// if ($headline !== null) {
// Helpers::deprecated('`headline` prop for sections has been deprecated and will be removed in Kirby 3.9.0. Use `label` instead.');
// }
if ($this->label) {
return $this->model()->toString($this->label);
}
return I18n::translate($headline, $headline);
},
/**
* The label for the section. This can be a simple string or
* a template with additional info from the parent page.
* Replaces the `headline` prop.
*/
'label' => function ($label = null) {
return I18n::translate($label, $label);
}
],
'computed' => [
'headline' => function () {
if ($this->headline) {
return $this->model()->toString($this->headline);
}
return ucfirst($this->name);
}
]
if ($this->label) {
return $this->model()->toString($this->label);
}
return ucfirst($this->name);
}
]
];

View file

@ -3,21 +3,21 @@
use Kirby\Toolkit\I18n;
return [
'props' => [
/**
* Sets the help text
*/
'help' => function ($help = null) {
return I18n::translate($help, $help);
}
],
'computed' => [
'help' => function () {
if ($this->help) {
$help = $this->model()->toSafeString($this->help);
$help = $this->kirby()->kirbytext($help);
return $help;
}
}
]
'props' => [
/**
* Sets the help text
*/
'help' => function ($help = null) {
return I18n::translate($help, $help);
}
],
'computed' => [
'help' => function () {
if ($this->help) {
$help = $this->model()->toSafeString($this->help);
$help = $this->kirby()->kirbytext($help);
return $help;
}
}
]
];

View file

@ -1,14 +1,129 @@
<?php
use Kirby\Toolkit\I18n;
use Kirby\Toolkit\Str;
return [
'props' => [
/**
* Section layout.
* Available layout methods: `list`, `cardlets`, `cards`.
*/
'layout' => function (string $layout = 'list') {
$layouts = ['list', 'cardlets', 'cards'];
return in_array($layout, $layouts) ? $layout : 'list';
}
]
'props' => [
/**
* Columns config for `layout: table`
*/
'columns' => function (array $columns = null) {
return $columns ?? [];
},
/**
* Section layout.
* Available layout methods: `list`, `cardlets`, `cards`, `table`.
*/
'layout' => function (string $layout = 'list') {
$layouts = ['list', 'cardlets', 'cards', 'table'];
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`
*/
'size' => function (string $size = 'auto') {
return $size;
},
],
'computed' => [
'columns' => function () {
$columns = [];
if ($this->layout !== 'table') {
return [];
}
if ($this->image !== false) {
$columns['image'] = [
'label' => ' ',
'mobile' => true,
'type' => 'image',
'width' => 'var(--table-row-height)'
];
}
if ($this->text) {
$columns['title'] = [
'label' => I18n::translate('title'),
'mobile' => true,
'type' => 'url',
];
}
if ($this->info) {
$columns['info'] = [
'label' => I18n::translate('info'),
'type' => 'text',
];
}
foreach ($this->columns as $columnName => $column) {
if ($column === true) {
$column = [];
}
if ($column === false) {
continue;
}
// fallback for labels
$column['label'] ??= Str::ucfirst($columnName);
// make sure to translate labels
$column['label'] = I18n::translate($column['label'], $column['label']);
// keep the original column name as id
$column['id'] = $columnName;
// add the custom column to the array with a key that won't
// override the system columns
$columns[$columnName . 'Cell'] = $column;
}
if ($this->type === 'pages') {
$columns['flag'] = [
'label' => ' ',
'mobile' => true,
'type' => 'flag',
'width' => 'var(--table-row-height)',
];
}
return $columns;
},
],
'methods' => [
'columnsValues' => function (array $item, $model) {
$item['title'] = [
// override toSafeString() coming from `$item`
// because the table cells don't use v-html
'text' => $model->toString($this->text),
'href' => $model->panel()->url(true)
];
if ($this->info) {
// override toSafeString() coming from `$item`
// because the table cells don't use v-html
$item['info'] = $model->toString($this->info);
}
foreach ($this->columns as $columnName => $column) {
// don't overwrite essential columns
if (isset($item[$columnName]) === true) {
continue;
}
if (empty($column['value']) === false) {
$value = $model->toString($column['value']);
} else {
$value = $model->content()->get($column['id'] ?? $columnName)->value();
}
$item[$columnName] = $value;
}
return $item;
}
],
];

View file

@ -1,28 +1,28 @@
<?php
return [
'props' => [
/**
* Sets the maximum number of allowed entries in the section
*/
'max' => function (int $max = null) {
return $max;
}
],
'methods' => [
'isFull' => function () {
if ($this->max) {
return $this->total >= $this->max;
}
'props' => [
/**
* Sets the maximum number of allowed entries in the section
*/
'max' => function (int $max = null) {
return $max;
}
],
'methods' => [
'isFull' => function () {
if ($this->max) {
return $this->total >= $this->max;
}
return false;
},
'validateMax' => function () {
if ($this->max && $this->total > $this->max) {
return false;
}
return false;
},
'validateMax' => function () {
if ($this->max && $this->total > $this->max) {
return false;
}
return true;
}
]
return true;
}
]
];

View file

@ -1,21 +1,21 @@
<?php
return [
'props' => [
/**
* Sets the minimum number of required entries in the section
*/
'min' => function (int $min = null) {
return $min;
}
],
'methods' => [
'validateMin' => function () {
if ($this->min && $this->min > $this->total) {
return false;
}
'props' => [
/**
* Sets the minimum number of required entries in the section
*/
'min' => function (int $min = null) {
return $min;
}
],
'methods' => [
'validateMin' => function () {
if ($this->min && $this->min > $this->total) {
return false;
}
return true;
}
]
return true;
}
]
];

View file

@ -1,36 +1,37 @@
<?php
use Kirby\Cms\App;
use Kirby\Toolkit\Pagination;
return [
'props' => [
/**
* Sets the number of items per page. If there are more items the pagination navigation will be shown at the bottom of the section.
*/
'limit' => function (int $limit = 20) {
return $limit;
},
/**
* Sets the default page for the pagination. This will overwrite default pagination.
*/
'page' => function (int $page = null) {
return get('page', $page);
},
],
'methods' => [
'pagination' => function () {
$pagination = new Pagination([
'limit' => $this->limit,
'page' => $this->page,
'total' => $this->total
]);
'props' => [
/**
* Sets the number of items per page. If there are more items the pagination navigation will be shown at the bottom of the section.
*/
'limit' => function (int $limit = 20) {
return $limit;
},
/**
* Sets the default page for the pagination. This will overwrite default pagination.
*/
'page' => function (int $page = null) {
return App::instance()->request()->get('page', $page);
},
],
'methods' => [
'pagination' => function () {
$pagination = new Pagination([
'limit' => $this->limit,
'page' => $this->page,
'total' => $this->total
]);
return [
'limit' => $pagination->limit(),
'offset' => $pagination->offset(),
'page' => $pagination->page(),
'total' => $pagination->total(),
];
},
]
return [
'limit' => $pagination->limit(),
'offset' => $pagination->offset(),
'page' => $pagination->page(),
'total' => $pagination->total(),
];
}
]
];

View file

@ -3,41 +3,41 @@
use Kirby\Exception\Exception;
return [
'props' => [
/**
* Sets the query to a parent to find items for the list
*/
'parent' => function (string $parent = null) {
return $parent;
}
],
'methods' => [
'parentModel' => function () {
$parent = $this->parent;
'props' => [
/**
* Sets the query to a parent to find items for the list
*/
'parent' => function (string $parent = null) {
return $parent;
}
],
'methods' => [
'parentModel' => function () {
$parent = $this->parent;
if (is_string($parent) === true) {
$query = $parent;
$parent = $this->model->query($query);
if (is_string($parent) === true) {
$query = $parent;
$parent = $this->model->query($query);
if (!$parent) {
throw new Exception('The parent for the query "' . $query . '" cannot be found in the section "' . $this->name() . '"');
}
if (!$parent) {
throw new Exception('The parent for the query "' . $query . '" cannot be found in the section "' . $this->name() . '"');
}
if (
is_a($parent, 'Kirby\Cms\Page') === false &&
is_a($parent, 'Kirby\Cms\Site') === false &&
is_a($parent, 'Kirby\Cms\File') === false &&
is_a($parent, 'Kirby\Cms\User') === false
) {
throw new Exception('The parent for the section "' . $this->name() . '" has to be a page, site or user object');
}
}
if (
is_a($parent, 'Kirby\Cms\Page') === false &&
is_a($parent, 'Kirby\Cms\Site') === false &&
is_a($parent, 'Kirby\Cms\File') === false &&
is_a($parent, 'Kirby\Cms\User') === false
) {
throw new Exception('The parent for the section "' . $this->name() . '" has to be a page, site or user object');
}
}
if ($parent === null) {
return $this->model;
}
if ($parent === null) {
return $this->model;
}
return $parent;
}
]
return $parent;
}
]
];

View file

@ -0,0 +1,19 @@
<?php
use Kirby\Cms\App;
return [
'props' => [
/**
* Enable/disable the search in the sections
*/
'search' => function (bool $search = false): bool {
return $search;
}
],
'methods' => [
'searchterm' => function (): ?string {
return App::instance()->request()->get('searchterm');
}
]
];

View file

@ -0,0 +1,53 @@
<?php
return [
'props' => [
/**
* Enables/disables reverse sorting
*/
'flip' => function (bool $flip = false) {
return $flip;
},
/**
* Enables/disables manual sorting
*/
'sortable' => function (bool $sortable = true) {
return $sortable;
},
/**
* Overwrites manual sorting and sorts by the given field and sorting direction (i.e. `date desc`)
*/
'sortBy' => function (string $sortBy = null) {
return $sortBy;
},
],
'computed' => [
'sortable' => function () {
if ($this->sortable === false) {
return false;
}
if (
$this->type === 'pages' &&
in_array($this->status, ['listed', 'published', 'all']) === false
) {
return false;
}
// don't allow sorting while search filter is active
if (empty($this->searchterm()) === false) {
return false;
}
if ($this->sortBy !== null) {
return false;
}
if ($this->flip === true) {
return false;
}
return true;
}
]
];