fix admin pager for links list
parent
f13814ff5e
commit
ab9b5e9b6b
|
@ -11,79 +11,86 @@
|
||||||
#
|
#
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
class kutrlLinkslist extends adminGenericList
|
class kutrlLinkslist
|
||||||
{
|
{
|
||||||
public function display($page, $nb_per_page, $url)
|
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)
|
||||||
{
|
{
|
||||||
if ($this->rs->isEmpty()) {
|
if ($this->rs->isEmpty()) {
|
||||||
|
if ($filter) {
|
||||||
|
echo '<p><strong>' . __('No short link matches the filter') . '</strong></p>';
|
||||||
|
} else {
|
||||||
echo '<p><strong>' . __('No short link') . '</strong></p>';
|
echo '<p><strong>' . __('No short link') . '</strong></p>';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$pager = new pager($page, $this->rs_count, $nb_per_page, 10);
|
$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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$pager->base_url = $url;
|
$blocks = explode('%s', sprintf($enclose_block,
|
||||||
|
'<div class="table-outer"><table>' .
|
||||||
$html_block =
|
($filter ?
|
||||||
'<table class="clear">' .
|
'<caption>' . sprintf(__('List of %s links matching the filter.'), $this->rs_count) . '</caption>' :
|
||||||
'<thead>' .
|
'<caption>' . sprintf(__('List of links (%s)'), $this->rs_count) . '</caption>'
|
||||||
|
) .
|
||||||
'<tr>' .
|
'<tr>' .
|
||||||
'<th class="nowrap" colspan="2">' . __('Hash') . '</th>' .
|
'<th colspan="2" class="first">' . __('Hash') . '</th>' .
|
||||||
'<th class="maximal">' . __('Link') . '</th>' .
|
'<th scope="col">' . __('Link') . '</th>' .
|
||||||
'<th class="nowrap">' . __('Date') . '</th>' .
|
'<th scope="col">' . __('Date') . '</th>' .
|
||||||
'<th class="nowrap">' . __('Service') . '</th>' .
|
'<th scope="col">' . __('Service') . '</th>' .
|
||||||
'</tr>' .
|
'</tr>%s</table>%s</div>'
|
||||||
'</thead>' .
|
));
|
||||||
'<tbody>%s</tbody>' .
|
|
||||||
'</table>';
|
|
||||||
|
|
||||||
echo '<p>' . __('Page(s)') . ' : ' . $pager->getLinks() . '</p>';
|
echo $pager->getLinks().$blocks[0];
|
||||||
$blocks = explode('%s', $html_block);
|
|
||||||
echo $blocks[0];
|
|
||||||
|
|
||||||
$this->rs->index(((integer)$page - 1) * $nb_per_page);
|
while ($this->rs->fetch()) {
|
||||||
$iter = 0;
|
|
||||||
while ($iter < $nb_per_page) {
|
|
||||||
|
|
||||||
echo $this->line($url,$iter);
|
|
||||||
|
|
||||||
if ($this->rs->isEnd()) {
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
$this->rs->moveNext();
|
|
||||||
}
|
|
||||||
$iter++;
|
|
||||||
}
|
|
||||||
echo $blocks[1];
|
|
||||||
echo '<p>' . __('Page(s)') . ' : ' . $pager->getLinks() . '</p>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function line($url, $loop)
|
|
||||||
{
|
|
||||||
$type = $this->rs->kut_type;
|
$type = $this->rs->kut_type;
|
||||||
$hash = $this->rs->kut_hash;
|
$hash = $this->rs->kut_hash;
|
||||||
|
|
||||||
if (null !== ($o = kutrl::quickService($this->rs->kut_type))) {
|
if (null !== ($o = kutrl::quickService($type))) {
|
||||||
$type = '<a href="' . $o->home . '" title="' . $o->name . '">' . $o->name . '</a>';
|
$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>';
|
$hash = '<a href="' . $o->url_base . $hash . '" title="' . $o->url_base . $hash . '">' . $hash . '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
echo
|
||||||
'<tr class="line">' . "\n" .
|
'<tr class="line">' .
|
||||||
'<td class="nowrap">' .
|
'<td class="nowrap">' .
|
||||||
form::checkbox(['entries[' . $loop . ']'], $this->rs->kut_id, 0) .
|
form::checkbox(['entries[]'], $this->rs->kut_id, ['checked' => isset($entries[$this->rs->kut_id])]) .
|
||||||
'</td>' .
|
'</td>' .
|
||||||
'<td class="nowrap">' .
|
'<td class="nowrap">' .
|
||||||
$hash .
|
$hash .
|
||||||
"</td>\n" .
|
'</td>' .
|
||||||
'<td class="maximal">' .
|
'<td class="maximal" scope="row">' .
|
||||||
'<a href="' . $this->rs->kut_url . '">' . $this->rs->kut_url . '</a>' .
|
'<a href="' . $this->rs->kut_url . '">' . $this->rs->kut_url . '</a>' .
|
||||||
"</td>\n" .
|
'</td>' .
|
||||||
'<td class="nowrap">' .
|
'<td class="nowrap count">' .
|
||||||
dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->kut_dt, $this->core->auth->getInfo('user_tz')) .
|
dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->kut_dt, $this->core->auth->getInfo('user_tz')) .
|
||||||
"</td>\n" .
|
'</td>' .
|
||||||
'<td class="nowrap">' .
|
'<td class="nowrap">' .
|
||||||
$type .
|
$type .
|
||||||
"</td>\n" .
|
'</td>' .
|
||||||
'</tr>' . "\n";
|
'</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $blocks[1].$blocks[2].$pager->getLinks();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
24
index.php
24
index.php
|
@ -237,14 +237,6 @@ if ($part == 'links') {
|
||||||
$show_filters = true;
|
$show_filters = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pager_base_url =
|
|
||||||
$p_url .
|
|
||||||
'&urlsrv=' . $urlsrv .
|
|
||||||
'&sortby=' . $sortby .
|
|
||||||
'&order=' . $order .
|
|
||||||
'&nb=' . $nb_per_page .
|
|
||||||
'&page=%s';
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$list_all = $log->getLogs($params);
|
$list_all = $log->getLogs($params);
|
||||||
$list_counter = $log->getLogs($params, true)->f(0);
|
$list_counter = $log->getLogs($params, true)->f(0);
|
||||||
|
@ -532,13 +524,15 @@ if ($part == 'links') {
|
||||||
|
|
||||||
<p><input type="submit" value="' . __('Apply filters and display options') . '" />
|
<p><input type="submit" value="' . __('Apply filters and display options') . '" />
|
||||||
<br class="clear" /></p>
|
<br class="clear" /></p>
|
||||||
</form>
|
</form>';
|
||||||
|
|
||||||
<form action="' . $p_url . '&part=links" method="post" id="form-actions">';
|
$list_current->display(
|
||||||
|
$page,
|
||||||
|
$nb_per_page,
|
||||||
|
'<form action="' . $p_url . '&part=links" method="post" id="form-actions">
|
||||||
|
|
||||||
$list_current->display($page, $nb_per_page, $pager_base_url);
|
%s
|
||||||
|
|
||||||
echo '
|
|
||||||
<div class="two-cols">
|
<div class="two-cols">
|
||||||
<p class="col checkboxes-helpers"></p>
|
<p class="col checkboxes-helpers"></p>
|
||||||
<p class="col right">
|
<p class="col right">
|
||||||
|
@ -553,9 +547,11 @@ if ($part == 'links') {
|
||||||
$core->formNonce() . '
|
$core->formNonce() . '
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</form>';
|
</form>',
|
||||||
|
$show_filters
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
# display footer
|
# display footer
|
||||||
dcPage::helpBlock('kUtRL');
|
dcPage::helpBlock('kUtRL');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue