Upgrade to 3.4.4

This commit is contained in:
Bastian Allgeier
2020-10-06 10:23:02 +02:00
parent c091f04115
commit 0b80361a79
53 changed files with 976 additions and 83 deletions

View File

@@ -1,7 +1,7 @@
{
"name": "getkirby/cms",
"description": "The Kirby 3 core",
"version": "3.4.3",
"version": "3.4.4",
"license": "proprietary",
"keywords": ["kirby", "cms", "core"],
"homepage": "https://getkirby.com",

2
kirby/composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "3c8b128ea6de49c70f9ec3056bcb18a2",
"content-hash": "b85ce02787ff0e052a3cc7a01c2daa91",
"packages": [
{
"name": "claviska/simpleimage",

View File

@@ -48,7 +48,7 @@ return [
'pattern' => 'pages/(:any)/children',
'method' => 'GET',
'action' => function (string $id) {
return $this->page($id)->children();
return $this->pages($id, $this->requestQuery('status'));
}
],
[
@@ -62,13 +62,7 @@ return [
'pattern' => 'pages/(:any)/children/search',
'method' => 'GET|POST',
'action' => function (string $id) {
$pages = $this->page($id)->children();
if ($this->requestMethod() === 'GET') {
return $pages->search($this->requestQuery('q'));
} else {
return $pages->query($this->requestBody());
}
return $this->searchPages($id);
}
],
[

View File

@@ -22,7 +22,7 @@ return [
'pattern' => 'site/children',
'method' => 'GET',
'action' => function () {
return $this->site()->children();
return $this->pages(null, $this->requestQuery('status'));
}
],
[
@@ -34,9 +34,9 @@ return [
],
[
'pattern' => 'site/children/search',
'method' => 'POST',
'method' => 'GET|POST',
'action' => function () {
return $this->site()->children()->query($this->requestBody());
return $this->searchPages();
}
],
[

View File

@@ -81,8 +81,8 @@ return [
// create url and root
$mediaRoot = dirname($file->mediaRoot());
$dst = $mediaRoot . '/{{ name }}{{ attributes }}.{{ extension }}';
$thumbRoot = (new Filename($file->root(), $dst, $options))->toString();
$template = $mediaRoot . '/{{ name }}{{ attributes }}.{{ extension }}';
$thumbRoot = (new Filename($file->root(), $template, $options))->toString();
$thumbName = basename($thumbRoot);
$job = $mediaRoot . '/.jobs/' . $thumbName . '.json';
@@ -306,14 +306,14 @@ return [
*
* @param \Kirby\Cms\App $kirby Kirby instance
* @param string $src The root of the original file
* @param string $dst The root to the desired destination
* @param string $template The template for the root to the desired destination
* @param array $options All thumb options that should be applied: `width`, `height`, `crop`, `blur`, `grayscale`
* @return string
*/
'thumb' => function (App $kirby, string $src, string $dst, array $options): string {
'thumb' => function (App $kirby, string $src, string $template, array $options): string {
$darkroom = Darkroom::factory(option('thumbs.driver', 'gd'), option('thumbs', []));
$options = $darkroom->preprocess($src, $options);
$root = (new Filename($src, $dst, $options))->toString();
$root = (new Filename($src, $template, $options))->toString();
F::copy($src, $root, true);
$darkroom->process($root, $options);

View File

@@ -136,7 +136,8 @@ function deprecated(string $message): bool
return false;
}
/**
if (function_exists('dump') === false) {
/**
* Simple object and variable dumper
* to help with debugging.
*
@@ -144,22 +145,25 @@ function deprecated(string $message): bool
* @param bool $echo
* @return string
*/
function dump($variable, bool $echo = true): string
{
function dump($variable, bool $echo = true): string
{
$kirby = App::instance();
return $kirby->component('dump')($kirby, $variable, $echo);
}
}
/**
if (function_exists('e') === false) {
/**
* Smart version of echo with an if condition as first argument
*
* @param mixed $condition
* @param mixed $value The string to be echoed if the condition is true
* @param mixed $alternative An alternative string which should be echoed when the condition is false
*/
function e($condition, $value, $alternative = null)
{
function e($condition, $value, $alternative = null)
{
echo r($condition, $value, $alternative);
}
}
/**

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "Страницата \"{slug}\" не може да бъде намерена",
"error.page.num.invalid": "Моля въведете валидно число за сортиране. Числата не трябва да са негативни.",
"error.page.slug.invalid": "Моля въведете валиден URL префикс",
"error.page.slug.maxlength": "Slug length must be less than \"{length}\" characters",
"error.page.sort.permission": "Страницата \"{slug}\" не може да бъде сортирана",
"error.page.status.invalid": "Моля изберете валиден статус на страницата",
"error.page.undefined": "\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u0442\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435 \u0434\u0430 \u0431\u044a\u0434\u0435 \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0430",
@@ -288,6 +289,7 @@
"on": "on",
"open": "Отвори",
"options": "Options",
"options.none": "No options",
"orientation": "Ориентация",
"orientation.landscape": "Пейзаж",
@@ -344,6 +346,9 @@
"save": "\u0417\u0430\u043f\u0438\u0448\u0438",
"search": "Търси",
"search.min": "Enter {min} characters to search",
"search.all": "Show all",
"search.results.none": "No results",
"section.required": "The section is required",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "La pàgina \"{slug}\" no s'ha trobat",
"error.page.num.invalid": "Si us plau, introdueix un número d 'ordenació vàlid. Els números no poden ser negatius.",
"error.page.slug.invalid": "Introduïu un prefix d'URL vàlid",
"error.page.slug.maxlength": "La longitud del nom ha de tenir menys de caràcters \"{length}\"",
"error.page.sort.permission": "La pàgina \"{slug}\" no es pot ordenar",
"error.page.status.invalid": "Si us plau, estableix un estat de pàgina vàlid",
"error.page.undefined": "La p\u00e0gina no s'ha trobat",
@@ -288,6 +289,7 @@
"on": "encès",
"open": "Obrir",
"options": "Opcions",
"options.none": "Sense opcions",
"orientation": "Orientació",
"orientation.landscape": "Horitzontal",
@@ -344,6 +346,9 @@
"save": "Desar",
"search": "Cercar",
"search.min": "Introduïu {min} caràcters per cercar",
"search.all": "Mostrar tots",
"search.results.none": "Sense resultats",
"section.required": "La secció és obligatòria",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "Siden kunne ikke findes",
"error.page.num.invalid": "Indtast venligst et gyldigt sorteringsnummer. Nummeret kan ikke være negativt.",
"error.page.slug.invalid": "Indtast venligst en gyldig URL prefix",
"error.page.slug.maxlength": "Slug length must be less than \"{length}\" characters",
"error.page.sort.permission": "Siden \"{slug}\" kan ikke sorteres",
"error.page.status.invalid": "Sæt venligst en gyldig status for siden",
"error.page.undefined": "Siden kunne ikke findes",
@@ -288,6 +289,7 @@
"on": "Tænd",
"open": "Åben",
"options": "Indstillinger",
"options.none": "No options",
"orientation": "Orientering",
"orientation.landscape": "Landskab",
@@ -344,6 +346,9 @@
"save": "Gem",
"search": "Søg",
"search.min": "Enter {min} characters to search",
"search.all": "Show all",
"search.results.none": "No results",
"section.required": "Sektionen er påkrævet",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "Δεν ήταν δυνατή η εύρεση της σελίδας \"{slug}\"",
"error.page.num.invalid": "Παρακαλώ εισάγετε έναν έγκυρο αριθμό ταξινόμησης. Οι αριθμοί δεν μπορεί να είναι αρνητικοί.",
"error.page.slug.invalid": "Παρακαλώ εισάγετε ένα έγκυρο πρόθεμα διεύθυνσης URL",
"error.page.slug.maxlength": "Slug length must be less than \"{length}\" characters",
"error.page.sort.permission": "Δεν είναι δυνατή η ταξινόμηση της σελίδας \"{slug}\"",
"error.page.status.invalid": "Ορίστε μια έγκυρη κατάσταση σελίδας",
"error.page.undefined": "Δεν ήταν δυνατή η εύρεση της σελίδας",
@@ -288,6 +289,7 @@
"on": "on",
"open": "Άνοιγμα",
"options": "Eπιλογές",
"options.none": "No options",
"orientation": "Προσανατολισμός",
"orientation.landscape": "Οριζόντιος",
@@ -344,6 +346,9 @@
"save": "\u0391\u03c0\u03bf\u03b8\u03ae\u03ba\u03b5\u03c5\u03c3\u03b7",
"search": "Αναζήτηση",
"search.min": "Enter {min} characters to search",
"search.all": "Show all",
"search.results.none": "No results",
"section.required": "The section is required",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "La página \"{slug}\" no se encuentra",
"error.page.num.invalid": "Por favor, introduce un número de posición válido. Los números no deben ser negativos.",
"error.page.slug.invalid": "Por favor ingresa un prefijo de URL válido",
"error.page.slug.maxlength": "Slug length must be less than \"{length}\" characters",
"error.page.sort.permission": "La página \"{slug}\" no se puede ordenar",
"error.page.status.invalid": "Por favor, establece una estado de página válido",
"error.page.undefined": "La p\u00e1gina no fue encontrada",
@@ -288,6 +289,7 @@
"on": "Encendido",
"open": "Abrir",
"options": "Opciones",
"options.none": "No options",
"orientation": "Orientación",
"orientation.landscape": "Paisaje",
@@ -344,6 +346,9 @@
"save": "Guardar",
"search": "Buscar",
"search.min": "Enter {min} characters to search",
"search.all": "Show all",
"search.results.none": "No results",
"section.required": "Esta sección es requerida",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "La página \"{slug}\" no puede ser encontrada",
"error.page.num.invalid": "Por favor, introduzca un número válido. Estos no deben ser negativos.",
"error.page.slug.invalid": "Por favor ingrese un prefijo de URL válido",
"error.page.slug.maxlength": "Slug length must be less than \"{length}\" characters",
"error.page.sort.permission": "La página \"{slug}\" no se puede ordenar",
"error.page.status.invalid": "Por favor, establezca un estado de página válido",
"error.page.undefined": "La página no se puede encontrar",
@@ -288,6 +289,7 @@
"on": "on",
"open": "Abrir",
"options": "Opciones",
"options.none": "No options",
"orientation": "Orientación",
"orientation.landscape": "Paisaje",
@@ -344,6 +346,9 @@
"save": "Guardar",
"search": "Buscar",
"search.min": "Enter {min} characters to search",
"search.all": "Show all",
"search.results.none": "No results",
"section.required": "The section is required",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "صفحه مورد نظر با آدرس «{slug}» پیدا نشد.",
"error.page.num.invalid": "لطفا شماره ترتیب را بدرستی وارد نمایید. اعداد نباید منفی باشند.",
"error.page.slug.invalid": "لطفا یک پیشوند Url صحیح وارد کنید",
"error.page.slug.maxlength": "Slug length must be less than \"{length}\" characters",
"error.page.sort.permission": "امکان مرتب‌سازی «{slug}» نیست",
"error.page.status.invalid": "لطفا وضعیت صحیحی برای صفحه انتخاب کنید",
"error.page.undefined": "صفحه مورد نظر پیدا نشد",
@@ -288,6 +289,7 @@
"on": "on",
"open": "بازکردن",
"options": "گزینه‌ها",
"options.none": "No options",
"orientation": "جهت",
"orientation.landscape": "افقی",
@@ -344,6 +346,9 @@
"save": "\u0630\u062e\u06cc\u0631\u0647",
"search": "جستجو",
"search.min": "Enter {min} characters to search",
"search.all": "Show all",
"search.results.none": "No results",
"section.required": "The section is required",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "Sivua \"{slug}\" ei löytynyt",
"error.page.num.invalid": "Anna kelpaava järjestysnumero. Numero ei voi olla negatiivinen.",
"error.page.slug.invalid": "Anna kelpaava URL-etuliite",
"error.page.slug.maxlength": "Slug length must be less than \"{length}\" characters",
"error.page.sort.permission": "Sivua \"{slug}\" ei voi järjestellä",
"error.page.status.invalid": "Aseta kelvollinen sivun tila",
"error.page.undefined": "Sivua ei l\u00f6ytynyt",
@@ -288,6 +289,7 @@
"on": "on",
"open": "Avaa",
"options": "Asetukset",
"options.none": "No options",
"orientation": "Suunta",
"orientation.landscape": "Vaakasuuntainen",
@@ -344,6 +346,9 @@
"save": "Tallenna",
"search": "Haku",
"search.min": "Enter {min} characters to search",
"search.all": "Show all",
"search.results.none": "No results",
"section.required": "Osio on pakollinen",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "La page « {slug} » na pu être trouvée",
"error.page.num.invalid": "Veuillez saisir un numéro de position valide. Les numéros ne doivent pas être négatifs.",
"error.page.slug.invalid": "Veuillez saisir un préfixe dURL valide",
"error.page.slug.maxlength": "Lidentifiant dURL doit faire moins de \"{length}\" caractères",
"error.page.sort.permission": "La page « {slug} » ne peut être réordonnée",
"error.page.status.invalid": "Veuillez choisir un statut de page valide",
"error.page.undefined": "La page na pu être trouvée",
@@ -288,6 +289,7 @@
"on": "on",
"open": "Ouvrir",
"options": "Options",
"options.none": "Pas doptions",
"orientation": "Orientation",
"orientation.landscape": "Paysage",
@@ -344,6 +346,9 @@
"save": "Enregistrer",
"search": "Rechercher",
"search.min": "Entrez {min} caractères pour rechercher",
"search.all": "Tout afficher",
"search.results.none": "Pas de résultats",
"section.required": "Cette section est obligatoire",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "Az oldal nem tal\u00e1lhat\u00f3",
"error.page.num.invalid": "Kérlek megfelelő oldalszámozást adj meg. Negatív szám itt nem használható.",
"error.page.slug.invalid": "Kérlek megfelelő URL-előtagot adj meg",
"error.page.slug.maxlength": "Slug length must be less than \"{length}\" characters",
"error.page.sort.permission": "A(z) \"{slug}\" oldal nem illeszthető a sorrendbe",
"error.page.status.invalid": "Kérlek add meg a megfelelő oldalstátuszt",
"error.page.undefined": "Az oldal nem tal\u00e1lhat\u00f3",
@@ -288,6 +289,7 @@
"on": "be",
"open": "Megnyitás",
"options": "Beállítások",
"options.none": "No options",
"orientation": "Tájolás",
"orientation.landscape": "Fekvő",
@@ -344,6 +346,9 @@
"save": "Ment\u00e9s",
"search": "Keresés",
"search.min": "Enter {min} characters to search",
"search.all": "Show all",
"search.results.none": "No results",
"section.required": "The section is required",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "La pagina \"{slug}\" non è stata trovata",
"error.page.num.invalid": "Inserisci un numero di ordinamento valido. I numeri non devono essere negativi",
"error.page.slug.invalid": "Inserisci un prefisso URL valido",
"error.page.slug.maxlength": "Slug length must be less than \"{length}\" characters",
"error.page.sort.permission": "La pagina \"{slug}\" non può essere ordinata",
"error.page.status.invalid": "Imposta uno stato valido per la pagina",
"error.page.undefined": "La pagina non \u00e8 stata trovata",
@@ -288,6 +289,7 @@
"on": "on",
"open": "Apri",
"options": "Opzioni",
"options.none": "No options",
"orientation": "Orientamento",
"orientation.landscape": "Panorama",
@@ -344,6 +346,9 @@
"save": "Salva",
"search": "Cerca",
"search.min": "Enter {min} characters to search",
"search.all": "Show all",
"search.results.none": "No results",
"section.required": "The section is required",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "페이지({slug})가 없습니다.",
"error.page.num.invalid": "올바른 정수를 입력하세요.",
"error.page.slug.invalid": "올바른 접두사를 입력하세요.",
"error.page.slug.maxlength": "{length}자 이하로 지정하세요.",
"error.page.sort.permission": "페이지({slug})를 정렬할 수 없습니다.",
"error.page.status.invalid": "올바른 상태를 설정하세요.",
"error.page.undefined": "\ud398\uc774\uc9c0\uac00 \uc5c6\uc2b5\ub2c8\ub2e4.",
@@ -179,7 +180,7 @@
"error.validation.notin": "{notIn}에 포함된 값은 입력할 수 없습니다.",
"error.validation.option": "올바른 옵션을 선택하세요.",
"error.validation.num": "올바른 숫자를 입력하세요.",
"error.validation.required": "아무거나 입력하세요.",
"error.validation.required": "해당 항목을 확인하세요.",
"error.validation.same": "다음을 입력하세요: {other}",
"error.validation.size": "값의 크기는 다음과 같아야 합니다: {size}",
"error.validation.startswith": "값은 다음으로 시작해야 합니다: {start}",
@@ -288,6 +289,7 @@
"on": "켬",
"open": "열기",
"options": "옵션",
"options.none": "옵션이 없습니다.",
"orientation": "비율",
"orientation.landscape": "가로로 긴 사각형",
@@ -344,6 +346,9 @@
"save": "\uc800\uc7a5",
"search": "검색",
"search.min": "{min}자 이상 입력하세요.",
"search.all": "모두 보기",
"search.results.none": "해당하는 결과가 없습니다.",
"section.required": "섹션이 필요합니다.",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "Puslapis \"{slug}\" nerastas",
"error.page.num.invalid": "Įrašykite teisingą eiliškumo numerį. Numeris negali būti neigiamas.",
"error.page.slug.invalid": "Įrašykite teisingą URL prefiksą",
"error.page.slug.maxlength": "Slug length must be less than \"{length}\" characters",
"error.page.sort.permission": "Puslapiui \"{slug}\" negalima pakeisti eiliškumo",
"error.page.status.invalid": "Nustatykite teisingą puslapio statusą",
"error.page.undefined": "Puslapis nerastas",
@@ -288,6 +289,7 @@
"on": "on",
"open": "Atidaryti",
"options": "Pasirinkimai",
"options.none": "No options",
"orientation": "Orientacija",
"orientation.landscape": "Horizontali",
@@ -344,6 +346,9 @@
"save": "Išsaugoti",
"search": "Ieškoti",
"search.min": "Enter {min} characters to search",
"search.all": "Show all",
"search.results.none": "No results",
"section.required": "Sekcija privaloma",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "Siden \"{slug}\" ble ikke funnet",
"error.page.num.invalid": "Vennligst skriv inn et gyldig sorteringsnummer. Tallet må ikke være negativt.",
"error.page.slug.invalid": "Vennligst skriv inn en gyldig URL-prefiks",
"error.page.slug.maxlength": "Slug length must be less than \"{length}\" characters",
"error.page.sort.permission": "Siden \"{slug}\" kan ikke sorteres",
"error.page.status.invalid": "Vennligst angi en gyldig sidestatus",
"error.page.undefined": "Siden kunne ikke bli funnet",
@@ -288,6 +289,7 @@
"on": "on",
"open": "Åpne",
"options": "Alternativer",
"options.none": "No options",
"orientation": "Orientering",
"orientation.landscape": "Landskap",
@@ -344,6 +346,9 @@
"save": "Lagre",
"search": "Søk",
"search.min": "Enter {min} characters to search",
"search.all": "Show all",
"search.results.none": "No results",
"section.required": "The section is required",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "De pagina \"{slug}\" kan niet worden gevonden",
"error.page.num.invalid": "Vul een geldig sorteer-cijfer in. Het cijfer mag niet negatief zijn",
"error.page.slug.invalid": "Vul een geldige URL-prefix in",
"error.page.slug.maxlength": "Slug length must be less than \"{length}\" characters",
"error.page.sort.permission": "De pagina \"{slug}\" kan niet worden gesorteerd",
"error.page.status.invalid": "Zorg voor een geldige paginastatus",
"error.page.undefined": "De pagina kan niet worden gevonden",
@@ -288,6 +289,7 @@
"on": "aan",
"open": "Open",
"options": "Opties",
"options.none": "No options",
"orientation": "Oriëntatie",
"orientation.landscape": "Liggend",
@@ -344,6 +346,9 @@
"save": "Opslaan",
"search": "Zoeken",
"search.min": "Enter {min} characters to search",
"search.all": "Show all",
"search.results.none": "No results",
"section.required": "De sectie is verplicht",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "Nie można znaleźć strony \"{slug}\"",
"error.page.num.invalid": "Wprowadź poprawny numer sortujący. Liczby nie mogą być ujemne.",
"error.page.slug.invalid": "Wprowadź poprawną końcówkę adresu URL",
"error.page.slug.maxlength": "Slug length must be less than \"{length}\" characters",
"error.page.sort.permission": "Nie można sortować strony \"{slug}\"",
"error.page.status.invalid": "Ustaw prawidłowy status strony",
"error.page.undefined": "Nie udało się znaleźć strony",
@@ -288,6 +289,7 @@
"on": "włączone",
"open": "Otwórz",
"options": "Opcje",
"options.none": "No options",
"orientation": "Orientacja",
"orientation.landscape": "Pozioma",
@@ -344,6 +346,9 @@
"save": "Zapisz",
"search": "Szukaj",
"search.min": "Enter {min} characters to search",
"search.all": "Show all",
"search.results.none": "No results",
"section.required": "Sekcja jest wymagana",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "Página\"{slug}\" não encontrada",
"error.page.num.invalid": "Digite um número de ordenação válido. Este número não pode ser negativo.",
"error.page.slug.invalid": "Por favor, digite uma URL válida",
"error.page.slug.maxlength": "Slug length must be less than \"{length}\" characters",
"error.page.sort.permission": "A página \"{slug}\" não pode ser ordenada",
"error.page.status.invalid": "Por favor, defina um estado de página válido",
"error.page.undefined": "P\u00e1gina n\u00e3o encontrada",
@@ -288,6 +289,7 @@
"on": "on",
"open": "Abrir",
"options": "Opções",
"options.none": "No options",
"orientation": "Orientação",
"orientation.landscape": "Paisagem",
@@ -344,6 +346,9 @@
"save": "Salvar",
"search": "Buscar",
"search.min": "Enter {min} characters to search",
"search.all": "Show all",
"search.results.none": "No results",
"section.required": "The section is required",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "Página\"{slug}\" não encontrada",
"error.page.num.invalid": "Digite um número de ordenação válido. Este número não pode ser negativo.",
"error.page.slug.invalid": "Por favor, digite um prefixo de URL válido",
"error.page.slug.maxlength": "Slug length must be less than \"{length}\" characters",
"error.page.sort.permission": "A página \"{slug}\" não pode ser ordenada",
"error.page.status.invalid": "Por favor, defina um estado de página válido",
"error.page.undefined": "P\u00e1gina n\u00e3o encontrada",
@@ -288,6 +289,7 @@
"on": "on",
"open": "Abrir",
"options": "Opções",
"options.none": "No options",
"orientation": "Orientação",
"orientation.landscape": "Paisagem",
@@ -344,6 +346,9 @@
"save": "Salvar",
"search": "Buscar",
"search.min": "Enter {min} characters to search",
"search.all": "Show all",
"search.results.none": "No results",
"section.required": "Esta seção é necessária",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u0430",
"error.page.num.invalid": "Пожалуйста, впишите правильное число сортировки. Число не может быть отрицательным.",
"error.page.slug.invalid": "Пожалуйста, впишите правильный префикс URL",
"error.page.slug.maxlength": "Slug length must be less than \"{length}\" characters",
"error.page.sort.permission": "Невозможно сортировать страницу \"{slug}\"",
"error.page.status.invalid": "Пожалуйста, установите верный статус страницы",
"error.page.undefined": "\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u0430",
@@ -288,6 +289,7 @@
"on": "включено",
"open": "Открыть",
"options": "Опции",
"options.none": "No options",
"orientation": "Ориентация",
"orientation.landscape": "Горизонтальная",
@@ -344,6 +346,9 @@
"save": "\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c",
"search": "Поиск",
"search.min": "Enter {min} characters to search",
"search.all": "Show all",
"search.results.none": "No results",
"section.required": "Секция обязательна",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "Stránku \"{slug}\" nie je možné nájsť",
"error.page.num.invalid": "Prosím, zadajte platné číslo pre radenie. Čísla nemôžu byť záporné.",
"error.page.slug.invalid": "Prosím, zadajte platný URL prefix.",
"error.page.slug.maxlength": "Slug length must be less than \"{length}\" characters",
"error.page.sort.permission": "Stránku \"{slug}\" nie je možné preradiť.",
"error.page.status.invalid": "Prosím, nastavte platnú status pre stránku",
"error.page.undefined": "Stránku nie je možné nájsť",
@@ -288,6 +289,7 @@
"on": "on",
"open": "Otvoriť",
"options": "Nastavenia",
"options.none": "No options",
"orientation": "Orientácia",
"orientation.landscape": "Širokouhlá",
@@ -344,6 +346,9 @@
"save": "Uložiť",
"search": "Hľadať",
"search.min": "Enter {min} characters to search",
"search.all": "Show all",
"search.results.none": "No results",
"section.required": "The section is required",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "Sidan \"{slug}\" kan inte hittas",
"error.page.num.invalid": "Ange ett giltigt nummer för sortering. Numret får inte vara negativt.",
"error.page.slug.invalid": "Ange ett giltigt URL-prefix",
"error.page.slug.maxlength": "Slug length must be less than \"{length}\" characters",
"error.page.sort.permission": "Sidan \"{slug}\" kan inte sorteras",
"error.page.status.invalid": "Sätt en giltig status för sidan",
"error.page.undefined": "Sidan kan inte hittas",
@@ -288,6 +289,7 @@
"on": "på",
"open": "Öppna",
"options": "Alternativ",
"options.none": "No options",
"orientation": "Orientering",
"orientation.landscape": "Liggande",
@@ -344,6 +346,9 @@
"save": "Spara",
"search": "Sök",
"search.min": "Enter {min} characters to search",
"search.all": "Show all",
"search.results.none": "No results",
"section.required": "Sektionen krävs",

View File

@@ -102,6 +102,7 @@
"error.page.notFound": "\"{slug}\" uzantısındaki sayfa bulunamadı",
"error.page.num.invalid": "Lütfen geçerli bir sıralama numarası girin. Sayılar negatif olmamalıdır.",
"error.page.slug.invalid": "Lütfen geçerli bir adres öneki girin",
"error.page.slug.maxlength": "Adres uzantısı \"{length}\" karakterden az olmalıdır",
"error.page.sort.permission": "\"{slug}\" sayfası sıralanamıyor",
"error.page.status.invalid": "Lütfen geçerli bir sayfa durumu ayarlayın",
"error.page.undefined": "Sayfa bulunamad\u0131",
@@ -288,6 +289,7 @@
"on": "açık",
"open": "Önizleme",
"options": "Seçenekler",
"options.none": "Seçenek yok",
"orientation": "Oryantasyon",
"orientation.landscape": "Yatay",
@@ -344,6 +346,9 @@
"save": "Kaydet",
"search": "Arama",
"search.min": "Aramak için {min} karakter girin",
"search.all": "Tümünü göster",
"search.results.none": "Sonuç yok",
"section.required": "Bölüm gereklidir",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -212,6 +212,53 @@ class Api extends BaseApi
]);
}
/**
* Returns the subpages for the given
* parent. The subpages can be filtered
* by status (draft, listed, unlisted, published, all)
*
* @param string|null $parentId
* @param string|null $status
* @return \Kirby\Cms\Pages
*/
public function pages(string $parentId = null, string $status = null)
{
$parent = $parentId === null ? $this->site() : $this->page($parentId);
switch ($status) {
case 'all':
return $parent->childrenAndDrafts();
case 'draft':
case 'drafts':
return $parent->drafts();
case 'listed':
return $parent->children()->listed();
case 'unlisted':
return $parent->children()->unlisted();
case 'published':
default:
return $parent->children();
}
}
/**
* Search for direct subpages of the
* given parent
*
* @param string|null $parent
* @return \Kirby\Cms\Pages
*/
public function searchPages(string $parent = null)
{
$pages = $this->pages($parent, $this->requestQuery('status'));
if ($this->requestMethod() === 'GET') {
return $pages->search($this->requestQuery('q'));
}
return $pages->query($this->requestBody());
}
/**
* Returns the current Session instance
*

View File

@@ -1079,10 +1079,15 @@ class App
// when the page has been found
if ($page) {
try {
return $this
->response()
->body($page->render([], $extension))
->type($extension);
$response = $this->response();
// attach a MIME type based on the representation
// only if no custom MIME type was set
if ($response->type() === null) {
$response->type($extension);
}
return $response->body($page->render([], $extension));
} catch (NotFoundException $e) {
return null;
}

View File

@@ -111,10 +111,14 @@ trait AppErrors
$httpCode = $exception->getHttpCode();
$code = $exception->getCode();
$details = $exception->getDetails();
} else {
} elseif (is_a($exception, '\Throwable') === true) {
$httpCode = 500;
$code = $exception->getCode();
$details = null;
} else {
$httpCode = 500;
$code = 500;
$details = null;
}
if ($this->option('debug') === true) {

View File

@@ -265,6 +265,8 @@ class Auth
// check for blocked ips
if ($this->isBlocked($email) === true) {
$this->kirby->trigger('user.login:failed', compact('email'));
if ($this->kirby->option('debug') === true) {
$message = 'Rate limit exceeded';
} else {
@@ -397,6 +399,8 @@ class Auth
*/
public function track(string $email): bool
{
$this->kirby->trigger('user.login:failed', compact('email'));
$ip = $this->ipHash();
$log = $this->log();
$time = time();

View File

@@ -245,6 +245,9 @@ trait FileActions
F::remove($file->root());
// remove the file from the sibling collection
$file->parent()->files()->remove($file);
return true;
});
}

View File

@@ -86,7 +86,7 @@ class Media
* given filename and then calls the thumb
* component to create a thumbnail accordingly
*
* @param \Kirby\Cms\Model $model
* @param \Kirby\Cms\Model|string $model
* @param string $hash
* @param string $filename
* @return \Kirby\Cms\Response|false
@@ -95,11 +95,14 @@ class Media
{
$kirby = App::instance();
if (is_string($model) === true) {
// assets
if (is_string($model) === true) {
$root = $kirby->root('media') . '/assets/' . $model . '/' . $hash;
} else {
// parent files for file model that already included hash
} elseif (is_a($model, '\Kirby\Cms\File')) {
$root = dirname($model->mediaRoot());
// model files
} else {
$root = $model->mediaRoot() . '/' . $hash;
}

View File

@@ -8,7 +8,6 @@ use Kirby\Exception\NotFoundException;
use Kirby\Http\Uri;
use Kirby\Toolkit\A;
use Kirby\Toolkit\F;
use Kirby\Toolkit\Str;
/**
* The `$page` object is the heart and
@@ -964,11 +963,6 @@ class Page extends ModelWithContent
{
if ($icon = $this->blueprint()->icon()) {
$params['type'] = $icon;
// check for emojis
if (strlen($icon) !== Str::length($icon)) {
$params['emoji'] = true;
}
}
return parent::panelIcon($params);

View File

@@ -27,11 +27,6 @@ class User extends ModelWithContent
use HasSiblings;
use UserActions;
/**
* @var File
*/
protected $avatar;
/**
* @var UserBlueprint
*/
@@ -798,7 +793,7 @@ class User extends ModelWithContent
*/
protected function setName(string $name = null)
{
$this->name = $name !== null ? trim($name) : null;
$this->name = $name !== null ? trim(strip_tags($name)) : null;
return $this;
}

View File

@@ -50,7 +50,7 @@ class UserPermissions extends ModelPermissions
}
// users who are not admins cannot create admins
if ($this->model->isAdmin() === true) {
if ($this->model->isAdmin() === false) {
return false;
}

View File

@@ -6,7 +6,7 @@ use Kirby\Exception\InvalidArgumentException;
use Spyc;
/**
* Simple Wrapper around Symfony's Yaml Component
* Simple Wrapper around the Spyc YAML class
*
* @package Kirby Data
* @author Bastian Allgeier <bastian@getkirby.com>

View File

@@ -19,30 +19,64 @@ class Body
{
use Properties;
/**
* @var string|null
*/
protected $html;
/**
* @var string|null
*/
protected $text;
/**
* Email body constructor
*
* @param array $props
*/
public function __construct(array $props = [])
{
$this->setProperties($props);
}
/**
* Returns the HTML content of the email body
*
* @return string|null
*/
public function html()
{
return $this->html;
}
/**
* Returns the plain text content of the email body
*
* @return string|null
*/
public function text()
{
return $this->text;
}
/**
* Sets the HTML content for the email body
*
* @param string|null $html
* @return self
*/
protected function setHtml(string $html = null)
{
$this->html = $html;
return $this;
}
/**
* Sets the plain text content for the email body
*
* @param string|null $text
* @return self
*/
protected function setText(string $text = null)
{
$this->text = $text;

View File

@@ -21,57 +21,142 @@ class Email
{
use Properties;
/**
* @var array|null
*/
protected $attachments;
/**
* @var \Kirby\Email\Body|null
*/
protected $body;
/**
* @var array|null
*/
protected $bcc;
/**
* @var \Closure|null
*/
protected $beforeSend;
/**
* @var array|null
*/
protected $cc;
/**
* @var string|null
*/
protected $from;
/**
* @var string|null
*/
protected $fromName;
/**
* @var string|null
*/
protected $replyTo;
/**
* @var string|null
*/
protected $replyToName;
/**
* @var bool
*/
protected $isSent = false;
/**
* @var string|null
*/
protected $subject;
/**
* @var array|null
*/
protected $to;
/**
* @var array|null
*/
protected $transport;
/**
* Email constructor
*
* @param array $props
* @param bool $debug
*/
public function __construct(array $props = [], bool $debug = false)
{
$this->setProperties($props);
if ($debug === false) {
$this->send();
$this->send(); // @codeCoverageIgnore
}
}
/**
* Returns the email attachments
*
* @return array
*/
public function attachments(): array
{
return $this->attachments;
}
/**
* @return \Kirby\Email\Body
* Returns the email body
*
* @return \Kirby\Email\Body|null
*/
public function body()
{
return $this->body;
}
/**
* Returns "bcc" recipients
*
* @return array
*/
public function bcc(): array
{
return $this->bcc;
}
/**
* Returns the beforeSend callback closure,
* which has access to the PHPMailer instance
*
* @return \Closure|null
*/
public function beforeSend(): ?Closure
{
return $this->beforeSend;
}
/**
* Returns "cc" recipients
*
* @return array
*/
public function cc(): array
{
return $this->cc;
}
/**
* Returns default transport settings
*
* @return array
*/
protected function defaultTransport(): array
{
return [
@@ -79,36 +164,74 @@ class Email
];
}
/**
* Returns the "from" email address
*
* @return string
*/
public function from(): string
{
return $this->from;
}
/**
* Returns the "from" name
*
* @return string|null
*/
public function fromName(): ?string
{
return $this->fromName;
}
/**
* Checks if the email has an HTML body
*
* @return bool
*/
public function isHtml()
{
return $this->body()->html() !== null;
}
/**
* Checks if the email has been sent successfully
*
* @return bool
*/
public function isSent(): bool
{
return $this->isSent;
}
/**
* Returns the "reply to" email address
*
* @return string
*/
public function replyTo(): string
{
return $this->replyTo;
}
/**
* Returns the "reply to" name
*
* @return string|null
*/
public function replyToName(): ?string
{
return $this->replyToName;
}
/**
* Converts single or multiple email addresses to a sanitized format
*
* @param string|array|null $email
* @param bool $multiple
* @return array|mixed|string
* @throws \Exception
*/
protected function resolveEmail($email = null, bool $multiple = true)
{
if ($email === null) {
@@ -139,17 +262,34 @@ class Email
return $multiple === true ? $result : array_keys($result)[0];
}
/**
* Sends the email
*
* @return bool
*/
public function send(): bool
{
return $this->isSent = true;
}
/**
* Sets the email attachments
*
* @param array|null $attachments
* @return self
*/
protected function setAttachments($attachments = null)
{
$this->attachments = $attachments ?? [];
return $this;
}
/**
* Sets the email body
*
* @param string|array $body
* @return self
*/
protected function setBody($body)
{
if (is_string($body) === true) {
@@ -160,76 +300,151 @@ class Email
return $this;
}
/**
* Sets "bcc" recipients
*
* @param string|array|null $bcc
* @return $this
*/
protected function setBcc($bcc = null)
{
$this->bcc = $this->resolveEmail($bcc);
return $this;
}
/**
* Sets the "beforeSend" callback
*
* @param \Closure|null $beforeSend
* @return self
*/
protected function setBeforeSend(?Closure $beforeSend = null)
{
$this->beforeSend = $beforeSend;
return $this;
}
/**
* Sets "cc" recipients
*
* @param string|array|null $cc
* @return self
*/
protected function setCc($cc = null)
{
$this->cc = $this->resolveEmail($cc);
return $this;
}
/**
* Sets the "from" email address
*
* @param string $from
* @return self
*/
protected function setFrom(string $from)
{
$this->from = $this->resolveEmail($from, false);
return $this;
}
/**
* Sets the "from" name
*
* @param string|null $fromName
* @return self
*/
protected function setFromName(string $fromName = null)
{
$this->fromName = $fromName;
return $this;
}
/**
* Sets the "reply to" email address
*
* @param string|null $replyTo
* @return self
*/
protected function setReplyTo(string $replyTo = null)
{
$this->replyTo = $this->resolveEmail($replyTo, false);
return $this;
}
/**
* Sets the "reply to" name
*
* @param string|null $replyToName
* @return self
*/
protected function setReplyToName(string $replyToName = null)
{
$this->replyToName = $replyToName;
return $this;
}
/**
* Sets the email subject
*
* @param string $subject
* @return self
*/
protected function setSubject(string $subject)
{
$this->subject = $subject;
return $this;
}
/**
* Sets the recipients of the email
*
* @param string|array $to
* @return self
*/
protected function setTo($to)
{
$this->to = $this->resolveEmail($to);
return $this;
}
/**
* Sets the email transport settings
*
* @param array|null $transport
* @return self
*/
protected function setTransport($transport = null)
{
$this->transport = $transport;
return $this;
}
/**
* Returns the email subject
*
* @return string
*/
public function subject(): string
{
return $this->subject;
}
/**
* Returns the email recipients
*
* @return array
*/
public function to(): array
{
return $this->to;
}
/**
* Returns the email transports settings
*
* @return array
*/
public function transport(): array
{
return $this->transport ?? $this->defaultTransport();

View File

@@ -17,6 +17,13 @@ use PHPMailer\PHPMailer\PHPMailer as Mailer;
*/
class PHPMailer extends Email
{
/**
* Sends email via PHPMailer library
*
* @param bool $debug
* @return bool
* @throws \Kirby\Exception\InvalidArgumentException
*/
public function send(bool $debug = false): bool
{
$mailer = new Mailer(true);
@@ -83,6 +90,6 @@ class PHPMailer extends Email
return $this->isSent = true;
}
return $this->isSent = $mailer->send();
return $this->isSent = $mailer->send(); // @codeCoverageIgnore
}
}

View File

@@ -3,7 +3,6 @@
namespace Kirby\Form;
use Exception;
use Kirby\Cms\Model;
use Kirby\Exception\InvalidArgumentException;
use Kirby\Toolkit\A;
use Kirby\Toolkit\Component;
@@ -51,6 +50,14 @@ class Field extends Component
*/
public static $types = [];
/**
* Field constructor
*
* @param string $type
* @param array $attrs
* @param \Kirby\Form\Fields|null $formFields
* @throws \Kirby\Exception\InvalidArgumentException
*/
public function __construct(string $type, array $attrs = [], ?Fields $formFields = null)
{
if (isset(static::$types[$type]) === false) {
@@ -71,6 +78,8 @@ class Field extends Component
}
/**
* Returns field api call
*
* @return mixed
*/
public function api()
@@ -81,10 +90,12 @@ class Field extends Component
}
/**
* @param mixed $default
* Returns field data
*
* @param bool $default
* @return mixed
*/
public function data($default = false)
public function data(bool $default = false)
{
$save = $this->options['save'] ?? true;
@@ -103,6 +114,11 @@ class Field extends Component
}
}
/**
* Default props and computed of the field
*
* @return array
*/
public static function defaults(): array
{
return [
@@ -232,11 +248,21 @@ class Field extends Component
];
}
/**
* Parent collection with all fields of the current form
*
* @return \Kirby\Form\Fields|null
*/
public function formFields(): ?Fields
{
return $this->formFields;
}
/**
* Validates when run for the first time and returns any errors
*
* @return array
*/
public function errors(): array
{
if ($this->errors === null) {
@@ -246,6 +272,12 @@ class Field extends Component
return $this->errors;
}
/**
* Checks if the field is empty
*
* @param mixed ...$args
* @return bool
*/
public function isEmpty(...$args): bool
{
if (count($args) === 0) {
@@ -261,22 +293,39 @@ class Field extends Component
return in_array($value, [null, '', []], true);
}
/**
* Checks if the field is invalid
*
* @return bool
*/
public function isInvalid(): bool
{
return empty($this->errors()) === false;
}
/**
* Checks if the field is required
*
* @return bool
*/
public function isRequired(): bool
{
return $this->required ?? false;
}
/**
* Checks if the field is valid
*
* @return bool
*/
public function isValid(): bool
{
return empty($this->errors()) === true;
}
/**
* Returns the Kirby instance
*
* @return \Kirby\Cms\App
*/
public function kirby()
@@ -284,6 +333,11 @@ class Field extends Component
return $this->model->kirby();
}
/**
* Returns the parent model
*
* @return mixed|null
*/
public function model()
{
return $this->model;
@@ -329,11 +383,21 @@ class Field extends Component
return true;
}
/**
* Checks if the field is saveable
*
* @return bool
*/
public function save(): bool
{
return ($this->options['save'] ?? true) !== false;
}
/**
* Converts the field to a plain array
*
* @return array
*/
public function toArray(): array
{
$array = parent::toArray();
@@ -352,6 +416,11 @@ class Field extends Component
});
}
/**
* Runs the validations defined for the field
*
* @return void
*/
protected function validate(): void
{
$validations = $this->options['validations'] ?? [];
@@ -395,6 +464,12 @@ class Field extends Component
}
}
/**
* Returns the value of the field if saveable
* otherwise it returns null
*
* @return mixed
*/
public function value()
{
return $this->save() ? $this->value : null;

View File

@@ -22,11 +22,12 @@ class Fields extends Collection
* the collection prop on each object correctly.
*
* @param string $name
* @param object $field
* @param object|array $field
* @return self
*/
public function __set(string $name, $field)
{
if (is_array($field)) {
if (is_array($field) === true) {
// use the array key as name if the name is not set
$field['name'] = $field['name'] ?? $name;
$field = new Field($field['type'], $field);
@@ -40,7 +41,7 @@ class Fields extends Collection
* array and also does that for every
* included field.
*
* @param Closure $map
* @param \Closure|null $map
* @return array
*/
public function toArray(Closure $map = null): array

View File

@@ -19,10 +19,32 @@ use Throwable;
*/
class Form
{
/**
* An array of all found errors
*
* @var array|null
*/
protected $errors;
/**
* Fields in the form
*
* @var \Kirby\Form\Fields|null
*/
protected $fields;
/**
* All values of form
*
* @var array
*/
protected $values = [];
/**
* Form constructor
*
* @param array $props
*/
public function __construct(array $props)
{
$fields = $props['fields'] ?? [];
@@ -85,11 +107,24 @@ class Form
}
}
/**
* Returns the data required to write to the content file
* Doesn't include default and null values
*
* @return array
*/
public function content(): array
{
return $this->data(false, false);
}
/**
* Returns data for all fields in the form
*
* @param false $defaults
* @param bool $includeNulls
* @return array
*/
public function data($defaults = false, bool $includeNulls = true): array
{
$data = $this->values;
@@ -109,6 +144,11 @@ class Form
return $data;
}
/**
* An array of all found errors
*
* @return array
*/
public function errors(): array
{
if ($this->errors !== null) {
@@ -129,6 +169,13 @@ class Form
return $this->errors;
}
/**
* Shows the error with the field
*
* @param \Throwable $exception
* @param array $props
* @return \Kirby\Form\Field
*/
public static function exceptionField(Throwable $exception, array $props = [])
{
$props = array_merge($props, [
@@ -140,21 +187,42 @@ class Form
return new Field('info', $props);
}
/**
* Returns form fields
*
* @return \Kirby\Form\Fields|null
*/
public function fields()
{
return $this->fields;
}
/**
* Checks if the form is invalid
*
* @return bool
*/
public function isInvalid(): bool
{
return empty($this->errors()) === false;
}
/**
* Checks if the form is valid
*
* @return bool
*/
public function isValid(): bool
{
return empty($this->errors()) === true;
}
/**
* Converts the data of fields to strings
*
* @param false $defaults
* @return array
*/
public function strings($defaults = false): array
{
$strings = [];
@@ -172,6 +240,11 @@ class Form
return $strings;
}
/**
* Converts the form to a plain array
*
* @return array
*/
public function toArray(): array
{
$array = [
@@ -185,6 +258,11 @@ class Form
return $array;
}
/**
* Returns form values
*
* @return array
*/
public function values(): array
{
return $this->values;

View File

@@ -19,6 +19,11 @@ use Kirby\Toolkit\I18n;
*/
class Options
{
/**
* Returns the classes of predefined Kirby objects
*
* @return array
*/
protected static function aliases(): array
{
return [
@@ -30,6 +35,13 @@ class Options
];
}
/**
* Brings options through api
*
* @param $api
* @param $model
* @return array
*/
public static function api($api, $model = null): array
{
$model = $model ?? App::instance()->site();
@@ -57,6 +69,10 @@ class Options
return $optionsApi->options();
}
/**
* @param $model
* @return array
*/
protected static function data($model): array
{
$kirby = $model->kirby();
@@ -78,6 +94,14 @@ class Options
return $data;
}
/**
* Brings options by supporting both api and query
*
* @param $options
* @param array $props
* @param null $model
* @return array
*/
public static function factory($options, array $props = [], $model = null): array
{
switch ($options) {
@@ -131,6 +155,13 @@ class Options
return $result;
}
/**
* Brings options with query
*
* @param $query
* @param null $model
* @return array
*/
public static function query($query, $model = null): array
{
$model = $model ?? App::instance()->site();

View File

@@ -25,34 +25,78 @@ class OptionsApi
{
use Properties;
/**
* @var
*/
protected $data;
/**
* @var
*/
protected $fetch;
/**
* @var
*/
protected $options;
/**
* @var string
*/
protected $text = '{{ item.value }}';
/**
* @var
*/
protected $url;
/**
* @var string
*/
protected $value = '{{ item.key }}';
/**
* OptionsApi constructor
*
* @param array $props
*/
public function __construct(array $props)
{
$this->setProperties($props);
}
/**
* @return array
*/
public function data(): array
{
return $this->data;
}
/**
* @return mixed
*/
public function fetch()
{
return $this->fetch;
}
/**
* @param string $field
* @param array $data
* @return string
*/
protected function field(string $field, array $data)
{
$value = $this->$field();
return Str::template($value, $data);
}
/**
* @return array
* @throws \Exception
* @throws \Kirby\Exception\InvalidArgumentException
*/
public function options(): array
{
if (is_array($this->options) === true) {
@@ -103,51 +147,94 @@ class OptionsApi
return $options;
}
/**
* @param array $data
* @return self
*/
protected function setData(array $data)
{
$this->data = $data;
return $this;
}
/**
* @param string|null $fetch
* @return self
*/
protected function setFetch(string $fetch = null)
{
$this->fetch = $fetch;
return $this;
}
/**
* @param $options
* @return self
*/
protected function setOptions($options = null)
{
$this->options = $options;
return $this;
}
/**
* @param $text
* @return self
*/
protected function setText($text = null)
{
$this->text = $text;
return $this;
}
/**
* @param $url
* @return self
*/
protected function setUrl($url)
{
$this->url = $url;
return $this;
}
/**
* @param null $value
* @return self
*/
protected function setValue($value = null)
{
$this->value = $value;
return $this;
}
/**
* @return string
*/
public function text()
{
return $this->text;
}
/**
* @return array
* @throws \Kirby\Exception\InvalidArgumentException
*/
public function toArray(): array
{
return $this->options();
}
/**
* @return string
*/
public function url(): string
{
return Str::template($this->url, $this->data());
}
/**
* @return string
*/
public function value()
{
return $this->value;

View File

@@ -27,28 +27,69 @@ class OptionsQuery
{
use Properties;
/**
* @var array
*/
protected $aliases = [];
/**
* @var
*/
protected $data;
/**
* @var
*/
protected $options;
/**
* @var
*/
protected $query;
/**
* @var
*/
protected $text;
/**
* @var
*/
protected $value;
/**
* OptionsQuery constructor
*
* @param array $props
*/
public function __construct(array $props)
{
$this->setProperties($props);
}
/**
* @return array
*/
public function aliases(): array
{
return $this->aliases;
}
/**
* @return array
*/
public function data(): array
{
return $this->data;
}
/**
* @param string $object
* @param string $field
* @param array $data
* @return string
* @throws \Kirby\Exception\NotFoundException
*/
protected function template(string $object, string $field, array $data)
{
$value = $this->$field();
@@ -64,6 +105,9 @@ class OptionsQuery
return Str::template($value, $data);
}
/**
* @return array
*/
public function options(): array
{
if (is_array($this->options) === true) {
@@ -89,11 +133,18 @@ class OptionsQuery
return $this->options = $options;
}
/**
* @return string
*/
public function query(): string
{
return $this->query;
}
/**
* @param $object
* @return mixed|string|null
*/
public function resolve($object)
{
// fast access
@@ -111,6 +162,10 @@ class OptionsQuery
return 'item';
}
/**
* @param $result
* @throws \Kirby\Exception\InvalidArgumentException
*/
protected function resultToCollection($result)
{
if (is_array($result)) {
@@ -133,36 +188,69 @@ class OptionsQuery
return $result;
}
/**
* @param array|null $aliases
* @return self
*/
protected function setAliases(array $aliases = null)
{
$this->aliases = $aliases;
return $this;
}
/**
* @param array $data
* @return self
*/
protected function setData(array $data)
{
$this->data = $data;
return $this;
}
/**
* @param $options
* @return self
*/
protected function setOptions($options = null)
{
$this->options = $options;
return $this;
}
/**
* @param string $query
* @return self
*/
protected function setQuery(string $query)
{
$this->query = $query;
return $this;
}
/**
* @param $text
* @return self
*/
protected function setText($text)
{
$this->text = $text;
return $this;
}
/**
* @param $value
* @return self
*/
protected function setValue($value)
{
$this->value = $value;
return $this;
}
/**
* @return mixed
*/
public function text()
{
return $this->text;
@@ -173,6 +261,9 @@ class OptionsQuery
return $this->options();
}
/**
* @return mixed
*/
public function value()
{
return $this->value;

View File

@@ -16,6 +16,14 @@ use Kirby\Toolkit\V;
*/
class Validations
{
/**
* Validates if the field value is boolean
*
* @param \Kirby\Form\Field $field
* @param $value
* @return bool
* @throws \Kirby\Exception\InvalidArgumentException
*/
public static function boolean(Field $field, $value): bool
{
if ($field->isEmpty($value) === false) {
@@ -29,6 +37,14 @@ class Validations
return true;
}
/**
* Validates if the field value is valid date
*
* @param \Kirby\Form\Field $field
* @param $value
* @return bool
* @throws \Kirby\Exception\InvalidArgumentException
*/
public static function date(Field $field, $value): bool
{
if ($field->isEmpty($value) === false) {
@@ -42,6 +58,14 @@ class Validations
return true;
}
/**
* Validates if the field value is valid email
*
* @param \Kirby\Form\Field $field
* @param $value
* @return bool
* @throws \Kirby\Exception\InvalidArgumentException
*/
public static function email(Field $field, $value): bool
{
if ($field->isEmpty($value) === false) {
@@ -55,6 +79,14 @@ class Validations
return true;
}
/**
* Validates if the field value is maximum
*
* @param \Kirby\Form\Field $field
* @param $value
* @return bool
* @throws \Kirby\Exception\InvalidArgumentException
*/
public static function max(Field $field, $value): bool
{
if ($field->isEmpty($value) === false && $field->max() !== null) {
@@ -68,6 +100,14 @@ class Validations
return true;
}
/**
* Validates if the field value is max length
*
* @param \Kirby\Form\Field $field
* @param $value
* @return bool
* @throws \Kirby\Exception\InvalidArgumentException
*/
public static function maxlength(Field $field, $value): bool
{
if ($field->isEmpty($value) === false && $field->maxlength() !== null) {
@@ -81,6 +121,14 @@ class Validations
return true;
}
/**
* Validates if the field value is minimum
*
* @param \Kirby\Form\Field $field
* @param $value
* @return bool
* @throws \Kirby\Exception\InvalidArgumentException
*/
public static function min(Field $field, $value): bool
{
if ($field->isEmpty($value) === false && $field->min() !== null) {
@@ -94,6 +142,14 @@ class Validations
return true;
}
/**
* Validates if the field value is min length
*
* @param \Kirby\Form\Field $field
* @param $value
* @return bool
* @throws \Kirby\Exception\InvalidArgumentException
*/
public static function minlength(Field $field, $value): bool
{
if ($field->isEmpty($value) === false && $field->minlength() !== null) {
@@ -107,6 +163,14 @@ class Validations
return true;
}
/**
* Validates if the field value matches defined pattern
*
* @param \Kirby\Form\Field $field
* @param $value
* @return bool
* @throws \Kirby\Exception\InvalidArgumentException
*/
public static function pattern(Field $field, $value): bool
{
if ($field->isEmpty($value) === false && $field->pattern() !== null) {
@@ -120,6 +184,14 @@ class Validations
return true;
}
/**
* Validates if the field value is required
*
* @param \Kirby\Form\Field $field
* @param $value
* @return bool
* @throws \Kirby\Exception\InvalidArgumentException
*/
public static function required(Field $field, $value): bool
{
if ($field->isRequired() === true && $field->save() === true && $field->isEmpty($value) === true) {
@@ -131,6 +203,14 @@ class Validations
return true;
}
/**
* Validates if the field value is in defined options
*
* @param \Kirby\Form\Field $field
* @param $value
* @return bool
* @throws \Kirby\Exception\InvalidArgumentException
*/
public static function option(Field $field, $value): bool
{
if ($field->isEmpty($value) === false) {
@@ -146,6 +226,14 @@ class Validations
return true;
}
/**
* Validates if the field values is in defined options
*
* @param \Kirby\Form\Field $field
* @param $value
* @return bool
* @throws \Kirby\Exception\InvalidArgumentException
*/
public static function options(Field $field, $value): bool
{
if ($field->isEmpty($value) === false) {
@@ -162,6 +250,14 @@ class Validations
return true;
}
/**
* Validates if the field value is valid time
*
* @param \Kirby\Form\Field $field
* @param $value
* @return bool
* @throws \Kirby\Exception\InvalidArgumentException
*/
public static function time(Field $field, $value): bool
{
if ($field->isEmpty($value) === false) {
@@ -175,6 +271,14 @@ class Validations
return true;
}
/**
* Validates if the field value is valid url
*
* @param \Kirby\Form\Field $field
* @param $value
* @return bool
* @throws \Kirby\Exception\InvalidArgumentException
*/
public static function url(Field $field, $value): bool
{
if ($field->isEmpty($value) === false) {

View File

@@ -71,10 +71,13 @@ class F
],
'image' => [
'ai',
'avif',
'bmp',
'gif',
'eps',
'ico',
'j2k',
'jp2',
'jpeg',
'jpg',
'jpe',

View File

@@ -29,6 +29,7 @@ class Mime
'aifc' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'avi' => 'video/x-msvideo',
'avif' => 'image/avif',
'bmp' => 'image/bmp',
'css' => 'text/css',
'csv' => ['text/csv', 'text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream'],
@@ -48,6 +49,8 @@ class Mime
'ics' => 'text/calendar',
'js' => 'application/x-javascript',
'json' => ['application/json', 'text/json'],
'j2k' => ['image/jp2'],
'jp2' => ['image/jp2'],
'jpg' => ['image/jpeg', 'image/pjpeg'],
'jpeg' => ['image/jpeg', 'image/pjpeg'],
'jpe' => ['image/jpeg', 'image/pjpeg'],

View File

@@ -353,16 +353,17 @@ class Pagination
return range($start, $end);
}
$start = $page - (int)floor($range/2);
$end = $page + (int)floor($range/2);
$middle = (int)floor($range/2);
$start = $page - $middle + ($range % 2 === 0);
$end = $start + $range - 1;
if ($start <= 0) {
$end += abs($start);
$end = $range;
$start = 1;
}
if ($end > $pages) {
$start -= $end - $pages;
$start = $pages - $range + 1;
$end = $pages;
}