Beispiel #1
0
 public function render(\Laasti\Pagination\Pagination $pagination)
 {
     $html = '<nav class="Breadcrumb">';
     if (!is_null($pagination->first())) {
         $html .= '<a href="' . $pagination->first()->link() . '">First</a>';
     }
     if (!is_null($pagination->previous())) {
         $html .= '<a href="' . $pagination->previous()->link() . '">Previous</a>';
     }
     foreach ($pagination as $page) {
         if ($page->isActive()) {
             $html .= '<b>' . $page->number() . '</b>';
         } else {
             $html .= '<a href="' . $page->link() . '">' . $page->number() . '</a>';
         }
     }
     if (!is_null($pagination->next())) {
         $html .= '<a href="' . $pagination->next()->link() . '">Next</a>';
     }
     if (!is_null($pagination->last())) {
         $html .= '<a href="' . $pagination->last()->link() . '">Last</a>';
     }
     $html .= '</nav>';
     return $html;
 }
Beispiel #2
0
 public function testSpecialLinks()
 {
     $pagination = new Pagination(6, 100, 10, 'http:/acme.com/pages/', 5);
     $this->assertTrue($pagination->next()->number() === 7);
     $this->assertTrue($pagination->previous()->number() === 5);
     $this->assertTrue($pagination->current()->number() === 6);
     $this->assertTrue($pagination->last()->number() === 10);
     $this->assertTrue($pagination->first()->number() === 1);
     $pagination->setCurrentPage(1);
     $this->assertTrue($pagination->previous() === null);
     $this->assertTrue($pagination->first() === null);
     $pagination->setCurrentPage(10);
     $this->assertTrue($pagination->next() === null);
     $this->assertTrue($pagination->last() === null);
 }