use 2.26 Html Helpers

This commit is contained in:
Jean-Christian 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 adminGenericListV2;
use dcPager;
use Dotclear\Helper\Html\Html;
use Dotclear\Helper\Html\Form\Checkbox;
use dt;
use form;
use html;
class BackendList extends adminGenericListV2
{
@ -77,28 +77,28 @@ class BackendList extends adminGenericListV2
{
$cols = [
'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>',
'date' => '<td class="nowrap minimal">' .
html::escapeHTML(dt::dt2str(
Html::escapeHTML(dt::dt2str(
__('%Y-%m-%d %H:%M'),
$this->rs->log_dt
)) .
'</td>',
'msg' => '<td class="maximal">' .
nl2br(html::escapeHTML($this->rs->log_msg)) .
nl2br(Html::escapeHTML($this->rs->log_msg)) .
'</td>',
'blog' => '<td class="minimal nowrap">' .
html::escapeHTML($this->rs->blog_id) .
Html::escapeHTML($this->rs->blog_id) .
'</td>',
'table' => '<td class="minimal nowrap">' .
html::escapeHTML($this->rs->log_table) .
Html::escapeHTML($this->rs->log_table) .
'</td>',
'user' => '<td class="minimal nowrap">' .
html::escapeHTML($this->rs->getUserCN()) .
Html::escapeHTML($this->rs->getUserCN()) .
'</td>',
'ip' => '<td class="minimal nowrap">' .
html::escapeHTML($this->rs->log_ip) .
Html::escapeHTML($this->rs->log_ip) .
'</td>',
];
$cols = new ArrayObject($cols);

View file

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