コード例 #1
0
 /**
  * Set the state data
  *
  * @param   array|object    An associative array of state data by name
  * @return  KModelPaginator
  */
 public function setData(array $data)
 {
     parent::setData($data);
     if ($this->total == 0) {
         $limit = 0;
         $offset = 0;
         $count = 0;
         $current = 0;
     } else {
         $total = (int) $this->total;
         $limit = (int) max($this->limit, 1);
         $offset = (int) max($this->offset, 0);
         if ($limit > $total) {
             $offset = 0;
         }
         if (!$this->limit) {
             $offset = 0;
             $limit = $total;
         }
         $count = (int) ceil($total / $limit);
         if ($offset > $total) {
             $offset = ($count - 1) * $limit;
         }
         $current = (int) floor($offset / $limit) + 1;
     }
     $this->limit = $limit;
     $this->offset = $offset;
     $this->count = $count;
     $this->current = $current;
     return $this;
 }
コード例 #2
0
ファイル: state.php プロジェクト: kosmosby/medicine-prof
    public function insert($name, $filter, $default = null, $unique = false, $required = array(), $internal = false)
    {
        if (in_array($name, self::$_internal)) {
            $internal = true;
        }

        return parent::insert($name, $filter, $default, $unique, $required, $internal);
    }