From 5cb3da5b307f1e4148b71412b4f90ca9c8cf90f2 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 21 Apr 2007 21:21:57 +0000 Subject: [PATCH] We now paginate log.php so we dont' flood the browser with log information --- log.php | 35 +++++++++++++++++++++++++++++-- templates/default/log.tpl | 2 ++ templates/default/pagenav.tpl | 7 +++++++ templates/default/pagenav_bit.tpl | 1 + 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 templates/default/pagenav.tpl create mode 100644 templates/default/pagenav_bit.tpl diff --git a/log.php b/log.php index 8514335..a660513 100644 --- a/log.php +++ b/log.php @@ -21,7 +21,9 @@ $fetchtemplates = array( 'log_node', - 'log' + 'log', + 'pagenav_bit', + 'pagenav' ); define('SVN', '$Id$'); @@ -30,6 +32,28 @@ require_once('./global.php'); $navbar = ConstructNavbar(); +$paginate = BSRegister::LoadModule('Pagination'); + +function _PageBitCallback($baselink, $nolink, $number, $paginator) +{ + eval('$data = "' . BSRegister::Get('template')->fetch('pagenav_bit') . '";'); + return $data; +} + +function _PageNavCallback($baselink, $nextpage, $prevpage, $show, $pagebits, $paginator) +{ + eval('$data = "' . BSRegister::Get('template')->fetch('pagenav') . '";'); + return $data; +} + +$paginate->setPageLinks(2); +$paginate->setPageVar('rev'); +$paginate->setMaxPerPage(20); +$paginate->setDefaultPerPage(20); +$paginate->setBitProcessor('_PageBitCallback'); +$paginate->setNavigatorProcessor('_PageNavCallback'); +$paginate->processIncomingData(); + // ################################################################### $logs = BSXml::Parse($lib->run('log --xml ' . $lib->arg($repos->fetchPath($input->in['repos']) . '/' . $input->in['path']), true)); @@ -38,8 +62,13 @@ $nodes = ''; BSXml::UnifyNode($logs['log']['logentry']); -foreach ($logs['log']['logentry'] AS $index => $log) +$paginate->setTotal(sizeof($logs['log']['logentry'])); +$paginate->splitPages(); + +for ($i = $paginate->fetchLimit() - $paginate->getPerPage(); $i < $paginate->fetchLimit($paginate->getPage()); $i++) { + $log = $logs['log']['logentry'][$i]; + $log['author'] = $log['author']['value']; $log['date'] = FormatSvnDate($log['date']['value']); $log['message_clean'] = FormatLogMessage($log['msg']['value']); @@ -51,6 +80,8 @@ foreach ($logs['log']['logentry'] AS $index => $log) eval('$nodes .= "' . $template->fetch('log_node') . '";'); } +$pagenav = $paginate->constructPageNav(ConstructLink('log', $input->in['repos'], $input->in['path'], 0), false); + // ################################################################### eval('$template->flush("' . $template->fetch('log') . '");'); diff --git a/templates/default/log.tpl b/templates/default/log.tpl index ad9c521..d61c982 100644 --- a/templates/default/log.tpl +++ b/templates/default/log.tpl @@ -10,4 +10,6 @@ $header
$navbar
$nodes +$pagenav + $footer \ No newline at end of file diff --git a/templates/default/pagenav.tpl b/templates/default/pagenav.tpl new file mode 100644 index 0000000..60f6611 --- /dev/null +++ b/templates/default/pagenav.tpl @@ -0,0 +1,7 @@ +
+ {@"First"} ... + {@"Prev"} ... +$pagebits + ... {@"Next"} + ... {@"Last"} +
\ No newline at end of file diff --git a/templates/default/pagenav_bit.tpl b/templates/default/pagenav_bit.tpl new file mode 100644 index 0000000..0a7a220 --- /dev/null +++ b/templates/default/pagenav_bit.tpl @@ -0,0 +1 @@ + $number$number \ No newline at end of file -- 2.43.5