コード例 #1
0
 /**
  * 
  * set control states
  */
 private static function setStates(JForm $form)
 {
     self::$arrStates = array();
     foreach (self::$arrIndexChildren as $childName => $arrParents) {
         $childStates = array("disabled" => false, "hidden" => false);
         if (array_key_exists($childName, self::$arrStates)) {
             $childStates = self::$arrStates[$childName];
         }
         foreach ($arrParents as $arrParent) {
             $parentName = $arrParent["parent"];
             $parentField = self::getFormField($form, $parentName);
             $parentValue = $parentField->value;
             $controlValue = $arrParent["value"];
             $ctype = $arrParent["ctype"];
             $valueMatch = $controlValue == $parentValue;
             switch ($ctype) {
                 case self::TYPE_ENABLE:
                     $childStates["disabled"] = !$valueMatch;
                     break;
                 case self::TYPE_DISABLE:
                     $childStates["disabled"] = $valueMatch;
                     break;
                 case self::TYPE_SHOW:
                     $childStates["hidden"] = !$valueMatch;
                     break;
                 case self::TYPE_HIDE:
                     $childStates["hidden"] = $valueMatch;
                     break;
                 default:
                     UniteFunctionsRev::throwError("Wrong ctype: " . $ctype);
                     break;
             }
             self::$arrStates[$childName] = $childStates;
         }
     }
 }