コード例 #1
0
ファイル: Validate.class.php プロジェクト: Nivl/Ninaca_1
 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;
 }
コード例 #2
0
 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);
         }
     }
 }
コード例 #3
0
ファイル: String.class.php プロジェクト: Nivl/Ninaca_1
 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;
 }
コード例 #4
0
ファイル: ValidateBool.class.php プロジェクト: Nivl/Ninaca_1
 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;
 }
コード例 #5
0
ファイル: Task.class.php プロジェクト: Nivl/Ninaca_1
 public function hasDescription()
 {
     return !Misc::isEmpty($this->description);
 }
コード例 #6
0
ファイル: Ftp.class.php プロジェクト: Nivl/Ninaca_1
 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;
 }
コード例 #7
0
ファイル: FormField.class.php プロジェクト: Nivl/Ninaca_1
 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 '';
 }