Upgrade to 4.4.0
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
// routing pattern to match all models with files
|
||||
$filePattern = '(account/|pages/[^/]+/|site/|users/[^/]+/|)files/(:any)';
|
||||
$filePattern = '(account/|pages/[^/]+/|site/|users/[^/]+/|)files/(:any)';
|
||||
$parentPattern = '(account|pages/[^/]+|site|users/[^/]+)/files';
|
||||
|
||||
/**
|
||||
@@ -47,17 +47,15 @@ return [
|
||||
// move_uploaded_file() not working with unit test
|
||||
// @codeCoverageIgnoreStart
|
||||
return $this->upload(function ($source, $filename) use ($path) {
|
||||
$props = [
|
||||
// move the source file from the temp dir
|
||||
return $this->parent($path)->createFile([
|
||||
'content' => [
|
||||
'sort' => $this->requestBody('sort')
|
||||
],
|
||||
'source' => $source,
|
||||
'template' => $this->requestBody('template'),
|
||||
'filename' => $filename
|
||||
];
|
||||
|
||||
// move the source file from the temp dir
|
||||
return $this->parent($path)->createFile($props, true);
|
||||
], true);
|
||||
});
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
@@ -3,12 +3,14 @@
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return function ($kirby) {
|
||||
$blueprint = $kirby->site()->blueprint();
|
||||
|
||||
return [
|
||||
'breadcrumbLabel' => function () use ($kirby) {
|
||||
return $kirby->site()->title()->or(I18n::translate('view.site'))->toString();
|
||||
},
|
||||
'icon' => 'home',
|
||||
'label' => $kirby->site()->blueprint()->title() ?? I18n::translate('view.site'),
|
||||
'icon' => $blueprint->icon() ?? 'home',
|
||||
'label' => $blueprint->title() ?? I18n::translate('view.site'),
|
||||
'menu' => true,
|
||||
'dialogs' => require __DIR__ . '/site/dialogs.php',
|
||||
'drawers' => require __DIR__ . '/site/drawers.php',
|
||||
|
@@ -194,12 +194,23 @@ return [
|
||||
'page.changeTitle' => [
|
||||
'pattern' => 'pages/(:any)/changeTitle',
|
||||
'load' => function (string $id) {
|
||||
$request = App::instance()->request();
|
||||
$kirby = App::instance();
|
||||
$request = $kirby->request();
|
||||
|
||||
$page = Find::page($id);
|
||||
$permissions = $page->permissions();
|
||||
$select = $request->get('select', 'title');
|
||||
|
||||
// build the path prefix
|
||||
$path = match ($kirby->multilang()) {
|
||||
true => Str::after($kirby->site()->url(), $kirby->url()) . '/',
|
||||
false => '/'
|
||||
};
|
||||
|
||||
if ($parent = $page->parent()) {
|
||||
$path .= $parent->uri() . '/';
|
||||
}
|
||||
|
||||
return [
|
||||
'component' => 'k-form-dialog',
|
||||
'props' => [
|
||||
@@ -212,7 +223,7 @@ return [
|
||||
'slug' => Field::slug([
|
||||
'required' => true,
|
||||
'preselect' => $select === 'slug',
|
||||
'path' => $page->parent() ? '/' . $page->parent()->uri() . '/' : '/',
|
||||
'path' => $path,
|
||||
'disabled' => $permissions->can('changeSlug') === false,
|
||||
'wizard' => [
|
||||
'text' => I18n::translate('page.changeSlug.fromTitle'),
|
||||
|
@@ -5,6 +5,8 @@ use Kirby\Cms\Find;
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return [
|
||||
// @codeCoverageIgnoreStart
|
||||
// TODO: move to controller class and add unit tests
|
||||
'tree' => [
|
||||
'pattern' => 'site/tree',
|
||||
'action' => function () {
|
||||
@@ -62,5 +64,20 @@ return [
|
||||
|
||||
return $pages;
|
||||
}
|
||||
],
|
||||
'tree.parents' => [
|
||||
'pattern' => 'site/tree/parents',
|
||||
'action' => function () {
|
||||
$kirby = App::instance();
|
||||
$request = $kirby->request();
|
||||
$page = $kirby->page($request->get('page'));
|
||||
|
||||
return [
|
||||
'data' => $page->parents()->flip()->values(
|
||||
fn ($parent) => $parent->uuid()?->toString() ?? $parent->id()
|
||||
)
|
||||
];
|
||||
}
|
||||
]
|
||||
// @codeCoverageIgnoreEnd
|
||||
];
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
use Kirby\Toolkit\I18n;
|
||||
use Kirby\Toolkit\Str;
|
||||
use Kirby\Uuid\Uuids;
|
||||
|
||||
return [
|
||||
'props' => [
|
||||
@@ -75,7 +76,11 @@ return [
|
||||
* @param string $store 'uuid'|'id'
|
||||
*/
|
||||
'store' => function (string $store = 'uuid') {
|
||||
return Str::lower($store);
|
||||
// fall back to ID, if UUIDs globally disabled
|
||||
return match (Uuids::enabled()) {
|
||||
false => 'id',
|
||||
default => Str::lower($store)
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
|
@@ -23,7 +23,11 @@ return [
|
||||
$uploads = [];
|
||||
}
|
||||
|
||||
$uploads['accept'] = '*';
|
||||
$uploads['accept'] = '*';
|
||||
|
||||
if ($preview = $this->image) {
|
||||
$uploads['preview'] = $preview;
|
||||
}
|
||||
|
||||
if ($template = $uploads['template'] ?? null) {
|
||||
// get parent object for upload target
|
||||
|
@@ -63,7 +63,14 @@ return [
|
||||
'computed' => [
|
||||
'value' => function () {
|
||||
$value = trim($this->value ?? '');
|
||||
return Sane::sanitize($value, 'html');
|
||||
$value = Sane::sanitize($value, 'html');
|
||||
|
||||
// convert non-breaking spaces to HTML entity
|
||||
// as that's how ProseMirror handles it internally;
|
||||
// will allow comparing saved and current content
|
||||
$value = str_replace(' ', ' ', $value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
],
|
||||
'validations' => [
|
||||
|
@@ -194,6 +194,7 @@ return [
|
||||
'multiple' => $multiple,
|
||||
'max' => $max,
|
||||
'api' => $this->parent->apiUrl(true) . '/files',
|
||||
'preview' => $this->image,
|
||||
'attributes' => [
|
||||
// TODO: an edge issue that needs to be solved:
|
||||
// if multiple users load the same section
|
||||
|
@@ -21,6 +21,14 @@ return [
|
||||
$layouts = ['list', 'cardlets', 'cards', 'table'];
|
||||
return in_array($layout, $layouts) ? $layout : 'list';
|
||||
},
|
||||
/**
|
||||
* Whether the raw content file values should be used for the table column previews. Should not be used unless it eases performance issues in your setup introduced with Kirby 4.2
|
||||
*
|
||||
* @todo remove when Form classes have been refactored
|
||||
*/
|
||||
'rawvalues' => function (bool $rawvalues = false) {
|
||||
return $rawvalues;
|
||||
},
|
||||
/**
|
||||
* The size option controls the size of cards. By default cards are auto-sized and the cards grid will always fill the full width. With a size you can disable auto-sizing. Available sizes: `tiny`, `small`, `medium`, `large`, `huge`, `full`
|
||||
*/
|
||||
@@ -133,6 +141,24 @@ return [
|
||||
$item['info'] = $model->toString($this->info);
|
||||
}
|
||||
|
||||
// if forcing raw values, get those directly from content file
|
||||
// TODO: remove once Form classes have been refactored
|
||||
// @codeCoverageIgnoreStart
|
||||
if ($this->rawvalues === true) {
|
||||
foreach ($this->columns as $columnName => $column) {
|
||||
$item[$columnName] = match (empty($column['value'])) {
|
||||
// if column value defined, resolve the query
|
||||
false => $model->toString($column['value']),
|
||||
// otherwise use the form value,
|
||||
// but don't overwrite columns
|
||||
default => $item[$columnName] ?? $model->content()->get($column['id'] ?? $columnName)->value()
|
||||
};
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
// Use form to get the proper values for the columns
|
||||
$form = Form::for($model)->values();
|
||||
|
||||
@@ -142,10 +168,7 @@ return [
|
||||
false => $model->toString($column['value']),
|
||||
// otherwise use the form value,
|
||||
// but don't overwrite columns
|
||||
default =>
|
||||
$item[$columnName] ??
|
||||
$form[$column['id'] ?? $columnName] ??
|
||||
null,
|
||||
default => $item[$columnName] ?? $form[$column['id'] ?? $columnName] ?? null
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -112,6 +112,11 @@ return [
|
||||
'width'
|
||||
],
|
||||
'html' => function (KirbyTag $tag): string {
|
||||
$kirby = $tag->kirby();
|
||||
|
||||
$tag->width ??= $kirby->option('kirbytext.image.width');
|
||||
$tag->height ??= $kirby->option('kirbytext.image.height');
|
||||
|
||||
if ($tag->file = $tag->file($tag->value)) {
|
||||
$tag->src = $tag->file->url();
|
||||
$tag->alt ??= $tag->file->alt()->or('')->value();
|
||||
@@ -129,6 +134,13 @@ return [
|
||||
|
||||
$tag->srcset = $tag->file->srcset($srcset);
|
||||
}
|
||||
|
||||
if ($tag->width === 'auto') {
|
||||
$tag->width = $tag->file->width();
|
||||
}
|
||||
if ($tag->height === 'auto') {
|
||||
$tag->height = $tag->file->height();
|
||||
}
|
||||
} else {
|
||||
$tag->src = Url::to($tag->value);
|
||||
}
|
||||
@@ -157,14 +169,14 @@ return [
|
||||
'alt' => $tag->alt ?? ''
|
||||
]);
|
||||
|
||||
if ($tag->kirby()->option('kirbytext.image.figure', true) === false) {
|
||||
if ($kirby->option('kirbytext.image.figure', true) === false) {
|
||||
return $link($image);
|
||||
}
|
||||
|
||||
// render KirbyText in caption
|
||||
if ($tag->caption) {
|
||||
$options = ['markdown' => ['inline' => true]];
|
||||
$caption = $tag->kirby()->kirbytext($tag->caption, $options);
|
||||
$caption = $kirby->kirbytext($tag->caption, $options);
|
||||
$tag->caption = [$caption];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user