Initial commit
This commit is contained in:
commit
73c6b816c0
716 changed files with 170045 additions and 0 deletions
21
kirby/config/sections/mixins/empty.php
Normal file
21
kirby/config/sections/mixins/empty.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
23
kirby/config/sections/mixins/headline.php
Normal file
23
kirby/config/sections/mixins/headline.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?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 () {
|
||||
if ($this->headline) {
|
||||
return $this->model()->toString($this->headline);
|
||||
}
|
||||
|
||||
return ucfirst($this->name);
|
||||
}
|
||||
]
|
||||
];
|
23
kirby/config/sections/mixins/help.php
Normal file
23
kirby/config/sections/mixins/help.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
14
kirby/config/sections/mixins/layout.php
Normal file
14
kirby/config/sections/mixins/layout.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
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';
|
||||
}
|
||||
]
|
||||
];
|
28
kirby/config/sections/mixins/max.php
Normal file
28
kirby/config/sections/mixins/max.php
Normal 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->total > $this->max) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
]
|
||||
];
|
21
kirby/config/sections/mixins/min.php
Normal file
21
kirby/config/sections/mixins/min.php
Normal 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
Normal file
36
kirby/config/sections/mixins/pagination.php
Normal 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 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(),
|
||||
];
|
||||
},
|
||||
]
|
||||
];
|
43
kirby/config/sections/mixins/parent.php
Normal file
43
kirby/config/sections/mixins/parent.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
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;
|
||||
|
||||
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 (
|
||||
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;
|
||||
}
|
||||
|
||||
return $parent;
|
||||
}
|
||||
]
|
||||
];
|
Loading…
Add table
Add a link
Reference in a new issue