Skip to content

Commit

Permalink
Simplified OpenURL code by removing getLinkDetailsForOpenUrl().
Browse files Browse the repository at this point in the history
- Fixed typo in result-grid.phtml in blueprint theme.
  • Loading branch information
demiankatz committed Aug 10, 2015
1 parent eb54539 commit 4719c76
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 33 deletions.
18 changes: 8 additions & 10 deletions module/VuFind/src/VuFind/View/Helper/Root/Record.php
Expand Up @@ -553,13 +553,15 @@ public function getUrlList()
* Get all the links associated with this record. Returns an array of
* associative arrays each containing 'desc' and 'url' keys.
*
* @param bool $openUrlActive Is there an active OpenURL on the page?
*
* @return array
*/
public function getLinkDetails()
public function getLinkDetails($openUrlActive = false)
{
// See if there are any links available:
$urls = $this->driver->tryMethod('getURLs');
if (empty($urls)) {
if (empty($urls) || ($openUrlActive && $this->hasOpenUrlReplaceSetting())) {
return [];
}

Expand Down Expand Up @@ -606,15 +608,11 @@ public function getLinkDetails()
* replace_other_urls. Returns an array of associative arrays each containing
* 'desc' and 'url' keys.
*
* @return array
* @return bool
*/
public function getLinkDetailsForOpenUrl()
protected function hasOpenUrlReplaceSetting()
{
if (isset($this->config->OpenURL->replace_other_urls)
&& $this->config->OpenURL->replace_other_urls
) {
return [];
}
return $this->getLinkDetails();
return isset($this->config->OpenURL->replace_other_urls)
&& $this->config->OpenURL->replace_other_urls;
}
}
Expand Up @@ -63,7 +63,7 @@
$openUrl = $this->openUrl($this->driver, 'results');
$openUrlActive = $openUrl->isActive();
// Account for replace_other_urls setting
$urls = $openUrlActive ? $this->record($this->driver)->getLinkDetailsForOpenUrl() : $this->record($this->driver)->getLinkDetails() ;
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
if ($openUrlActive || !empty($urls)): ?>
<? if ($openUrlActive): ?>
<br/>
Expand Down
Expand Up @@ -133,7 +133,7 @@
$openUrl = $this->openUrl($this->driver, 'record');
$openUrlActive = $openUrl->isActive();
// Account for replace_other_urls setting
$urls = $openUrlActive ? $this->record($this->driver)->getLinkDetailsForOpenUrl() : $this->record($this->driver)->getLinkDetails() ;
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
?>
<? if (!empty($urls) || $openUrlActive): ?>
<tr valign="top">
Expand Down
Expand Up @@ -174,7 +174,7 @@
$openUrl = $this->openUrl($this->driver, 'record');
$openUrlActive = $openUrl->isActive();
// Account for replace_other_urls setting
$urls = $openUrlActive ? $this->record($this->driver)->getLinkDetailsForOpenUrl() : $this->record($this->driver)->getLinkDetails() ;
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
?>
<? if (!empty($urls) || $openUrlActive): ?>
<tr valign="top">
Expand Down
Expand Up @@ -79,7 +79,7 @@
$openUrl = $this->openUrl($this->driver, 'results');
$openUrlActive = $openUrl->isActive();
// Account for replace_other_urls setting
$urls = $openUrlActive ? $this->record($this->driver)->getLinkDetailsForOpenUrl() : $this->record($this->driver)->getLinkDetails() ;
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
if ($openUrlActive || !empty($urls)): ?>
<? if ($openUrlActive): ?>
<br/>
Expand Down
Expand Up @@ -7,17 +7,17 @@
<a class="gridTitle" href="<?=$this->recordLink()->getUrl($this->driver)?>">
<?=$this->record($this->driver)->getTitleHtml(80)?>
</a>
<?
<?
/* We need to find out if we're supposed to display an OpenURL link ($openUrlActive),
but even if we don't plan to display the link, we still want to get the $openUrl
value for use in generating a COinS (Z3988) tag -- see bottom of file.
*/
$openUrl = $this->openUrl($this->driver, 'results');
$openUrlActive = $openUrl->isActive();
// Account for replace_other_urls setting
$urls = $openUrlActive ? $this->record($this->driver)->getLinkDetailsForOpenUrl() : $this->record($this->driver)->getLinkDetails() ;
?>
if ($openUrlActive || !empty($urls)): ?>
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
?>
<? if ($openUrlActive || !empty($urls)): ?>
<? if ($openUrlActive): ?>
<?=$openUrl->renderTemplate()?><br />
<? endif; ?>
Expand Down
Expand Up @@ -112,7 +112,7 @@
$openUrl = $this->openUrl($this->driver, 'results');
$openUrlActive = $openUrl->isActive();
// Account for replace_other_urls setting
$urls = $openUrlActive ? $this->record($this->driver)->getLinkDetailsForOpenUrl() : $this->record($this->driver)->getLinkDetails() ;
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
if ($openUrlActive || !empty($urls)): ?>
<? if ($openUrlActive): ?>
<br/>
Expand Down
2 changes: 1 addition & 1 deletion themes/blueprint/templates/RecordTab/holdingsils.phtml
Expand Up @@ -6,7 +6,7 @@
$openUrl = $this->openUrl($this->driver, 'holdings');
$openUrlActive = $openUrl->isActive();
// Account for replace_other_urls setting
$urls = $openUrlActive ? $this->record($this->driver)->getLinkDetailsForOpenUrl() : $this->record($this->driver)->getLinkDetails() ;
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
$offlineMode = $this->ils()->getOfflineMode();
// Set page title.
$this->headTitle($this->translate('Holdings') . ': ' . $this->driver->getBreadcrumb());
Expand Down
Expand Up @@ -78,7 +78,7 @@
$openUrl = $this->openUrl($this->driver, 'results');
$openUrlActive = $openUrl->isActive();
// Account for replace_other_urls setting
$urls = $openUrlActive ? $this->record($this->driver)->getLinkDetailsForOpenUrl() : $this->record($this->driver)->getLinkDetails() ;
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
if ($openUrlActive || !empty($urls)): ?>
<? if ($openUrlActive): ?>
<br/>
Expand Down
Expand Up @@ -156,7 +156,7 @@
$openUrl = $this->openUrl($this->driver, 'record');
$openUrlActive = $openUrl->isActive();
// Account for replace_other_urls setting
$urls = $openUrlActive ? $this->record($this->driver)->getLinkDetailsForOpenUrl() : $this->record($this->driver)->getLinkDetails() ;
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
?>
<? if (!empty($urls) || $openUrlActive): ?>
<tr>
Expand Down
Expand Up @@ -216,7 +216,7 @@
$openUrl = $this->openUrl($this->driver, 'record');
$openUrlActive = $openUrl->isActive();
// Account for replace_other_urls setting
$urls = $openUrlActive ? $this->record($this->driver)->getLinkDetailsForOpenUrl() : $this->record($this->driver)->getLinkDetails() ;
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
?>
<? if (!empty($urls) || $openUrlActive): ?>
<tr>
Expand Down
Expand Up @@ -130,7 +130,7 @@
$openUrl = $this->openUrl($this->driver, 'results');
$openUrlActive = $openUrl->isActive();
// Account for replace_other_urls setting
$urls = $openUrlActive ? $this->record($this->driver)->getLinkDetailsForOpenUrl() : $this->record($this->driver)->getLinkDetails() ;
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);

