diff --git a/modules/Plugins/Controllers/PluginController.php b/modules/Plugins/Controllers/PluginController.php index c9e4edbb..788e5a78 100644 --- a/modules/Plugins/Controllers/PluginController.php +++ b/modules/Plugins/Controllers/PluginController.php @@ -125,8 +125,15 @@ class PluginController extends BaseController $data['episode'] = $episode; } + $fields = $plugin->getSettingsFields($type); + + if ($fields === []) { + throw PageNotFoundException::forPageNotFound(); + } + $data['type'] = $type; $data['context'] = $context; + $data['fields'] = $fields; helper('form'); replace_breadcrumb_params($breadcrumbReplacements); @@ -164,8 +171,8 @@ class PluginController extends BaseController $rules = []; foreach ($plugin->getSettingsFields($type) as $field) { $typeRules = $plugins::FIELDS_VALIDATIONS[$field->type]; - if (! in_array('permit_empty', $typeRules, true) && ! $field->optional) { - $typeRules[] = 'required'; + if (! in_array('permit_empty', $typeRules, true)) { + $typeRules[] = $field->optional ? 'permit_empty' : 'required'; } $rules[$field->key] = $typeRules; @@ -182,7 +189,7 @@ class PluginController extends BaseController foreach ($plugin->getSettingsFields('general') as $field) { $value = $validatedData[$field->key] ?? null; - $fieldValue = match ($plugins::FIELDS_CASTS[$field->type] ?? 'text') { + $fieldValue = $value === '' ? null : match ($plugins::FIELDS_CASTS[$field->type] ?? 'text') { 'bool' => $value === 'yes', 'int' => (int) $value, 'uri' => new URI($value), @@ -192,7 +199,7 @@ class PluginController extends BaseController $this->request->getPost('client_timezone') )->setTimezone(app_timezone()), 'markdown' => new Markdown($value), - default => $value === '' ? null : $value, + default => $value, }; $plugins->setOption($plugin, $field->key, $fieldValue, $context); } diff --git a/modules/Plugins/Core/BasePlugin.php b/modules/Plugins/Core/BasePlugin.php index b9fe8674..7eafb3ed 100644 --- a/modules/Plugins/Core/BasePlugin.php +++ b/modules/Plugins/Core/BasePlugin.php @@ -108,11 +108,6 @@ abstract class BasePlugin implements PluginInterface return in_array($name, $this->manifest->hooks, true); } - final public function getSettings(): ?Settings - { - return $this->manifest->settings; - } - final public function getVersion(): string { return $this->manifest->version; @@ -167,7 +162,7 @@ abstract class BasePlugin implements PluginInterface */ final public function getSettingsFields(string $type): array { - $settings = $this->getSettings(); + $settings = $this->manifest->settings; if (! $settings instanceof Settings) { return []; } @@ -175,6 +170,14 @@ abstract class BasePlugin implements PluginInterface return $settings->{$type}; } + /** + * @return list + */ + final public function getHooks(): array + { + return $this->manifest->hooks; + } + final public function getKey(): string { return $this->key; diff --git a/modules/Plugins/Language/en/Plugins.php b/modules/Plugins/Language/en/Plugins.php index a41c91db..b5e4dbd1 100644 --- a/modules/Plugins/Language/en/Plugins.php +++ b/modules/Plugins/Language/en/Plugins.php @@ -16,7 +16,13 @@ return [ 'authors' => 'Authors', 'author_email' => 'Email {authorName}', 'author_homepage' => '{authorName} homepage', + 'declaredHooks' => 'Declared hooks', 'settings' => 'Settings', + 'settingsTitle' => '{type, select, + podcast {{pluginName} podcast settings} + episode {{pluginName} episode settings} + other {{pluginName} general settings} + }', 'view' => 'View', 'activate' => 'Activate', 'deactivate' => 'Deactivate', @@ -29,6 +35,8 @@ return [ 'analytics' => 'Analytics', 'accessibility' => 'Accessibility', ], + 'noDescription' => 'No description', + 'noReadme' => 'No README file found.', 'messages' => [ 'saveSettingsSuccess' => '{pluginName} settings were successfully saved!', ], diff --git a/modules/Plugins/Manifest/Person.php b/modules/Plugins/Manifest/Person.php index 1a5b4289..2c2cd74c 100644 --- a/modules/Plugins/Manifest/Person.php +++ b/modules/Plugins/Manifest/Person.php @@ -46,8 +46,8 @@ class Person extends ManifestObject $data = [ 'name' => $matches['name'], - 'email' => $matches['email'], - 'url' => $matches['url'], + 'email' => $matches['email'] ?? null, + 'url' => $matches['url'] ?? null, ]; } diff --git a/themes/cp_admin/_layout.php b/themes/cp_admin/_layout.php index 9a9369cc..87a1ad8a 100644 --- a/themes/cp_admin/_layout.php +++ b/themes/cp_admin/_layout.php @@ -40,10 +40,10 @@ $isEpisodeArea = isset($podcast) && isset($episode); is_premium) || ($isPodcastArea && $podcast->is_premium)): ?>
is_premium) ? lang('PremiumPodcasts.episode_is_premium') : lang('PremiumPodcasts.podcast_is_premium') ?> - renderSection('pageTitle') ?> + renderSection('pageTitle') ?>
- renderSection('pageTitle') ?> + renderSection('pageTitle') ?> renderSection('headerLeft') ?> diff --git a/themes/cp_admin/_partials/_nav_menu.php b/themes/cp_admin/_partials/_nav_menu.php index ecf844cb..6e0f16fa 100644 --- a/themes/cp_admin/_partials/_nav_menu.php +++ b/themes/cp_admin/_partials/_nav_menu.php @@ -49,11 +49,11 @@ ?>
  • - " href=""> - +
  • diff --git a/themes/cp_admin/plugins/_plugin.php b/themes/cp_admin/plugins/_plugin.php index 1c48a318..0fd1f6c2 100644 --- a/themes/cp_admin/plugins/_plugin.php +++ b/themes/cp_admin/plugins/_plugin.php @@ -7,8 +7,8 @@ -
    -

    getName() ?>

    +
    +

    getName() ?>

    getVendor() ?> @@ -16,9 +16,9 @@ getPackage() ?> getVersion() ?>

    -

    getDescription() ?>

    +

    getDescription() ?? '' . lang('Plugins.noDescription') . '' ?>

    -