コード例 #1
0
ファイル: PathInput.php プロジェクト: robbrandt/Avatar
 function validate(Zikula_Form_View $view)
 {
     parent::validate($view);
     if (!$this->isValid) {
         return;
     }
     if ($this->text != '') {
         if (!is_dir($this->text) || !is_readable($this->text)) {
             $this->setError(__f('The path %s does not exist or is not readable by the webserver.', $this->text));
         } elseif ($this->writable == true && !is_writable($this->text)) {
             $this->setError(__f('The webserver cannot write to %s.', $this->text));
         } else {
             if ($this->removeSlash == true) {
                 do {
                     $hasSlash = false;
                     if (StringUtil::right($this->text, 1) == '/') {
                         $hasSlash = true;
                         $this->text = StringUtil::left($this->text, strlen($this->text) - 1);
                     }
                 } while ($hasSlash == true);
             }
         }
     } else {
         $this->setError(__('Error! Missing path.'));
     }
 }
コード例 #2
0
ファイル: EmailInput.php プロジェクト: Silwereth/core
 /**
  * Validates the input.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return void
  */
 public function validate(Zikula_Form_View $view)
 {
     parent::validate($view);
     if (!$this->isValid) {
         return;
     }
     if (!empty($this->text)) {
         if (!System::varValidate($this->text, 'email')) {
             $this->setError(__('Error! Invalid e-mail address.'));
         }
     }
 }
コード例 #3
0
ファイル: IntInput.php プロジェクト: projectesIF/Sirius
 /**
  * Validates the input.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return void
  */
 public function validate(Zikula_Form_View $view)
 {
     parent::validate($view);
     if (!$this->isValid) {
         return;
     }
     if ($this->text !== '') {
         $i = (int) $this->text;
         if ($this->minValue !== null && $i < $this->minValue || $this->maxValue !== null && $i > $this->maxValue) {
             if ($this->minValue !== null && $this->maxValue !== null) {
                 $this->setError(__f('Error! Range error. Value must be between %1$s and %2$s.', array($this->minValue, $this->maxValue)));
             } elseif ($this->minValue !== null) {
                 $this->setError(__f('Error! The value must be %s or more.', $this->minValue));
             } elseif ($this->maxValue !== null) {
                 $this->setError(__f('Error! The value must be %s or less.', $this->maxValue));
             }
         }
     }
 }
コード例 #4
0
ファイル: DateInput.php プロジェクト: projectesIF/Sirius
 /**
  * Validates the input string.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return void
  */
 public function validate(Zikula_Form_View $view)
 {
     parent::validate($view);
     if (!$this->isValid) {
         return;
     }
     if (strlen($this->text) > 0) {
         if ($this->includeTime) {
             $dateValue = DateUtil::transformInternalDateTime(DateUtil::parseUIDate($this->text, $this->ifFormat));
         } else {
             $dateValue = DateUtil::transformInternalDate(DateUtil::parseUIDate($this->text, $this->ifFormat));
         }
         if ($dateValue == null) {
             $this->setError(__('Error! Invalid date.'));
         } else {
             // the date validated so we can use the transformed date
             $this->text = $dateValue;
         }
     }
 }
コード例 #5
0
ファイル: FloatInput.php プロジェクト: projectesIF/Sirius
 /**
  * Validates the input.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return void
  */
 public function validate(Zikula_Form_View $view)
 {
     parent::validate($view);
     if (!$this->isValid) {
         return;
     }
     if ($this->text !== '') {
         $this->text = DataUtil::transformNumberInternal($this->text);
         if (!is_numeric($this->text)) {
             $this->setError(__('Error! Invalid number.'));
         }
         $i = $this->text;
         if ($this->minValue !== null && $i < $this->minValue || $this->maxValue !== null && $i > $this->maxValue) {
             if ($this->minValue !== null && $this->maxValue !== null) {
                 $this->setError(__f('Error! Range error. Value must be between %1$s and %2$s.', array($this->minValue, $this->maxValue)));
             } elseif ($this->minValue !== null) {
                 $this->setError(__f('Error! The value must be %s or more.', $this->minValue));
             } elseif ($this->maxValue !== null) {
                 $this->setError(__f('Error! The value must be %s or less.', $this->maxValue));
             }
         }
     }
 }
コード例 #6
0
ファイル: ColourInput.php プロジェクト: rmaiwald/Reviews
 /**
  * Validates the input string.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return boolean
  */
 public function validate(Zikula_Form_View $view)
 {
     parent::validate($view);
     if (!$this->isValid) {
         return;
     }
     if (strlen($this->text) > 0) {
         $regex = '/^#?(([a-fA-F0-9]{3}){1,2})$/';
         $result = preg_match($regex, $this->text);
         if (!$result) {
             $this->setError(__('Error! Invalid colour.'));
             return false;
         }
     }
 }