Upgrade to 3.5.2
This commit is contained in:
@@ -188,6 +188,11 @@ trait AppTranslations
|
||||
// get injected translation data from plugins etc.
|
||||
$inject = $this->extensions['translations'][$locale] ?? [];
|
||||
|
||||
// inject current language translations
|
||||
if ($language = $this->language($locale)) {
|
||||
$inject = array_merge($inject, $language->translations());
|
||||
}
|
||||
|
||||
// load from disk instead
|
||||
return Translation::load($locale, $this->root('i18n:translations') . '/' . $locale . '.json', $inject);
|
||||
}
|
||||
@@ -203,6 +208,23 @@ trait AppTranslations
|
||||
return $this->translations;
|
||||
}
|
||||
|
||||
return Translations::load($this->root('i18n:translations'), $this->extensions['translations'] ?? []);
|
||||
$translations = $this->extensions['translations'] ?? [];
|
||||
|
||||
// injects languages translations
|
||||
if ($languages = $this->languages()) {
|
||||
foreach ($languages as $language) {
|
||||
// merges language translations with extension translations
|
||||
if ($language->translations()) {
|
||||
$translations[$language->code()] = array_merge(
|
||||
$translations[$language->code()],
|
||||
$language->translations()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->translations = Translations::load($this->root('i18n:translations'), $translations);
|
||||
|
||||
return $this->translations;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,7 +375,9 @@ class Blueprint
|
||||
protected function normalizeColumns(string $tabName, array $columns): array
|
||||
{
|
||||
foreach ($columns as $columnKey => $columnProps) {
|
||||
// unset/remove column if its property is not array
|
||||
if (is_array($columnProps) === false) {
|
||||
unset($columns[$columnKey]);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +105,12 @@ class Fieldset extends Item
|
||||
|
||||
// normalize tabs props
|
||||
foreach ($tabs as $name => $tab) {
|
||||
// unset/remove tab if its property is false
|
||||
if ($tab === false) {
|
||||
unset($tabs[$name]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$tab = Blueprint::extend($tab);
|
||||
|
||||
$tab['fields'] = $this->createFields($tab['fields'] ?? []);
|
||||
|
||||
@@ -75,6 +75,31 @@ class Layout extends Item
|
||||
return $this->columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the layout is empty
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmpty(): bool
|
||||
{
|
||||
return $this
|
||||
->columns()
|
||||
->filter(function ($column) {
|
||||
return $column->isNotEmpty();
|
||||
})
|
||||
->count() === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the layout is not empty
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isNotEmpty(): bool
|
||||
{
|
||||
return $this->isEmpty() === false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The result is being sent to the editor
|
||||
* via the API in the panel
|
||||
|
||||
@@ -54,6 +54,29 @@ class LayoutColumn extends Item
|
||||
return $this->blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the column is empty
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmpty(): bool
|
||||
{
|
||||
return $this
|
||||
->blocks()
|
||||
->filter('isHidden', false)
|
||||
->count() === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the column is not empty
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isNotEmpty(): bool
|
||||
{
|
||||
return $this->isEmpty() === false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of columns this column spans
|
||||
*
|
||||
|
||||
@@ -139,7 +139,7 @@ class Page extends ModelWithContent
|
||||
/**
|
||||
* The intended page template
|
||||
*
|
||||
* @var string
|
||||
* @var \Kirby\Cms\Template
|
||||
*/
|
||||
protected $template;
|
||||
|
||||
|
||||
@@ -533,7 +533,9 @@ trait PageActions
|
||||
$lang = $this->kirby()->defaultLanguage() ?? null;
|
||||
$field = $this->content($lang)->get('date');
|
||||
$date = $field->isEmpty() ? 'now' : $field;
|
||||
return date($format, strtotime($date));
|
||||
// TODO: in 3.6.0 throw an error if date() doesn't
|
||||
// return a number, see https://github.com/getkirby/kirby/pull/3061#discussion_r552783943
|
||||
return (int)date($format, strtotime($date));
|
||||
break;
|
||||
case 'default':
|
||||
|
||||
|
||||
@@ -23,12 +23,19 @@ use Kirby\Exception\InvalidArgumentException;
|
||||
class Pages extends Collection
|
||||
{
|
||||
/**
|
||||
* Cache for the index
|
||||
* Cache for the index only listed and unlisted pages
|
||||
*
|
||||
* @var \Kirby\Cms\Pages|null
|
||||
*/
|
||||
protected $index = null;
|
||||
|
||||
/**
|
||||
* Cache for the index all statuses also including drafts
|
||||
*
|
||||
* @var \Kirby\Cms\Pages|null
|
||||
*/
|
||||
protected $indexWithDrafts = null;
|
||||
|
||||
/**
|
||||
* All registered pages methods
|
||||
*
|
||||
@@ -331,24 +338,31 @@ class Pages extends Collection
|
||||
*/
|
||||
public function index(bool $drafts = false)
|
||||
{
|
||||
if (is_a($this->index, 'Kirby\Cms\Pages') === true) {
|
||||
return $this->index;
|
||||
// get object property by cache mode
|
||||
$index = $drafts === true ? $this->indexWithDrafts : $this->index;
|
||||
|
||||
if (is_a($index, 'Kirby\Cms\Pages') === true) {
|
||||
return $index;
|
||||
}
|
||||
|
||||
$this->index = new Pages([], $this->parent);
|
||||
$index = new Pages([], $this->parent);
|
||||
|
||||
foreach ($this->data as $pageKey => $page) {
|
||||
$this->index->data[$pageKey] = $page;
|
||||
$index = $page->index($drafts);
|
||||
$index->data[$pageKey] = $page;
|
||||
$pageIndex = $page->index($drafts);
|
||||
|
||||
if ($index) {
|
||||
foreach ($index as $childKey => $child) {
|
||||
$this->index->data[$childKey] = $child;
|
||||
if ($pageIndex) {
|
||||
foreach ($pageIndex as $childKey => $child) {
|
||||
$index->data[$childKey] = $child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->index;
|
||||
if ($drafts === true) {
|
||||
return $this->indexWithDrafts = $index;
|
||||
}
|
||||
|
||||
return $this->index = $index;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,12 +19,12 @@ class Response extends \Kirby\Http\Response
|
||||
* parses locations with the Url::to method
|
||||
* first.
|
||||
*
|
||||
* @param string|null $location
|
||||
* @param int|null $code
|
||||
* @param string $location
|
||||
* @param int $code
|
||||
* @return self
|
||||
*/
|
||||
public static function redirect(?string $location = null, ?int $code = null)
|
||||
public static function redirect(string $location = '/', int $code = 302)
|
||||
{
|
||||
return parent::redirect(Url::to($location ?? '/'), $code);
|
||||
return parent::redirect(Url::to($location), $code);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user