use 2.26 Html Helpers

This commit is contained in:
Jean-Christian Paul Denis 2023-03-26 21:37:00 +02:00
parent b65d8a88c6
commit 5334bfa884
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
2 changed files with 33 additions and 28 deletions

View File

@ -17,9 +17,9 @@ namespace Dotclear\Plugin\dcLog;
use ArrayObject; use ArrayObject;
use adminGenericListV2; use adminGenericListV2;
use dcPager; use dcPager;
use Dotclear\Helper\Html\Html;
use Dotclear\Helper\Html\Form\Checkbox;
use dt; use dt;
use form;
use html;
class BackendList extends adminGenericListV2 class BackendList extends adminGenericListV2
{ {
@ -77,28 +77,28 @@ class BackendList extends adminGenericListV2
{ {
$cols = [ $cols = [
'check' => '<td class="nowrap minimal">' . 'check' => '<td class="nowrap minimal">' .
form::checkbox(['entries[]'], $this->rs->log_id, ['checked' => $checked]) . (new Checkbox(['entries[]'], $checked))->value($this->rs->log_id)->render() .
'</td>', '</td>',
'date' => '<td class="nowrap minimal">' . 'date' => '<td class="nowrap minimal">' .
html::escapeHTML(dt::dt2str( Html::escapeHTML(dt::dt2str(
__('%Y-%m-%d %H:%M'), __('%Y-%m-%d %H:%M'),
$this->rs->log_dt $this->rs->log_dt
)) . )) .
'</td>', '</td>',
'msg' => '<td class="maximal">' . 'msg' => '<td class="maximal">' .
nl2br(html::escapeHTML($this->rs->log_msg)) . nl2br(Html::escapeHTML($this->rs->log_msg)) .
'</td>', '</td>',
'blog' => '<td class="minimal nowrap">' . 'blog' => '<td class="minimal nowrap">' .
html::escapeHTML($this->rs->blog_id) . Html::escapeHTML($this->rs->blog_id) .
'</td>', '</td>',
'table' => '<td class="minimal nowrap">' . 'table' => '<td class="minimal nowrap">' .
html::escapeHTML($this->rs->log_table) . Html::escapeHTML($this->rs->log_table) .
'</td>', '</td>',
'user' => '<td class="minimal nowrap">' . 'user' => '<td class="minimal nowrap">' .
html::escapeHTML($this->rs->getUserCN()) . Html::escapeHTML($this->rs->getUserCN()) .
'</td>', '</td>',
'ip' => '<td class="minimal nowrap">' . 'ip' => '<td class="minimal nowrap">' .
html::escapeHTML($this->rs->log_ip) . Html::escapeHTML($this->rs->log_ip) .
'</td>', '</td>',
]; ];
$cols = new ArrayObject($cols); $cols = new ArrayObject($cols);

View File

@ -17,8 +17,15 @@ namespace Dotclear\Plugin\dcLog;
use dcCore; use dcCore;
use dcNsProcess; use dcNsProcess;
use dcPage; use dcPage;
use Dotclear\Helper\Html\Form\{
Div,
Form,
Hidden,
Para,
Submit,
Text
};
use Exception; use Exception;
use form;
/** /**
* Manage logs list * Manage logs list
@ -89,31 +96,29 @@ class Manage extends dcNsProcess
if ($current->logs !== null && $current->list != null) { if ($current->logs !== null && $current->list != null) {
if ($current->logs->isEmpty() && !$current->filter->show()) { if ($current->logs->isEmpty() && !$current->filter->show()) {
echo '<p>' . __('There are no logs') . '</p>'; echo (new Text('p', __('There are no logs')))->render();
} else { } else {
$current->filter->display( $current->filter->display(
'admin.plugin.' . My::id(), 'admin.plugin.' . My::id(),
form::hidden('p', My::id()) (new Hidden(['p'], My::id()))->render()
); );
$current->list->display( $current->list->display(
(int) $current->filter->__get('page'), (int) $current->filter->__get('page'),
(int) $current->filter->__get('nb'), (int) $current->filter->__get('nb'),
'<form action="' . dcCore::app()->adminurl?->get('admin.plugin.' . My::id()) . '" method="post" id="form-entries">' . (new Form('form-entries'))->action(dcCore::app()->adminurl->get('admin.plugin.' . My::id()))->method('post')->fields([
(new Text('', '%s')),
'%s' . (new Div())->class('two-cols')->items([
(new Para())->class('col checkboxes-helpers'),
'<div class="two-cols">' . (new Para())->class('col right')->separator('&nbsp;')->items([
'<p class="col checkboxes-helpers"></p>' . (new Submit(['selected_logs']))->class('delete')->value(__('Delete selected logs')),
(new Submit(['all_logs']))->class('delete')->value(__('Delete all logs')),
'<p class="col right">' . ]),
'<input type="submit" value="' . __('Delete selected logs') . '" name="selected_logs" />&nbsp;' . (new Text('',
'<input type="submit" value="' . __('Delete all logs') . '" name="all_logs" />' .
'</p>' .
dcCore::app()->adminurl?->getHiddenFormFields('admin.plugin.' . My::id(), $current->filter->values()) . dcCore::app()->adminurl?->getHiddenFormFields('admin.plugin.' . My::id(), $current->filter->values()) .
dcCore::app()->formNonce() . dcCore::app()->formNonce()
'</div>' . )),
'</form>', ]),
])->render(),
$current->filter->show() $current->filter->show()
); );
} }