Small code cleanups while changing another issue
authorChuck Hagenbuch <chuck@horde.org>
Sun, 8 Aug 2010 20:27:03 +0000 (16:27 -0400)
committerChuck Hagenbuch <chuck@horde.org>
Sun, 8 Aug 2010 20:27:03 +0000 (16:27 -0400)
ansel/lib/Gallery.php
ansel/lib/Storage.php
ansel/lib/View/GalleryRenderer/Base.php
ansel/lib/Widget/OtherGalleries.php

index 9c2b9c8..dda5f0d 100644 (file)
@@ -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;
                 }
             }
         }
index 7a7e92d..123ed4e 100644 (file)
@@ -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(),
index 386fc33..77e248b 100644 (file)
@@ -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.
      *
index 2b84514..0c924d8 100644 (file)
@@ -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 .= '</div>';
         $selfurl = Horde::selfUrl(true, true);
-        $html .=  '<div class="control">'
+        $html .= '<div class="control">'
               . $selfurl->add('actionID', 'show_actions')->link(
                         array('id' => 'othergalleries-toggle',
                               'class' => ($GLOBALS['prefs']->getValue('show_othergalleries') ? 'hide' : 'show')))