protected function render_paging_bar(paging_bar $pagingbar)
 {
     $pagingbar = clone $pagingbar;
     $pagingbar->prepare($this, $this->page, $this->target);
     $show_pagingbar = $pagingbar->perpage > 0 && $pagingbar->totalcount > $pagingbar->perpage;
     if (!$show_pagingbar) {
         return '';
     }
     $current_page = $pagingbar->page + 1;
     // Counting from one, not zero.
     $pager = new pager($pagingbar->perpage, $pagingbar->totalcount, $current_page);
     $pages = $pager->pages();
     $pagination = new bootstrap_pager(html_entity_decode($pagingbar->baseurl), $current_page, $pager->last_page);
     return bootstrap::pagination($pagination->for_pages($pages));
 }
 public function test_last_page_of_ten()
 {
     $pager = new bootstrap_pager('example.com?one=fish&two=fish', 10, 10);
     $links = $pager->for_pages(array(1, 'skip', 4, 5, 6, 7, 8, 9, 10));
     $actual = $links[0];
     $expected = $this->expected_link('_previous', 9);
     $this->assertEquals($expected, $actual);
     $actual = $links[1];
     $expected = $this->expected_link(1);
     $this->assertEquals($expected, $actual);
     $actual = $links[2];
     $expected = $this->skipped_link;
     $this->assertEquals($expected, $actual);
     $actual = $links[3];
     $expected = $this->expected_link(4);
     $this->assertEquals($expected, $actual);
     $actual = $links[9];
     $expected = $this->active(10);
     $this->assertEquals($expected, $actual);
     $actual = $links[10];
     $expected = $this->disabled_next;
     $this->assertEquals($expected, $actual);
 }