Пример #1
0
 /**
  * A function for setting fields.
  *
  * @param string $key Object's field name.
  * @param mixed $value
  * @return true
  */
 public function set($key, $value)
 {
     $key = trim($key, '_');
     switch ($key) {
         case 'chunk':
         case 'around':
             $value = (int) $value;
             break;
     }
     return parent::set($key, $value);
 }
Пример #2
0
 /**
  * A function for setting fields.
  *
  * @param string $key Object's field name.
  * @param mixed $value
  * @return true
  */
 public function set($key, $value)
 {
     $key = trim($key, '_');
     switch ($key) {
         case 'range':
             if ($value < 1) {
                 $value = 1;
             }
             $value = (int) $value;
             break;
     }
     return parent::set($key, $value);
 }
Пример #3
0
 /**
  * A function for setting fields.
  *
  * @param string $key Object's field name.
  * @param mixed $value
  * @return true
  */
 public function set($key, $value)
 {
     $key = trim($key, '_');
     switch ($key) {
         case 'stepping':
             $value = (int) $value;
             break;
         case 'steps':
             $value = (bool) $value;
             break;
     }
     return parent::set($key, $value);
 }
Пример #4
0
 /**
  * A function to setting fields.
  * 
  * @param string $key Object's field name.
  * @param mixed $value
  * @return true
  */
 public function set($key, $value)
 {
     switch ($key) {
         case 'offset':
             if ($value >= $this->get('all')) {
                 throw new Opc_PaginatorPageNotFound_Exception('offset: ' . $value);
             }
             $this->{$key} = $value;
             $this->page = $this->offset / $this->get('limit') + 1;
             break;
         case 'page':
             if ($value < 1 || $value > $this->get('pageCount')) {
                 throw new Opc_PaginatorPageNotFound_Exception($value);
             }
             $this->{$key} = (int) $value;
             $this->offset = $this->get('limit') * ($this->page - 1);
             break;
         case 'decorator':
             if (is_string($value)) {
                 $decoratorClass = Opc_Paginator::getDecoratorClassName($value);
                 if (!$decoratorClass) {
                     throw new Opc_PaginatorUndefinedDecorator_Exception($value);
                 }
                 $this->_decorator = new $decoratorClass();
                 if (!is_subclass_of($this->_decorator, 'Opc_Paginator_Decorator')) {
                     throw new Opc_PaginatorWrongSubclassDecorator_Exception(get_class($value));
                 }
                 $this->_decorator->setPaginator($this);
             } elseif (is_object($value)) {
                 if (!is_subclass_of($value, 'Opc_Paginator_Decorator')) {
                     throw new Opc_PaginatorWrongSubclassDecorator_Exception(get_class($value));
                 }
                 $this->_decorator = clone $value;
                 $this->_decorator->setPaginator($this);
             } else {
                 throw new Opc_PaginatorUndefinedDecorator_Exception((string) $value);
             }
             $this->state(self::STATE_DIRTY);
             break;
         case 'all':
             $this->{$key} = (int) $value;
             break;
         case 'limit':
             $this->{$key} = (int) $value;
             if ($this->{$key} < 1) {
                 throw new Opc_OptionInvalid_Exception($key, get_class($this), 'grater than 0');
             }
             break;
         case 'page_float':
         case 'first':
         case 'last':
         case 'previous':
         case 'next':
             throw new Opc_OptionReadOnly_Exception($key, get_class($this));
             break;
         default:
             throw new Opc_OptionNotExists_Exception($key, get_class($this));
             break;
     }
     $this->state(self::STATE_DIRTY);
     return true;
 }