Пример #1
0
/**
 * Get all the fields xxx->yyy based on the field xxx which is an external key
 * @param string $sExtKeyAttCode Attribute code of the external key
 * @param AttributeDefinition $oExtKeyAttDef Attribute definition of the external key
 * @param bool $bAdvanced True if advanced mode
 * @return Ash List of codes=>display name: xxx->yyy where yyy are the reconciliation keys for the object xxx 
 */
function GetMappingsForExtKey($sAttCode, AttributeDefinition $oExtKeyAttDef, $bAdvanced)
{
    $aResult = array();
    $sTargetClass = $oExtKeyAttDef->GetTargetClass();
    foreach (MetaModel::ListAttributeDefs($sTargetClass) as $sTargetAttCode => $oTargetAttDef) {
        if (MetaModel::IsReconcKey($sTargetClass, $sTargetAttCode)) {
            $bExtKey = $oTargetAttDef->IsExternalKey();
            $sSuffix = '';
            if ($bExtKey) {
                $sSuffix = '->id';
            }
            if ($bAdvanced || !$bExtKey) {
                // When not in advanced mode do not allow to use reconciliation keys (on external keys) if they are themselves external keys !
                $aResult[$sAttCode . '->' . $sTargetAttCode] = $oExtKeyAttDef->GetLabel() . '->' . $oTargetAttDef->GetLabel() . $sSuffix;
            }
        }
    }
    return $aResult;
}
 public function GetLabel($sDefault = null)
 {
     $sLabel = parent::GetLabel('');
     if (strlen($sLabel) == 0) {
         $oRemoteAtt = $this->GetExtAttDef();
         $sLabel = $oRemoteAtt->GetLabel($this->m_sCode);
     }
     return $sLabel;
 }