diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index 3d0158c0f..b1273c19a 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -3992,6 +3992,29 @@ class AttributeDuration extends AttributeInteger $seconds = ($duration % 60); // modulo return array( 'days' => $days, 'hours' => $hours, 'minutes' => $minutes, 'seconds' => $seconds ); } + + static public function GetFormFieldClass() + { + return '\\Combodo\\iTop\\Form\\Field\\LabelField'; + } + + public function MakeFormField(DBObject $oObject, $oFormField = null) + { + if ($oFormField === null) + { + $sFormFieldClass = static::GetFormFieldClass(); + $oFormField = new $sFormFieldClass($this->GetCode()); + } + parent::MakeFormField($oObject, $oFormField); + + // Note : As of today, this attribute is -by nature- only supported in readonly mode, not edition + $sAttCode = $this->GetCode(); + $oFormField->SetCurrentValue(html_entity_decode($oObject->GetAsHTML($sAttCode), ENT_QUOTES, 'UTF-8')); + $oFormField->SetReadOnly(true); + + return $oFormField; + } + } /** * Map a date+time column to an attribute @@ -4690,6 +4713,32 @@ class AttributeExternalField extends AttributeDefinition return $oExtAttDef->GetAsCSV($value, $sSeparator, $sTestQualifier, null, $bLocalize, $bConvertToPlainText); } + static public function GetFormFieldClass() + { + return '\\Combodo\\iTop\\Form\\Field\\LabelField'; + } + + public function MakeFormField(DBObject $oObject, $oFormField = null) + { + if ($oFormField === null) + { + $sFormFieldClass = static::GetFormFieldClass(); + $oFormField = new $sFormFieldClass($this->GetCode()); + } + parent::MakeFormField($oObject, $oFormField); + + // Note : As of today, this attribute is -by nature- only supported in readonly mode, not edition + $sAttCode = $this->GetCode(); + $sAttCodeFriendlyname = $sAttCode .= '_friendlyname'; + if ($this->IsExternalKey(EXTKEY_ABSOLUTE) && MetaModel::IsValidAttCode(get_class($oObject), $sAttCodeFriendlyname)) + { + $sAttCode = $sAttCodeFriendlyname; + } + $oFormField->SetCurrentValue(html_entity_decode($oObject->GetAsHTML($sAttCode), ENT_QUOTES, 'UTF-8')); + + return $oFormField; + } + public function IsPartOfFingerprint() { return false; @@ -5796,7 +5845,33 @@ class AttributeSubItem extends AttributeDefinition return $res; } - public function IsPartOfFingerprint() { return false; } + public function IsPartOfFingerprint() + { + return false; + } + + static public function GetFormFieldClass() + { + return '\\Combodo\\iTop\\Form\\Field\\LabelField'; + } + + public function MakeFormField(DBObject $oObject, $oFormField = null) + { + if ($oFormField === null) + { + $sFormFieldClass = static::GetFormFieldClass(); + $oFormField = new $sFormFieldClass($this->GetCode()); + } + parent::MakeFormField($oObject, $oFormField); + + // Note : As of today, this attribute is -by nature- only supported in readonly mode, not edition + $sAttCode = $this->GetCode(); + $oFormField->SetCurrentValue(html_entity_decode($oObject->GetAsHTML($sAttCode), ENT_QUOTES, 'UTF-8')); + $oFormField->SetReadOnly(true); + + return $oFormField; + } + } /** diff --git a/datamodels/2.x/itop-portal-base/portal/src/forms/objectformmanager.class.inc.php b/datamodels/2.x/itop-portal-base/portal/src/forms/objectformmanager.class.inc.php index f622d08f1..a456db9fb 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/forms/objectformmanager.class.inc.php +++ b/datamodels/2.x/itop-portal-base/portal/src/forms/objectformmanager.class.inc.php @@ -434,7 +434,7 @@ class ObjectFormManager extends FormManager $oAttDef = MetaModel::GetAttributeDef(get_class($this->oObject), $sAttCode); // TODO : Make AttributeDefinition::MakeFormField() for all kind of fields - if (in_array(get_class($oAttDef), array('AttributeString', 'AttributeEmailAddress', 'AttributeText', 'AttributeLongText', 'AttributeCaseLog', 'AttributeHTML', 'AttributeFriendlyName', 'AttributeEnum', 'AttributeExternalKey', 'AttributeCustomFields', 'AttributeLinkedSet', 'AttributeLinkedSetIndirect', 'AttributeDate', 'AttributeDateTime'))) + if (in_array(get_class($oAttDef), array('AttributeString', 'AttributeEmailAddress', 'AttributeText', 'AttributeLongText', 'AttributeCaseLog', 'AttributeHTML', 'AttributeFriendlyName', 'AttributeEnum', 'AttributeExternalKey', 'AttributeExternalField', 'AttributeHierarchicalKey', 'AttributeCustomFields', 'AttributeLinkedSet', 'AttributeLinkedSetIndirect', 'AttributeDate', 'AttributeDateTime', 'AttributeDuration', 'AttributeSubItem'))) { $oField = $oAttDef->MakeFormField($this->oObject); @@ -471,7 +471,7 @@ class ObjectFormManager extends FormManager { // Normal field } - + // Specific operation on field // - Field that require a transaction id if (in_array(get_class($oField), array('Combodo\\iTop\\Form\\Field\\TextAreaField', 'Combodo\\iTop\\Form\\Field\\CaseLogField'))) @@ -513,7 +513,7 @@ class ObjectFormManager extends FormManager $oField->SetReadOnly(true); } } - + $oForm->AddField($oField); } else