Skip to content

Commit

Permalink
Rename view helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Dec 18, 2024
1 parent 9926c7d commit c2aaf3c
Show file tree
Hide file tree
Showing 21 changed files with 90 additions and 89 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* DOI view helper
* IdentifierLinker view helper
*
* PHP version 8
*
Expand Down Expand Up @@ -29,19 +29,20 @@

namespace VuFind\View\Helper\Root;

use VuFind\Config\Config;
use VuFind\RecordDriver\AbstractBase as RecordDriver;

use function in_array;

/**
* DOI view helper
* IdentifierLinker view helper
*
* @category VuFind
* @package View_Helpers
* @author Demian Katz <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
class Doi extends \Laminas\View\Helper\AbstractHelper
class IdentifierLinker extends \Laminas\View\Helper\AbstractHelper
{
/**
* Current RecordDriver
Expand Down Expand Up @@ -88,7 +89,7 @@ public function __construct(protected Context $context, protected array $config
* Set up context for helper
*
* @param RecordDriver $driver The current record driver
* @param string $area DOI context ('results', 'record' or 'holdings')
* @param string $area Display context ('results', 'record' or 'holdings')
*
* @return static
*/
Expand Down Expand Up @@ -136,7 +137,7 @@ public function renderTemplate()
}

/**
* Does the configuration indicate that we should display DOI links in
* Does the configuration indicate that we should display identifier links in
* the specified context?
*
* @return bool
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* DOI helper factory.
* IdentifierLinker helper factory.
*
* PHP version 8
*
Expand Down Expand Up @@ -36,15 +36,15 @@
use Psr\Container\ContainerInterface;

/**
* DOI helper factory.
* IdentifierLinker helper factory.
*
* @category VuFind
* @package View_Helpers
* @author Demian Katz <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
class DoiFactory implements FactoryInterface
class IdentifierLinkerFactory implements FactoryInterface
{
/**
* Create an object
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
$openUrl = $this->openUrl($this->driver, 'record');
$openUrlActive = $openUrl->isActive();
$doi = $this->doi($this->driver, 'record');
$doiActive = $doi->isActive();
$identifierLinker = $this->identifierLinker($this->driver, 'record');
$identifierLinkerActive = $identifierLinker->isActive();
// Account for replace_other_urls setting
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
?>
Expand All @@ -12,4 +12,4 @@
<?php if ($openUrlActive): ?>
<?=$openUrl->renderTemplate()?><br>
<?php endif; ?>
<?php if ($doiActive): ?><?=$doi->renderTemplate()?><?php endif; ?>
<?php if ($identifierLinkerActive): ?><?=$identifierLinker->renderTemplate()?><?php endif; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,20 @@
*/
$openUrl = $this->openUrl($this->driver, 'results');
$openUrlActive = $openUrl->isActive();
$doi = $this->doi($this->driver, 'results');
$doiActive = $doi->isActive();
$identifierLinker = $this->identifierLinker($this->driver, 'results');
$identifierLinkerActive = $identifierLinker->isActive();
// Account for replace_other_urls setting
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
?>
<?php if ($openUrlActive || $doiActive || !empty($urls)): ?>
<?php if ($openUrlActive || $identifierLinkerActive || !empty($urls)): ?>
<?php if ($openUrlActive): ?>
<br>
<?=$openUrl->renderTemplate()?>
<?php endif;?>

<?php if ($doiActive): ?>
<?php if ($identifierLinkerActive): ?>
<br>
<?=$doi->renderTemplate()?>
<?=$identifierLinker->renderTemplate()?>
<?php endif; ?>

