From a4667b7562ab0cdaf3c43ab436c92eba760cffdb Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Fri, 5 May 2023 15:45:16 +0200 Subject: [PATCH] use Html Form helper --- src/Manage.php | 88 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 27 deletions(-) diff --git a/src/Manage.php b/src/Manage.php index 72b8f0b..8246c13 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -17,10 +17,19 @@ namespace Dotclear\Plugin\noodles; use dcCore; use dcNsProcess; use dcPage; +use Dotclear\Helper\Html\Form\{ + Checkbox, + Div, + Input, + Label, + Note, + Para, + Select, + Submit, + Text +}; use Exception; -use form; - class Manage extends dcNsProcess { public static function init(): bool @@ -114,21 +123,42 @@ class Manage extends dcNsProcess ]) . dcPage::notices() . ' -
-

' . sprintf(__('Configure "%s"'), __('Noodles')) . '

-

' . __('Settings') . '

-

-

' . - form::combo('noodles_api', Combo::api(), $targets->api) . '

-

' . - form::combo('noodles_local', Combo::local(), $targets->local) . '

-

' . $note . '

-

' . sprintf(__('You can add your own default avatar by adding file "%s" in media manager.'), 'img/' . My::IMAGE) . '

-
+ +

' . sprintf(__('Configure "%s"'), __('Noodles')) . '

' . + (new Div()) + ->class('fieldset') + ->items([ + (new Text('h4', __('Settings'))), + (new Para()) + ->items([ + (new Checkbox('noodles_active', $targets->active)) + ->value(1), + (new Label(__('Enable plugin noodles on this blog'), Label::OUTSIDE_LABEL_AFTER)) + ->class('classic') + ->for('noodles_active'), + ]), + (new Para())->class('field') + ->items([ + (new Label(__('Image API:'), Label::OUTSIDE_LABEL_BEFORE)) + ->class('classic') + ->for('noodles_api'), + (new Select('noodles_api')) + ->default($targets->api) + ->items(Combo::api()), + ]), + (new Para())->class('field') + ->items([ + (new Label(__('Default image:'), Label::OUTSIDE_LABEL_BEFORE)) + ->class('classic') + ->for('noodles_local'), + (new Select('noodles_local')) + ->default((string) (int) $targets->local) + ->items(Combo::local()), + ]), + (new Note(''))->class('form-note')->text($note), + (new Note(''))->class('form-note')->text(sprintf(__('You can add your own default avatar by adding file "%s" in media manager.'), 'img/' . My::IMAGE)), + ]) + ->render() . '

' . __('Behaviors') . '

@@ -146,30 +176,34 @@ class Manage extends dcNsProcess foreach ($targets->dump() as $target) { echo ' - ' . form::checkbox(['noodle[' . $target->id . '][active]', 'ck_' . $target->id], 1, $target->active()) . ' + ' . (new Checkbox(['noodle[' . $target->id . '][active]', 'ck_' . $target->id], $target->active()))->value(1)->render() . ' - ' . form::combo(['noodle[' . $target->id . '][size]'], Combo::size(), $target->size()) . ' - ' . form::combo(['noodle[' . $target->id . '][rating]'], Combo::rating(), $target->rating()) . ' + ' . (new Select(['noodle[' . $target->id . '][size]']))->items(Combo::size())->default((string) $target->size())->render() . ' + ' . (new Select(['noodle[' . $target->id . '][rating]']))->items(Combo::rating())->default($target->rating())->render() . ' ' . ( $target->hasPhpCallback() ? 'ok' : 'nok' ) . ' ok - ' . form::field(['noodle[' . $target->id . '][target]'], 20, 255, $target->target()) . ' - ' . form::combo(['noodle[' . $target->id . '][place]'], Combo::place(), $target->place()) . ' - ' . form::field(['noodle[' . $target->id . '][css]'], 50, 255, $target->css()) . ' + ' . (new Input(['noodle[' . $target->id . '][target]']))->size(20)->maxlenght(255)->value($target->target())->render() . ' + ' . (new Select(['noodle[' . $target->id . '][place]']))->items(Combo::place())->default($target->place())->render() . ' + ' . (new Input(['noodle[' . $target->id . '][css]']))->size(20)->maxlenght(255)->value($target->css())->render() . ' .noodles-' . $target->id . '{} '; } echo '

' . __('Target and Place are for javascript.') . '

-
+ ' . -

- ' . - dcCore::app()->formNonce() . '

+ (new Para()) + ->class('clear') + ->items([ + (new Submit('save', __('Save') . ' (s)'))->accesskey('s'), + dcCore::app()->formNonce(false), + ]) + ->render() . '
'; dcPage::closeModule();