Upgrade to 3.7.0
This commit is contained in:
0
kirby/src/Panel/Dialog.php
Normal file → Executable file
0
kirby/src/Panel/Dialog.php
Normal file → Executable file
31
kirby/src/Panel/Document.php
Normal file → Executable file
31
kirby/src/Panel/Document.php
Normal file → Executable file
@@ -2,8 +2,11 @@
|
||||
|
||||
namespace Kirby\Panel;
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\Helpers;
|
||||
use Kirby\Exception\Exception;
|
||||
use Kirby\Exception\InvalidArgumentException;
|
||||
use Kirby\Filesystem\Asset;
|
||||
use Kirby\Filesystem\Dir;
|
||||
use Kirby\Filesystem\F;
|
||||
use Kirby\Http\Response;
|
||||
@@ -33,7 +36,7 @@ class Document
|
||||
*/
|
||||
public static function assets(): array
|
||||
{
|
||||
$kirby = kirby();
|
||||
$kirby = App::instance();
|
||||
$nonce = $kirby->nonce();
|
||||
|
||||
// get the assets from the Vite dev server in dev mode;
|
||||
@@ -129,15 +132,15 @@ class Document
|
||||
/**
|
||||
* Check for a custom asset file from the
|
||||
* config (e.g. panel.css or panel.js)
|
||||
* @since 3.6.2
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @param string $option asset option name
|
||||
* @return string|null
|
||||
*/
|
||||
public static function customAsset(string $option): ?string
|
||||
{
|
||||
if ($path = kirby()->option($option)) {
|
||||
$asset = asset($path);
|
||||
if ($path = App::instance()->option($option)) {
|
||||
$asset = new Asset($path);
|
||||
|
||||
if ($asset->exists() === true) {
|
||||
return $asset->url() . '?' . $asset->modified();
|
||||
@@ -149,33 +152,37 @@ class Document
|
||||
|
||||
/**
|
||||
* @deprecated 3.7.0 Use `Document::customAsset('panel.css)` instead
|
||||
* @todo add deprecation warning in 3.7.0, remove in 3.8.0
|
||||
* @todo remove in 3.8.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function customCss(): ?string
|
||||
{
|
||||
Helpers::deprecated('Panel\Document::customCss() has been deprecated and will be removed in Kirby 3.8.0. Use Panel\Document::customAsset(\'panel.css\') instead.');
|
||||
return static::customAsset('panel.css');
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 3.7.0 Use `Document::customAsset('panel.js)` instead
|
||||
* @todo add deprecation warning in 3.7.0, remove in 3.8.0
|
||||
* @todo remove in 3.8.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function customJs(): ?string
|
||||
{
|
||||
Helpers::deprecated('Panel\Document::customJs() has been deprecated and will be removed in Kirby 3.8.0. Use Panel\Document::customAsset(\'panel.js\') instead.');
|
||||
return static::customAsset('panel.js');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array of favion icons
|
||||
* based on config option
|
||||
* @since 3.6.2
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @param string $url URL prefix for default icons
|
||||
* @return array
|
||||
*/
|
||||
public static function favicon(string $url = ''): array
|
||||
{
|
||||
$kirby = kirby();
|
||||
$kirby = App::instance();
|
||||
$icons = $kirby->option('panel.favicon', [
|
||||
'apple-touch-icon' => [
|
||||
'type' => 'image/png',
|
||||
@@ -217,7 +224,7 @@ class Document
|
||||
*/
|
||||
public static function icons(): string
|
||||
{
|
||||
return F::read(kirby()->root('kirby') . '/panel/dist/img/icons.svg');
|
||||
return F::read(App::instance()->root('kirby') . '/panel/dist/img/icons.svg');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,7 +236,7 @@ class Document
|
||||
*/
|
||||
public static function link(): bool
|
||||
{
|
||||
$kirby = kirby();
|
||||
$kirby = App::instance();
|
||||
$mediaRoot = $kirby->root('media') . '/panel';
|
||||
$panelRoot = $kirby->root('panel') . '/dist';
|
||||
$versionHash = $kirby->versionHash();
|
||||
@@ -262,14 +269,14 @@ class Document
|
||||
*/
|
||||
public static function response(array $fiber)
|
||||
{
|
||||
$kirby = kirby();
|
||||
$kirby = App::instance();
|
||||
|
||||
// Full HTML response
|
||||
// @codeCoverageIgnoreStart
|
||||
try {
|
||||
if (static::link() === true) {
|
||||
usleep(1);
|
||||
go($kirby->url('index') . '/' . $kirby->path());
|
||||
Response::go($kirby->url('index') . '/' . $kirby->path());
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
die('The Panel assets cannot be installed properly. ' . $e->getMessage());
|
||||
|
5
kirby/src/Panel/Dropdown.php
Normal file → Executable file
5
kirby/src/Panel/Dropdown.php
Normal file → Executable file
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Kirby\Panel;
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\Find;
|
||||
use Kirby\Exception\LogicException;
|
||||
use Kirby\Http\Uri;
|
||||
@@ -31,9 +32,9 @@ class Dropdown extends Json
|
||||
*/
|
||||
public static function changes(): array
|
||||
{
|
||||
$kirby = kirby();
|
||||
$kirby = App::instance();
|
||||
$multilang = $kirby->multilang();
|
||||
$ids = Str::split(get('ids'));
|
||||
$ids = Str::split($kirby->request()->get('ids'));
|
||||
$options = [];
|
||||
|
||||
foreach ($ids as $id) {
|
||||
|
28
kirby/src/Panel/Field.php
Normal file → Executable file
28
kirby/src/Panel/Field.php
Normal file → Executable file
@@ -2,8 +2,10 @@
|
||||
|
||||
namespace Kirby\Panel;
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\File;
|
||||
use Kirby\Cms\Page;
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
/**
|
||||
* Provides common field prop definitions
|
||||
@@ -27,7 +29,7 @@ class Field
|
||||
public static function email(array $props = []): array
|
||||
{
|
||||
return array_merge([
|
||||
'label' => t('email'),
|
||||
'label' => I18n::translate('email'),
|
||||
'type' => 'email',
|
||||
'counter' => false,
|
||||
], $props);
|
||||
@@ -68,7 +70,7 @@ class Field
|
||||
];
|
||||
|
||||
return array_merge([
|
||||
'label' => t('file.sort'),
|
||||
'label' => I18n::translate('file.sort'),
|
||||
'type' => 'select',
|
||||
'empty' => false,
|
||||
'options' => $options
|
||||
@@ -126,7 +128,7 @@ class Field
|
||||
}
|
||||
|
||||
return array_merge([
|
||||
'label' => t('page.changeStatus.position'),
|
||||
'label' => I18n::translate('page.changeStatus.position'),
|
||||
'type' => 'select',
|
||||
'empty' => false,
|
||||
'options' => $options,
|
||||
@@ -142,7 +144,7 @@ class Field
|
||||
public static function password(array $props = []): array
|
||||
{
|
||||
return array_merge([
|
||||
'label' => t('password'),
|
||||
'label' => I18n::translate('password'),
|
||||
'type' => 'password'
|
||||
], $props);
|
||||
}
|
||||
@@ -155,7 +157,7 @@ class Field
|
||||
*/
|
||||
public static function role(array $props = []): array
|
||||
{
|
||||
$kirby = kirby();
|
||||
$kirby = App::instance();
|
||||
$user = $kirby->user();
|
||||
$isAdmin = $user && $user->isAdmin();
|
||||
$roles = [];
|
||||
@@ -169,13 +171,13 @@ class Field
|
||||
|
||||
$roles[] = [
|
||||
'text' => $role->title(),
|
||||
'info' => $role->description() ?? t('role.description.placeholder'),
|
||||
'info' => $role->description() ?? I18n::translate('role.description.placeholder'),
|
||||
'value' => $role->name()
|
||||
];
|
||||
}
|
||||
|
||||
return array_merge([
|
||||
'label' => t('role'),
|
||||
'label' => I18n::translate('role'),
|
||||
'type' => count($roles) <= 1 ? 'hidden' : 'radio',
|
||||
'options' => $roles
|
||||
], $props);
|
||||
@@ -188,7 +190,7 @@ class Field
|
||||
public static function slug(array $props = []): array
|
||||
{
|
||||
return array_merge([
|
||||
'label' => t('slug'),
|
||||
'label' => I18n::translate('slug'),
|
||||
'type' => 'slug',
|
||||
], $props);
|
||||
}
|
||||
@@ -210,7 +212,7 @@ class Field
|
||||
}
|
||||
|
||||
return array_merge([
|
||||
'label' => t('template'),
|
||||
'label' => I18n::translate('template'),
|
||||
'type' => 'select',
|
||||
'empty' => false,
|
||||
'options' => $options,
|
||||
@@ -226,7 +228,7 @@ class Field
|
||||
public static function title(array $props = []): array
|
||||
{
|
||||
return array_merge([
|
||||
'label' => t('title'),
|
||||
'label' => I18n::translate('title'),
|
||||
'type' => 'text',
|
||||
'icon' => 'title',
|
||||
], $props);
|
||||
@@ -241,7 +243,7 @@ class Field
|
||||
public static function translation(array $props = []): array
|
||||
{
|
||||
$translations = [];
|
||||
foreach (kirby()->translations() as $translation) {
|
||||
foreach (App::instance()->translations() as $translation) {
|
||||
$translations[] = [
|
||||
'text' => $translation->name(),
|
||||
'value' => $translation->code()
|
||||
@@ -249,7 +251,7 @@ class Field
|
||||
}
|
||||
|
||||
return array_merge([
|
||||
'label' => t('language'),
|
||||
'label' => I18n::translate('language'),
|
||||
'type' => 'select',
|
||||
'icon' => 'globe',
|
||||
'options' => $translations,
|
||||
@@ -265,7 +267,7 @@ class Field
|
||||
{
|
||||
return array_merge([
|
||||
'icon' => 'user',
|
||||
'label' => t('name'),
|
||||
'label' => I18n::translate('name'),
|
||||
'type' => 'text',
|
||||
], $props);
|
||||
}
|
||||
|
72
kirby/src/Panel/File.php
Normal file → Executable file
72
kirby/src/Panel/File.php
Normal file → Executable file
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Kirby\Panel;
|
||||
|
||||
use Kirby\Toolkit\I18n;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
@@ -104,14 +105,11 @@ class File extends Model
|
||||
*/
|
||||
public function dropdown(array $options = []): array
|
||||
{
|
||||
$defaults = [
|
||||
'view' => get('view'),
|
||||
'update' => get('update'),
|
||||
'delete' => get('delete')
|
||||
];
|
||||
$file = $this->model;
|
||||
|
||||
$defaults = $file->kirby()->request()->get(['view', 'update', 'delete']);
|
||||
$options = array_merge($defaults, $options);
|
||||
|
||||
$options = array_merge($defaults, $options);
|
||||
$file = $this->model;
|
||||
$permissions = $this->options(['preview']);
|
||||
$view = $options['view'] ?? 'view';
|
||||
$url = $this->url(true);
|
||||
@@ -122,7 +120,7 @@ class File extends Model
|
||||
'link' => $file->previewUrl(),
|
||||
'target' => '_blank',
|
||||
'icon' => 'open',
|
||||
'text' => t('open')
|
||||
'text' => I18n::translate('open')
|
||||
];
|
||||
$result[] = '-';
|
||||
}
|
||||
@@ -130,14 +128,14 @@ class File extends Model
|
||||
$result[] = [
|
||||
'dialog' => $url . '/changeName',
|
||||
'icon' => 'title',
|
||||
'text' => t('rename'),
|
||||
'text' => I18n::translate('rename'),
|
||||
'disabled' => $this->isDisabledDropdownOption('changeName', $options, $permissions)
|
||||
];
|
||||
|
||||
$result[] = [
|
||||
'click' => 'replace',
|
||||
'icon' => 'upload',
|
||||
'text' => t('replace'),
|
||||
'text' => I18n::translate('replace'),
|
||||
'disabled' => $this->isDisabledDropdownOption('replace', $options, $permissions)
|
||||
];
|
||||
|
||||
@@ -146,7 +144,7 @@ class File extends Model
|
||||
$result[] = [
|
||||
'dialog' => $url . '/changeSort',
|
||||
'icon' => 'sort',
|
||||
'text' => t('file.sort'),
|
||||
'text' => I18n::translate('file.sort'),
|
||||
'disabled' => $this->isDisabledDropdownOption('update', $options, $permissions)
|
||||
];
|
||||
}
|
||||
@@ -155,7 +153,7 @@ class File extends Model
|
||||
$result[] = [
|
||||
'dialog' => $url . '/delete',
|
||||
'icon' => 'trash',
|
||||
'text' => t('delete'),
|
||||
'text' => I18n::translate('delete'),
|
||||
'disabled' => $this->isDisabledDropdownOption('delete', $options, $permissions)
|
||||
];
|
||||
|
||||
@@ -190,7 +188,7 @@ class File extends Model
|
||||
'document' => 'red-400',
|
||||
'audio' => 'aqua-400',
|
||||
'code' => 'blue-400',
|
||||
'archive' => 'white'
|
||||
'archive' => 'gray-500'
|
||||
];
|
||||
|
||||
$extensions = [
|
||||
@@ -205,7 +203,7 @@ class File extends Model
|
||||
|
||||
return $extensions[$this->model->extension()] ??
|
||||
$types[$this->model->type()] ??
|
||||
parent::imageDefaults()['icon'];
|
||||
parent::imageDefaults()['color'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,28 +227,28 @@ class File extends Model
|
||||
protected function imageIcon(): string
|
||||
{
|
||||
$types = [
|
||||
'image' => 'file-image',
|
||||
'video' => 'file-video',
|
||||
'document' => 'file-document',
|
||||
'audio' => 'file-audio',
|
||||
'code' => 'file-code',
|
||||
'archive' => 'file-zip'
|
||||
'image' => 'image',
|
||||
'video' => 'video',
|
||||
'document' => 'document',
|
||||
'audio' => 'audio',
|
||||
'code' => 'code',
|
||||
'archive' => 'archive'
|
||||
];
|
||||
|
||||
$extensions = [
|
||||
'xls' => 'file-spreadsheet',
|
||||
'xlsx' => 'file-spreadsheet',
|
||||
'csv' => 'file-spreadsheet',
|
||||
'docx' => 'file-word',
|
||||
'doc' => 'file-word',
|
||||
'rtf' => 'file-word',
|
||||
'mdown' => 'file-text',
|
||||
'md' => 'file-text'
|
||||
'xls' => 'table',
|
||||
'xlsx' => 'table',
|
||||
'csv' => 'table',
|
||||
'docx' => 'pen',
|
||||
'doc' => 'pen',
|
||||
'rtf' => 'pen',
|
||||
'mdown' => 'markdown',
|
||||
'md' => 'markdown'
|
||||
];
|
||||
|
||||
return $extensions[$this->model->extension()] ??
|
||||
$types[$this->model->type()] ??
|
||||
parent::imageDefaults()['color'];
|
||||
'file';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -377,29 +375,29 @@ class File extends Model
|
||||
'url' => $url = $file->previewUrl(),
|
||||
'details' => [
|
||||
[
|
||||
'title' => t('template'),
|
||||
'title' => I18n::translate('template'),
|
||||
'text' => $file->template() ?? '—'
|
||||
],
|
||||
[
|
||||
'title' => t('mime'),
|
||||
'title' => I18n::translate('mime'),
|
||||
'text' => $file->mime()
|
||||
],
|
||||
[
|
||||
'title' => t('url'),
|
||||
'title' => I18n::translate('url'),
|
||||
'text' => $id,
|
||||
'link' => $url
|
||||
],
|
||||
[
|
||||
'title' => t('size'),
|
||||
'title' => I18n::translate('size'),
|
||||
'text' => $file->niceSize()
|
||||
],
|
||||
[
|
||||
'title' => t('dimensions'),
|
||||
'text' => $file->type() === 'image' ? $file->dimensions() . ' ' . t('pixel') : '—'
|
||||
'title' => I18n::translate('dimensions'),
|
||||
'text' => $file->type() === 'image' ? $file->dimensions() . ' ' . I18n::translate('pixel') : '—'
|
||||
],
|
||||
[
|
||||
'title' => t('orientation'),
|
||||
'text' => $file->type() === 'image' ? t('orientation.' . $dimensions->orientation()) : '—'
|
||||
'title' => I18n::translate('orientation'),
|
||||
'text' => $file->type() === 'image' ? I18n::translate('orientation.' . $dimensions->orientation()) : '—'
|
||||
],
|
||||
]
|
||||
]
|
||||
|
17
kirby/src/Panel/Home.php
Normal file → Executable file
17
kirby/src/Panel/Home.php
Normal file → Executable file
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace Kirby\Panel;
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\User;
|
||||
use Kirby\Exception\InvalidArgumentException;
|
||||
use Kirby\Exception\NotFoundException;
|
||||
use Kirby\Http\Router;
|
||||
use Kirby\Http\Uri;
|
||||
use Kirby\Toolkit\Str;
|
||||
use Throwable;
|
||||
@@ -46,7 +48,7 @@ class Home
|
||||
|
||||
// no access to the panel? The only good alternative is the main url
|
||||
if ($permissions->for('access', 'panel') === false) {
|
||||
return site()->url();
|
||||
return App::instance()->site()->url();
|
||||
}
|
||||
|
||||
// needed to create a proper menu
|
||||
@@ -104,7 +106,7 @@ class Home
|
||||
|
||||
// create a dummy router to check if we can access this route at all
|
||||
try {
|
||||
return router($path, 'GET', $routes, function ($route) use ($user) {
|
||||
return Router::execute($path, 'GET', $routes, function ($route) use ($user) {
|
||||
$auth = $route->attributes()['auth'] ?? true;
|
||||
$areaId = $route->attributes()['area'] ?? null;
|
||||
$type = $route->attributes()['type'] ?? 'view';
|
||||
@@ -138,7 +140,8 @@ class Home
|
||||
*/
|
||||
public static function hasValidDomain(Uri $uri): bool
|
||||
{
|
||||
return $uri->domain() === (new Uri(site()->url()))->domain();
|
||||
$rootUrl = App::instance()->site()->url();
|
||||
return $uri->domain() === (new Uri($rootUrl))->domain();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,7 +152,7 @@ class Home
|
||||
*/
|
||||
public static function isPanelUrl(string $url): bool
|
||||
{
|
||||
return Str::startsWith($url, kirby()->url('panel'));
|
||||
return Str::startsWith($url, App::instance()->url('panel'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +164,7 @@ class Home
|
||||
*/
|
||||
public static function panelPath(string $url): ?string
|
||||
{
|
||||
$after = Str::after($url, kirby()->url('panel'));
|
||||
$after = Str::after($url, App::instance()->url('panel'));
|
||||
return trim($after, '/');
|
||||
}
|
||||
|
||||
@@ -176,7 +179,7 @@ class Home
|
||||
public static function remembered(): ?string
|
||||
{
|
||||
// check for a stored path after login
|
||||
$remembered = kirby()->session()->pull('panel.path');
|
||||
$remembered = App::instance()->session()->pull('panel.path');
|
||||
|
||||
// convert the result to an absolute URL if available
|
||||
return $remembered ? Panel::url($remembered) : null;
|
||||
@@ -208,7 +211,7 @@ class Home
|
||||
*/
|
||||
public static function url(): string
|
||||
{
|
||||
$user = kirby()->user();
|
||||
$user = App::instance()->user();
|
||||
|
||||
// if there's no authenticated user, all internal
|
||||
// redirects will be blocked and the user is redirected
|
||||
|
0
kirby/src/Panel/Json.php
Normal file → Executable file
0
kirby/src/Panel/Json.php
Normal file → Executable file
10
kirby/src/Panel/Model.php
Normal file → Executable file
10
kirby/src/Panel/Model.php
Normal file → Executable file
@@ -53,7 +53,7 @@ abstract class Model
|
||||
public function dragTextFromCallback(string $type, ...$args): ?string
|
||||
{
|
||||
$option = 'panel.' . $type . '.' . $this->model::CLASS_ALIAS . 'DragText';
|
||||
$callback = option($option);
|
||||
$callback = $this->model->kirby()->option($option);
|
||||
|
||||
if (
|
||||
empty($callback) === false &&
|
||||
@@ -81,7 +81,8 @@ abstract class Model
|
||||
$type ??= 'auto';
|
||||
|
||||
if ($type === 'auto') {
|
||||
$type = option('panel.kirbytext', true) ? 'kirbytext' : 'markdown';
|
||||
$kirby = $this->model->kirby();
|
||||
$type = $kirby->option('panel.kirbytext', true) ? 'kirbytext' : 'markdown';
|
||||
}
|
||||
|
||||
return $type === 'markdown' ? 'markdown' : 'kirbytext';
|
||||
@@ -351,8 +352,9 @@ abstract class Model
|
||||
public function props(): array
|
||||
{
|
||||
$blueprint = $this->model->blueprint();
|
||||
$request = $this->model->kirby()->request();
|
||||
$tabs = $blueprint->tabs();
|
||||
$tab = $blueprint->tab(get('tab')) ?? $tabs[0] ?? null;
|
||||
$tab = $blueprint->tab($request->get('tab')) ?? $tabs[0] ?? null;
|
||||
|
||||
$props = [
|
||||
'lock' => $this->lock(),
|
||||
@@ -407,7 +409,7 @@ abstract class Model
|
||||
|
||||
$data = $model->panel()->toLink($tooltip);
|
||||
|
||||
if ($tab = get('tab')) {
|
||||
if ($tab = $model->kirby()->request()->get('tab')) {
|
||||
$uri = new Uri($data['link'], [
|
||||
'query' => ['tab' => $tab]
|
||||
]);
|
||||
|
29
kirby/src/Panel/Page.php
Normal file → Executable file
29
kirby/src/Panel/Page.php
Normal file → Executable file
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Kirby\Panel;
|
||||
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
/**
|
||||
* Provides information about the page model for the Panel
|
||||
* @since 3.6.0
|
||||
@@ -66,14 +68,11 @@ class Page extends Model
|
||||
*/
|
||||
public function dropdown(array $options = []): array
|
||||
{
|
||||
$defaults = [
|
||||
'view' => get('view'),
|
||||
'sort' => get('sort'),
|
||||
'delete' => get('delete')
|
||||
];
|
||||
$page = $this->model;
|
||||
|
||||
$defaults = $page->kirby()->request()->get(['view', 'sort', 'delete']);
|
||||
$options = array_merge($defaults, $options);
|
||||
|
||||
$options = array_merge($defaults, $options);
|
||||
$page = $this->model;
|
||||
$permissions = $this->options(['preview']);
|
||||
$view = $options['view'] ?? 'view';
|
||||
$url = $this->url(true);
|
||||
@@ -84,7 +83,7 @@ class Page extends Model
|
||||
'link' => $page->previewUrl(),
|
||||
'target' => '_blank',
|
||||
'icon' => 'open',
|
||||
'text' => t('open'),
|
||||
'text' => I18n::translate('open'),
|
||||
'disabled' => $this->isDisabledDropdownOption('preview', $options, $permissions)
|
||||
];
|
||||
$result[] = '-';
|
||||
@@ -98,14 +97,14 @@ class Page extends Model
|
||||
]
|
||||
],
|
||||
'icon' => 'title',
|
||||
'text' => t('rename'),
|
||||
'text' => I18n::translate('rename'),
|
||||
'disabled' => $this->isDisabledDropdownOption('changeTitle', $options, $permissions)
|
||||
];
|
||||
|
||||
$result['duplicate'] = [
|
||||
'dialog' => $url . '/duplicate',
|
||||
'icon' => 'copy',
|
||||
'text' => t('duplicate'),
|
||||
'text' => I18n::translate('duplicate'),
|
||||
'disabled' => $this->isDisabledDropdownOption('duplicate', $options, $permissions)
|
||||
];
|
||||
|
||||
@@ -119,14 +118,14 @@ class Page extends Model
|
||||
]
|
||||
],
|
||||
'icon' => 'url',
|
||||
'text' => t('page.changeSlug'),
|
||||
'text' => I18n::translate('page.changeSlug'),
|
||||
'disabled' => $this->isDisabledDropdownOption('changeSlug', $options, $permissions)
|
||||
];
|
||||
|
||||
$result['changeStatus'] = [
|
||||
'dialog' => $url . '/changeStatus',
|
||||
'icon' => 'preview',
|
||||
'text' => t('page.changeStatus'),
|
||||
'text' => I18n::translate('page.changeStatus'),
|
||||
'disabled' => $this->isDisabledDropdownOption('changeStatus', $options, $permissions)
|
||||
];
|
||||
|
||||
@@ -135,14 +134,14 @@ class Page extends Model
|
||||
$result['changeSort'] = [
|
||||
'dialog' => $url . '/changeSort',
|
||||
'icon' => 'sort',
|
||||
'text' => t('page.sort'),
|
||||
'text' => I18n::translate('page.sort'),
|
||||
'disabled' => $siblings->count() === 0 || $this->isDisabledDropdownOption('sort', $options, $permissions)
|
||||
];
|
||||
|
||||
$result['changeTemplate'] = [
|
||||
'dialog' => $url . '/changeTemplate',
|
||||
'icon' => 'template',
|
||||
'text' => t('page.changeTemplate'),
|
||||
'text' => I18n::translate('page.changeTemplate'),
|
||||
'disabled' => $this->isDisabledDropdownOption('changeTemplate', $options, $permissions)
|
||||
];
|
||||
|
||||
@@ -150,7 +149,7 @@ class Page extends Model
|
||||
$result['delete'] = [
|
||||
'dialog' => $url . '/delete',
|
||||
'icon' => 'trash',
|
||||
'text' => t('delete'),
|
||||
'text' => I18n::translate('delete'),
|
||||
'disabled' => $this->isDisabledDropdownOption('delete', $options, $permissions)
|
||||
];
|
||||
|
||||
|
41
kirby/src/Panel/Panel.php
Normal file → Executable file
41
kirby/src/Panel/Panel.php
Normal file → Executable file
@@ -2,11 +2,14 @@
|
||||
|
||||
namespace Kirby\Panel;
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\Url as CmsUrl;
|
||||
use Kirby\Cms\User;
|
||||
use Kirby\Exception\Exception;
|
||||
use Kirby\Exception\NotFoundException;
|
||||
use Kirby\Exception\PermissionException;
|
||||
use Kirby\Http\Response;
|
||||
use Kirby\Http\Router;
|
||||
use Kirby\Http\Url;
|
||||
use Kirby\Toolkit\Str;
|
||||
use Kirby\Toolkit\Tpl;
|
||||
@@ -55,7 +58,7 @@ class Panel
|
||||
*/
|
||||
public static function areas(): array
|
||||
{
|
||||
$kirby = kirby();
|
||||
$kirby = App::instance();
|
||||
$system = $kirby->system();
|
||||
$user = $kirby->user();
|
||||
$areas = $kirby->load()->areas();
|
||||
@@ -189,7 +192,7 @@ class Panel
|
||||
*/
|
||||
public static function isFiberRequest(): bool
|
||||
{
|
||||
$request = kirby()->request();
|
||||
$request = App::instance()->request();
|
||||
|
||||
if ($request->method() === 'GET') {
|
||||
return (bool)($request->get('_json') ?? $request->header('X-Fiber'));
|
||||
@@ -208,9 +211,11 @@ class Panel
|
||||
*/
|
||||
public static function json(array $data, int $code = 200)
|
||||
{
|
||||
return Response::json($data, $code, get('_pretty'), [
|
||||
$request = App::instance()->request();
|
||||
|
||||
return Response::json($data, $code, $request->get('_pretty'), [
|
||||
'X-Fiber' => 'true',
|
||||
'Cache-Control' => 'no-store'
|
||||
'Cache-Control' => 'no-store, private'
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -222,7 +227,7 @@ class Panel
|
||||
public static function multilang(): bool
|
||||
{
|
||||
// multilang setup check
|
||||
$kirby = kirby();
|
||||
$kirby = App::instance();
|
||||
return $kirby->option('languages') || $kirby->multilang();
|
||||
}
|
||||
|
||||
@@ -233,8 +238,10 @@ class Panel
|
||||
*/
|
||||
public static function referrer(): string
|
||||
{
|
||||
$referrer = kirby()->request()->header('X-Fiber-Referrer')
|
||||
?? get('_referrer')
|
||||
$request = App::instance()->request();
|
||||
|
||||
$referrer = $request->header('X-Fiber-Referrer')
|
||||
?? $request->get('_referrer')
|
||||
?? '';
|
||||
|
||||
return '/' . trim($referrer, '/');
|
||||
@@ -285,7 +292,7 @@ class Panel
|
||||
*/
|
||||
public static function router(string $path = null)
|
||||
{
|
||||
$kirby = kirby();
|
||||
$kirby = App::instance();
|
||||
|
||||
if ($kirby->option('panel') === false) {
|
||||
return null;
|
||||
@@ -303,7 +310,7 @@ class Panel
|
||||
$routes = static::routes($areas);
|
||||
|
||||
// create a micro-router for the Panel
|
||||
return router($path, $method = $kirby->request()->method(), $routes, function ($route) use ($areas, $kirby, $method, $path) {
|
||||
return Router::execute($path, $method = $kirby->request()->method(), $routes, function ($route) use ($areas, $kirby, $method, $path) {
|
||||
|
||||
// route needs authentication?
|
||||
$auth = $route->attributes()['auth'] ?? true;
|
||||
@@ -345,7 +352,7 @@ class Panel
|
||||
*/
|
||||
public static function routes(array $areas): array
|
||||
{
|
||||
$kirby = kirby();
|
||||
$kirby = App::instance();
|
||||
|
||||
// the browser incompatibility
|
||||
// warning is always needed
|
||||
@@ -492,7 +499,9 @@ class Panel
|
||||
'type' => 'search',
|
||||
'area' => $areaId,
|
||||
'action' => function () use ($params) {
|
||||
return $params['query'](get('query'));
|
||||
$request = App::instance()->request();
|
||||
|
||||
return $params['query']($request->get('query'));
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -530,7 +539,7 @@ class Panel
|
||||
*/
|
||||
public static function setLanguage(): ?string
|
||||
{
|
||||
$kirby = kirby();
|
||||
$kirby = App::instance();
|
||||
|
||||
// language switcher
|
||||
if (static::multilang()) {
|
||||
@@ -542,7 +551,7 @@ class Panel
|
||||
|
||||
$session = $kirby->session();
|
||||
$sessionLanguage = $session->get('panel.language', $fallback);
|
||||
$language = get('language') ?? $sessionLanguage;
|
||||
$language = $kirby->request()->get('language') ?? $sessionLanguage;
|
||||
|
||||
// keep the language for the next visit
|
||||
if ($language !== $sessionLanguage) {
|
||||
@@ -566,7 +575,7 @@ class Panel
|
||||
*/
|
||||
public static function setTranslation(): string
|
||||
{
|
||||
$kirby = kirby();
|
||||
$kirby = App::instance();
|
||||
|
||||
if ($user = $kirby->user()) {
|
||||
// use the user language for the default translation
|
||||
@@ -590,7 +599,7 @@ class Panel
|
||||
*/
|
||||
public static function url(?string $url = null): string
|
||||
{
|
||||
$slug = kirby()->option('panel.slug', 'panel');
|
||||
$slug = App::instance()->option('panel.slug', 'panel');
|
||||
|
||||
// only touch relative paths
|
||||
if (Url::isAbsolute($url) === false) {
|
||||
@@ -603,7 +612,7 @@ class Panel
|
||||
}
|
||||
|
||||
// create an absolute URL
|
||||
$url = url($path);
|
||||
$url = CmsUrl::to($path);
|
||||
}
|
||||
|
||||
return $url;
|
||||
|
0
kirby/src/Panel/Plugins.php
Normal file → Executable file
0
kirby/src/Panel/Plugins.php
Normal file → Executable file
0
kirby/src/Panel/Redirect.php
Normal file → Executable file
0
kirby/src/Panel/Redirect.php
Normal file → Executable file
0
kirby/src/Panel/Search.php
Normal file → Executable file
0
kirby/src/Panel/Search.php
Normal file → Executable file
0
kirby/src/Panel/Site.php
Normal file → Executable file
0
kirby/src/Panel/Site.php
Normal file → Executable file
17
kirby/src/Panel/User.php
Normal file → Executable file
17
kirby/src/Panel/User.php
Normal file → Executable file
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace Kirby\Panel;
|
||||
|
||||
use Kirby\Cms\Url;
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
/**
|
||||
* Provides information about the user model for the Panel
|
||||
* @since 3.6.0
|
||||
@@ -51,7 +54,7 @@ class User extends Model
|
||||
$result[] = [
|
||||
'dialog' => $url . '/changeName',
|
||||
'icon' => 'title',
|
||||
'text' => t($i18nPrefix . '.changeName'),
|
||||
'text' => I18n::translate($i18nPrefix . '.changeName'),
|
||||
'disabled' => $this->isDisabledDropdownOption('changeName', $options, $permissions)
|
||||
];
|
||||
|
||||
@@ -60,28 +63,28 @@ class User extends Model
|
||||
$result[] = [
|
||||
'dialog' => $url . '/changeEmail',
|
||||
'icon' => 'email',
|
||||
'text' => t('user.changeEmail'),
|
||||
'text' => I18n::translate('user.changeEmail'),
|
||||
'disabled' => $this->isDisabledDropdownOption('changeEmail', $options, $permissions)
|
||||
];
|
||||
|
||||
$result[] = [
|
||||
'dialog' => $url . '/changeRole',
|
||||
'icon' => 'bolt',
|
||||
'text' => t('user.changeRole'),
|
||||
'text' => I18n::translate('user.changeRole'),
|
||||
'disabled' => $this->isDisabledDropdownOption('changeRole', $options, $permissions)
|
||||
];
|
||||
|
||||
$result[] = [
|
||||
'dialog' => $url . '/changePassword',
|
||||
'icon' => 'key',
|
||||
'text' => t('user.changePassword'),
|
||||
'text' => I18n::translate('user.changePassword'),
|
||||
'disabled' => $this->isDisabledDropdownOption('changePassword', $options, $permissions)
|
||||
];
|
||||
|
||||
$result[] = [
|
||||
'dialog' => $url . '/changeLanguage',
|
||||
'icon' => 'globe',
|
||||
'text' => t('user.changeLanguage'),
|
||||
'text' => I18n::translate('user.changeLanguage'),
|
||||
'disabled' => $this->isDisabledDropdownOption('changeLanguage', $options, $permissions)
|
||||
];
|
||||
|
||||
@@ -90,7 +93,7 @@ class User extends Model
|
||||
$result[] = [
|
||||
'dialog' => $url . '/delete',
|
||||
'icon' => 'trash',
|
||||
'text' => t($i18nPrefix . '.delete'),
|
||||
'text' => I18n::translate($i18nPrefix . '.delete'),
|
||||
'disabled' => $this->isDisabledDropdownOption('delete', $options, $permissions)
|
||||
];
|
||||
|
||||
@@ -119,7 +122,7 @@ class User extends Model
|
||||
{
|
||||
if ($home = ($this->model->blueprint()->home() ?? null)) {
|
||||
$url = $this->model->toString($home);
|
||||
return url($url);
|
||||
return Url::to($url);
|
||||
}
|
||||
|
||||
return Panel::url('site');
|
||||
|
21
kirby/src/Panel/View.php
Normal file → Executable file
21
kirby/src/Panel/View.php
Normal file → Executable file
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace Kirby\Panel;
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Http\Response;
|
||||
use Kirby\Http\Url;
|
||||
use Kirby\Toolkit\A;
|
||||
use Kirby\Toolkit\I18n;
|
||||
use Kirby\Toolkit\Str;
|
||||
|
||||
/**
|
||||
@@ -32,14 +33,14 @@ class View
|
||||
*/
|
||||
public static function apply(array $data): array
|
||||
{
|
||||
$request = kirby()->request();
|
||||
$only = $request->header('X-Fiber-Only') ?? get('_only');
|
||||
$request = App::instance()->request();
|
||||
$only = $request->header('X-Fiber-Only') ?? $request->get('_only');
|
||||
|
||||
if (empty($only) === false) {
|
||||
return static::applyOnly($data, $only);
|
||||
}
|
||||
|
||||
$globals = $request->header('X-Fiber-Globals') ?? get('_globals');
|
||||
$globals = $request->header('X-Fiber-Globals') ?? $request->get('_globals');
|
||||
|
||||
if (empty($globals) === false) {
|
||||
return static::applyGlobals($data, $globals);
|
||||
@@ -139,7 +140,7 @@ class View
|
||||
*/
|
||||
public static function data(array $view = [], array $options = []): array
|
||||
{
|
||||
$kirby = kirby();
|
||||
$kirby = App::instance();
|
||||
|
||||
// multilang setup check
|
||||
$multilang = Panel::multilang();
|
||||
@@ -196,7 +197,7 @@ class View
|
||||
'$license' => (bool)$kirby->system()->license(),
|
||||
'$multilang' => $multilang,
|
||||
'$searches' => static::searches($options['areas'] ?? [], $permissions),
|
||||
'$url' => Url::current(),
|
||||
'$url' => $kirby->request()->url()->toString(),
|
||||
'$user' => function () use ($user) {
|
||||
if ($user) {
|
||||
return [
|
||||
@@ -251,7 +252,7 @@ class View
|
||||
'error' => $message,
|
||||
'props' => [
|
||||
'error' => $message,
|
||||
'layout' => Panel::hasAccess(kirby()->user()) ? 'inside' : 'outside'
|
||||
'layout' => Panel::hasAccess(App::instance()->user()) ? 'inside' : 'outside'
|
||||
],
|
||||
'title' => 'Error'
|
||||
];
|
||||
@@ -269,7 +270,7 @@ class View
|
||||
*/
|
||||
public static function globals(): array
|
||||
{
|
||||
$kirby = kirby();
|
||||
$kirby = App::instance();
|
||||
|
||||
return [
|
||||
'$config' => function () use ($kirby) {
|
||||
@@ -372,7 +373,7 @@ class View
|
||||
'id' => 'account',
|
||||
'link' => 'account',
|
||||
'disabled' => ($permissions['access']['account'] ?? false) === false,
|
||||
'text' => t('view.account'),
|
||||
'text' => I18n::translate('view.account'),
|
||||
];
|
||||
$menu[] = '-';
|
||||
|
||||
@@ -381,7 +382,7 @@ class View
|
||||
'icon' => 'logout',
|
||||
'id' => 'logout',
|
||||
'link' => 'logout',
|
||||
'text' => t('logout')
|
||||
'text' => I18n::translate('logout')
|
||||
];
|
||||
return $menu;
|
||||
}
|
||||
|
Reference in New Issue
Block a user