diff --git a/module/VuFind/src/VuFind/View/Helper/Root/AbstractSyndetics.php b/module/VuFind/src/VuFind/View/Helper/Root/AbstractSyndetics.php index 093ef97468edcbfd67b40fcde35642b7384001f0..47cdff5caac5fa9ca039380df0e4d5702e9ebcd7 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/AbstractSyndetics.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/AbstractSyndetics.php @@ -87,6 +87,23 @@ abstract class AbstractSyndetics extends AbstractHelper return true; } + /** + * Get the Syndetics URL for making a request. + * + * @param string $id Client ID + * @param string $file File to request + * @param string $type Type parameter + * + * @return string + */ + protected function getSyndeticsUrl($id, $file = 'index.xml', $type = 'rw12,h7') + { + $baseUrl = isset($this->config->Syndetics->url) + ? $this->config->Syndetics->url : 'http://syndetics.com'; + return $baseUrl . '/index.aspx?isbn=' . $this->getIsbn10() + . '/' . $file . '&client=' . $id . '&type=' . $type; + } + /** * Attempt to get an ISBN-10; revert to ISBN-13 only when ISBN-10 representation * is impossible. @@ -96,10 +113,7 @@ abstract class AbstractSyndetics extends AbstractHelper protected function getIsbn10() { $isbn = is_object($this->isbn) ? $this->isbn->get10() : false; - if (!$isbn) { - $isbn = $this->isbn->get13(); - } - return $isbn; + return (!$isbn && is_object($this->isbn)) ? $this->isbn->get13() : $isbn; } /** diff --git a/module/VuFind/src/VuFind/View/Helper/Root/AuthorNotes.php b/module/VuFind/src/VuFind/View/Helper/Root/AuthorNotes.php index 3d35e0bca47372f7b8f97aa8b0bb8ec7582d6087..83d43f20ef072d5bec9cdb4093ee3a01b4962928 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/AuthorNotes.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/AuthorNotes.php @@ -82,15 +82,11 @@ class AuthorNotes extends AbstractSyndetics ) ); - //first request url - $baseUrl = isset($this->config->Syndetics->url) ? - $this->config->Syndetics->url : 'http://syndetics.com'; - $url = $baseUrl . '/index.aspx?isbn=' . $this->getIsbn10() . - '/index.xml&client=' . $id . '&type=rw12,hw7'; - + // Initialize return value $anotes = array(); - //find out if there are any notes + // Find out if there are any notes + $url = $this->getSyndeticsUrl($id); $result = $this->getHttpClient($url)->send(); if (!$result->isSuccess()) { return $anotes; @@ -106,9 +102,7 @@ class AuthorNotes extends AbstractSyndetics $nodes = $xmldoc->getElementsByTagName($source); if ($nodes->length) { // Load notes - $url = $baseUrl . '/index.aspx?isbn=' . $this->getIsbn10() . '/' . - $sourceInfo['file'] . '&client=' . $id . '&type=rw12,hw7'; - + $url = $this->getSyndeticsUrl($id, $sourceInfo['file']); $result2 = $this->getHttpClient($url)->send(); if (!$result2->isSuccess()) { continue; diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Excerpt.php b/module/VuFind/src/VuFind/View/Helper/Root/Excerpt.php index 412e4bfe6eae90b7bf709af96d6a56da966fbc6c..b9665ebe10bfa3bd07cafc5c1f365e4cd481e8e3 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Excerpt.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Excerpt.php @@ -74,7 +74,7 @@ class Excerpt extends AbstractSyndetics */ protected function loadSyndetics($id, $s_plus=false) { - //list of syndetic excerpts + // List of syndetic excerpts $sourceList = array( 'DBCHAPTER' => array( 'title' => 'First Chapter or Excerpt', @@ -83,15 +83,11 @@ class Excerpt extends AbstractSyndetics ) ); - //first request url - $baseUrl = isset($this->config->Syndetics->url) ? - $this->config->Syndetics->url : 'http://syndetics.com'; - $url = $baseUrl . '/index.aspx?isbn=' . $this->getIsbn10() . - '/index.xml&client=' . $id . '&type=rw12,hw7'; - + // Initialize return value: $review = array(); - //find out if there are any excerpts + // Find out if there are any excerpts + $url = $this->getSyndeticsUrl($id); $result = $this->getHttpClient($url)->send(); if (!$result->isSuccess()) { return $review; @@ -107,9 +103,7 @@ class Excerpt extends AbstractSyndetics $nodes = $xmldoc->getElementsByTagName($source); if ($nodes->length) { // Load excerpts - $url = $baseUrl . '/index.aspx?isbn=' . $this->getIsbn10() . '/' . - $sourceInfo['file'] . '&client=' . $id . '&type=rw12,hw7'; - + $url = $this->getSyndeticsUrl($id, $sourceInfo['file']); $result2 = $this->getHttpClient($url)->send(); if (!$result2->isSuccess()) { continue; diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Reviews.php b/module/VuFind/src/VuFind/View/Helper/Root/Reviews.php index 5d36d67217bdeef977235eda3131595ba34a6349..cb0aa37452a0ba36741b283b93dd3fd18a5d1faf 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Reviews.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Reviews.php @@ -218,7 +218,7 @@ class Reviews extends AbstractSyndetics */ protected function loadSyndetics($id, $s_plus=false) { - //list of syndetic reviews + // List of syndetic reviews $sourceList = array( 'CHREVIEW' => array('title' => 'Choice Review', 'file' => 'CHREVIEW.XML', @@ -255,15 +255,11 @@ class Reviews extends AbstractSyndetics 'file' => 'CRITICASEREVIEW.XML') ); - //first request url - $baseUrl = isset($this->config->Syndetics->url) ? - $this->config->Syndetics->url : 'http://syndetics.com'; - $url = $baseUrl . '/index.aspx?isbn=' . $this->getIsbn10() . '/' . - 'index.xml&client=' . $id . '&type=rw12,hw7'; - + // Initialize return value $review = array(); - //find out if there are any reviews + // Find out if there are any reviews + $url = $this->getSyndeticsUrl($id); $result = $this->getHttpClient($url)->send(); if (!$result->isSuccess()) { return $review; @@ -279,8 +275,7 @@ class Reviews extends AbstractSyndetics $nodes = $xmldoc->getElementsByTagName($source); if ($nodes->length) { // Load reviews - $url = $baseUrl . '/index.aspx?isbn=' . $this->getIsbn10() . '/' . - $sourceInfo['file'] . '&client=' . $id . '&type=rw12,hw7'; + $url = $this->getSyndeticsUrl($id, $sourceInfo['file']); $result2 = $this->getHttpClient($url)->send(); if (!$result2->isSuccess()) { continue; diff --git a/module/VuFind/src/VuFind/View/Helper/Root/VideoClips.php b/module/VuFind/src/VuFind/View/Helper/Root/VideoClips.php index 2ab67a091a31262b6a76e2ee0afa740478c7b09a..884a70709c6fea515a798cdf2550249fe4dc0a79 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/VideoClips.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/VideoClips.php @@ -82,15 +82,11 @@ class VideoClips extends AbstractSyndetics ) ); - //first request url - $baseUrl = isset($this->config->Syndetics->url) ? - $this->config->Syndetics->url : 'http://syndetics.com'; - $url = $baseUrl . '/index.aspx?isbn=' . $this->getIsbn10() . - '/index.xml&client=' . $id . '&type=rw12,hw7'; - + // Initialize return value: $vclips = array(); - //find out if there are any clips + // Find out if there are any clips + $url = $this->getSyndeticsUrl($id); $result = $this->getHttpClient($url)->send(); if (!$result->isSuccess()) { return $vclips; @@ -106,9 +102,7 @@ class VideoClips extends AbstractSyndetics $nodes = $xmldoc->getElementsByTagName($source); if ($nodes->length) { // Load clips - $url = $baseUrl . '/index.aspx?isbn=' . $this->getIsbn10() . '/' . - $sourceInfo['file'] . '&client=' . $id . '&type=rw12,hw7'; - + $url = $this->getSyndeticsUrl($id, $sourceInfo['file']); $result2 = $this->getHttpClient($url)->send(); if (!$result2->isSuccess()) { continue;