/** * Returns list of valid template placeholders for the specified bundle. These placeholders always begin * with a caret ("^") and will be replaced with content values when a bundle display is rendered by xxx() * * @param $ps_bundle_name - name of bundle * @return array - list of placeholders as keys; values are text description of value; will return null if bundle name is invalid */ public function getTemplatePlaceholderListForBundle($ps_bundle_name) { $o_dm = $this->getAppDatamodel(); $t_instance = null; $va_tmp = explode('.', $ps_bundle_name); switch (sizeof($va_tmp)) { case 2: $vs_table = $va_tmp[0]; $vs_bundle = $va_tmp[1]; if ($vs_bundle == 'rel') { $vs_bundle = 'preferred_labels'; } break; case 1: if (!($t_instance = $o_dm->getInstanceByTableName($va_tmp[0], true))) { $vs_table = $o_dm->getTableName($this->get('table_num')); $vs_bundle = $va_tmp[0]; } else { $vs_table = $va_tmp[0]; $vs_bundle = 'preferred_labels'; } break; default: return null; break; } if (!$t_instance) { if (!($t_instance = $o_dm->getInstanceByTableName($vs_table, true))) { return null; } } $va_key = array('^label' => array('label' => _t('Placement label'), 'description' => _t('The label for this placement as defined in the placements settings. The value used will be adjusted to reflect the current user's locale.'))); if ($t_instance->hasField($vs_bundle)) { // is intrinsic field $va_key["^{$vs_bundle}"] = array('label' => $t_instance->getFieldInfo($vs_bundle, 'LABEL'), 'description' => $t_instance->getFieldInfo($vs_bundle, 'DESCRIPTION')); return $va_key; } $va_element_codes = array_flip($t_instance->getApplicableElementCodes(null, false, false)); if ($va_element_codes[$vs_bundle]) { $t_element = new ca_metadata_elements(); if ($this->inTransaction()) { $t_element->setTransaction($this->getTransaction()); } if ($t_element->load(array('element_code' => $vs_bundle))) { // is attribute $va_hier = $t_element->getElementsInSet(); if (is_array($va_hier) && sizeof($va_hier) > 0) { // is container with children foreach ($va_hier as $va_node) { if ($va_node['datatype'] == 0) { continue; } // skip containers $va_key['^' . $va_node['element_code']] = array('label' => $t_instance->getAttributeLabel($va_node['element_code']), 'description' => $t_instance->getAttributeDescription($va_node['element_code'])); } return $va_key; } // is simple single-element attribute $va_key["^{$vs_bundle}"] = array('label' => $t_instance->getAttributeLabel($vs_bundle), 'description' => $t_instance->getAttributeDescription($vs_bundle)); return $va_key; } } if ($vs_bundle == 'preferred_labels') { if ($t_label = $t_instance->getLabelTableInstance()) { foreach ($t_label->getFormFields() as $vs_field => $va_field_info) { $va_key['^' . $vs_field] = array('label' => $va_field_info['LABEL'], 'description' => $va_field_info['DESCRIPTION']); } return $va_key; } } if ($vs_bundle == 'nonpreferred_labels') { if ($t_label = $t_instance->getLabelTableInstance()) { foreach ($t_label->getFormFields() as $vs_field => $va_field_info) { $va_key['^' . $vs_field] = array('label' => $va_field_info['LABEL'], 'description' => $va_field_info['DESCRIPTION']); } return $va_key; } } if ($vs_bundle == 'ca_object_representations') { if ($vs_table == 'ca_objects') { $t_rep = new ca_object_representations(); foreach ($t_rep->getFormFields() as $vs_field => $va_field_info) { $va_key['^' . $vs_field] = array('label' => $va_field_info['LABEL'], 'description' => $va_field_info['DESCRIPTION']); } $va_key['^media:{version name}'] = array('label' => _t('Specified version of media'), 'description' => _t('The version of the media representation specified by {version name} for display.')); return $va_key; } } return null; }