Don't add javascript until we need it. Don't offer gallery filters since getRecentIma...
authorChuck Hagenbuch <chuck@horde.org>
Sun, 22 Aug 2010 03:24:26 +0000 (23:24 -0400)
committerChuck Hagenbuch <chuck@horde.org>
Sun, 22 Aug 2010 03:24:26 +0000 (23:24 -0400)
ansel/lib/Block/recently_added_geodata.php

index 66d33ff..171a33a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-$block_name = _("Recently Geotagged");
+$block_name = _("Recently Geotagged Photos");
 
 /**
  * Display most recently geotagged images.
@@ -19,12 +19,6 @@ class Horde_Block_ansel_recently_added_geodata extends Horde_Block
      * @var string
      */
     protected $_app = 'ansel';
-    
-    /**
-     *
-     * @var Ansel_Gallery
-     */
-    private $_gallery = null;
 
     /**
      *
@@ -32,30 +26,15 @@ class Horde_Block_ansel_recently_added_geodata extends Horde_Block
      */
     protected function _params()
     {
-        $params = array('gallery' => array(
-                            'name' => _("Gallery"),
-                            'type' => 'enum',
-                            'default' => '__random',
-                            'values' => array('all' => 'All')),
-                        'limit' => array(
-                             'name' => _("Maximum number of photos"),
-                             'type' => 'int',
-                             'default' => 10),
-                        'height' => array(
-                             'name' => _("Height of map (width automatically adjusts to block)"),
-                             'type' => 'int',
-                             'default' => 250),
+        return array('limit' => array(
+                         'name' => _("Maximum number of photos"),
+                         'type' => 'int',
+                         'default' => 10),
+                     'height' => array(
+                         'name' => _("Height of map (width automatically adjusts to block)"),
+                         'type' => 'int',
+                         'default' => 250),
         );
-
-        if ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->countGalleries($GLOBALS['registry']->getAuth(), Horde_Perms::READ) < $GLOBALS['conf']['gallery']['listlimit']) {
-            foreach ($GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->listGalleries(array('perm' => Horde_Perms::READ)) as $id => $gal) {
-                if (!$gal->hasPasswd() && $gal->isOldEnough()) {
-                    $params['gallery']['values'][$id] = $gal->get('name');
-                }
-            }
-        }
-
-        return $params;
     }
 
     /**
@@ -64,33 +43,7 @@ class Horde_Block_ansel_recently_added_geodata extends Horde_Block
      */
     protected function _title()
     {
-        Horde::addScriptFile('http://maps.google.com/maps?file=api&v=2&sensor=false&key=' . $GLOBALS['conf']['api']['googlemaps'], 'ansel', array('external' => true));
-        Horde::addScriptFile('http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/1.1/src/markermanager.js', 'ansel', array('external' => true));
-        Horde::addScriptFile('googlemap.js');
-        if ($this->_params['gallery'] != 'all') {
-            try {
-                $gallery = $this->_getGallery();
-            } catch (Exception $e) {
-                return Ansel::getUrlFor('view', array('view' => 'List'), true)->link() . _("Gallery") . '</a>';
-            }
-
-            // Build the gallery name.
-            if (isset($this->_params['gallery'])) {
-                $name = @htmlspecialchars($gallery->get('name'), ENT_COMPAT, $GLOBALS['registry']->getCharset());
-            }
-
-            $style = $gallery->getStyle();
-            $viewurl = Ansel::getUrlFor('view',
-                                        array('slug' => $gallery->get('slug'),
-                                              'gallery' => $gallery->id,
-                                              'view' => 'Gallery'),
-                                        true);
-        } else {
-            $viewurl = Ansel::getUrlFor('view', array('view' => 'List'), true);
-            $name = _("All Galleries");
-        }
-
-        return sprintf(_("Recently Geotagged Photos From %s"), $viewurl->link() . $name . '</a>');
+        return _("Recently Geotagged Photos");
     }
 
     /**
@@ -99,14 +52,6 @@ class Horde_Block_ansel_recently_added_geodata extends Horde_Block
      */
     protected function _content()
     {
-        if ($this->_params['gallery'] == 'all') {
-            $galleries = array();
-        } elseif (!is_array($this->_params['gallery'])) {
-            $galleries = array($this->_params['gallery']);
-        } else {
-            $galleries = $this->_params['gallery'];
-        }
-
         try {
             $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRecentImagesGeodata(null, 0, min($this->_params['limit'], 100));
         } catch (Ansel_Exception $e) {
@@ -156,34 +101,9 @@ class Horde_Block_ansel_recently_added_geodata extends Horde_Block
         </script>
 EOT;
 
+        Horde::addScriptFile('http://maps.google.com/maps?file=api&v=2&sensor=false&key=' . $GLOBALS['conf']['api']['googlemaps'], 'ansel', array('external' => true));
+        Horde::addScriptFile('http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/1.1/src/markermanager.js', 'ansel', array('external' => true));
+        Horde::addScriptFile('googlemap.js');
         return $html;
     }
-
-    /**
-     *
-     * @return Ansel_Gallery
-     */
-    protected function _getGallery()
-    {
-        if ($this->_gallery instanceof Ansel_Gallery) {
-            return $this->_gallery;
-        }
-
-        if (isset($this->_params['gallery']) &&
-            $this->_params['gallery'] != '__random') {
-            $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery(
-                $this->_params['gallery']);
-        } else {
-            $this->_gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getRandomGallery();
-        }
-
-        if (empty($this->_gallery)) {
-           throw new Horde_Exception_NotFound(_("Gallery not found."));
-        } elseif (!$this->_gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
-            throw new Horde_Exception_PermissionDenied(_("Access denied viewing this gallery."));
-        }
-
-        return $this->_gallery;
-    }
-
 }