Upgrade to 3.3.0
This commit is contained in:
@@ -5,7 +5,6 @@ use Kirby\Cms\Asset;
|
||||
use Kirby\Cms\Html;
|
||||
use Kirby\Cms\Response;
|
||||
use Kirby\Cms\Url;
|
||||
use Kirby\Http\Server;
|
||||
use Kirby\Toolkit\Escape;
|
||||
use Kirby\Toolkit\F;
|
||||
use Kirby\Toolkit\I18n;
|
||||
@@ -55,7 +54,7 @@ function collection(string $name)
|
||||
* Checks / returns a CSRF token
|
||||
*
|
||||
* @param string $check Pass a token here to compare it to the one in the session
|
||||
* @return string|boolean Either the token or a boolean check result
|
||||
* @return string|bool Either the token or a boolean check result
|
||||
*/
|
||||
function csrf(string $check = null)
|
||||
{
|
||||
@@ -89,7 +88,7 @@ function csrf(string $check = null)
|
||||
* @param string|array $options Pass an array of attributes for the link tag or a media attribute string
|
||||
* @return string|null
|
||||
*/
|
||||
function css($url, $options = null)
|
||||
function css($url, $options = null): ?string
|
||||
{
|
||||
if (is_array($url) === true) {
|
||||
$links = array_map(function ($url) use ($options) {
|
||||
@@ -121,27 +120,33 @@ function css($url, $options = null)
|
||||
return '<link ' . attr($attr) . '>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers a deprecation warning if debug mode is active
|
||||
*
|
||||
* @param string $message
|
||||
* @return bool Whether the warning was triggered
|
||||
*/
|
||||
function deprecated(string $message): bool
|
||||
{
|
||||
if (App::instance()->option('debug') === true) {
|
||||
return trigger_error($message, E_USER_DEPRECATED) === true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple object and variable dumper
|
||||
* to help with debugging.
|
||||
*
|
||||
* @param mixed $variable
|
||||
* @param boolean $echo
|
||||
* @param bool $echo
|
||||
* @return string
|
||||
*/
|
||||
function dump($variable, bool $echo = true): string
|
||||
{
|
||||
if (Server::cli() === true) {
|
||||
$output = print_r($variable, true) . PHP_EOL;
|
||||
} else {
|
||||
$output = '<pre>' . print_r($variable, true) . '</pre>';
|
||||
}
|
||||
|
||||
if ($echo === true) {
|
||||
echo $output;
|
||||
}
|
||||
|
||||
return $output;
|
||||
$kirby = App::instance();
|
||||
return $kirby->component('dump')($kirby, $variable, $echo);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,10 +164,10 @@ function e($condition, $value, $alternative = null)
|
||||
/**
|
||||
* Escape context specific output
|
||||
*
|
||||
* @param string $string Untrusted data
|
||||
* @param string $context Location of output
|
||||
* @param boolean $strict Whether to escape an extended set of characters (HTML attributes only)
|
||||
* @return string Escaped data
|
||||
* @param string $string Untrusted data
|
||||
* @param string $context Location of output
|
||||
* @param bool $strict Whether to escape an extended set of characters (HTML attributes only)
|
||||
* @return string Escaped data
|
||||
*/
|
||||
function esc($string, $context = 'html', $strict = false)
|
||||
{
|
||||
@@ -177,9 +182,9 @@ function esc($string, $context = 'html', $strict = false)
|
||||
/**
|
||||
* Shortcut for $kirby->request()->get()
|
||||
*
|
||||
* @param mixed $key The key to look for. Pass false or null to return the entire request array.
|
||||
* @param mixed $default Optional default value, which should be returned if no element has been found
|
||||
* @return mixed
|
||||
* @param mixed $key The key to look for. Pass false or null to return the entire request array.
|
||||
* @param mixed $default Optional default value, which should be returned if no element has been found
|
||||
* @return mixed
|
||||
*/
|
||||
function get($key = null, $default = null)
|
||||
{
|
||||
@@ -206,7 +211,7 @@ function gist(string $url, string $file = null): string
|
||||
* Urls can be relative or absolute.
|
||||
*
|
||||
* @param string $url
|
||||
* @param integer $code
|
||||
* @param int $code
|
||||
* @return void
|
||||
*/
|
||||
function go(string $url = null, int $code = 302)
|
||||
@@ -348,9 +353,9 @@ function invalid(array $data = [], array $rules = [], array $messages = [])
|
||||
*
|
||||
* @param string|array $url
|
||||
* @param string|array $options
|
||||
* @return void
|
||||
* @return string|null
|
||||
*/
|
||||
function js($url, $options = null)
|
||||
function js($url, $options = null): ?string
|
||||
{
|
||||
if (is_array($url) === true) {
|
||||
$scripts = array_map(function ($url) use ($options) {
|
||||
@@ -589,7 +594,7 @@ function r($condition, $value, $alternative = null)
|
||||
* by the defined step
|
||||
*
|
||||
* @param string $date
|
||||
* @param integer $step
|
||||
* @param int $step
|
||||
* @return string|null
|
||||
*/
|
||||
function timestamp(string $date = null, int $step = null): ?string
|
||||
@@ -671,7 +676,7 @@ function smartypants(string $text = null): string
|
||||
*
|
||||
* @param string|array $name
|
||||
* @param array|object $data
|
||||
* @param boolean $return
|
||||
* @param bool $return
|
||||
* @return string
|
||||
*/
|
||||
function snippet($name, $data = [], bool $return = false)
|
||||
@@ -693,11 +698,20 @@ function snippet($name, $data = [], bool $return = false)
|
||||
* Includes an SVG file by absolute or
|
||||
* relative file path.
|
||||
*
|
||||
* @param string $file
|
||||
* @return string
|
||||
* @param string|\Kirby\Cms\File $file
|
||||
* @return string|false
|
||||
*/
|
||||
function svg(string $file)
|
||||
function svg($file)
|
||||
{
|
||||
// support for Kirby's file objects
|
||||
if (is_a($file, 'Kirby\Cms\File') === true && $file->extension() === 'svg') {
|
||||
return $file->read();
|
||||
}
|
||||
|
||||
if (is_string($file) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$extension = F::extension($file);
|
||||
|
||||
// check for valid svg files
|
||||
@@ -721,9 +735,9 @@ function svg(string $file)
|
||||
/**
|
||||
* Returns translate string for key from translation file
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param string|null $fallback
|
||||
* @return mixed
|
||||
* @param string|array $key
|
||||
* @param string|null $fallback
|
||||
* @return mixed
|
||||
*/
|
||||
function t($key, string $fallback = null)
|
||||
{
|
||||
@@ -733,9 +747,9 @@ function t($key, string $fallback = null)
|
||||
/**
|
||||
* Translates a count
|
||||
*
|
||||
* @param string|array $key
|
||||
* @param int $count
|
||||
* @return mixed
|
||||
* @param string|array $key
|
||||
* @param int $count
|
||||
* @return mixed
|
||||
*/
|
||||
function tc($key, int $count)
|
||||
{
|
||||
@@ -825,7 +839,7 @@ function video(string $url, array $options = [], array $attr = []): string
|
||||
*/
|
||||
function vimeo(string $url, array $options = [], array $attr = []): string
|
||||
{
|
||||
return Html::video($url, $options, $attr);
|
||||
return Html::vimeo($url, $options, $attr);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -851,5 +865,5 @@ function widont(string $string = null): string
|
||||
*/
|
||||
function youtube(string $url, array $options = [], array $attr = []): string
|
||||
{
|
||||
return Html::video($url, $options, $attr);
|
||||
return Html::youtube($url, $options, $attr);
|
||||
}
|
||||
|
Reference in New Issue
Block a user