/** * Generates a list of pagination links * * @param QFrame_Paginator paginator object * @param string (optional) action to use for page link * @param string (optional) variable to use for page number * @param Array (optional) list of additional parameters to add to each link * @return string */ public function pagination($pager, $action = 'page', $pageNum = 'id', $params = array()) { if (count($pager->pageNumbers()) <= 1) { return ''; } $controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); $b = new Tag_Builder(); $content = ''; // set up an array of arguments that are common to all links $linkArgs = array_merge($params, array('controller' => $controller, 'action' => $action)); // print out links to each page number (unless it is the current page number // in which case print out just the number, no link) foreach ($pager->pageNumbers() as $page) { if ($page == $pager->currentNumber()) { $pageContent = "{$page} "; } else { $linkArgs[$pageNum] = $page; $pageContent = $this->_view->linkTo($linkArgs, "{$page}") . ' '; } $content .= $b->li($pageContent); } // prepend a previous page link if there is/are previous page(s), otherwise // just the equivalent text if ($pager->currentNumber() > 1) { $linkArgs[$pageNum] = $pager->currentNumber() - 1; $content = $b->li($this->_view->linkTo($linkArgs, '< prev'), ' ', $content); } // append a next page link if there is/are next page(s), otherwise just // the equivalent text if ($pager->currentNumber() < $pager->lastPageNumber()) { $linkArgs[$pageNum] = $pager->currentNumber() + 1; $content .= $b->li($this->_view->linkTo($linkArgs, 'next >'), ' '); } return $b->ol(array('class' => 'pagination'), $content); }