<?php $urls = is_array($urls) ? $urls : []; ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/
$openUrl = $this->openUrl($this->driver, 'results');
$openUrlActive = $openUrl->isActive();
$doi = $this->doi($this->driver, 'results');
$doiActive = $doi->isActive();
$identifierLinker = $this->identifierLinker($this->driver, 'results');
$identifierLinkerActive = $identifierLinker->isActive();
// Account for replace_other_urls setting
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
$recordLinker = $this->recordLinker($this->results);
Expand Down Expand Up @@ -35,13 +35,13 @@ $showCheckboxes = $this->searchSettings($this->results->getParams())->checkboxes
<?=$this->record($this->driver)->getTitleHtml(80)?>
</a>
</h2>
<?php if ($openUrlActive || $doiActive || !empty($urls)): ?>
<?php if ($openUrlActive || $identifierLinkerActive || !empty($urls)): ?>
<br><br>
<?php if ($openUrlActive): ?>
<?=$openUrl->renderTemplate()?><br>
<?php endif; ?>
<?php if ($doiActive): ?>
<?=$doi->renderTemplate()?><br>
<?php if ($identifierLinkerActive): ?>
<?=$identifierLinker->renderTemplate()?><br>
<?php endif; ?>
<?php foreach (is_array($urls) ? $urls : [] as $current): ?>
<a href="<?=$this->escapeHtmlAttr($this->proxyUrl($current['url']))?>" class="fulltext" target="new">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,19 @@
// Display an OpenURL link if configured to do so:
$openUrl = $this->openUrl($this->driver, 'results');
$openUrlActive = $openUrl->isActive();
$doi = $this->doi($this->driver, 'results');
$doiActive = $doi->isActive();
$identifierLinker = $this->identifierLinker($this->driver, 'results');
$identifierLinkerActive = $identifierLinker->isActive();
// Account for replace_other_urls setting
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
?>
<?php if ($openUrlActive || $doiActive || !empty($urls)): ?>
<?php if ($openUrlActive || $identifierLinkerActive || !empty($urls)): ?>
<?php if ($openUrlActive): ?>
<br>
<?=$openUrl->renderTemplate()?>
<?php endif; ?>
<?php if ($doiActive): ?>
<?php if ($identifierLinkerActive): ?>
<br>
<?=$doi->renderTemplate()?>
<?=$identifierLinker->renderTemplate()?>
<?php endif; ?>
<?php $urls = is_array($urls) ? $urls : []; ?>
<?php if (!$this->driver->isCollection()): ?>
Expand Down
6 changes: 3 additions & 3 deletions themes/bootstrap3/templates/RecordDriver/EDS/core.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@
<?php endforeach; ?>
<?php endif; ?>

<?php $doi = $this->doi($this->driver, 'record'); ?>
<?php if ($doi->isActive()): ?>
<div><?=$doi->renderTemplate()?></div>
<?php $identifierLinker = $this->identifierLinker($this->driver, 'record'); ?>
<?php if ($identifierLinker->isActive()): ?>
<div><?=$identifierLinker->renderTemplate()?></div>
<?php endif; ?>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@
);
?>

<?php /* Links from DOI linker */ ?>
<?php $doi = $this->doi($this->driver, 'results'); ?>
<?php if ($doi->isActive()): ?>
<div><?=$doi->renderTemplate()?></div>
<?php /* Links from identifier linker */ ?>
<?php $identifierLinker = $this->identifierLinker($this->driver, 'results'); ?>
<?php if ($identifierLinker->isActive()): ?>
<div><?=$identifierLinker->renderTemplate()?></div>
<?php endif; ?>
</div>
<div class="result-links hidden-print">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,19 @@
*/
$openUrl = $this->openUrl($this->driver, 'results');
$openUrlActive = $openUrl->isActive();
$doi = $this->doi($this->driver, 'results');
$doiActive = $doi->isActive();
$identifierLinker = $this->identifierLinker($this->driver, 'results');
$identifierLinkerActive = $identifierLinker->isActive();
// Account for replace_other_urls setting
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);

