Example #1
0
 /**
  * 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);
 }
Example #2
0
 /**
  * Output a lock icon which also serves as a link to unlock a page (if the user has permission
  * to do this)
  *
  * @param  Array       menu item array for this lock
  * @param  DbUserModel user that is currently logged in
  * @return string
  */
 public function lockIcon($menu, DbUserModel $user)
 {
     if ($menu['locked']) {
         $user = new DbUserModel(array('dbUserID' => $menu['locked'], 'depth' => 'dbUser'));
         $title = "Currently locked by '{$this->h($user->dbUserFullName)}'.";
         if ($user->hasAccess('edit', $menu['page']) || $user->hasAccess('approve', $menu['page'])) {
             $title .= ' Click to unlock.';
             $html = $this->view->linkTo('#', $this->view->imageTag('icons/ffffff/lock_small.png', array('id' => $this->view->url(array('action' => 'unlock', 'id' => $menu['page']->pageID)), 'class' => 'inline lock tooltip', 'tooltip' => $title)));
         } else {
             $html = $this->view->imageTag('icons/ffffff/lock_small.png', array('class' => 'inline', 'title' => $title));
         }
     } else {
         $html = '';
     }
     return $html;
 }
Example #3
0
 /**
  * Returns a link for the header bar of a page
  *
  * @param  PageModel    current page
  * @param  DbUserModel currently logged in user
  * @param  integer The current page number
  * @return string
  */
 public function topLinks($page, $user, $spNum)
 {
     if ($page->numQuestions <= 0) {
         return;
     }
     $current = Zend_Controller_Front::getInstance()->getRequest()->getActionName();
     $actions = "<li class=\"current\">{$current}</li>";
     //TODO need to relocate this list of available actions somewhere more appropriate
     foreach (array('view', 'edit', 'approve') as $action) {
         if ($action !== $current && $user->hasAccess($action, $page)) {
             $links[] = $this->view->linkTo($this->view->url(array('action' => $action, 'id' => $page->pageID)) . "?sp={$spNum}", $action);
         }
     }
     $actions = '<ul id="pageHeading">' . $actions . '<li>';
     if (isset($links)) {
         $actions .= implode($links, ' | </li><li>') . '</li>';
     }
     return "{$actions}<li class=\"stats\">{$this->stats($page)}</li><li class=\"bottom\"></li></ul>";
 }
Example #4
0
 /**
  * Outputs an option button for the "more options" panel
  *
  * @param  string name of the javascript event handler
  * @param  string image filename
  * @param  string description (when hovered over)
  * @param  string (optional) class to apply to the button
  * @return string
  */
 public function optionButton($handler, $image, $description, $class = 'inline')
 {
     $image = 'icons/ffffff/' . $image;
     return $this->view->linkTo("#{$handler}", $this->view->imageTag($image, array('class' => $class, 'title' => $description)));
 }