diff --git a/module/VuFind/src/VuFind/RecordTab/HoldingsWorldCat.php b/module/VuFind/src/VuFind/RecordTab/HoldingsWorldCat.php index 144aaf96b7ab1d80796f99237e43c6e7b78c0a3d..2b91d0ee049d633015302a24e7b8e83944e7f1f7 100644 --- a/module/VuFind/src/VuFind/RecordTab/HoldingsWorldCat.php +++ b/module/VuFind/src/VuFind/RecordTab/HoldingsWorldCat.php @@ -67,14 +67,38 @@ class HoldingsWorldCat extends AbstractBase } /** - * Get holdings information from WorldCat. + * Get holdings information from WorldCat (false if none available). * - * @param string $id Record ID + * @return \SimpleXMLElement|bool + */ + public function getHoldings() + { + $id = $this->getOCLCNum(); + return empty($id) ? false : $this->wc->getHoldings($id); + } + + /** + * Is this tab active? + * + * @return bool + */ + public function isActive() + { + $id = $this->getOCLCNum(); + return !empty($id); + } + + /** + * Get the OCLC number from the active record driver. * - * @return \SimpleXMLElement + * @return string */ - public function getHoldings($id) + protected function getOCLCNum() { - return $this->wc->getHoldings($id); + static $id = false; // cache value in static variable + if (!$id) { + $id = $this->getRecordDriver()->tryMethod('getCleanOCLCNum'); + } + return $id; } } \ No newline at end of file diff --git a/themes/blueprint/templates/RecordTab/holdingsworldcat.phtml b/themes/blueprint/templates/RecordTab/holdingsworldcat.phtml index 2f4c12ca45d13844e282e86aa285e6cc5499812b..8148ca6d4cc364f638e60273721c9755374a63a5 100644 --- a/themes/blueprint/templates/RecordTab/holdingsworldcat.phtml +++ b/themes/blueprint/templates/RecordTab/holdingsworldcat.phtml @@ -1,4 +1,4 @@ -<? $holdings = $this->tab->getHoldings($this->driver->getUniqueId()); if ($holdings && count($holdings) > 0): ?> +<? $holdings = $this->tab->getHoldings(); 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/bootstrap/templates/RecordTab/holdingsworldcat.phtml b/themes/bootstrap/templates/RecordTab/holdingsworldcat.phtml index 6f1e69c64d53167e1965d4794ffbc08dafd58032..57c0267ecdd6307f26865dec6a0ec4e42dc0b5a0 100644 --- a/themes/bootstrap/templates/RecordTab/holdingsworldcat.phtml +++ b/themes/bootstrap/templates/RecordTab/holdingsworldcat.phtml @@ -1,4 +1,4 @@ -<? $holdings = $this->tab->getHoldings($this->driver->getUniqueId()); if ($holdings && count($holdings) > 0): ?> +<? $holdings = $this->tab->getHoldings(); if ($holdings && count($holdings) > 0): ?> <h3><?=$this->transEsc('Holdings at Other Libraries')?></h3> <table class="table table-striped"> <? foreach ($holdings as $holding): ?> diff --git a/themes/bootstrap3/templates/RecordTab/holdingsworldcat.phtml b/themes/bootstrap3/templates/RecordTab/holdingsworldcat.phtml index 6f1e69c64d53167e1965d4794ffbc08dafd58032..57c0267ecdd6307f26865dec6a0ec4e42dc0b5a0 100644 --- a/themes/bootstrap3/templates/RecordTab/holdingsworldcat.phtml +++ b/themes/bootstrap3/templates/RecordTab/holdingsworldcat.phtml @@ -1,4 +1,4 @@ -<? $holdings = $this->tab->getHoldings($this->driver->getUniqueId()); if ($holdings && count($holdings) > 0): ?> +<? $holdings = $this->tab->getHoldings(); if ($holdings && count($holdings) > 0): ?> <h3><?=$this->transEsc('Holdings at Other Libraries')?></h3> <table class="table table-striped"> <? foreach ($holdings as $holding): ?> diff --git a/themes/jquerymobile/templates/RecordTab/holdingsworldcat.phtml b/themes/jquerymobile/templates/RecordTab/holdingsworldcat.phtml index 2f4c12ca45d13844e282e86aa285e6cc5499812b..8148ca6d4cc364f638e60273721c9755374a63a5 100644 --- a/themes/jquerymobile/templates/RecordTab/holdingsworldcat.phtml +++ b/themes/jquerymobile/templates/RecordTab/holdingsworldcat.phtml @@ -1,4 +1,4 @@ -<? $holdings = $this->tab->getHoldings($this->driver->getUniqueId()); if ($holdings && count($holdings) > 0): ?> +<? $holdings = $this->tab->getHoldings(); 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): ?>