diff --git a/module/VuFind/src/VuFind/RecordDriver/WorldCat.php b/module/VuFind/src/VuFind/RecordDriver/WorldCat.php index 0510ec6a2addd1a42441b558985e64632dcd4671..e59cf6227b2fbefe8d0766395a49ad8d9580667f 100644 --- a/module/VuFind/src/VuFind/RecordDriver/WorldCat.php +++ b/module/VuFind/src/VuFind/RecordDriver/WorldCat.php @@ -303,16 +303,4 @@ class WorldCat extends SolrMarc { return $this->getFieldArray('780', array('a', 's', 't')); } - - /** - * Get holdings information from WorldCat. - * - * @return SimpleXMLElement - */ - public function getWorldCatHoldings() - { - $wc = $this->getServiceLocator()->getServiceLocator() - ->get('VuFind\WorldCatConnection'); - return $wc->getHoldings($this->getUniqueId()); - } } diff --git a/module/VuFind/src/VuFind/View/Helper/Root/WorldCat.php b/module/VuFind/src/VuFind/View/Helper/Root/WorldCat.php new file mode 100644 index 0000000000000000000000000000000000000000..57e38e8c460c217851fb90667697fc037336bde0 --- /dev/null +++ b/module/VuFind/src/VuFind/View/Helper/Root/WorldCat.php @@ -0,0 +1,70 @@ +<?php +/** + * WorldCat view helper + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package View_Helpers + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/vufind2:developer_manual Wiki + */ +namespace VuFind\View\Helper\Root; +use Zend\View\Helper\AbstractHelper; + +/** + * WorldCat view helper + * + * @category VuFind2 + * @package View_Helpers + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/vufind2:developer_manual Wiki + */ +class WorldCat extends AbstractHelper +{ + /** + * WorldCat connection + * + * @var \VuFind\Connection\WorldCat + */ + protected $wc; + + /** + * Constructor + * + * @param \VuFind\Connection\WorldCat $wc WorldCat connection + */ + public function __construct(\VuFind\Connection\WorldCat $wc) + { + $this->wc = $wc; + } + + /** + * Get holdings information from WorldCat. + * + * @param string $id Record ID + * + * @return SimpleXMLElement + */ + public function getHoldings($id) + { + return $this->wc->getHoldings($id); + } +} \ No newline at end of file diff --git a/themes/blueprint/templates/RecordTab/holdingsworldcat.phtml b/themes/blueprint/templates/RecordTab/holdingsworldcat.phtml index 736a051ffc2c31b8c214dc63e100be6802d897df..f5afadfa6fa7474b7bd7f5a2da09326f968e44ee 100644 --- a/themes/blueprint/templates/RecordTab/holdingsworldcat.phtml +++ b/themes/blueprint/templates/RecordTab/holdingsworldcat.phtml @@ -1,4 +1,4 @@ -<? $holdings = $this->driver->getWorldCatHoldings(); if ($holdings && count($holdings) > 0): ?> +<? $holdings = $this->worldcat()->getHoldings($this->driver->getUniqueId()); if ($holdings && count($holdings) > 0): ?> <h3><?=$this->transEsc('Holdings at Other Libraries')?></h3> <table cellpadding="2" cellspacing="0" border="0" class="citation" width="100%"> <? foreach ($holdings as $holding): ?> diff --git a/themes/jquerymobile/templates/RecordTab/holdingsworldcat.phtml b/themes/jquerymobile/templates/RecordTab/holdingsworldcat.phtml index 736a051ffc2c31b8c214dc63e100be6802d897df..f5afadfa6fa7474b7bd7f5a2da09326f968e44ee 100644 --- a/themes/jquerymobile/templates/RecordTab/holdingsworldcat.phtml +++ b/themes/jquerymobile/templates/RecordTab/holdingsworldcat.phtml @@ -1,4 +1,4 @@ -<? $holdings = $this->driver->getWorldCatHoldings(); if ($holdings && count($holdings) > 0): ?> +<? $holdings = $this->worldcat()->getHoldings($this->driver->getUniqueId()); if ($holdings && count($holdings) > 0): ?> <h3><?=$this->transEsc('Holdings at Other Libraries')?></h3> <table cellpadding="2" cellspacing="0" border="0" class="citation" width="100%"> <? foreach ($holdings as $holding): ?> diff --git a/themes/root/theme.config.php b/themes/root/theme.config.php index 1d8307ece2c5b2ae850cb01a399eee5b16b25fa9..3193669a6c6c6ac2ebe357d6f7c56b9ef9ec4546 100644 --- a/themes/root/theme.config.php +++ b/themes/root/theme.config.php @@ -114,6 +114,11 @@ return array( $sm->getServiceLocator()->get('VuFind\Config')->get('config') ); }, + 'worldcat' => function ($sm) { + return new \VuFind\View\Helper\Root\WorldCat( + $sm->getServiceLocator()->get('VuFind\WorldCatConnection') + ); + } ), 'invokables' => array( 'addellipsis' => 'VuFind\View\Helper\Root\AddEllipsis',