Upgrade to 3.7.0
This commit is contained in:
36
kirby/config/sections/mixins/details.php
Executable file
36
kirby/config/sections/mixins/details.php
Executable 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;
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
0
kirby/config/sections/mixins/empty.php
Normal file → Executable file
0
kirby/config/sections/mixins/empty.php
Normal file → Executable file
12
kirby/config/sections/mixins/headline.php
Normal file → Executable file
12
kirby/config/sections/mixins/headline.php
Normal file → Executable file
@@ -1,18 +1,26 @@
|
||||
<?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
|
||||
* @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.');
|
||||
// }
|
||||
|
||||
return I18n::translate($headline, $headline);
|
||||
},
|
||||
/**
|
||||
* label is the new official replacement for 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);
|
||||
|
0
kirby/config/sections/mixins/help.php
Normal file → Executable file
0
kirby/config/sections/mixins/help.php
Normal file → Executable file
117
kirby/config/sections/mixins/layout.php
Normal file → Executable file
117
kirby/config/sections/mixins/layout.php
Normal file → Executable file
@@ -1,14 +1,125 @@
|
||||
<?php
|
||||
|
||||
use Kirby\Toolkit\I18n;
|
||||
use Kirby\Toolkit\Str;
|
||||
|
||||
return [
|
||||
'props' => [
|
||||
/**
|
||||
* Columns config for `layout: table`
|
||||
*/
|
||||
'columns' => function (array $columns = null) {
|
||||
return $columns ?? [];
|
||||
},
|
||||
/**
|
||||
* Section layout.
|
||||
* Available layout methods: `list`, `cardlets`, `cards`.
|
||||
* Available layout methods: `list`, `cardlets`, `cards`, `table`.
|
||||
*/
|
||||
'layout' => function (string $layout = 'list') {
|
||||
$layouts = ['list', 'cardlets', 'cards'];
|
||||
$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'] = [
|
||||
'text' => $item['text'],
|
||||
'href' => $model->panel()->url(true)
|
||||
];
|
||||
|
||||
foreach ($this->columns as $columnName => $column) {
|
||||
// don't overwrite essential columns
|
||||
if (isset($item[$columnName]) === true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty($column['value']) === false) {
|
||||
if ($column['type'] ?? false === 'html') {
|
||||
$value = $model->toString($column['value']);
|
||||
} else {
|
||||
$value = $model->toSafeString($column['value']);
|
||||
}
|
||||
} else {
|
||||
$value = $model->content()->get($column['id'] ?? $columnName)->value();
|
||||
}
|
||||
|
||||
$item[$columnName] = $value;
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
]
|
||||
],
|
||||
];
|
||||
|
0
kirby/config/sections/mixins/max.php
Normal file → Executable file
0
kirby/config/sections/mixins/max.php
Normal file → Executable file
0
kirby/config/sections/mixins/min.php
Normal file → Executable file
0
kirby/config/sections/mixins/min.php
Normal file → Executable file
5
kirby/config/sections/mixins/pagination.php
Normal file → Executable file
5
kirby/config/sections/mixins/pagination.php
Normal file → Executable file
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Toolkit\Pagination;
|
||||
|
||||
return [
|
||||
@@ -14,7 +15,7 @@ return [
|
||||
* Sets the default page for the pagination. This will overwrite default pagination.
|
||||
*/
|
||||
'page' => function (int $page = null) {
|
||||
return get('page', $page);
|
||||
return App::instance()->request()->get('page', $page);
|
||||
},
|
||||
],
|
||||
'methods' => [
|
||||
@@ -31,6 +32,6 @@ return [
|
||||
'page' => $pagination->page(),
|
||||
'total' => $pagination->total(),
|
||||
];
|
||||
},
|
||||
}
|
||||
]
|
||||
];
|
||||
|
0
kirby/config/sections/mixins/parent.php
Normal file → Executable file
0
kirby/config/sections/mixins/parent.php
Normal file → Executable file
19
kirby/config/sections/mixins/search.php
Executable file
19
kirby/config/sections/mixins/search.php
Executable 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;
|
||||
}
|
||||
],
|
||||
'computed' => [
|
||||
'searchterm' => function (): ?string {
|
||||
return App::instance()->request()->get('searchterm');
|
||||
}
|
||||
]
|
||||
];
|
53
kirby/config/sections/mixins/sort.php
Executable file
53
kirby/config/sections/mixins/sort.php
Executable 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->query) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->sortBy !== null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->flip === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
]
|
||||
];
|
Reference in New Issue
Block a user