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

refs #22002 [finc] moving base css icon class from template into icon mapping configuration

* view helper loads additional property from ini and adds css class to view variable

co-authored by: Robert Lange <robert.lange@uni-leipzig.de>
* code styles
parent 1a937f21
No related merge requests found
...@@ -18,6 +18,9 @@ concatenateKeys = false ...@@ -18,6 +18,9 @@ concatenateKeys = false
; Formats[default] = "" ; Formats[default] = ""
; Formats[unknown] = "" ; Formats[unknown] = ""
; prepending special icon css class
baseIconClass = "fa"
; finc default mapping for facet_avail ; finc default mapping for facet_avail
FacetAvail[marcfincpda] = "fa-home passive" FacetAvail[marcfincpda] = "fa-home passive"
FacetAvail[object] = "fa-home object" FacetAvail[object] = "fa-home object"
......
...@@ -106,6 +106,14 @@ class Record extends \VuFind\View\Helper\Root\Record ...@@ -106,6 +106,14 @@ class Record extends \VuFind\View\Helper\Root\Record
*/ */
protected $concatKeysForIconMapping; protected $concatKeysForIconMapping;
/**
* Base css class for displaying icons
* Like 'fa' needed by font awesome
*
* @var string
*/
protected $baseIconClass;
/** /**
* Constructor * Constructor
* *
...@@ -144,6 +152,8 @@ class Record extends \VuFind\View\Helper\Root\Record ...@@ -144,6 +152,8 @@ class Record extends \VuFind\View\Helper\Root\Record
->StyleBasedIcons->concatenateKeys ->StyleBasedIcons->concatenateKeys
) && $this->iconConfig ) && $this->iconConfig
->StyleBasedIcons->concatenateKeys ? true : false; ->StyleBasedIcons->concatenateKeys ? true : false;
$this->baseIconClass = $this->iconConfig->StyleBasedIcons
->baseIconClass ?? 'fa';
} }
} }
...@@ -161,7 +171,10 @@ class Record extends \VuFind\View\Helper\Root\Record ...@@ -161,7 +171,10 @@ class Record extends \VuFind\View\Helper\Root\Record
): string { ): string {
$iconType = $this->getRecordIconType(); $iconType = $this->getRecordIconType();
$iconClass = $this->getRecordIconClass($iconType); $iconClass = $this->getRecordIconClass($iconType);
return $this->renderTemplate($tpl . '.phtml', ['iconClass' => $iconClass]) return $this->renderTemplate(
$tpl . '.phtml',
['iconClass' => $this->baseIconClass . ' ' . $iconClass]
)
. ($addText ? $this->getRecordIconText($iconType, $iconClass) : ''); . ($addText ? $this->getRecordIconText($iconType, $iconClass) : '');
} }
...@@ -212,8 +225,7 @@ class Record extends \VuFind\View\Helper\Root\Record ...@@ -212,8 +225,7 @@ class Record extends \VuFind\View\Helper\Root\Record
protected function getRecordIconType() protected function getRecordIconType()
{ {
$recordType = $this->driver->getRecordType(); $recordType = $this->driver->getRecordType();
switch ($recordType) switch ($recordType) {
{
case 'lido': case 'lido':
return "object"; return "object";
case 'missing': case 'missing':
...@@ -226,7 +238,9 @@ class Record extends \VuFind\View\Helper\Root\Record ...@@ -226,7 +238,9 @@ class Record extends \VuFind\View\Helper\Root\Record
$recordTypes = $this->driver->tryMethod("get{$type}") ?? ['default']; $recordTypes = $this->driver->tryMethod("get{$type}") ?? ['default'];
$recordTypes = $this->concatKeysForIconMapping ? $recordTypes = $this->concatKeysForIconMapping ?
implode('', $recordTypes) : $recordTypes[0] ?? 'default'; implode('', $recordTypes) : $recordTypes[0] ?? 'default';
$recordType .= strtolower(str_replace([' ','-',','], '', $recordTypes)); $recordType .= strtolower(
str_replace([' ','-',','], '', $recordTypes)
);
} }
return $recordType; return $recordType;
} }
...@@ -525,7 +539,9 @@ class Record extends \VuFind\View\Helper\Root\Record ...@@ -525,7 +539,9 @@ class Record extends \VuFind\View\Helper\Root\Record
$onlineEditions[] = $add; $onlineEditions[] = $add;
} }
} elseif (isset($add['related_records'])) { } elseif (isset($add['related_records'])) {
foreach ($add['related_records']['first_results'] as $linkedRecord) { foreach (
$add['related_records']['first_results'] as $linkedRecord
) {
$link = $recordLinkHelper->getTabUrl($linkedRecord); $link = $recordLinkHelper->getTabUrl($linkedRecord);
if (!empty($link)) { if (!empty($link)) {
//overwrite link in entry and add to result array //overwrite link in entry and add to result array
......
<!-- finc: recordDriver - DefaultRecord - record-icon --> <!-- finc: recordDriver - DefaultRecord - record-icon -->
<?php if (!empty($iconClass)): ?> <?php if (!empty($iconClass)): ?>
<span class="access-icon hidden-print"> <span class="access-icon hidden-print">
<i aria-hidden="true" class="fa <?=$iconClass?>"></i> <i aria-hidden="true" class="<?=$iconClass?>"></i>
<?php /* separate access text from icon - moved to cover.phtml */ ?> <?php /* separate access text from icon - moved to cover.phtml */ ?>
</span> </span>
<?php endif; ?> <?php endif; ?>
......
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