Файловый менеджер - Редактировать - /var/www/iplanru/data/old/www/i-plan.ru/administrator/components/com_zoo/framework/classes/pagination.php
Назад
<?php /** * @package ZOO * @author YOOtheme http://www.yootheme.com * @copyright Copyright (C) YOOtheme GmbH * @license http://www.gnu.org/licenses/gpl.html GNU/GPL */ /** * Class to provide pagination functionalities * * @package Framework.Classes */ class AppPagination { /** * A reference to the global App object * * @var App * @since 1.0.0 */ public $app; /** * Name of the paging http GET variable * * @var string * @since 1.0.0 */ protected $_name; /** * The total item count * * @var int * @since 1.0.0 */ protected $_total; /** * The current page number * * @var int * @since 1.0.0 */ protected $_current; /** * The number of items per pag * * @var int * @since 1.0.0 */ protected $_limit; /** * The range for the displayed pagination pages * * @var int * @since 1.0.0 */ protected $_range; /** * The total number of pages * * @var int * @since 1.0.0 */ protected $_pages; /** * If we are showing all the items * * @var boolean * @since 1.0.0 */ protected $_showall = false; /** * Constructor * * @param string $name The name of the pagination http GET variable * @param int $total The total number of items * @param int $current The current page (default: 1) * @param int $limit The number of items per page (default: 10) * @param int $range The range for the displayed page (default: 5) */ public function __construct($name, $total, $current = 1, $limit = 10, $range = 5) { // init vars $this->_name = $name; $this->_total = (int) max($total, 0); $this->_current = (int) max($current, 1); $this->_limit = (int) max($limit, 1); $this->_range = (int) max($range, 1); $this->_pages = (int) ceil($this->_total / $this->_limit); } /** * Get the show all items flag * * @return boolean True if we have to show all the items * * @since 1.0.0 */ public function getShowAll() { return $this->_showall; } /** * Set the show all items flag * * @param boolean $showall If we have to show all the items * * @since 1.0.0 */ public function setShowAll($showall) { $this->_showall = $showall; } /** * Get the current limit start * * @return int The current limit start * * @since 1.0.0 */ public function limitStart() { return ($this->_current - 1) * $this->_limit; } /** * Get the link with the added GET parameters * * @param string $url The url to which we should add the GET parameter * @param mixed $vars A list of variables to add to the url * * @return string The url with the added GET parameters * * @since 1.0.0 */ public function link($url, $vars) { if (!is_array($vars)) { $vars = array($vars); } return $url.(strpos($url, '?') === false ? '?' : '&').implode('&', $vars); } /** * Render the pagination * * @param string $url The url of the page on which we're adding the pagination * * @return string The html code of the pagination * * @since 1.0.0 */ public function render($url = 'index.php') { $html = ''; // check if show all if ($this->_showall) { return $html; } // check if current page is valid if ($this->_current > $this->_pages) { $this->_current = $this->_pages; } if ($this->_pages > 1) { $range_start = max($this->_current - $this->_range, 1); $range_end = min($this->_current + $this->_range - 1, $this->_pages); if ($this->_current > 1) { $link = $url; $html .= '<a class="start" href="'.JRoute::_($link).'"><<</a> '; $link = $this->_current - 1 == 1 ? $url : $this->link($url, $this->_name.'='.($this->_current - 1)); $html .= '<a class="previous" href="'.JRoute::_($link).'"><</a> '; } for ($i = $range_start; $i <= $range_end; $i++) { if ($i == $this->_current) { $html .= '[<span>'.$i.'</span>]'; } else { $link = $i == 1 ? $url : $this->link($url, $this->_name.'='.$i); $html .= '<a href="'.JRoute::_($link).'">'.$i.'</a>'; } $html .= " "; } if ($this->_current < $this->_pages) { $link = $this->link($url, $this->_name.'='.($this->_current + 1)); $html .= '<a class="next" href="'.JRoute::_($link).'">> </a> '; $link = $this->link($url, $this->_name.'='.($this->_pages)); $html .= '<a class="end" href="'.JRoute::_($link).'">>> </a> '; } } return $html; } }
| ver. 1.4 |
Github
|
.
| PHP 5.4.45-1~dotdeb+6.1 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка