open test sur la geoloc svp
authorPascal Corpet <pascal.corpet@m4x.org>
Sat, 11 Jun 2005 18:35:26 +0000 (18:35 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:29:13 +0000 (23:29 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-702

ChangeLog
htdocs/geoloc/globe.php [new file with mode: 0644]
htdocs/geoloc/index.php [new file with mode: 0644]
include/geoloc.inc.php
include/profil/verif_adresses.inc.php
templates/geoloc/form.address.tpl
templates/geoloc/index.tpl [new file with mode: 0644]

index b0bcbcd..f7b1044 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@ VERSION 0.9.7                                                                                                            07 May 2004
 
 New :
 
+       * Profile :
+               - Address parser.                                                                                                       -Car
+               
        * Search :
                - Nickname are used in fast search.                                                                     -Car
 
diff --git a/htdocs/geoloc/globe.php b/htdocs/geoloc/globe.php
new file mode 100644 (file)
index 0000000..05c3497
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2005 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('xorg.inc.php');
+new_nonhtml_page('', AUTH_COOKIE);
+header("Content-type: image/png");
+
+$res = $globals->xdb->iterRow('SELECT lat, lon FROM geoloc_city AS gc LEFT JOIN adresses AS a ON(gc.id = a.cityid) WHERE a.cityid IS NOT NULL GROUP BY gc.id');
+
+$img = imageCreateFromPng("../images/globe.png");
+
+$coul = imagecolorallocate($img, 0, 0, 0);
+
+while ($a = $res->next()) 
+  imagefilledellipse($img, round(($a[1]/100000 + 180 )/360*600), round((90 - $a[0]/100000)/180*300), 5, 5, $coul);
+
+imagePng($img);
+imagedestroy($img);
+// vim:set et sws=4 sw=4 sts=4:
+?>
diff --git a/htdocs/geoloc/index.php b/htdocs/geoloc/index.php
new file mode 100644 (file)
index 0000000..ad1da96
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2005 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('xorg.inc.php');
+new_skinned_page('geoloc/index.tpl', AUTH_COOKIE);
+
+$res = $globals->xdb->query('SELECT COUNT(DISTINCT uid) FROM adresses WHERE cityid IS NOT NULL');
+$page->assign('localises', $res->fetchOneCell());
+
+$page->run();
+
+// vim:set et sws=4 sw=4 sts=4:
+?>
index 4cf977a..717436d 100644 (file)
@@ -76,7 +76,7 @@ function get_address_infos($txt) {
     $keys = explode('|',fgets($f));
     $vals = explode('|',fgets($f));
     $infos = array();
-    foreach ($keys as $i=>$key) if($vals[$i]) $infos[$key] = $vals[$i];
+    foreach ($keys as $i=>$key) if($vals[$i]) $infos[$key] = ($key == 'sql')?$vals[$i]:utf8_decode($vals[$i]);
     global $globals;
     if ($infos['sql'])
        $globals->xdb->execute("REPLACE INTO geoloc_city VALUES ".$infos['sql']);
@@ -99,6 +99,11 @@ function get_address_text($adr) {
         if ($adr['city']) $l .= $adr['city'];
     }
     if ($l) $t .= "\n".trim($l);
+    if ($adr['country'] != '00' && !$adr['countrytxt']) {
+        global $globals;
+        $res = $globals->xdb->query("SELECT pays FROM geoloc_pays WHERE a2 = {?}", $adr['country']);
+        $adr['countrytxt'] = $res->fetchOneCell();
+    }
     if ($adr['countrytxt']) $t .= "\n".$adr['countrytxt'];
     return trim($t);
 }
index 39d9121..b13a1bb 100644 (file)
@@ -85,20 +85,24 @@ function replace_address($i){
   replace_ifset_adr('pub', $i);
   replace_ifset_adr('tel_pub', $i);
   replace_ifset_adr('txt', $i);
-  if ($GLOBALS['adresses'][$i]['txt'] && !Env::get('nochange'.$i, true)) {
+  if ($GLOBALS['adresses'][$i]['txt'] && Env::get('change'.$i, false)) {
        require_once('geoloc.inc.php');
        $new = get_address_infos($GLOBALS['adresses'][$i]['txt']);
-       $GLOBALS['adresses'][$i]['adr1'] = '';
-       $GLOBALS['adresses'][$i]['adr2'] = '';
-       $GLOBALS['adresses'][$i]['adr3'] = '';
-       $GLOBALS['adresses'][$i]['postcode'] = '';
-       $GLOBALS['adresses'][$i]['city'] = '';
-       unset($GLOBALS['adresses'][$i]['cityid']);
-       $GLOBALS['adresses'][$i]['country'] = '00';
-       $GLOBALS['adresses'][$i]['region'] = '';
-       $GLOBALS['adresses'][$i] = array_merge($GLOBALS['adresses'][$i], $new);
-       $GLOBALS['adresses'][$i]['txt'] = get_address_text($GLOBALS['adresses'][$i]);
+       // if we found a localisation, erase old address
+       if ($new['sql']) {
+               $GLOBALS['adresses'][$i]['adr1'] = '';
+               $GLOBALS['adresses'][$i]['adr2'] = '';
+               $GLOBALS['adresses'][$i]['adr3'] = '';
+               $GLOBALS['adresses'][$i]['postcode'] = '';
+               $GLOBALS['adresses'][$i]['city'] = '';
+               unset($GLOBALS['adresses'][$i]['cityid']);
+               $GLOBALS['adresses'][$i]['country'] = '00';
+               $GLOBALS['adresses'][$i]['countrytxt'] = '';
+               $GLOBALS['adresses'][$i]['region'] = '';
+               $GLOBALS['adresses'][$i] = array_merge($GLOBALS['adresses'][$i], $new);
+       }
   }
+  $GLOBALS['adresses'][$i]['txt'] = get_address_text($GLOBALS['adresses'][$i]);
   $tab = Env::getMixed('numero_formulaire', Array());
   if($tab[$i])
     $GLOBALS['adresses'][$i]['numero_formulaire'] = $tab[$i];
index dd8d632..0d6fc50 100644 (file)
@@ -1,18 +1,22 @@
     <tr>
       <td class="colg">
         <span class="titre">{$titre}</span>
-        {if $adr.nouvelle != 'new' && !$smarty.request.detail[$adrid]}
+        {if !$smarty.request.detail[$adrid]}
        <br />
-          [<a href="{$url}&amp;detail[{$adrid}]=1">corriger</a>]
-        {/if}
-       {if $adr.nouvelle != 'new' && !$adr.cityid}
+          [<a href="{$url}&amp;detail[{$adrid}]=1">{if $adr.nouvelle != 'new'}corriger{else}préciser{/if}</a>]
+       {/if}
+       {if $adr.nouvelle != 'new' && !$adr.cityid && !$smarty.request.detail[$adrid]}
        <br />
        <span class="erreur">non géolocalisée</span>
-       {/if}
+       <br />
+       <input type="checkbox" name="change{$adrid}" id="change{$adrid}" />
+       <label for="change{$adrid}">localiser</label>
+       {else}
+        <input type="hidden" name="change{$adrid}" value="0" />
+        {/if}
       </td>
       <td class="cold">
         {if $smarty.request.detail[$adrid] neq 1}
-        <input type="hidden" name="nochange{$adrid}" value="1" />
         <input type="hidden" name="adr1[{$adrid}]" value="{$adr.adr1}" />
         <input type="hidden" name="adr2[{$adrid}]" value="{$adr.adr2}" />
         <input type="hidden" name="adr3[{$adrid}]" value="{$adr.adr3}" />
         <input type="hidden" name="cityid[{$adrid}]" value="{$adr.cityid}" />
         <input type="hidden" name="region[{$adrid}]" value="{$adr.region}" />
         <input type="hidden" name="country[{$adrid}]" value="{$adr.country}" />
-        <textarea name="txt[{$adrid}]" cols="43" rows="3" onclick="form.nochange{$adrid}.value=0;select()">{$adr.txt}</textarea>
+        <textarea name="txt[{$adrid}]" cols="43" rows="3"
+       {if $adr.nouvelle != 'new' && !$adr.cityid && !$smarty.request.detail[$adrid]}
+       onclick="form.change{$adrid}.checked='checked';select()"
+       {else}
+       onclick="form.change{$adrid}.value=1;select()"
+       {/if}
+       >{$adr.txt}</textarea>
       {else}
         <input type="hidden" name="cityid[{$adrid}]" value="{$adr.cityid}" />
         <input type="text" name="adr1[{$adrid}]" size="43" maxlength="88" value="{$adr.adr1}" />
diff --git a/templates/geoloc/index.tpl b/templates/geoloc/index.tpl
new file mode 100644 (file)
index 0000000..555ce6d
--- /dev/null
@@ -0,0 +1,41 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2004-2005 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               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<h1>Géolocalisation</h1>
+
+<p class="descr">Aujourd'hui {$localises} de nos camarades sont localisés grâce à leurs adresses personnelles. La géolocalisation permet de :
+</p>
+<ul>
+<li>standardiser les adresses</li>
+<li>rechercher de manière précise par lieu géographique</li>
+<li>dans un deuxième temps, faire des jolies cartes</li>
+</ul>
+
+<p class="center">
+<img src="globe.php" width="500" alt="Carte du monde des X"/>
+</p>
+
+<p class="descr">Pour savoir comment ça marche tu peux aller faire un tour sur le <a href="http://www.aaege.org/GeolocDev/">site de développement</a> du projet.</p>
+
+<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>
+
+{* vim:set et sw=2 sts=2 sws=2: *}