/**
  * @param mixed $listItem
  * @param null  $value
  *
  * @return $this
  */
 public function addListItem($listItem, $value = null)
 {
     if (!$listItem instanceof Li) {
         $listItem = Li::make($listItem, $value);
     }
     $this->appendContents($listItem);
     return $this;
 }
Exemple #2
0
 /**
  * @return Ul
  */
 protected function _getContentForRender()
 {
     $listItems = [];
     // Make previous link
     $previous = new A($this->_makeLink($this->_page - 1), 'Previous');
     if ($this->_page <= 1) {
         $previous->removeAttribute('href');
     }
     $previous = new Li($previous);
     if ($this->_page <= 1) {
         $previous->addClass('disabled');
     }
     $listItems[] = $previous;
     // Make numbers
     foreach ($this->_findGaps($this->_getPages()) as $page) {
         if (is_numeric($page)) {
             $link = new A($this->_makeLink($page), $page);
             if ($this->_page == $page) {
                 $link->removeAttribute('href');
             }
             $link = new Li($link);
             if ($this->_page == $page) {
                 $link->addClass('active');
             }
         } else {
             $link = new Span('&hellip;');
             $link = new Li($link);
             $link->addClass('disabled');
         }
         $listItems[] = $link;
     }
     // Make next link
     $next = new A($this->_makeLink($this->_page + 1), 'Next');
     if ($this->_page >= $this->_pages) {
         $next->removeAttribute('href');
     }
     $next = new Li($next);
     if ($this->_page >= $this->_pages) {
         $next->addClass('disabled');
     }
     $listItems[] = $next;
     // Output
     $list = new Ul();
     $list->addClass('pagination')->addListItems($listItems);
     return $list;
 }