forked from NatLibFi/NDL-VuFind2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into alertschedule3
- Loading branch information
Showing
36 changed files
with
629 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -274,6 +274,79 @@ public function getMyListsAjax() | |
return $this->output($html, self::STATUS_OK); | ||
} | ||
|
||
/** | ||
* Fetch Links from resolver given an OpenURL and format as HTML | ||
* and output the HTML content in JSON object. | ||
* | ||
* @return \Zend\Http\Response | ||
* @author Graham Seaman <[email protected]> | ||
*/ | ||
protected function getResolverLinksAjax() | ||
{ | ||
$this->writeSession(); // avoid session write timing bug | ||
$openUrl = $this->params()->fromQuery('openurl', ''); | ||
|
||
$config = $this->getConfig(); | ||
$resolverType = isset($config->OpenURL->resolver) | ||
? $config->OpenURL->resolver : 'other'; | ||
$pluginManager = $this->getServiceLocator() | ||
->get('VuFind\ResolverDriverPluginManager'); | ||
if (!$pluginManager->has($resolverType)) { | ||
return $this->output( | ||
$this->translate("Could not load driver for $resolverType"), | ||
self::STATUS_ERROR | ||
); | ||
} | ||
$resolver = new \VuFind\Resolver\Connection( | ||
$pluginManager->get($resolverType) | ||
); | ||
if (isset($config->OpenURL->resolver_cache)) { | ||
$resolver->enableCache($config->OpenURL->resolver_cache); | ||
} | ||
$result = $resolver->fetchLinks($openUrl); | ||
|
||
// Sort the returned links into categories based on service type: | ||
$electronic = $print = $services = []; | ||
foreach ($result as $link) { | ||
switch (isset($link['service_type']) ? $link['service_type'] : '') { | ||
case 'getHolding': | ||
$print[] = $link; | ||
break; | ||
case 'getWebService': | ||
$services[] = $link; | ||
break; | ||
case 'getDOI': | ||
// Special case -- modify DOI text for special display: | ||
$link['title'] = $this->translate('Get full text'); | ||
$link['coverage'] = ''; | ||
case 'getFullTxt': | ||
default: | ||
$electronic[] = $link; | ||
break; | ||
} | ||
} | ||
|
||
// Get the OpenURL base: | ||
if (isset($config->OpenURL) && isset($config->OpenURL->url)) { | ||
// Trim off any parameters (for legacy compatibility -- default config | ||
// used to include extraneous parameters): | ||
list($base) = explode('?', $config->OpenURL->url); | ||
} else { | ||
$base = false; | ||
} | ||
|
||
// Render the links using the view: | ||
$view = [ | ||
'openUrlBase' => $base, 'openUrl' => $openUrl, 'print' => $print, | ||
'electronic' => $electronic, 'services' => $services, | ||
'searchClassId' => $this->params()->fromQuery('searchClassId', '') | ||
]; | ||
$html = $this->getViewRenderer()->render('ajax/resolverLinks.phtml', $view); | ||
|
||
// output HTML encoded in JSON object | ||
return $this->output($html, self::STATUS_OK); | ||
} | ||
|
||
/** | ||
* Update or create a list object. | ||
* | ||
|
@@ -512,14 +585,14 @@ public function getFeedAjax() | |
|
||
$type = $config->type; | ||
$channel = null; | ||
|
||
// Check for cached version | ||
$cacheEnabled = false; | ||
$cacheDir = $this->getServiceLocator()->get('VuFind\CacheManager') | ||
->getCache('feed')->getOptions()->getCacheDir(); | ||
|
||
$localFile = "$cacheDir/" . md5(var_export($config, true)) . '.xml'; | ||
|
||
$cacheConfig = $this->getServiceLocator() | ||
->get('VuFind\Config')->get('config'); | ||
$maxAge = isset($cacheConfig->Content->feedcachetime) | ||
|
@@ -533,7 +606,7 @@ public function getFeedAjax() | |
$channel = Reader::importFile($localFile); | ||
} | ||
} | ||
|
||
if (!$channel) { | ||
// No cache available, read from source. | ||
if (preg_match('/^http(s)?:\/\//', $url)) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
* @category VuFind2 | ||
* @package RecordDrivers | ||
* @author Samuli Sillanpää <[email protected]> | ||
* @author Ere Maijala <[email protected]> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link http://vufind.org/wiki/vufind2:record_drivers Wiki | ||
*/ | ||
|
@@ -34,6 +35,7 @@ | |
* @category VuFind2 | ||
* @package RecordDrivers | ||
* @author Samuli Sillanpää <[email protected]> | ||
* @author Ere Maijala <[email protected]> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link http://vufind.org/wiki/vufind2:record_drivers Wiki | ||
*/ | ||
|
@@ -177,6 +179,20 @@ public function getBuilding() | |
return null; | ||
} | ||
|
||
/** | ||
* Return information whether fulltext is available | ||
* | ||
* @return bool | ||
*/ | ||
public function getFulltextAvailable() | ||
{ | ||
$rec = $this->getSimpleXML(); | ||
if (isset($rec->delivery->fulltext)) { | ||
return $rec->delivery->fulltext == 'fulltext'; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Return image rights. | ||
* | ||
|
@@ -210,81 +226,32 @@ public function getRecordImage($size = 'small', $index = 0) | |
return $params; | ||
} | ||
|
||
/** | ||
* Get OpenURL parameters for an article. | ||
* | ||
* @return array | ||
*/ | ||
protected function getArticleOpenURLParams() | ||
{ | ||
return $this->processOpenURLParams( | ||
parent::getArticleOpenURLParams() | ||
); | ||
} | ||
|
||
/** | ||
* Get OpenURL parameters for a book. | ||
* | ||
* @return array | ||
*/ | ||
protected function getBookOpenURLParams() | ||
{ | ||
return $this->processOpenURLParams( | ||
parent::getBookOpenURLParams() | ||
); | ||
} | ||
|
||
/** | ||
* Get OpenURL parameters for a journal. | ||
* | ||
* @return array | ||
*/ | ||
protected function getJournalOpenURLParams() | ||
{ | ||
return $this->processOpenURLParams( | ||
parent::getJournalOpenURLParams() | ||
); | ||
} | ||
|
||
/** | ||
* Get OpenURL parameters for an unknown format. | ||
* | ||
* @param string $format Name of format | ||
* | ||
* @return array | ||
*/ | ||
protected function getUnknownFormatOpenURLParams($format) | ||
{ | ||
return $this->processOpenURLParams( | ||
parent::getUnknownFormatOpenURLParams($format) | ||
); | ||
} | ||
|
||
/** | ||
* Get default OpenURL parameters. | ||
* | ||
* @return array|false | ||
* @return array | ||
*/ | ||
protected function getDefaultOpenURLParams() | ||
{ | ||
if (!isset($this->mainConfig->OpenURL->rfr_id) | ||
|| empty($this->mainConfig->OpenURL->rfr_id) | ||
) { | ||
return false; | ||
} | ||
|
||
$link = $this->fields['url']; | ||
$link = isset($this->fields['url']) ? $this->fields['url'] : ''; | ||
|
||
$params = []; | ||
// Take params from the OpenURL returned from Primo, if available | ||
if ($link && strpos($link, 'url_ver=Z39.88-2004') !== false) { | ||
parse_str(substr($link, strpos($link, '?') + 1), $params); | ||
$params['rfr_id'] = $this->mainConfig->OpenURL->rfr_id; | ||
if ($dates = $this->getPublicationDates()) { | ||
$params['rft.date'] = implode('', $this->getPublicationDates()); | ||
} | ||
return $params; | ||
$params = $this->processOpenURLParams($params); | ||
} | ||
$params['rfr_id'] = !empty($this->mainConfig->OpenURL->rfr_id) | ||
? $this->mainConfig->OpenURL->rfr_id | ||
: ''; | ||
if ($dates = $this->getPublicationDates()) { | ||
$params['rft.date'] = implode('', $this->getPublicationDates()); | ||
} | ||
if (!isset($params['rft.title'])) { | ||
$params['rft.title'] = $this->getTitle(); | ||
} | ||
|
||
return false; | ||
return $params; | ||
} | ||
|
||
/** | ||
|
Oops, something went wrong.