/**
  * Returns all available bundle display placements - those data bundles that can be displayed for the given content type, in other words.
  * The returned value is a list of arrays; each array contains a 'bundle' specifier than can be passed got Model::get() or SearchResult::get() and a display name
  *
  * @param mixed $pm_table_name_or_num The table name or number specifying the content type to fetch bundles for. If omitted the content table of the currently loaded display will be used.
  * @param array $pa_options Support options are
  *		no_cache = if set caching of underlying data required to generate list is disabled. This is required in certain situations such as during installation. Only set this if you suspect stale data is being used to generate the list. Eg. if you've been changing metadata attributes in the same request in which you call this method. Default is false.
  *		no_tooltips = if set no tooltips for available bundles will be emitted. Default is false - tooltips will be emitted.
  *		format = specifies label format for bundles. Valid values are "simple" (just the name of the element) or "full" (name of element, name of type of item element pertains to and alternate label, if defined). Default is "full"
  * @return array And array of bundles keyed on display label. Each value is an array with these keys:
  *		bundle = The bundle name (eg. ca_objects.idno)
  *		display = Display label for each available bundle
  *		description = Description of bundle
  * 
  * Will return null if table name or number is invalid.
  */
 public function getAvailableBundles($pm_table_name_or_num = null, $pa_options = null)
 {
     if (!$pm_table_name_or_num) {
         $pm_table_name_or_num = $this->get('table_num');
     }
     $pm_table_name_or_num = $this->getAppDatamodel()->getTableNum($pm_table_name_or_num);
     if (!$pm_table_name_or_num) {
         return null;
     }
     $vb_show_tooltips = isset($pa_options['no_tooltips']) && (bool) $pa_options['no_tooltips'] ? false : true;
     $vs_format = isset($pa_options['format']) && in_array($pa_options['format'], array('simple', 'full')) ? $pa_options['format'] : 'full';
     $t_instance = $this->getAppDatamodel()->getInstanceByTableNum($pm_table_name_or_num, false);
     $vs_table = $t_instance->tableName();
     $vs_table_display_name = $t_instance->getProperty('NAME_PLURAL');
     $va_available_bundles = array();
     $t_placement = new ca_bundle_display_placements(null, array());
     if ($this->inTransaction()) {
         $t_placement->setTransaction($this->getTransaction());
     }
     // get intrinsic fields
     $va_additional_settings = array('maximum_length' => array('formatType' => FT_NUMBER, 'displayType' => DT_FIELD, 'width' => 6, 'height' => 1, 'takesLocale' => false, 'default' => 100, 'label' => _t('Maximum length'), 'description' => _t('Maximum length, in characters, of displayed information.')));
     foreach ($t_instance->getFormFields() as $vs_f => $va_info) {
         if (isset($va_info['DONT_USE_AS_BUNDLE']) && $va_info['DONT_USE_AS_BUNDLE']) {
             continue;
         }
         if ($t_instance->getFieldInfo($vs_f, 'ALLOW_BUNDLE_ACCESS_CHECK')) {
             if (caGetBundleAccessLevel($vs_table, $vs_f) == __CA_BUNDLE_ACCESS_NONE__) {
                 continue;
             }
         }
         $vs_bundle = $vs_table . '.' . $vs_f;
         $vs_display = "<div id='bundleDisplayEditorBundle_{$vs_table}_{$vs_f}'><span class='bundleDisplayEditorPlacementListItemTitle'>" . caUcFirstUTF8Safe($t_instance->getProperty('NAME_SINGULAR')) . "</span> " . ($vs_label = $t_instance->getDisplayLabel($vs_bundle)) . "</div>";
         $va_available_bundles[strip_tags($vs_display)][$vs_bundle] = array('bundle' => $vs_bundle, 'display' => $vs_format == 'simple' ? $vs_label : $vs_display, 'description' => $vs_description = $t_instance->getDisplayDescription($vs_bundle), 'settingsForm' => $t_placement->getHTMLSettingForm(array('id' => $vs_bundle . '_0')), 'settings' => $va_additional_settings);
         if ($vb_show_tooltips) {
             TooltipManager::add("#bundleDisplayEditorBundle_{$vs_table}_{$vs_f}", $this->_formatBundleTooltip($vs_label, $vs_bundle, $vs_description));
         }
     }
     // get attributes
     $va_element_codes = $t_instance->getApplicableElementCodes(null, false, $pa_options['no_cache']);
     $t_md = new ca_metadata_elements();
     if ($this->inTransaction()) {
         $t_md->setTransaction($this->getTransaction());
     }
     $va_all_elements = $t_md->getElementsAsList();
     $va_additional_settings = array('format' => array('formatType' => FT_TEXT, 'displayType' => DT_FIELD, 'width' => 35, 'height' => 5, 'takesLocale' => false, 'default' => '', 'label' => _t('Display format'), 'description' => _t('Template used to format output.'), 'helpText' => ''), 'delimiter' => array('formatType' => FT_TEXT, 'displayType' => DT_FIELD, 'width' => 35, 'height' => 1, 'takesLocale' => false, 'default' => '', 'label' => _t('Delimiter'), 'description' => _t('Text to place in-between repeating values.')), 'maximum_length' => array('formatType' => FT_NUMBER, 'displayType' => DT_FIELD, 'width' => 6, 'height' => 1, 'takesLocale' => false, 'default' => 2048, 'label' => _t('Maximum length'), 'description' => _t('Maximum length, in characters, of displayed information.')), 'filter' => array('formatType' => FT_TEXT, 'displayType' => DT_FIELD, 'width' => 35, 'height' => 5, 'takesLocale' => false, 'default' => '', 'label' => _t('Filter using expression'), 'description' => _t('Expression to filter values with. Leave blank if you do not wish to filter values.')));
     foreach ($va_element_codes as $vn_element_id => $vs_element_code) {
         if (!is_null($va_all_elements[$vn_element_id]['settings']['canBeUsedInDisplay']) && !$va_all_elements[$vn_element_id]['settings']['canBeUsedInDisplay']) {
             continue;
         }
         $t_placement = new ca_bundle_display_placements(null, $va_additional_settings);
         if ($this->inTransaction()) {
             $t_placement->setTransaction($this->getTransaction());
         }
         if (caGetBundleAccessLevel($vs_table, $vs_element_code) == __CA_BUNDLE_ACCESS_NONE__) {
             continue;
         }
         switch ($va_all_elements[$vn_element_id]['datatype']) {
             case 3:
                 // list
                 $va_even_more_settings = array('sense' => array('formatType' => FT_TEXT, 'displayType' => DT_SELECT, 'width' => 20, 'height' => 1, 'takesLocale' => false, 'default' => 'singular', 'options' => array(_t('Singular') => 'singular', _t('Plural') => 'plural'), 'label' => _t('Sense'), 'description' => _t('Determines if value used is singular or plural version.')));
                 break;
             case 0:
                 // container (allows sub-elements to be summarized)
             // container (allows sub-elements to be summarized)
             case 6:
                 // Currency
             // Currency
             case 8:
                 // Length
             // Length
             case 9:
                 // Weight
             // Weight
             case 10:
                 // Timecode
             // Timecode
             case 11:
                 // Integer
             // Integer
             case 12:
                 // Numeric (decimal)
                 $va_even_more_settings = array('bottom_line' => array('formatType' => FT_TEXT, 'displayType' => DT_FIELD, 'width' => 35, 'height' => 5, 'takesLocale' => false, 'default' => '', 'label' => _t('Bottom line format'), 'description' => _t('Template to format aggregate data for display under this column. The template can include these aggregate data tags: ^PAGEAVG, ^AVG, ^PAGESUM, ^SUM, ^PAGEMin, ^MIN, ^PAGEMAX, ^MAX. For containers follow the tag with the element code of the subelement to aggregate. Ex. ^SUM:dimensions_width')));
                 if ($va_all_elements[$vn_element_id]['datatype'] == 6) {
                     $va_even_more_settings['display_currency_conversion'] = array('formatType' => FT_NUMBER, 'displayType' => DT_CHECKBOXES, 'width' => 10, 'height' => 1, 'takesLocale' => false, 'default' => '0', 'label' => _t('Display currency conversion?'), 'description' => _t('Check this option if you want your currency values to be displayed in both the specified and local currency.'));
                 }
                 break;
             default:
                 $va_even_more_settings = array();
                 break;
         }
         $vs_bundle = $vs_table . '.' . $vs_element_code;
         $va_even_more_settings['format'] = $va_additional_settings['format'];
         //$va_even_more_settings['format']['helpText'] = $this->getTemplatePlaceholderDisplayListForBundle($vs_bundle);
         $t_placement = new ca_bundle_display_placements(null, array_merge($va_additional_settings, $va_even_more_settings));
         if ($this->inTransaction()) {
             $t_placement->setTransaction($this->getTransaction());
         }
         $vs_display = "<div id='bundleDisplayEditorBundle_{$vs_table}_{$vs_element_code}'><span class='bundleDisplayEditorPlacementListItemTitle'>" . caUcFirstUTF8Safe($t_instance->getProperty('NAME_SINGULAR')) . "</span> " . ($vs_label = $t_instance->getDisplayLabel($vs_bundle)) . "</div>";
         $va_available_bundles[strip_tags($vs_display)][$vs_bundle] = array('bundle' => $vs_bundle, 'display' => $vs_format == 'simple' ? $vs_label : $vs_display, 'description' => $vs_description = $t_instance->getDisplayDescription($vs_bundle), 'settingsForm' => $t_placement->getHTMLSettingForm(array('id' => $vs_bundle . '_0')), 'settings' => array_merge($va_additional_settings, $va_even_more_settings));
         if ($vb_show_tooltips) {
             TooltipManager::add("#bundleDisplayEditorBundle_{$vs_table}_{$vs_element_code}", $this->_formatBundleTooltip($vs_label, $vs_bundle, $vs_description));
         }
     }
     if (caGetBundleAccessLevel($vs_table, "preferred_labels") != __CA_BUNDLE_ACCESS_NONE__) {
         // get preferred labels for this table
         $va_additional_settings = array('format' => array('formatType' => FT_TEXT, 'displayType' => DT_FIELD, 'width' => 35, 'height' => 5, 'takesLocale' => false, 'default' => '', 'label' => _t('Display format'), 'description' => _t('Template used to format output.')), 'delimiter' => array('formatType' => FT_TEXT, 'displayType' => DT_FIELD, 'width' => 35, 'height' => 1, 'takesLocale' => false, 'default' => '', 'label' => _t('Delimiter'), 'description' => _t('Text to place in-between repeating values.')), 'maximum_length' => array('formatType' => FT_NUMBER, 'displayType' => DT_FIELD, 'width' => 6, 'height' => 1, 'takesLocale' => false, 'default' => 100, 'label' => _t('Maximum length'), 'description' => _t('Maximum length, in characters, of displayed information.')));
         $t_placement = new ca_bundle_display_placements(null, $va_additional_settings);
         if ($this->inTransaction()) {
             $t_placement->setTransaction($this->getTransaction());
         }
         $vs_bundle = $vs_table . '.preferred_labels';
         $vs_display = "<div id='bundleDisplayEditorBundle_{$vs_table}_preferred_labels'><span class='bundleDisplayEditorPlacementListItemTitle'>" . caUcFirstUTF8Safe($t_instance->getProperty('NAME_SINGULAR')) . "</span> " . ($vs_label = $t_instance->getDisplayLabel($vs_bundle)) . "</div>";
         $va_available_bundles[strip_tags($vs_display)][$vs_bundle] = array('bundle' => $vs_bundle, 'display' => $vs_format == 'simple' ? $vs_label : $vs_display, 'description' => $vs_description = $t_instance->getDisplayDescription($vs_bundle), 'settingsForm' => $t_placement->getHTMLSettingForm(array('id' => $vs_bundle . '_0')), 'settings' => $va_additional_settings);
         if ($vb_show_tooltips) {
             TooltipManager::add("#bundleDisplayEditorBundle_{$vs_table}_preferred_labels", $this->_formatBundleTooltip($vs_label, $vs_bundle, $vs_description));
         }
     }
     if (caGetBundleAccessLevel($vs_table, "nonpreferred_labels") != __CA_BUNDLE_ACCESS_NONE__) {
         // get non-preferred labels for this table
         $t_placement = new ca_bundle_display_placements(null, $va_additional_settings);
         if ($this->inTransaction()) {
             $t_placement->setTransaction($this->getTransaction());
         }
         $vs_bundle = $vs_table . '.nonpreferred_labels';
         $vs_display = "<div id='bundleDisplayEditorBundle_{$vs_table}_nonpreferred_labels'><span class='bundleDisplayEditorPlacementListItemTitle'>" . caUcFirstUTF8Safe($t_instance->getProperty('NAME_SINGULAR')) . "</span> " . ($vs_label = $t_instance->getDisplayLabel($vs_bundle)) . "</div>";
         $va_available_bundles[strip_tags($vs_display)][$vs_bundle] = array('bundle' => $vs_bundle, 'display' => $vs_format == 'simple' ? $vs_label : $vs_display, 'description' => $vs_description = $t_instance->getDisplayDescription($vs_bundle), 'settingsForm' => $t_placement->getHTMLSettingForm(array('id' => $vs_bundle . '_0')), 'settings' => $va_additional_settings);
         if ($vb_show_tooltips) {
             TooltipManager::add("#bundleDisplayEditorBundle_{$vs_table}_nonpreferred_labels", $this->_formatBundleTooltip($vs_label, $vs_bundle, $vs_description));
         }
     }
     // get library checkout and commerce order history bundle (objects only, of course)
     if ($vs_table == 'ca_objects') {
         $va_additional_settings = array('order_type' => array('formatType' => FT_TEXT, 'displayType' => DT_SELECT, 'width' => 35, 'height' => 1, 'takesLocale' => false, 'default' => '', 'options' => array(_t('Sales order') => 'O', _t('Loan') => 'L'), 'label' => _t('Type of order'), 'description' => _t('Determines which type of order is displayed.')));
         $t_placement = new ca_bundle_display_placements(null, $va_additional_settings);
         if ($this->inTransaction()) {
             $t_placement->setTransaction($this->getTransaction());
         }
         $vs_bundle = 'ca_commerce_order_history';
         $vs_label = _t('Order history');
         $vs_display = _t('Order history');
         $vs_description = _t('List of orders (loans or sales) that include this object');
         $va_available_bundles[strip_tags($vs_display)][$vs_bundle] = array('bundle' => $vs_bundle, 'display' => $vs_format == 'simple' ? $vs_label : $vs_display, 'description' => $vs_description, 'settingsForm' => $t_placement->getHTMLSettingForm(array('id' => $vs_bundle . '_0')), 'settings' => $va_additional_settings);
         if ($vb_show_tooltips) {
             TooltipManager::add("#bundleDisplayEditorBundle_ca_commerce_order_history", $this->_formatBundleTooltip($vs_label, $vs_bundle, $vs_description));
         }
         $va_additional_settings = array('format' => array('formatType' => FT_TEXT, 'displayType' => DT_FIELD, 'width' => 35, 'height' => 5, 'takesLocale' => false, 'default' => '', 'label' => _t('Display format'), 'description' => _t('Template used to format output.')));
         $t_placement = new ca_bundle_display_placements(null, $va_additional_settings);
         if ($this->inTransaction()) {
             $t_placement->setTransaction($this->getTransaction());
         }
         $vs_bundle = 'ca_object_checkouts';
         $vs_label = _t('Library checkouts');
         $vs_display = "<div id='bundleDisplayEditorBundle_{$vs_table}_preferred_labels'><span class='bundleDisplayEditorPlacementListItemTitle'>" . caUcFirstUTF8Safe($t_instance->getProperty('NAME_SINGULAR')) . "</span> " . _t('Library checkouts') . "</div>";
         $vs_description = _t('List of library checkouts that include this object');
         $va_available_bundles[strip_tags($vs_display)][$vs_bundle] = array('bundle' => $vs_bundle, 'display' => $vs_format == 'simple' ? $vs_label : $vs_display, 'description' => $vs_description, 'settingsForm' => $t_placement->getHTMLSettingForm(array('id' => $vs_bundle . '_0')), 'settings' => $va_additional_settings);
         if ($vb_show_tooltips) {
             TooltipManager::add("#bundleDisplayEditorBundle_ca_object_checkouts", $this->_formatBundleTooltip($vs_label, $vs_bundle, $vs_description));
         }
         $va_additional_settings = array();
         $t_placement = new ca_bundle_display_placements(null, $va_additional_settings);
         if ($this->inTransaction()) {
             $t_placement->setTransaction($this->getTransaction());
         }
         $vs_bundle = $vs_table . '.ca_objects_location';
         $vs_label = _t('Current location');
         $vs_display = "<div id='bundleDisplayEditorBundle_{$vs_table}_ca_objects_location'><span class='bundleDisplayEditorPlacementListItemTitle'>" . caUcFirstUTF8Safe($t_instance->getProperty('NAME_SINGULAR')) . "</span> " . _t('Current location') . "</div>";
         $vs_description = _t('Current location of object');
         $va_available_bundles[strip_tags($vs_display)][$vs_bundle] = array('bundle' => $vs_bundle, 'display' => $vs_format == 'simple' ? $vs_label : $vs_display, 'description' => $vs_description, 'settingsForm' => $t_placement->getHTMLSettingForm(array('id' => $vs_bundle . '_0')), 'settings' => $va_additional_settings);
         if ($vb_show_tooltips) {
             TooltipManager::add("#bundleDisplayEditorBundle_ca_objects_location", $this->_formatBundleTooltip($vs_label, $vs_bundle, $vs_description));
         }
     }
     if (caGetBundleAccessLevel($vs_table, "ca_object_representations") != __CA_BUNDLE_ACCESS_NONE__) {
         // get object representations (objects only, of course)
         if ($vs_table == 'ca_objects') {
             $va_additional_settings = array('display_mode' => array('formatType' => FT_TEXT, 'displayType' => DT_SELECT, 'width' => 35, 'height' => 1, 'takesLocale' => false, 'default' => '', 'options' => array(_t('Media') => 'media', _t('URL') => 'url'), 'label' => _t('Output mode'), 'description' => _t('Determines if value used is URL of media or the media itself.')));
             $o_media_settings = new MediaProcessingSettings('ca_object_representations', 'media');
             $va_versions = $o_media_settings->getMediaTypeVersions('*');
             foreach ($va_versions as $vs_version => $va_version_info) {
                 $t_placement = new ca_bundle_display_placements(null, $va_additional_settings);
                 if ($this->inTransaction()) {
                     $t_placement->setTransaction($this->getTransaction());
                 }
                 $vs_bundle = 'ca_object_representations.media.' . $vs_version;
                 $vs_display = "<div id='bundleDisplayEditorBundle_ca_object_representations_media_{$vs_version}'><span class='bundleDisplayEditorPlacementListItemTitle'>" . caUcFirstUTF8Safe($t_instance->getProperty('NAME_SINGULAR')) . "</span> " . ($vs_label = $t_instance->getDisplayLabel($vs_bundle)) . "</div>";
                 $va_available_bundles[strip_tags($vs_display)][$vs_bundle] = array('bundle' => $vs_bundle, 'display' => $vs_format == 'simple' ? $vs_label : $vs_display, 'description' => $vs_description = $t_instance->getDisplayDescription($vs_bundle), 'settingsForm' => $t_placement->getHTMLSettingForm(array('id' => $vs_bundle . '_0')), 'settings' => $va_additional_settings);
                 if ($vb_show_tooltips) {
                     TooltipManager::add("#bundleDisplayEditorBundle_ca_object_representations_media_{$vs_version}", $this->_formatBundleTooltip($vs_label, $vs_bundle, $vs_description));
                 }
             }
             $t_rep = new ca_object_representations();
             if ($this->inTransaction()) {
                 $t_rep->setTransaction($this->getTransaction());
             }
             foreach (array('mimetype', 'md5', 'original_filename') as $vs_rep_field) {
                 $vs_bundle = 'ca_object_representations.' . $vs_rep_field;
                 $vs_display = "<div id='bundleDisplayEditorBundle_ca_object_representations_{$vs_rep_field}'><span class='bundleDisplayEditorPlacementListItemTitle'>" . caUcFirstUTF8Safe($t_rep->getProperty('NAME_SINGULAR')) . "</span> " . ($vs_label = $t_rep->getDisplayLabel($vs_bundle)) . "</div>";
                 $va_available_bundles[strip_tags($vs_display)][$vs_bundle] = array('bundle' => $vs_bundle, 'display' => $vs_format == 'simple' ? $vs_label : $vs_display, 'description' => $vs_description = $t_rep->getDisplayDescription($vs_bundle), 'settingsForm' => $t_placement->getHTMLSettingForm(array('id' => $vs_bundle . '_0')), 'settings' => array());
             }
         }
     }
     // get related items
     $o_dm = $this->getAppDatamodel();
     foreach (array('ca_objects', 'ca_object_lots', 'ca_entities', 'ca_places', 'ca_occurrences', 'ca_collections', 'ca_storage_locations', 'ca_loans', 'ca_movements', 'ca_list_items', 'ca_object_representations') as $vs_related_table) {
         if ($this->getAppConfig()->get($vs_related_table . '_disable') && !($vs_related_table == 'ca_object_representations' && !$this->getAppConfig()->get('ca_objects_disable'))) {
             continue;
         }
         if (caGetBundleAccessLevel($vs_table, $vs_related_table) == __CA_BUNDLE_ACCESS_NONE__) {
             continue;
         }
         if ($vs_related_table === $vs_table) {
             $vs_bundle = $vs_related_table . '.related';
         } else {
             $vs_bundle = $vs_related_table;
         }
         $t_rel_instance = $o_dm->getInstanceByTableName($vs_related_table, true);
         $vs_table_name = $o_dm->getTableName($this->get('table_num'));
         $va_path = array_keys($o_dm->getPath($vs_table_name, $vs_related_table));
         if (sizeof($va_path) < 2 || sizeof($va_path) > 3) {
             continue;
         }
         // only use direct relationships (one-many or many-many)
         $va_additional_settings = array('format' => array('formatType' => FT_TEXT, 'displayType' => DT_FIELD, 'width' => 35, 'height' => 5, 'takesLocale' => false, 'default' => '', 'label' => _t('Display format'), 'description' => _t('Template used to format output.')), 'restrict_to_relationship_types' => array('formatType' => FT_TEXT, 'displayType' => DT_SELECT, 'useRelationshipTypeList' => $va_path[1], 'width' => 35, 'height' => 5, 'takesLocale' => false, 'default' => '', 'label' => _t('Restrict to relationship types'), 'description' => _t('Restricts display to items related using the specified relationship type(s). Leave all unchecked for no restriction.')), 'restrict_to_types' => array('formatType' => FT_TEXT, 'displayType' => DT_SELECT, 'useList' => $t_rel_instance->getTypeListCode(), 'width' => 35, 'height' => 5, 'takesLocale' => false, 'default' => '', 'label' => _t('Restrict to types'), 'description' => _t('Restricts display to items of the specified type(s). Leave all unchecked for no restriction.')), 'delimiter' => array('formatType' => FT_TEXT, 'displayType' => DT_FIELD, 'width' => 35, 'height' => 1, 'takesLocale' => false, 'default' => '', 'label' => _t('Delimiter'), 'description' => _t('Text to place in-between repeating values.')));
         if ($t_rel_instance->isHierarchical()) {
             $va_additional_settings += array('show_hierarchy' => array('formatType' => FT_NUMBER, 'displayType' => DT_CHECKBOXES, 'width' => 10, 'height' => 1, 'hideOnSelect' => array('format'), 'takesLocale' => false, 'default' => '0', 'label' => _t('Show hierarchy?'), 'description' => _t('If checked the full hierarchical path will be shown.')), 'remove_first_items' => array('formatType' => FT_NUMBER, 'displayType' => DT_FIELD, 'width' => 10, 'height' => 1, 'takesLocale' => false, 'default' => '0', 'label' => _t('Remove first items from hierarchy?'), 'description' => _t('If set to a non-zero value, the specified number of items at the top of the hierarchy will be omitted. For example, if set to 2, the root and first child of the hierarchy will be omitted.')), 'hierarchy_order' => array('formatType' => FT_TEXT, 'displayType' => DT_SELECT, 'options' => array(_t('top first') => 'ASC', _t('bottom first') => 'DESC'), 'width' => 35, 'height' => 1, 'takesLocale' => false, 'default' => '', 'label' => _t('Order hierarchy'), 'description' => _t('Determines order in which hierarchy is displayed.')), 'hierarchy_limit' => array('formatType' => FT_NUMBER, 'displayType' => DT_FIELD, 'width' => 10, 'height' => 1, 'takesLocale' => false, 'default' => '', 'label' => _t('Maximum length of hierarchy'), 'description' => _t('Maximum number of items to show in the hierarchy. Leave blank to show the unabridged hierarchy.')), 'hierarchical_delimiter' => array('formatType' => FT_TEXT, 'displayType' => DT_FIELD, 'width' => 35, 'height' => 1, 'takesLocale' => false, 'default' => ' ➔ ', 'label' => _t('Hierarchical delimiter'), 'description' => _t('Text to place in-between elements of a hierarchical value.')));
         }
         if ($vs_table === 'ca_objects' && $vs_related_table === 'ca_storage_locations' || $vs_table === 'ca_storage_locations' && $vs_related_table === 'ca_objects' || $vs_table === 'ca_objects' && $vs_related_table === 'ca_movements' || $vs_table === 'ca_movements' && $vs_related_table === 'ca_objects' || $vs_table === 'ca_storage_locations' && $vs_related_table === 'ca_movements' || $vs_table === 'ca_movements' && $vs_related_table === 'ca_storage_locations') {
             $va_additional_settings['showCurrentOnly'] = array('formatType' => FT_TEXT, 'displayType' => DT_CHECKBOXES, 'width' => "10", 'height' => "1", 'takesLocale' => false, 'default' => '0', 'label' => _t('Show current only?'), 'description' => _t('If checked only current objects are displayed.'));
         }
         //$va_additional_settings['format']['helpText'] = $this->getTemplatePlaceholderDisplayListForBundle($vs_bundle);
         $t_placement = new ca_bundle_display_placements(null, $va_additional_settings);
         if ($this->inTransaction()) {
             $t_placement->setTransaction($this->getTransaction());
         }
         $vs_id_suffix = "bundleDisplayEditorBundle_" . str_replace(".", "_", $vs_bundle);
         $vs_display = "<div id='bundleDisplayEditorBundle_{$vs_id_suffix}'><span class='bundleDisplayEditorPlacementListItemTitle'>" . caUcFirstUTF8Safe($t_rel_instance->getProperty('NAME_SINGULAR')) . "</span> " . ($vs_label = $t_rel_instance->getDisplayLabel($vs_bundle)) . "</div>";
         $va_available_bundles[strip_tags($vs_display)][$vs_bundle] = array('bundle' => $vs_bundle, 'display' => $vs_format == 'simple' ? $vs_label : $vs_display, 'description' => $vs_description = $t_rel_instance->getDisplayDescription($vs_bundle), 'settingsForm' => $t_placement->getHTMLSettingForm(array('id' => $vs_bundle . '_0')), 'settings' => $va_additional_settings);
         if ($vb_show_tooltips) {
             TooltipManager::add("#bundleDisplayEditorBundle_{$vs_id_suffix}", $this->_formatBundleTooltip($vs_label, $vs_bundle, $vs_description));
         }
     }
     // created and modified
     $va_additional_settings = array('dateFormat' => array('formatType' => FT_TEXT, 'displayType' => DT_SELECT, 'width' => 40, 'height' => 1, 'takesLocale' => false, 'default' => 'iso8601', 'options' => array('ISO-8601' => 'iso8601', 'Text' => 'text'), 'label' => _t('Date format'), 'description' => _t('Sets format for output of date when exporting.')));
     $t_placement = new ca_bundle_display_placements(null, $va_additional_settings);
     if ($this->inTransaction()) {
         $t_placement->setTransaction($this->getTransaction());
     }
     $vs_bundle = "{$vs_table}.created";
     $vs_display = "<div id='bundleDisplayEditorBundle_{$vs_table}_created'><span class='bundleDisplayEditorPlacementListItemTitle'>" . _t('General') . "</span> " . ($vs_label = $t_instance->getDisplayLabel($vs_bundle)) . "</div>";
     $va_available_bundles[strip_tags($vs_display)][$vs_bundle] = array('bundle' => $vs_bundle, 'display' => $vs_format == 'simple' ? $vs_label : $vs_display, 'description' => $vs_description = _t('Date and time item was created'), 'settingsForm' => $t_placement->getHTMLSettingForm(array('id' => $vs_bundle . '_0')), 'settings' => $va_additional_settings);
     if ($vb_show_tooltips) {
         TooltipManager::add("#bundleDisplayEditorBundle_{$vs_table}_created", $this->_formatBundleTooltip($vs_label, $vs_bundle, $vs_description));
     }
     $vs_bundle = "{$vs_table}.lastModified";
     $vs_display = "<div id='bundleDisplayEditorBundle_{$vs_table}_lastModified'><span class='bundleDisplayEditorPlacementListItemTitle'>" . _t('General') . "</span> " . ($vs_label = $t_instance->getDisplayLabel($vs_bundle)) . "</div>";
     $va_available_bundles[strip_tags($vs_display)][$vs_bundle] = array('bundle' => $vs_bundle, 'display' => $vs_display, 'description' => $vs_description = _t('Date and time item was last modified'), 'settingsForm' => $t_placement->getHTMLSettingForm(array('id' => $vs_bundle . '_0')), 'settings' => $va_additional_settings);
     if ($vb_show_tooltips) {
         TooltipManager::add("#bundleDisplayEditorBundle_{$vs_table}_lastModified", $this->_formatBundleTooltip($vs_label, $vs_bundle, $vs_description));
     }
     ksort($va_available_bundles);
     $va_sorted_bundles = array();
     foreach ($va_available_bundles as $vs_k => $va_val) {
         foreach ($va_val as $vs_real_key => $va_info) {
             $va_sorted_bundles[$vs_real_key] = $va_info;
         }
     }
     return $va_sorted_bundles;
 }