diff --git a/core/attributedef/AttributeClassState.php b/core/attributedef/AttributeClassState.php new file mode 100644 index 000000000..e2d66a13f --- /dev/null +++ b/core/attributedef/AttributeClassState.php @@ -0,0 +1,77 @@ +Get('class_field'); + $sClass = $oHostObj->Get($sTargetClass); + + $aAllowedStates = array(); + foreach (MetaModel::EnumChildClasses($sClass, ENUM_CHILD_CLASSES_ALL) as $sChildClass) { + $aValues = MetaModel::EnumStates($sChildClass); + foreach (array_keys($aValues) as $sState) { + $aAllowedStates[$sState] = $sState . ' (' . MetaModel::GetStateLabel($sChildClass, $sState) . ')'; + } + } + return $aAllowedStates; + } + + return null; + } + + public function GetAsHTML($sValue, $oHostObject = null, $bLocalize = true) + { + if (empty($sValue)) { + return ''; + } + + if (!empty($oHostObject)) { + $sTargetClass = $this->Get('class_field'); + $sClass = $oHostObject->Get($sTargetClass); + foreach (MetaModel::EnumChildClasses($sClass, ENUM_CHILD_CLASSES_ALL) as $sChildClass) { + $aValues = MetaModel::EnumStates($sChildClass); + if (in_array($sValue, $aValues)) { + $sLabelForHtmlAttribute = utils::EscapeHtml($sValue . ' (' . MetaModel::GetStateLabel($sChildClass, $sValue) . ')'); + $sHTML = '' . $sValue . ''; + + return $sHTML; + } + } + } + + return $sValue; + } + +} \ No newline at end of file