/** * 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); }
/** * Generate a string containing all of the references for an object * * @param mixed object whose references we are going to print out * @return string */ public function referenceString($referenced) { // if the object has no references, just return a blank string if (!isset($referenced->references) || count($referenced->references) <= 0) { return ''; } // new tag builder object $builder = new Tag_Builder(); // go through each reference generating a short reference string foreach ($referenced->references as $reference) { $shortName = $this->view->h($reference['shortName']); $item = $this->view->h($reference['item']); $references[] = "{$shortName} {$item}"; } // return an imploded version of all generated strings return $builder->em(' (' . implode(', ', $references) . ')'); }
/** * Render the lock icon next to a menu item where appropriate * * @param PageModel the page for which we are rendering a lock icon * @return string */ protected function renderMenuLockIcon(PageModel $page) { $builder = new Tag_Builder(); if (LockModel::isLocked($page)) { return ' ' . $builder->image('lock.png', array('class' => 'inline')); } return ''; }
/** * Return HTML for the private notes box * * @param ResponseModel response in queston * @return string */ public function privateNote(ResponseModel $response) { $builder = new Tag_Builder(); $class = 'privateNote'; if ($response->hasPrivateNote()) { $class .= ' hasContent'; $content = $this->view->h($response->privateNote); $style = ''; } else { $style = 'display: none;'; $content = 'Enter private notes here'; } $privNote = "<br/>private notes:<br/>\n"; $privNote .= $this->view->formTextarea("q{$response->parent->questionID}_privateNote", $content, array('class' => $class, 'style' => $style)); $privNote = $builder->span(array('class' => 'privateNote_main', 'style' => $style), $privNote); $privNoteMod = $this->view->formHidden("q{$response->parent->questionID}_privateNote_mod", 0); return $privNote . $privNoteMod; }