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