Upgrade to 3.5.1
This commit is contained in:
@@ -11,8 +11,11 @@ return [
|
||||
'ascii' => function () {
|
||||
return Str::$ascii;
|
||||
},
|
||||
'authStatus' => function () {
|
||||
return $this->kirby()->auth()->status()->toArray();
|
||||
},
|
||||
'defaultLanguage' => function () {
|
||||
return $this->kirby()->option('panel.language', 'en');
|
||||
return $this->kirby()->panelLanguage();
|
||||
},
|
||||
'isOk' => function (System $system) {
|
||||
return $system->isOk();
|
||||
@@ -35,21 +38,17 @@ return [
|
||||
'license' => function (System $system) {
|
||||
return $system->license();
|
||||
},
|
||||
'locales' => function () {
|
||||
$locales = [];
|
||||
$translations = $this->kirby()->translations();
|
||||
foreach ($translations as $translation) {
|
||||
$locales[$translation->code()] = $translation->locale();
|
||||
}
|
||||
return $locales;
|
||||
},
|
||||
'loginMethods' => function (System $system) {
|
||||
return array_keys($system->loginMethods());
|
||||
},
|
||||
'pendingChallenge' => function () {
|
||||
if ($this->session()->get('kirby.challenge.email') === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// fake the email challenge if no challenge was created
|
||||
// to avoid leaking whether the user exists
|
||||
return $this->session()->get('kirby.challenge.type', 'email');
|
||||
},
|
||||
'pendingEmail' => function () {
|
||||
return $this->session()->get('kirby.challenge.email');
|
||||
},
|
||||
'requirements' => function (System $system) {
|
||||
return $system->toArray();
|
||||
},
|
||||
@@ -70,7 +69,7 @@ return [
|
||||
if ($user = $this->user()) {
|
||||
$translationCode = $user->language();
|
||||
} else {
|
||||
$translationCode = $this->kirby()->option('panel.language', 'en');
|
||||
$translationCode = $this->kirby()->panelLanguage();
|
||||
}
|
||||
|
||||
if ($translation = $this->kirby()->translation($translationCode)) {
|
||||
@@ -98,12 +97,11 @@ return [
|
||||
'type' => 'Kirby\Cms\System',
|
||||
'views' => [
|
||||
'login' => [
|
||||
'authStatus',
|
||||
'isOk',
|
||||
'isInstallable',
|
||||
'isInstalled',
|
||||
'loginMethods',
|
||||
'pendingChallenge',
|
||||
'pendingEmail',
|
||||
'title',
|
||||
'translation'
|
||||
],
|
||||
@@ -124,6 +122,7 @@ return [
|
||||
'kirbytext',
|
||||
'languages',
|
||||
'license',
|
||||
'locales',
|
||||
'multilang',
|
||||
'requirements',
|
||||
'site',
|
||||
|
@@ -65,7 +65,7 @@ return [
|
||||
isset($methods['password']['2fa']) === true &&
|
||||
$methods['password']['2fa'] === true
|
||||
) {
|
||||
$challenge = $auth->login2fa($email, $password, $long);
|
||||
$status = $auth->login2fa($email, $password, $long);
|
||||
} else {
|
||||
$user = $auth->login($email, $password, $long);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ return [
|
||||
throw new InvalidArgumentException('Login without password is not enabled');
|
||||
}
|
||||
|
||||
$challenge = $auth->createChallenge($email, $long, $mode);
|
||||
$status = $auth->createChallenge($email, $long, $mode);
|
||||
}
|
||||
|
||||
if (isset($user)) {
|
||||
@@ -89,11 +89,9 @@ return [
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'code' => 200,
|
||||
'status' => 'ok',
|
||||
|
||||
// don't leak users that don't exist at this point
|
||||
'challenge' => $challenge ?? 'email'
|
||||
'code' => 200,
|
||||
'status' => 'ok',
|
||||
'challenge' => $status->challenge()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -1 +1,2 @@
|
||||
<?php /** @var \Kirby\Cms\Block $block */ ?>
|
||||
<pre><code class="language-<?= $block->language()->or('text') ?>"><?= $block->code()->html(false) ?></code></pre>
|
||||
|
@@ -1,3 +1,4 @@
|
||||
<?php /** @var \Kirby\Cms\Block $block */ ?>
|
||||
<figure>
|
||||
<ul>
|
||||
<?php foreach ($block->images()->toFiles() as $image): ?>
|
||||
|
@@ -1 +1,2 @@
|
||||
<?php /** @var \Kirby\Cms\Block $block */ ?>
|
||||
<<?= $level = $block->level()->or('h2') ?>><?= $block->text() ?></<?= $level ?>>
|
||||
|
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
/** @var \Kirby\Cms\Block $block */
|
||||
$alt = $block->alt();
|
||||
$caption = $block->caption();
|
||||
$crop = $block->crop()->isTrue();
|
||||
|
@@ -1 +1,2 @@
|
||||
<?php /** @var \Kirby\Cms\Block $block */ ?>
|
||||
<?= $block->text();
|
||||
|
@@ -1 +1,2 @@
|
||||
<?php /** @var \Kirby\Cms\Block $block */ ?>
|
||||
<?= $block->text()->kt();
|
||||
|
@@ -1,3 +1,4 @@
|
||||
<?php /** @var \Kirby\Cms\Block $block */ ?>
|
||||
<blockquote>
|
||||
<?= $block->text() ?>
|
||||
<?php if ($block->citation()->isNotEmpty()): ?>
|
||||
|
@@ -1 +1,2 @@
|
||||
<?php /** @var \Kirby\Cms\Block $block */ ?>
|
||||
<?= $block->text();
|
||||
|
@@ -1,3 +1,4 @@
|
||||
<?php /** @var \Kirby\Cms\Block $block */ ?>
|
||||
<?php if ($block->url()->isNotEmpty()): ?>
|
||||
<figure>
|
||||
<?= video($block->url()) ?>
|
||||
|
@@ -106,6 +106,9 @@ return [
|
||||
return Str::upper($this->display);
|
||||
}
|
||||
},
|
||||
'format' => function () {
|
||||
return $this->props['format'] ?? ($this->time === false ? 'Y-m-d' : 'Y-m-d H:i:s');
|
||||
},
|
||||
'time' => function () {
|
||||
if ($this->time === false) {
|
||||
return false;
|
||||
@@ -127,10 +130,6 @@ return [
|
||||
return $this->toDatetime($this->value);
|
||||
},
|
||||
],
|
||||
'save' => function ($value) {
|
||||
$format = $this->time === false ? 'Y-m-d' : 'Y-m-d H:i:s';
|
||||
return $this->toContent($value, $format);
|
||||
},
|
||||
'validations' => [
|
||||
'date',
|
||||
'minMax' => function ($value) {
|
||||
|
@@ -1,6 +1,14 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'props' => [
|
||||
/**
|
||||
* Defines a custom format that is used when the field is saved
|
||||
*/
|
||||
'format' => function (string $format = null) {
|
||||
return $format;
|
||||
}
|
||||
],
|
||||
'methods' => [
|
||||
'toDatetime' => function ($value, string $format = 'Y-m-d H:i:s') {
|
||||
if ($timestamp = timestamp($value, $this->step)) {
|
||||
@@ -8,13 +16,13 @@ return [
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
'toContent' => function ($value, string $format = 'Y-m-d H:i:s') {
|
||||
if ($value !== null && $timestamp = strtotime($value)) {
|
||||
return date($format, $timestamp);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
]
|
||||
],
|
||||
'save' => function ($value) {
|
||||
if ($value !== null && $timestamp = strtotime($value)) {
|
||||
return date($this->format, $timestamp);
|
||||
}
|
||||
|
||||
return '';
|
||||
},
|
||||
];
|
||||
|
@@ -95,13 +95,13 @@ return [
|
||||
|
||||
return $this->notation === 24 ? 'HH:mm' : 'h:mm a';
|
||||
},
|
||||
'format' => function () {
|
||||
return $this->props['format'] ?? 'H:i:s';
|
||||
},
|
||||
'value' => function () {
|
||||
return $this->toDatetime($this->value, 'H:i:s');
|
||||
}
|
||||
],
|
||||
'save' => function ($value): string {
|
||||
return $this->toContent($value, 'H:i:s');
|
||||
},
|
||||
'validations' => [
|
||||
'time',
|
||||
'minMax' => function ($value) {
|
||||
|
@@ -5,6 +5,7 @@ use Kirby\Cms\Asset;
|
||||
use Kirby\Cms\Html;
|
||||
use Kirby\Cms\Response;
|
||||
use Kirby\Cms\Url;
|
||||
use Kirby\Exception\InvalidArgumentException;
|
||||
use Kirby\Toolkit\Escape;
|
||||
use Kirby\Toolkit\F;
|
||||
use Kirby\Toolkit\I18n;
|
||||
@@ -110,7 +111,7 @@ function css($url, $options = null): ?string
|
||||
}
|
||||
}
|
||||
|
||||
$url = $kirby->component('css')($kirby, $url, $options);
|
||||
$url = ($kirby->component('css'))($kirby, $url, $options);
|
||||
$url = Url::to($url);
|
||||
$attr = array_merge((array)$options, [
|
||||
'href' => $url,
|
||||
@@ -148,7 +149,7 @@ if (function_exists('dump') === false) {
|
||||
function dump($variable, bool $echo = true): string
|
||||
{
|
||||
$kirby = App::instance();
|
||||
return $kirby->component('dump')($kirby, $variable, $echo);
|
||||
return ($kirby->component('dump'))($kirby, $variable, $echo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,7 +383,7 @@ function js($url, $options = null): ?string
|
||||
}
|
||||
}
|
||||
|
||||
$url = $kirby->component('js')($kirby, $url, $options);
|
||||
$url = ($kirby->component('js'))($kirby, $url, $options);
|
||||
$url = Url::to($url);
|
||||
$attr = array_merge((array)$options, ['src' => $url]);
|
||||
|
||||
@@ -623,7 +624,7 @@ function site()
|
||||
function size($value): int
|
||||
{
|
||||
if (is_numeric($value)) {
|
||||
return $value;
|
||||
return (int)$value;
|
||||
}
|
||||
|
||||
if (is_string($value)) {
|
||||
@@ -643,6 +644,8 @@ function size($value): int
|
||||
return $value->count();
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException('Could not determine the size of the given value');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -744,9 +747,9 @@ function tc($key, int $count)
|
||||
*
|
||||
* @param string $date
|
||||
* @param int $step array of `unit` and `size` to round to nearest
|
||||
* @return string|null
|
||||
* @return int|null
|
||||
*/
|
||||
function timestamp(string $date = null, $step = null): ?string
|
||||
function timestamp(string $date = null, $step = null): ?int
|
||||
{
|
||||
if (V::date($date) === false) {
|
||||
return null;
|
||||
@@ -791,7 +794,7 @@ function timestamp(string $date = null, $step = null): ?string
|
||||
$parts[$part] = 0;
|
||||
}
|
||||
|
||||
return strtotime(
|
||||
$timestamp = strtotime(
|
||||
$parts['year'] . '-' .
|
||||
str_pad($parts['month'], 2, 0, STR_PAD_LEFT) . '-' .
|
||||
str_pad($parts['day'], 2, 0, STR_PAD_LEFT) . ' ' .
|
||||
@@ -799,6 +802,9 @@ function timestamp(string $date = null, $step = null): ?string
|
||||
str_pad($parts['minute'], 2, 0, STR_PAD_LEFT) . ':' .
|
||||
str_pad($parts['second'], 2, 0, STR_PAD_LEFT)
|
||||
);
|
||||
|
||||
// on error, convert `false` into `null`
|
||||
return $timestamp ? $timestamp : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -127,7 +127,7 @@ return function (App $app) {
|
||||
return $time;
|
||||
}
|
||||
|
||||
return $app->option('date.handler', 'date')($format, $time);
|
||||
return ($app->option('date.handler', 'date'))($format, $time);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@@ -5,11 +5,6 @@
|
||||
*/
|
||||
define('DS', '/');
|
||||
|
||||
/**
|
||||
* Load files that can't be autoloaded
|
||||
*/
|
||||
require_once __DIR__ . '/helpers.php';
|
||||
|
||||
/**
|
||||
* Class aliases
|
||||
*/
|
||||
|
@@ -1,3 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @var \Kirby\Cms\User $user
|
||||
* @var string $code
|
||||
* @var int $timeout
|
||||
*/
|
||||
echo I18n::template('login.email.login.body', null, compact('user', 'code', 'timeout'));
|
||||
|
@@ -1,3 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @var \Kirby\Cms\User $user
|
||||
* @var string $code
|
||||
* @var int $timeout
|
||||
*/
|
||||
echo I18n::template('login.email.password-reset.body', null, compact('user', 'code', 'timeout'));
|
||||
|
Reference in New Issue
Block a user