Add blueprints and fake content

This commit is contained in:
Paul Nicoué 2021-11-18 17:44:47 +01:00
parent 1ff19bf38f
commit 8235816462
592 changed files with 22385 additions and 31535 deletions

View file

@ -1,6 +1,6 @@
<?php
use Kirby\Cms\Form;
use Kirby\Form\Form;
return [
'props' => [

View file

@ -1,7 +1,6 @@
<?php
use Kirby\Cms\File;
use Kirby\Toolkit\Escape;
use Kirby\Toolkit\I18n;
return [
@ -29,7 +28,7 @@ return [
return $image ?? [];
},
/**
* Optional info text setup. Info text is shown on the right (lists) or below (cards) the filename.
* Optional info text setup. Info text is shown on the right (lists, cardlets) or below (cards) the filename.
*/
'info' => function ($info = null) {
return I18n::translate($info, $info);
@ -70,6 +69,7 @@ return [
if ($this->template) {
$file = new File([
'filename' => 'tmp',
'parent' => $this->model(),
'template' => $this->template
]);
@ -90,7 +90,7 @@ return [
if ($this->sortBy) {
$files = $files->sort(...$files::sortArgs($this->sortBy));
} else {
$files = $files->sort('sort', 'asc', 'filename', 'asc');
$files = $files->sorted();
}
// flip
@ -115,28 +115,21 @@ return [
$dragTextAbsolute = $this->model->is($this->parent) === false;
foreach ($this->files as $file) {
$image = $file->panelImage($this->image);
// escape the default text
// TODO: no longer needed in 3.6
$text = $file->toString($this->text);
if ($this->text === '{{ file.filename }}') {
$text = Escape::html($text);
}
$panel = $file->panel();
$data[] = [
'dragText' => $file->dragText('auto', $dragTextAbsolute),
'dragText' => $panel->dragText('auto', $dragTextAbsolute),
'extension' => $file->extension(),
'filename' => $file->filename(),
'id' => $file->id(),
'icon' => $file->panelIcon($image),
'image' => $image,
'info' => $file->toString($this->info ?? false),
'link' => $file->panelUrl(true),
'mime' => $file->mime(),
'parent' => $file->parent()->panelPath(),
'text' => $text,
'url' => $file->url(),
'filename' => $file->filename(),
'id' => $file->id(),
'image' => $panel->image($this->image, $this->layout),
'info' => $file->toSafeString($this->info ?? false),
'link' => $panel->url(true),
'mime' => $file->mime(),
'parent' => $file->parent()->panel()->path(),
'template' => $file->template(),
'text' => $file->toSafeString($this->text),
'url' => $file->url(),
];
}
@ -174,8 +167,8 @@ return [
];
},
'link' => function () {
$modelLink = $this->model->panelUrl(true);
$parentLink = $this->parent->panelUrl(true);
$modelLink = $this->model->panel()->url(true);
$parentLink = $this->parent->panel()->url(true);
if ($modelLink !== $parentLink) {
return $parentLink;
@ -222,6 +215,7 @@ return [
'max' => $max,
'api' => $this->parent->apiUrl(true) . '/files',
'attributes' => array_filter([
'sort' => $this->sortable === true ? $total + 1 : null,
'template' => $template
])
];

View file

@ -17,7 +17,7 @@ return [
'computed' => [
'text' => function () {
if ($this->text) {
$text = $this->model()->toString($this->text);
$text = $this->model()->toSafeString($this->text);
$text = $this->kirby()->kirbytext($text);
return $text;
}
@ -25,11 +25,9 @@ return [
],
'toArray' => function () {
return [
'options' => [
'headline' => $this->headline,
'text' => $this->text,
'theme' => $this->theme
]
'headline' => $this->headline,
'text' => $this->text,
'theme' => $this->theme
];
}
];

View file

@ -14,7 +14,7 @@ return [
'computed' => [
'empty' => function () {
if ($this->empty) {
return $this->model()->toString($this->empty);
return $this->model()->toSafeString($this->empty);
}
}
]

View file

@ -14,7 +14,7 @@ return [
'computed' => [
'help' => function () {
if ($this->help) {
$help = $this->model()->toString($this->help);
$help = $this->model()->toSafeString($this->help);
$help = $this->kirby()->kirbytext($help);
return $help;
}

View file

@ -3,10 +3,12 @@
return [
'props' => [
/**
* Section layout. Available layout methods: `list`, `cards`.
* Section layout.
* Available layout methods: `list`, `cardlets`, `cards`.
*/
'layout' => function (string $layout = 'list') {
return $layout === 'cards' ? 'cards' : 'list';
$layouts = ['list', 'cardlets', 'cards'];
return in_array($layout, $layouts) ? $layout : 'list';
}
]
];

View file

@ -1,8 +1,8 @@
<?php
use Kirby\Cms\Blueprint;
use Kirby\Exception\InvalidArgumentException;
use Kirby\Toolkit\A;
use Kirby\Toolkit\Escape;
use Kirby\Toolkit\I18n;
return [
@ -89,7 +89,13 @@ return [
],
'computed' => [
'parent' => function () {
return $this->parentModel();
$parent = $this->parentModel();
if (is_a($parent, 'Kirby\Cms\Site') === false && is_a($parent, 'Kirby\Cms\Page') === false) {
throw new InvalidArgumentException('The parent is invalid. You must choose the site or a page as parent.');
}
return $parent;
},
'pages' => function () {
switch ($this->status) {
@ -151,32 +157,25 @@ return [
$data = [];
foreach ($this->pages as $item) {
$panel = $item->panel();
$permissions = $item->permissions();
$image = $item->panelImage($this->image);
// escape the default text
// TODO: no longer needed in 3.6
$text = $item->toString($this->text);
if ($this->text === '{{ page.title }}') {
$text = Escape::html($text);
}
$data[] = [
'dragText' => $panel->dragText(),
'id' => $item->id(),
'dragText' => $item->dragText(),
'text' => $text,
'info' => $item->toString($this->info ?? false),
'image' => $panel->image($this->image, $this->layout),
'info' => $item->toSafeString($this->info ?? false),
'link' => $panel->url(true),
'parent' => $item->parentId(),
'icon' => $item->panelIcon($image),
'image' => $image,
'link' => $item->panelUrl(true),
'status' => $item->status(),
'permissions' => [
'sort' => $permissions->can('sort'),
'changeSlug' => $permissions->can('changeSlug'),
'changeStatus' => $permissions->can('changeStatus'),
'changeTitle' => $permissions->can('changeTitle')
]
'changeTitle' => $permissions->can('changeTitle'),
],
'status' => $item->status(),
'template' => $item->intendedTemplate()->name(),
'text' => $item->toSafeString($this->text),
];
}
@ -226,8 +225,8 @@ return [
return true;
},
'link' => function () {
$modelLink = $this->model->panelUrl(true);
$parentLink = $this->parent->panelUrl(true);
$modelLink = $this->model->panel()->url(true);
$parentLink = $this->parent->panel()->url(true);
if ($modelLink !== $parentLink) {
return $parentLink;