if ($openUrlActive || !empty($urls)):
?>
Expand Down
Expand Up @@ -6,7 +6,7 @@
$openUrl = $this->openUrl($this->driver, 'results');
$openUrlActive = $openUrl->isActive();
// Account for replace_other_urls setting
$urls = $openUrlActive ? $this->record($this->driver)->getLinkDetailsForOpenUrl() : $this->record($this->driver)->getLinkDetails() ;
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
?>

<div class="result <?=$this->driver->supportsAjaxStatus()?' ajaxItem':''?>">
Expand Down
Expand Up @@ -119,7 +119,7 @@
$openUrl = $this->openUrl($this->driver, 'results');
$openUrlActive = $openUrl->isActive();
// Account for replace_other_urls setting
$urls = $openUrlActive ? $this->record($this->driver)->getLinkDetailsForOpenUrl() : $this->record($this->driver)->getLinkDetails() ;
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);

if ($openUrlActive || !empty($urls)): ?>
<? if ($openUrlActive): ?>
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap3/templates/RecordTab/holdingsils.phtml
Expand Up @@ -6,7 +6,7 @@
$openUrl = $this->openUrl($this->driver, 'holdings');
$openUrlActive = $openUrl->isActive();
// Account for replace_other_urls setting
$urls = $openUrlActive ? $this->record($this->driver)->getLinkDetailsForOpenUrl() : $this->record($this->driver)->getLinkDetails() ;
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
$offlineMode = $this->ils()->getOfflineMode();
// Set page title.
$this->headTitle($this->translate('Holdings') . ': ' . $this->driver->getBreadcrumb());
Expand Down
Expand Up @@ -136,9 +136,7 @@
$openUrl = $this->openUrl($this->driver, 'record');
$openUrlActive = $openUrl->isActive();
// Account for replace_other_urls setting
$urls = $openUrlActive
? $this->record($this->driver)->getLinkDetailsForOpenUrl()
: $this->record($this->driver)->getLinkDetails();
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
?>
<? if (!empty($urls) || $openUrlActive): ?>
<dt><?=$this->transEsc('Online Access')?>: </dt>
Expand Down
Expand Up @@ -26,9 +26,7 @@
<?
$openUrl = $this->openUrl($this->driver, 'results');
$openUrlActive = $openUrl->isActive();
$urls = $openUrlActive
? $this->record($this->driver)->getLinkDetailsForOpenUrl()
: $this->record($this->driver)->getLinkDetails();
$urls = $this->record($this->driver)->getLinkDetails($openUrlActive);
?>
<? if (!$openUrlActive && empty($urls) && $this->driver->supportsAjaxStatus()): ?>
<p><span class="ajax_availability hide status"><?=$this->transEsc('Loading')?>...</span></p>
Expand Down

0 comments on commit 4719c76

Please sign in to comment.