public function validation($value) { if (!empty($this->options['callback']) && is_array($this->options['callback'])) { foreach ($this->options['callback'] as $callback) { $value = call_user_func($callback, $value); } } if (!is_array($value)) { $value = trim($value); } if (Misc::isEmpty($value)) { if ($this->options['allowEmpty']) { return $value; } else { $this->errors[] = _("This field must be filled-in."); } } else { if ($value === null && $this->options['required']) { $this->errors[] = _("This field is required."); } else { $value = $this->execute($value); } } return $value; }
private function moveTableClasses() { if ($this->getOptionsValue('generate-table') === true) { if (!Misc::isEmpty($to = $this->getOptionsValue('table-dir'))) { $from = $this->getOptionsValue('models-path'); $to = $from . '/' . $to; $opt = array('suffix' => 'Table' . self::getOptionsValue('suffix')); Ftp::moveFiles($from, $to, false, false, $opt); } } }
static function countCharOccurrence($char, $string) { if (Misc::isEmpty($char) || Misc::isEmpty($string)) { return false; } $len = self::lenght($string); $occ = 0; for ($i = 0; $i < $len; ++$i) { if ($string[$i] == $char) { ++$occ; } } return $occ; }
protected function execute($value) { //var_dump($value); $true = array('1', 'on', 'true', 'yes'); $false = array('0', 'off', 'false', 'no'); if (Misc::isEmpty($value) || in_array($value, $false)) { $value = false; } else { if (in_array($value, $true)) { $value = true; } else { $this->errors[] = _("This field must be a boolean."); } } //var_dump($value); return $value; }
public function hasDescription() { return !Misc::isEmpty($this->description); }
public static function getDirs($dir, array $except = array('.', '..')) { if (Misc::isEmpty($dir) || !@($directory = opendir($dir))) { return false; } $dirs = array(); while ($file = readdir($directory)) { if (is_dir($dir . '/' . $file) && !in_array($file, $except)) { $dirs[] = $file; } } closedir($directory); return $dirs; }
public function getValue($protect = false) { if (is_array($this->value)) { if ($protect) { return array_map(array('Security', 'noHTML'), $this->value); } else { return $this->value; } } else { if (!Misc::isEmpty($this->value)) { return $protect ? Security::noHTML($this->value) : $this->value; } else { if ($this->bound && !Misc::isEmpty($this->def_value)) { return $protect ? Security::noHTML($this->def_value) : $this->def_value; } } } return ''; }