Map is back (but empty for now).
authorStéphane Jacob <sj@m4x.org>
Tue, 17 May 2011 19:56:42 +0000 (21:56 +0200)
committerStéphane Jacob <sj@m4x.org>
Wed, 18 May 2011 13:25:01 +0000 (15:25 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
classes/xnet.php
classes/xorg.php
htdocs/javascript/maps.js [new file with mode: 0644]
modules/geoloc.php [new file with mode: 0644]
templates/geoloc/index.tpl [new file with mode: 0644]
templates/skin/common.menu.tpl

index 8df2ae3..6dc2e23 100644 (file)
@@ -24,7 +24,7 @@ class Xnet extends Platal
     public function __construct()
     {
         parent::__construct('xnet', 'xnetgrp', 'xnetlists', 'xnetevents',
-                            'payment', 'bandeau', 'xnetnl');
+                            'payment', 'bandeau', 'xnetnl', 'geoloc');
     }
 
     public function hook_map($name)
index 3930d7e..ec7aee9 100644 (file)
@@ -28,7 +28,7 @@ class Xorg extends Platal
                             'profile', 'register', 'search', 'stats', 'admin',
                             'newsletter', 'axletter', 'epletter', 'bandeau', 'survey',
                             'fusionax', 'gadgets', 'googleapps', 'poison',
-                            'openid', 'reminder', 'api', 'urlshortener', 'deltaten');
+                            'openid', 'reminder', 'api', 'urlshortener', 'deltaten', 'geoloc');
     }
 
     public function find_hook()
diff --git a/htdocs/javascript/maps.js b/htdocs/javascript/maps.js
new file mode 100644 (file)
index 0000000..96cf94e
--- /dev/null
@@ -0,0 +1,34 @@
+/***************************************************************************
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+// http://code.google.com/apis/maps/documentation/javascript/
+
+function map_initialize(latitude, longitude)
+{
+    var latlng = new google.maps.LatLng(latitude, longitude);
+    var myOptions = {
+        zoom: 1,
+        center: latlng,
+        mapTypeId: google.maps.MapTypeId.ROADMAP
+    };
+    var map = new google.maps.Map($('#map_canvas').get(0), myOptions);
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
diff --git a/modules/geoloc.php b/modules/geoloc.php
new file mode 100644 (file)
index 0000000..b8b452d
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+class GeolocModule extends PLModule
+{
+    function handlers()
+    {
+        return array(
+            'map' => $this->make_hook('map', AUTH_COOKIE),
+        );
+    }
+
+    function handler_map($page)
+    {
+        $page->changeTpl('geoloc/index.tpl');
+        $page->addJsLink('https://maps-api-ssl.google.com/maps/api/js?v=3&sensor=false', false);
+        $page->addJsLink('maps.js');
+        $page->assign('pl_extra_header', '<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />');
+
+        $page->assign('latitude', 0);
+        $page->assign('longitude', 0);
+    }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
diff --git a/templates/geoloc/index.tpl b/templates/geoloc/index.tpl
new file mode 100644 (file)
index 0000000..a71228a
--- /dev/null
@@ -0,0 +1,29 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  This program is free software; you can redistribute it and/or modify  *}
+{*  it under the terms of the GNU General Public License as published by  *}
+{*  the Free Software Foundation; either version 2 of the License, or     *}
+{*  (at your option) any later version.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<div id="map_canvas" style="width: 100%; height: 600px"></div>
+
+<script type="text/javascript">
+  map_initialize("{$latitude}", "{$longitude}");
+</script>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
index ebc782b..605526e 100644 (file)
@@ -79,6 +79,9 @@
 
 <div class="menu_title">Communauté X</div>
 <div class="menu_item"><a href="search">Annuaire</a></div>
+{if hasPerm('directory_private,edit_directory')}
+<div class="menu_item"><a href="map">Planisphère</a></div>
+{/if}
 {if hasPerm('directory_private')}
 <div class="menu_item"><a href="jobs">Emploi &amp; Carrières</a></div>
 {/if}