/** * Renders the pagination to HTML * * @param object $base_url A CP\URL object * @return string The rendered HTML of the pagination */ public function render(Url $base_url) { $prev = $this->current_page - 1 >= 1 ? $this->current_page - 1 : NULL; $pages = (int) ceil($this->total_count / $this->per_page); $next = $this->current_page + 1 <= $pages ? $this->current_page + 1 : NULL; $last = $pages; // Show no pagination unless we have at least 2 pages if ($pages < 2) { return; } // Remove the current page from the count and force an integer instead of a float. $pages_to_display = (int) $this->pages_to_display - 1; $links['total_count'] = $this->total_count; $links['current_page'] = $this->current_page; $links['first'] = $base_url->compile(); foreach (array('prev', 'next', 'last') as $key) { if (${$key} === NULL) { continue; } $url = clone $base_url; $url->setQueryStringVariable((string) $this->page_variable, ${$key}); $links[$key] = $url->compile(); } $start = $this->current_page - 1 > 1 ? $this->current_page - 1 : 1; if ($start + $pages_to_display <= $pages) { $end = $start + $pages_to_display; } else { $end = $pages; if ($end - $pages_to_display > 1) { $start = $end - $pages_to_display; } else { $start = 1; } } for ($i = $start; $i <= $end; $i++) { $url = clone $base_url; $url->setQueryStringVariable($this->page_variable, $i); $links['pages'][$i] = $url->compile(); } return $this->view->render(array('pagination' => $links)); }
/** * Render the section with a view * * @param object View $view object to render * @return string **/ public function render(View $view, $index) { return $view->render(array('profiler_data' => $this->data, 'index' => $index)); }
/** * Renders the alert to HTML. * * @return string The rendered HTML of the alert */ public function render() { return $this->view->render(array('alert' => $this)); }