Update Composer packages
This commit is contained in:
parent
0320235f6c
commit
a8b68fb61b
378 changed files with 28466 additions and 28852 deletions
|
@ -2,6 +2,10 @@
|
|||
|
||||
namespace Kirby\Panel;
|
||||
|
||||
use Closure;
|
||||
use Kirby\Cms\File as CmsFile;
|
||||
use Kirby\Cms\ModelWithContent;
|
||||
use Kirby\Filesystem\Asset;
|
||||
use Kirby\Form\Form;
|
||||
use Kirby\Http\Uri;
|
||||
use Kirby\Toolkit\A;
|
||||
|
@ -18,23 +22,15 @@ use Kirby\Toolkit\A;
|
|||
*/
|
||||
abstract class Model
|
||||
{
|
||||
/**
|
||||
* @var \Kirby\Cms\ModelWithContent
|
||||
*/
|
||||
protected $model;
|
||||
protected ModelWithContent $model;
|
||||
|
||||
/**
|
||||
* @param \Kirby\Cms\ModelWithContent $model
|
||||
*/
|
||||
public function __construct($model)
|
||||
public function __construct(ModelWithContent $model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content values for the model
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function content(): array
|
||||
{
|
||||
|
@ -47,20 +43,14 @@ abstract class Model
|
|||
* @internal
|
||||
*
|
||||
* @param string $type markdown or kirbytext
|
||||
* @param mixed ...$args
|
||||
* @return string|null
|
||||
*/
|
||||
public function dragTextFromCallback(string $type, ...$args): ?string
|
||||
public function dragTextFromCallback(string $type, ...$args): string|null
|
||||
{
|
||||
$option = 'panel.' . $type . '.' . $this->model::CLASS_ALIAS . 'DragText';
|
||||
$callback = $this->model->kirby()->option($option);
|
||||
|
||||
if (
|
||||
empty($callback) === false &&
|
||||
is_a($callback, 'Closure') === true &&
|
||||
($dragText = $callback($this->model, ...$args)) !== null
|
||||
) {
|
||||
return $dragText;
|
||||
if ($callback instanceof Closure) {
|
||||
return $callback($this->model, ...$args);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -74,9 +64,8 @@ abstract class Model
|
|||
* @internal
|
||||
*
|
||||
* @param string|null $type (`auto`|`kirbytext`|`markdown`)
|
||||
* @return string
|
||||
*/
|
||||
public function dragTextType(string $type = null): string
|
||||
public function dragTextType(string|null $type = null): string
|
||||
{
|
||||
$type ??= 'auto';
|
||||
|
||||
|
@ -92,8 +81,6 @@ abstract class Model
|
|||
* Returns the setup for a dropdown option
|
||||
* which is used in the changes dropdown
|
||||
* for example.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function dropdownOption(): array
|
||||
{
|
||||
|
@ -106,14 +93,12 @@ abstract class Model
|
|||
|
||||
/**
|
||||
* Returns the Panel image definition
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param string|array|false|null $settings
|
||||
* @return array|null
|
||||
*/
|
||||
public function image($settings = [], string $layout = 'list'): ?array
|
||||
{
|
||||
public function image(
|
||||
string|array|false|null $settings = [],
|
||||
string $layout = 'list'
|
||||
): array|null {
|
||||
// completely switched off
|
||||
if ($settings === false) {
|
||||
return null;
|
||||
|
@ -147,20 +132,16 @@ abstract class Model
|
|||
if ($image->isResizable() === true) {
|
||||
$settings['src'] = static::imagePlaceholder();
|
||||
|
||||
switch ($layout) {
|
||||
case 'cards':
|
||||
$sizes = [352, 864, 1408];
|
||||
break;
|
||||
case 'cardlets':
|
||||
$sizes = [96, 192];
|
||||
break;
|
||||
case 'list':
|
||||
default:
|
||||
$sizes = [38, 76];
|
||||
break;
|
||||
}
|
||||
$sizes = match ($layout) {
|
||||
'cards' => [352, 864, 1408],
|
||||
'cardlets' => [96, 192],
|
||||
default => [38, 76]
|
||||
};
|
||||
|
||||
if (($settings['cover'] ?? false) === false || $layout === 'cards') {
|
||||
if (
|
||||
($settings['cover'] ?? false) === false ||
|
||||
$layout === 'cards'
|
||||
) {
|
||||
$settings['srcset'] = $image->srcset($sizes);
|
||||
} else {
|
||||
$settings['srcset'] = $image->srcset([
|
||||
|
@ -181,9 +162,7 @@ abstract class Model
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($settings['query']) === true) {
|
||||
unset($settings['query']);
|
||||
}
|
||||
unset($settings['query']);
|
||||
|
||||
// resolve remaining options defined as query
|
||||
return A::map($settings, function ($option) {
|
||||
|
@ -197,8 +176,6 @@ abstract class Model
|
|||
|
||||
/**
|
||||
* Default settings for Panel image
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function imageDefaults(): array
|
||||
{
|
||||
|
@ -213,10 +190,7 @@ abstract class Model
|
|||
|
||||
/**
|
||||
* Data URI placeholder string for Panel image
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function imagePlaceholder(): string
|
||||
{
|
||||
|
@ -225,20 +199,17 @@ abstract class Model
|
|||
|
||||
/**
|
||||
* Returns the image file object based on provided query
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param string|null $query
|
||||
* @return \Kirby\Cms\File|\Kirby\Filesystem\Asset|null
|
||||
*/
|
||||
protected function imageSource(?string $query = null)
|
||||
{
|
||||
protected function imageSource(
|
||||
string|null $query = null
|
||||
): CmsFile|Asset|null {
|
||||
$image = $this->model->query($query ?? null);
|
||||
|
||||
// validate the query result
|
||||
if (
|
||||
is_a($image, 'Kirby\Cms\File') === true ||
|
||||
is_a($image, 'Kirby\Filesystem\Asset') === true
|
||||
$image instanceof CmsFile ||
|
||||
$image instanceof Asset
|
||||
) {
|
||||
return $image;
|
||||
}
|
||||
|
@ -249,11 +220,6 @@ abstract class Model
|
|||
/**
|
||||
* Checks for disabled dropdown options according
|
||||
* to the given permissions
|
||||
*
|
||||
* @param string $action
|
||||
* @param array $options
|
||||
* @param array $permissions
|
||||
* @return bool
|
||||
*/
|
||||
public function isDisabledDropdownOption(string $action, array $options, array $permissions): bool
|
||||
{
|
||||
|
@ -267,21 +233,10 @@ abstract class Model
|
|||
* @return array|false array with lock info,
|
||||
* false if locking is not supported
|
||||
*/
|
||||
public function lock()
|
||||
public function lock(): array|false
|
||||
{
|
||||
if ($lock = $this->model->lock()) {
|
||||
if ($lock->isUnlocked() === true) {
|
||||
return ['state' => 'unlock'];
|
||||
}
|
||||
|
||||
if ($lock->isLocked() === true) {
|
||||
return [
|
||||
'state' => 'lock',
|
||||
'data' => $lock->get()
|
||||
];
|
||||
}
|
||||
|
||||
return ['state' => null];
|
||||
return $lock->toArray();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -293,7 +248,6 @@ abstract class Model
|
|||
* This also checks for the lock status
|
||||
*
|
||||
* @param array $unlock An array of options that will be force-unlocked
|
||||
* @return array
|
||||
*/
|
||||
public function options(array $unlock = []): array
|
||||
{
|
||||
|
@ -314,17 +268,12 @@ abstract class Model
|
|||
|
||||
/**
|
||||
* Returns the full path without leading slash
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract public function path(): string;
|
||||
|
||||
/**
|
||||
* Prepares the response data for page pickers
|
||||
* and page fields
|
||||
*
|
||||
* @param array|null $params
|
||||
* @return array
|
||||
*/
|
||||
public function pickerData(array $params = []): array
|
||||
{
|
||||
|
@ -338,16 +287,14 @@ abstract class Model
|
|||
'link' => $this->url(true),
|
||||
'sortable' => true,
|
||||
'text' => $this->model->toSafeString($params['text'] ?? false),
|
||||
'uuid' => $this->model->uuid()?->toString() ?? $this->model->id(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data array for the
|
||||
* view's component props
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function props(): array
|
||||
{
|
||||
|
@ -376,11 +323,7 @@ abstract class Model
|
|||
* Returns link url and tooltip
|
||||
* for model (e.g. used for prev/next
|
||||
* navigation)
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param string $tooltip
|
||||
* @return array
|
||||
*/
|
||||
public function toLink(string $tooltip = 'title'): array
|
||||
{
|
||||
|
@ -396,12 +339,8 @@ abstract class Model
|
|||
* preserves tab selection
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param \Kirby\Cms\ModelWithContent|null $model
|
||||
* @param string $tooltip
|
||||
* @return array
|
||||
*/
|
||||
protected function toPrevNextLink($model = null, string $tooltip = 'title'): ?array
|
||||
protected function toPrevNextLink(ModelWithContent|null $model = null, string $tooltip = 'title'): array|null
|
||||
{
|
||||
if ($model === null) {
|
||||
return null;
|
||||
|
@ -425,9 +364,6 @@ abstract class Model
|
|||
* in the Panel
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @param bool $relative
|
||||
* @return string
|
||||
*/
|
||||
public function url(bool $relative = false): string
|
||||
{
|
||||
|
@ -443,8 +379,6 @@ abstract class Model
|
|||
* this model's Panel view
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
abstract public function view(): array;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue