Update Kirby and dependencies

This commit is contained in:
Paul Nicoué 2022-06-17 18:02:55 +02:00
parent 750b9cc83e
commit 8c71a258b6
59 changed files with 2143 additions and 813 deletions

View file

@ -16,6 +16,11 @@ use Throwable;
*/
class File extends Model
{
/**
* @var \Kirby\Cms\File
*/
protected $model;
/**
* Breadcrumb array
*
@ -423,11 +428,11 @@ class File extends Model
return [
'next' => function () use ($file, $siblings): ?array {
$next = $siblings->nth($siblings->indexOf($file) + 1);
return $next ? $next->panel()->toLink('filename') : null;
return $this->toPrevNextLink($next, 'filename');
},
'prev' => function () use ($file, $siblings): ?array {
$prev = $siblings->nth($siblings->indexOf($file) - 1);
return $prev ? $prev->panel()->toLink('filename') : null;
return $this->toPrevNextLink($prev, 'filename');
}
];
}

View file

@ -3,6 +3,7 @@
namespace Kirby\Panel;
use Kirby\Form\Form;
use Kirby\Http\Uri;
use Kirby\Toolkit\A;
/**
@ -387,6 +388,36 @@ abstract class Model
];
}
/**
* Returns link url and tooltip
* for optional sibling model and
* preserves tab selection
*
* @internal
*
* @param \Kirby\Cms\ModelWithContent|null $model
* @param string $tooltip
* @return array
*/
protected function toPrevNextLink($model = null, string $tooltip = 'title'): ?array
{
if ($model === null) {
return null;
}
$data = $model->panel()->toLink($tooltip);
if ($tab = get('tab')) {
$uri = new Uri($data['link'], [
'query' => ['tab' => $tab]
]);
$data['link'] = $uri->toString();
}
return $data;
}
/**
* Returns the url to the editing view
* in the Panel

View file

@ -14,6 +14,11 @@ namespace Kirby\Panel;
*/
class Page extends Model
{
/**
* @var \Kirby\Cms\Page
*/
protected $model;
/**
* Breadcrumb array
*
@ -309,14 +314,8 @@ class Page extends Model
};
return [
'next' => function () use ($siblings) {
$next = $siblings('next')->first();
return $next ? $next->panel()->toLink('title') : null;
},
'prev' => function () use ($siblings) {
$prev = $siblings('prev')->last();
return $prev ? $prev->panel()->toLink('title') : null;
}
'next' => fn () => $this->toPrevNextLink($siblings('next')->first()),
'prev' => fn () => $this->toPrevNextLink($siblings('prev')->last())
];
}

View file

@ -14,6 +14,11 @@ namespace Kirby\Panel;
*/
class Site extends Model
{
/**
* @var \Kirby\Cms\Site
*/
protected $model;
/**
* Returns the setup for a dropdown option
* which is used in the changes dropdown

View file

@ -14,6 +14,11 @@ namespace Kirby\Panel;
*/
class User extends Model
{
/**
* @var \Kirby\Cms\User
*/
protected $model;
/**
* Breadcrumb array
*
@ -193,14 +198,8 @@ class User extends Model
$user = $this->model;
return [
'next' => function () use ($user) {
$next = $user->next();
return $next ? $next->panel()->toLink('username') : null;
},
'prev' => function () use ($user) {
$prev = $user->prev();
return $prev ? $prev->panel()->toLink('username') : null;
}
'next' => fn () => $this->toPrevNextLink($user->next(), 'username'),
'prev' => fn () => $this->toPrevNextLink($user->prev(), 'username')
];
}