diff --git a/src/Backend.php b/src/Backend.php index 2cefb47..374f392 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -21,8 +21,12 @@ use dcPage; use dcFavorites; use dcNsProcess; use dcSettings; - -use form; +use Dotclear\Helper\Html\Form\{ + Checkbox, + Input, + Label, + Para +}; class Backend extends dcNsProcess { @@ -73,9 +77,11 @@ class Backend extends dcNsProcess '

' . My::name() . '

' . '
' . '
' . - '

' . + // active + (new Para())->items([ + (new Checkbox('epc_active', $active))->value(1), + (new Label(__('Enable plugin'), Label::OUTSIDE_LABEL_AFTER))->for('epc_active')->class('classic'), + ])->render() . '

' . __('This enable public widgets and contents filter.') . '

' . @@ -85,11 +91,17 @@ class Backend extends dcNsProcess '
' . '
' . __('Extra') . '
' . '

' . __('This is a special feature to edit list of allowed template values and public pages where this plugin works.') . '

' . - '

' . - form::field('epc_allowedtplvalues', 100, 0, Epc::implode($allowedtplvalues)) . '

' . + // allowedtplvalues + (new Para())->items([ + (new Label(__('Allowed DC template values:'), Label::OUTSIDE_LABEL_BEFORE))->for('epc_allowedtplvalues'), + (new Input('epc_allowedtplvalues'))->size(100)->maxlenght(0)->value(Epc::implode($allowedtplvalues)), + ])->render() . '

' . __('Use "readable_name1:template_value1;readable_name2:template_value2;" like "entry content:EntryContent;entry excerpt:EntryExcerpt;".') . '

' . - '

' . - form::field('epc_allowedpubpages', 100, 0, Epc::implode($allowedpubpages)) . '

' . + // allowedpubpages + (new Para())->items([ + (new Label(__('Allowed public pages:'), Label::OUTSIDE_LABEL_BEFORE))->for('epc_allowedpubpages'), + (new Input('epc_allowedpubpages'))->size(100)->maxlenght(0)->value(Epc::implode($allowedpubpages)), + ])->render() . '

' . __('Use "readable_name1:template_page1;readable_name2:template_page2;" like "post page:post.html;home page:home.html;".') . '

' . '
' . '
' . diff --git a/src/Manage.php b/src/Manage.php index 7e1d978..765e9d0 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -19,12 +19,24 @@ use adminGenericFilterV2; use dcCore; use dcNsProcess; use dcPage; +use Dotclear\Helper\Html\Form\{ + Checkbox, + Div, + Form, + Hidden, + Input, + label, + Note, + Number, + Para, + Select, + Submit, + Text +}; use Dotclear\Helper\Html\Html; use Dotclear\Helper\Network\Http; use Exception; -use form; - class Manage extends dcNsProcess { public static function init(): bool @@ -192,109 +204,86 @@ class Manage extends dcNsProcess My::name() => '', $current->filter->name => '', ]) . - dcPage::notices() . + dcPage::notices(); # Filters select menu list - '
' . - '

' . - form::combo('part', $current->combo, $current->part) . ' ' . - '' . - form::hidden('p', My::id()) . '

' . - '
'; + echo + (new Form('filters_menu'))->method('get')->action(dcCore::app()->adminurl->get('admin.plugin.' . My::id()))->fields([ + (new Para())->class('anchor-nav')->items([ + (new Select('part'))->items($current->combo)->default($current->part), + (new Submit(['do']))->value(__('Ok')), + (new Hidden(['p'], My::id())), + ]), + ])->render(); # Filter title and description - echo ' -

' . $current->filter->name . '

-

' . $current->filter->help . '

'; + echo + '

' . $current->filter->name . '

' . + '

' . $current->filter->help . '

'; # Filter settings - echo ' -
-
- -
-

' . __('Pages to be filtered') . '

'; - + $form_pages = [(new Text('h4', __('Pages to be filtered')))]; foreach (Epc::blogAllowedPubPages() as $k => $v) { - echo ' -

'; + $form_pages[] = (new Para())->items([ + (new Checkbox(['filter_pubPages[]', 'filter_pubPages' . $v], in_array($v, $current->filter->pubPages)))->value(1), + (new Label(__($k), Label::OUTSIDE_LABEL_AFTER))->for('filter_pubPages' . $v)->class('classic'), + ]); } - echo ' -
-

' . __('Filtering') . '

- -

- -

- -

' . - form::number('filter_limit', ['min' => 0, 'max' => 99, 'default' => (int) $current->filter->limit]) . ' -

-

' . __('Leave it blank or set it to 0 for no limit') . '

- -
-

' . __('Contents to be filtered') . '

'; - + $form_values = [(new Text('h4', __('Contents to be filtered')))]; foreach (Epc::blogAllowedTplValues() as $k => $v) { - echo ' -

'; + $form_values[] = (new Para())->items([ + (new Checkbox(['filter_tplValues[]', 'filter_tplValues' . $v], in_array($v, $current->filter->tplValues)))->value(1), + (new Label(__($k), Label::OUTSIDE_LABEL_AFTER))->for('filter_tplValues' . $v)->class('classic'), + ]); } - echo ' -
-

' . __('Style') . '

'; - + $form_styles = [(new Text('h4', __('Style')))]; foreach ($current->filter->class as $k => $v) { - echo ' -

' . - form::field( - ['filter_style[]', 'filter_style' . $k], - 60, - 255, - Html::escapeHTML($current->filter->style[$k]) - ) . - '

'; + $form_styles[] = (new Para())->items([ + (new Label(sprintf(__('Class "%s":'), $v), Label::OUTSIDE_LABEL_BEFORE))->for('filter_style' . $k), + (new Input(['filter_style[]', 'filter_style' . $k]))->size(60)->maxlenght(255)->value(Html::escapeHTML($current->filter->style[$k])), + ]); } - echo ' -

' . sprintf(__('The inserted HTML tag looks like: %s'), Html::escapeHTML(str_replace('%s', '...', $current->filter->replace))) . '

+ echo + (new Div('setting'))->class('multi-part')->title(__('Settings'))->items([ + (new Form('setting_form'))->method('post')->action(dcCore::app()->adminurl->get('admin.plugin.' . My::id()) . '#setting')->separator('')->fields([ + (new Div())->class('two-boxes even')->items($form_pages), + (new Div())->class('two-boxes odd')->items([ + (new Text('h4', __('Filtering'))), + (new Para())->items([ + (new Checkbox('filter_nocase', $current->filter->nocase))->value(1), + (new Label(__('Case insensitive'), Label::OUTSIDE_LABEL_AFTER))->for('filter_nocase')->class('classic'), + ]), + (new Para())->items([ + (new Checkbox('filter_plural', $current->filter->plural))->value(1), + (new Label(__('Also use the plural'), Label::OUTSIDE_LABEL_AFTER))->for('filter_plural')->class('classic'), + ]), + (new Para())->items([ + (new Label(__('Limit the number of replacement to:'), Label::OUTSIDE_LABEL_BEFORE))->for('filter_limit'), + (new Number('filter_limit'))->min(0)->max(99)->value((int) $current->filter->limit), + ]), + (new Note())->class('form-note')->text(__('Leave it blank or set it to 0 for no limit')), + ]), + (new Div())->class('two-boxes even')->items($form_values), + (new Div())->class('two-boxes odd')->items(array_merge($form_styles, [ + (new Note())->class('form-note')->text(sprintf(__('The inserted HTML tag looks like: %s'), Html::escapeHTML(str_replace('%s', '...', $current->filter->replace)))), + (new Para())->items([ + (new Label(__('Ignore HTML tags:'), Label::OUTSIDE_LABEL_BEFORE))->for('filter_notag'), + (new Input('filter_notag'))->size(60)->maxlenght(255)->value(Html::escapeHTML($current->filter->notag)), + ]), + (new Note())->class('form-note')->text(__('This is the list of HTML tags where content will be ignored.') . ' ' . ('' != $current->filter->htmltag ? '' : sprintf(__('Tag "%s" always be ignored.'), $current->filter->htmltag))), -

' . - form::field('filter_notag', 60, 255, Html::escapeHTML($current->filter->notag)) . ' -

-

' . __('This is the list of HTML tags where content will be ignored.') . ' ' . - ('' != $current->filter->htmltag ? '' : sprintf(__('Tag "%s" always be ignored.'), $current->filter->htmltag)) . '

-
-
-

' . - dcCore::app()->formNonce() . - form::hidden(['action'], 'savefiltersetting') . - form::hidden(['part'], $current->part) . ' - -

-
- -
-
'; + ])), + (new Div())->class('clear')->items([ + dcCore::app()->formNonce(false), + (new Hidden(['action'], 'savefiltersetting')), + (new Hidden(['part'], $current->part)), + (new Submit(['save']))->value(__('Save')), + ]), + ]), + ])->render(); # Filter records list if ($current->filter->has_list && isset($sorts) && isset($pager)) { @@ -303,7 +292,7 @@ class Manage extends dcNsProcess echo '
'; - $sorts->display(['admin.plugin.' . My::id(), '#record'], form::hidden('p', My::id()) . form::hidden('part', $current->part)); + $sorts->display(['admin.plugin.' . My::id(), '#record'], (new Hidden('p', My::id()))->render() . (new Hidden('part', $current->part))->render()); $pager->display( $sorts, @@ -314,12 +303,15 @@ class Manage extends dcNsProcess '
' . '

' . - '

' . - form::hidden('action', 'deleterecords') . - '

' . - dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.' . My::id(), array_merge(['p' => My::id()], $sorts->values(true))) . - form::hidden('redir', dcCore::app()->adminurl->get('admin.plugin.' . My::id(), $sorts->values(true))) . - dcCore::app()->formNonce() . + (new Para())->class('col right')->items(array_merge( + dcCore::app()->adminurl->hiddenFormFields('admin.plugin.' . My::id(), array_merge(['p' => My::id()], $sorts->values(true))), + [ + dcCore::app()->formNonce(false), + (new Hidden('redir', dcCore::app()->adminurl->get('admin.plugin.' . My::id(), $sorts->values(true)))), + (new Hidden('action', 'deleterecords')), + (new Submit(['save', 'del-action']))->value(__('Delete selected records')), + ] + ))->render() . '
' . '' ); @@ -327,26 +319,25 @@ class Manage extends dcNsProcess echo '
'; # New record - echo ' -
-
' . - - '

' . - form::field('new_key', 60, 255, ['extra_html' => 'required']) . - '

' . - - '

' . - form::field('new_value', 60, 255, ['extra_html' => 'required']) . - '

- -

' . - form::hidden(['action'], 'savenewrecord') . - form::hidden(['part'], $current->part) . - dcCore::app()->formNonce() . ' - -

-
-
'; + echo + (new Div('newrecord'))->class('multi-part')->title(__('New record'))->items([ + (new Form('form-create'))->method('post')->action(dcCore::app()->adminurl->get('admin.plugin.' . My::id()) . '#record')->fields([ + (new Para())->items([ + (new Label(__('Key:'), Label::OUTSIDE_LABEL_BEFORE))->for('new_key'), + (new Input('new_key'))->size(60)->maxlenght(255)->required(true), + ]), + (new Para())->items([ + (new Label(__('Value:'), Label::OUTSIDE_LABEL_BEFORE))->for('new_value'), + (new Input('new_value'))->size(60)->maxlenght(255)->required(true), + ]), + (new Para())->class('clear')->items([ + dcCore::app()->formNonce(false), + (new Hidden(['action'], 'savenewrecord')), + (new Hidden(['part'], $current->part)), + (new Submit(['save', 'new-action']))->value(__('Save')), + ]), + ]), + ])->render(); } # --BEHAVIOR-- enhancePostContentAdminPage