Fixes issue in Bug: 8623 as well.
// or if we were asked to explicitly try again.
if (($reload || empty($result))) {
$image = &$ansel_storage->getImage($image_id);
- $image->createView('screen');
- $result = $faces->getFromPicture($image_id, $autocreate);
+ try {
+ $image->createView('screen');
+ $result = $faces->getFromPicture($image_id, $autocreate);
+ } catch (Horde_Exception $e) {
+ Horde::logMessage($e->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
+ $result = null;
+ }
}
if (!empty($result)) {
/* Sendfile support. Lighttpd < 1.5 only understands the X-LIGHTTPD-send-file header */
if ($conf['vfs']['src'] == 'sendfile') {
/* Need to ensure the file exists */
- $result = $image->createView('mini', 'ansel_default');
- if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
+ try {
+ $image->createView('mini', 'ansel_default');
+ } catch (Horde_Exception $e) {
+ Horde::logMessage($e->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
exit;
}
$filename = $ansel_vfs->readFile($image->getVFSPath('mini'), $image->getVFSName('mini'));
/* Sendfile support. Lighttpd < 1.5 only understands the X-LIGHTTPD-send-file header */
if ($conf['vfs']['src'] == 'sendfile') {
/* Need to ensure the file exists */
- $result = $image->createView('prettythumb', $style);
- if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
+ try {
+ $image->createView('prettythumb', $style);
+ } catch (Horde_Exception $e) {
+ Horde::logMessage($e->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
exit;
}
$filename = $ansel_vfs->readFile($image->getVFSPath('prettythumb', $style), $image->getVFSName('prettythumb'));
/* Sendfile support. Lighttpd < 1.5 only understands the X-LIGHTTPD-send-file header */
if ($conf['vfs']['src'] == 'sendfile') {
/* Need to ensure the file exists */
- $result = $image->createView('screen', 'ansel_default');
- if (is_a($result, 'PEAR_Error')) {
+ try {
+ $image->createView('screen', 'ansel_default');
+ } catch (Horde_Exception $e) {
Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
exit;
}
/* Sendfile support. Lighttpd < 1.5 only understands the X-LIGHTTPD-send-file header */
if ($conf['vfs']['src'] == 'sendfile') {
/* Need to ensure the file exists */
- $result = $image->createView('thumb', 'ansel_default');
- if (is_a($result, 'PEAR_Error')) {
+ try {
+ $image->createView('thumb', 'ansel_default');
+ } catch (Horde_Exception $e) {
Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
exit;
}
($viewHash = Ansel_Image::viewExists($imageId, $view, $style)) === false) {
// We have to make sure the image exists first, since we won't
// be going through img/*.php to auto-create it.
- if (is_a($image = $ansel_storage->getImage($imageId), 'PEAR_Error')) {
+ try {
+ $image = $ansel_storage->getImage($imageId);
+ } catch (Horde_Exception $e) {
+ Horde::logMessage($e->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
return Ansel::getErrorImage($view);
}
- if (is_a($result = $image->createView($view, $style, false), 'PEAR_Error')) {
+ try {
+ $image->createView($view, $style, false);
+ } catch (Horde_Exception $e) {
return Ansel::getErrorImage($view);
}
$viewHash = $image->getViewHash($view, $style) . '/'
} else {
// Load View
$result = $image->load($view, $style);
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
// Return image content
$data = $image->_image->raw();
$image = &$GLOBALS['ansel_storage']->getImage($image_id);
// Actually create the image.
- $result = $this->createView(
+ $this->createView(
$face_id,
$image,
$data['face_x1'],
$image->load('screen');
// Process the image
- $result = $this->createView($face_id,
+ $this->createView($face_id,
$image,
$x1,
$y1,
* @param string $view Which view to load.
* @param string $style The named gallery style.
*
- * @return mixed True || PEAR_Error
+ * @return boolean
+ * @throws Horde_Exception
*/
function load($view = 'full', $style = null)
{
if (!empty($this->_loaded[$viewHash])) {
return true;
}
-
- $result = $this->createView($view, $style);
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
+ $this->createView($view, $style);
/* If createView() had to resize the full image, we've already
* loaded the data, so return now. */
/* Get the VFS info. */
$vfspath = $this->getVFSPath($view, $style);
- if (is_a($vfspath, 'PEAR_Error')) {
- return $vfspath;
- }
/* Read in the requested view. */
$data = $GLOBALS['ansel_vfs']->read($vfspath, $this->getVFSName($view));
if (is_a($data, 'PEAR_Error')) {
Horde::logMessage($date, __FILE__, __LINE__, PEAR_LOG_ERR);
- return $data;
+ throw new Horde_Exception($data->getMessage());
}
$this->_data[$viewHash] = $data;
*
* @param string $view Which view to create.
* @param string $style A named gallery style
+ *
+ * @return boolean
+ * @throws Horde_Exception
*/
function createView($view, $style = null)
{
$this->getVFSName('full'));
if (is_a($data, 'PEAR_Error')) {
Horde::logMessage($data, __FILE__, __LINE__, PEAR_LOG_ERR);
- return $data;
+ throw new Horde_Exception($data->getMessage());
}
$this->_image->loadString($this->getVFSPath('full') . '/' . $this->id, $data);
$styleDef = Ansel::getStyleDefinition($style);
$view = $this->getViewHash($view, $style);
- $this->_data[$view] = $this->_image->raw();
+ try {
+ $this->_data[$view] = $this->_image->raw();
+ } catch (Horde_Image_Exception $e) {
+ throw new Horde_Exception($e);
+ }
$this->_image->loadString($vfspath . '/' . $this->id,
$this->_data[$view]);
$this->_loaded[$view] = true;
echo $data;
return;
}
-
- if (is_a($result = $this->load($view, $style), 'PEAR_Error')) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- return $result;
+ try {
+ $this->load($view, $style);
+ $this->_image->display();
+ } catch (Horde_Exception $e) {
+ Horde::logMessage($e->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
}
-
- $this->_image->display();
}
/**
*/
function toFile($view = 'full')
{
- if (is_a(($result = $this->load($view)), 'PEAR_Error')) {
- return $result;
+ try {
+ $this->load($view);
+ return $this->_image->toFile($this->_dirty ? false : $this->_data[$view]);
+ } catch (Horde_Exception $e) {
+ Horde::logMessage($e->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
}
- return $this->_image->toFile($this->_dirty ? false : $this->_data[$view]);
}
/**
*/
function getDimensions($view = 'full')
{
- if (is_a(($result = $this->load($view)), 'PEAR_Error')) {
- return $result;
+ try {
+ $this->load($view);
+ return $this->_image->getDimensions();
+ } catch (Horde_Exception $e) {
+ Horde::logMessage($e->getMessage(), __FILE__, __LINE__);
}
- return $this->_image->getDimensions();
}
/**
$style = $this->_params['style'];
foreach ($images as $image) {
$result = $image->load('screen');
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
$imgobjs[] = $image->_image;
}
$images = $this->_getStackImages();
$style = $this->_params['style'];
foreach ($images as $image) {
- $result = $image->load('screen');
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
+ $image->load('screen');
$imgobjs[] = $image->_image;
}
$style = $this->_params['style'];
foreach ($images as $image) {
$result = $image->load('screen');
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
$imgobjs[] = $image->_image;
}