Initial commit

This commit is contained in:
Paul Nicoué 2021-10-29 18:05:46 +02:00
commit 1ff19bf38f
830 changed files with 159212 additions and 0 deletions

View 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()->toString($this->empty);
}
}
]
];

View 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);
}
]
];

View 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()->toString($this->help);
$help = $this->kirby()->kirbytext($help);
return $help;
}
}
]
];

View 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';
}
]
];

View 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;
}
]
];

View 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;
}
]
];

View 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(),
];
},
]
];

View 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;
}
]
];