Exemple #1
0
 public function __construct(array $options = NULL)
 {
     parent::__construct($options);
     if (empty($this->choices)) {
         throw new Sprig_Exception('Enum fields must declare the available choices');
     }
 }
Exemple #2
0
 public function value($value)
 {
     if (is_object($value)) {
         // Assume this is a Sprig object
         $value = $value->{$value->pk()};
     }
     return parent::value($value);
 }
Exemple #3
0
 public function value($value)
 {
     $value = parent::value($value);
     if (is_null($value)) {
         return inet_pton($_SERVER['REMOTE_ADDR']);
     } else {
         return Validate::ip($value) ? inet_pton($value) : inet_ntop($value);
     }
 }
Exemple #4
0
 public function __construct(array $options = NULL)
 {
     if (empty($options['path']) or !is_dir($options['path'])) {
         throw new Sprig_Exception('Image fields must have a directory path to save and load images from');
     }
     parent::__construct($options);
     // Make sure the path has a trailing slash
     $this->path = rtrim(str_replace('\\', '/', $this->path), '/') . '/';
 }
Exemple #5
0
 public function __construct(array $options = NULL)
 {
     if (empty($options['directory']) or !is_dir($options['directory'])) {
         throw new Sprig_Exception('Image fields must define a directory path');
     }
     // Normalize the directory path
     $options['directory'] = rtrim(str_replace(array('\\', '/'), '/', $options['directory']), '/') . '/';
     parent::__construct($options);
 }
Exemple #6
0
 public function __construct(array $options = NULL)
 {
     parent::__construct($options);
     if ($this->empty or $this->prompt) {
         Arr::unshift($this->codes, '', $this->prompt);
     }
     if (!$this->choices) {
         $this->choices = $this->codes;
     }
 }
Exemple #7
0
 public function value($value)
 {
     if (TRUE === $this->mysql_time) {
         if (is_integer($value)) {
             return date($this->_format, $value);
         } else {
             return date($this->_format, strtotime($value));
         }
     }
     if ($value and is_string($value) and !ctype_digit($value)) {
         $value = strtotime($value);
     }
     return parent::value($value);
 }