From 7b1ee43b0b01c2392744ae40546819ee630d3ff6 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 25 Jun 2008 14:43:08 -0400 Subject: [PATCH] Rewrite of the pagination system --- includes/functions.php | 60 ------------------------------- includes/pagination.php | 80 +++++++++++++++++++++++++++++++++++++++++ index.php | 5 ++- 3 files changed, 84 insertions(+), 61 deletions(-) create mode 100644 includes/pagination.php diff --git a/includes/functions.php b/includes/functions.php index 73a812d..8091875 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -689,66 +689,6 @@ function ProcessBugDataForDisplay($bug, $color = '') return $bug; } -// ################################################################### -/** -* Loads the pagination module and sets all of the appropriate options -* for it -* -* @access public -*/ -function LoadPaginationFramework() -{ - global $bugsys; - - $bugsys->load('pagination', 'pagination', true); - $bugsys->pagination->setDefaultPerPage(bugdar::$options['defaultpp']); - $bugsys->pagination->setMaxPerPage(bugdar::$options['maxpp']); - $bugsys->pagination->setPageLinks(bugdar::$options['pagelinks']); - $bugsys->pagination->setPageVar('p'); - $bugsys->pagination->setPerPageVar('pp'); - $bugsys->pagination->setBitProcessor('PageNavigatorBitCallback'); - $bugsys->pagination->setNavigatorProcessor('PageNavigatorCallback'); - $bugsys->pagination->processIncomingData(); -} - -// ################################################################### -/** -* Callback function for the Pagination->BitProcessor() -* -* @param string Base link -* @param bool Do not show this as a link -* @param integer Page number -* @param object Page navigator framework -* -* @return string Processed HTML -*/ -function PageNavigatorBitCallback($baselink, $nolink, $number, $paginator) -{ - global $bugsys; - eval('$return = "' . $bugsys->template->fetch('pagenav_bit') . '";'); - return $return; -} - -// ################################################################### -/** -* Callback function for the Pagination->NavigatorProcessor() -* -* @param string Base URL -* @param integer Next page number -* @param integer Previous page number -* @param array Show information -* @param string Individual page bits -* @param object Page navigator framework -* -* @return string Processed HTML -*/ -function PageNavigatorCallback($baselink, $nextpage, $prevpage, $show, $pagebits, $paginator) -{ - global $bugsys; - eval('$return = "' . $bugsys->template->fetch('pagenav') . '";'); - return $return; -} - // ################################################################### /** * Determines the correct permissions of the user. This is especially diff --git a/includes/pagination.php b/includes/pagination.php new file mode 100644 index 0000000..c641bcc --- /dev/null +++ b/includes/pagination.php @@ -0,0 +1,80 @@ +page = BSApp::$input->inputClean('p', TYPE_UINT); + $this->defaultperpage = bugdar::$options['defaultpp']; + $this->perpage = BSApp::$input->inputClean('pp', TYPE_UINT); + $this->pagelinks = bugdar::$options['pagelinks']; + $this->maxperpage = bugdar::$options['maxpp']; + } + + /** + * Processes an individual page link + */ + protected function _bitProcessor($baselink, $isCurrent, $pagenumber) + { + $template = new BSTemplate('pagenav_bit'); + $template->vars = array( + 'baselink' => $baselink, + 'nolink' => $isCurrent, + 'number' => $pagenumber + ); + return $template->evaluate(); + } + + /** + * Generates the entire page navigation HTML + */ + protected function _navigationProcessor($baselink, $next, $prev, $show, $bits) + { + $template = new BSTemplate('pagenav'); + $template->vars = array( + 'baselink' => $baselink, + 'nextpage' => $next, + 'prevpage' => $prev, + 'show' => $show, + 'pagebits' => $bits, + 'paginator' => $this + ); + return $template->evaluate(); + } +} + +?> \ No newline at end of file diff --git a/index.php b/index.php index a70099c..586ea39 100644 --- a/index.php +++ b/index.php @@ -40,7 +40,10 @@ if (!can_perform('canviewbugs')) } $sort = new ListSorter('index'); -LoadPaginationFramework(); + +require_once 'includes/pagination.php'; +$pagination = new Pagination(); +$pagination->processIncomingData(); // ################################################################### -- 2.43.5