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

@@ -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();