Beispiel #1
0
 /**
  * @see parent::checkProperty()
  */
 function checkProperty($object)
 {
     $propValue = $object->{$this->fieldName};
     // Root node surrounding
     $source = utf8_encode("<div>{$propValue}</div>");
     //for external html content => no validation
     if (stripos($source, "<html") !== false) {
         return null;
     }
     // Entity purge
     $source = preg_replace("/&\\w+;/i", "", $source);
     // Escape warnings, returns false if really invalid
     if (!@DOMDocument::loadXML($source)) {
         CModelObject::warning("Error-Html-document-bad-formatted");
         return "Le document HTML est mal formé, ou la requête n'a pas pu se terminer.";
     }
     return null;
 }
Beispiel #2
0
 /**
  * @see parent::checkProperty()
  */
 function checkProperty($object)
 {
     $propValue = CMbFieldSpec::checkNumeric($object->{$this->fieldName}, false);
     if ($propValue === null) {
         return "N'est pas une valeur décimale";
     }
     // pos
     if ($this->pos && $propValue <= 0) {
         return "Doit avoir une valeur positive";
     }
     // min
     if ($this->min) {
         if (!($min = CMbFieldSpec::checkNumeric($this->min, false))) {
             CModelObject::warning("Specification-de-minimum-numerique-invalide-min=min%d", $this->min);
             return "Erreur système";
         }
         if ($propValue < $min) {
             return "Doit avoir une valeur minimale de {$min}";
         }
     }
     // max
     if ($this->max) {
         $max = CMbFieldSpec::checkNumeric($this->max, false);
         if ($max === null) {
             CModelObject::warning("Specification-de-maximum-numerique-invalide-max=max%d", $this->max);
             return "Erreur système";
         }
         if ($propValue > $max) {
             return "Doit avoir une valeur maximale de {$max}";
         }
     }
     return null;
 }
 /**
  * @see parent::checkOptions()
  */
 function checkOptions()
 {
     parent::checkOptions();
     if (!$this->list) {
         CModelObject::warning("CEnumSpec-list-missing-for-field-fieldName%s-of-class-className%s", $this->fieldName, $this->className);
     }
 }
 /**
  * Check whether target field exists in object
  * 
  * @param object $object Object to scan
  * @param string $field  Field name
  * 
  * @return string Error-like message
  */
 function checkTargetPropValue($object, $field)
 {
     $fields = get_object_vars($object);
     if (!$field || $field === true || !is_scalar($field) || !array_key_exists($field, $fields)) {
         $class = get_class($this);
         CModelObject::warning("Element-cible-field%s-invalide-ou-inexistant-dans-la-classe%s", $field, $class);
         return "Erreur système";
     }
     return null;
 }