Skip to content
Snippets Groups Projects
Commit bb4cbf59 authored by Dorian Merz's avatar Dorian Merz Committed by Robert Lange
Browse files

refs #19336 [finc] introduce RecordDataFormatter config for TOC tab contents

* use getTOC and specific data template for TOC tab
parent bae74ca2
No related merge requests found
......@@ -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();
}
}
<!-- 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
<!-- 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
<!-- 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
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment