mirror of
https://github.com/Combodo/iTop.git
synced 2026-03-06 09:34:13 +01:00
Customer portal : Added support for some AttributeType in forms (AttributeExternalField, AttributeHierarchicalkey, AttributeSubItem, AttributeDuration)
SVN:trunk[4169]
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user