コード例 #1
0
ファイル: link.php プロジェクト: bizanto/Hooked
 public function _validateSubmission($value, $params)
 {
     $values = $value;
     $validator = new YValidatorString(array('required' => false));
     $text = $validator->clean($values->get('text'));
     $target = $validator->clean($values->get('target'));
     $custom_title = $validator->clean($values->get('custom_title'));
     $rel = $validator->clean($values->get('rel'));
     $validator = new YValidatorUrl(array('required' => $params->get('required')), array('required' => 'Please enter an URL.'));
     $value = $validator->clean($values->get('value'));
     return compact('value', 'text', 'target', 'custom_title', 'rel');
 }
コード例 #2
0
ファイル: video.php プロジェクト: bizanto/Hooked
 public function validateSubmission($value, $params)
 {
     $validator = new YValidatorUrl(array('required' => $params->get('required')), array('required' => 'Please enter an URL.'));
     $url = $validator->clean($value->get('url'));
     if ($url) {
         // get video format
         $format = $this->getVideoFormat($url);
         // filter file formats
         $formats = array_filter($this->_getVideoFormats(), create_function('$a', 'return isset($a["regex"]);'));
         if (!in_array($format, array_keys($formats))) {
             throw new YValidatorException('Not a valid video format.');
         }
     }
     $validator = new YValidatorInteger(array('required' => false), array('number' => 'The Width needs to be a number.'));
     $width = $validator->clean($value->get('width'));
     $width = empty($width) ? '' : $width;
     $validator = new YValidatorInteger(array('required' => false), array('number' => 'The Height needs to be a number.'));
     $height = $validator->clean($value->get('height'));
     $height = empty($height) ? '' : $height;
     $autoplay = $value->get('autoplay');
     return compact('url', 'format', 'width', 'height', 'autoplay');
 }