geoloc sur xnet
authorx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Fri, 16 Jun 2006 06:32:04 +0000 (06:32 +0000)
committerx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Fri, 16 Jun 2006 06:32:04 +0000 (06:32 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@317 839d8a87-29fc-0310-9880-83ba4fa771e5

12 files changed:
ChangeLog
htdocs.net/groupe/dynamap.php [new file with mode: 0644]
htdocs.net/groupe/geoloc.php [new file with mode: 0644]
htdocs.net/groupe/geolocInit.php [new file with mode: 0644]
htdocs.net/groupe/getCityInfos.php [new file with mode: 0644]
htdocs.net/groupe/getData.php [new file with mode: 0644]
htdocs.net/groupe/icon.php [new file with mode: 0644]
htdocs/geoloc/getData.php
include/geoloc.inc.php
include/search.inc.php
include/xnet/page.inc.php
templates/geoloc/index.tpl

index 4ec746e..8b41967 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,8 +22,9 @@ New :
         - Add a quick search form in this common header.                    -Car
 
     * Xnet :
-        - Use wiki from Xnet.                                               -Car
+        - Use wiki from Xorg.                                               -Car
         - Use wiki for group pages.                                         -Car
+        - Dynamic maps using geodesix plugin.                               -Car
 
 Bug/Wish :
 
diff --git a/htdocs.net/groupe/dynamap.php b/htdocs.net/groupe/dynamap.php
new file mode 100644 (file)
index 0000000..ed7b7db
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2006 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                *
+ ***************************************************************************/
+
+
+require_once('xnet.inc.php');
+
+$querystring = "";
+foreach ($_GET as $v => $a)
+       if ($v != 'initfile')
+               $querystring .= '&'.urlencode($v).'='.urlencode($a);
+$initfile = urlencode('geolocInit.php?'.$querystring);
+
+if (urlencode(Env::get('initfile')) != $initfile)
+{
+       header("Location: dynamap.php?initfile=$initfile{$querystring}");
+       die();
+}
+
+header("Content-type: application/x-shockwave-flash");
+
+if ($globals->geoloc->use_map())
+       readfile($globals->geoloc->dynamap_path);
+
+?>
diff --git a/htdocs.net/groupe/geoloc.php b/htdocs.net/groupe/geoloc.php
new file mode 100644 (file)
index 0000000..ecbb45e
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2006 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                *
+ ***************************************************************************/
+
+require_once 'xnet.inc.php';
+
+if ($globals->asso('pub') == 'public')
+       new_group_page('geoloc/index.tpl');
+else
+       new_groupadmin_page('geoloc/index.tpl');
+
+$page->assign('use_map', $globals->geoloc->use_map());
+$page->assign('no_annu', true);
+$page->assign('dynamap_vars', 'none');
+$page->run();
+
+?>
\ No newline at end of file
diff --git a/htdocs.net/groupe/geolocInit.php b/htdocs.net/groupe/geolocInit.php
new file mode 100644 (file)
index 0000000..e9ce723
--- /dev/null
@@ -0,0 +1,28 @@
+<?php 
+/***************************************************************************
+ *  Copyright (C) 2003-2006 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                *
+ ***************************************************************************/
+
+require_once('xnet.inc.php');
+
+header("Content-type: text/xml");
+new_nonhtml_page('geoloc/geolocInit.tpl');
+
+$page->run();
+?>
diff --git a/htdocs.net/groupe/getCityInfos.php b/htdocs.net/groupe/getCityInfos.php
new file mode 100644 (file)
index 0000000..80d8032
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2006 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                *
+ ***************************************************************************/
+
+require 'xnet.inc.php';
+
+
+header("Content-type: text/xml");
+
+new_nonhtml_page('geoloc/getCityInfos.tpl');
+
+require_once('geoloc.inc.php');
+require_once('search.inc.php');
+
+$_REQUEST['asso_id'] = $globals->asso('id');
+$_REQUEST['only_current'] = 1;
+$assoField   = new RefSField('asso_id',array('gxm.asso_id'),'groupex.membres','gxm','u.user_id=gxm.uid');
+$cityIdField    = new RefSField('cityid',array('av.cityid'),'adresses','av',getadr_join('av'));
+
+$fields = new SFieldGroup(true, array($assoField, $cityIdField));
+$where = $fields->get_where_statement();
+if ($where) $where = "WHERE ".$where;
+
+$users = $globals->xdb->iterator("
+    SELECT u.user_id AS id, u.prenom, u.nom, u.promo
+      FROM adresses AS a 
+INNER JOIN auth_user_md5 AS u ON(u.user_id = a.uid)
+INNER JOIN auth_user_quick AS q ON(q.user_id = a.uid)
+        ".$fields->get_select_statement()."
+        ".$where."
+     GROUP BY u.user_id LIMIT 11",
+        $id);
+
+if ($globals->asso('pub') == 'public' || has_perms())
+    $page->assign('users', $users);
+
+$page->run();
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
diff --git a/htdocs.net/groupe/getData.php b/htdocs.net/groupe/getData.php
new file mode 100644 (file)
index 0000000..28701ab
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2006 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                *
+ ***************************************************************************/
+
+require 'xnet.inc.php';
+
+new_nonhtml_page('geoloc/getData.tpl');
+$nodata = ($globals->asso('pub') != 'public') && !has_perms();
+
+header("Content-type: text/xml");
+
+require_once('geoloc.inc.php');
+require_once('search.inc.php');
+
+$querystring = "";
+foreach ($_GET as $v => $a)
+       if ($v != 'mapid')
+               $querystring .= urlencode($v).'='.urlencode($a).'&amp;';
+$page->assign('searchvars', $querystring);
+if (Env::has('mapid'))
+    $mapid = Env::getInt('mapid', -2);
+else
+    $mapid = false;
+
+$_REQUEST['asso_id'] = $globals->asso('id');
+$_REQUEST['only_current'] = 1;
+$assoField   = new RefSField('asso_id',array('gxm.asso_id'),'groupex.membres','gxm','u.user_id=gxm.uid');
+
+if (!$nodata) {
+    list($countries, $cities) = geoloc_getData_subcountries($mapid, array($assoField), 10);
+    $page->assign('countries', $countries);
+    $page->assign('cities', $cities);
+}
+
+$page->run();
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
diff --git a/htdocs.net/groupe/icon.php b/htdocs.net/groupe/icon.php
new file mode 100644 (file)
index 0000000..9fcd601
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 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                *
+ ***************************************************************************/
+
+
+require_once('xnet.inc.php');
+
+new_nonhtml_page('');
+
+header("Content-type: application/x-shockwave-flash");
+
+if ($globals->geoloc->use_map())
+       readfile($globals->geoloc->icon_path);
+
+?>
index 61b6f9c..d358631 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  Copyright (C) 2003-2006 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -31,129 +31,20 @@ else
        new_nonhtml_page('geoloc/getData.tpl', AUTH_COOKIE);
 }
 
