Update Kirby and dependencies
This commit is contained in:
parent
07150a0011
commit
c7c5d615a4
451 changed files with 67540 additions and 63740 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Kirby\Panel;
|
||||
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\Find;
|
||||
use Kirby\Exception\LogicException;
|
||||
use Kirby\Http\Uri;
|
||||
|
@ -22,68 +23,68 @@ use Throwable;
|
|||
*/
|
||||
class Dropdown extends Json
|
||||
{
|
||||
protected static $key = '$dropdown';
|
||||
protected static $key = '$dropdown';
|
||||
|
||||
/**
|
||||
* Returns the options for the changes dropdown
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function changes(): array
|
||||
{
|
||||
$kirby = kirby();
|
||||
$multilang = $kirby->multilang();
|
||||
$ids = Str::split(get('ids'));
|
||||
$options = [];
|
||||
/**
|
||||
* Returns the options for the changes dropdown
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function changes(): array
|
||||
{
|
||||
$kirby = App::instance();
|
||||
$multilang = $kirby->multilang();
|
||||
$ids = Str::split($kirby->request()->get('ids'));
|
||||
$options = [];
|
||||
|
||||
foreach ($ids as $id) {
|
||||
try {
|
||||
// parse the given ID to extract
|
||||
// the path and an optional query
|
||||
$uri = new Uri($id);
|
||||
$path = $uri->path()->toString();
|
||||
$query = $uri->query();
|
||||
$option = Find::parent($path)->panel()->dropdownOption();
|
||||
foreach ($ids as $id) {
|
||||
try {
|
||||
// parse the given ID to extract
|
||||
// the path and an optional query
|
||||
$uri = new Uri($id);
|
||||
$path = $uri->path()->toString();
|
||||
$query = $uri->query();
|
||||
$option = Find::parent($path)->panel()->dropdownOption();
|
||||
|
||||
// add the language to each option, if it is included in the query
|
||||
// of the given ID and the language actually exists
|
||||
if ($multilang && $query->language && $language = $kirby->language($query->language)) {
|
||||
$option['text'] .= ' (' . $language->code() . ')';
|
||||
$option['link'] .= '?language=' . $language->code();
|
||||
}
|
||||
// add the language to each option, if it is included in the query
|
||||
// of the given ID and the language actually exists
|
||||
if ($multilang && $query->language && $language = $kirby->language($query->language)) {
|
||||
$option['text'] .= ' (' . $language->code() . ')';
|
||||
$option['link'] .= '?language=' . $language->code();
|
||||
}
|
||||
|
||||
$options[] = $option;
|
||||
} catch (Throwable $e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$options[] = $option;
|
||||
} catch (Throwable $e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// the given set of ids does not match any
|
||||
// real models. This means that the stored ids
|
||||
// in local storage are not correct and the changes
|
||||
// store needs to be cleared
|
||||
if (empty($options) === true) {
|
||||
throw new LogicException('No changes for given models');
|
||||
}
|
||||
// the given set of ids does not match any
|
||||
// real models. This means that the stored ids
|
||||
// in local storage are not correct and the changes
|
||||
// store needs to be cleared
|
||||
if (empty($options) === true) {
|
||||
throw new LogicException('No changes for given models');
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders dropdowns
|
||||
*
|
||||
* @param mixed $data
|
||||
* @param array $options
|
||||
* @return \Kirby\Http\Response
|
||||
*/
|
||||
public static function response($data, array $options = [])
|
||||
{
|
||||
if (is_array($data) === true) {
|
||||
$data = [
|
||||
'options' => array_values($data)
|
||||
];
|
||||
}
|
||||
/**
|
||||
* Renders dropdowns
|
||||
*
|
||||
* @param mixed $data
|
||||
* @param array $options
|
||||
* @return \Kirby\Http\Response
|
||||
*/
|
||||
public static function response($data, array $options = [])
|
||||
{
|
||||
if (is_array($data) === true) {
|
||||
$data = [
|
||||
'options' => array_values($data)
|
||||
];
|
||||
}
|
||||
|
||||
return parent::response($data, $options);
|
||||
}
|
||||
return parent::response($data, $options);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue