From eb9895ffb9b0e03c09f2b4defe7fd5d18da724d3 Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Sat, 21 Aug 2010 23:24:26 -0400 Subject: [PATCH] Don't add javascript until we need it. Don't offer gallery filters since getRecentImagesGeodata() isn't written to support them. --- ansel/lib/Block/recently_added_geodata.php | 106 ++++------------------------- 1 file changed, 13 insertions(+), 93 deletions(-) diff --git a/ansel/lib/Block/recently_added_geodata.php b/ansel/lib/Block/recently_added_geodata.php index 66d33ff61..171a33a40 100644 --- a/ansel/lib/Block/recently_added_geodata.php +++ b/ansel/lib/Block/recently_added_geodata.php @@ -1,6 +1,6 @@ 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") . ''; - } - - // 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 . ''); + 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 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; - } - } -- 2.11.0