use 2.26 Html Helpers

This commit is contained in:
Jean-Christian Denis 2023-03-26 21:48:03 +02:00
parent 942f04b671
commit 7ff7b24f36
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
2 changed files with 17 additions and 36 deletions

View file

@ -14,17 +14,15 @@ declare(strict_types=1);
namespace Dotclear\Plugin\whiteListCom; namespace Dotclear\Plugin\whiteListCom;
/* dotclear ns */
use dcCore; use dcCore;
use dcPage; use dcPage;
use dcSpamFilter; use dcSpamFilter;
use Dotclear\Helper\Html\Form\{
/* clearbricks ns */ Checkbox,
use form; Hidden
use html; };
use http; use Dotclear\Helper\Html\Html;
use Dotclear\Helper\Network\Http;
/* php ns */
use Exception; use Exception;
/** /**
@ -88,7 +86,7 @@ class ReservedWhiteList extends dcSpamFilter
} }
$wlc->commit(); $wlc->commit();
dcPage::addSuccessNotice(__('Reserved names have been successfully updated.')); dcPage::addSuccessNotice(__('Reserved names have been successfully updated.'));
http::redirect($url); Http::redirect($url);
} }
$comments = $wlc->getCommentsUsers(); $comments = $wlc->getCommentsUsers();
@ -96,7 +94,7 @@ class ReservedWhiteList extends dcSpamFilter
dcCore::app()->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
} }
$res = '<form action="' . html::escapeURL($url) . '" method="post">' . $res = '<form action="' . Html::escapeURL($url) . '" method="post">' .
'<p>' . __('Check the users who can make comments without being moderated.') . '</p>' . '<p>' . __('Check the users who can make comments without being moderated.') . '</p>' .
'<p>' . __('Comments authors list') . '</p>' . '<p>' . __('Comments authors list') . '</p>' .
'<table class="clear">' . '<table class="clear">' .
@ -107,12 +105,8 @@ class ReservedWhiteList extends dcSpamFilter
foreach ($comments as $user) { foreach ($comments as $user) {
$res .= '<tr class="line">' . $res .= '<tr class="line">' .
'<td class="nowrap">' . '<td class="nowrap">' .
form::checkbox( (new Checkbox(['reserved[' . $i . ']'], (null === $wlc->isReserved($user['name'], $user['email']))))->value($user['name'])->render() .
['reserved[' . $i . ']'], (new Hidden(['reserved_email[' . $i . ']'], $user['email']))->render() .
$user['name'],
(null === $wlc->isReserved($user['name'], $user['email']))
) .
form::hidden(['reserved_email[' . $i . ']'], $user['email']) .
' ' . $user['name'] . '</td>' . ' ' . $user['name'] . '</td>' .
'<td class="nowrap">' . $user['email'] . '</td>' . '<td class="nowrap">' . $user['email'] . '</td>' .
'</tr>'; '</tr>';

View file

@ -14,17 +14,12 @@ declare(strict_types=1);
namespace Dotclear\Plugin\whiteListCom; namespace Dotclear\Plugin\whiteListCom;
/* dotclear ns */
use dcCore; use dcCore;
use dcPage; use dcPage;
use dcSpamFilter; use dcSpamFilter;
use Dotclear\Helper\Html\Form\Checkbox;
/* clearbricks ns */ use Dotclear\Helper\Html\Html;
use form; use Dotclear\Helper\Network\Http;
use html;
use http;
/* php ns */
use Exception; use Exception;
/** /**
@ -80,7 +75,7 @@ class UnmoderatedWhiteList extends dcSpamFilter
} }
$wlc->commit(); $wlc->commit();
dcPage::addSuccessNotice(__('Unmoderated names have been successfully updated.')); dcPage::addSuccessNotice(__('Unmoderated names have been successfully updated.'));
http::redirect($url); Http::redirect($url);
} }
$posts = $wlc->getPostsUsers(); $posts = $wlc->getPostsUsers();
$comments = $wlc->getCommentsUsers(); $comments = $wlc->getCommentsUsers();
@ -96,7 +91,7 @@ class UnmoderatedWhiteList extends dcSpamFilter
'</p>'; '</p>';
} }
$res .= '<form action="' . html::escapeURL($url) . '" method="post">' . $res .= '<form action="' . Html::escapeURL($url) . '" method="post">' .
'<p>' . __('Check the users who can make comments without being moderated.') . '</p>' . '<p>' . __('Check the users who can make comments without being moderated.') . '</p>' .
'<div class="two-cols">' . '<div class="two-cols">' .
'<div class="col">' . '<div class="col">' .
@ -108,11 +103,7 @@ class UnmoderatedWhiteList extends dcSpamFilter
foreach ($posts as $user) { foreach ($posts as $user) {
$res .= '<tr class="line">' . $res .= '<tr class="line">' .
'<td class="nowrap">' . '<td class="nowrap">' .
form::checkbox( (new Checkbox(['unmoderated[]'], $wlc->isUnmoderated($user['email'])))->value($user['email'])->render() .
['unmoderated[]'],
$user['email'],
$wlc->isUnmoderated($user['email'])
) .
' ' . $user['name'] . '</td>' . ' ' . $user['name'] . '</td>' .
'<td class="nowrap">' . $user['email'] . '</td>' . '<td class="nowrap">' . $user['email'] . '</td>' .
'</tr>'; '</tr>';
@ -130,11 +121,7 @@ class UnmoderatedWhiteList extends dcSpamFilter
foreach ($comments as $user) { foreach ($comments as $user) {
$res .= '<tr class="line">' . $res .= '<tr class="line">' .
'<td class="nowrap">' . '<td class="nowrap">' .
form::checkbox( (new Checkbox(['unmoderated[]'], $wlc->isUnmoderated($user['email'])))->value($user['email'])->render() .
['unmoderated[]'],
$user['email'],
$wlc->isUnmoderated($user['email'])
) .
' ' . $user['name'] . '</td>' . ' ' . $user['name'] . '</td>' .
'<td class="nowrap">' . $user['email'] . '</td>' . '<td class="nowrap">' . $user['email'] . '</td>' .
'</tr>'; '</tr>';