Update Kirby and dependencies
This commit is contained in:
parent
07150a0011
commit
c7c5d615a4
451 changed files with 67540 additions and 63740 deletions
|
@ -3,25 +3,25 @@
|
|||
use Kirby\Exception\PermissionException;
|
||||
|
||||
return function () {
|
||||
$auth = $this->kirby()->auth();
|
||||
$allowImpersonation = $this->kirby()->option('api.allowImpersonation') ?? false;
|
||||
$auth = $this->kirby()->auth();
|
||||
$allowImpersonation = $this->kirby()->option('api.allowImpersonation') ?? false;
|
||||
|
||||
// csrf token check
|
||||
if (
|
||||
$auth->type($allowImpersonation) === 'session' &&
|
||||
$auth->csrf() === false
|
||||
) {
|
||||
throw new PermissionException('Unauthenticated');
|
||||
}
|
||||
// csrf token check
|
||||
if (
|
||||
$auth->type($allowImpersonation) === 'session' &&
|
||||
$auth->csrf() === false
|
||||
) {
|
||||
throw new PermissionException('Unauthenticated');
|
||||
}
|
||||
|
||||
// get user from session or basic auth
|
||||
if ($user = $auth->user(null, $allowImpersonation)) {
|
||||
if ($user->role()->permissions()->for('access', 'panel') === false) {
|
||||
throw new PermissionException(['key' => 'access.panel']);
|
||||
}
|
||||
// get user from session or basic auth
|
||||
if ($user = $auth->user(null, $allowImpersonation)) {
|
||||
if ($user->role()->permissions()->for('access', 'panel') === false) {
|
||||
throw new PermissionException(['key' => 'access.panel']);
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
return $user;
|
||||
}
|
||||
|
||||
throw new PermissionException('Unauthenticated');
|
||||
throw new PermissionException('Unauthenticated');
|
||||
};
|
||||
|
|
|
@ -5,66 +5,66 @@
|
|||
*/
|
||||
return [
|
||||
|
||||
/**
|
||||
* Children
|
||||
*/
|
||||
'children' => [
|
||||
'model' => 'page',
|
||||
'type' => 'Kirby\Cms\Pages',
|
||||
'view' => 'compact'
|
||||
],
|
||||
/**
|
||||
* Children
|
||||
*/
|
||||
'children' => [
|
||||
'model' => 'page',
|
||||
'type' => 'Kirby\Cms\Pages',
|
||||
'view' => 'compact'
|
||||
],
|
||||
|
||||
/**
|
||||
* Files
|
||||
*/
|
||||
'files' => [
|
||||
'model' => 'file',
|
||||
'type' => 'Kirby\Cms\Files'
|
||||
],
|
||||
/**
|
||||
* Files
|
||||
*/
|
||||
'files' => [
|
||||
'model' => 'file',
|
||||
'type' => 'Kirby\Cms\Files'
|
||||
],
|
||||
|
||||
/**
|
||||
* Languages
|
||||
*/
|
||||
'languages' => [
|
||||
'model' => 'language',
|
||||
'type' => 'Kirby\Cms\Languages'
|
||||
],
|
||||
/**
|
||||
* Languages
|
||||
*/
|
||||
'languages' => [
|
||||
'model' => 'language',
|
||||
'type' => 'Kirby\Cms\Languages'
|
||||
],
|
||||
|
||||
/**
|
||||
* Pages
|
||||
*/
|
||||
'pages' => [
|
||||
'model' => 'page',
|
||||
'type' => 'Kirby\Cms\Pages',
|
||||
'view' => 'compact'
|
||||
],
|
||||
/**
|
||||
* Pages
|
||||
*/
|
||||
'pages' => [
|
||||
'model' => 'page',
|
||||
'type' => 'Kirby\Cms\Pages',
|
||||
'view' => 'compact'
|
||||
],
|
||||
|
||||
/**
|
||||
* Roles
|
||||
*/
|
||||
'roles' => [
|
||||
'model' => 'role',
|
||||
'type' => 'Kirby\Cms\Roles',
|
||||
'view' => 'compact'
|
||||
],
|
||||
/**
|
||||
* Roles
|
||||
*/
|
||||
'roles' => [
|
||||
'model' => 'role',
|
||||
'type' => 'Kirby\Cms\Roles',
|
||||
'view' => 'compact'
|
||||
],
|
||||
|
||||
/**
|
||||
* Translations
|
||||
*/
|
||||
'translations' => [
|
||||
'model' => 'translation',
|
||||
'type' => 'Kirby\Cms\Translations',
|
||||
'view' => 'compact'
|
||||
],
|
||||
/**
|
||||
* Translations
|
||||
*/
|
||||
'translations' => [
|
||||
'model' => 'translation',
|
||||
'type' => 'Kirby\Cms\Translations',
|
||||
'view' => 'compact'
|
||||
],
|
||||
|
||||
/**
|
||||
* Users
|
||||
*/
|
||||
'users' => [
|
||||
'default' => fn () => $this->users(),
|
||||
'model' => 'user',
|
||||
'type' => 'Kirby\Cms\Users',
|
||||
'view' => 'compact'
|
||||
]
|
||||
/**
|
||||
* Users
|
||||
*/
|
||||
'users' => [
|
||||
'default' => fn () => $this->users(),
|
||||
'model' => 'user',
|
||||
'type' => 'Kirby\Cms\Users',
|
||||
'view' => 'compact'
|
||||
]
|
||||
|
||||
];
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
* Api Model Definitions
|
||||
*/
|
||||
return [
|
||||
'File' => include __DIR__ . '/models/File.php',
|
||||
'FileBlueprint' => include __DIR__ . '/models/FileBlueprint.php',
|
||||
'FileVersion' => include __DIR__ . '/models/FileVersion.php',
|
||||
'Language' => include __DIR__ . '/models/Language.php',
|
||||
'Page' => include __DIR__ . '/models/Page.php',
|
||||
'PageBlueprint' => include __DIR__ . '/models/PageBlueprint.php',
|
||||
'Role' => include __DIR__ . '/models/Role.php',
|
||||
'Site' => include __DIR__ . '/models/Site.php',
|
||||
'SiteBlueprint' => include __DIR__ . '/models/SiteBlueprint.php',
|
||||
'System' => include __DIR__ . '/models/System.php',
|
||||
'Translation' => include __DIR__ . '/models/Translation.php',
|
||||
'User' => include __DIR__ . '/models/User.php',
|
||||
'UserBlueprint' => include __DIR__ . '/models/UserBlueprint.php',
|
||||
'File' => include __DIR__ . '/models/File.php',
|
||||
'FileBlueprint' => include __DIR__ . '/models/FileBlueprint.php',
|
||||
'FileVersion' => include __DIR__ . '/models/FileVersion.php',
|
||||
'Language' => include __DIR__ . '/models/Language.php',
|
||||
'Page' => include __DIR__ . '/models/Page.php',
|
||||
'PageBlueprint' => include __DIR__ . '/models/PageBlueprint.php',
|
||||
'Role' => include __DIR__ . '/models/Role.php',
|
||||
'Site' => include __DIR__ . '/models/Site.php',
|
||||
'SiteBlueprint' => include __DIR__ . '/models/SiteBlueprint.php',
|
||||
'System' => include __DIR__ . '/models/System.php',
|
||||
'Translation' => include __DIR__ . '/models/Translation.php',
|
||||
'User' => include __DIR__ . '/models/User.php',
|
||||
'UserBlueprint' => include __DIR__ . '/models/UserBlueprint.php',
|
||||
];
|
||||
|
|
|
@ -7,116 +7,109 @@ use Kirby\Form\Form;
|
|||
* File
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'blueprint' => fn (File $file) => $file->blueprint(),
|
||||
'content' => fn (File $file) => Form::for($file)->values(),
|
||||
'dimensions' => fn (File $file) => $file->dimensions()->toArray(),
|
||||
'dragText' => fn (File $file) => $file->panel()->dragText(),
|
||||
'exists' => fn (File $file) => $file->exists(),
|
||||
'extension' => fn (File $file) => $file->extension(),
|
||||
'filename' => fn (File $file) => $file->filename(),
|
||||
'id' => fn (File $file) => $file->id(),
|
||||
'link' => fn (File $file) => $file->panel()->url(true),
|
||||
'mime' => fn (File $file) => $file->mime(),
|
||||
'modified' => fn (File $file) => $file->modified('c'),
|
||||
'name' => fn (File $file) => $file->name(),
|
||||
'next' => fn (File $file) => $file->next(),
|
||||
'nextWithTemplate' => function (File $file) {
|
||||
$files = $file->templateSiblings()->sorted();
|
||||
$index = $files->indexOf($file);
|
||||
'fields' => [
|
||||
'blueprint' => fn (File $file) => $file->blueprint(),
|
||||
'content' => fn (File $file) => Form::for($file)->values(),
|
||||
'dimensions' => fn (File $file) => $file->dimensions()->toArray(),
|
||||
'dragText' => fn (File $file) => $file->panel()->dragText(),
|
||||
'exists' => fn (File $file) => $file->exists(),
|
||||
'extension' => fn (File $file) => $file->extension(),
|
||||
'filename' => fn (File $file) => $file->filename(),
|
||||
'id' => fn (File $file) => $file->id(),
|
||||
'link' => fn (File $file) => $file->panel()->url(true),
|
||||
'mime' => fn (File $file) => $file->mime(),
|
||||
'modified' => fn (File $file) => $file->modified('c'),
|
||||
'name' => fn (File $file) => $file->name(),
|
||||
'next' => fn (File $file) => $file->next(),
|
||||
'nextWithTemplate' => function (File $file) {
|
||||
$files = $file->templateSiblings()->sorted();
|
||||
$index = $files->indexOf($file);
|
||||
|
||||
return $files->nth($index + 1);
|
||||
},
|
||||
'niceSize' => fn (File $file) => $file->niceSize(),
|
||||
'options' => fn (File $file) => $file->panel()->options(),
|
||||
'panelIcon' => function (File $file) {
|
||||
// TODO: remove in 3.7.0
|
||||
// @codeCoverageIgnoreStart
|
||||
deprecated('The API field file.panelIcon has been deprecated and will be removed in 3.7.0. Use file.panelImage instead');
|
||||
return $file->panel()->image();
|
||||
// @codeCoverageIgnoreEnd
|
||||
},
|
||||
'panelImage' => fn (File $file) => $file->panel()->image(),
|
||||
'panelUrl' => fn (File $file) => $file->panel()->url(true),
|
||||
'prev' => fn (File $file) => $file->prev(),
|
||||
'prevWithTemplate' => function (File $file) {
|
||||
$files = $file->templateSiblings()->sorted();
|
||||
$index = $files->indexOf($file);
|
||||
return $files->nth($index + 1);
|
||||
},
|
||||
'niceSize' => fn (File $file) => $file->niceSize(),
|
||||
'options' => fn (File $file) => $file->panel()->options(),
|
||||
'panelImage' => fn (File $file) => $file->panel()->image(),
|
||||
'panelUrl' => fn (File $file) => $file->panel()->url(true),
|
||||
'prev' => fn (File $file) => $file->prev(),
|
||||
'prevWithTemplate' => function (File $file) {
|
||||
$files = $file->templateSiblings()->sorted();
|
||||
$index = $files->indexOf($file);
|
||||
|
||||
return $files->nth($index - 1);
|
||||
},
|
||||
'parent' => fn (File $file) => $file->parent(),
|
||||
'parents' => fn (File $file) => $file->parents()->flip(),
|
||||
'size' => fn (File $file) => $file->size(),
|
||||
'template' => fn (File $file) => $file->template(),
|
||||
'thumbs' => function ($file) {
|
||||
if ($file->isResizable() === false) {
|
||||
return null;
|
||||
}
|
||||
return $files->nth($index - 1);
|
||||
},
|
||||
'parent' => fn (File $file) => $file->parent(),
|
||||
'parents' => fn (File $file) => $file->parents()->flip(),
|
||||
'size' => fn (File $file) => $file->size(),
|
||||
'template' => fn (File $file) => $file->template(),
|
||||
'thumbs' => function ($file) {
|
||||
if ($file->isResizable() === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'tiny' => $file->resize(128)->url(),
|
||||
'small' => $file->resize(256)->url(),
|
||||
'medium' => $file->resize(512)->url(),
|
||||
'large' => $file->resize(768)->url(),
|
||||
'huge' => $file->resize(1024)->url(),
|
||||
];
|
||||
},
|
||||
'type' => fn (File $file) => $file->type(),
|
||||
'url' => fn (File $file) => $file->url(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\File',
|
||||
'views' => [
|
||||
'default' => [
|
||||
'content',
|
||||
'dimensions',
|
||||
'exists',
|
||||
'extension',
|
||||
'filename',
|
||||
'id',
|
||||
'link',
|
||||
'mime',
|
||||
'modified',
|
||||
'name',
|
||||
'next' => 'compact',
|
||||
'niceSize',
|
||||
'parent' => 'compact',
|
||||
'options',
|
||||
'prev' => 'compact',
|
||||
'size',
|
||||
'template',
|
||||
'type',
|
||||
'url'
|
||||
],
|
||||
'compact' => [
|
||||
'filename',
|
||||
'id',
|
||||
'link',
|
||||
'type',
|
||||
'url',
|
||||
],
|
||||
'panel' => [
|
||||
'blueprint',
|
||||
'content',
|
||||
'dimensions',
|
||||
'extension',
|
||||
'filename',
|
||||
'id',
|
||||
'link',
|
||||
'mime',
|
||||
'modified',
|
||||
'name',
|
||||
'nextWithTemplate' => 'compact',
|
||||
'niceSize',
|
||||
'options',
|
||||
'panelIcon',
|
||||
'panelImage',
|
||||
'parent' => 'compact',
|
||||
'parents' => ['id', 'slug', 'title'],
|
||||
'prevWithTemplate' => 'compact',
|
||||
'template',
|
||||
'type',
|
||||
'url'
|
||||
]
|
||||
],
|
||||
return [
|
||||
'tiny' => $file->resize(128)->url(),
|
||||
'small' => $file->resize(256)->url(),
|
||||
'medium' => $file->resize(512)->url(),
|
||||
'large' => $file->resize(768)->url(),
|
||||
'huge' => $file->resize(1024)->url(),
|
||||
];
|
||||
},
|
||||
'type' => fn (File $file) => $file->type(),
|
||||
'url' => fn (File $file) => $file->url(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\File',
|
||||
'views' => [
|
||||
'default' => [
|
||||
'content',
|
||||
'dimensions',
|
||||
'exists',
|
||||
'extension',
|
||||
'filename',
|
||||
'id',
|
||||
'link',
|
||||
'mime',
|
||||
'modified',
|
||||
'name',
|
||||
'next' => 'compact',
|
||||
'niceSize',
|
||||
'parent' => 'compact',
|
||||
'options',
|
||||
'prev' => 'compact',
|
||||
'size',
|
||||
'template',
|
||||
'type',
|
||||
'url'
|
||||
],
|
||||
'compact' => [
|
||||
'filename',
|
||||
'id',
|
||||
'link',
|
||||
'type',
|
||||
'url',
|
||||
],
|
||||
'panel' => [
|
||||
'blueprint',
|
||||
'content',
|
||||
'dimensions',
|
||||
'extension',
|
||||
'filename',
|
||||
'id',
|
||||
'link',
|
||||
'mime',
|
||||
'modified',
|
||||
'name',
|
||||
'nextWithTemplate' => 'compact',
|
||||
'niceSize',
|
||||
'options',
|
||||
'panelIcon',
|
||||
'panelImage',
|
||||
'parent' => 'compact',
|
||||
'parents' => ['id', 'slug', 'title'],
|
||||
'prevWithTemplate' => 'compact',
|
||||
'template',
|
||||
'type',
|
||||
'url'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
|
|
@ -6,13 +6,13 @@ use Kirby\Cms\FileBlueprint;
|
|||
* FileBlueprint
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'name' => fn (FileBlueprint $blueprint) => $blueprint->name(),
|
||||
'options' => fn (FileBlueprint $blueprint) => $blueprint->options(),
|
||||
'tabs' => fn (FileBlueprint $blueprint) => $blueprint->tabs(),
|
||||
'title' => fn (FileBlueprint $blueprint) => $blueprint->title(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\FileBlueprint',
|
||||
'views' => [
|
||||
],
|
||||
'fields' => [
|
||||
'name' => fn (FileBlueprint $blueprint) => $blueprint->name(),
|
||||
'options' => fn (FileBlueprint $blueprint) => $blueprint->options(),
|
||||
'tabs' => fn (FileBlueprint $blueprint) => $blueprint->tabs(),
|
||||
'title' => fn (FileBlueprint $blueprint) => $blueprint->title(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\FileBlueprint',
|
||||
'views' => [
|
||||
],
|
||||
];
|
||||
|
|
|
@ -6,54 +6,54 @@ use Kirby\Cms\FileVersion;
|
|||
* FileVersion
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'dimensions' => fn (FileVersion $file) => $file->dimensions()->toArray(),
|
||||
'exists' => fn (FileVersion $file) => $file->exists(),
|
||||
'extension' => fn (FileVersion $file) => $file->extension(),
|
||||
'filename' => fn (FileVersion $file) => $file->filename(),
|
||||
'id' => fn (FileVersion $file) => $file->id(),
|
||||
'mime' => fn (FileVersion $file) => $file->mime(),
|
||||
'modified' => fn (FileVersion $file) => $file->modified('c'),
|
||||
'name' => fn (FileVersion $file) => $file->name(),
|
||||
'niceSize' => fn (FileVersion $file) => $file->niceSize(),
|
||||
'size' => fn (FileVersion $file) => $file->size(),
|
||||
'type' => fn (FileVersion $file) => $file->type(),
|
||||
'url' => fn (FileVersion $file) => $file->url(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\FileVersion',
|
||||
'views' => [
|
||||
'default' => [
|
||||
'dimensions',
|
||||
'exists',
|
||||
'extension',
|
||||
'filename',
|
||||
'id',
|
||||
'mime',
|
||||
'modified',
|
||||
'name',
|
||||
'niceSize',
|
||||
'size',
|
||||
'type',
|
||||
'url'
|
||||
],
|
||||
'compact' => [
|
||||
'filename',
|
||||
'id',
|
||||
'type',
|
||||
'url',
|
||||
],
|
||||
'panel' => [
|
||||
'dimensions',
|
||||
'extension',
|
||||
'filename',
|
||||
'id',
|
||||
'mime',
|
||||
'modified',
|
||||
'name',
|
||||
'niceSize',
|
||||
'template',
|
||||
'type',
|
||||
'url'
|
||||
]
|
||||
],
|
||||
'fields' => [
|
||||
'dimensions' => fn (FileVersion $file) => $file->dimensions()->toArray(),
|
||||
'exists' => fn (FileVersion $file) => $file->exists(),
|
||||
'extension' => fn (FileVersion $file) => $file->extension(),
|
||||
'filename' => fn (FileVersion $file) => $file->filename(),
|
||||
'id' => fn (FileVersion $file) => $file->id(),
|
||||
'mime' => fn (FileVersion $file) => $file->mime(),
|
||||
'modified' => fn (FileVersion $file) => $file->modified('c'),
|
||||
'name' => fn (FileVersion $file) => $file->name(),
|
||||
'niceSize' => fn (FileVersion $file) => $file->niceSize(),
|
||||
'size' => fn (FileVersion $file) => $file->size(),
|
||||
'type' => fn (FileVersion $file) => $file->type(),
|
||||
'url' => fn (FileVersion $file) => $file->url(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\FileVersion',
|
||||
'views' => [
|
||||
'default' => [
|
||||
'dimensions',
|
||||
'exists',
|
||||
'extension',
|
||||
'filename',
|
||||
'id',
|
||||
'mime',
|
||||
'modified',
|
||||
'name',
|
||||
'niceSize',
|
||||
'size',
|
||||
'type',
|
||||
'url'
|
||||
],
|
||||
'compact' => [
|
||||
'filename',
|
||||
'id',
|
||||
'type',
|
||||
'url',
|
||||
],
|
||||
'panel' => [
|
||||
'dimensions',
|
||||
'extension',
|
||||
'filename',
|
||||
'id',
|
||||
'mime',
|
||||
'modified',
|
||||
'name',
|
||||
'niceSize',
|
||||
'template',
|
||||
'type',
|
||||
'url'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
|
|
@ -6,25 +6,25 @@ use Kirby\Cms\Language;
|
|||
* Language
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'code' => fn (Language $language) => $language->code(),
|
||||
'default' => fn (Language $language) => $language->isDefault(),
|
||||
'direction' => fn (Language $language) => $language->direction(),
|
||||
'locale' => fn (Language $language) => $language->locale(),
|
||||
'name' => fn (Language $language) => $language->name(),
|
||||
'rules' => fn (Language $language) => $language->rules(),
|
||||
'url' => fn (Language $language) => $language->url(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\Language',
|
||||
'views' => [
|
||||
'default' => [
|
||||
'code',
|
||||
'default',
|
||||
'direction',
|
||||
'locale',
|
||||
'name',
|
||||
'rules',
|
||||
'url'
|
||||
]
|
||||
]
|
||||
'fields' => [
|
||||
'code' => fn (Language $language) => $language->code(),
|
||||
'default' => fn (Language $language) => $language->isDefault(),
|
||||
'direction' => fn (Language $language) => $language->direction(),
|
||||
'locale' => fn (Language $language) => $language->locale(),
|
||||
'name' => fn (Language $language) => $language->name(),
|
||||
'rules' => fn (Language $language) => $language->rules(),
|
||||
'url' => fn (Language $language) => $language->url(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\Language',
|
||||
'views' => [
|
||||
'default' => [
|
||||
'code',
|
||||
'default',
|
||||
'direction',
|
||||
'locale',
|
||||
'name',
|
||||
'rules',
|
||||
'url'
|
||||
]
|
||||
]
|
||||
];
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\Helpers;
|
||||
use Kirby\Cms\Page;
|
||||
use Kirby\Form\Form;
|
||||
|
||||
|
@ -7,122 +8,116 @@ use Kirby\Form\Form;
|
|||
* Page
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'blueprint' => fn (Page $page) => $page->blueprint(),
|
||||
'blueprints' => fn (Page $page) => $page->blueprints(),
|
||||
'children' => fn (Page $page) => $page->children(),
|
||||
'content' => fn (Page $page) => Form::for($page)->values(),
|
||||
'drafts' => fn (Page $page) => $page->drafts(),
|
||||
'errors' => fn (Page $page) => $page->errors(),
|
||||
'files' => fn (Page $page) => $page->files()->sorted(),
|
||||
'hasChildren' => fn (Page $page) => $page->hasChildren(),
|
||||
'hasDrafts' => fn (Page $page) => $page->hasDrafts(),
|
||||
'hasFiles' => fn (Page $page) => $page->hasFiles(),
|
||||
'id' => fn (Page $page) => $page->id(),
|
||||
'isSortable' => fn (Page $page) => $page->isSortable(),
|
||||
/**
|
||||
* @deprecated 3.6.0
|
||||
* @todo Throw deprecated warning in 3.7.0
|
||||
* @todo Remove in 3.8.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
'next' => function (Page $page) {
|
||||
return $page
|
||||
->nextAll()
|
||||
->filter('intendedTemplate', $page->intendedTemplate())
|
||||
->filter('status', $page->status())
|
||||
->filter('isReadable', true)
|
||||
->first();
|
||||
},
|
||||
'num' => fn (Page $page) => $page->num(),
|
||||
'options' => fn (Page $page) => $page->panel()->options(['preview']),
|
||||
/**
|
||||
* @todo Remove in 3.7.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
'panelIcon' => function (Page $page) {
|
||||
deprecated('The API field page.panelIcon has been deprecated and will be removed in 3.7.0. Use page.panelImage instead');
|
||||
return $page->panel()->image();
|
||||
},
|
||||
'panelImage' => fn (Page $page) => $page->panel()->image(),
|
||||
'parent' => fn (Page $page) => $page->parent(),
|
||||
'parents' => fn (Page $page) => $page->parents()->flip(),
|
||||
/**
|
||||
* @deprecated 3.6.0
|
||||
* @todo Throw deprecated warning in 3.7.0
|
||||
* @todo Remove in 3.8.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
'prev' => function (Page $page) {
|
||||
return $page
|
||||
->prevAll()
|
||||
->filter('intendedTemplate', $page->intendedTemplate())
|
||||
->filter('status', $page->status())
|
||||
->filter('isReadable', true)
|
||||
->last();
|
||||
},
|
||||
'previewUrl' => fn (Page $page) => $page->previewUrl(),
|
||||
'siblings' => function (Page $page) {
|
||||
if ($page->isDraft() === true) {
|
||||
return $page->parentModel()->children()->not($page);
|
||||
} else {
|
||||
return $page->siblings();
|
||||
}
|
||||
},
|
||||
'slug' => fn (Page $page) => $page->slug(),
|
||||
'status' => fn (Page $page) => $page->status(),
|
||||
'template' => fn (Page $page) => $page->intendedTemplate()->name(),
|
||||
'title' => fn (Page $page) => $page->title()->value(),
|
||||
'url' => fn (Page $page) => $page->url(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\Page',
|
||||
'views' => [
|
||||
'compact' => [
|
||||
'id',
|
||||
'title',
|
||||
'url',
|
||||
'num'
|
||||
],
|
||||
'default' => [
|
||||
'content',
|
||||
'id',
|
||||
'status',
|
||||
'num',
|
||||
'options',
|
||||
'parent' => 'compact',
|
||||
'slug',
|
||||
'template',
|
||||
'title',
|
||||
'url'
|
||||
],
|
||||
'panel' => [
|
||||
'id',
|
||||
'blueprint',
|
||||
'content',
|
||||
'status',
|
||||
'options',
|
||||
'next' => ['id', 'slug', 'title'],
|
||||
'parents' => ['id', 'slug', 'title'],
|
||||
'prev' => ['id', 'slug', 'title'],
|
||||
'previewUrl',
|
||||
'slug',
|
||||
'title',
|
||||
'url'
|
||||
],
|
||||
'selector' => [
|
||||
'id',
|
||||
'title',
|
||||
'parent' => [
|
||||
'id',
|
||||
'title'
|
||||
],
|
||||
'children' => [
|
||||
'hasChildren',
|
||||
'id',
|
||||
'panelIcon',
|
||||
'panelImage',
|
||||
'title',
|
||||
],
|
||||
]
|
||||
],
|
||||
'fields' => [
|
||||
'blueprint' => fn (Page $page) => $page->blueprint(),
|
||||
'blueprints' => fn (Page $page) => $page->blueprints(),
|
||||
'children' => fn (Page $page) => $page->children(),
|
||||
'content' => fn (Page $page) => Form::for($page)->values(),
|
||||
'drafts' => fn (Page $page) => $page->drafts(),
|
||||
'errors' => fn (Page $page) => $page->errors(),
|
||||
'files' => fn (Page $page) => $page->files()->sorted(),
|
||||
'hasChildren' => fn (Page $page) => $page->hasChildren(),
|
||||
'hasDrafts' => fn (Page $page) => $page->hasDrafts(),
|
||||
'hasFiles' => fn (Page $page) => $page->hasFiles(),
|
||||
'id' => fn (Page $page) => $page->id(),
|
||||
'isSortable' => fn (Page $page) => $page->isSortable(),
|
||||
/**
|
||||
* @deprecated 3.6.0
|
||||
* @todo Remove in 3.8.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
'next' => function (Page $page) {
|
||||
Helpers::deprecated('The API field page.next has been deprecated and will be removed in 3.8.0.');
|
||||
|
||||
return $page
|
||||
->nextAll()
|
||||
->filter('intendedTemplate', $page->intendedTemplate())
|
||||
->filter('status', $page->status())
|
||||
->filter('isReadable', true)
|
||||
->first();
|
||||
},
|
||||
'num' => fn (Page $page) => $page->num(),
|
||||
'options' => fn (Page $page) => $page->panel()->options(['preview']),
|
||||
'panelImage' => fn (Page $page) => $page->panel()->image(),
|
||||
'parent' => fn (Page $page) => $page->parent(),
|
||||
'parents' => fn (Page $page) => $page->parents()->flip(),
|
||||
/**
|
||||
* @deprecated 3.6.0
|
||||
* @todo Remove in 3.8.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
'prev' => function (Page $page) {
|
||||
Helpers::deprecated('The API field page.prev has been deprecated and will be removed in 3.8.0.');
|
||||
|
||||
return $page
|
||||
->prevAll()
|
||||
->filter('intendedTemplate', $page->intendedTemplate())
|
||||
->filter('status', $page->status())
|
||||
->filter('isReadable', true)
|
||||
->last();
|
||||
},
|
||||
'previewUrl' => fn (Page $page) => $page->previewUrl(),
|
||||
'siblings' => function (Page $page) {
|
||||
if ($page->isDraft() === true) {
|
||||
return $page->parentModel()->children()->not($page);
|
||||
} else {
|
||||
return $page->siblings();
|
||||
}
|
||||
},
|
||||
'slug' => fn (Page $page) => $page->slug(),
|
||||
'status' => fn (Page $page) => $page->status(),
|
||||
'template' => fn (Page $page) => $page->intendedTemplate()->name(),
|
||||
'title' => fn (Page $page) => $page->title()->value(),
|
||||
'url' => fn (Page $page) => $page->url(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\Page',
|
||||
'views' => [
|
||||
'compact' => [
|
||||
'id',
|
||||
'title',
|
||||
'url',
|
||||
'num'
|
||||
],
|
||||
'default' => [
|
||||
'content',
|
||||
'id',
|
||||
'status',
|
||||
'num',
|
||||
'options',
|
||||
'parent' => 'compact',
|
||||
'slug',
|
||||
'template',
|
||||
'title',
|
||||
'url'
|
||||
],
|
||||
'panel' => [
|
||||
'id',
|
||||
'blueprint',
|
||||
'content',
|
||||
'status',
|
||||
'options',
|
||||
'next' => ['id', 'slug', 'title'],
|
||||
'parents' => ['id', 'slug', 'title'],
|
||||
'prev' => ['id', 'slug', 'title'],
|
||||
'previewUrl',
|
||||
'slug',
|
||||
'title',
|
||||
'url'
|
||||
],
|
||||
'selector' => [
|
||||
'id',
|
||||
'title',
|
||||
'parent' => [
|
||||
'id',
|
||||
'title'
|
||||
],
|
||||
'children' => [
|
||||
'hasChildren',
|
||||
'id',
|
||||
'panelIcon',
|
||||
'panelImage',
|
||||
'title',
|
||||
],
|
||||
]
|
||||
],
|
||||
];
|
||||
|
|
|
@ -6,16 +6,16 @@ use Kirby\Cms\PageBlueprint;
|
|||
* PageBlueprint
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'name' => fn (PageBlueprint $blueprint) => $blueprint->name(),
|
||||
'num' => fn (PageBlueprint $blueprint) => $blueprint->num(),
|
||||
'options' => fn (PageBlueprint $blueprint) => $blueprint->options(),
|
||||
'preview' => fn (PageBlueprint $blueprint) => $blueprint->preview(),
|
||||
'status' => fn (PageBlueprint $blueprint) => $blueprint->status(),
|
||||
'tabs' => fn (PageBlueprint $blueprint) => $blueprint->tabs(),
|
||||
'title' => fn (PageBlueprint $blueprint) => $blueprint->title(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\PageBlueprint',
|
||||
'views' => [
|
||||
],
|
||||
'fields' => [
|
||||
'name' => fn (PageBlueprint $blueprint) => $blueprint->name(),
|
||||
'num' => fn (PageBlueprint $blueprint) => $blueprint->num(),
|
||||
'options' => fn (PageBlueprint $blueprint) => $blueprint->options(),
|
||||
'preview' => fn (PageBlueprint $blueprint) => $blueprint->preview(),
|
||||
'status' => fn (PageBlueprint $blueprint) => $blueprint->status(),
|
||||
'tabs' => fn (PageBlueprint $blueprint) => $blueprint->tabs(),
|
||||
'title' => fn (PageBlueprint $blueprint) => $blueprint->title(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\PageBlueprint',
|
||||
'views' => [
|
||||
],
|
||||
];
|
||||
|
|
|
@ -6,18 +6,18 @@ use Kirby\Cms\Role;
|
|||
* Role
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'description' => fn (Role $role) => $role->description(),
|
||||
'name' => fn (Role $role) => $role->name(),
|
||||
'permissions' => fn (Role $role) => $role->permissions()->toArray(),
|
||||
'title' => fn (Role $role) => $role->title(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\Role',
|
||||
'views' => [
|
||||
'compact' => [
|
||||
'description',
|
||||
'name',
|
||||
'title'
|
||||
]
|
||||
]
|
||||
'fields' => [
|
||||
'description' => fn (Role $role) => $role->description(),
|
||||
'name' => fn (Role $role) => $role->name(),
|
||||
'permissions' => fn (Role $role) => $role->permissions()->toArray(),
|
||||
'title' => fn (Role $role) => $role->title(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\Role',
|
||||
'views' => [
|
||||
'compact' => [
|
||||
'description',
|
||||
'name',
|
||||
'title'
|
||||
]
|
||||
]
|
||||
];
|
||||
|
|
|
@ -7,46 +7,46 @@ use Kirby\Form\Form;
|
|||
* Site
|
||||
*/
|
||||
return [
|
||||
'default' => fn () => $this->site(),
|
||||
'fields' => [
|
||||
'blueprint' => fn (Site $site) => $site->blueprint(),
|
||||
'children' => fn (Site $site) => $site->children(),
|
||||
'content' => fn (Site $site) => Form::for($site)->values(),
|
||||
'drafts' => fn (Site $site) => $site->drafts(),
|
||||
'files' => fn (Site $site) => $site->files()->sorted(),
|
||||
'options' => fn (Site $site) => $site->permissions()->toArray(),
|
||||
'previewUrl' => fn (Site $site) => $site->previewUrl(),
|
||||
'title' => fn (Site $site) => $site->title()->value(),
|
||||
'url' => fn (Site $site) => $site->url(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\Site',
|
||||
'views' => [
|
||||
'compact' => [
|
||||
'title',
|
||||
'url'
|
||||
],
|
||||
'default' => [
|
||||
'content',
|
||||
'options',
|
||||
'title',
|
||||
'url'
|
||||
],
|
||||
'panel' => [
|
||||
'title',
|
||||
'blueprint',
|
||||
'content',
|
||||
'options',
|
||||
'previewUrl',
|
||||
'url'
|
||||
],
|
||||
'selector' => [
|
||||
'title',
|
||||
'children' => [
|
||||
'id',
|
||||
'title',
|
||||
'panelIcon',
|
||||
'hasChildren'
|
||||
],
|
||||
]
|
||||
]
|
||||
'default' => fn () => $this->site(),
|
||||
'fields' => [
|
||||
'blueprint' => fn (Site $site) => $site->blueprint(),
|
||||
'children' => fn (Site $site) => $site->children(),
|
||||
'content' => fn (Site $site) => Form::for($site)->values(),
|
||||
'drafts' => fn (Site $site) => $site->drafts(),
|
||||
'files' => fn (Site $site) => $site->files()->sorted(),
|
||||
'options' => fn (Site $site) => $site->permissions()->toArray(),
|
||||
'previewUrl' => fn (Site $site) => $site->previewUrl(),
|
||||
'title' => fn (Site $site) => $site->title()->value(),
|
||||
'url' => fn (Site $site) => $site->url(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\Site',
|
||||
'views' => [
|
||||
'compact' => [
|
||||
'title',
|
||||
'url'
|
||||
],
|
||||
'default' => [
|
||||
'content',
|
||||
'options',
|
||||
'title',
|
||||
'url'
|
||||
],
|
||||
'panel' => [
|
||||
'title',
|
||||
'blueprint',
|
||||
'content',
|
||||
'options',
|
||||
'previewUrl',
|
||||
'url'
|
||||
],
|
||||
'selector' => [
|
||||
'title',
|
||||
'children' => [
|
||||
'id',
|
||||
'title',
|
||||
'panelIcon',
|
||||
'hasChildren'
|
||||
],
|
||||
]
|
||||
]
|
||||
];
|
||||
|
|
|
@ -6,12 +6,12 @@ use Kirby\Cms\SiteBlueprint;
|
|||
* SiteBlueprint
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'name' => fn (SiteBlueprint $blueprint) => $blueprint->name(),
|
||||
'options' => fn (SiteBlueprint $blueprint) => $blueprint->options(),
|
||||
'tabs' => fn (SiteBlueprint $blueprint) => $blueprint->tabs(),
|
||||
'title' => fn (SiteBlueprint $blueprint) => $blueprint->title(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\SiteBlueprint',
|
||||
'views' => [],
|
||||
'fields' => [
|
||||
'name' => fn (SiteBlueprint $blueprint) => $blueprint->name(),
|
||||
'options' => fn (SiteBlueprint $blueprint) => $blueprint->options(),
|
||||
'tabs' => fn (SiteBlueprint $blueprint) => $blueprint->tabs(),
|
||||
'title' => fn (SiteBlueprint $blueprint) => $blueprint->title(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\SiteBlueprint',
|
||||
'views' => [],
|
||||
];
|
||||
|
|
|
@ -7,92 +7,92 @@ use Kirby\Toolkit\Str;
|
|||
* System
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'ascii' => fn () => Str::$ascii,
|
||||
'authStatus' => fn () => $this->kirby()->auth()->status()->toArray(),
|
||||
'defaultLanguage' => fn () => $this->kirby()->panelLanguage(),
|
||||
'isOk' => fn (System $system) => $system->isOk(),
|
||||
'isInstallable' => fn (System $system) => $system->isInstallable(),
|
||||
'isInstalled' => fn (System $system) => $system->isInstalled(),
|
||||
'isLocal' => fn (System $system) => $system->isLocal(),
|
||||
'multilang' => fn () => $this->kirby()->option('languages', false) !== false,
|
||||
'languages' => fn () => $this->kirby()->languages(),
|
||||
'license' => fn (System $system) => $system->license(),
|
||||
'locales' => function () {
|
||||
$locales = [];
|
||||
$translations = $this->kirby()->translations();
|
||||
foreach ($translations as $translation) {
|
||||
$locales[$translation->code()] = $translation->locale();
|
||||
}
|
||||
return $locales;
|
||||
},
|
||||
'loginMethods' => fn (System $system) => array_keys($system->loginMethods()),
|
||||
'requirements' => fn (System $system) => $system->toArray(),
|
||||
'site' => fn (System $system) => $system->title(),
|
||||
'slugs' => fn () => Str::$language,
|
||||
'title' => fn () => $this->site()->title()->value(),
|
||||
'translation' => function () {
|
||||
if ($user = $this->user()) {
|
||||
$translationCode = $user->language();
|
||||
} else {
|
||||
$translationCode = $this->kirby()->panelLanguage();
|
||||
}
|
||||
'fields' => [
|
||||
'ascii' => fn () => Str::$ascii,
|
||||
'authStatus' => fn () => $this->kirby()->auth()->status()->toArray(),
|
||||
'defaultLanguage' => fn () => $this->kirby()->panelLanguage(),
|
||||
'isOk' => fn (System $system) => $system->isOk(),
|
||||
'isInstallable' => fn (System $system) => $system->isInstallable(),
|
||||
'isInstalled' => fn (System $system) => $system->isInstalled(),
|
||||
'isLocal' => fn (System $system) => $system->isLocal(),
|
||||
'multilang' => fn () => $this->kirby()->option('languages', false) !== false,
|
||||
'languages' => fn () => $this->kirby()->languages(),
|
||||
'license' => fn (System $system) => $system->license(),
|
||||
'locales' => function () {
|
||||
$locales = [];
|
||||
$translations = $this->kirby()->translations();
|
||||
foreach ($translations as $translation) {
|
||||
$locales[$translation->code()] = $translation->locale();
|
||||
}
|
||||
return $locales;
|
||||
},
|
||||
'loginMethods' => fn (System $system) => array_keys($system->loginMethods()),
|
||||
'requirements' => fn (System $system) => $system->toArray(),
|
||||
'site' => fn (System $system) => $system->title(),
|
||||
'slugs' => fn () => Str::$language,
|
||||
'title' => fn () => $this->site()->title()->value(),
|
||||
'translation' => function () {
|
||||
if ($user = $this->user()) {
|
||||
$translationCode = $user->language();
|
||||
} else {
|
||||
$translationCode = $this->kirby()->panelLanguage();
|
||||
}
|
||||
|
||||
if ($translation = $this->kirby()->translation($translationCode)) {
|
||||
return $translation;
|
||||
} else {
|
||||
return $this->kirby()->translation('en');
|
||||
}
|
||||
},
|
||||
'kirbytext' => fn () => $this->kirby()->option('panel.kirbytext') ?? true,
|
||||
'user' => fn () => $this->user(),
|
||||
'version' => function () {
|
||||
$user = $this->user();
|
||||
if ($translation = $this->kirby()->translation($translationCode)) {
|
||||
return $translation;
|
||||
} else {
|
||||
return $this->kirby()->translation('en');
|
||||
}
|
||||
},
|
||||
'kirbytext' => fn () => $this->kirby()->option('panel.kirbytext') ?? true,
|
||||
'user' => fn () => $this->user(),
|
||||
'version' => function () {
|
||||
$user = $this->user();
|
||||
|
||||
if ($user && $user->role()->permissions()->for('access', 'system') === true) {
|
||||
return $this->kirby()->version();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
],
|
||||
'type' => 'Kirby\Cms\System',
|
||||
'views' => [
|
||||
'login' => [
|
||||
'authStatus',
|
||||
'isOk',
|
||||
'isInstallable',
|
||||
'isInstalled',
|
||||
'loginMethods',
|
||||
'title',
|
||||
'translation'
|
||||
],
|
||||
'troubleshooting' => [
|
||||
'isOk',
|
||||
'isInstallable',
|
||||
'isInstalled',
|
||||
'title',
|
||||
'translation',
|
||||
'requirements'
|
||||
],
|
||||
'panel' => [
|
||||
'ascii',
|
||||
'defaultLanguage',
|
||||
'isOk',
|
||||
'isInstalled',
|
||||
'isLocal',
|
||||
'kirbytext',
|
||||
'languages',
|
||||
'license',
|
||||
'locales',
|
||||
'multilang',
|
||||
'requirements',
|
||||
'site',
|
||||
'slugs',
|
||||
'title',
|
||||
'translation',
|
||||
'user' => 'auth',
|
||||
'version'
|
||||
]
|
||||
],
|
||||
if ($user && $user->role()->permissions()->for('access', 'system') === true) {
|
||||
return $this->kirby()->version();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
],
|
||||
'type' => 'Kirby\Cms\System',
|
||||
'views' => [
|
||||
'login' => [
|
||||
'authStatus',
|
||||
'isOk',
|
||||
'isInstallable',
|
||||
'isInstalled',
|
||||
'loginMethods',
|
||||
'title',
|
||||
'translation'
|
||||
],
|
||||
'troubleshooting' => [
|
||||
'isOk',
|
||||
'isInstallable',
|
||||
'isInstalled',
|
||||
'title',
|
||||
'translation',
|
||||
'requirements'
|
||||
],
|
||||
'panel' => [
|
||||
'ascii',
|
||||
'defaultLanguage',
|
||||
'isOk',
|
||||
'isInstalled',
|
||||
'isLocal',
|
||||
'kirbytext',
|
||||
'languages',
|
||||
'license',
|
||||
'locales',
|
||||
'multilang',
|
||||
'requirements',
|
||||
'site',
|
||||
'slugs',
|
||||
'title',
|
||||
'translation',
|
||||
'user' => 'auth',
|
||||
'version'
|
||||
]
|
||||
],
|
||||
];
|
||||
|
|
|
@ -6,19 +6,19 @@ use Kirby\Cms\Translation;
|
|||
* Translation
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'author' => fn (Translation $translation) => $translation->author(),
|
||||
'data' => fn (Translation $translation) => $translation->dataWithFallback(),
|
||||
'direction' => fn (Translation $translation) => $translation->direction(),
|
||||
'id' => fn (Translation $translation) => $translation->id(),
|
||||
'name' => fn (Translation $translation) => $translation->name(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\Translation',
|
||||
'views' => [
|
||||
'compact' => [
|
||||
'direction',
|
||||
'id',
|
||||
'name'
|
||||
]
|
||||
]
|
||||
'fields' => [
|
||||
'author' => fn (Translation $translation) => $translation->author(),
|
||||
'data' => fn (Translation $translation) => $translation->dataWithFallback(),
|
||||
'direction' => fn (Translation $translation) => $translation->direction(),
|
||||
'id' => fn (Translation $translation) => $translation->id(),
|
||||
'name' => fn (Translation $translation) => $translation->name(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\Translation',
|
||||
'views' => [
|
||||
'compact' => [
|
||||
'direction',
|
||||
'id',
|
||||
'name'
|
||||
]
|
||||
]
|
||||
];
|
||||
|
|
|
@ -7,71 +7,71 @@ use Kirby\Form\Form;
|
|||
* User
|
||||
*/
|
||||
return [
|
||||
'default' => fn () => $this->user(),
|
||||
'fields' => [
|
||||
'avatar' => fn (User $user) => $user->avatar() ? $user->avatar()->crop(512) : null,
|
||||
'blueprint' => fn (User $user) => $user->blueprint(),
|
||||
'content' => fn (User $user) => Form::for($user)->values(),
|
||||
'email' => fn (User $user) => $user->email(),
|
||||
'files' => fn (User $user) => $user->files()->sorted(),
|
||||
'id' => fn (User $user) => $user->id(),
|
||||
'language' => fn (User $user) => $user->language(),
|
||||
'name' => fn (User $user) => $user->name()->value(),
|
||||
'next' => fn (User $user) => $user->next(),
|
||||
'options' => fn (User $user) => $user->panel()->options(),
|
||||
'panelImage' => fn (User $user) => $user->panel()->image(),
|
||||
'permissions' => fn (User $user) => $user->role()->permissions()->toArray(),
|
||||
'prev' => fn (User $user) => $user->prev(),
|
||||
'role' => fn (User $user) => $user->role(),
|
||||
'roles' => fn (User $user) => $user->roles(),
|
||||
'username' => fn (User $user) => $user->username()
|
||||
],
|
||||
'type' => 'Kirby\Cms\User',
|
||||
'views' => [
|
||||
'default' => [
|
||||
'avatar',
|
||||
'content',
|
||||
'email',
|
||||
'id',
|
||||
'language',
|
||||
'name',
|
||||
'next' => 'compact',
|
||||
'options',
|
||||
'prev' => 'compact',
|
||||
'role',
|
||||
'username'
|
||||
],
|
||||
'compact' => [
|
||||
'avatar' => 'compact',
|
||||
'id',
|
||||
'email',
|
||||
'language',
|
||||
'name',
|
||||
'role' => 'compact',
|
||||
'username'
|
||||
],
|
||||
'auth' => [
|
||||
'avatar' => 'compact',
|
||||
'permissions',
|
||||
'email',
|
||||
'id',
|
||||
'name',
|
||||
'role',
|
||||
'language'
|
||||
],
|
||||
'panel' => [
|
||||
'avatar' => 'compact',
|
||||
'blueprint',
|
||||
'content',
|
||||
'email',
|
||||
'id',
|
||||
'language',
|
||||
'name',
|
||||
'next' => ['id', 'name'],
|
||||
'options',
|
||||
'prev' => ['id', 'name'],
|
||||
'role',
|
||||
'username',
|
||||
],
|
||||
]
|
||||
'default' => fn () => $this->user(),
|
||||
'fields' => [
|
||||
'avatar' => fn (User $user) => $user->avatar() ? $user->avatar()->crop(512) : null,
|
||||
'blueprint' => fn (User $user) => $user->blueprint(),
|
||||
'content' => fn (User $user) => Form::for($user)->values(),
|
||||
'email' => fn (User $user) => $user->email(),
|
||||
'files' => fn (User $user) => $user->files()->sorted(),
|
||||
'id' => fn (User $user) => $user->id(),
|
||||
'language' => fn (User $user) => $user->language(),
|
||||
'name' => fn (User $user) => $user->name()->value(),
|
||||
'next' => fn (User $user) => $user->next(),
|
||||
'options' => fn (User $user) => $user->panel()->options(),
|
||||
'panelImage' => fn (User $user) => $user->panel()->image(),
|
||||
'permissions' => fn (User $user) => $user->role()->permissions()->toArray(),
|
||||
'prev' => fn (User $user) => $user->prev(),
|
||||
'role' => fn (User $user) => $user->role(),
|
||||
'roles' => fn (User $user) => $user->roles(),
|
||||
'username' => fn (User $user) => $user->username()
|
||||
],
|
||||
'type' => 'Kirby\Cms\User',
|
||||
'views' => [
|
||||
'default' => [
|
||||
'avatar',
|
||||
'content',
|
||||
'email',
|
||||
'id',
|
||||
'language',
|
||||
'name',
|
||||
'next' => 'compact',
|
||||
'options',
|
||||
'prev' => 'compact',
|
||||
'role',
|
||||
'username'
|
||||
],
|
||||
'compact' => [
|
||||
'avatar' => 'compact',
|
||||
'id',
|
||||
'email',
|
||||
'language',
|
||||
'name',
|
||||
'role' => 'compact',
|
||||
'username'
|
||||
],
|
||||
'auth' => [
|
||||
'avatar' => 'compact',
|
||||
'permissions',
|
||||
'email',
|
||||
'id',
|
||||
'name',
|
||||
'role',
|
||||
'language'
|
||||
],
|
||||
'panel' => [
|
||||
'avatar' => 'compact',
|
||||
'blueprint',
|
||||
'content',
|
||||
'email',
|
||||
'id',
|
||||
'language',
|
||||
'name',
|
||||
'next' => ['id', 'name'],
|
||||
'options',
|
||||
'prev' => ['id', 'name'],
|
||||
'role',
|
||||
'username',
|
||||
],
|
||||
]
|
||||
];
|
||||
|
|
|
@ -6,13 +6,13 @@ use Kirby\Cms\UserBlueprint;
|
|||
* UserBlueprint
|
||||
*/
|
||||
return [
|
||||
'fields' => [
|
||||
'name' => fn (UserBlueprint $blueprint) => $blueprint->name(),
|
||||
'options' => fn (UserBlueprint $blueprint) => $blueprint->options(),
|
||||
'tabs' => fn (UserBlueprint $blueprint) => $blueprint->tabs(),
|
||||
'title' => fn (UserBlueprint $blueprint) => $blueprint->title(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\UserBlueprint',
|
||||
'views' => [
|
||||
],
|
||||
'fields' => [
|
||||
'name' => fn (UserBlueprint $blueprint) => $blueprint->name(),
|
||||
'options' => fn (UserBlueprint $blueprint) => $blueprint->options(),
|
||||
'tabs' => fn (UserBlueprint $blueprint) => $blueprint->tabs(),
|
||||
'title' => fn (UserBlueprint $blueprint) => $blueprint->title(),
|
||||
],
|
||||
'type' => 'Kirby\Cms\UserBlueprint',
|
||||
'views' => [
|
||||
],
|
||||
];
|
||||
|
|
|
@ -4,23 +4,23 @@
|
|||
* Api Routes Definitions
|
||||
*/
|
||||
return function ($kirby) {
|
||||
$routes = array_merge(
|
||||
include __DIR__ . '/routes/auth.php',
|
||||
include __DIR__ . '/routes/pages.php',
|
||||
include __DIR__ . '/routes/roles.php',
|
||||
include __DIR__ . '/routes/site.php',
|
||||
include __DIR__ . '/routes/users.php',
|
||||
include __DIR__ . '/routes/files.php',
|
||||
include __DIR__ . '/routes/lock.php',
|
||||
include __DIR__ . '/routes/system.php',
|
||||
include __DIR__ . '/routes/translations.php'
|
||||
);
|
||||
$routes = array_merge(
|
||||
include __DIR__ . '/routes/auth.php',
|
||||
include __DIR__ . '/routes/pages.php',
|
||||
include __DIR__ . '/routes/roles.php',
|
||||
include __DIR__ . '/routes/site.php',
|
||||
include __DIR__ . '/routes/users.php',
|
||||
include __DIR__ . '/routes/files.php',
|
||||
include __DIR__ . '/routes/lock.php',
|
||||
include __DIR__ . '/routes/system.php',
|
||||
include __DIR__ . '/routes/translations.php'
|
||||
);
|
||||
|
||||
// only add the language routes if the
|
||||
// multi language setup is activated
|
||||
if ($kirby->option('languages', false) !== false) {
|
||||
$routes = array_merge($routes, include __DIR__ . '/routes/languages.php');
|
||||
}
|
||||
// only add the language routes if the
|
||||
// multi language setup is activated
|
||||
if ($kirby->option('languages', false) !== false) {
|
||||
$routes = array_merge($routes, include __DIR__ . '/routes/languages.php');
|
||||
}
|
||||
|
||||
return $routes;
|
||||
return $routes;
|
||||
};
|
||||
|
|
|
@ -7,102 +7,102 @@ use Kirby\Exception\NotFoundException;
|
|||
* Authentication
|
||||
*/
|
||||
return [
|
||||
[
|
||||
'pattern' => 'auth',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
if ($user = $this->kirby()->auth()->user()) {
|
||||
return $this->resolve($user)->view('auth');
|
||||
}
|
||||
[
|
||||
'pattern' => 'auth',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
if ($user = $this->kirby()->auth()->user()) {
|
||||
return $this->resolve($user)->view('auth');
|
||||
}
|
||||
|
||||
throw new NotFoundException('The user cannot be found');
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'auth/code',
|
||||
'method' => 'POST',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
$auth = $this->kirby()->auth();
|
||||
throw new NotFoundException('The user cannot be found');
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'auth/code',
|
||||
'method' => 'POST',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
$auth = $this->kirby()->auth();
|
||||
|
||||
// csrf token check
|
||||
if ($auth->type() === 'session' && $auth->csrf() === false) {
|
||||
throw new InvalidArgumentException('Invalid CSRF token');
|
||||
}
|
||||
// csrf token check
|
||||
if ($auth->type() === 'session' && $auth->csrf() === false) {
|
||||
throw new InvalidArgumentException('Invalid CSRF token');
|
||||
}
|
||||
|
||||
$user = $auth->verifyChallenge($this->requestBody('code'));
|
||||
$user = $auth->verifyChallenge($this->requestBody('code'));
|
||||
|
||||
return [
|
||||
'code' => 200,
|
||||
'status' => 'ok',
|
||||
'user' => $this->resolve($user)->view('auth')->toArray()
|
||||
];
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'auth/login',
|
||||
'method' => 'POST',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
$auth = $this->kirby()->auth();
|
||||
$methods = $this->kirby()->system()->loginMethods();
|
||||
return [
|
||||
'code' => 200,
|
||||
'status' => 'ok',
|
||||
'user' => $this->resolve($user)->view('auth')->toArray()
|
||||
];
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'auth/login',
|
||||
'method' => 'POST',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
$auth = $this->kirby()->auth();
|
||||
$methods = $this->kirby()->system()->loginMethods();
|
||||
|
||||
// csrf token check
|
||||
if ($auth->type() === 'session' && $auth->csrf() === false) {
|
||||
throw new InvalidArgumentException('Invalid CSRF token');
|
||||
}
|
||||
// csrf token check
|
||||
if ($auth->type() === 'session' && $auth->csrf() === false) {
|
||||
throw new InvalidArgumentException('Invalid CSRF token');
|
||||
}
|
||||
|
||||
$email = $this->requestBody('email');
|
||||
$long = $this->requestBody('long');
|
||||
$password = $this->requestBody('password');
|
||||
$email = $this->requestBody('email');
|
||||
$long = $this->requestBody('long');
|
||||
$password = $this->requestBody('password');
|
||||
|
||||
if ($password) {
|
||||
if (isset($methods['password']) !== true) {
|
||||
throw new InvalidArgumentException('Login with password is not enabled');
|
||||
}
|
||||
if ($password) {
|
||||
if (isset($methods['password']) !== true) {
|
||||
throw new InvalidArgumentException('Login with password is not enabled');
|
||||
}
|
||||
|
||||
if (
|
||||
isset($methods['password']['2fa']) === true &&
|
||||
$methods['password']['2fa'] === true
|
||||
) {
|
||||
$status = $auth->login2fa($email, $password, $long);
|
||||
} else {
|
||||
$user = $auth->login($email, $password, $long);
|
||||
}
|
||||
} else {
|
||||
if (isset($methods['code']) === true) {
|
||||
$mode = 'login';
|
||||
} elseif (isset($methods['password-reset']) === true) {
|
||||
$mode = 'password-reset';
|
||||
} else {
|
||||
throw new InvalidArgumentException('Login without password is not enabled');
|
||||
}
|
||||
if (
|
||||
isset($methods['password']['2fa']) === true &&
|
||||
$methods['password']['2fa'] === true
|
||||
) {
|
||||
$status = $auth->login2fa($email, $password, $long);
|
||||
} else {
|
||||
$user = $auth->login($email, $password, $long);
|
||||
}
|
||||
} else {
|
||||
if (isset($methods['code']) === true) {
|
||||
$mode = 'login';
|
||||
} elseif (isset($methods['password-reset']) === true) {
|
||||
$mode = 'password-reset';
|
||||
} else {
|
||||
throw new InvalidArgumentException('Login without password is not enabled');
|
||||
}
|
||||
|
||||
$status = $auth->createChallenge($email, $long, $mode);
|
||||
}
|
||||
$status = $auth->createChallenge($email, $long, $mode);
|
||||
}
|
||||
|
||||
if (isset($user)) {
|
||||
return [
|
||||
'code' => 200,
|
||||
'status' => 'ok',
|
||||
'user' => $this->resolve($user)->view('auth')->toArray()
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'code' => 200,
|
||||
'status' => 'ok',
|
||||
'challenge' => $status->challenge()
|
||||
];
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'auth/logout',
|
||||
'method' => 'POST',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
$this->kirby()->auth()->logout();
|
||||
return true;
|
||||
}
|
||||
],
|
||||
if (isset($user)) {
|
||||
return [
|
||||
'code' => 200,
|
||||
'status' => 'ok',
|
||||
'user' => $this->resolve($user)->view('auth')->toArray()
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'code' => 200,
|
||||
'status' => 'ok',
|
||||
'challenge' => $status->challenge()
|
||||
];
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'auth/logout',
|
||||
'method' => 'POST',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
$this->kirby()->auth()->logout();
|
||||
return true;
|
||||
}
|
||||
],
|
||||
];
|
||||
|
|
|
@ -8,125 +8,125 @@ $pattern = '(account|pages/[^/]+|site|users/[^/]+)';
|
|||
*/
|
||||
return [
|
||||
|
||||
[
|
||||
'pattern' => $pattern . '/files/(:any)/sections/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $path, string $filename, string $sectionName) {
|
||||
if ($section = $this->file($path, $filename)->blueprint()->section($sectionName)) {
|
||||
return $section->toResponse();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files/(:any)/fields/(:any)/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $parent, string $filename, string $fieldName, string $path = null) {
|
||||
if ($file = $this->file($parent, $filename)) {
|
||||
return $this->fieldApi($file, $fieldName, $path);
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $path) {
|
||||
return $this->parent($path)->files()->sorted();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files',
|
||||
'method' => 'POST',
|
||||
'action' => function (string $path) {
|
||||
// move_uploaded_file() not working with unit test
|
||||
// @codeCoverageIgnoreStart
|
||||
return $this->upload(function ($source, $filename) use ($path) {
|
||||
return $this->parent($path)->createFile([
|
||||
'content' => [
|
||||
'sort' => $this->requestBody('sort')
|
||||
],
|
||||
'source' => $source,
|
||||
'template' => $this->requestBody('template'),
|
||||
'filename' => $filename
|
||||
]);
|
||||
});
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files/search',
|
||||
'method' => 'GET|POST',
|
||||
'action' => function (string $path) {
|
||||
$files = $this->parent($path)->files();
|
||||
[
|
||||
'pattern' => $pattern . '/files/(:any)/sections/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $path, string $filename, string $sectionName) {
|
||||
if ($section = $this->file($path, $filename)->blueprint()->section($sectionName)) {
|
||||
return $section->toResponse();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files/(:any)/fields/(:any)/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $parent, string $filename, string $fieldName, string $path = null) {
|
||||
if ($file = $this->file($parent, $filename)) {
|
||||
return $this->fieldApi($file, $fieldName, $path);
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $path) {
|
||||
return $this->parent($path)->files()->sorted();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files',
|
||||
'method' => 'POST',
|
||||
'action' => function (string $path) {
|
||||
// move_uploaded_file() not working with unit test
|
||||
// @codeCoverageIgnoreStart
|
||||
return $this->upload(function ($source, $filename) use ($path) {
|
||||
return $this->parent($path)->createFile([
|
||||
'content' => [
|
||||
'sort' => $this->requestBody('sort')
|
||||
],
|
||||
'source' => $source,
|
||||
'template' => $this->requestBody('template'),
|
||||
'filename' => $filename
|
||||
]);
|
||||
});
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files/search',
|
||||
'method' => 'GET|POST',
|
||||
'action' => function (string $path) {
|
||||
$files = $this->parent($path)->files();
|
||||
|
||||
if ($this->requestMethod() === 'GET') {
|
||||
return $files->search($this->requestQuery('q'));
|
||||
} else {
|
||||
return $files->query($this->requestBody());
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files/sort',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $path) {
|
||||
return $this->parent($path)->files()->changeSort(
|
||||
$this->requestBody('files'),
|
||||
$this->requestBody('index')
|
||||
);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $path, string $filename) {
|
||||
return $this->file($path, $filename);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files/(:any)',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $path, string $filename) {
|
||||
return $this->file($path, $filename)->update($this->requestBody(), $this->language(), true);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files/(:any)',
|
||||
'method' => 'POST',
|
||||
'action' => function (string $path, string $filename) {
|
||||
return $this->upload(function ($source) use ($path, $filename) {
|
||||
return $this->file($path, $filename)->replace($source);
|
||||
});
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files/(:any)',
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $path, string $filename) {
|
||||
return $this->file($path, $filename)->delete();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files/(:any)/name',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $path, string $filename) {
|
||||
return $this->file($path, $filename)->changeName($this->requestBody('name'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'files/search',
|
||||
'method' => 'GET|POST',
|
||||
'action' => function () {
|
||||
$files = $this
|
||||
->site()
|
||||
->index(true)
|
||||
->filter('isReadable', true)
|
||||
->files();
|
||||
if ($this->requestMethod() === 'GET') {
|
||||
return $files->search($this->requestQuery('q'));
|
||||
} else {
|
||||
return $files->query($this->requestBody());
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files/sort',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $path) {
|
||||
return $this->parent($path)->files()->changeSort(
|
||||
$this->requestBody('files'),
|
||||
$this->requestBody('index')
|
||||
);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $path, string $filename) {
|
||||
return $this->file($path, $filename);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files/(:any)',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $path, string $filename) {
|
||||
return $this->file($path, $filename)->update($this->requestBody(), $this->language(), true);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files/(:any)',
|
||||
'method' => 'POST',
|
||||
'action' => function (string $path, string $filename) {
|
||||
return $this->upload(function ($source) use ($path, $filename) {
|
||||
return $this->file($path, $filename)->replace($source);
|
||||
});
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files/(:any)',
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $path, string $filename) {
|
||||
return $this->file($path, $filename)->delete();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $pattern . '/files/(:any)/name',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $path, string $filename) {
|
||||
return $this->file($path, $filename)->changeName($this->requestBody('name'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'files/search',
|
||||
'method' => 'GET|POST',
|
||||
'action' => function () {
|
||||
$files = $this
|
||||
->site()
|
||||
->index(true)
|
||||
->filter('isReadable', true)
|
||||
->files();
|
||||
|
||||
if ($this->requestMethod() === 'GET') {
|
||||
return $files->search($this->requestQuery('q'));
|
||||
} else {
|
||||
return $files->query($this->requestBody());
|
||||
}
|
||||
}
|
||||
],
|
||||
if ($this->requestMethod() === 'GET') {
|
||||
return $files->search($this->requestQuery('q'));
|
||||
} else {
|
||||
return $files->query($this->requestBody());
|
||||
}
|
||||
}
|
||||
],
|
||||
];
|
||||
|
|
|
@ -4,43 +4,43 @@
|
|||
* Roles Routes
|
||||
*/
|
||||
return [
|
||||
[
|
||||
'pattern' => 'languages',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
return $this->kirby()->languages();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'languages',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
return $this->kirby()->languages()->create($this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'languages/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $code) {
|
||||
return $this->kirby()->languages()->find($code);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'languages/(:any)',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $code) {
|
||||
if ($language = $this->kirby()->languages()->find($code)) {
|
||||
return $language->update($this->requestBody());
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'languages/(:any)',
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $code) {
|
||||
if ($language = $this->kirby()->languages()->find($code)) {
|
||||
return $language->delete();
|
||||
}
|
||||
}
|
||||
]
|
||||
[
|
||||
'pattern' => 'languages',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
return $this->kirby()->languages();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'languages',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
return $this->kirby()->languages()->create($this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'languages/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $code) {
|
||||
return $this->kirby()->languages()->find($code);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'languages/(:any)',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $code) {
|
||||
if ($language = $this->kirby()->languages()->find($code)) {
|
||||
return $language->update($this->requestBody());
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'languages/(:any)',
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $code) {
|
||||
if ($language = $this->kirby()->languages()->find($code)) {
|
||||
return $language->delete();
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
||||
|
|
|
@ -5,87 +5,40 @@
|
|||
* Content Lock Routes
|
||||
*/
|
||||
return [
|
||||
[
|
||||
'pattern' => '(:all)/lock',
|
||||
'method' => 'GET',
|
||||
/**
|
||||
* @deprecated 3.6.0
|
||||
* @todo Remove in 3.7.0
|
||||
*/
|
||||
'action' => function (string $path) {
|
||||
deprecated('The `GET (:all)/lock` API endpoint has been deprecated and will be removed in 3.7.0');
|
||||
|
||||
if ($lock = $this->parent($path)->lock()) {
|
||||
return [
|
||||
'supported' => true,
|
||||
'locked' => $lock->get()
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'supported' => false,
|
||||
'locked' => null
|
||||
];
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => '(:all)/lock',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $path) {
|
||||
if ($lock = $this->parent($path)->lock()) {
|
||||
return $lock->create();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => '(:all)/lock',
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $path) {
|
||||
if ($lock = $this->parent($path)->lock()) {
|
||||
return $lock->remove();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => '(:all)/unlock',
|
||||
'method' => 'GET',
|
||||
/**
|
||||
* @deprecated 3.6.0
|
||||
* @todo Remove in 3.7.0
|
||||
*/
|
||||
'action' => function (string $path) {
|
||||
deprecated('The `GET (:all)/unlock` API endpoint has been deprecated and will be removed in 3.7.0');
|
||||
|
||||
|
||||
if ($lock = $this->parent($path)->lock()) {
|
||||
return [
|
||||
'supported' => true,
|
||||
'unlocked' => $lock->isUnlocked()
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'supported' => false,
|
||||
'unlocked' => null
|
||||
];
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => '(:all)/unlock',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $path) {
|
||||
if ($lock = $this->parent($path)->lock()) {
|
||||
return $lock->unlock();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => '(:all)/unlock',
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $path) {
|
||||
if ($lock = $this->parent($path)->lock()) {
|
||||
return $lock->resolve();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => '(:all)/lock',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $path) {
|
||||
if ($lock = $this->parent($path)->lock()) {
|
||||
return $lock->create();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => '(:all)/lock',
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $path) {
|
||||
if ($lock = $this->parent($path)->lock()) {
|
||||
return $lock->remove();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => '(:all)/unlock',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $path) {
|
||||
if ($lock = $this->parent($path)->lock()) {
|
||||
return $lock->unlock();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => '(:all)/unlock',
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $path) {
|
||||
if ($lock = $this->parent($path)->lock()) {
|
||||
return $lock->resolve();
|
||||
}
|
||||
}
|
||||
],
|
||||
];
|
||||
|
|
|
@ -1,132 +1,121 @@
|
|||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Page Routes
|
||||
*/
|
||||
return [
|
||||
|
||||
[
|
||||
'pattern' => 'pages/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->update($this->requestBody(), $this->language(), true);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)',
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->delete($this->requestBody('force', false));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/blueprint',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->blueprint();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'pages/(:any)/blueprints',
|
||||
/**
|
||||
* @deprecated
|
||||
* @todo remove in 3.7.0
|
||||
*/
|
||||
'pages/(:any)/children/blueprints',
|
||||
],
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
// @codeCoverageIgnoreStart
|
||||
if ($this->route->pattern() === 'pages/([a-zA-Z0-9\.\-_%= \+\@\(\)]+)/children/blueprints') {
|
||||
deprecated('`GET pages/(:any)/children/blueprints` API endpoint has been deprecated and will be removed in 3.7.0. Use `GET pages/(:any)/blueprints` instead');
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
return $this->page($id)->blueprints($this->requestQuery('section'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/children',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->pages($id, $this->requestQuery('status'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/children',
|
||||
'method' => 'POST',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->createChild($this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/children/search',
|
||||
'method' => 'GET|POST',
|
||||
'action' => function (string $id) {
|
||||
return $this->searchPages($id);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/duplicate',
|
||||
'method' => 'POST',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->duplicate($this->requestBody('slug'), [
|
||||
'children' => $this->requestBody('children'),
|
||||
'files' => $this->requestBody('files'),
|
||||
]);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/slug',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->changeSlug($this->requestBody('slug'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/status',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->changeStatus($this->requestBody('status'), $this->requestBody('position'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/template',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->changeTemplate($this->requestBody('template'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/title',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->changeTitle($this->requestBody('title'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/sections/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id, string $sectionName) {
|
||||
if ($section = $this->page($id)->blueprint()->section($sectionName)) {
|
||||
return $section->toResponse();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/fields/(:any)/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $id, string $fieldName, string $path = null) {
|
||||
if ($page = $this->page($id)) {
|
||||
return $this->fieldApi($page, $fieldName, $path);
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->update($this->requestBody(), $this->language(), true);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)',
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->delete($this->requestBody('force', false));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/blueprint',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->blueprint();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/blueprints',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->blueprints($this->requestQuery('section'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/children',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->pages($id, $this->requestQuery('status'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/children',
|
||||
'method' => 'POST',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->createChild($this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/children/search',
|
||||
'method' => 'GET|POST',
|
||||
'action' => function (string $id) {
|
||||
return $this->searchPages($id);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/duplicate',
|
||||
'method' => 'POST',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->duplicate($this->requestBody('slug'), [
|
||||
'children' => $this->requestBody('children'),
|
||||
'files' => $this->requestBody('files'),
|
||||
]);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/slug',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->changeSlug($this->requestBody('slug'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/status',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->changeStatus($this->requestBody('status'), $this->requestBody('position'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/template',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->changeTemplate($this->requestBody('template'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/title',
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->page($id)->changeTitle($this->requestBody('title'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/sections/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id, string $sectionName) {
|
||||
if ($section = $this->page($id)->blueprint()->section($sectionName)) {
|
||||
return $section->toResponse();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/fields/(:any)/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $id, string $fieldName, string $path = null) {
|
||||
if ($page = $this->page($id)) {
|
||||
return $this->fieldApi($page, $fieldName, $path);
|
||||
}
|
||||
}
|
||||
],
|
||||
];
|
||||
|
|
|
@ -4,25 +4,27 @@
|
|||
* Roles Routes
|
||||
*/
|
||||
return [
|
||||
[
|
||||
'pattern' => 'roles',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
switch (get('canBe')) {
|
||||
case 'changed':
|
||||
return $this->kirby()->roles()->canBeChanged();
|
||||
case 'created':
|
||||
return $this->kirby()->roles()->canBeCreated();
|
||||
default:
|
||||
return $this->kirby()->roles();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'roles/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $name) {
|
||||
return $this->kirby()->roles()->find($name);
|
||||
}
|
||||
]
|
||||
[
|
||||
'pattern' => 'roles',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
$kirby = $this->kirby();
|
||||
|
||||
switch ($kirby->request()->get('canBe')) {
|
||||
case 'changed':
|
||||
return $kirby->roles()->canBeChanged();
|
||||
case 'created':
|
||||
return $kirby->roles()->canBeCreated();
|
||||
default:
|
||||
return $kirby->roles();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'roles/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $name) {
|
||||
return $this->kirby()->roles()->find($name);
|
||||
}
|
||||
]
|
||||
];
|
||||
|
|
|
@ -1,115 +1,104 @@
|
|||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Site Routes
|
||||
*/
|
||||
return [
|
||||
|
||||
[
|
||||
'pattern' => 'site',
|
||||
'action' => function () {
|
||||
return $this->site();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site',
|
||||
'method' => 'PATCH',
|
||||
'action' => function () {
|
||||
return $this->site()->update($this->requestBody(), $this->language(), true);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/children',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
return $this->pages(null, $this->requestQuery('status'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/children',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
return $this->site()->createChild($this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/children/search',
|
||||
'method' => 'GET|POST',
|
||||
'action' => function () {
|
||||
return $this->searchPages();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/blueprint',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
return $this->site()->blueprint();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'site/blueprints',
|
||||
/**
|
||||
* @deprecated
|
||||
* @todo remove in 3.7.0
|
||||
*/
|
||||
'site/children/blueprints',
|
||||
],
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
// @codeCoverageIgnoreStart
|
||||
if ($this->route->pattern() === 'site/children/blueprints') {
|
||||
deprecated('`GET site/children/blueprints` API endpoint has been deprecated and will be removed in 3.7.0. Use `GET site/blueprints` instead.');
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
return $this->site()->blueprints($this->requestQuery('section'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/find',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
return $this->site()->find(false, ...$this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/title',
|
||||
'method' => 'PATCH',
|
||||
'action' => function () {
|
||||
return $this->site()->changeTitle($this->requestBody('title'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/search',
|
||||
'method' => 'GET|POST',
|
||||
'action' => function () {
|
||||
$pages = $this
|
||||
->site()
|
||||
->index(true)
|
||||
->filter('isReadable', true);
|
||||
[
|
||||
'pattern' => 'site',
|
||||
'action' => function () {
|
||||
return $this->site();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site',
|
||||
'method' => 'PATCH',
|
||||
'action' => function () {
|
||||
return $this->site()->update($this->requestBody(), $this->language(), true);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/children',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
return $this->pages(null, $this->requestQuery('status'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/children',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
return $this->site()->createChild($this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/children/search',
|
||||
'method' => 'GET|POST',
|
||||
'action' => function () {
|
||||
return $this->searchPages();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/blueprint',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
return $this->site()->blueprint();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/blueprints',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
return $this->site()->blueprints($this->requestQuery('section'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/find',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
return $this->site()->find(false, ...$this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/title',
|
||||
'method' => 'PATCH',
|
||||
'action' => function () {
|
||||
return $this->site()->changeTitle($this->requestBody('title'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/search',
|
||||
'method' => 'GET|POST',
|
||||
'action' => function () {
|
||||
$pages = $this
|
||||
->site()
|
||||
->index(true)
|
||||
->filter('isReadable', true);
|
||||
|
||||
if ($this->requestMethod() === 'GET') {
|
||||
return $pages->search($this->requestQuery('q'));
|
||||
} else {
|
||||
return $pages->query($this->requestBody());
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/sections/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $sectionName) {
|
||||
if ($section = $this->site()->blueprint()->section($sectionName)) {
|
||||
return $section->toResponse();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/fields/(:any)/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $fieldName, string $path = null) {
|
||||
return $this->fieldApi($this->site(), $fieldName, $path);
|
||||
}
|
||||
]
|
||||
if ($this->requestMethod() === 'GET') {
|
||||
return $pages->search($this->requestQuery('q'));
|
||||
} else {
|
||||
return $pages->query($this->requestBody());
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/sections/(:any)',
|
||||
'method' => 'GET',
|
||||
'action' => function (string $sectionName) {
|
||||
if ($section = $this->site()->blueprint()->section($sectionName)) {
|
||||
return $section->toResponse();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/fields/(:any)/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $fieldName, string $path = null) {
|
||||
return $this->fieldApi($this->site(), $fieldName, $path);
|
||||
}
|
||||
]
|
||||
|
||||
];
|
||||
|
|
|
@ -8,72 +8,72 @@ use Kirby\Exception\InvalidArgumentException;
|
|||
*/
|
||||
return [
|
||||
|
||||
[
|
||||
'pattern' => 'system',
|
||||
'method' => 'GET',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
$system = $this->kirby()->system();
|
||||
[
|
||||
'pattern' => 'system',
|
||||
'method' => 'GET',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
$system = $this->kirby()->system();
|
||||
|
||||
if ($this->kirby()->user()) {
|
||||
return $system;
|
||||
} else {
|
||||
if ($system->isOk() === true) {
|
||||
$info = $this->resolve($system)->view('login')->toArray();
|
||||
} else {
|
||||
$info = $this->resolve($system)->view('troubleshooting')->toArray();
|
||||
}
|
||||
if ($this->kirby()->user()) {
|
||||
return $system;
|
||||
} else {
|
||||
if ($system->isOk() === true) {
|
||||
$info = $this->resolve($system)->view('login')->toArray();
|
||||
} else {
|
||||
$info = $this->resolve($system)->view('troubleshooting')->toArray();
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'data' => $info,
|
||||
'type' => 'model'
|
||||
];
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'system/register',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
return $this->kirby()->system()->register($this->requestBody('license'), $this->requestBody('email'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'system/install',
|
||||
'method' => 'POST',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
$system = $this->kirby()->system();
|
||||
$auth = $this->kirby()->auth();
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'data' => $info,
|
||||
'type' => 'model'
|
||||
];
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'system/register',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
return $this->kirby()->system()->register($this->requestBody('license'), $this->requestBody('email'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'system/install',
|
||||
'method' => 'POST',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
$system = $this->kirby()->system();
|
||||
$auth = $this->kirby()->auth();
|
||||
|
||||
// csrf token check
|
||||
if ($auth->type() === 'session' && $auth->csrf() === false) {
|
||||
throw new InvalidArgumentException('Invalid CSRF token');
|
||||
}
|
||||
// csrf token check
|
||||
if ($auth->type() === 'session' && $auth->csrf() === false) {
|
||||
throw new InvalidArgumentException('Invalid CSRF token');
|
||||
}
|
||||
|
||||
if ($system->isOk() === false) {
|
||||
throw new Exception('The server is not setup correctly');
|
||||
}
|
||||
if ($system->isOk() === false) {
|
||||
throw new Exception('The server is not setup correctly');
|
||||
}
|
||||
|
||||
if ($system->isInstallable() === false) {
|
||||
throw new Exception('The Panel cannot be installed');
|
||||
}
|
||||
if ($system->isInstallable() === false) {
|
||||
throw new Exception('The Panel cannot be installed');
|
||||
}
|
||||
|
||||
if ($system->isInstalled() === true) {
|
||||
throw new Exception('The Panel is already installed');
|
||||
}
|
||||
if ($system->isInstalled() === true) {
|
||||
throw new Exception('The Panel is already installed');
|
||||
}
|
||||
|
||||
// create the first user
|
||||
$user = $this->users()->create($this->requestBody());
|
||||
$token = $user->login($this->requestBody('password'));
|
||||
// create the first user
|
||||
$user = $this->users()->create($this->requestBody());
|
||||
$token = $user->login($this->requestBody('password'));
|
||||
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'token' => $token,
|
||||
'user' => $this->resolve($user)->view('auth')->toArray()
|
||||
];
|
||||
}
|
||||
]
|
||||
return [
|
||||
'status' => 'ok',
|
||||
'token' => $token,
|
||||
'user' => $this->resolve($user)->view('auth')->toArray()
|
||||
];
|
||||
}
|
||||
]
|
||||
|
||||
];
|
||||
|
|
|
@ -4,21 +4,21 @@
|
|||
* Translations Routes
|
||||
*/
|
||||
return [
|
||||
[
|
||||
'pattern' => 'translations',
|
||||
'method' => 'GET',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
return $this->kirby()->translations();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'translations/(:any)',
|
||||
'method' => 'GET',
|
||||
'auth' => false,
|
||||
'action' => function (string $code) {
|
||||
return $this->kirby()->translations()->find($code);
|
||||
}
|
||||
]
|
||||
[
|
||||
'pattern' => 'translations',
|
||||
'method' => 'GET',
|
||||
'auth' => false,
|
||||
'action' => function () {
|
||||
return $this->kirby()->translations();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'translations/(:any)',
|
||||
'method' => 'GET',
|
||||
'auth' => false,
|
||||
'action' => function (string $code) {
|
||||
return $this->kirby()->translations()->find($code);
|
||||
}
|
||||
]
|
||||
|
||||
];
|
||||
|
|
|
@ -6,202 +6,202 @@ use Kirby\Filesystem\F;
|
|||
* User Routes
|
||||
*/
|
||||
return [
|
||||
[
|
||||
'pattern' => 'users',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
return $this->users()->sort('username', 'asc', 'email', 'asc');
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'users',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
return $this->users()->create($this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'users/search',
|
||||
'method' => 'GET|POST',
|
||||
'action' => function () {
|
||||
if ($this->requestMethod() === 'GET') {
|
||||
return $this->users()->search($this->requestQuery('q'));
|
||||
} else {
|
||||
return $this->users()->query($this->requestBody());
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)',
|
||||
'users/(:any)',
|
||||
],
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)',
|
||||
'users/(:any)',
|
||||
],
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->update($this->requestBody(), $this->language(), true);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)',
|
||||
'users/(:any)',
|
||||
],
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->delete();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/avatar',
|
||||
'users/(:any)/avatar',
|
||||
],
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->avatar();
|
||||
}
|
||||
],
|
||||
// @codeCoverageIgnoreStart
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/avatar',
|
||||
'users/(:any)/avatar',
|
||||
],
|
||||
'method' => 'POST',
|
||||
'action' => function (string $id) {
|
||||
if ($avatar = $this->user($id)->avatar()) {
|
||||
$avatar->delete();
|
||||
}
|
||||
[
|
||||
'pattern' => 'users',
|
||||
'method' => 'GET',
|
||||
'action' => function () {
|
||||
return $this->users()->sort('username', 'asc', 'email', 'asc');
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'users',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
return $this->users()->create($this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'users/search',
|
||||
'method' => 'GET|POST',
|
||||
'action' => function () {
|
||||
if ($this->requestMethod() === 'GET') {
|
||||
return $this->users()->search($this->requestQuery('q'));
|
||||
} else {
|
||||
return $this->users()->query($this->requestBody());
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)',
|
||||
'users/(:any)',
|
||||
],
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)',
|
||||
'users/(:any)',
|
||||
],
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->update($this->requestBody(), $this->language(), true);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)',
|
||||
'users/(:any)',
|
||||
],
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->delete();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/avatar',
|
||||
'users/(:any)/avatar',
|
||||
],
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->avatar();
|
||||
}
|
||||
],
|
||||
// @codeCoverageIgnoreStart
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/avatar',
|
||||
'users/(:any)/avatar',
|
||||
],
|
||||
'method' => 'POST',
|
||||
'action' => function (string $id) {
|
||||
if ($avatar = $this->user($id)->avatar()) {
|
||||
$avatar->delete();
|
||||
}
|
||||
|
||||
return $this->upload(function ($source, $filename) use ($id) {
|
||||
return $this->user($id)->createFile([
|
||||
'filename' => 'profile.' . F::extension($filename),
|
||||
'template' => 'avatar',
|
||||
'source' => $source
|
||||
]);
|
||||
}, $single = true);
|
||||
}
|
||||
],
|
||||
// @codeCoverageIgnoreEnd
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/avatar',
|
||||
'users/(:any)/avatar',
|
||||
],
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->avatar()->delete();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/blueprint',
|
||||
'users/(:any)/blueprint',
|
||||
],
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->blueprint();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/blueprints',
|
||||
'users/(:any)/blueprints',
|
||||
],
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->blueprints($this->requestQuery('section'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/email',
|
||||
'users/(:any)/email',
|
||||
],
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->changeEmail($this->requestBody('email'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/language',
|
||||
'users/(:any)/language',
|
||||
],
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->changeLanguage($this->requestBody('language'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/name',
|
||||
'users/(:any)/name',
|
||||
],
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->changeName($this->requestBody('name'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/password',
|
||||
'users/(:any)/password',
|
||||
],
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->changePassword($this->requestBody('password'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/role',
|
||||
'users/(:any)/role',
|
||||
],
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->changeRole($this->requestBody('role'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/roles',
|
||||
'users/(:any)/roles',
|
||||
],
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->roles();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/sections/(:any)',
|
||||
'users/(:any)/sections/(:any)',
|
||||
],
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id, string $sectionName) {
|
||||
if ($section = $this->user($id)->blueprint()->section($sectionName)) {
|
||||
return $section->toResponse();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/fields/(:any)/(:all?)',
|
||||
'users/(:any)/fields/(:any)/(:all?)',
|
||||
],
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $id, string $fieldName, string $path = null) {
|
||||
return $this->fieldApi($this->user($id), $fieldName, $path);
|
||||
}
|
||||
],
|
||||
return $this->upload(function ($source, $filename) use ($id) {
|
||||
return $this->user($id)->createFile([
|
||||
'filename' => 'profile.' . F::extension($filename),
|
||||
'template' => 'avatar',
|
||||
'source' => $source
|
||||
]);
|
||||
}, $single = true);
|
||||
}
|
||||
],
|
||||
// @codeCoverageIgnoreEnd
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/avatar',
|
||||
'users/(:any)/avatar',
|
||||
],
|
||||
'method' => 'DELETE',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->avatar()->delete();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/blueprint',
|
||||
'users/(:any)/blueprint',
|
||||
],
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->blueprint();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/blueprints',
|
||||
'users/(:any)/blueprints',
|
||||
],
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->blueprints($this->requestQuery('section'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/email',
|
||||
'users/(:any)/email',
|
||||
],
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->changeEmail($this->requestBody('email'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/language',
|
||||
'users/(:any)/language',
|
||||
],
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->changeLanguage($this->requestBody('language'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/name',
|
||||
'users/(:any)/name',
|
||||
],
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->changeName($this->requestBody('name'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/password',
|
||||
'users/(:any)/password',
|
||||
],
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->changePassword($this->requestBody('password'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/role',
|
||||
'users/(:any)/role',
|
||||
],
|
||||
'method' => 'PATCH',
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->changeRole($this->requestBody('role'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/roles',
|
||||
'users/(:any)/roles',
|
||||
],
|
||||
'action' => function (string $id) {
|
||||
return $this->user($id)->roles();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/sections/(:any)',
|
||||
'users/(:any)/sections/(:any)',
|
||||
],
|
||||
'method' => 'GET',
|
||||
'action' => function (string $id, string $sectionName) {
|
||||
if ($section = $this->user($id)->blueprint()->section($sectionName)) {
|
||||
return $section->toResponse();
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/fields/(:any)/(:all?)',
|
||||
'users/(:any)/fields/(:any)/(:all?)',
|
||||
],
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $id, string $fieldName, string $path = null) {
|
||||
return $this->fieldApi($this->user($id), $fieldName, $path);
|
||||
}
|
||||
],
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue