Skip to content

Commit 25f8d73

Browse files
committed
Fix for PROV-468: Horizontal hierarchy browser for List attributes broken
1 parent 867263b commit 25f8d73

File tree

8 files changed

+32
-14
lines changed

8 files changed

+32
-14
lines changed

app/controllers/lookup/ListItemController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function GetHierarchyLevel() {
125125
if (!$va_item[$vs_label_display_field_name]) { $va_item[$vs_label_display_field_name] = $va_item['idno']; }
126126
if (!$va_item[$vs_label_display_field_name]) { $va_item[$vs_label_display_field_name] = '???'; }
127127

128-
$va_item['name'] = caProcessTemplateForIDs($vs_template, 'ca_list_items', array($vn_item_id));
128+
$va_item['name'] = caProcessTemplateForIDs($vs_template, 'ca_list_items', array($vn_item_id), array('requireLinkTags' => true));
129129
$va_item['table'] = 'ca_list_items';
130130

131131
// Child count is only valid if has_children is not null

app/helpers/displayHelpers.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,6 +1706,7 @@ function caProcessTemplate($ps_template, $pa_values, $pa_options=null) {
17061706
* relatedValues = array of field values to return in template when directly referenced. Array should be indexed numerically in parallel with $pa_row_ids
17071707
* relationshipValues = array of field values to return in template for relationship when directly referenced. Should be indexed by row_id and then by relation_id
17081708
* placeholderPrefix =
1709+
* requireLinkTags = if set then links are only added when explicitly defined with <l> tags. Default is to make the entire text a link in the absence of <l> tags.
17091710
* @return mixed Output of processed templates
17101711
*/
17111712
function caProcessTemplateForIDs($ps_template, $pm_tablename_or_num, $pa_row_ids, $pa_options=null) {
@@ -1906,7 +1907,7 @@ function caProcessTemplateForIDs($ps_template, $pm_tablename_or_num, $pa_row_ids
19061907

19071908
if (is_array($va_val)) {
19081909
if($vb_is_related) {
1909-
$va_val = caCreateLinksFromText($va_val, $va_tmp[0], $va_related_ids);
1910+
$va_val = caCreateLinksFromText($va_val, $va_tmp[0], $va_related_ids, null, null, $pa_options);
19101911
}
19111912

19121913
foreach($va_val as $vn_j => $vs_val) {
@@ -2081,7 +2082,7 @@ function caProcessTemplateForIDs($ps_template, $pm_tablename_or_num, $pa_row_ids
20812082
}
20822083

20832084
// Transform links
2084-
$va_proc_templates = caCreateLinksFromText($va_proc_templates, $ps_tablename, $pa_row_ids);
2085+
$va_proc_templates = caCreateLinksFromText($va_proc_templates, $ps_tablename, $pa_row_ids, null, null, $pa_options);
20852086

20862087
if ($vb_return_as_array) {
20872088
return $va_proc_templates;
@@ -2600,10 +2601,12 @@ function caObjectsDisplayDownloadLink($po_request) {
26002601
* @param string $ps_table_name The name of the table/record to which the links refer
26012602
* @param array $pa_row_ids Array of row_ids to link to. Values must correspond by index with those in $pa_text
26022603
* @param string $ps_class Optional CSS class to apply to links
2604+
* @param array $pa_options Supported options are:
2605+
* requireLinkTags = if set then links are only added when explicitly defined with <l> tags. Default is to make the entire text a link in the absence of <l> tags.
26032606
*
26042607
* @return array A list of HTML links
26052608
*/
2606-
function caCreateLinksFromText($pa_text, $ps_table_name, $pa_row_ids, $ps_class=null, $ps_target=null) {
2609+
function caCreateLinksFromText($pa_text, $ps_table_name, $pa_row_ids, $ps_class=null, $ps_target=null, $pa_options=null) {
26072610
if (!in_array(__CA_APP_TYPE__, array('PROVIDENCE', 'PAWTUCKET'))) { return $pa_text; }
26082611
if (__CA_APP_TYPE__ == 'PAWTUCKET') {
26092612
$o_config = Configuration::load();
@@ -2665,6 +2668,10 @@ function caCreateLinksFromText($pa_text, $ps_table_name, $pa_row_ids, $ps_class=
26652668
}
26662669
$va_links[] = $vs_content;
26672670
} else {
2671+
if (isset($pa_options['requireLinkTags']) && $pa_options['requireLinkTags']) {
2672+
$va_links[] = $vs_text;
2673+
continue;
2674+
}
26682675
if ($vb_can_handle_target) {
26692676
$va_params = array('request' => $g_request, 'content' => $vs_text, 'table' => $ps_table_name, 'id' => $pa_row_ids[$vn_i], 'classname' => $ps_class, 'target' => $ps_target, 'additionalParameters' => null, 'options' => null);
26702677
$va_params = $o_app_plugin_manager->hookGetAsLink($va_params);

app/lib/ca/BaseLookupController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public function GetHierarchyLevel() {
263263
if (!$va_tmp[$vs_label_display_field_name]) { $va_tmp[$vs_label_display_field_name] = $va_tmp['idno']; }
264264
if (!$va_tmp[$vs_label_display_field_name]) { $va_tmp[$vs_label_display_field_name] = '???'; }
265265

266-
$va_tmp['name'] = caProcessTemplateForIDs($vs_item_template, $vs_table_name, array($va_tmp[$vs_pk]));
266+
$va_tmp['name'] = caProcessTemplateForIDs($vs_item_template, $vs_table_name, array($va_tmp[$vs_pk]), array('requireLinkTags' => true));
267267

268268
// Child count is only valid if has_children is not null
269269
$va_tmp['children'] = isset($va_child_counts[$vn_id]) ? (int)$va_child_counts[$vn_id] : 0;

app/models/ca_list_items.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ public function getHierarchyList($pb_vocabularies=false) {
476476
if ($qr_children->nextRow()) {
477477
$vn_children_count = $qr_children->get('children');
478478
}
479-
$va_hierarchies[$vn_hierarchy_id]['name'] = caProcessTemplateForIDs($vs_template, 'ca_lists', array($vn_hierarchy_id));
479+
$va_hierarchies[$vn_hierarchy_id]['name'] = caProcessTemplateForIDs($vs_template, 'ca_lists', array($vn_hierarchy_id), array('requireLinkTags' => true));
480480
$va_hierarchies[$vn_hierarchy_id]['children'] = intval($vn_children_count);
481481
$va_hierarchies[$vn_hierarchy_id]['has_children'] = ($vn_children_count > 0) ? 1 : 0;
482482
}

themes/default/css/base.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2583,6 +2583,7 @@ div.hierarchyBrowserCurrentSelection {
25832583

25842584
span.hierarchyBrowserCurrentSelectionText {
25852585
font-weight: normal;
2586+
font-style: italic;
25862587
}
25872588

25882589
div.hierarchyBrowserSearchBar {

themes/default/views/bundles/ca_list_items.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,11 @@
188188
<div style="float: right;">
189189
<div class='hierarchyBrowserSearchBar'><?php print _t('Search'); ?>: <input type='text' id='<?php print $vs_id_prefix; ?>_hierarchyBrowserSearch{n}' class='hierarchyBrowserSearchBar' name='search' value='' size='40'/></div>
190190
</div>
191-
<div style="float: left;">
191+
<div style="float: left;" class="hierarchyBrowserCurrentSelectionText">
192192
<select name="<?php print $vs_id_prefix; ?>_type_id{n}" id="<?php print $vs_id_prefix; ?>_type_id{n}" style="display: none;"></select>
193193
<input type="hidden" name="<?php print $vs_id_prefix; ?>_id{n}" id="<?php print $vs_id_prefix; ?>_id{n}" value="{id}"/>
194+
195+
<span class="hierarchyBrowserCurrentSelectionText" id="<?php print $vs_id_prefix; ?>_browseCurrentSelectionText{n}"> </span>
194196
</div>
195197

196198
<script type='text/javascript'>
@@ -213,10 +215,11 @@ classNameContainer: 'hierarchyBrowserContainer',
213215

214216
editButtonIcon: '<img src="<?php print $this->request->getThemeUrlPath(); ?>/graphics/buttons/arrow_grey_right.gif" border="0" title="Edit"/>',
215217

216-
initItemID: <?php print $vn_browse_last_id; ?>,
218+
//initItemID: <?php print $vn_browse_last_id; ?>,
217219
useAsRootID: <?php print $vn_use_as_root_id; ?>,
218220
indicatorUrl: '<?php print $this->request->getThemeUrlPath(); ?>/graphics/icons/indicator.gif',
219221

222+
displayCurrentSelectionOnLoad: false,
220223
currentSelectionDisplayID: '<?php print $vs_id_prefix; ?>_browseCurrentSelectionText{n}',
221224
onSelection: function(item_id, parent_id, name, display, type_id) {
222225
if (!init) { // Don't actually select the init value, otherwise if you save w/no selection you get "phantom" relationships

themes/default/views/bundles/ca_places.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,11 @@
159159
<div style="float: right;">
160160
<div class='hierarchyBrowserSearchBar'><?php print _t('Search'); ?>: <input type='text' id='<?php print $vs_id_prefix; ?>_hierarchyBrowserSearch{n}' class='hierarchyBrowserSearchBar' name='search' value='' size='40'/></div>
161161
</div>
162-
<div style="float: left;">
163-
<?php print _t('Type'); ?>: <select name="<?php print $vs_id_prefix; ?>_type_id{n}" id="<?php print $vs_id_prefix; ?>_type_id{n}" style="display: none;"></select>
162+
<div style="float: left;" class="hierarchyBrowserCurrentSelectionText">
163+
<select name="<?php print $vs_id_prefix; ?>_type_id{n}" id="<?php print $vs_id_prefix; ?>_type_id{n}" style="display: none;"></select>
164164
<input type="hidden" name="<?php print $vs_id_prefix; ?>_id{n}" id="<?php print $vs_id_prefix; ?>_id{n}" value="{id}"/>
165+
166+
<span class="hierarchyBrowserCurrentSelectionText" id="<?php print $vs_id_prefix; ?>_browseCurrentSelectionText{n}"> </span>
165167
</div>
166168

167169
<script type='text/javascript'>
@@ -181,10 +183,11 @@ classNameContainer: 'hierarchyBrowserContainer',
181183

182184
editButtonIcon: '<img src="<?php print $this->request->getThemeUrlPath(); ?>/graphics/buttons/arrow_grey_right.gif" border="0" title="Edit"/>',
183185

184-
initItemID: <?php print (int)$this->request->session->getVar('ca_places_browse_last_id'); ?>,
186+
//initItemID: <?php print (int)$this->request->session->getVar('ca_places_browse_last_id'); ?>,
185187
useAsRootID: <?php print $vn_use_as_root_id; ?>,
186188
indicatorUrl: '<?php print $this->request->getThemeUrlPath(); ?>/graphics/icons/indicator.gif',
187189

190+
displayCurrentSelectionOnLoad: false,
188191
currentSelectionDisplayID: '<?php print $vs_id_prefix; ?>_browseCurrentSelectionText{n}',
189192
onSelection: function(item_id, parent_id, name, display, type_id) {
190193
caRelationBundle<?php print $vs_id_prefix; ?>.select('{n}', {id: item_id, type_id: type_id}, display);

themes/default/views/bundles/ca_storage_locations.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,13 @@
147147
<div style="float: right;">
148148
<div class='hierarchyBrowserSearchBar'><?php print _t('Search'); ?>: <input type='text' id='<?php print $vs_id_prefix; ?>_hierarchyBrowserSearch{n}' class='hierarchyBrowserSearchBar' name='search' value='' size='40'/></div>
149149
</div>
150-
<div style="float: left;">
151-
<?php print _t('Type'); ?>: <select name="<?php print $vs_id_prefix; ?>_type_id{n}" id="<?php print $vs_id_prefix; ?>_type_id{n}" style="display: none;"></select>
150+
<div style="float: left;" class="hierarchyBrowserCurrentSelectionText">
151+
<select name="<?php print $vs_id_prefix; ?>_type_id{n}" id="<?php print $vs_id_prefix; ?>_type_id{n}" style="display: none;"></select>
152152
<input type="hidden" name="<?php print $vs_id_prefix; ?>_id{n}" id="<?php print $vs_id_prefix; ?>_id{n}" value="{id}"/>
153+
154+
<span class="hierarchyBrowserCurrentSelectionText" id="<?php print $vs_id_prefix; ?>_browseCurrentSelectionText{n}"> </span>
153155
</div>
156+
154157

155158
<script type='text/javascript'>
156159
jQuery(document).ready(function() {
@@ -169,9 +172,10 @@ classNameContainer: 'hierarchyBrowserContainer',
169172

170173
editButtonIcon: '<img src="<?php print $this->request->getThemeUrlPath(); ?>/graphics/buttons/arrow_grey_right.gif" border="0" title="Edit"/>',
171174

172-
initItemID: <?php print (int)$this->request->session->getVar('ca_storage_locations_browse_last_id'); ?>,
175+
//initItemID: <?php print (int)$this->request->session->getVar('ca_storage_locations_browse_last_id'); ?>,
173176
indicatorUrl: '<?php print $this->request->getThemeUrlPath(); ?>/graphics/icons/indicator.gif',
174177

178+
displayCurrentSelectionOnLoad: false,
175179
currentSelectionDisplayID: '<?php print $vs_id_prefix; ?>_browseCurrentSelectionText{n}',
176180
onSelection: function(item_id, parent_id, name, display, type_id) {
177181
caRelationBundle<?php print $vs_id_prefix; ?>.select('{n}', {id: item_id, type_id: type_id}, display);

0 commit comments

Comments
 (0)