/**
  * Get the validation rule (regular expression)
  * @internal
  * @return string
  */
 public function getCheck()
 {
     $strReturn = "";
     if (!empty($this->__validation)) {
         $strReturn = $this->__validation;
     } else {
         $strReturn = Validator::getCheck($this->__field->getType());
     }
     return $strReturn;
 }
 /**
  * Get the validation rule (regular expression)
  * @internal
  * @return string
  */
 public function getCheck()
 {
     $strReturn = "";
     switch ($this->__field->getType()) {
         case ValidForm::VFORM_CUSTOM:
         case ValidForm::VFORM_CUSTOM_TEXT:
             $strReturn = $this->__validation;
             break;
         default:
             $strReturn = Validator::getCheck($this->__field->getType());
     }
     return $strReturn;
 }
Пример #3
0
 /**
  * Convert the Comparion's contents to a json string in order to validate this comparison client-side
  *
  * @internal
  * @param string $intDynamicPosition
  * @return string The generated JSON
  */
 public function jsonSerialize($intDynamicPosition = null)
 {
     if (get_class($this->__subject) == "ValidFormBuilder\\GroupField") {
         $identifier = $this->__subject->getId();
     } else {
         $identifier = $this->__subject->getName();
         if ($intDynamicPosition > 0) {
             $identifier = $identifier . "_" . $intDynamicPosition;
         }
     }
     $arrReturn = array("subject" => $identifier, "comparison" => $this->__comparison, "value" => $this->__value);
     return $arrReturn;
 }
Пример #4
0
 /**
  * toJson method creates an array representation of the current condition object and all
  * of it's comparions.
  *
  * In the future this class should extend the JsonSerializable interface
  * (http://php.net/manual/en/class.jsonserializable.php). Since this is only
  * supported in PHP >= 5.4, we now use our own implementation.
  *
  * @internal
  * @return array An array representation of this object and it's comparisons.
  */
 public function jsonSerialize($intDynamicPosition = null)
 {
     if (get_class($this->__subject) == "ValidFormBuilder\\GroupField" || get_class($this->__subject) == "ValidFormBuilder\\Area") {
         $identifier = $this->__subject->getId();
     } elseif (get_class($this->__subject) == "ValidFormBuilder\\StaticText") {
         $identifier = $this->__subject->getMeta("id");
     } else {
         $identifier = $this->__subject->getName();
         if ($intDynamicPosition > 0) {
             $identifier = $identifier . "_" . $intDynamicPosition;
         }
     }
     $arrReturn = array("subject" => $identifier, "property" => $this->__property, "value" => $this->__value, "comparisonType" => $this->__comparisontype, "comparisons" => array());
     foreach ($this->__comparisons as $objComparison) {
         array_push($arrReturn["comparisons"], $objComparison->jsonSerialize($intDynamicPosition));
     }
     return $arrReturn;
 }
Пример #5
0
 /**
  * Check if an element should be visible according to an optionally attached "visible" condition.
  *
  * @param Base $objElement
  * @param $intDynamicCount
  * @return bool|true
  */
 protected function elementShouldDisplay(Base $objElement, $intDynamicCount = 0)
 {
     $blnReturn = true;
     $objCondition = $objElement->getConditionRecursive("visible");
     if (is_object($objCondition)) {
         if ($objCondition->isMet($intDynamicCount)) {
             $blnReturn = $objCondition->getValue();
         } else {
             $blnReturn = !$objCondition->getValue();
         }
     }
     return $blnReturn;
 }