选择语言 :

 Core_Pagination::renew

设置更新

object Core_Pagination::renew( )
返回值
  • object Pagination
File: ./core/classes/pagination.class.php
protected function renew()
{
    $this->_is_renew = true;

    if (null===$this->current_page)
    {
        if (!empty($this->config['page']))
        {
            $this->current_page = (int)$this->config['page'];
        }
        else
        {
            switch ($this->config['source'])
            {
                case 'query_string' :
                    $this->current_page = isset($_GET[$this->config['key']]) ? (int)$_GET[$this->config['key']] : 1;
                    break;
                case 'route' :
                    $this->current_page = (int)HttpIO::param($this->config['key'], 1);
                    break;
                case 'default' :
                default :
                    $this->current_page = isset(HttpIO::$params['arguments'][$this->config['key']])?(int)HttpIO::$params['arguments'][$this->config['key']] : 1;
                    break;
            }
        }
    }
    else
    {
        $this->current_page = (int)max(1, $this->current_page);
    }

    $this->items_per_page = (int)$this->items_per_page;
    if (!$this->items_per_page>0)
    {
        $this->items_per_page = (int)max(1, $this->config['items_per_page']);
    }

    $this->total_pages        = (int)ceil($this->total_items / $this->items_per_page);
    $this->current_page       = (int)min(max(1, $this->current_page), max(1, $this->total_pages));
    $this->current_first_item = (int)min((($this->current_page - 1) * $this->items_per_page) + 1, $this->total_items);
    $this->current_last_item  = (int)min($this->current_first_item + $this->items_per_page - 1, $this->total_items);
    $this->previous_page      = ($this->current_page > 1) ? $this->current_page - 1 : false;
    $this->next_page          = ($this->current_page < $this->total_pages) ? $this->current_page + 1 : false;
    $this->first_page         = ($this->current_page === 1) ? false : 1;
    $this->last_page          = ($this->current_page >= $this->total_pages) ? false : $this->total_pages;
    $this->offset             = (int)(($this->current_page - 1) * $this->items_per_page);
}