diff --git a/module/finc/src/finc/View/Helper/Root/Record.php b/module/finc/src/finc/View/Helper/Root/Record.php index 847bec98d2cfc4e5aa69fc6e1ff5c5f5ae2c254a..63545be5c92d7a5ea7cad1748e9a83bc48de1760 100644 --- a/module/finc/src/finc/View/Helper/Root/Record.php +++ b/module/finc/src/finc/View/Helper/Root/Record.php @@ -2,7 +2,7 @@ /** * Record driver view helper * - * PHP version 5 + * PHP version 7 * * Copyright (C) Villanova University 2010. * @@ -103,27 +103,34 @@ class Record extends \VuFind\View\Helper\Root\Record /** * Render a (list of) record icons. * - * @param string $tpl Define alternative template for record icon. Default: - * record-icon.phtml + * @param string $tpl Define alternative template for record icon. Default: record-icon.phtml + * @param bool $addText Return additional access / format. Default: true * * @return string */ - public function getRecordIcon($tpl = 'record-icon') + public function getRecordIcon(string $tpl = 'record-icon', bool $addText = true): string { - return $this->renderTemplate($tpl . '.phtml'); + $iconType = $this->getRecordIconType(); + $iconClass = $this->getRecordIconClass($iconType); + return $this->renderTemplate($tpl . '.phtml', ['iconClass' => $iconClass]) + . ($addText ? $this->getRecordIconText($iconType,$iconClass) : ''); } /** * Get the CSS class used to properly render an icon for given value * - * @param string $value (identifier) Value to convert into CSS class + * @param string $value (identifier) Value to convert into CSS class. Default: null * @param string $classfile Define alternative file for icon class without * suffix. Default: record-icon-class.phtml * * @return string */ - public function getRecordIconClass($value, $classfile = 'record-icon-class') + public function getRecordIconClass(string $value = null, string $classfile = 'record-icon-class'): string { + if ($value === null) { + $value = $this->getRecordIconType(); + } + return $this->renderTemplate( $classfile . '.phtml', ['value' => $value] @@ -137,13 +144,34 @@ class Record extends \VuFind\View\Helper\Root\Record * * @return string */ - public function getRecordIconText($classfile = 'record-icon-text') + public function getRecordIconText(string $iconType = null, string $iconClass = null, $classfile = 'record-icon-text'): string { + if (null === $iconType) { + $iconType = $this->getRecordIconType(); + } + if (null === $iconClass) { + $iconClass = $this->getRecordIconClass($iconType); + } return $this->renderTemplate( - $classfile . '.phtml' + $classfile . '.phtml', compact('iconType','iconClass') ); } + function getRecordIconType() { + + /* block copied from record-icon - RL */ + $recordType = $this->driver->getRecordType(); + switch ($recordType) { + case 'lido': + return "object"; + case 'missing': + case 'marcfincpda': + return $recordType; + default: + return implode('', $this->driver->getFacetAvail()); + } + } + /** * Returns if style based icons should be shown (if covers are disabled!) * diff --git a/themes/finc/templates/RecordDriver/DefaultRecord/record-icon-text.phtml b/themes/finc/templates/RecordDriver/DefaultRecord/record-icon-text.phtml index 50bd4d1b6e9856521d913ae9a4f4fbf9a5504ad1..997f06c9234e5b470499e6b3e5a94b43f87a4786 100644 --- a/themes/finc/templates/RecordDriver/DefaultRecord/record-icon-text.phtml +++ b/themes/finc/templates/RecordDriver/DefaultRecord/record-icon-text.phtml @@ -1,20 +1,9 @@ <!-- finc: recordDriver - DefaultRecord - record-icon-text --> -<?php - /* block copied from record-icon - RL */ - $recordType = $this->driver->getRecordType(); - if ($recordType == "marcfincpda") { - $type = $recordType; - } elseif ($recordType == "lido") { - $type = "object"; - } else { - $type = implode('', $this->driver->getFacetAvail()); - } -?> -<?php if ($iconClass = $this->record($this->driver)->getRecordIconClass($type)): ?> - <span class="access-icon hidden-print"> +<?php if ($iconClass): ?> + <div class="access-icon hidden-print"> <span> <?=$this->translate("($iconClass)")?> </span> - </span> + </div> <?php endif; ?> <!-- finc: recordDriver - DefaultRecord - record-icon-text - END --> \ No newline at end of file diff --git a/themes/finc/templates/RecordDriver/DefaultRecord/record-icon.phtml b/themes/finc/templates/RecordDriver/DefaultRecord/record-icon.phtml index b36f126e35c921bc00d91b93aa7b303a19c08382..bfa3afa3183bac4a2625e33bd2e732da77b67a9c 100644 --- a/themes/finc/templates/RecordDriver/DefaultRecord/record-icon.phtml +++ b/themes/finc/templates/RecordDriver/DefaultRecord/record-icon.phtml @@ -1,18 +1,8 @@ <!-- finc: recordDriver - DefaultRecord - record-icon --> -<?php - /* finc: template is NOT identical with de_15 - RL */ - $recordType = $this->driver->getRecordType(); - if ($recordType == "marcfincpda") { - $type = $recordType; - } elseif ($recordType == "lido") { - $type = "object"; - } else { - $type = implode('', $this->driver->getFacetAvail()); - } - $iconClass = $this->record($this->driver)->getRecordIconClass($type); -?> -<span class="access-icon hidden-print"> - <i aria-hidden="true" class="fa <?=$iconClass?>"></i> - <?php /* separate access text from icon - moved to cover.phtml */ ?> -</span> +<?php if (!empty($iconClass)): ?> + <span class="access-icon hidden-print"> + <i aria-hidden="true" class="fa <?=$iconClass?>"></i> + <?php /* separate access text from icon - moved to cover.phtml */ ?> + </span> +<?php endif; ?> <!-- finc: recordDriver - DefaultRecord - record-icon - END --> \ No newline at end of file diff --git a/themes/finc/templates/RecordDriver/DefaultRecord/result-list.phtml b/themes/finc/templates/RecordDriver/DefaultRecord/result-list.phtml index 767f185304e75b2ec54d4dad17025a4275a791ac..878760060d4bcac2728a7ac5cf914eb170648406 100644 --- a/themes/finc/templates/RecordDriver/DefaultRecord/result-list.phtml +++ b/themes/finc/templates/RecordDriver/DefaultRecord/result-list.phtml @@ -18,7 +18,6 @@ if ($cover): <?php ob_start(); ?> <div class="media-<?=$thumbnailAlignment?> record-icon"> <?=$this->record($this->driver)->getRecordIcon()?> - <?=$this->record($this->driver)->getRecordIconText()?> </div> <?php $thumbnail = ob_get_contents(); ?> <?php ob_end_clean(); ?> diff --git a/themes/finc/templates/RecordDriver/SolrAI/result-list.phtml b/themes/finc/templates/RecordDriver/SolrAI/result-list.phtml index 16be9bd855b86b1155ba70f51928ecab646d9b4d..0b8dc222334495369c4a119078df6840174a8a3f 100644 --- a/themes/finc/templates/RecordDriver/SolrAI/result-list.phtml +++ b/themes/finc/templates/RecordDriver/SolrAI/result-list.phtml @@ -16,7 +16,6 @@ if ($cover): <?php ob_start(); ?> <div class="media-<?=$thumbnailAlignment?> record-icon"> <?=$this->record($this->driver)->getRecordIcon()?> - <?=$this->record($this->driver)->getRecordIconText()?> </div> <?php $thumbnail = ob_get_contents(); ?> <?php ob_end_clean(); ?> diff --git a/themes/finc/templates/record/cover.phtml b/themes/finc/templates/record/cover.phtml index ccc96247aef93c12b7ba2671726b0028e306ff52..e557d2210f79a7de886fcd9fde892f794e09b6af 100644 --- a/themes/finc/templates/record/cover.phtml +++ b/themes/finc/templates/record/cover.phtml @@ -10,7 +10,7 @@ <?php if ($this->link): ?> </a> <script> - registerCoverForModal($('#<?=$coverId?>'), '<?=$this->link?>'); + registerCoverForModal($('#<?=$coverId?>'), '<?=$cover?>'); </script> <?php endif; ?> <?php elseif ($cover === false): ?> diff --git a/themes/finc/templates/record/coverReplacement.phtml b/themes/finc/templates/record/coverReplacement.phtml index d74b4f1f8f5847b60f8da4fbe046abfddfab6438..d26b8d7bcb980e7a9d10d36e7f64b1cf126c1a32 100644 --- a/themes/finc/templates/record/coverReplacement.phtml +++ b/themes/finc/templates/record/coverReplacement.phtml @@ -1 +1 @@ -<?= $this->record($this->driver)->getRecordIcon() ?> \ No newline at end of file +<?= $this->record($this->driver)->getRecordIcon('record-icon', false) ?> \ No newline at end of file