Upgrade to 3.1.2

This commit is contained in:
Bastian Allgeier
2019-04-09 14:34:12 +02:00
parent 852a14595e
commit eb29ef6d6c
58 changed files with 535 additions and 258 deletions

View File

@@ -27,7 +27,7 @@ return [
return $page->errors();
},
'files' => function (Page $page) {
return $page->files();
return $page->files()->sortBy('sort', 'asc');
},
'hasChildren' => function (Page $page) {
return $page->hasChildren();

View File

@@ -20,8 +20,11 @@ return [
'content' => function (Site $site) {
return Form::for($site)->values();
},
'drafts' => function (Site $site) {
return $site->drafts();
},
'files' => function (Site $site) {
return $site->files();
return $site->files()->sortBy('sort', 'asc');
},
'options' => function (Site $site) {
return $site->permissions()->toArray();

View File

@@ -23,6 +23,9 @@ return [
'email' => function (User $user) {
return $user->email();
},
'files' => function (User $user) {
return $user->files()->sortBy('sort', 'asc');
},
'id' => function (User $user) {
return $user->id();
},

View File

@@ -29,7 +29,7 @@ return [
'pattern' => '(:all)/files',
'method' => 'GET',
'action' => function (string $path) {
return $this->parent($path)->files();
return $this->parent($path)->files()->sortBy('sort', 'asc');
}
],
[
@@ -62,7 +62,10 @@ return [
'pattern' => '(:all)/files/sort',
'method' => 'PATCH',
'action' => function (string $path) {
return $this->parent($path)->files()->changeSort($this->requestBody('files'));
return $this->parent($path)->files()->changeSort(
$this->requestBody('files'),
$this->requestBody('index')
);
}
],
[

View File

@@ -1,8 +1,10 @@
<?php
use Kirby\Cms\App;
use Kirby\Cms\File;
use Kirby\Cms\Filename;
use Kirby\Cms\FileVersion;
use Kirby\Cms\FileModifications;
use Kirby\Cms\Model;
use Kirby\Cms\Response;
use Kirby\Cms\Template;
@@ -15,6 +17,37 @@ use Kirby\Toolkit\F;
use Kirby\Toolkit\Tpl as Snippet;
return [
/**
* Used by the `css()` helper
*
* @param Kirby\Cms\App $kirby Kirby instance
* @param string $url Relative or absolute URL
* @param string|array $options An array of attributes for the link tag or a media attribute string
*/
'css' => function (App $kirby, string $url, $options = null): string {
return $url;
},
/**
* Modify URLs for file objects
*
* @param Kirby\Cms\App $kirby Kirby instance
* @param Kirby\Cms\File $file The original file object
* @return string
*/
'file::url' => function (App $kirby, File $file): string {
return $file->mediaUrl();
},
/**
* Adapt file characteristics
*
* @param Kirby\Cms\App $kirby Kirby instance
* @param Kirby\Cms\File|Kirby\Cms\FileModifications $file The file object
* @param array $options All thumb options (width, height, crop, blur, grayscale)
* @return Kirby\Cms\File|Kirby\Cms\FileVersion
*/
'file::version' => function (App $kirby, $file, array $options = []) {
if ($file->isResizable() === false) {
return $file;
@@ -48,9 +81,27 @@ return [
'url' => dirname($file->mediaUrl()) . '/' . $thumbName,
]);
},
'file::url' => function (App $kirby, $file) {
return $file->mediaUrl();
/**
* Used by the `js()` helper
*
* @param Kirby\Cms\App $kirby Kirby instance
* @param string $url Relative or absolute URL
* @param string|array $options An array of attributes for the link tag or a media attribute string
*/
'js' => function (App $kirby, string $url, $options = null): string {
return $url;
},
/**
* Add your own Markdown parser
*
* @param Kirby\Cms\App $kirby Kirby instance
* @param string $text Text to parse
* @param array $options Markdown options
* @param bool $inline Whether to wrap the text in `<p>` tags
* @return string
*/
'markdown' => function (App $kirby, string $text = null, array $options = [], bool $inline = false): string {
static $markdown;
@@ -58,6 +109,15 @@ return [
return $markdown->parse($text, $inline);
},
/**
* Add your own SmartyPants parser
*
* @param Kirby\Cms\App $kirby Kirby instance
* @param string $text Text to parse
* @param array $options SmartyPants options
* @return string
*/
'smartypants' => function (App $kirby, string $text = null, array $options = []): string {
static $smartypants;
@@ -65,7 +125,16 @@ return [
return $smartypants->parse($text);
},
'snippet' => function (App $kirby, string $name, array $data = []) {
/**
* Add your own snippet loader
*
* @param Kirby\Cms\App $kirby Kirby instance
* @param string $name Snippet name
* @param array $data Data array for the snippet
* @return string|null
*/
'snippet' => function (App $kirby, string $name, array $data = []): ?string {
$file = $kirby->root('snippets') . '/' . $name . '.php';
if (file_exists($file) === false) {
@@ -74,10 +143,30 @@ return [
return Snippet::load($file, $data);
},
/**
* Add your own template engine
*
* @param Kirby\Cms\App $kirby Kirby instance
* @param string $name Template name
* @param string $type Extension type
* @param string $defaultType Default extension type
* @return Kirby\Cms\Template
*/
'template' => function (App $kirby, string $name, string $type = 'html', string $defaultType = 'html') {
return new Template($name, $type, $defaultType);
},
'thumb' => function (App $kirby, string $src, string $dst, array $options) {
/**
* Add your own thumb generator
*
* @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 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 {
$darkroom = Darkroom::factory(option('thumbs.driver', 'gd'), option('thumbs', []));
$options = $darkroom->preprocess($src, $options);
$root = (new Filename($src, $dst, $options))->toString();
@@ -87,4 +176,18 @@ return [
return $root;
},
/**
* Modify all URLs
*
* @param Kirby\Cms\App $kirby Kirby instance
* @param string $path URL path
* @param array|null $options Array of options for the Uri class
* @param Closure $originalHandler Callback function to the original URL handler with `$path` and `$options` as parameters
* @return string
*/
'url' => function (App $kirby, string $path = null, $options = [], Closure $originalHandler): string {
return $originalHandler($path, $options);
},
];

View File

@@ -4,7 +4,7 @@ use Kirby\Toolkit\A;
use Kirby\Toolkit\Str;
return [
'mixins' => ['options'],
'mixins' => ['min', 'options'],
'props' => [
/**
* Unset inherited props

View File

@@ -3,6 +3,7 @@
use Kirby\Toolkit\A;
return [
'mixins' => ['min'],
'props' => [
/**
* Unset inherited props

View File

@@ -0,0 +1,22 @@
<?php
return [
'computed' => [
'min' => function () {
// set min to at least 1, if required
if ($this->required === true) {
return $this->min ?? 1;
}
return $this->min;
},
'required' => function () {
// set required to true if min is set
if ($this->min) {
return true;
}
return $this->required;
}
]
];

View File

@@ -4,6 +4,7 @@ use Kirby\Toolkit\A;
use Kirby\Toolkit\I18n;
return [
'mixins' => ['min'],
'props' => [
/**
* Unset inherited props

View File

@@ -4,6 +4,7 @@ use Kirby\Cms\Form;
use Kirby\Cms\Blueprint;
return [
'mixins' => ['min'],
'props' => [
/**
* Unset inherited props
@@ -28,6 +29,14 @@ return [
'empty' => function ($empty = null) {
return I18n::translate($empty, $empty);
},
/**
* Set the default rows for the structure
*/
'default' => function (array $default = null) {
return $default;
},
/**
* Fields setup for the structure form. Works just like fields in regular forms.
*/
@@ -113,7 +122,7 @@ return [
}
return $columns;
},
}
],
'methods' => [
'rows' => function ($value) {
@@ -149,11 +158,11 @@ return [
]
];
},
'save' => function () {
'save' => function ($value) {
$data = [];
foreach ($this->value() as $row) {
$data[] = $this->form($row)->data();
foreach ($value as $row) {
$data[] = $this->form($row)->data(true);
}
return $data;

View File

@@ -1,7 +1,7 @@
<?php
return [
'mixins' => ['options'],
'mixins' => ['min', 'options'],
'props' => [
/**

View File

@@ -9,7 +9,7 @@ return [
'before' => null,
/**
* Enables/disables the format buttons. Can either be true/false or a list of allowed buttons. Available buttons: headlines, italic, bold, link, email, list, code, ul, ol
* Enables/disables the format buttons. Can either be true/false or a list of allowed buttons. Available buttons: headlines, italic, bold, link, email, file, list, code, ul, ol
*/
'buttons' => function ($buttons = true) {
return $buttons;

View File

@@ -1,6 +1,7 @@
<?php
return [
'mixins' => ['min'],
'props' => [
/**
* Unset inherited props

View File

@@ -105,16 +105,13 @@ function css($url, $options = null)
$kirby = App::instance();
if ($component = $kirby->component('css')) {
$url = $component($kirby, $url, $options);
}
if ($url === '@auto') {
if (!$url = Url::toTemplateAsset('css/templates', 'css')) {
return null;
}
}
$url = $kirby->component('css')($kirby, $url, $options);
$url = Url::to($url);
$attr = array_merge((array)$options, [
'href' => $url,
@@ -264,10 +261,20 @@ function image(string $path = null)
$uri = null;
}
$page = $uri === '/' ? site() : page($uri);
switch ($uri) {
case '/':
$parent = site();
break;
case null:
$parent = page();
break;
default:
$parent = page($uri);
break;
}
if ($page) {
return $page->image($filename);
if ($parent) {
return $parent->image($filename);
} else {
return null;
}
@@ -359,16 +366,13 @@ function js($url, $options = null)
$kirby = App::instance();
if ($component = $kirby->component('js')) {
$url = $component($kirby, $url, $options);
}
if ($url === '@auto') {
if (!$url = Url::toTemplateAsset('js/templates', 'js')) {
return null;
}
}
$url = $kirby->component('js')($kirby, $url, $options);
$url = Url::to($url);
$attr = array_merge((array)$options, ['src' => $url]);
@@ -711,12 +715,7 @@ function svg(string $file)
}
}
ob_start();
include $file;
$svg = ob_get_contents();
ob_end_clean();
return $svg;
return F::read($file);
}
/**

View File

@@ -5,7 +5,6 @@ use Kirby\Toolkit\I18n;
return [
'mixins' => [
'headline',
'help'
],
'props' => [
'text' => function ($text = null) {

View File

@@ -8,21 +8,5 @@ return [
'empty' => function ($empty = null) {
return I18n::translate($empty, $empty);
}
],
'methods' => [
'isFull' => function () {
if ($this->max) {
return $this->total >= $this->max;
}
return false;
},
'validateMax' => function () {
if ($this->max && $this->max < $this->total) {
return false;
}
return true;
}
]
];

View File

@@ -18,7 +18,7 @@ return [
return false;
},
'validateMax' => function () {
if ($this->max && $this->max < $this->total) {
if ($this->max && $this->total > $this->max) {
return false;
}

View File

@@ -188,7 +188,7 @@ return [
}
if ($this->validateMin() === false) {
$errors['min'] = I18n::template('error.section.pages.min.' . I18n::form($this->max), [
$errors['min'] = I18n::template('error.section.pages.min.' . I18n::form($this->min), [
'min' => $this->min,
'section' => $this->headline
]);
@@ -228,7 +228,7 @@ return [
return $this->pagination();
},
'sortable' => function () {
if ($this->status !== 'listed' && $this->status !== 'all') {
if (in_array($this->status, ['listed', 'published', 'all']) === false) {
return false;
}