This commit is contained in:
Bastian Allgeier
2019-01-14 10:52:45 +01:00
parent 01277f79f2
commit 8070893b64
22 changed files with 482 additions and 351 deletions

View File

@@ -64,6 +64,7 @@ return [
'views' => [
'login' => [
'isOk',
'isInstallable',
'isInstalled',
'title',
'translation'

View File

@@ -53,6 +53,10 @@ return [
throw new Exception('The server is not setup correctly');
}
if ($system->isInstallable() === false) {
throw new Exception('The panel cannot be installed');
}
if ($system->isInstalled() === true) {
throw new Exception('The panel is already installed');
}

View File

@@ -87,21 +87,22 @@ function css($url, $options = null)
return implode(PHP_EOL, $links);
}
$href = $url === '@auto' ? Url::toTemplateAsset('css/templates', 'css') : Url::to($url);
$attr = [
'href' => $href,
'rel' => 'stylesheet'
];
if (is_string($options) === true) {
$attr['media'] = $options;
$options = ['media' => $options];
}
if (is_array($options) === true) {
$attr = array_merge($options, $attr);
$kirby = App::instance();
if ($component = $kirby->component('css')) {
$url = $component($kirby, $url, $options);
}
$url = $url === '@auto' ? Url::toTemplateAsset('css/templates', 'css') : Url::to($url);
$attr = array_merge((array)$options, [
'href' => $url,
'rel' => 'stylesheet'
]);
return '<link ' . attr($attr) . '>';
}
@@ -334,19 +335,19 @@ function js($url, $options = null)
return implode(PHP_EOL, $scripts);
}
$src = $url === '@auto' ? Url::toTemplateAsset('js/templates', 'js') : Url::to($url);
$attr = [
'src' => $src,
];
if (is_bool($options) === true) {
$attr['async'] = $options;
$options = ['async' => $options];
}
if (is_array($options) === true) {
$attr = array_merge($options, $attr);
$kirby = App::instance();
if ($component = $kirby->component('js')) {
$url = $component($kirby, $url, $options);
}
$url = $url === '@auto' ? Url::toTemplateAsset('js/templates', 'js') : Url::to($url);
$attr = array_merge((array)$options, ['src' => $url]);
return '<script ' . attr($attr) . '></script>';
}

View File

@@ -119,8 +119,17 @@ return function (App $app) {
*
* @return Files
*/
'toFiles' => function (Field $field) {
return $field->parent()->files()->find(false, false, ...$field->toData('yaml'));
'toFiles' => function (Field $field, string $separator = 'yaml') {
$parent = $field->parent();
$files = new Files([]);
foreach ($field->toData($separator) as $id) {
if ($file = $parent->kirby()->file($id, $parent)) {
$files->add($file);
}
}
return $files;
},
/**
@@ -226,8 +235,8 @@ return function (App $app) {
*
* @return Users
*/
'toUsers' => function (Field $field) use ($app) {
return $app->users()->find(false, false, ...$field->toData('yaml'));
'toUsers' => function (Field $field, string $separator = 'yaml') use ($app) {
return $app->users()->find(false, false, ...$field->toData($separator));
},
// inspectors