Upgrade to 3.2.4
This commit is contained in:
@@ -1063,12 +1063,13 @@ class App
|
||||
protected function setLanguages(array $languages = null)
|
||||
{
|
||||
if ($languages !== null) {
|
||||
$this->languages = new Languages();
|
||||
$objects = [];
|
||||
|
||||
foreach ($languages as $props) {
|
||||
$language = new Language($props);
|
||||
$this->languages->data[$language->code()] = $language;
|
||||
$objects[] = new Language($props);
|
||||
}
|
||||
|
||||
$this->languages = new Languages($objects);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@@ -51,7 +51,6 @@ trait AppPlugins
|
||||
'fieldMethods' => [],
|
||||
'fileMethods' => [],
|
||||
'filesMethods' => [],
|
||||
'fileModels' => [],
|
||||
'fields' => [],
|
||||
'hooks' => [],
|
||||
'pages' => [],
|
||||
@@ -205,17 +204,6 @@ trait AppPlugins
|
||||
return $this->extensions['filesMethods'] = Files::$methods = array_merge(Files::$methods, $methods);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers additional file models
|
||||
*
|
||||
* @param array $models
|
||||
* @return array
|
||||
*/
|
||||
protected function extendFileModels(array $models): array
|
||||
{
|
||||
return $this->extensions['fileModels'] = File::$models = array_merge(File::$models, $models);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers additional field methods
|
||||
*
|
||||
|
@@ -197,7 +197,7 @@ class Collection extends BaseCollection
|
||||
/**
|
||||
* Returns a Collection without the given element(s)
|
||||
*
|
||||
* @param mixxed[] $keys any number of keys, passed as individual arguments
|
||||
* @param mixed[] $keys any number of keys, passed as individual arguments
|
||||
* @return Kirby\Cms\Collection
|
||||
*/
|
||||
public function not(...$keys)
|
||||
|
@@ -40,7 +40,9 @@ class Email
|
||||
$this->props = array_merge($this->preset, $props);
|
||||
|
||||
// add transport settings
|
||||
$this->props['transport'] = $this->options['transport'] ?? [];
|
||||
if (isset($this->props['transport']) === false) {
|
||||
$this->props['transport'] = $this->options['transport'] ?? [];
|
||||
}
|
||||
|
||||
// transform model objects to values
|
||||
foreach (static::$transform as $prop => $model) {
|
||||
|
@@ -70,14 +70,6 @@ class File extends ModelWithContent
|
||||
*/
|
||||
public static $methods = [];
|
||||
|
||||
/**
|
||||
* Registry with all File models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $models = [];
|
||||
|
||||
|
||||
/**
|
||||
* The parent object
|
||||
*
|
||||
@@ -266,18 +258,13 @@ class File extends ModelWithContent
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a File object and also
|
||||
* takes File models into account.
|
||||
* Constructs a File object
|
||||
*
|
||||
* @internal
|
||||
* @return self
|
||||
*/
|
||||
public static function factory($props)
|
||||
{
|
||||
if (empty($props['model']) === false) {
|
||||
return static::model($props['model'], $props);
|
||||
}
|
||||
|
||||
return new static($props);
|
||||
}
|
||||
|
||||
@@ -375,27 +362,6 @@ class File extends ModelWithContent
|
||||
return $this->content();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file model if it has been registered
|
||||
*
|
||||
* @internal
|
||||
* @param string $name
|
||||
* @param array $props
|
||||
* @return Kirby\Cms\File
|
||||
*/
|
||||
public static function model(string $name, array $props = [])
|
||||
{
|
||||
if ($class = (static::$models[$name] ?? null)) {
|
||||
$object = new $class($props);
|
||||
|
||||
if (is_a($object, 'Kirby\Cms\File') === true) {
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
||||
return new static($props);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file's last modification time.
|
||||
*
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Kirby\Cms;
|
||||
|
||||
use Kirby\Exception\DuplicateException;
|
||||
use Kirby\Toolkit\F;
|
||||
|
||||
/**
|
||||
@@ -16,6 +17,25 @@ use Kirby\Toolkit\F;
|
||||
class Languages extends Collection
|
||||
{
|
||||
|
||||
/**
|
||||
* Creates a new collection with the given language objects
|
||||
*
|
||||
* @param array $objects
|
||||
* @param object $parent
|
||||
*/
|
||||
public function __construct($objects = [], $parent = null)
|
||||
{
|
||||
$defaults = array_filter($objects, function ($language) {
|
||||
return $language->isDefault() === true;
|
||||
});
|
||||
|
||||
if (count($defaults) > 1) {
|
||||
throw new DuplicateException('You cannot have multiple default languages. Please check your language config files.');
|
||||
}
|
||||
|
||||
parent::__construct($objects, $parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all language codes as array
|
||||
*
|
||||
@@ -69,22 +89,20 @@ class Languages extends Collection
|
||||
*/
|
||||
public static function load()
|
||||
{
|
||||
$languages = new static;
|
||||
$languages = [];
|
||||
$files = glob(App::instance()->root('languages') . '/*.php');
|
||||
|
||||
foreach ($files as $file) {
|
||||
$props = include $file;
|
||||
|
||||
if (is_array($props) === true) {
|
||||
|
||||
// inject the language code from the filename if it does not exist
|
||||
$props['code'] = $props['code'] ?? F::name($file);
|
||||
|
||||
$language = new Language($props);
|
||||
$languages->data[$language->code()] = $language;
|
||||
$languages[] = new Language($props);
|
||||
}
|
||||
}
|
||||
|
||||
return $languages;
|
||||
return new static($languages);
|
||||
}
|
||||
}
|
||||
|
@@ -463,7 +463,10 @@ trait PageActions
|
||||
case 'date':
|
||||
case 'datetime':
|
||||
$format = $mode === 'date' ? 'Ymd' : 'YmdHi';
|
||||
return $this->date()->toDate($format, 'now');
|
||||
$lang = $this->kirby()->defaultLanguage() ?? null;
|
||||
$field = $this->content($lang)->get('date');
|
||||
$date = $field->isEmpty() ? 'now' : $field;
|
||||
return date($format, strtotime($date));
|
||||
break;
|
||||
case 'default':
|
||||
|
||||
|
@@ -4,6 +4,7 @@ namespace Kirby\Cms;
|
||||
|
||||
use Kirby\Toolkit\Dir;
|
||||
use Kirby\Toolkit\F;
|
||||
use Kirby\Toolkit\Str;
|
||||
|
||||
/**
|
||||
* The PanelPlugins class takes care of collecting
|
||||
@@ -78,12 +79,21 @@ class PanelPlugins
|
||||
foreach ($this->files() as $file) {
|
||||
if (F::extension($file) === $type) {
|
||||
if ($content = F::read($file)) {
|
||||
if ($type === 'js') {
|
||||
$content = trim($content);
|
||||
|
||||
// make sure that each plugin is ended correctly
|
||||
if (Str::endsWith($content, ';') === false) {
|
||||
$content .= ';';
|
||||
}
|
||||
}
|
||||
|
||||
$dist[] = $content;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return implode(PHP_EOL, $dist);
|
||||
return implode(PHP_EOL . PHP_EOL, $dist);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -163,7 +163,7 @@ class Field extends Component
|
||||
return $translate;
|
||||
},
|
||||
/**
|
||||
* Conditions when the field will be shown
|
||||
* Conditions when the field will be shown (since 3.1.0)
|
||||
*/
|
||||
'when' => function ($when = null) {
|
||||
return $when;
|
||||
|
@@ -93,7 +93,7 @@ class A
|
||||
while ($innerKey = array_shift($keys)) {
|
||||
$currentKey = $currentKey . '.' . $innerKey;
|
||||
|
||||
if (isset($array[$currentKey]) === true) {
|
||||
if (isset($array[$currentKey]) === true && is_array($array[$currentKey])) {
|
||||
return static::get($array[$currentKey], implode('.', $keys), $default);
|
||||
}
|
||||
}
|
||||
|
@@ -42,7 +42,7 @@ class Str
|
||||
'/⁸|₈/' => '8',
|
||||
'/⁹|₉/' => '9',
|
||||
'/À|Á|Â|Ã|Å|Ǻ|Ā|Ă|Ą|Ǎ|Ä|A/' => 'A',
|
||||
'/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª|æ|ǽ|ä|a/' => 'a',
|
||||
'/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª|æ|ǽ|ä|a|а/' => 'a',
|
||||
'/Б/' => 'B',
|
||||
'/б/' => 'b',
|
||||
'/Ç|Ć|Ĉ|Ċ|Č|Ц/' => 'C',
|
||||
@@ -60,7 +60,7 @@ class Str
|
||||
'/Ĥ|Ħ|Х/' => 'H',
|
||||
'/ĥ|ħ|х/' => 'h',
|
||||
'/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ|И/' => 'I',
|
||||
'/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|и/' => 'i',
|
||||
'/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|и|i̇/' => 'i',
|
||||
'/Ĵ|Й/' => 'J',
|
||||
'/ĵ|й/' => 'j',
|
||||
'/Ķ|К/' => 'K',
|
||||
@@ -72,7 +72,7 @@ class Str
|
||||
'/Ñ|Ń|Ņ|Ň|Н/' => 'N',
|
||||
'/ñ|ń|ņ|ň|ʼn|н/' => 'n',
|
||||
'/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|Ö|O/' => 'O',
|
||||
'/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|ö|o/' => 'o',
|
||||
'/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|ö|o|о/' => 'o',
|
||||
'/П/' => 'P',
|
||||
'/п/' => 'p',
|
||||
'/Ŕ|Ŗ|Ř|Р/' => 'R',
|
||||
|
Reference in New Issue
Block a user