/**
* Fetch the matching resources that should appear on the current page
*
- * @TODO: Implement an Interface that Ansel_Gallery and Ansel_Image should
- * implement that the client search code will use.
- *
* @return Array of Ansel_Images and Ansel_Galleries
*/
public function getSlice($page, $perpage)
$count = $perpage - count($galleries);
if ($count > 0) {
$iresults = array_slice($this->_results['images'], $istart, $count);
- $images = count($iresults) ? array_values($GLOBALS['injector']->getInstance('Ansel_Storage')->getImages(array('ids' => $iresults))) : array();
+ try {
+ $images = count($iresults) ? array_values($GLOBALS['injector']->getInstance('Ansel_Storage')->getImages(array('ids' => $iresults))) : array();
+ } catch (Horde_Exception_NotFound $e) {
+ throw new Ansel_Exception($e);
+ }
if (($conf['comments']['allow'] == 'all' || ($conf['comments']['allow'] == 'authenticated' && $GLOBALS['registry']->getAuth())) &&
$registry->hasMethod('forums/numMessagesBatch')) {
$ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage');
// Get the slice of galleries/images to view on this page.
- $results = $this->_search->getSlice($this->_page, $this->_perPage);
+ try {
+ $results = $this->_search->getSlice($this->_page, $this->_perPage);
+ } catch (Ansel_Exception $e) {
+ Horde::logMessage($e->getMessage(), 'ERR');
+ return _("An error has occured retrieving the image. Details have been logged.");
+ }
$total = $this->_search->count();
$total = $total['galleries'] + $total['images'];
$error = false;
}
} catch (Ansel_Exception $e) {
- $error = _("There was an error accessing the gallery");
+ $error = _("There was an error accessing the gallery.");
}
}
if (!$name || $error) {