/** * Returns display label for element specified by standard "get" bundle code (eg. <table_name>.<bundle_name> format) */ public function getDisplayLabel($ps_field) { $va_tmp = explode('.', $ps_field); if (sizeof($va_tmp) == 2 && $va_tmp[0] == $this->getLabelTableName() && $va_tmp[1] == $this->getLabelDisplayField()) { $va_tmp[0] = $this->tableName(); $va_tmp[1] = 'preferred_labels'; $ps_field = join('.', $va_tmp); } switch (sizeof($va_tmp)) { # ------------------------------------- case 1: // table_name if ($t_instance = $this->_DATAMODEL->getInstanceByTableName($va_tmp[0], true)) { return _t("Related %1", $t_instance->getProperty('NAME_PLURAL')); } break; # ------------------------------------- # ------------------------------------- case 2: // table_name.field_name // table_name.field_name case 3: // table_name.field_name.sub_element if (!($t_instance = $this->_DATAMODEL->getInstanceByTableName($va_tmp[0], true))) { break; } $vs_prefix = $vs_suffix = ''; $vs_suffix_string = ' (' . _t('from related %1', $t_instance->getProperty('NAME_PLURAL')) . ')'; if ($va_tmp[0] !== $this->tableName()) { $vs_suffix = $vs_suffix_string; } switch ($va_tmp[1]) { # -------------------- case 'related': unset($va_tmp[1]); $vs_label = $this->getDisplayLabel(join('.', $va_tmp)); if ($va_tmp[0] != $this->tableName()) { return $vs_label . $vs_suffix_string; } return $vs_label; break; # -------------------- # -------------------- case 'preferred_labels': if (method_exists($t_instance, 'getLabelTableInstance') && ($t_label_instance = $t_instance->getLabelTableInstance())) { if (!isset($va_tmp[2])) { return unicode_ucfirst($t_label_instance->getProperty('NAME_PLURAL')) . $vs_suffix; } else { return unicode_ucfirst($t_label_instance->getDisplayLabel($t_label_instance->tableName() . '.' . $va_tmp[2])) . $vs_suffix; } } break; # -------------------- # -------------------- case 'nonpreferred_labels': if (method_exists($t_instance, 'getLabelTableInstance') && ($t_label_instance = $t_instance->getLabelTableInstance())) { if ($va_tmp[0] !== $this->tableName()) { $vs_suffix = ' (' . _t('alternates from related %1', $t_instance->getProperty('NAME_PLURAL')) . ')'; } else { $vs_suffix = ' (' . _t('alternates') . ')'; } if (!isset($va_tmp[2])) { return unicode_ucfirst($t_label_instance->getProperty('NAME_PLURAL')) . $vs_suffix; } else { return unicode_ucfirst($t_label_instance->getDisplayLabel($t_label_instance->tableName() . '.' . $va_tmp[2])) . $vs_suffix; } } break; # -------------------- # -------------------- case 'media': if ($va_tmp[0] === 'ca_object_representations') { if ($va_tmp[2]) { return _t('Object media representation (%1)', $va_tmp[2]); } else { return _t('Object media representation (default)'); } } break; # -------------------- # -------------------- default: if ($va_tmp[0] !== $this->tableName()) { return unicode_ucfirst($t_instance->getDisplayLabel($ps_field)) . $vs_suffix; } break; # -------------------- } break; # ------------------------------------- } // maybe it's a special bundle name? if ($va_tmp[0] === $this->tableName() && isset($this->BUNDLES[$va_tmp[1]]) && $this->BUNDLES[$va_tmp[1]]['label']) { return $this->BUNDLES[$va_tmp[1]]['label']; } return parent::getDisplayLabel($ps_field); }