Skip to content

Commit 6452ba6

Browse files
Fix to allow simple related gets in templates (eg. ca_occurrences). They now default to preferred labels
Now support <l> tags for related items
1 parent cd21a2a commit 6452ba6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

app/helpers/displayHelpers.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,10 @@ function caProcessTemplateForIDs($ps_template, $pm_tablename_or_num, $pa_row_ids
18361836
if (!isset($va_relationship_values[$vs_pk_val])) { $va_relationship_values[$vs_pk_val] = array(0 => null); }
18371837

18381838
foreach($va_relationship_values[$vs_pk_val] as $vn_relation_id => $va_relationship_value_array) {
1839+
$vb_is_related = false;
1840+
$va_related_ids = array();
18391841
$va_val = null;
1842+
18401843
if (isset($va_relationship_value_array[$vs_tag]) && !(isset($pa_options['showHierarchicalLabels']) && $pa_options['showHierarchicalLabels'] && ($vs_tag == 'label'))) {
18411844
$va_val = array($vs_val = $va_relationship_value_array[$vs_tag]);
18421845
} else {
@@ -1855,10 +1858,20 @@ function caProcessTemplateForIDs($ps_template, $pm_tablename_or_num, $pa_row_ids
18551858
$vs_get_spec = $vs_tag;
18561859
}
18571860

1861+
$va_spec_bits = explode(".", $vs_get_spec);
1862+
if ((sizeof($va_spec_bits) == 1) && ($o_dm->getTableNum($va_spec_bits[0]))) {
1863+
$vs_get_spec .= ".preferred_labels";
1864+
}
18581865
$va_val = $qr_res->get($vs_get_spec, array_merge($pa_options, array('returnAsArray' => true)));
1866+
$vb_is_related = true;
1867+
$va_related_ids = $qr_res->get($va_tmp[0].".".$o_dm->getTablePrimaryKeyName($va_tmp[0]), array('returnAsArray' => true));
18591868
} else {
18601869
if ($va_tmp[0] == $ps_tablename) { array_shift($va_tmp); } // get rid of primary table if it's in the field spec
18611870

1871+
if (!sizeof($va_tmp)) {
1872+
$va_tmp[] = "preferred_labels";
1873+
}
1874+
18621875
if (isset($pa_options['showHierarchicalLabels']) && $pa_options['showHierarchicalLabels']) {
18631876
if ($va_tmp[1] == 'preferred_labels') {
18641877
array_unshift($va_tmp, 'hierarchy');
@@ -1892,6 +1905,10 @@ function caProcessTemplateForIDs($ps_template, $pm_tablename_or_num, $pa_row_ids
18921905

18931906

18941907
if (is_array($va_val)) {
1908+
if($vb_is_related) {
1909+
$va_val = caCreateLinksFromText($va_val, $va_tmp[0], $va_related_ids);
1910+
}
1911+
18951912
foreach($va_val as $vn_j => $vs_val) {
18961913
$va_tag_val_list[$vn_i][$vn_j][$vs_tag] = $vs_val;
18971914
if ((is_array($vs_val) && (sizeof($vs_val))) || (strlen($vs_val) > 0)) {

0 commit comments

Comments
 (0)