if ($openUrlActive || $doiActive || !empty($urls)): ?>
if ($openUrlActive || $identifierLinkerActive || !empty($urls)): ?>
<?php if ($openUrlActive): ?>
<br>
<?=$openUrl->renderTemplate()?>
<?php endif; ?>
<?php if ($doiActive): ?>
<?php if ($identifierLinkerActive): ?>
<br>
<?=$doi->renderTemplate()?>
<?=$identifierLinker->renderTemplate()?>
<?php endif; ?>
<?php $urls = is_array($urls) ? $urls : []; ?>
<?php if (!$this->driver->isCollection()): ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,19 @@
// Display an OpenURL link if configured to do so:
$openUrl = $this->openUrl($this->driver, 'results');
$openUrlActive = $openUrl->isActive();
$doi = $this->doi($this->driver, 'results');
$doiActive = $doi->isActive();
$identifierLinker = $this->identifierLinker($this->driver, 'results');
$identifierLinkerActive = $identifierLinker->isActive();
// Account for replace_other_urls setting
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
?>
<?php if ($openUrlActive || $doiActive || !empty($urls)): ?>
<?php if ($openUrlActive || $identifierLinkerActive || !empty($urls)): ?>
<?php if ($openUrlActive): ?>
<br>
<?=$openUrl->renderTemplate()?>
<?php endif; ?>
<?php if ($doiActive): ?>
<?php if ($identifierLinkerActive): ?>
<br>
<?=$doi->renderTemplate()?>
<?=$identifierLinker->renderTemplate()?>
<?php endif; ?>
<?php $urls = is_array($urls) ? $urls : []; ?>
<?php if (!$this->driver->isCollection()): ?>
Expand Down
8 changes: 4 additions & 4 deletions themes/bootstrap3/templates/RecordTab/holdingsils.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
$user = $account->getUserObject();
$openUrl = $this->openUrl($this->driver, 'holdings');
$openUrlActive = $openUrl->isActive();
$doi = $this->doi($this->driver, 'holdings');
$doiActive = $doi->isActive();
$identifierLinker = $this->identifierLinker($this->driver, 'holdings');
$identifierLinkerActive = $identifierLinker->isActive();
// Account for replace_other_urls setting
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
$offlineMode = $this->ils()->getOfflineMode();
Expand Down Expand Up @@ -62,15 +62,15 @@
<span class="icon-link__label"><?=$this->transEsc('title_hold_place')?></span>
</a>
<?php endif; ?>
<?php if (!empty($urls) || $openUrlActive || $doiActive): ?>
<?php if (!empty($urls) || $openUrlActive || $identifierLinkerActive): ?>
<h2><?=$this->transEsc('Internet')?></h2>
<?php if (!empty($urls)): ?>
<?php foreach ($urls as $current): ?>
<a href="<?=$this->escapeHtmlAttr($this->proxyUrl($current['url']))?>"><?=$this->escapeHtml($current['desc'])?></a><br>
<?php endforeach; ?>
<?php endif; ?>
<?php if ($openUrlActive): ?><?=$openUrl->renderTemplate()?><?php endif; ?>
<?php if ($doiActive): ?><?=$doi->renderTemplate()?><?php endif; ?>
<?php if ($identifierLinkerActive): ?><?=$identifierLinker->renderTemplate()?><?php endif; ?>
<?php endif; ?>

<?php if (!empty($holdings['electronic_holdings'])): ?>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
$openUrl = $this->openUrl($this->driver, 'record');
$openUrlActive = $openUrl->isActive();
$doi = $this->doi($this->driver, 'record');
$doiActive = $doi->isActive();
$identifierLinker = $this->identifierLinker($this->driver, 'record');
$identifierLinkerActive = $identifierLinker->isActive();
// Account for replace_other_urls setting
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
?>
Expand All @@ -12,4 +12,4 @@
<?php if ($openUrlActive): ?>
<?=$openUrl->renderTemplate()?><br>
<?php endif; ?>
<?php if ($doiActive): ?><?=$doi->renderTemplate()?><?php endif; ?>
<?php if ($identifierLinkerActive): ?><?=$identifierLinker->renderTemplate()?><?php endif; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,20 @@
*/
$openUrl = $this->openUrl($this->driver, 'results');
$openUrlActive = $openUrl->isActive();
$doi = $this->doi($this->driver, 'results');
$doiActive = $doi->isActive();
$identifierLinker = $this->identifierLinker($this->driver, 'results');
$identifierLinkerActive = $identifierLinker->isActive();
// Account for replace_other_urls setting
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
?>
<?php if ($openUrlActive || $doiActive || !empty($urls)): ?>
<?php if ($openUrlActive || $identifierLinkerActive || !empty($urls)): ?>
<?php if ($openUrlActive): ?>
<br>
<?=$openUrl->renderTemplate()?>
<?php endif;?>

