From 7defaa3b1dd35de48683a224858c1ede5c88ebeb Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Sun, 8 Aug 2010 16:27:03 -0400 Subject: [PATCH] Small code cleanups while changing another issue --- ansel/lib/Gallery.php | 15 +++++---------- ansel/lib/Storage.php | 1 + ansel/lib/View/GalleryRenderer/Base.php | 3 ++- ansel/lib/Widget/OtherGalleries.php | 24 ++++++++++++------------ 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/ansel/lib/Gallery.php b/ansel/lib/Gallery.php index 9c2b9c812..dda5f0d74 100644 --- a/ansel/lib/Gallery.php +++ b/ansel/lib/Gallery.php @@ -573,7 +573,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical /* Get the available styles */ $styles = $GLOBALS['injector']->getInstance('Ansel_Styles'); - /* Check for explicitly requested style */ + /* Check for explicitly requested style */ if (!is_null($style)) { $gal_style = Ansel::getStyleDefinition($style); } else { @@ -618,7 +618,6 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical $this->set('default_prettythumb', $prettyData, true); return $newImg->id; - } catch (Horde_Exception $e) { // Might not support the requested style...try ansel_default // but protect against infinite recursion. @@ -627,13 +626,10 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical return $this->getKeyImage('ansel_default'); } } - } else { /* We are just using an image thumbnail. */ if ($this->countImages()) { - if (!empty($this->data['attribute_default']) && - $this->data['attribute_default'] > 0) { - + if (!empty($this->data['attribute_default'])) { return $this->data['attribute_default']; } $keys = $this->listImages(); @@ -650,15 +646,14 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical ->getInstance('Ansel_Storage') ->getScope() ->listGalleries(array('parent' => $this, 'allLevels' => false)); - } catch (Horde_Exception $e) { - return false; - } - if ($galleries) { + foreach ($galleries as $galleryId => $gallery) { if ($default_img = $gallery->getKeyImage($style)) { return $default_img; } } + } catch (Horde_Exception $e) { + return false; } } } diff --git a/ansel/lib/Storage.php b/ansel/lib/Storage.php index 7a7e92d1a..123ed4ee1 100644 --- a/ansel/lib/Storage.php +++ b/ansel/lib/Storage.php @@ -837,6 +837,7 @@ class Ansel_Storage public function listGalleries($params = array()) { $params = new Horde_Support_Array($params); + try { $shares = $this->_shares->listShares( $GLOBALS['registry']->getAuth(), diff --git a/ansel/lib/View/GalleryRenderer/Base.php b/ansel/lib/View/GalleryRenderer/Base.php index 386fc333d..77e248b0d 100644 --- a/ansel/lib/View/GalleryRenderer/Base.php +++ b/ansel/lib/View/GalleryRenderer/Base.php @@ -22,10 +22,11 @@ abstract class Ansel_View_GalleryRenderer_Base /** * The gallery id for this view's gallery * (Convienience instead of $this->view->gallery->id) - * + * * @var integer */ public $galleryId; + /** * Gallery slug for current gallery. * diff --git a/ansel/lib/Widget/OtherGalleries.php b/ansel/lib/Widget/OtherGalleries.php index 2b84514fc..0c924d80f 100644 --- a/ansel/lib/Widget/OtherGalleries.php +++ b/ansel/lib/Widget/OtherGalleries.php @@ -37,12 +37,11 @@ class Ansel_Widget_OtherGalleries extends Ansel_Widget_Base */ public function html() { - // The cache breaks this block for some reason, disable until figured - // out. + // The cache breaks this block for some reason, disable until figured + // out. // if ($GLOBALS['conf']['ansel_cache']['usecache']) { // $widget = $GLOBALS['injector']->getInstance('Horde_Cache')->get('Ansel_OtherGalleries' . $this->_view->gallery->get('owner')); // if ($widget !== false) { -// //var_dump($widget); // return $widget; // } // } @@ -68,7 +67,7 @@ class Ansel_Widget_OtherGalleries extends Ansel_Widget_Base $tree = $GLOBALS['injector']->getInstance('Horde_Tree')->getTree('otherAnselGalleries_' . md5($owner), 'Javascript', array('class' => 'anselWidgets')); try { - $gals = $GLOBALS['injector']->getInstance('Ansel_Storage') + $galleries = $GLOBALS['injector']->getInstance('Ansel_Storage') ->getScope() ->listGalleries(array('filter' => $owner)); } catch (Ansel_Exception $e) { @@ -81,8 +80,8 @@ class Ansel_Widget_OtherGalleries extends Ansel_Widget_Base . ';background:' . $this->_style['background'] . ';width:100%;max-height:300px;overflow:auto;" id="othergalleries" >'; - foreach($gals as $gal) { - $parents = $gal->get('parents'); + foreach ($galleries as $gallery) { + $parents = $gallery->get('parents'); if (empty($parents)) { $parent = null; } else { @@ -90,16 +89,17 @@ class Ansel_Widget_OtherGalleries extends Ansel_Widget_Base $parent = array_pop($parents); } - $img = (string)Ansel::getImageUrl($gal->getKeyImage('ansel_default'), 'mini', true); - $link = Ansel::getUrlFor('view', array('gallery' => $gal->id, - 'slug' => $gal->get('slug'), + $img = (string)Ansel::getImageUrl($gallery->getKeyImage('ansel_default'), 'mini', true); + $link = Ansel::getUrlFor('view', array('gallery' => $gallery->id, + 'slug' => $gallery->get('slug'), 'view' => 'Gallery'), true); - $tree->addNode($gal->id, $parent, $gal->get('name'), null, - ($gal->id == $this->_view->gallery->id), + $tree->addNode($gallery->id, $parent, $gallery->get('name'), null, + ($gallery->id == $this->_view->gallery->id), array('icon' => $img, 'icondir' => '', 'url' => $link)); } + Horde::startBuffer(); $GLOBALS['injector']->getInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'ToggleOtherGalleries'), array( 'bindTo' => 'othergalleries' @@ -110,7 +110,7 @@ class Ansel_Widget_OtherGalleries extends Ansel_Widget_Base $html .= Horde::endBuffer(); $html .= ''; $selfurl = Horde::selfUrl(true, true); - $html .= '
' + $html .= '
' . $selfurl->add('actionID', 'show_actions')->link( array('id' => 'othergalleries-toggle', 'class' => ($GLOBALS['prefs']->getValue('show_othergalleries') ? 'hide' : 'show'))) -- 2.11.0