Upgrade to 3.0.2

This commit is contained in:
Bastian Allgeier
2019-02-19 16:39:58 +01:00
parent f76ee1bb14
commit 8e3d86a590
44 changed files with 638 additions and 264 deletions

View File

@@ -3,6 +3,7 @@
$aliases = [
// cms classes
'asset' => 'Kirby\Cms\Asset',
'collection' => 'Kirby\Cms\Collection',
'dir' => 'Kirby\Cms\Dir',
'field' => 'Kirby\Cms\Field',

View File

@@ -32,7 +32,11 @@ return [
return $system->toArray();
},
'breadcrumbTitle' => function () {
return $this->site()->blueprint()->title();
try {
return $this->site()->blueprint()->title();
} catch (Throwable $e) {
return $this->site()->title()->value();
}
},
'title' => function () {
return $this->site()->title()->value();

View File

@@ -14,7 +14,7 @@ use Kirby\Toolkit\F;
use Kirby\Toolkit\Tpl as Snippet;
return [
'file::version' => function (App $kirby, Model $file, array $options = []) {
'file::version' => function (App $kirby, $file, array $options = []) {
if ($file->isResizable() === false) {
return $file;
}
@@ -24,8 +24,7 @@ return [
$attributes = $darkroom->preprocess($file->root(), $options);
// create url and root
$parent = $file->parent();
$mediaRoot = $parent->mediaRoot() . '/' . $file->mediaHash();
$mediaRoot = dirname($file->mediaRoot());
$dst = $mediaRoot . '/{{ name }}{{ attributes }}.{{ extension }}';
$thumbRoot = (new Filename($file->root(), $dst, $attributes))->toString();
$thumbName = basename($thumbRoot);
@@ -45,10 +44,10 @@ return [
'modifications' => $options,
'original' => $file,
'root' => $thumbRoot,
'url' => $parent->mediaUrl() . '/' . $file->mediaHash() . '/' . $thumbName,
'url' => dirname($file->mediaUrl()) . '/' . $thumbName,
]);
},
'file::url' => function (App $kirby, Model $file) {
'file::url' => function (App $kirby, $file) {
return $file->mediaUrl();
},
'markdown' => function (App $kirby, string $text = null, array $options = []): string {

View File

@@ -3,6 +3,12 @@
return [
'extends' => 'tags',
'props' => [
/**
* Unset inherited props
*/
'accept' => null,
/**
* Custom icon to replace the arrow down.
*/

View File

@@ -36,10 +36,7 @@ return [
return null;
}
$value = str_replace(',', '.', $value);
$value = floatval($value);
return $value;
return (float)Str::float($value);
}
],
'validations' => [

View File

@@ -1,6 +1,7 @@
<?php
use Kirby\Cms\App;
use Kirby\Cms\Asset;
use Kirby\Cms\Html;
use Kirby\Cms\Response;
use Kirby\Cms\Url;
@@ -11,6 +12,17 @@ use Kirby\Toolkit\F;
use Kirby\Toolkit\I18n;
use Kirby\Toolkit\View;
/**
* Helper to create an asset object
*
* @param string $path
* @return Asset
*/
function asset(string $path)
{
return new Asset($path);
}
/**
* Generates a list of HTML attributes
*
@@ -425,6 +437,9 @@ function kirbytext(string $text = null, array $data = []): string
*/
function load(array $classmap, string $base = null)
{
// convert all classnames to lowercase
$classmap = array_change_key_case($classmap);
spl_autoload_register(function ($class) use ($classmap, $base) {
$class = strtolower($class);
@@ -640,15 +655,25 @@ function snippet(string $name, $data = [], bool $return = false)
*/
function svg(string $file)
{
$root = App::instance()->root();
$file = $root . '/' . $file;
$extension = F::extension($file);
if (file_exists($file) === false) {
// check for valid svg files
if ($extension !== 'svg') {
return false;
}
// try to convert relative paths to absolute
if (file_exists($file) === false) {
$root = App::instance()->root();
$file = realpath($root . '/' . $file);
if (file_exists($file) === false) {
return false;
}
}
ob_start();
include F::realpath($file, $root);
include $file;
$svg = ob_get_contents();
ob_end_clean();

View File

@@ -56,9 +56,6 @@ return [
'controllers' => function (array $roots) {
return $roots['site'] . '/controllers';
},
'emails' => function (array $roots) {
return $roots['site'] . '/emails';
},
'languages' => function (array $roots) {
return $roots['site'] . '/languages';
},

View File

@@ -94,6 +94,13 @@ return function ($kirby) {
'action' => function ($id, $hash, $filename) use ($kirby) {
return Media::link($kirby->user($id), $hash, $filename);
}
],
[
'pattern' => 'media/assets/(:all)/(:any)/(:any)',
'env' => 'media',
'action' => function ($path, $hash, $filename) use ($kirby) {
return Media::thumb($path, $hash, $filename);
}
]
];

View File

@@ -67,6 +67,12 @@ return [
return $status;
},
/**
* Filters the list by templates and sets template options when adding new pages to the section.
*/
'templates' => function ($templates = null) {
return A::wrap($templates ?? $this->template);
},
/**
* Setup for the main text in the list or cards. By default this will display the page title.
*/
@@ -78,9 +84,6 @@ return [
'dragTextType' => function () {
return option('panel.kirbytext', true) ? 'kirbytext' : 'markdown';
},
'templates' => function () {
return A::wrap($this->templates ?? $this->template);
},
'parent' => function () {
return $this->parentModel();
},