diff --git a/module/VuDL/src/VuDL/Connection/AbstractBase.php b/module/VuDL/src/VuDL/Connection/AbstractBase.php index 30e9372a8d26335d1e404c53945e9b1611915bae..03e88a78c2cfc76a0e2195b5625efba3bc0d3efd 100644 --- a/module/VuDL/src/VuDL/Connection/AbstractBase.php +++ b/module/VuDL/src/VuDL/Connection/AbstractBase.php @@ -135,54 +135,32 @@ class AbstractBase implements \VuFindHttp\HttpServiceAwareInterface if (empty($detailsList)) { throw new \Exception('Missing [Details] in VuDL.ini'); } + $details = array(); foreach ($detailsList as $key=>$title) { $keys = explode(',', $key); - foreach ($keys as $k) { - $fields[$k] = $title; - } - // Link up to top combined field - if (count($keys) > 1) { - $combinedFields[] = $keys; - } - } - // Pool details - $details = array(); - foreach ($fields as $key=>$title) { - if (isset($record[$key])) { - $details[$key] = array('title' => $title, 'value' => $record[$key]); - } - } - // Rearrange combined fields - foreach ($combinedFields as $fields) { - $main = $fields[0]; - if (!isset($details[$main]['value']) - || !is_array($details[$main]['value']) - ) { - if (isset($details[$main]['value'])) { - $details[$main]['value'] = array($details[$main]['value']); - } else { - $details[$main]['value'] = array(); + if (count($keys) == 1) { + if (isset($record[$keys[0]])) { + $value = $record[$keys[0]]; } - } - for ($i=1;$i<count($fields);$i++) { - if (isset($details[$fields[$i]])) { - if (!isset($details[$main]['title'])) { - $details[$main]['title'] = $details[$fields[$i]]['title']; - } - if (is_array($details[$main]['value'])) { - foreach ($details[$fields[$i]]['value'] as $value) { - $details[$main]['value'][] = $value; + } else { + $value = array(); + foreach ($keys as $k) { + if (isset($record[$k])) { + if (is_array($record[$k])) { + $value = array_merge($value, $record[$k]); + } else { + $value[] = $record[$k]; } - } else { - $details[$main]['value'][] = $details[$fields[$i]]['value']; } - unset($details[$fields[$i]]); } } - if (empty($details[$main]['value'])) { - unset($details[$main]); - } + $details[$keys[0]] = array( + 'title' => $title, + 'value' => $value + ); } + var_dump($detailsList); + var_dump($details); return $details; } } \ No newline at end of file diff --git a/themes/bootstrap/templates/vudl/details.phtml b/themes/bootstrap/templates/vudl/details.phtml index bf72a8be084429aa54bef955ca1d45c55de06555..11baa80e4ac503e16c67f812c64984f347594312 100644 --- a/themes/bootstrap/templates/vudl/details.phtml +++ b/themes/bootstrap/templates/vudl/details.phtml @@ -24,6 +24,7 @@ <? // If we need exploding and backlinking ?> <? elseif($attr == 'topic' || $attr == 'series'): ?> + <? if(!is_array($val['value'])) $val['value'] = array($val['value']); ?> <? if(count($val['value']) > 1): ?><ul class="unstyled"><? endif ?> <? foreach($val['value'] as $v): ?> <? if(count($val['value']) > 1): ?><li><? endif ?>