Upgrade to 3.5.6
This commit is contained in:
@@ -82,6 +82,7 @@ class Auth
|
||||
/**
|
||||
* Creates an authentication challenge
|
||||
* (one-time auth code)
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param string $email
|
||||
* @param bool $long If `true`, a long session will be created
|
||||
@@ -284,6 +285,7 @@ class Auth
|
||||
/**
|
||||
* Returns the list of enabled challenges in the
|
||||
* configured order
|
||||
* @since 3.5.1
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -406,6 +408,7 @@ class Auth
|
||||
|
||||
/**
|
||||
* Login a user by email, password and auth challenge
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param string $email
|
||||
* @param string $password
|
||||
@@ -442,6 +445,7 @@ class Auth
|
||||
|
||||
/**
|
||||
* Returns the authentication status object
|
||||
* @since 3.5.1
|
||||
*
|
||||
* @param \Kirby\Session\Session|array|null $session
|
||||
* @param bool $allowImpersonation If set to false, only the actually
|
||||
@@ -760,6 +764,7 @@ class Auth
|
||||
* Verifies an authentication code that was
|
||||
* requested with the `createChallenge()` method;
|
||||
* if successful, the user is automatically logged in
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param string $code User-provided auth code to verify
|
||||
* @return \Kirby\Cms\User User object of the logged-in user
|
||||
@@ -822,7 +827,7 @@ class Auth
|
||||
throw new PermissionException(['key' => 'access.code']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
throw new LogicException('Invalid authentication challenge: ' . $challenge);
|
||||
} catch (Throwable $e) {
|
||||
if ($e->getMessage() !== 'Rate limit exceeded') {
|
||||
|
@@ -9,6 +9,7 @@ use Kirby\Toolkit\Properties;
|
||||
/**
|
||||
* Information container for the
|
||||
* authentication status
|
||||
* @since 3.5.1
|
||||
*
|
||||
* @package Kirby Cms
|
||||
* @author Lukas Bestle <lukas@getkirby.com>
|
||||
|
@@ -10,6 +10,7 @@ use Throwable;
|
||||
* Represents a single block
|
||||
* which can be inspected further or
|
||||
* converted to HTML
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @package Kirby Cms
|
||||
* @author Bastian Allgeier <bastian@getkirby.com>
|
||||
|
@@ -2,6 +2,17 @@
|
||||
|
||||
namespace Kirby\Cms;
|
||||
|
||||
/**
|
||||
* Converts the data from the old builder and editor fields
|
||||
* to the format supported by the new block field.
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @package Kirby Cms
|
||||
* @author Bastian Allgeier <bastian@getkirby.com>
|
||||
* @link https://getkirby.com
|
||||
* @copyright Bastian Allgeier GmbH
|
||||
* @license https://getkirby.com/license
|
||||
*/
|
||||
class BlockConverter
|
||||
{
|
||||
public static function builderBlock(array $params): array
|
||||
|
@@ -13,6 +13,7 @@ use Throwable;
|
||||
|
||||
/**
|
||||
* A collection of blocks
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @package Kirby Cms
|
||||
* @author Bastian Allgeier <bastian@getkirby.com>
|
||||
|
@@ -10,6 +10,7 @@ use Kirby\Toolkit\Controller;
|
||||
* The Event object is created whenever the `$kirby->trigger()`
|
||||
* or `$kirby->apply()` methods are called. It collects all
|
||||
* event information and handles calling the individual hooks.
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @package Kirby Cms
|
||||
* @author Lukas Bestle <lukas@getkirby.com>,
|
||||
|
@@ -8,6 +8,7 @@ use Kirby\Toolkit\Str;
|
||||
|
||||
/**
|
||||
* Represents a single Fieldset
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @package Kirby Cms
|
||||
* @author Bastian Allgeier <bastian@getkirby.com>
|
||||
|
@@ -8,6 +8,7 @@ use Kirby\Toolkit\Str;
|
||||
|
||||
/**
|
||||
* A collection of fieldsets
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @package Kirby Cms
|
||||
* @author Bastian Allgeier <bastian@getkirby.com>
|
||||
|
@@ -10,6 +10,7 @@ namespace Kirby\Cms;
|
||||
* - a Block in a collection of Blocks
|
||||
* - a Layout in a collection of Layouts
|
||||
* - a Column in a collection of Columns
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @package Kirby Cms
|
||||
* @author Bastian Allgeier <bastian@getkirby.com>
|
||||
|
@@ -7,6 +7,7 @@ use Exception;
|
||||
|
||||
/**
|
||||
* A collection of items
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @package Kirby Cms
|
||||
* @author Bastian Allgeier <bastian@getkirby.com>
|
||||
|
@@ -5,6 +5,7 @@ namespace Kirby\Cms;
|
||||
/**
|
||||
* Represents a single Layout with
|
||||
* multiple columns
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @package Kirby Cms
|
||||
* @author Bastian Allgeier <bastian@getkirby.com>
|
||||
@@ -77,6 +78,7 @@ class Layout extends Item
|
||||
|
||||
/**
|
||||
* Checks if the layout is empty
|
||||
* @since 3.5.2
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -92,6 +94,7 @@ class Layout extends Item
|
||||
|
||||
/**
|
||||
* Checks if the layout is not empty
|
||||
* @since 3.5.2
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
@@ -7,6 +7,7 @@ use Kirby\Toolkit\Str;
|
||||
/**
|
||||
* Represents a single layout column with
|
||||
* multiple blocks
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @package Kirby Cms
|
||||
* @author Bastian Allgeier <bastian@getkirby.com>
|
||||
@@ -56,6 +57,7 @@ class LayoutColumn extends Item
|
||||
|
||||
/**
|
||||
* Checks if the column is empty
|
||||
* @since 3.5.2
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -69,6 +71,7 @@ class LayoutColumn extends Item
|
||||
|
||||
/**
|
||||
* Checks if the column is not empty
|
||||
* @since 3.5.2
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
@@ -4,6 +4,7 @@ namespace Kirby\Cms;
|
||||
|
||||
/**
|
||||
* A collection of layout columns
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @package Kirby Cms
|
||||
* @author Bastian Allgeier <bastian@getkirby.com>
|
||||
|
@@ -4,6 +4,7 @@ namespace Kirby\Cms;
|
||||
|
||||
/**
|
||||
* A collection of layouts
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @package Kirby Cms
|
||||
* @author Bastian Allgeier <bastian@getkirby.com>
|
||||
|
@@ -91,6 +91,7 @@ class Responder
|
||||
* Setter and getter for the flag that defines
|
||||
* whether the current response can be cached
|
||||
* by Kirby's cache
|
||||
* @since 3.5.5
|
||||
*
|
||||
* @param bool|null $cache
|
||||
* @return bool|$this
|
||||
@@ -108,6 +109,7 @@ class Responder
|
||||
/**
|
||||
* Setter and getter for the cache expiry
|
||||
* timestamp for Kirby's cache
|
||||
* @since 3.5.5
|
||||
*
|
||||
* @param int|string|null $expires Timestamp, number of minutes or time string to parse
|
||||
* @param bool $override If `true`, the already defined timestamp will be overridden
|
||||
|
@@ -51,7 +51,8 @@ class Db
|
||||
'user' => Config::get('db.user', 'root'),
|
||||
'password' => Config::get('db.password', ''),
|
||||
'database' => Config::get('db.database', ''),
|
||||
'prefix' => Config::get('db.prefix', '')
|
||||
'prefix' => Config::get('db.prefix', ''),
|
||||
'port' => Config::get('db.port', '')
|
||||
];
|
||||
$params = $params ?? $defaults;
|
||||
|
||||
|
@@ -9,6 +9,7 @@ use Kirby\Toolkit\F;
|
||||
* Base handler abstract,
|
||||
* which needs to be extended to
|
||||
* create valid sane handlers
|
||||
* @since 3.5.4
|
||||
*
|
||||
* @package Kirby Sane
|
||||
* @author Lukas Bestle <lukas@getkirby.com>
|
||||
|
@@ -10,6 +10,7 @@ use Kirby\Toolkit\F;
|
||||
* don't contain potentially harmful contents.
|
||||
* The class comes with handlers for `svg`, `svgz` and `xml`
|
||||
* files for now, but can be extended and customized.
|
||||
* @since 3.5.4
|
||||
*
|
||||
* @package Kirby Sane
|
||||
* @author Lukas Bestle <lukas@getkirby.com>
|
||||
|
@@ -11,6 +11,7 @@ use Kirby\Toolkit\Str;
|
||||
|
||||
/**
|
||||
* Sane handler for SVG files
|
||||
* @since 3.5.4
|
||||
*
|
||||
* @package Kirby Sane
|
||||
* @author Bastian Allgeier <bastian@getkirby.com>,
|
||||
|
@@ -6,6 +6,7 @@ use Kirby\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Sane handler for gzip-compressed SVGZ files
|
||||
* @since 3.5.4
|
||||
*
|
||||
* @package Kirby Sane
|
||||
* @author Lukas Bestle <lukas@getkirby.com>
|
||||
|
@@ -12,6 +12,7 @@ use Kirby\Toolkit\Str;
|
||||
|
||||
/**
|
||||
* Sane handler for XML files
|
||||
* @since 3.5.4
|
||||
*
|
||||
* @package Kirby Sane
|
||||
* @author Bastian Allgeier <bastian@getkirby.com>,
|
||||
|
@@ -31,6 +31,27 @@ class A
|
||||
return $array + $append;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively loops through the array and
|
||||
* resolves any item defined as `Closure`,
|
||||
* applying the passed parameters
|
||||
* @since 3.5.6
|
||||
*
|
||||
* @param array $array
|
||||
* @param mixed ...$args Parameters to pass to the closures
|
||||
* @return array
|
||||
*/
|
||||
public static function apply(array $array, ...$args): array
|
||||
{
|
||||
array_walk_recursive($array, function (&$item) use ($args) {
|
||||
if (is_a($item, 'Closure')) {
|
||||
$item = $item(...$args);
|
||||
}
|
||||
});
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an element of an array by key
|
||||
*
|
||||
|
@@ -1135,14 +1135,17 @@ class Collection extends Iterator implements Countable
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an non-associative array
|
||||
* with all values
|
||||
* Returns a non-associative array
|
||||
* with all values. If a mapping Closure is passed,
|
||||
* all values are processed by the Closure.
|
||||
*
|
||||
* @param Closure|null $map
|
||||
* @return array
|
||||
*/
|
||||
public function values(): array
|
||||
public function values(Closure $map = null): array
|
||||
{
|
||||
return array_values($this->data);
|
||||
$data = $map === null ? $this->data : array_map($map, $this->data);
|
||||
return array_values($data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace Kirby\Toolkit;
|
||||
|
||||
use Kirby\Exception\Exception;
|
||||
use Kirby\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* PHP locale handling
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @package Kirby Toolkit
|
||||
* @author Lukas Bestle <lukas@getkirby.com>
|
||||
@@ -15,6 +17,14 @@ use Kirby\Exception\InvalidArgumentException;
|
||||
*/
|
||||
class Locale
|
||||
{
|
||||
/**
|
||||
* List of all locale constants supported by PHP
|
||||
*/
|
||||
const LOCALE_CONSTANTS = [
|
||||
'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY',
|
||||
'LC_NUMERIC', 'LC_TIME', 'LC_MESSAGES'
|
||||
];
|
||||
|
||||
/**
|
||||
* Converts a normalized locale array to an array with the
|
||||
* locale constants replaced with their string representations
|
||||
@@ -24,20 +34,7 @@ class Locale
|
||||
*/
|
||||
public static function export(array $locale): array
|
||||
{
|
||||
// list of all possible constant names
|
||||
$constantNames = [
|
||||
'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY',
|
||||
'LC_NUMERIC', 'LC_TIME', 'LC_MESSAGES'
|
||||
];
|
||||
|
||||
// build an associative array with the locales
|
||||
// that are actually supported on this system
|
||||
$constants = [];
|
||||
foreach ($constantNames as $name) {
|
||||
if (defined($name) === true) {
|
||||
$constants[constant($name)] = $name;
|
||||
}
|
||||
}
|
||||
$constants = static::supportedConstants(true);
|
||||
|
||||
// replace the keys in the locale data array with the locale names
|
||||
$return = [];
|
||||
@@ -55,6 +52,54 @@ class Locale
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current locale value for
|
||||
* a specified or for all locale categories
|
||||
* @since 3.5.6
|
||||
*
|
||||
* @param int|string $category Locale category constant or constant name
|
||||
* @return array|string Associative array if `LC_ALL` was passed (default), otherwise string
|
||||
*
|
||||
* @throws \Kirby\Exception\Exception If the locale cannot be determined
|
||||
* @throws \Kirby\Exception\InvalidArgumentException If the provided locale category is invalid
|
||||
*/
|
||||
public static function get($category = LC_ALL)
|
||||
{
|
||||
$normalizedCategory = static::normalizeConstant($category);
|
||||
|
||||
if (is_int($normalizedCategory) !== true) {
|
||||
throw new InvalidArgumentException('Invalid locale category "' . $category . '"');
|
||||
}
|
||||
|
||||
if ($normalizedCategory !== LC_ALL) {
|
||||
// `setlocale(..., 0)` actually *gets* the locale
|
||||
$locale = setlocale($normalizedCategory, 0);
|
||||
|
||||
if (is_string($locale) !== true) {
|
||||
throw new Exception('Could not determine locale for category "' . $category . '"');
|
||||
}
|
||||
|
||||
return $locale;
|
||||
}
|
||||
|
||||
// no specific `$category` was passed, make a list of all locales
|
||||
$array = [];
|
||||
foreach (static::supportedConstants() as $constant => $name) {
|
||||
// `setlocale(..., 0)` actually *gets* the locale
|
||||
$array[$constant] = setlocale($constant, '0');
|
||||
}
|
||||
|
||||
// if all values are the same, we can use `LC_ALL`
|
||||
// instead of a long array with all constants
|
||||
if (count(array_unique($array)) === 1) {
|
||||
return [
|
||||
LC_ALL => array_shift($array)
|
||||
];
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a locale string or an array with constant or
|
||||
* string keys to a normalized constant => value array
|
||||
@@ -68,11 +113,7 @@ class Locale
|
||||
// replace string constant keys with the constant values
|
||||
$convertedLocale = [];
|
||||
foreach ($locale as $key => $value) {
|
||||
if (is_string($key) === true && Str::startsWith($key, 'LC_') === true) {
|
||||
$key = constant($key);
|
||||
}
|
||||
|
||||
$convertedLocale[$key] = $value;
|
||||
$convertedLocale[static::normalizeConstant($key)] = $value;
|
||||
}
|
||||
|
||||
return $convertedLocale;
|
||||
@@ -98,4 +139,45 @@ class Locale
|
||||
setlocale($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to convert an `LC_*` constant name
|
||||
* to its constant value
|
||||
*
|
||||
* @param int|string $constant
|
||||
* @return int|string
|
||||
*/
|
||||
protected static function normalizeConstant($constant)
|
||||
{
|
||||
if (is_string($constant) === true && Str::startsWith($constant, 'LC_') === true) {
|
||||
return constant($constant);
|
||||
}
|
||||
|
||||
// already an int or we cannot convert it safely
|
||||
return $constant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an associative array with the locales
|
||||
* that are actually supported on this system
|
||||
*
|
||||
* @param bool $withAll If set to `true`, `LC_ALL` is returned as well
|
||||
* @return array
|
||||
*/
|
||||
protected static function supportedConstants(bool $withAll = false): array
|
||||
{
|
||||
$names = static::LOCALE_CONSTANTS;
|
||||
if ($withAll === true) {
|
||||
array_unshift($names, 'LC_ALL');
|
||||
}
|
||||
|
||||
$constants = [];
|
||||
foreach ($names as $name) {
|
||||
if (defined($name) === true) {
|
||||
$constants[constant($name)] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
return $constants;
|
||||
}
|
||||
}
|
||||
|
@@ -805,6 +805,7 @@ class Str
|
||||
|
||||
/**
|
||||
* Calculates the similarity between two strings with multibyte support
|
||||
* @since 3.5.2
|
||||
*
|
||||
* @author Based on the work of Antal Áron
|
||||
* @copyright Original Copyright (c) 2017, Antal Áron
|
||||
|
Reference in New Issue
Block a user