-require_once('search.inc.php');
 require_once('geoloc.inc.php');
-
-$usual_fields = advancedSearchFromInput();
-foreach ($usual_fields as $i_mapfield => $field) if ($field->fieldFormName == 'mapid') break;
+require_once('search.inc.php');
 
 $querystring = "";
 foreach ($_GET as $v => $a)
        if ($v != 'mapid')
                $querystring .= urlencode($v).'='.urlencode($a).'&amp;';
 $page->assign('searchvars', $querystring);
-
-$maxentities = 100;
-$minentities = 5;
-
-function get_cities_in_territory($t, $usual_fields, $direct=true)
-{
-  global $cities, $globals, $i_mapfield;
-  $usual_fields[$i_mapfield] = new MapSField('mapid', array('gcim.map_id'), array('adresses','geoloc_city_in_maps'), array('am','gcim'), array(getadr_join('am'), 'am.cityid = gcim.city_id'), $t);
-               $fields = new SFieldGroup(true, $usual_fields);
-               $where = $fields->get_where_statement();
-               if ($where) $where = " AND ".$where;
-    $cityres = $globals->xdb->iterator("
-        SELECT  gc.id,
-                gc.lon / 100000 AS x, gc.lat/100000 AS y,
-                gc.name,
-                COUNT(u.user_id) AS pop,
-                SUM(u.promo % 2) AS yellow
-          FROM auth_user_md5 AS u
-    INNER JOIN auth_user_quick AS q ON(u.user_id = q.user_id)
-            ".$fields->get_select_statement()."
-                                LEFT JOIN geoloc_city AS gc ON(gcim.city_id = gc.id)
-         WHERE ".($direct?"gcim.infos = 'smallest'":"1")."
-         $where
-      GROUP BY gc.id,gc.alias ORDER BY pop DESC");
-    while ($c = $cityres->next())
-        if ($c['pop'] > 0)
-        {
-            $city = $c;
-            $city['x'] = geoloc_to_x($c['x'], $c['y']);
-            $city['y'] = geoloc_to_y($c['x'], $c['y']);
-            $city['size'] = size_of_city($c['pop']);
-            $cities[$c['id']] = $city;
-        }
-}
-
 if (Env::has('mapid'))
-       $wheremapid = "WHERE   gm.parent = {?}";
+    $mapid = Env::getInt('mapid', -2);
 else
-       $wheremapid = "WHERE gm.parent IS NULL";
-
-$submapres = $globals->xdb->iterator(
-    "SELECT  gm.map_id AS id, gm.name, gm.x, gm.y, gm.xclip, gm.yclip, 
-            gm.width, gm.height, gm.scale, 1 AS rat
-    FROM    geoloc_maps AS gm
-    ".$wheremapid, Env::get('mapid',''));
-
-$countries = array();
-while ($c = $submapres->next())
-{
-    $country = $c;
-    $country['name'] = utf8_decode($country['name']);
-    $country['color'] = 0xFFFFFF;
-    $country['swf'] = $globals->geoloc->webservice_url."maps/mercator/map_".$c['id'].".swf";
-    $countries[$c['id']] = $country;
-}
-
-$cities = array();
-if (Env::has('mapid'))
-{
-       get_cities_in_territory(Env::getInt('mapid'), $usual_fields);
-       $nbcities = count($cities);
-       $nocity = $nbcities == 0;
-
-       $usual_fields[$i_mapfield] = new MapSField('mapid', array('map.parent'), array('adresses','geoloc_city_in_maps','geoloc_maps'), array('am','gcim','map'), array(getadr_join('am'), 'am.cityid = gcim.city_id', 'map.map_id = gcim.map_id'));
-       $fields = new SFieldGroup(true, $usual_fields);
-       $where = $fields->get_where_statement();
-       if ($where) $where = " WHERE ".$where;
-               
-       $countryres = $globals->xdb->iterator("
-           SELECT  map.map_id AS id,
-                   COUNT(u.user_id) AS nbPop,
-                   SUM(u.promo % 2) AS yellow,
-                   COUNT(DISTINCT gcim.city_id) AS nbCities,
-                   SUM(IF(u.user_id IS NULL,0,am.glng)) AS lonPop,
-                   SUM(IF(u.user_id IS NULL, 0,am.glat)) AS latPop
-             FROM  auth_user_md5 AS u
-       INNER JOIN  auth_user_quick AS q ON(u.user_id = q.user_id)
-                   ".$fields->get_select_statement()."
-            $where
-         GROUP BY  map.map_id ORDER BY NULL", $hierarchy);
-       
-       $maxpop = 0;
-       $nbentities = $nbcities + $countryres->total();
-       while ($c = $countryres->next())
-       {
-           $c['latPop'] /= $c['nbPop'];
-           $c['lonPop'] /= $c['nbPop'];
-           $c['rad'] = size_of_territory($c['nbPop']);
-           if ($maxpop < $c['nbPop']) $maxpop = $c['nbPop'];
-           $c['xPop'] = geoloc_to_x($c['lonPop'], $c['latPop']);
-           $c['yPop'] = geoloc_to_y($c['lonPop'], $c['latPop']);
-           $countries[$c['id']] = array_merge($countries[$c['id']], $c);
-       
-           $nbcities += $c['nbCities'];
-       }
-       
-       if ($nocity && $nbcities < 10)
-       {
-           foreach($countries as $i => $c)
-           {
-               $countries[$i]['nbPop'] = 0;
-               if ($c['nbCities'] > 0)
-                   get_cities_in_territory($c['id'], $usual_fields, false);
-           }   
-       }
-       
-       foreach ($countries as $i => $c) if ($c['nbPop'] > 0)
-       {
-           $lambda = pow($c['nbPop'] / $maxpop,0.3);
-           $countries[$i]['color'] = 0x0000FF + round((1-$lambda) * 0xFF)*0x010100;
-       }
-}
+    $mapid = false;
+    
+list($countries, $cities) = geoloc_getData_subcountries($mapid, advancedSearchFromInput(), 10);
 
 $page->assign('countries', $countries);
 $page->assign('cities', $cities);
index 3ef6611..43ed1f1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  Copyright (C) 2003-2006 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -301,5 +301,121 @@ function geoloc_to_y($lon, $lat) {
 function size_of_city($nb) { $s = round(log($nb + 1)*2,2); if ($s < 1) return 1; return $s; }
 function size_of_territory($nb) { return size_of_city($nb); }
 
+function geoloc_getData_subcities($mapid, $SFields, &$cities, $direct=true) {
+    global $globals;
+    for ($i_mapfield=0; $i_mapfield < count($SFields) ; $i_mapfield++) if ($SFields[$i_mapfield]->fieldFormName == 'mapid') break;
+    $SFields[$i_mapfield] = new MapSField('mapid', array('gcim.map_id'), array('adresses','geoloc_city_in_maps'), array('am','gcim'), array(getadr_join('am'), 'am.cityid = gcim.city_id'), $mapid);
+    
+    $fields = new SFieldGroup(true, $SFields);
+    $where = $fields->get_where_statement();
+    if ($where) $where = " AND ".$where;
+
+    $cityres = $globals->xdb->iterator("
+        SELECT  gc.id,
+                gc.lon / 100000 AS x, gc.lat/100000 AS y,
+                gc.name,
+                COUNT(u.user_id) AS pop,
+                SUM(u.promo % 2) AS yellow
+          FROM auth_user_md5 AS u
+    INNER JOIN auth_user_quick AS q ON(u.user_id = q.user_id)
+            ".$fields->get_select_statement()."
+                                LEFT JOIN geoloc_city AS gc ON(gcim.city_id = gc.id)
+         WHERE ".($direct?"gcim.infos = 'smallest'":"1")."
+         $where
+      GROUP BY gc.id,gc.alias ORDER BY pop DESC");
+    while ($c = $cityres->next())
+        if ($c['pop'] > 0)
+        {
+            $city = $c;
+            $city['x'] = geoloc_to_x($c['x'], $c['y']);
+            $city['y'] = geoloc_to_y($c['x'], $c['y']);
+            $city['size'] = size_of_city($c['pop']);
+            $cities[$c['id']] = $city;
+        }
+}
+
+function geoloc_getData_subcountries($mapid, $SFields, $minentities) {
+    global $globals;
+    $countries = array();
+    $cities = array();
+    
+    if ($mapid === false)
+       $wheremapid = "WHERE gm.parent IS NULL";
+    else
+       $wheremapid = "WHERE   gm.parent = {?}";
+    $submapres = $globals->xdb->iterator(
+        "SELECT  gm.map_id AS id, gm.name, gm.x, gm.y, gm.xclip, gm.yclip, 
+                gm.width, gm.height, gm.scale, 1 AS rat
+        FROM    geoloc_maps AS gm
+        ".$wheremapid, Env::get('mapid',''));
+
+    while ($c = $submapres->next())
+    {
+        $country = $c;
+        $country['name'] = utf8_decode($country['name']);
+        $country['color'] = 0xFFFFFF;
+        $country['swf'] = $globals->geoloc->webservice_url."maps/mercator/map_".$c['id'].".swf";
+        $countries[$c['id']] = $country;
+    }
+    
+    if ($mapid === false) return array($countries, $cities);
+
+       geoloc_getData_subcities(Env::getInt('mapid'), $SFields, $cities);
+       $nbcities = count($cities);
+       $nocity = $nbcities == 0;
+
+    for ($i_mapfield=0; $i_mapfield < count($SFields) ; $i_mapfield++) if ($SFields[$i_mapfield]->fieldFormName == 'mapid') break;
+       $SFields[$i_mapfield] = new MapSField('mapid', array('map.parent'), array('adresses','geoloc_city_in_maps','geoloc_maps'), array('am','gcim','map'), array(getadr_join('am'), 'am.cityid = gcim.city_id', 'map.map_id = gcim.map_id'));
+
+       $fields = new SFieldGroup(true, $SFields);
+       $where = $fields->get_where_statement();
+       if ($where) $where = " WHERE ".$where;
+               
+       $countryres = $globals->xdb->iterator("
+           SELECT  map.map_id AS id,
+                   COUNT(u.user_id) AS nbPop,
+                   SUM(u.promo % 2) AS yellow,
+                   COUNT(DISTINCT gcim.city_id) AS nbCities,
+                   SUM(IF(u.user_id IS NULL,0,am.glng)) AS lonPop,
+                   SUM(IF(u.user_id IS NULL, 0,am.glat)) AS latPop
+             FROM  auth_user_md5 AS u
+       INNER JOIN  auth_user_quick AS q ON(u.user_id = q.user_id)
+                   ".$fields->get_select_statement()."
+            $where
+         GROUP BY  map.map_id ORDER BY NULL", $hierarchy);
+       
+       $maxpop = 0;
+       $nbentities = $nbcities + $countryres->total();
+       while ($c = $countryres->next())
+       {
+           $c['latPop'] /= $c['nbPop'];
+           $c['lonPop'] /= $c['nbPop'];
+           $c['rad'] = size_of_territory($c['nbPop']);
+           if ($maxpop < $c['nbPop']) $maxpop = $c['nbPop'];
+           $c['xPop'] = geoloc_to_x($c['lonPop'], $c['latPop']);
+           $c['yPop'] = geoloc_to_y($c['lonPop'], $c['latPop']);
+           $countries[$c['id']] = array_merge($countries[$c['id']], $c);
+       
+           $nbcities += $c['nbCities'];
+       }
+       
+       if ($nocity && $nbcities < $minentities)
+       {
+           foreach($countries as $i => $c)
+           {
+               $countries[$i]['nbPop'] = 0;
+               if ($c['nbCities'] > 0)
+                   geoloc_getData_subcities($c['id'], $SFields, $cities, false);
+           }   
+       }
+       
+       foreach ($countries as $i => $c) if ($c['nbPop'] > 0)
+       {
+           $lambda = pow($c['nbPop'] / $maxpop,0.3);
+           $countries[$i]['color'] = 0x0000FF + round((1-$lambda) * 0xFF)*0x010100;
+       }
+       
+    return array($countries, $cities);   
+} 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
 ?>
index a337031..179e9c1 100644 (file)
@@ -23,6 +23,9 @@ require_once('xorg.plugin.inc.php');
 require_once("search/classes.inc.php");
 
 // {{{ function advancedSearchFromInput
+function getadr_join($table) {
+    return 'u.user_id='.$table.'.uid'.(Env::get('only_current',false)?' AND FIND_IN_SET(\'active\','.$table.'.statut)':'');
+}
 function advancedSearchFromInput()
 {
     if ($with_soundex = Env::has('with_soundex')) {
@@ -40,10 +43,6 @@ function advancedSearchFromInput()
     $subscriberField = new RefSField('subscriber',array('!(u.perms IN (\'admin\',\'user\'))+1'),'','','');
     $aliveField      = new RefSField('alive',array('(u.deces!=0)+1'),'','','');
 
-    function getadr_join($table) {
-        return 'u.user_id='.$table.'.uid'.(Env::get('only_current',false)?' AND FIND_IN_SET(\'active\','.$table.'.statut)':'');
-    }
-
     $townField      = new RefSField('city',array('ac.city'),'adresses','ac',getadr_join('ac'),false);
     $cityIdField    = new RefSField('cityid',array('av.cityid'),'adresses','av',getadr_join('av'));
     $countryField   = new RefSField('country',array('ap.country'),'adresses','ap',getadr_join('ap'));
index 6fd7c7a..261da94 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  Copyright (C) 2003-2006 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -73,8 +73,11 @@ class XnetPage extends PlatalPage
             $sub = array();
             $dim = $globals->asso('diminutif');
             $sub['présentation'] = "$dim/asso.php";
-            if (may_update() || $globals->asso('pub') == 'public')
+            if (may_update() || $globals->asso('pub') == 'public') {
                 $sub['annuaire du groupe'] = "$dim/annuaire.php";
+                if ($globals->xnet->geoloc)
+                    $sub['carte'] = "$dim/geoloc.php";
+            }
             if ($globals->asso('mail_domain')) {
                 $sub['listes de diffusion'] = "$dim/listes.php";
             }
index 524d589..2194487 100644 (file)
@@ -28,6 +28,9 @@ function ficheXorg(id)
 {
   window.open('../fiche.php?user='+id,'_blank','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=840,height=600');
 }
+{/literal}
+{if !$no_annu}
+{literal}
 function clickOnCity(id)
 {
        var f = document.getElementById('search_form');
@@ -51,31 +54,34 @@ function searchMapId(f)
        document.getElementById('search_results').style.height = '250px';
 }
 {/literal}
+{/if}
 
 </script>
-{if !$dynamap_vars}
-<p class="descr">
-Aujourd'hui {$localises} de nos camarades sont localisés grâce à leurs adresses personnelles.
-</p>
+{if !$dynamap_vars and $localises}
+  <p class="descr">
+    Aujourd'hui {$localises} de nos camarades sont localisés grâce à leurs adresses personnelles.
+  </p>
 {/if}
 {if $use_map}
-<p class="center">
-<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="600" height="450" id="dynamap" align="middle">
-<param name="allowScriptAccess" value="sameDomain" />
-<param name="quality" value="high" />
-<param name="bgcolor" value="#ffffff" />
-<param name="movie" value="dynamap_{$dynamap_vars|default:"only_current=on"}.swf" />
-<embed src="dynamap_{$dynamap_vars|default:"only_current=on"}.swf" quality="high" bgcolor="#ffffff" width="600" height="450" name="dynamap" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
-</object>
-<p class="smaller">Carte fournie gracieusement par <a href="http://www.geodesix.com/">Geodesix</a>.</p>
-</p>
-<form id="search_form" action="{#globals.baseurl#}/advanced_search.php?{$dynamap_vars|default:"only_current=on"}&amp;rechercher=1" method="post">
-<p>
-       <input type="button" value="Lister les camarades de la carte" onclick="searchMapId(this.form)"/>
-</p>
-</form>
+  <p class="center">
+    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="600" height="450" id="dynamap" align="middle">
+    <param name="allowScriptAccess" value="sameDomain" />
+    <param name="quality" value="high" />
+    <param name="bgcolor" value="#ffffff" />
+    <param name="movie" value="dynamap{if $dynamap_vars neq 'none'}_{$dynamap_vars|default:"only_current=on"}{/if}.swf" />
+    <embed src="dynamap{if $dynamap_vars neq 'none'}_{$dynamap_vars|default:"only_current=on"}{/if}.swf" quality="high" bgcolor="#ffffff" width="600" height="450" name="dynamap" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
+    </object>
+  </p>
+  <p class="smaller">Carte fournie gracieusement par <a href="http://www.geodesix.com/">Geodesix</a>.</p>
+  {if !$no_annu}
+    <form id="search_form" action="{#globals.baseurl#}/advanced_search.php?{$dynamap_vars|default:"only_current=on"}&amp;rechercher=1" method="post">
+    <p>
+       <input type="button" value="Lister les camarades de la carte" onclick="searchMapId(this.form)"/>
+    </p>
+    </form>
+  {/if}
 {else}
-<p>Le moteur de carte n'a pas été installé sur cette version de plat/al. Veuillez contacter <a href="http://www.geodesix.com/">Geodesix</a>.</p>
+  <p>Le moteur de carte n'a pas été installé sur cette version de plat/al. Veuillez contacter <a href="http://www.geodesix.com/">Geodesix</a>.</p>
 {/if} 
 <p class="descr">Pour toute question, problème ou suggestion tu peux envoyer un mail à <a href="mailto:contact+geoloc@polytechnique.org">contact+geoloc@polytechnique.org</a></p>