示例#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;
 }
示例#2
0
 public function testFormatter()
 {
     $pagination = new Pagination(3, 30, 5);
     $pagination->setFormatter(new PlainHtml());
     $result = '<nav class="Breadcrumb"><a href="/1">First</a><a href="/2">Previous</a><a href="/1">1</a><a href="/2">2</a><b>3</b><a href="/4">4</a><a href="/5">5</a><a href="/6">6</a><a href="/4">Next</a><a href="/6">Last</a></nav>';
     $this->assertEquals($result, (string) $pagination);
 }