Upgrade to 3.0.1
This commit is contained in:
@@ -35,6 +35,8 @@ use Kirby\Toolkit\Url;
|
||||
*/
|
||||
class App
|
||||
{
|
||||
const CLASS_ALIAS = 'kirby';
|
||||
|
||||
use AppCaches;
|
||||
use AppErrors;
|
||||
use AppPlugins;
|
||||
|
@@ -99,7 +99,7 @@ trait AppErrors
|
||||
'status' => 'error',
|
||||
'code' => $code,
|
||||
'details' => $details,
|
||||
'message' => 'An unexpected error occurred! Enable debug mode for more info: https://getkirby.com/docs/reference/options/debug',
|
||||
'message' => 'An unexpected error occurred! Enable debug mode for more info: https://getkirby.com/docs/reference/system/options/debug',
|
||||
], $httpCode);
|
||||
}
|
||||
|
||||
|
@@ -402,6 +402,7 @@ trait AppPlugins
|
||||
PageBlueprint::$presets['files'] = include static::$root . '/config/presets/files.php';
|
||||
|
||||
// section mixins
|
||||
Section::$mixins['empty'] = include static::$root . '/config/sections/mixins/empty.php';
|
||||
Section::$mixins['headline'] = include static::$root . '/config/sections/mixins/headline.php';
|
||||
Section::$mixins['layout'] = include static::$root . '/config/sections/mixins/layout.php';
|
||||
Section::$mixins['max'] = include static::$root . '/config/sections/mixins/max.php';
|
||||
|
@@ -25,6 +25,8 @@ use Throwable;
|
||||
*/
|
||||
class File extends ModelWithContent
|
||||
{
|
||||
const CLASS_ALIAS = 'file';
|
||||
|
||||
use FileActions;
|
||||
use FileFoundation;
|
||||
use HasMethods;
|
||||
|
@@ -24,6 +24,8 @@ use Throwable;
|
||||
*/
|
||||
class Page extends ModelWithContent
|
||||
{
|
||||
const CLASS_ALIAS = 'page';
|
||||
|
||||
use PageActions;
|
||||
use PageSiblings;
|
||||
use HasChildren;
|
||||
@@ -179,6 +181,10 @@ class Page extends ModelWithContent
|
||||
*/
|
||||
public function __construct(array $props)
|
||||
{
|
||||
// set the slug as the first property
|
||||
$this->slug = $props['slug'] ?? null;
|
||||
|
||||
// add all other properties
|
||||
$this->setProperties($props);
|
||||
}
|
||||
|
||||
@@ -592,7 +598,11 @@ class Page extends ModelWithContent
|
||||
*/
|
||||
public function isChildOf($parent): bool
|
||||
{
|
||||
return $this->parent()->is($parent);
|
||||
if ($parent = $this->parent()) {
|
||||
return $parent->is($parent);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1478,7 +1488,11 @@ class Page extends ModelWithContent
|
||||
}
|
||||
|
||||
if ($parent = $this->parent()) {
|
||||
return $this->url = $this->parent()->url() . '/' . $this->uid();
|
||||
if ($parent->isHomePage() === true) {
|
||||
return $this->url = $this->kirby()->url('base') . '/' . $parent->uid() . '/' . $this->uid();
|
||||
} else {
|
||||
return $this->url = $this->parent()->url() . '/' . $this->uid();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->url = $this->kirby()->url('base') . '/' . $this->uid();
|
||||
@@ -1502,7 +1516,11 @@ class Page extends ModelWithContent
|
||||
}
|
||||
|
||||
if ($parent = $this->parent()) {
|
||||
return $this->url = $this->parent()->urlForLanguage($language) . '/' . $this->slug($language);
|
||||
if ($parent->isHomePage() === true) {
|
||||
return $this->url = $this->site()->urlForLanguage($language) . '/' . $parent->slug($language) . '/' . $this->slug($language);
|
||||
} else {
|
||||
return $this->url = $this->parent()->urlForLanguage($language) . '/' . $this->slug($language);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->url = $this->site()->urlForLanguage($language) . '/' . $this->slug($language);
|
||||
|
@@ -151,6 +151,11 @@ class PageBlueprint extends Blueprint
|
||||
$status = ['draft' => $defaults['draft']] + $status;
|
||||
}
|
||||
|
||||
// remove the draft status for the home and error pages
|
||||
if ($this->model->isHomeOrErrorPage() === true) {
|
||||
unset($status['draft']);
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
|
@@ -82,7 +82,7 @@ class Panel
|
||||
'api' => $kirby->url('api'),
|
||||
'csrf' => $kirby->option('api')['csrf'] ?? csrf(),
|
||||
'translation' => 'en',
|
||||
'debug' => true,
|
||||
'debug' => $kirby->option('debug', false),
|
||||
'search' => [
|
||||
'limit' => $kirby->option('panel')['search']['limit'] ?? 10
|
||||
]
|
||||
|
@@ -20,6 +20,8 @@ use Kirby\Toolkit\Str;
|
||||
*/
|
||||
class Site extends ModelWithContent
|
||||
{
|
||||
const CLASS_ALIAS = 'site';
|
||||
|
||||
use SiteActions;
|
||||
use HasChildren;
|
||||
use HasFiles;
|
||||
|
@@ -47,15 +47,33 @@ class Url extends BaseUrl
|
||||
* Smart resolver for internal and external urls
|
||||
*
|
||||
* @param string $path
|
||||
* @param array $options
|
||||
* @param array|string|null $options Either an array of options for the Uri class or a language string
|
||||
* @return string
|
||||
*/
|
||||
public static function to(string $path = null, array $options = null): string
|
||||
public static function to(string $path = null, $options = null): string
|
||||
{
|
||||
$kirby = App::instance();
|
||||
$kirby = App::instance();
|
||||
$language = null;
|
||||
|
||||
// get language from simple string option
|
||||
if (is_string($options) === true) {
|
||||
$language = $options;
|
||||
$options = null;
|
||||
}
|
||||
|
||||
// get language from array
|
||||
if (is_array($options) === true && isset($options['language']) === true) {
|
||||
$language = $options['language'];
|
||||
unset($options['language']);
|
||||
}
|
||||
|
||||
// get a language url for the linked page, if the page can be found
|
||||
if ($language !== null && $kirby->multilang() === true && $page = page($path)) {
|
||||
$path = $page->url($language);
|
||||
}
|
||||
|
||||
if ($handler = $kirby->component('url')) {
|
||||
return $handler($kirby, $path, $options, function (string $path = null, array $options = null) {
|
||||
return $handler($kirby, $path, $options, function (string $path = null, $options = null) {
|
||||
return parent::to($path, $options);
|
||||
});
|
||||
}
|
||||
|
@@ -24,6 +24,8 @@ use Throwable;
|
||||
*/
|
||||
class User extends ModelWithContent
|
||||
{
|
||||
const CLASS_ALIAS = 'user';
|
||||
|
||||
use HasFiles;
|
||||
use HasSiblings;
|
||||
use UserActions;
|
||||
|
@@ -516,7 +516,7 @@ class Uri
|
||||
$slash = false;
|
||||
}
|
||||
|
||||
$path = $this->path->toString($slash) . $this->params->toString($slash);
|
||||
$path = $this->path->toString($slash) . $this->params->toString(true);
|
||||
|
||||
if ($this->slash && $slash === true) {
|
||||
$path .= '/';
|
||||
|
@@ -250,10 +250,10 @@ class Url
|
||||
* Smart resolver for internal and external urls
|
||||
*
|
||||
* @param string $path
|
||||
* @param array $options
|
||||
* @param $options
|
||||
* @return string
|
||||
*/
|
||||
public static function to(string $path = null, array $options = null): string
|
||||
public static function to(string $path = null, $options = null): string
|
||||
{
|
||||
// keep relative urls
|
||||
if (substr($path, 0, 2) === './' || substr($path, 0, 3) === '../') {
|
||||
|
@@ -61,7 +61,7 @@ class Silo
|
||||
public static function remove(string $key = null): array
|
||||
{
|
||||
// reset the entire array
|
||||
if ($key === true) {
|
||||
if ($key === null) {
|
||||
return static::$data = [];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user