diff --git a/module/fid/config/module.config.php b/module/fid/config/module.config.php index b0c4ca6c08dfeb0af9eced2f2812738bf8e9c854..77b6b0c368be6037f68d6265dde8c9d80300d0ce 100644 --- a/module/fid/config/module.config.php +++ b/module/fid/config/module.config.php @@ -135,6 +135,11 @@ return [ Fid::class => FidFactory::class, ], ], + 'recordtab' => [ + 'invokables' => [ + 'worldcat' => 'fid\RecordTab\Worldcat', + ], + ], 'resolver_driver' => [ 'factories' => [ Ezb::class => diff --git a/module/fid/src/RecordTab/Worldcat.php b/module/fid/src/RecordTab/Worldcat.php new file mode 100644 index 0000000000000000000000000000000000000000..bae617db2831f563e04a5ca98ef1d0f4d495f0d1 --- /dev/null +++ b/module/fid/src/RecordTab/Worldcat.php @@ -0,0 +1,84 @@ +<?php +/** + * Staff view tab for AI records + * + * PHP version 5 + * + * Copyright (C) Villanova University 2010. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * @category VuFind + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @author André Lahmann <lahmann@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development:plugins:record_tabs Wiki + */ +namespace fid\RecordTab; + +/** + * Staff view tab for AI records + * + * @category VuFind + * @package RecordTabs + * @author Demian Katz <demian.katz@villanova.edu> + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development:plugins:record_tabs Wiki + */ +class Worldcat extends \VuFind\RecordTab\AbstractBase +{ + /** + * Constructor + */ + public function __construct() + { + $this->accessPermission = 'WorldcatTab'; + } + + /** + * Get the on-screen description for this tab. + * + * @return string + */ + public function getDescription() + { + return 'view_worldcat'; + } + + /** + * Is this tab active? + * + * @return bool + */ + public function isActive() + { + $isbns = $this->getRecordDriver()->tryMethod('getISBNs'); + $oclc = $this->getRecordDriver()->tryMethod('getOCLC'); + $permission = $this->getRecordDriver()->tryMethod('getRecordPermission'); + $isFilled = false; + + if (!empty($oclc)) { + $isFilled = true; + } elseif (!empty($isbns)) { + $isFilled = true; + } + + if (isset($permission)) { + return $permission != null && $isFilled ? true : false; + } + return $isFilled; + } +} diff --git a/themes/fid/templates/RecordTab/worldcat.phtml b/themes/fid/templates/RecordTab/worldcat.phtml new file mode 100644 index 0000000000000000000000000000000000000000..ed69a7a8e714d7897754e8c850b6bc10892643a4 --- /dev/null +++ b/themes/fid/templates/RecordTab/worldcat.phtml @@ -0,0 +1,20 @@ +<!-- fid: recordtab - worldcat --> +<? $script = <<<JS + $(document).ready(function() { + var recordId = $('.hiddenId').val(); + var recordSource = $('.hiddenSource').val(); + // console.log({id: recordId, source: recordSource}); + $.ajax({ + dataType: 'json', + url: VuFind.path + '/AJAX/JSON?method=getWorldCat', + method: 'GET', + data: {id: recordId, source: recordSource} + }).done(function(response) { + $('.worldcat').html(response.data.html); + }); + }); +JS; +?> +<?=$this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET');?> +<div class="worldcat"></div> +<!-- fid: recordtab - worldcat - END -->