Skip to content
Snippets Groups Projects
Commit e9f874d5 authored by Alexander Purr's avatar Alexander Purr Committed by Robert Lange
Browse files

refs #21909 [finc] rearrange usage of record data formatter within record tab

* usage like in description tab
** only one spec definition for whole topics tab
** reuse description tabs template
* remove single definition for rvk and signature in formatter factory
* remove in ticket 21133 introduced templates: data-rvk & data-topics
** use default / more accessible templates instead
parent a5130110
No related merge requests found
......@@ -92,12 +92,8 @@ class RecordDataFormatterFactory
[$this, 'getMarcCoreSpecs']
);
$helper->setDefaults(
'rvk',
[$this, 'getRvkSpecs']
);
$helper->setDefaults(
'topics',
[$this, 'getTopicsSpecs']
'topics-tab',
[$this, 'getTopicsTabSpecs']
);
return $helper;
......@@ -921,35 +917,24 @@ class RecordDataFormatterFactory
);
return $spec->getArray();
}
/**
* Get marc specifications for displaying rvk.
* Get default specifications for displaying data in the topics tab.
*
* @return array
*/
public function getRvkSpecs()
public function getTopicsTabSpecs()
{
$spec = new RecordDataFormatter\SpecBuilder();
$spec->setTemplateLine(
'Topics',
'RVK',
'getRvkWithMetadata',
'data-rvk.phtml'
'data-rvkNotation.phtml'
);
return $spec->getArray();
}
/**
* Get marc specifications for displaying topics.
*
* @return array
*/
public function getTopicsSpecs()
{
$spec = new RecordDataFormatter\SpecBuilder();
$spec->setTemplateLine(
'Topics',
'Subjects',
'getTopics',
'data-topics.phtml'
'data-allSubjectHeadingsWithExtended.phtml'
);
return $spec->getArray();
}
......
<!-- finc: RecordDriver - DefaultRecord - data-rvk -->
<tr>
<th><?=$this->transEsc('RVK')?>:</th>
<td data-title="<?= $this->transEsc('RVK') ?>:">
<?php $i = 0; foreach ($data as $item): ?>
<?=($i > 0 ? "<br />" : "") //no linebreak after last item?>
<?=$item['rvk']?>
<?php if (isset($item['level']) || isset($item['name'])): ?>
<?php
$tooltip_content = "<ul class='no-bullet'>" . (isset($item['name']) ? "<li><strong>" . $item['name'] . "</strong></li>" : "");
if (isset($item['level']) && count($item['level'])) {
foreach ($item['level'] as $level) {
$tooltip_content .= "<li>" . $level . "</li>";
}
}
$tooltip_content .= "</ul>";
?>
<?php endif; ?>
<span <?=(isset($tooltip_content) ? 'data-toggle="tooltip" data-html="true" title="' . $tooltip_content . '"' : "")?>>
<a href="<?=$this->record($this->driver)->getLink('rvk', $item['rvk'])?>"> <i class="fa fa-search" aria-hidden="true"></i> <?=$this->transEsc('Find Similar Items');?></a>
</span>
<?php $i++; ?>
<?php endforeach; ?>
</td>
</tr>
<!-- finc: RecordDriver - DefaultRecord - data-rvk - END -->
<!-- finc: RecordDriver - DefaultRecord - data-topics -->
<tr>
<th><?=$this->transEsc('Subjects')?>: </th>
<td data-title="<?= $this->transEsc('Subjects') ?>:">
<?php foreach ($data as $field): ?>
<div class="subject-line" property="keywords">
<?php $subject = ''; ?>
<?php
if (count($field) == 1 && !isset($field['subject'])) {
$field = explode('--', $field[0]);
}
?>
<?php if (isset($field['subject'])): /* extended topics */?>
<?php $field = $field['subject']; ?>
<?php endif; ?>
<?php $i = 0; foreach ($field as $subfield): ?>
<?=($i++ == 0) ? '' : ' &gt; '?>
<?php $subject = trim($subject . ' ' . $subfield); ?>
<a title="<?=$this->escapeHtmlAttr($subject)?>" href="<?=$this->record($this->driver)->getLink('subject', $subject)?>" rel="nofollow"><?=trim($this->escapeHtml($subfield))?></a>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
</td>
</tr>
<!-- finc: RecordDriver - DefaultRecord - data-topics - END -->
<!-- finc: recordtab - topics -->
<?php /* template copied from themes/finc/templates/RecordTab/description.phtml
same display logic */ ?>
<?php
// Set page title.
$this->headTitle($this->translate('Topics') . ': ' . $this->driver->getBreadcrumb());
$formatter = $this->recordDataFormatter();
$rvk = $formatter->getData($this->driver, $formatter->getDefaults('rvk'));
$topics = $formatter->getData($this->driver, $formatter->getDefaults('topics'));
// Set page title.
$this->headTitle($this->translate('Topics') . ': ' . $this->driver->getBreadcrumb());
$formatter = $this->recordDataFormatter();
$mainFields = $formatter->getData($driver, $formatter->getDefaults('topics-tab'));
?>
<?php /* finc: remove schema tag here but keep in core, include responsive data table - CK */ ?>
<table class="table table-striped table-resp-data">
<?php
/* Table gets filled via recordDriver/.../data-... templates as referenced in RecordDataFormatterFactory */ ?>
<caption><span class="sr-only"><?=$this->transEsc('Topics')?></span></caption>
<?php foreach ($rvk as $rvkItem): ?>
<?= $rvkItem['value'] ?? ''?>
<?php endforeach; ?>
<?php foreach ($topics as $topicsItem): ?>
<?= $topicsItem['value'] ?? ''?>
<?php endforeach; ?>
<?php if (!empty($mainFields)): ?>
<?php foreach ($mainFields as $current): ?>
<tr>
<?php if (!empty($current['label'])): ?>
<th><?=$this->transEsc($current['label'])?>:</th>
<td lang="" data-title="<?= $this->transEsc($current['label']) ?>:">
<?php else: ?>
<td lang="" colspan="2">
<?php endif; ?>
<?=$current['value']?></td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr><td><?=$this->transEsc('no_description')?></td></tr>
<?php endif; ?>
</table>
<!-- finc: recordtab - topics - END -->
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