diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php b/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php index e1567dffd60c90295dd9d1f28f03e4442cb7da6a..328afd9496adb7fd14b7d5986876fa51f7a01bc6 100644 --- a/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php +++ b/module/VuFind/src/VuFind/RecordDriver/SolrDefault.php @@ -959,24 +959,21 @@ class SolrDefault extends AbstractBase } /** - * Return a URL to a thumbnail preview of the record, if available; false - * otherwise. + * Returns one of three things: a full URL to a thumbnail preview of the record + * if an image is available in an external system; an array of parameters to + * send to VuFind's internal cover generator if no fixed URL exists; or false + * if no thumbnail can be generated. * - * @param array $size Size of thumbnail (small, medium or large -- small is + * @param string $size Size of thumbnail (small, medium or large -- small is * default). * - * @return string|bool + * @return string|array|bool */ public function getThumbnail($size = 'small') { - /* TODO if ($isbn = $this->getCleanISBN()) { - $frontController = Zend_Controller_Front::getInstance(); - return $frontController->getBaseUrl() . '/Cover/Show?isn=' . - urlencode($isbn) . '&size=' . urlencode($size); + return array('isn' => $isbn, 'size' => $size); } - */ - return false; } diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrVudl.php b/module/VuFind/src/VuFind/RecordDriver/SolrVudl.php index 572f0c3809212479ea62bc93a5be452330414f96..8c67016c549bd8bae0599353b4c5b5bbb81cd54f 100644 --- a/module/VuFind/src/VuFind/RecordDriver/SolrVudl.php +++ b/module/VuFind/src/VuFind/RecordDriver/SolrVudl.php @@ -55,13 +55,15 @@ class SolrVudl extends SolrDefault } /** - * Return a URL to a thumbnail preview of the record, if available; false - * otherwise. + * Returns one of three things: a full URL to a thumbnail preview of the record + * if an image is available in an external system; an array of parameters to + * send to VuFind's internal cover generator if no fixed URL exists; or false + * if no thumbnail can be generated. * - * @param array $size Size of thumbnail (small, medium or large -- small is + * @param string $size Size of thumbnail (small, medium or large -- small is * default). * - * @return string|bool + * @return string|array|bool */ public function getThumbnail($size = 'small') { diff --git a/module/VuFind/src/VuFind/RecordDriver/Summon.php b/module/VuFind/src/VuFind/RecordDriver/Summon.php index 563127ab3367bd199fe2eceaf5074c59ccdce76c..1117498ad8e66e4b9d73998ae429965138111fc5 100644 --- a/module/VuFind/src/VuFind/RecordDriver/Summon.php +++ b/module/VuFind/src/VuFind/RecordDriver/Summon.php @@ -406,32 +406,29 @@ class Summon extends SolrDefault } /** - * Return a URL to a thumbnail preview of the record, if available; false - * otherwise. + * Returns one of three things: a full URL to a thumbnail preview of the record + * if an image is available in an external system; an array of parameters to + * send to VuFind's internal cover generator if no fixed URL exists; or false + * if no thumbnail can be generated. * - * @param array $size Size of thumbnail (small, medium or large -- small is + * @param string $size Size of thumbnail (small, medium or large -- small is * default). * - * @return string|bool + * @return string|array|bool */ public function getThumbnail($size = 'small') { - /* TODO $formats = $this->getFormats(); if ($isbn = $this->getCleanISBN() || !empty($formats)) { - $frontController = Zend_Controller_Front::getInstance(); - $url = $frontController->getBaseUrl() . '/Cover/Show?'; - $params = array('size=' . urlencode($size)); + $params = array('size' => $size); if ($isbn) { - $params[] = 'isn=' . urlencode($isbn); + $params['isn'] = $isbn; } if (!empty($formats)) { - $params[] = 'contenttype=' . urlencode($formats[0]); + $params['contenttype'] = $formats[0]; } - return $url . implode('&', $params); + return $params; } - */ - return false; } diff --git a/module/VuFind/src/VuFind/Theme/Root/Helper/Record.php b/module/VuFind/src/VuFind/Theme/Root/Helper/Record.php index 662d593afb81456c086510f265eacb30ef980f1e..26a0f31daca0cb84f38578ac65370f83e17f3309 100644 --- a/module/VuFind/src/VuFind/Theme/Root/Helper/Record.php +++ b/module/VuFind/src/VuFind/Theme/Root/Helper/Record.php @@ -306,4 +306,32 @@ class Record extends AbstractHelper 'record/checkbox.phtml', $context ); } + + /** + * Generate a thumbnail URL (return false if unsupported). + * + * @param string $size Size of thumbnail (small, medium or large -- small is + * default). + * + * @return string|bool + */ + public function getThumbnail($size = 'small') + { + // Try to build thumbnail: + $thumb = $this->driver->tryMethod('getThumbnail', array($size)); + + // No thumbnail? Return false: + if (empty($thumb)) { + return false; + } + + // Array? It's parameters to send to the cover generator: + if (is_array($thumb)) { + $urlHelper = $this->getView()->plugin('url'); + return $urlHelper('cover-show') . '?' . http_build_query($thumb); + } + + // Default case -- return fixed string: + return $thumb; + } } \ No newline at end of file diff --git a/themes/blueprint/templates/RecordDriver/SolrDefault/core.phtml b/themes/blueprint/templates/RecordDriver/SolrDefault/core.phtml index 316cd456f1338cddfcb5d6c60844679052c6bea3..b5581e64dc40320d1828a209546e35ede81f67b8 100644 --- a/themes/blueprint/templates/RecordDriver/SolrDefault/core.phtml +++ b/themes/blueprint/templates/RecordDriver/SolrDefault/core.phtml @@ -209,7 +209,7 @@ <div class="span-4 last"> <? /* Display thumbnail if appropriate: */ ?> - <? $mediumThumb = $this->driver->getThumbnail('medium'); $largeThumb = $this->driver->getThumbnail('large'); ?> + <? $mediumThumb = $this->record($this->driver)->getThumbnail('medium'); $largeThumb = $this->record($this->driver)->getThumbnail('large'); ?> <? if ($mediumThumb): ?> <? if ($largeThumb): ?><a href="<?=$this->escapeHtml($largeThumb)?>"><? endif; ?> <img alt="<?=$this->transEsc('Cover Image')?>" class="recordcover" src="<?=$this->escapeHtml($mediumThumb);?>"/> diff --git a/themes/blueprint/templates/RecordDriver/SolrDefault/list-entry.phtml b/themes/blueprint/templates/RecordDriver/SolrDefault/list-entry.phtml index e140ef992279bef1ab9a42d4c582ddf07b5aa5ff..0cf68bcdcd68ad0bf94ad74b8307281e34584b7a 100644 --- a/themes/blueprint/templates/RecordDriver/SolrDefault/list-entry.phtml +++ b/themes/blueprint/templates/RecordDriver/SolrDefault/list-entry.phtml @@ -12,7 +12,7 @@ ?> <div class="listentry recordId source<?=$this->escapeHtml($source)?>" id="record<?=$this->escapeHtml($id)?>"> <div class="span-2"> - <? if ($listThumb = $this->driver->getThumbnail()): ?> + <? if ($listThumb = $this->record($this->driver)->getThumbnail()): ?> <img src="<?=$this->escapeHtml($listThumb)?>" class="summcover" alt="<?=$this->transEsc('Cover Image')?>"/> <? else: ?> <img src="<?=$this->url('cover-unavailable')?>" class="summcover" alt="<?=$this->transEsc('No Cover Image')?>"/> diff --git a/themes/blueprint/templates/RecordDriver/SolrDefault/result-grid.phtml b/themes/blueprint/templates/RecordDriver/SolrDefault/result-grid.phtml index 586884f6d90b54a25b620c0c2a873a152214e921..0570b2ead561159712f305b1eb019eeec5966983 100644 --- a/themes/blueprint/templates/RecordDriver/SolrDefault/result-grid.phtml +++ b/themes/blueprint/templates/RecordDriver/SolrDefault/result-grid.phtml @@ -2,9 +2,9 @@ <input type="hidden" value="<?=$this->escapeHtml($this->driver->getUniqueID())?>" class="hiddenId" /> <span class="gridImageBox"> <a href="<?=$this->recordLink()->getUrl($this->driver)?>"> - <? if ($summThumb = $this->driver->getThumbnail('large')): ?> + <? if ($summThumb = $this->record($this->driver)->getThumbnail('large')): ?> <img src="<?=$this->escapeHtml($summThumb)?>" class="gridImage" alt="<?=$this->transEsc('Cover Image')?>"/> - <? elseif ($summThumb = $this->driver->getThumbnail()): ?> + <? elseif ($summThumb = $this->record($this->driver)->getThumbnail()): ?> <img src="<?=$this->escapeHtml($summThumb)?>" class="gridImage" alt="<?=$this->transEsc('Cover Image')?>"/> <? else: ?> <img src="<?=$this->url('cover-unavailable')?>" class="gridImage" alt="<?=$this->transEsc('No Cover Image')?>"/> diff --git a/themes/blueprint/templates/RecordDriver/SolrDefault/result-list.phtml b/themes/blueprint/templates/RecordDriver/SolrDefault/result-list.phtml index 5f00940f1dd1882f1e8b4349023428638109c189..784c1a5bfd2ef531394d161e97064530f06c5558 100644 --- a/themes/blueprint/templates/RecordDriver/SolrDefault/result-list.phtml +++ b/themes/blueprint/templates/RecordDriver/SolrDefault/result-list.phtml @@ -1,7 +1,7 @@ <div class="result source<?=$this->escapeHtml($this->driver->getResourceSource())?> recordId<?=$this->driver->supportsAjaxStatus()?' ajaxItemId':''?>"> <input type="hidden" value="<?=$this->escapeHtml($this->driver->getUniqueID())?>" class="hiddenId" /> <div class="span-2"> - <? if ($summThumb = $this->driver->getThumbnail()): ?> + <? if ($summThumb = $this->record($this->driver)->getThumbnail()): ?> <img src="<?=$this->escapeHtml($summThumb)?>" class="summcover" alt="<?=$this->transEsc('Cover Image')?>"/> <? else: ?> <img src="<?=$this->url('cover-unavailable')?>" class="summcover" alt="<?=$this->transEsc('No Cover Image')?>"/> diff --git a/themes/blueprint/templates/ajax/result-google-map-info.phtml b/themes/blueprint/templates/ajax/result-google-map-info.phtml index 353c3a40785e2e22f7656b673db67f54647f4320..aee2f17152337cca4db243b7920018c39ef13503 100644 --- a/themes/blueprint/templates/ajax/result-google-map-info.phtml +++ b/themes/blueprint/templates/ajax/result-google-map-info.phtml @@ -6,7 +6,7 @@ <? $i++; ?> <div class="mapInfoResult <? if ($i % 2 == 0): ?>alt <? endif; ?>record<?=$i ?>"> <div class="mapInfoResultThumb"> - <? if ($record->getThumbnail()): ?><img class="mapInfoResultThumbImg" src="<?=$this->escapeHtml($record->getThumbnail()) ?>" style="display:block"/><? endif; ?> + <? if ($thumb = $this->record($record)->getThumbnail()): ?><img class="mapInfoResultThumbImg" src="<?=$this->escapeHtml($thumb) ?>" style="display:block"/><? endif; ?> </div> <div class="mapInfoResultText"> diff --git a/themes/blueprint/templates/myresearch/checkedout.phtml b/themes/blueprint/templates/myresearch/checkedout.phtml index 974ca392f2dbc38fbf5c7af79a37ebd5ba79c9bf..e4152da519047d470cbdef22b0c78941aa2acfc5 100644 --- a/themes/blueprint/templates/myresearch/checkedout.phtml +++ b/themes/blueprint/templates/myresearch/checkedout.phtml @@ -37,7 +37,7 @@ <? endif; ?> <div id="record<?=$this->escapeHtml($resource->getUniqueId())?>"> <div class="span-2"> - <? if ($summThumb = $resource->getThumbnail()): ?> + <? if ($summThumb = $this->record($resource)->getThumbnail()): ?> <img src="<?=$this->escapeHtml($summThumb)?>" class="summcover" alt="<?=$this->transEsc('Cover Image')?>"/> <? else: ?> <img src="<?=$this->url('cover-unavailable')?>" class="summcover" alt="<?=$this->transEsc('No Cover Image')?>"/> diff --git a/themes/blueprint/templates/myresearch/holds.phtml b/themes/blueprint/templates/myresearch/holds.phtml index 7b9c528da14c1ea133a7b2ae8e61a8e41e436653..549e939ac257a8f3f093c09288214c8f48c9317e 100644 --- a/themes/blueprint/templates/myresearch/holds.phtml +++ b/themes/blueprint/templates/myresearch/holds.phtml @@ -38,7 +38,7 @@ <? endif; ?> <div id="record<?=$this->escapeHtml($resource->getUniqueId()) ?>"> <div class="span-2"> - <? if ($summThumb = $resource->getThumbnail()): ?> + <? if ($summThumb = $this->record($resource)->getThumbnail()): ?> <img src="<?=$this->escapeHtml($summThumb)?>" class="summcover" alt="<?=$this->transEsc('Cover Image')?>"/> <? else: ?> <img src="<?=$this->url('cover-unavailable')?>" class="summcover" alt="<?=$this->transEsc('No Cover Image')?>"/> diff --git a/themes/jquerymobile/templates/RecordDriver/SolrDefault/core.phtml b/themes/jquerymobile/templates/RecordDriver/SolrDefault/core.phtml index 709e438fc318972f1c2dcaf90498c1c6661af7b3..203d5856fc7adcefc89e056593adc167f350b192 100644 --- a/themes/jquerymobile/templates/RecordDriver/SolrDefault/core.phtml +++ b/themes/jquerymobile/templates/RecordDriver/SolrDefault/core.phtml @@ -1,5 +1,5 @@ <? /* Display thumbnail if appropriate: */ ?> -<? $mediumThumb = $this->driver->getThumbnail('medium'); $largeThumb = $this->driver->getThumbnail('large'); ?> +<? $mediumThumb = $this->record($this->driver)->getThumbnail('medium'); $largeThumb = $this->record($this->driver)->getThumbnail('large'); ?> <? if ($mediumThumb): ?> <? if ($largeThumb): ?><a rel="external" href="<?=$this->escapeHtml($largeThumb)?>"><? endif; ?> <div class="recordcover">