enhancePostContent/inc/class.adminepclist.php

83 lines
2.7 KiB
PHP
Raw Normal View History

<?php
2021-10-31 22:22:34 +00:00
/**
* @brief enhancePostContent, a plugin for Dotclear 2
2021-11-01 09:33:43 +00:00
*
2021-10-31 22:22:34 +00:00
* @package Dotclear
* @subpackage Plugin
2021-11-01 09:33:43 +00:00
*
2021-10-31 22:22:34 +00:00
* @author Jean-Christian Denis and Contributors
2021-11-01 09:33:43 +00:00
*
2021-10-31 22:22:34 +00:00
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
/**
* @ingroup DC_PLUGIN_PERIODICAL
* @brief Periodical - admin pager methods.
* @since 2.6
*/
class adminEpcList extends adminGenericList
{
2021-11-01 09:33:43 +00:00
public function display($filter, $pager_url, $enclose_block = '')
{
if ($this->rs->isEmpty()) {
2022-12-21 21:27:20 +00:00
echo '<p><strong>' . ($filter->show() ? __('No record matches the filter') : __('No record')) . '</strong></p>';
} else {
2021-11-01 09:33:43 +00:00
$pager = new dcPager($filter->page, $this->rs_count, $filter->nb, 10);
$pager->base_url = $pager_url;
$epc_id = [];
if (isset($_REQUEST['epc_id'])) {
foreach ($_REQUEST['epc_id'] as $v) {
2021-11-06 13:46:37 +00:00
$epc_id[(int) $v] = true;
}
}
$cols = [
'key' => '<th colspan="2" class="first">' . __('Key') . '</th>',
'value' => '<th scope="col">' . __('Value') . '</th>',
2022-11-13 20:30:48 +00:00
'date' => '<th scope="col">' . __('Date') . '</th>',
];
2021-11-01 09:33:43 +00:00
$html_block = '<div class="table-outer"><table><caption>' .
(
$filter->show() ?
sprintf(__('List of %s records matching the filter.'), $this->rs_count) :
sprintf(__('List of %s records.'), $this->rs_count)
2021-11-01 09:33:43 +00:00
) . '</caption>' .
'<tr>' . implode($cols) . '</tr>%s</table>%s</div>';
if ($enclose_block) {
$html_block = sprintf($enclose_block, $html_block);
}
$blocks = explode('%s', $html_block);
echo $pager->getLinks() . $blocks[0];
while ($this->rs->fetch()) {
echo $this->line(isset($epc_id[$this->rs->epc_id]));
}
echo $blocks[1] . $blocks[2] . $pager->getLinks();
}
}
private function line($checked)
{
$cols = [
2021-11-01 09:33:43 +00:00
'check' => '<td class="nowrap">' . form::checkbox(['epc_id[]'], $this->rs->epc_id, ['checked' => $checked]) . '</td>',
'key' => '<td class="nowrap">' . html::escapeHTML($this->rs->epc_key) . '</td>',
'value' => '<td class="maximal">' . html::escapeHTML($this->rs->epc_value) . '</td>',
2022-11-13 20:30:48 +00:00
'date' => '<td class="nowrap count">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->epc_upddt) . '</td>',
];
2021-11-01 09:33:43 +00:00
return
'<tr class="line" id="p' . $this->rs->epc_id . '">' .
2021-11-01 09:33:43 +00:00
implode($cols) .
'</tr>';
}
2021-11-01 09:33:43 +00:00
}