diff --git a/module/finc/src/finc/View/Helper/Root/RecordDataFormatterFactory.php b/module/finc/src/finc/View/Helper/Root/RecordDataFormatterFactory.php index 372032924f2c49ace68fa61226e0660a22dbcf41..4b8ae4866d25c59f90f315af5305f28e94578535 100644 --- a/module/finc/src/finc/View/Helper/Root/RecordDataFormatterFactory.php +++ b/module/finc/src/finc/View/Helper/Root/RecordDataFormatterFactory.php @@ -71,6 +71,10 @@ class RecordDataFormatterFactory 'description', [$this, 'getDefaultDescriptionSpecs'] ); + $helper->setDefaults( + 'toc', + [$this, 'getTOCSpecs'] + ); $helper->setDefaults( 'core-ai', [$this, 'getAiCoreSpecs'] @@ -893,4 +897,20 @@ class RecordDataFormatterFactory ? 'rda_original_title' : 'non_rda_original_title'; } + + /** + * Get marc specifications for displaying table of contents. + * + * @return array + */ + public function getTOCSpecs() + { + $spec = new RecordDataFormatter\SpecBuilder(); + $spec->setTemplateLine( + 'Table of Contents', + 'getTOC', + 'data-toc.phtml' + ); + return $spec->getArray(); + } } diff --git a/themes/finc-accessibility/templates/RecordTab/toc.phtml b/themes/finc-accessibility/templates/RecordTab/toc.phtml deleted file mode 100644 index 6e71822f85068fe2a473bbc3071afd496220f6f5..0000000000000000000000000000000000000000 --- a/themes/finc-accessibility/templates/RecordTab/toc.phtml +++ /dev/null @@ -1,35 +0,0 @@ -<!-- finc-accessibility: RecordTab - toc --> -<?php /** - * copy of VuFind-version, adds empty lang-attribute to <li>s - */ -?> -?> -<?php - // Set page title. - $this->headTitle($this->translate('Table of Contents') . ': ' . $this->driver->getBreadcrumb()); - - $toc = $this->tab->getContent(); - if (empty($toc)) { - $driverToc = $this->driver->getTOC(); - if (!empty($driverToc)) { - $toc['RecordDriver'] = $driverToc; - } - } -?> -<?php if (!empty($toc)): ?> - <strong><?=$this->transEsc('Table of Contents')?>: </strong> - <?php foreach ($toc as $provider => $content): ?> - <?php if (!is_array($content)): // treat non-array content as raw HTML ?> - <?=$content?> - <?php else: ?> - <ul class="toc"> - <?php foreach ($content as $line): ?> - <li lang=""><?=$this->escapeHtml($line)?></li> - <?php endforeach; ?> - </ul> - <?php endif; ?> - <?php endforeach; ?> -<?php else: ?> - <?=$this->transEsc('Table of Contents unavailable')?>. -<?php endif; ?> -<!-- finc-accessibility: RecordTab - toc - END --> \ No newline at end of file diff --git a/themes/finc/templates/RecordDriver/DefaultRecord/data-toc.phtml b/themes/finc/templates/RecordDriver/DefaultRecord/data-toc.phtml new file mode 100644 index 0000000000000000000000000000000000000000..e2c53a3d900f0d10a657f91ebf98844d159259af --- /dev/null +++ b/themes/finc/templates/RecordDriver/DefaultRecord/data-toc.phtml @@ -0,0 +1,7 @@ +<!-- finc: RecordDriver - DefaultRecord - data-toc --> +<ul class="toc"> +<?php foreach ($data as $item): ?> + <li lang=""><?=$this->escapeHtml($item)?></li> +<?php endforeach; ?> +</ul> +<!-- finc: RecordDriver - DefaultRecord - data-toc - END --> \ No newline at end of file diff --git a/themes/finc/templates/RecordTab/toc.phtml b/themes/finc/templates/RecordTab/toc.phtml new file mode 100644 index 0000000000000000000000000000000000000000..eb89dc704ee6e9e182599bac1de1076753b76bf9 --- /dev/null +++ b/themes/finc/templates/RecordTab/toc.phtml @@ -0,0 +1,16 @@ +<!-- finc: RecordTab - toc --> +<?php + // Set page title. + $this->headTitle($this->translate('Table of Contents') . ': ' . $this->driver->getBreadcrumb()); + $formatter = $this->recordDataFormatter(); + $mainFields = $formatter->getData($this->driver, $formatter->getDefaults('toc')); +?> +<?php if (!empty($mainFields)): ?> + <?php foreach ($mainFields as $current): ?> + <strong><?=$this->transEsc($current['label'])?>: </strong> + <?=$current['value']?> + <?php endforeach; ?> +<?php else: ?> + <?=$this->transEsc('Table of Contents unavailable')?>. +<?php endif; ?> +<!-- finc: RecordTab - toc - END --> \ No newline at end of file