Ejemplo n.º 1
0
 private function validateYoutube($fieldName)
 {
     $fieldData = $this->fields[$fieldName];
     $required = $fieldData['required'] === true ? true : false;
     $missingError = isset($fieldData['options']['missingError']) ? $fieldData['options']['missingError'] : "missingError for field {$fieldName} not defined";
     $invalidError = isset($fieldData['options']['invalidError']) ? $fieldData['options']['invalidError'] : "invalidError for field {$fieldName} not defined";
     $value = isset($this->rsc[$fieldName]) ? trim($this->rsc[$fieldName]) : '';
     if ($required === true && $value == '') {
         $this->addError($fieldName, $missingError);
     }
     if ($value != '') {
         $request = new RestRequest("http://gdata.youtube.com/feeds/api/videos/{$value}");
         $request->stdRequest(array(), array('Accept: text/xml'));
         $responseInfo = $request->getResponseInfo();
         if (!isset($responseInfo['http_code']) || $responseInfo['http_code'] != '200') {
             $this->addError($fieldName, $invalidError);
         }
     }
     $this->setFieldValue($fieldName, $value);
 }