2021-08-28 16:27:58 +00:00
|
|
|
<?php
|
2021-08-28 19:59:42 +00:00
|
|
|
# -- BEGIN LICENSE BLOCK ----------------------------------
|
|
|
|
#
|
|
|
|
# This file is part of kUtRL, a plugin for Dotclear 2.
|
|
|
|
#
|
|
|
|
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
|
|
|
#
|
|
|
|
# Licensed under the GPL version 2.0 license.
|
|
|
|
# A copy of this license is available in LICENSE file or at
|
|
|
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
#
|
|
|
|
# -- END LICENSE BLOCK ------------------------------------
|
2021-08-28 16:27:58 +00:00
|
|
|
|
2021-08-28 21:17:13 +00:00
|
|
|
class kutrlLinkslist
|
2021-08-28 16:27:58 +00:00
|
|
|
{
|
2021-08-28 21:17:13 +00:00
|
|
|
protected $core;
|
|
|
|
protected $rs;
|
|
|
|
protected $rs_count;
|
|
|
|
protected $html_prev;
|
|
|
|
protected $html_next;
|
|
|
|
|
|
|
|
public function __construct(dcCore $core, $rs, $rs_count)
|
|
|
|
{
|
|
|
|
$this->core = &$core;
|
|
|
|
$this->rs = &$rs;
|
|
|
|
$this->rs_count = $rs_count;
|
|
|
|
$this->html_prev = __('« prev.');
|
|
|
|
$this->html_next = __('next »');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function display($page, $nb_per_page, $enclose_block, $filter = false)
|
2021-08-28 16:27:58 +00:00
|
|
|
{
|
|
|
|
if ($this->rs->isEmpty()) {
|
2021-08-28 21:17:13 +00:00
|
|
|
if ($filter) {
|
|
|
|
echo '<p><strong>' . __('No short link matches the filter') . '</strong></p>';
|
|
|
|
} else {
|
|
|
|
echo '<p><strong>' . __('No short link') . '</strong></p>';
|
|
|
|
}
|
2021-08-28 16:27:58 +00:00
|
|
|
} else {
|
2021-08-28 21:17:13 +00:00
|
|
|
$pager = new dcPager($page, $this->rs_count, $nb_per_page, 10);
|
|
|
|
$entries = [];
|
|
|
|
if (isset($_REQUEST['entries'])) {
|
|
|
|
foreach ($_REQUEST['entries'] as $v) {
|
|
|
|
$entries[(integer) $v] = true;
|
|
|
|
}
|
|
|
|
}
|
2021-08-28 16:27:58 +00:00
|
|
|
|
2021-08-28 21:17:13 +00:00
|
|
|
$blocks = explode('%s', sprintf($enclose_block,
|
|
|
|
'<div class="table-outer"><table>' .
|
|
|
|
($filter ?
|
|
|
|
'<caption>' . sprintf(__('List of %s links matching the filter.'), $this->rs_count) . '</caption>' :
|
|
|
|
'<caption>' . sprintf(__('List of links (%s)'), $this->rs_count) . '</caption>'
|
|
|
|
) .
|
|
|
|
'<tr>' .
|
|
|
|
'<th colspan="2" class="first">' . __('Hash') . '</th>' .
|
|
|
|
'<th scope="col">' . __('Link') . '</th>' .
|
|
|
|
'<th scope="col">' . __('Date') . '</th>' .
|
|
|
|
'<th scope="col">' . __('Service') . '</th>' .
|
|
|
|
'</tr>%s</table>%s</div>'
|
|
|
|
));
|
2021-08-28 16:27:58 +00:00
|
|
|
|
2021-08-28 21:17:13 +00:00
|
|
|
echo $pager->getLinks().$blocks[0];
|
2021-08-28 16:27:58 +00:00
|
|
|
|
2021-08-28 21:17:13 +00:00
|
|
|
while ($this->rs->fetch()) {
|
|
|
|
$type = $this->rs->kut_type;
|
|
|
|
$hash = $this->rs->kut_hash;
|
2021-08-28 16:27:58 +00:00
|
|
|
|
2021-08-28 21:17:13 +00:00
|
|
|
if (null !== ($o = kutrl::quickService($type))) {
|
|
|
|
$type = '<a href="' . $o->home . '" title="' . $o->name . '">' . $o->name . '</a>';
|
|
|
|
$hash = '<a href="' . $o->url_base . $hash . '" title="' . $o->url_base . $hash . '">' . $hash . '</a>';
|
2021-08-28 16:27:58 +00:00
|
|
|
}
|
|
|
|
|
2021-08-28 21:17:13 +00:00
|
|
|
echo
|
|
|
|
'<tr class="line">' .
|
|
|
|
'<td class="nowrap">' .
|
|
|
|
form::checkbox(['entries[]'], $this->rs->kut_id, ['checked' => isset($entries[$this->rs->kut_id])]) .
|
|
|
|
'</td>' .
|
|
|
|
'<td class="nowrap">' .
|
|
|
|
$hash .
|
|
|
|
'</td>' .
|
|
|
|
'<td class="maximal" scope="row">' .
|
|
|
|
'<a href="' . $this->rs->kut_url . '">' . $this->rs->kut_url . '</a>' .
|
|
|
|
'</td>' .
|
|
|
|
'<td class="nowrap count">' .
|
|
|
|
dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->kut_dt, $this->core->auth->getInfo('user_tz')) .
|
|
|
|
'</td>' .
|
|
|
|
'<td class="nowrap">' .
|
|
|
|
$type .
|
|
|
|
'</td>' .
|
|
|
|
'</tr>';
|
|
|
|
}
|
2021-08-28 16:27:58 +00:00
|
|
|
|
2021-08-28 21:17:13 +00:00
|
|
|
echo $blocks[1].$blocks[2].$pager->getLinks();
|
2021-08-28 16:27:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|