Beispiel #1
0
 private static function validateVars($context, GWF_Form $form, $validator)
 {
     $errors = array();
     $method = $form->getMethod();
     foreach ($form->getFormData() as $key => $data) {
         # Skippers
         if (in_array($data[0], self::$SKIPPERS, true) || $data[0] === GWF_Form::SUBMITS || $data[0] === GWF_Form::SUBMIT_IMGS) {
             continue;
         }
         # Captcha
         if ($data[0] === GWF_Form::CAPTCHA) {
             if (false !== ($error = self::validateCaptcha($context, $form, $validator, $key))) {
                 $errors[] = $error;
             }
             continue;
         }
         # Get forms do not validate mo/me
         if ($method === GWF_Form::METHOD_GET) {
             if ($key === 'mo' || $key === 'me') {
                 continue;
             }
         }
         # Validators
         $func_name = 'validate_' . Common::substrUntil($key, '[', $key);
         $function = array($validator, $func_name);
         if (!method_exists($validator, $func_name)) {
             $errors[] = GWF_HTML::lang('ERR_METHOD_MISSING', array($func_name, get_class($validator)));
         } elseif (false !== ($error = call_user_func($function, $context, $form->getVar($key)))) {
             $errors[] = $error;
         }
     }
     return count($errors) === 0 ? false : $errors;
 }