</values>
</configmultienum>
</configsection>
+
+ <configsection name="maps">
+ <configheader>Maps</configheader>
+ <configswitch name="driver" desc="Which driver should we use for inline maps?">
+ <case name="false" desc="No inline map support" />
+ <case name="Horde" desc="Horde driver (support for various map providers)">
+ <configmultienum name="providers" desc="Which layers should we add to the map?">
+ <values>
+ <value desc="Google">Google</value>
+ <value desc="Yahoo">Yahoo</value>
+ <value desc="Virtual Earth/Bing">Ve</value>
+ <value desc="Various Open Sources">Public</value>
+ </values>
+ </configmultienum>
+ </case>
+ <case name="SAPO" desc="Driver for SAPO Mapas API">
+ </case>
+ </configswitch>
+ <configenum default="false" name="geocoder" desc="Which Geocoder service
+ should we use?">
+ <values>
+ <value desc="None" default="true">false</value>
+ <value desc="Google">Google</value>
+ <value desc="Yahoo">Yahoo</value>
+ <value desc="SAPO">SAPO</value>
+ </values>
+ </configenum>
+ </configsection>
</configuration>
require KRONOLITH_TEMPLATES . '/index/index.inc';
Horde::includeScriptFiles();
Horde::outputInlineScript();
+Kronolith::initEventMap($conf['maps']);
$notification->notify(array('listeners' => array('javascript')));
$tac = Horde_Ajax_Imple::factory(array('kronolith', 'TagAutoCompleter'), array('triggerId' => 'kronolithEventTags', 'box' => 'kronolithEventACBox', 'pretty' => true));
$tac->attach();
dialog.select('.tabset li').invoke('removeClassName', 'activeTab');
$(id.replace(/Link/, 'Tab')).show();
elt.parentNode.addClassName('activeTab');
+ if (id == 'kronolithEventLinkMap') {
+ /* Maps */
+ if (!Object.isUndefined(KronolithEventMap) && !KronolithEventMap.isInitialized()) {
+ KronolithEventMap.initialize();
+ }
+ }
e.stop();
return;
};
+KronolithEventMap =
+{
+ _marker: null,
+ _map: null,
+ _initialized: false,
+
+ initialize: function()
+ {
+ var layers = [];
+ if (Kronolith.conf.maps.providers) {
+ Kronolith.conf.maps.providers.each(function(l)
+ {
+ var p = new HordeMap[l]();
+ $H(p.getLayers()).values().each(function(e) { layers.push(e); });
+ });
+ }
+
+ this._map = new HordeMap.Map[Kronolith.conf.maps.driver](
+ {
+ 'elt': 'kronolithEventMap',
+ 'delayed': true,
+ 'layers': layers
+ });
+ this._map.display();
+ this._marker = this._map.addMarker(
+ {lat:38.7115479, lon: -9.13774},
+ {'draggable': true},
+ {
+ 'context': this,
+ 'dragend': this.onMarkerDragEnd
+ });
+
+ this._map.setCenter({lat:38.7115479, lon: -9.13774}, 10);
+ this._initialized = true;
+ },
+
+ isInitialized: function()
+ {
+ return this._initialized;
+ },
+
+ onMarkerDragEnd: function(r)
+ {
+ var gc = new HordeMap.Geocoder[Kronolith.conf.maps.geocoder]();
+ gc.reverseGeocode(r.getLonLat(), this.onReverseGeocode.bind(this), this.onError.bind(this) );
+ },
+
+ onReverseGeocode: function(r) { $('kronolithEventLocation').value = r; },
+
+ onError: function(r) { },
+
+ onGeocode: function(r) { },
+
+ geocode: function(a) {
+ var gc = new HordeMap.Geocoder[Kronolith.geocoderType]();
+ gc.geocode(a, function(r) {
+ r = r.shift();
+ ll = new OpenLayers.LonLat(r.Longitude, r.Latitude);
+ //this._marker.setLonLat(ll);
+ this._map.setCenter(ll);
+ }.bind(this),
+ this.onError);
+ }
+};
+
/* Initialize global event handlers. */
document.observe('dom:loaded', KronolithCore.onDomLoad.bind(KronolithCore));
Event.observe(window, 'resize', KronolithCore.onResize.bind(KronolithCore));
}
/**
+ * Initialize the event map.
+ *
+ * @param array $params Parameters to pass the the map
+ *
+ * @return void
+ */
+ public static function initEventMap($params)
+ {
+ // Add the apikeys
+ if (!empty($params['layers'])) {
+ foreach ($params['layers'] as $layer) {
+ switch ($layer) {
+ case 'Google':
+ $params['apikeys']['google'] = $GLOBALS['conf']['api']['googlemaps'];
+ break;
+ case 'Yahoo':
+ $params['apikeys']['yahoo'] = $GLOBALS['conf']['api']['yahoomaps'];
+ break;
+ //case 'Ve':
+ // none needed.
+ case 'Cloudmade':
+ $params['apikeys']['cloudemade'] = $GLOBALS['conf']['api']['cloudemade'];
+ break;
+ }
+ }
+ }
+
+ if (!empty($params['geocoder'])) {
+ switch ($params['geocoder']) {
+ case 'Google':
+ $params['apikeys']['google'] = $GLOBALS['conf']['api']['googlemaps'];
+ break;
+ case 'Yahoo':
+ $params['apikeys']['yahoo'] = $GLOBALS['conf']['api']['yahoomaps'];
+ break;
+ //case 'Ve':
+ // none needed.
+ case 'Cloudmade':
+ $params['apikeys']['cloudemade'] = $GLOBALS['conf']['api']['cloudemade'];
+ break;
+ }
+ }
+
+ Horde::addScriptFile('hordemap/map.js', 'horde');
+ $js = 'HordeMap.initialize(' . Horde_Serialize::serialize($params, HORDE_SERIALIZE::JSON) . ');';
+ Horde::addinlineScript($js);
+ }
+
+ /**
* Outputs the javascript code which defines all javascript variables
* that are dependent on the local user's account.
*
$code['text']['recur'][$recurType] = self::recurToString($recurType);
}
+ // Maps
+ $code['conf']['maps'] = $GLOBALS['conf']['maps'];
+
return array('var Kronolith = ' . Horde_Serialize::serialize($code, Horde_Serialize::JSON, Horde_Nls::getCharset()) . ';');
}
<li><a href="#" class="kronolithTabLink" id="kronolithEventLinkRecur"><?php echo _("Repeat") ?></a></li>
<li><a href="#" class="kronolithTabLink" id="kronolithEventLinkUrl"><?php echo _("URL") ?></a></li>
<li><a href="#" class="kronolithTabLink" id="kronolithEventLinkAttendees"><?php echo _("Attendees") ?></a></li>
- <li><a href="#" class="kronolithTabLink" id="kronolithEventLinkTags"><?php echo _("Tags") ?></a></li>
+ <li><a href="#" class="kronolithTabLink" id="kronolithEventLinkTags"><?php echo _("Tags") ?></a></li>
+ <li><a href="#" class="kronolithTabLink" id="kronolithEventLinkMap"><?php echo _("Map") ?></a></li>
</ul>
</div>
<br class="clear" />
<div class="kronolithTopTags" id="kronolithEventTopTags"></div>
</div>
+<div id="kronolithEventTabMap" class="kronolithTabsOption" style="display:none;">
+ <div id="kronolithEventMap"></div>
+</div>
+
<div class="kronolithFormActions">
<input id="kronolithEventSave" type="button" value="<?php echo _("Save") ?>" class="button ok" />
<input id="kronolithEventDelete" type="button" value="<?php echo _("Delete") ?>" class="button ko" />
#kronolithEventTabAttendees th.night {
background-color: #ccc;
}
+
#kronolithEventTabAttendees td div {
margin: 0;
height: 100%;
}
+/* Map */
+#kronolithEventMap {
+ height: 400px;
+ width: 700px;
+}
+#kronolithEventMap_OpenLayers_ViewPort div {
+ margin-bottom: 0;
+}
+.olMapViewPort div {
+ margin-bottom: 0;
+}
+.olControlLayerSwitcher div {
+ line-height: 100%;
+ margin-bottom: 0px;
+}
+
/* Mini calendar */
.kronolithMinical {
position: relative;