use Html Form helper

This commit is contained in:
Jean-Christian Denis 2023-05-05 15:45:16 +02:00
parent 7daccacae7
commit a4667b7562
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951

View file

@ -17,10 +17,19 @@ namespace Dotclear\Plugin\noodles;
use dcCore; use dcCore;
use dcNsProcess; use dcNsProcess;
use dcPage; use dcPage;
use Dotclear\Helper\Html\Form\{
Checkbox,
Div,
Input,
Label,
Note,
Para,
Select,
Submit,
Text
};
use Exception; use Exception;
use form;
class Manage extends dcNsProcess class Manage extends dcNsProcess
{ {
public static function init(): bool public static function init(): bool
@ -114,21 +123,42 @@ class Manage extends dcNsProcess
]) . ]) .
dcPage::notices() . ' dcPage::notices() . '
<form id="module_config" action="' . <form id="module_config" action="' . dcCore::app()->adminurl->get('admin.plugin.' . My::id()) . '" method="post" enctype="multipart/form-data">
dcCore::app()->adminurl->get('admin.plugin.' . My::id()) . <h3>' . sprintf(__('Configure "%s"'), __('Noodles')) . '</h3>' .
'" method="post" enctype="multipart/form-data"> (new Div())
<h3>' . sprintf(__('Configure "%s"'), __('Noodles')) . '</h3> ->class('fieldset')
<div class="fieldset"><h4>' . __('Settings') . '</h4> ->items([
<p><label for="noodles_active">' . (new Text('h4', __('Settings'))),
form::checkbox('noodles_active', 1, $targets->active) . (new Para())
__('Enable plugin noodles on this blog') . '</label></p> ->items([
<p class="field"><label for="noodles_api" class="classic">' . __('Image API:') . ' </label>' . (new Checkbox('noodles_active', $targets->active))
form::combo('noodles_api', Combo::api(), $targets->api) . '</p> ->value(1),
<p class="field"><label for="noodles_local" class="classic">' . __('Default image:') . ' </label>' . (new Label(__('Enable plugin noodles on this blog'), Label::OUTSIDE_LABEL_AFTER))
form::combo('noodles_local', Combo::local(), $targets->local) . '</p> ->class('classic')
<p class="form-note">' . $note . '</p> ->for('noodles_active'),
<p class="form-note">' . sprintf(__('You can add your own default avatar by adding file "%s" in media manager.'), 'img/' . My::IMAGE) . '</p> ]),
</div> (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() . '
<div class="fieldset"><h4>' . __('Behaviors') . '</h4> <div class="fieldset"><h4>' . __('Behaviors') . '</h4>
<div class="table-outer"> <div class="table-outer">
@ -146,30 +176,34 @@ class Manage extends dcNsProcess
foreach ($targets->dump() as $target) { foreach ($targets->dump() as $target) {
echo ' echo '
<tr class="line"> <tr class="line">
<td>' . form::checkbox(['noodle[' . $target->id . '][active]', 'ck_' . $target->id], 1, $target->active()) . '</td> <td>' . (new Checkbox(['noodle[' . $target->id . '][active]', 'ck_' . $target->id], $target->active()))->value(1)->render() . '</td>
<td class="nowrap" scope="row"><label for="ck_' . $target->id . '">' . $target->name . '</label></td> <td class="nowrap" scope="row"><label for="ck_' . $target->id . '">' . $target->name . '</label></td>
<td>' . form::combo(['noodle[' . $target->id . '][size]'], Combo::size(), $target->size()) . '</td> <td>' . (new Select(['noodle[' . $target->id . '][size]']))->items(Combo::size())->default((string) $target->size())->render() . '</td>
<td>' . form::combo(['noodle[' . $target->id . '][rating]'], Combo::rating(), $target->rating()) . '</td> <td>' . (new Select(['noodle[' . $target->id . '][rating]']))->items(Combo::rating())->default($target->rating())->render() . '</td>
<td>' . ( <td>' . (
$target->hasPhpCallback() ? $target->hasPhpCallback() ?
'<img alt="ok" src="images/check-on.png" />' : '<img alt="ok" src="images/check-on.png" />' :
'<img alt="nok" src="images/check-off.png" />' '<img alt="nok" src="images/check-off.png" />'
) . '</td> ) . '</td>
<td><img alt="ok" src="images/check-on.png" /></td> <td><img alt="ok" src="images/check-on.png" /></td>
<td>' . form::field(['noodle[' . $target->id . '][target]'], 20, 255, $target->target()) . '</td> <td>' . (new Input(['noodle[' . $target->id . '][target]']))->size(20)->maxlenght(255)->value($target->target())->render() . '</td>
<td>' . form::combo(['noodle[' . $target->id . '][place]'], Combo::place(), $target->place()) . '</td> <td>' . (new Select(['noodle[' . $target->id . '][place]']))->items(Combo::place())->default($target->place())->render() . '</td>
<td>' . form::field(['noodle[' . $target->id . '][css]'], 50, 255, $target->css()) . '</td> <td>' . (new Input(['noodle[' . $target->id . '][css]']))->size(20)->maxlenght(255)->value($target->css())->render() . '</td>
<td> .noodles-' . $target->id . '{}</td> <td> .noodles-' . $target->id . '{}</td>
</tr>'; </tr>';
} }
echo ' echo '
</tbody></table></div> </tbody></table></div>
<p class="form-note">' . __('Target and Place are for javascript.') . '</p> <p class="form-note">' . __('Target and Place are for javascript.') . '</p>
</div> </div>' .
<p class="clear"> (new Para())
<input type="submit" value="' . __('Save') . ' (s)" accesskey="s" name="save" /> ' . ->class('clear')
dcCore::app()->formNonce() . '</p> ->items([
(new Submit('save', __('Save') . ' (s)'))->accesskey('s'),
dcCore::app()->formNonce(false),
])
->render() . '
</form>'; </form>';
dcPage::closeModule(); dcPage::closeModule();