<?php if ($doiActive): ?>
<?php if ($identifierLinkerActive): ?>
<br>
<?=$doi->renderTemplate()?>
<?=$identifierLinker->renderTemplate()?>
<?php endif; ?>

<?php $urls = is_array($urls) ? $urls : []; ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/
$openUrl = $this->openUrl($this->driver, 'results');
$openUrlActive = $openUrl->isActive();
$doi = $this->doi($this->driver, 'results');
$doiActive = $doi->isActive();
$identifierLinker = $this->identifierLinker($this->driver, 'results');
$identifierLinkerActive = $identifierLinker->isActive();
// Account for replace_other_urls setting
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
$recordLinker = $this->recordLinker($this->results);
Expand Down Expand Up @@ -35,13 +35,13 @@ $showCheckboxes = $this->searchSettings($this->results->getParams())->checkboxes
<?=$this->record($this->driver)->getTitleHtml(80)?>
</a>
</h2>
<?php if ($openUrlActive || $doiActive || !empty($urls)): ?>
<?php if ($openUrlActive || $identifierLinkerActive || !empty($urls)): ?>
<br><br>
<?php if ($openUrlActive): ?>
<?=$openUrl->renderTemplate()?><br>
<?php endif; ?>
<?php if ($doiActive): ?>
<?=$doi->renderTemplate()?><br>
<?php if ($identifierLinkerActive): ?>
<?=$identifierLinker->renderTemplate()?><br>
<?php endif; ?>
<?php foreach (is_array($urls) ? $urls : [] as $current): ?>
<a href="<?=$this->escapeHtmlAttr($this->proxyUrl($current['url']))?>" class="fulltext" target="new">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,19 @@
// Display an OpenURL link if configured to do so:
$openUrl = $this->openUrl($this->driver, 'results');
$openUrlActive = $openUrl->isActive();
$doi = $this->doi($this->driver, 'results');
$doiActive = $doi->isActive();
$identifierLinker = $this->identifierLinker($this->driver, 'results');
$identifierLinkerActive = $identifierLinker->isActive();
// Account for replace_other_urls setting
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
?>
<?php if ($openUrlActive || $doiActive || !empty($urls)): ?>
<?php if ($openUrlActive || $identifierLinkerActive || !empty($urls)): ?>
<?php if ($openUrlActive): ?>
<br>
<?=$openUrl->renderTemplate()?>
<?php endif; ?>
<?php if ($doiActive): ?>
<?php if ($identifierLinkerActive): ?>
<br>
<?=$doi->renderTemplate()?>
<?=$identifierLinker->renderTemplate()?>
<?php endif; ?>
<?php $urls = is_array($urls) ? $urls : []; ?>
<?php if (!$this->driver->isCollection()): ?>
Expand Down
6 changes: 3 additions & 3 deletions themes/bootstrap5/templates/RecordDriver/EDS/core.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@
<?php endforeach; ?>
<?php endif; ?>

<?php $doi = $this->doi($this->driver, 'record'); ?>
<?php if ($doi->isActive()): ?>
<div><?=$doi->renderTemplate()?></div>
<?php $identifierLinker = $this->identifierLinker($this->driver, 'record'); ?>
<?php if ($identifierLinker->isActive()): ?>
<div><?=$identifierLinker->renderTemplate()?></div>
<?php endif; ?>
</div>
</div>
Expand Down
Loading

0 comments on commit c2aaf3c

Please sign in to comment.