/** * Make the most relevant label, given the value of the expression * * @param DBSearch oFilter The context in which this expression has been used * @param string sValue The value returned by the query, for this expression * @param string sDefault The default value if no relevant label could be computed * @return The label */ public function MakeValueLabel($oFilter, $sValue, $sDefault) { $sAttCode = $this->GetName(); $sParentAlias = $this->GetParent(); $aSelectedClasses = $oFilter->GetSelectedClasses(); $sClass = $aSelectedClasses[$sParentAlias]; $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode); // Set a default value for the general case $sRes = $oAttDef->GetAsHtml($sValue); // Exceptions... if ($oAttDef->IsExternalKey()) { $sObjClass = $oAttDef->GetTargetClass(); $iObjKey = (int) $sValue; if ($iObjKey > 0) { $oObject = MetaModel::GetObject($sObjClass, $iObjKey); $sRes = $oObject->GetHyperlink(); } else { // Undefined $sRes = DBObject::MakeHyperLink($sObjClass, 0); } } elseif ($oAttDef->IsExternalField()) { if (is_null($sValue)) { $sRes = Dict::S('UI:UndefinedObject'); } } return $sRes; }