Overview

Packages

  • Ansel
  • None

Classes

  • Ansel_Application
  • Ansel_Block_Cloud
  • Ansel_Block_Gallery
  • Ansel_Block_MyGalleries
  • Ansel_Block_RandomPhoto
  • Ansel_Block_RecentComments
  • Ansel_Block_RecentFaces
  • Ansel_Block_Recentlyadded
  • Ansel_Block_RecentlyAddedGeodata
  • Ansel_Config
  • Ansel_Form_Watermark
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Display most recently geotagged images.
  4:  *
  5:  * Copyright 2007-2012 Horde LLC (http://www.horde.org/)
  6:  *
  7:  * See the enclosed file COPYING for license information (GPL). If you
  8:  * did not receive this file, see http://www.horde.org/licenses/gpl.
  9:  *
 10:  * @author  Michael Rubinsky <mrubinsk@horde.org>
 11:  */
 12: class Ansel_Block_RecentlyAddedGeodata extends Horde_Core_Block
 13: {
 14:     /**
 15:      */
 16:     public function __construct($app, $params = array())
 17:     {
 18:         parent::__construct($app, $params);
 19: 
 20:         $this->_name = _("Recently Geotagged Photos");
 21:     }
 22: 
 23:     /**
 24:      */
 25:     protected function _params()
 26:     {
 27:         return array(
 28:             'limit' => array(
 29:                 'name' => _("Maximum number of photos"),
 30:                 'type' => 'int',
 31:                 'default' => 10
 32:             ),
 33:             'height' => array(
 34:                 'name' => _("Height of map (width automatically adjusts to block)"),
 35:                 'type' => 'int',
 36:                 'default' => 250
 37:             ),
 38:         );
 39:     }
 40: 
 41:     /**
 42:      */
 43:     protected function _content()
 44:     {
 45:         Ansel::initHordeMap();
 46:         Horde::addScriptFile('blocks/geotag.js');
 47:         try {
 48:             $images = $GLOBALS['injector']
 49:                 ->getInstance('Ansel_Storage')
 50:                 ->getRecentImagesGeodata(null, 0, min($this->_params['limit'], 100));
 51:         } catch (Ansel_Exception $e) {
 52:             return $e->getMessage();
 53:         }
 54:         $images = array_reverse($images);
 55:         foreach ($images as $key => $image) {
 56:             $id = $image['image_id'];
 57:             $gallery = $GLOBALS['injector']
 58:                 ->getInstance('Ansel_Storage')
 59:                 ->getGallery($image['gallery_id']);
 60: 
 61:             // Don't show locked galleries in the block.
 62:             if (!$gallery->isOldEnough() || $gallery->hasPasswd()) {
 63:                 continue;
 64:             }
 65:             $style = $gallery->getStyle();
 66: 
 67:             // Generate the image view url
 68:             $url = Ansel::getUrlFor(
 69:                 'view',
 70:                 array('view' => 'Image',
 71:                       'slug' => $gallery->get('slug'),
 72:                       'gallery' => $gallery->id,
 73:                       'image' => $id,
 74:                       'gallery_view' => $style->gallery_view), true);
 75:             $images[$key]['icon'] = (string)Ansel::getImageUrl($images[$key]['image_id'], 'mini', true);
 76:             $images[$key]['link'] = (string)$url;
 77:             $images[$key]['markerOnly'] = false;
 78:         }
 79:         // URL for updating selected layer
 80:         $imple =  $GLOBALS['injector']
 81:             ->getInstance('Horde_Core_Factory_Imple')
 82:             ->create(array('ansel', 'MapLayerSelect'));
 83:         $layerImpleUrl = $imple->getUrl();
 84: 
 85:         // And the current defaultLayer, if any.
 86:         $defaultLayer = $GLOBALS['prefs']->getValue('current_maplayer');
 87: 
 88:         $json = Horde_Serialize::serialize(array_values($images), Horde_Serialize::JSON);
 89:         $html = '<div id="ansel_map" style="height:' . $this->_params['height'] . 'px;"></div>';
 90:         $html .= <<<EOT
 91:         <script type="text/javascript">
 92:             var opts = {
 93:                 'layerUpdateEndpoint': '{$layerImpleUrl}',
 94:                 'defaultBaseLayer': '{$defaultLayer}'
 95:             }
 96:             document.observe('dom:loaded', function() { new AnselBlockGeoTag({$json}, opts); });
 97:         </script>
 98: EOT;
 99:         return $html;
100:     }
101: 
102: }
103: 
API documentation generated by ApiGen