first version
This commit is contained in:
28
kirby/config/sections/mixins/empty.php
Executable file
28
kirby/config/sections/mixins/empty.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'props' => [
|
||||
/**
|
||||
* Sets the text for the empty state box
|
||||
*/
|
||||
'empty' => function (string $empty = null) {
|
||||
return I18n::translate($empty);
|
||||
}
|
||||
],
|
||||
'methods' => [
|
||||
'isFull' => function () {
|
||||
if ($this->max) {
|
||||
return $this->total >= $this->max;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
'validateMax' => function () {
|
||||
if ($this->max && $this->max < $this->total) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
]
|
||||
];
|
19
kirby/config/sections/mixins/headline.php
Executable file
19
kirby/config/sections/mixins/headline.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
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.
|
||||
*/
|
||||
'headline' => function ($headline = null) {
|
||||
return I18n::translate($headline, $headline);
|
||||
}
|
||||
],
|
||||
'computed' => [
|
||||
'headline' => function () {
|
||||
return $this->headline ?? ucfirst($this->name);
|
||||
}
|
||||
]
|
||||
];
|
12
kirby/config/sections/mixins/layout.php
Executable file
12
kirby/config/sections/mixins/layout.php
Executable file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'props' => [
|
||||
/**
|
||||
* Section layout. Available layout methods: list, cards.
|
||||
*/
|
||||
'layout' => function (string $layout = 'list') {
|
||||
return $layout === 'cards' ? 'cards' : 'list';
|
||||
}
|
||||
]
|
||||
];
|
28
kirby/config/sections/mixins/max.php
Executable file
28
kirby/config/sections/mixins/max.php
Executable file
@@ -0,0 +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;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
'validateMax' => function () {
|
||||
if ($this->max && $this->max < $this->total) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
]
|
||||
];
|
21
kirby/config/sections/mixins/min.php
Executable file
21
kirby/config/sections/mixins/min.php
Executable file
@@ -0,0 +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;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
]
|
||||
];
|
36
kirby/config/sections/mixins/pagination.php
Executable file
36
kirby/config/sections/mixins/pagination.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
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 $page ?? get('page', 1);
|
||||
},
|
||||
],
|
||||
'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(),
|
||||
];
|
||||
},
|
||||
]
|
||||
];
|
29
kirby/config/sections/mixins/parent.php
Executable file
29
kirby/config/sections/mixins/parent.php
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Kirby\Toolkit\Str;
|
||||
|
||||
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;
|
||||
|
||||
if (is_string($parent) === true) {
|
||||
$parent = $this->model->query($parent);
|
||||
}
|
||||
|
||||
if ($parent === null) {
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
return $parent;
|
||||
}
|
||||
]
|
||||
];
|
Reference in New Issue
Block a user