2021-09-07 12:33:18 +00:00
|
|
|
<?php
|
2021-09-07 13:21:38 +00:00
|
|
|
/**
|
|
|
|
* @brief cinecturlink2, a plugin for Dotclear 2
|
2021-11-02 22:55:41 +00:00
|
|
|
*
|
2021-09-07 13:21:38 +00:00
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
2021-11-02 22:55:41 +00:00
|
|
|
*
|
2021-09-07 13:21:38 +00:00
|
|
|
* @author Jean-Christian Denis and Contributors
|
2021-11-02 22:55:41 +00:00
|
|
|
*
|
2021-09-07 13:21:38 +00:00
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2021-09-07 12:33:18 +00:00
|
|
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
2021-09-07 13:21:38 +00:00
|
|
|
return null;
|
2021-09-07 12:33:18 +00:00
|
|
|
}
|
|
|
|
|
2021-09-08 22:12:14 +00:00
|
|
|
class adminlistCinecturlink2
|
2021-09-07 12:33:18 +00:00
|
|
|
{
|
2021-09-08 22:12:14 +00:00
|
|
|
public $redir = '';
|
|
|
|
|
|
|
|
protected $core;
|
|
|
|
protected $rs;
|
|
|
|
protected $rs_count;
|
|
|
|
protected $html_prev;
|
|
|
|
protected $html_next;
|
|
|
|
|
|
|
|
public function __construct(dcCore $core, $rs, $rs_count)
|
2021-09-07 13:21:38 +00:00
|
|
|
{
|
2021-11-02 22:55:41 +00:00
|
|
|
$this->core = &$core;
|
|
|
|
$this->rs = &$rs;
|
|
|
|
$this->rs_count = $rs_count;
|
2021-09-08 22:12:14 +00:00
|
|
|
$this->html_prev = __('« prev.');
|
|
|
|
$this->html_next = __('next »');
|
|
|
|
}
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-09-10 22:46:28 +00:00
|
|
|
public function userColumns($type, $cols)
|
|
|
|
{
|
|
|
|
$cols_user = @$this->core->auth->user_prefs->interface->cols;
|
|
|
|
if (is_array($cols_user) || $cols_user instanceof ArrayObject) {
|
|
|
|
if (isset($cols_user[$type])) {
|
|
|
|
foreach ($cols_user[$type] as $cn => $cd) {
|
|
|
|
if (!$cd && isset($cols[$cn])) {
|
|
|
|
unset($cols[$cn]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-08 22:12:14 +00:00
|
|
|
public function display($page, $nb_per_page, $enclose_block = '', $filter = false, $redir = '')
|
|
|
|
{
|
|
|
|
$this->redir = $redir;
|
|
|
|
if ($this->rs->isEmpty()) {
|
|
|
|
if ($filter) {
|
|
|
|
echo '<p><strong>' . __('No link matches the filter') . '</strong></p>';
|
|
|
|
} else {
|
|
|
|
echo '<p><strong>' . __('No link') . '</strong></p>';
|
|
|
|
}
|
|
|
|
} else {
|
2021-11-02 22:55:41 +00:00
|
|
|
$pager = new dcPager($page, $this->rs_count, $nb_per_page, 10);
|
2021-09-08 22:12:14 +00:00
|
|
|
$links = [];
|
|
|
|
if (isset($_REQUEST['links'])) {
|
|
|
|
foreach ($_REQUEST['links'] as $v) {
|
2021-11-02 22:55:41 +00:00
|
|
|
$links[(int) $v] = true;
|
2021-09-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
}
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-09-10 22:46:28 +00:00
|
|
|
$cols = [
|
2021-11-02 22:55:41 +00:00
|
|
|
'title' => '<th colspan="2" class="first">' . __('Title') . '</th>',
|
|
|
|
'author' => '<th scope="col">' . __('Author') . '</th>',
|
|
|
|
'desc' => '<th scope="col">' . __('Description') . '</th>',
|
|
|
|
'link' => '<th scope="col">' . __('Links') . '</th>',
|
|
|
|
'cat' => '<th scope="col">' . __('Category') . '</th>',
|
|
|
|
'note' => '<th scope="col">' . __('Rating') . '</th>',
|
|
|
|
'date' => '<th scope="col">' . __('Date') . '</th>'
|
2021-09-10 22:46:28 +00:00
|
|
|
];
|
|
|
|
$cols = new ArrayObject($cols);
|
|
|
|
$this->userColumns('c2link', $cols);
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
$html_block = '<div class="table-outer">' .
|
2021-09-08 22:12:14 +00:00
|
|
|
'<table>' .
|
2021-11-02 22:55:41 +00:00
|
|
|
'<caption>' . (
|
|
|
|
$filter ?
|
2021-09-08 22:12:14 +00:00
|
|
|
sprintf(__('List of %s links matching the filter.'), $this->rs_count) :
|
|
|
|
sprintf(__('List of links (%s)'), $this->rs_count)
|
2021-11-02 22:55:41 +00:00
|
|
|
) . '</caption>' .
|
2021-09-08 22:12:14 +00:00
|
|
|
'<thead>' .
|
2021-09-10 22:46:28 +00:00
|
|
|
'<tr>' . implode(iterator_to_array($cols)) . '</tr>' .
|
2021-09-08 22:12:14 +00:00
|
|
|
'</thead>' .
|
|
|
|
'<tbody>%s</tbody>' .
|
|
|
|
'</table>' .
|
|
|
|
'%s</div>';
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-11-04 01:03:49 +00:00
|
|
|
$enclose_blocks = explode('%s', $enclose_block);
|
|
|
|
$blocks = explode('%s', $html_block);
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-11-05 22:23:00 +00:00
|
|
|
echo $pager->getLinks() . $enclose_blocks[0] . $blocks[0];
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-09-08 22:12:14 +00:00
|
|
|
while ($this->rs->fetch()) {
|
|
|
|
echo $this->linkLine(isset($links[$this->rs->link_id]));
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
2021-09-08 22:12:14 +00:00
|
|
|
|
2021-11-05 22:23:00 +00:00
|
|
|
echo $blocks[1] . $blocks[2] . $enclose_blocks[1] . $pager->getLinks();
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
}
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-09-08 22:12:14 +00:00
|
|
|
private function linkLine($checked)
|
2021-09-07 13:21:38 +00:00
|
|
|
{
|
2021-09-10 22:46:28 +00:00
|
|
|
$cols = [
|
|
|
|
'check' => '<td class="nowrap minimal">' .
|
2021-11-02 22:55:41 +00:00
|
|
|
form::checkbox(['entries[]'], $this->rs->link_id, ['checked' => $checked]) .
|
2021-09-10 22:46:28 +00:00
|
|
|
'</td>',
|
|
|
|
'title' => '<td class="nowrap" scope="row">' .
|
|
|
|
'<a href="' . $this->core->adminurl->get(
|
2021-11-02 22:55:41 +00:00
|
|
|
'admin.plugin.cinecturlink2',
|
2021-09-10 22:46:28 +00:00
|
|
|
['part' => 'link', 'linkid' => $this->rs->link_id, 'redir' => $this->redir]
|
|
|
|
) . '" title="' . __('Edit') . '">' .
|
|
|
|
html::escapeHTML($this->rs->link_title) . '</a>' .
|
|
|
|
'</td>',
|
|
|
|
'author' => '<td class="nowrap">' .
|
|
|
|
html::escapeHTML($this->rs->link_author) .
|
|
|
|
'</td>',
|
|
|
|
'desc' => '<td class="maximal">' .
|
|
|
|
html::escapeHTML($this->rs->link_desc) .
|
|
|
|
'</td>',
|
|
|
|
'link' => '<td class="nowrap">' .
|
2021-11-02 22:55:41 +00:00
|
|
|
'<a href="' . $this->rs->link_url . '" title="' .
|
|
|
|
html::escapeHTML($this->rs->link_url) .
|
2021-09-10 22:46:28 +00:00
|
|
|
'">' . __('URL') . '</a> ' .
|
2021-11-02 22:55:41 +00:00
|
|
|
'<a href="' . $this->rs->link_img . '" title="' .
|
|
|
|
html::escapeHTML($this->rs->link_img) .
|
2021-09-10 22:46:28 +00:00
|
|
|
'">' . __('image') . '</a> ' .
|
|
|
|
'</td>',
|
|
|
|
'cat' => '<td class="nowrap minimal">' .
|
|
|
|
'<a href="' . $this->core->adminurl->get(
|
2021-11-02 22:55:41 +00:00
|
|
|
'admin.plugin.cinecturlink2',
|
2021-09-10 22:46:28 +00:00
|
|
|
['part' => 'cat', 'catid' => $this->rs->cat_id, 'redir' => $this->redir]
|
|
|
|
) . '" title="' . __('Edit') . '">' .
|
|
|
|
html::escapeHTML($this->rs->cat_title) . '</a>' .
|
|
|
|
'</td>',
|
|
|
|
'note' => '</td>' .
|
|
|
|
'<td class="nowrap count minimal">' .
|
|
|
|
html::escapeHTML($this->rs->link_note) . '/20' .
|
|
|
|
'</td>',
|
|
|
|
'date' => '<td class="nowrap count minimal">' .
|
|
|
|
dt::dt2str(
|
2021-11-02 22:55:41 +00:00
|
|
|
$this->core->blog->settings->system->date_format . ', ' . $this->core->blog->settings->system->time_format,
|
|
|
|
$this->rs->link_upddt,
|
2021-09-10 22:46:28 +00:00
|
|
|
$this->core->auth->getInfo('user_tz')
|
|
|
|
) .
|
|
|
|
'</td>'
|
|
|
|
];
|
|
|
|
|
|
|
|
$cols = new ArrayObject($cols);
|
|
|
|
$this->userColumns('c2link', $cols);
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
return '<tr class="line">' . implode(iterator_to_array($cols)) . '</tr>' . "\n";
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
2021-11-02 22:55:41 +00:00
|
|
|
}
|