From 2aa2c77aef77e0bfba275dfcb3b257a8f8d66ef1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Wed, 18 Feb 2009 21:45:48 +0100 Subject: [PATCH] Finishes to move functions from geoloc.inc.php to geocoding.inc.php, adapts them to the new geocoding, trashes the planisphere. --- classes/xnetpage.php | 1 - htdocs/xorg.php | 2 +- include/geocoding.inc.php | 10 + include/geoloc.inc.php | 538 ----------------------------------- include/userset.inc.php | 96 ------- modules/events.php | 5 +- modules/geoloc.php | 159 ----------- modules/geoloc/.gitignore | 1 - modules/profile/mentor.inc.php | 4 + plugins/function.display_address.php | 2 +- plugins/function.geoloc_country.php | 31 -- plugins/function.geoloc_region.php | 31 -- templates/admin/index.tpl | 8 - templates/geoloc/admin.tpl | 36 --- templates/geoloc/admin_dynamap.tpl | 64 ----- templates/geoloc/city.tpl | 27 -- templates/geoloc/country.tpl | 47 --- templates/geoloc/init.tpl | 59 ---- templates/include/plview.geoloc.tpl | 84 ------ templates/profile/groupesx.tpl | 1 - templates/profile/mentor.tpl | 5 +- templates/skin/common.menu.tpl | 1 - 22 files changed, 22 insertions(+), 1190 deletions(-) delete mode 100644 include/geoloc.inc.php delete mode 100644 modules/geoloc.php delete mode 100644 modules/geoloc/.gitignore delete mode 100644 plugins/function.geoloc_country.php delete mode 100644 plugins/function.geoloc_region.php delete mode 100644 templates/geoloc/admin.tpl delete mode 100644 templates/geoloc/admin_dynamap.tpl delete mode 100644 templates/geoloc/city.tpl delete mode 100644 templates/geoloc/country.tpl delete mode 100644 templates/geoloc/init.tpl delete mode 100644 templates/include/plview.geoloc.tpl diff --git a/classes/xnetpage.php b/classes/xnetpage.php index 50d86bb..f038564 100644 --- a/classes/xnetpage.php +++ b/classes/xnetpage.php @@ -87,7 +87,6 @@ class XnetPage extends PlPage if ($perms->hasFlag('groupannu')) { $sub['annuaire du groupe'] = "$dim/annuaire"; $sub['trombinoscope'] = "$dim/trombi"; - $sub['planisphère'] = "$dim/geoloc"; } if ($perms->hasFlag('groupmember')) { if ($globals->asso('forum')) { diff --git a/htdocs/xorg.php b/htdocs/xorg.php index 28202d6..7f1a842 100644 --- a/htdocs/xorg.php +++ b/htdocs/xorg.php @@ -22,7 +22,7 @@ require_once dirname(__FILE__).'/../include/xorg.inc.php'; $platal = new Xorg('auth', 'carnet', 'email', 'events', 'forums', - 'geoloc', 'lists', 'marketing', 'payment', 'platal', + 'lists', 'marketing', 'payment', 'platal', 'profile', 'register', 'search', 'stats', 'admin', 'newsletter', 'axletter', 'bandeau', 'survey', 'fusionax', 'gadgets', 'googleapps', 'poison', 'openid'); diff --git a/include/geocoding.inc.php b/include/geocoding.inc.php index fc812fa..c888a85 100644 --- a/include/geocoding.inc.php +++ b/include/geocoding.inc.php @@ -68,6 +68,16 @@ abstract class Geocoder { } return implode("\n", array_slice($textArray, 0, $limit)); } + + // Returns the number of non geocoded addresses for a user. + static public function countNonGeocoded($pid) + { + $res = XDB::query("SELECT COUNT(*) + FROM profile_addresses + WHERE pid = {?} AND FIND_IN_SET('home', type) AND accuracy = 0", + $pid); + return $res->fetchOneCell(); + } } // Implementation of a Geocoder using the Google Maps API. Please refer to diff --git a/include/geoloc.inc.php b/include/geoloc.inc.php deleted file mode 100644 index 0a6bfac..0000000 --- a/include/geoloc.inc.php +++ /dev/null @@ -1,538 +0,0 @@ -fetchOneCell(); - } - if (isset($adr['countrytxt']) && $adr['countrytxt']) { - $t .= "\n".$adr['countrytxt']; - } - return trim($t); -} -// }}} -// {{{ compare_addresses_text($a, $b) -/** compares if two address matches - * @param $a the raw text of an address - * @param $b the raw text of a complete valid address - */ -function compare_addresses_text($a, $b) -{ - $ta = strtoupper(preg_replace(array("/[0-9,\"'#~:;_\- ]/", "/\r\n/"), array("", "\n"), $a)); - $tb = strtoupper(preg_replace(array("/[0-9,\"'#~:;_\- ]/", "/\r\n/"), array("", "\n"), $b)); - - $la = explode("\n", $ta); - $lb = explode("\n", $tb); - - if (count($lb) > count($la) + 1) { - return false; - } - foreach ($la as $i => $l) { - if (levenshtein(trim($l), trim($lb[$i])) > 3) { - return false; - } - } - return true; -} - -// }}} -// {{{ localize_addresses($uid) -/* localize all the address of a user and modify the database - * if the new address match with the old one - * @param $uid the id of the user - */ -function localize_addresses($uid) -{ - $res = XDB::iterator("SELECT * - FROM adresses - WHERE uid = {?} and (cityid IS NULL OR cityid = 0)", $uid); - $erreur = Array(); - - while ($a = $res->next()) { - $new = get_address_infos($ta = get_address_text($a)); - if (compare_addresses_text($ta, get_address_text($new))) { - XDB::execute("UPDATE adresses - SET adr1 = {?}, adr2 = {?}, adr3 = {?}, - cityid = {?}, city = {?}, postcode = {?}, - region = {?}, regiontxt = {?}, country = {?}, - glat = {?}, glng = {?} - WHERE uid = {?} AND adrid = {?}", - $new['adr1'], $new['adr2'], $new['adr3'], - $new['cityid'], $new['city'], $new['postcode'], - $new['region'], $new['regiontxt'], $new['country'], - $new['precise_lat'], $new['precise_lon'], - $uid, $a['adrid']); - $new['store'] = true; - if (!$new['cityid']) { - $erreur[$a['adrid']] = $new; - } - } else { - $new['store'] = false; - $erreur[$a['adrid']] = $new; - } - } - return $erreur; -} -// }}} -// {{{ get_address_infos($txt) -/** retrieve the infos on a text address - * store on the fly the info of the city concerned - * @param $txt the raw text of an address - */ - -function get_address_infos($txt) -{ - global $globals; - - $url = $globals->geoloc->webservice_url."address.php?precise=1&txt=" . urlencode($txt); - if ($globals->debug & DEBUG_BT) { - if (!isset(PlBacktrace::$bt['Geoloc'])) { - new PlBacktrace('Geoloc'); - } - PlBacktrace::$bt['Geoloc']->start($url); - } - $f = @fopen($url, 'r'); - if ($f === false) { - if ($globals->debug & DEBUG_BT) { - PlBacktrace::$bt['Geoloc']->stop(0, 'Can\'t fetch result'); - } - return false; - } - $keys = explode('|',fgets($f)); - $vals = explode('|',fgets($f)); - if ($globals->debug & DEBUG_BT) { - $data = array(); - for ($i = 0 ; $i < count($keys) ; ++$i) { - $data[] = array($keys[$i], $vals[$i]); - } - PlBacktrace::$bt['Geoloc']->stop(count($keys), null, $data); - } - $infos = empty_address(); - foreach ($keys as $i=>$key) { - if($vals[$i]) { - if ($key == 'sql') { - $infos[$key] = $vals[$i]; - } else { - $val = strtr($vals[$i], array(chr(197).chr(147) => "œ")); - $infos[$key] = $val; - } - } - } - if (empty($infos['country'])) { - $infos['country'] = '00'; - } - if (isset($infos['sql']) && $infos['sql']) { - $sql = explode(', ', trim($infos['sql'], '()')); - if (count($sql) == 16) { - for ($i = 0 ; $i < 16 ; ++$i) { - $sql[$i] = stripslashes(trim($sql[$i], ' \'')); - } - XDB::execute("REPLACE INTO geoloc_city - VALUES ({?}, {?}, {?}, {?}, {?}, {?}, - {?}, {?}, {?}, {?}, {?}, {?}, - {?}, {?}, {?}, {?})", - $sql[0], $sql[1], $sql[2], $sql[3], $sql[4], $sql[5], - $sql[6], $sql[7], $sql[8], $sql[9], $sql[10], $sql[11], - $sql[12], $sql[13], $sql[14], $sql[15]); - } - } - if (isset($infos['display']) && $infos['display']) - XDB::execute("UPDATE geoloc_pays - SET display = {?} - WHERE a2 = {?}", $infos['display'], $infos['country']); - if (isset($infos['cityid'])) { - fix_cities_not_on_map(1, $infos['cityid']); - if (floatval($infos['precise_lat']) && floatval($infos['precise_lon'])) { - $res = XDB::query("SELECT c.lat / 100000, c.lon / 100000 - FROM geoloc_city AS c - WHERE c.id = {?}", $infos['cityid']); - if ($res->numRows()) { - list($glat, $glng) = $res->fetchOneRow(); - $infos['precise_lat'] = $glat; - $infos['precise_lon'] = $glng; - } - } - } - return $infos; -} - -// }}} -// {{{ synchro_city($id) -/** synchronise the local geoloc_city base to geoloc.org - * @param $id the id of the city to synchronize - */ -function synchro_city($id) -{ - global $globals; - $url = $globals->geoloc->webservice_url."cityFinder.php?method=id&id=".$id."&out=sql"; - if (!($f = @fopen($url, 'r'))) { - return false; - } - $s = fgets($f); - if ($s) { - return XDB::execute("REPLACE INTO geoloc_city VALUES ".$s) > 0; - } -} - // }}} -// {{{ function fix_cities_not_on_map($limit) -function fix_cities_not_on_map($limit=false, $cityid=false) -{ - $missing = XDB::query("SELECT c.id - FROM geoloc_city AS c - LEFT JOIN geoloc_city_in_maps AS m ON(c.id = m.city_id) - WHERE m.city_id IS NULL" - . ($cityid ? " AND c.id = '" . $cityid . "'" : "" ) - . ($limit ? " LIMIT $limit" : "" )); - $maps = get_cities_maps($missing->fetchColumn()); - if ($maps) { - $values = ""; - foreach ($maps as $cityid => $maps_c) { - foreach ($maps_c as $map_id) { - $values .= ",($cityid, $map_id, '')"; - } - } - if (strlen($values) > 1) { - XDB::execute("REPLACE INTO geoloc_city_in_maps - VALUES ".substr($values, 1)); - } - } else { - return false; - } - return true; -} - -function set_smallest_levels() -{ - $maxlengths = XDB::iterRow("SELECT MAX(LENGTH(gm.path)), gcim.city_id - FROM geoloc_city_in_maps AS gcim - INNER JOIN geoloc_maps AS gm USING ( map_id ) - GROUP BY gcim.city_id"); - while (list($length, $id) = $maxlengths->next()) { - XDB::execute("UPDATE geoloc_city_in_maps AS gcim - INNER JOIN geoloc_maps AS gm USING(map_id) - SET gcim.infos = IF(LENGTH(gm.path) = {?}, 'smallest', '') - WHERE gcim.city_id = {?}", $length, $id); - } - return true; -} -// }}} -// {{{ geoloc_country($current, $avail_only = false) -/** donne la liste déroulante des pays - * @param $current pays actuellement selectionné - */ -function geoloc_country($current, $avail_only = false) -{ - if ($avail_only) { - $res = XDB::iterRow('SELECT g.a2, g.pays - FROM geoloc_pays AS g - INNER JOIN adresses AS a ON(a.country = g.a2) - GROUP BY g.a2 - ORDER BY g.pays'); - } else { - $res = XDB::iterRow('SELECT a2,pays FROM geoloc_pays ORDER BY pays'); - } - $html = ""; - while (list($my_id, $my_pays) = $res->next()) { - $html .= sprintf("\n", - $my_id, ($current==$my_id?"selected='selected'":""), $my_pays); - } - return $html; -} - -// }}} -// {{{ geoloc_region($country, $current, $avail_only = false) -/** donne la liste deroulante des regions pour un pays - * @param $pays le pays dont on veut afficher les regions - * @param $current la region actuellement selectionnee - */ -function geoloc_region($country, $current, $avail_only = false) -{ - if ($avail_only) { - $res = XDB::iterRow('SELECT r.region, r.name - FROM geoloc_region AS r - INNER JOIN adresses AS a ON (a.country = r.a2 AND a.region = r.region) - WHERE r.a2 = {?} - GROUP BY r.region - ORDER BY r.name', $country); - } else { - $res = XDB::iterRow('SELECT region,name - FROM geoloc_region - WHERE a2 = {?} - ORDER BY name', $country); - } - $html = ""; - while (list($regid, $regname) = $res->next()) { - $html .= sprintf("\n", - $regid, ($current==$regid?"selected='selected'":""), $regname); - } - return $html; -} -// }}} -// {{{ get_cities_maps($array) -/* get all the maps id of the cities contained in an array */ -function get_cities_maps($array) -{ - global $globals; - implode("\n",$array); - $url = $globals->geoloc->webservice_url."findMaps.php?datatext=".urlencode(implode("\n", $array)); - if (!($f = @fopen($url, 'r'))) return false; - $maps = array(); - while (!feof($f)) - { - $l = trim(fgets($f)); - $tab = explode(';', $l); - $i = $tab[0]; - unset($tab[0]); - $maps[$i] = $tab; - } - return $maps; -} -// }}} -// {{{ get_new_maps($url) -/** set new maps from url **/ -function get_new_maps($url) -{ - if (!($f = @fopen($url, 'r'))) { - return false; - } - XDB::query('TRUNCATE TABLE geoloc_maps'); - $s = ''; - while (!feof($f)) { - $l = fgetcsv($f, 1024, ';', '"'); - foreach ($l as $i => $val) { - if ($val != 'NULL') { - $l[$i] = '\''.addslashes($val).'\''; - } - } - $s .= ',('.implode(',',$l).')'; - } - XDB::execute('INSERT INTO geoloc_maps VALUES '.substr($s, 1)); - return true; -} -// }}} - -function geoloc_to_x($lon, $lat) -{ - return deg2rad(1) * $lon *100; -} - -function geoloc_to_y($lon, $lat) -{ - if ($lat < -75) { - return latToY(-75); - } - if ($lat > 75) { - return latToY(75); - } - return -100 * log(tan(pi()/4 + deg2rad(1)/2*$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) -{ - if ($SFields instanceof UserSet) { - $set = $SFields; - $SFields = array(); - } else { - $set = new UserSet(); - } - 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(); - $joins = $fields->get_select_statement(); - if ($where) { - $where .= ' AND '; - } - $cityres = $set->get('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', - "$joins - LEFT JOIN geoloc_city AS gc ON(gcim.city_id = gc.id)", - $where . ($direct ? "gcim.infos = 'smallest'" : '1'), - 'gc.id, gc.alias', - 'pop DESC'); - foreach($cityres as $c) { - 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, $sin, $minentities) -{ - $countries = array(); - $cities = array(); - - if ($mapid === false) { - $wheremapid = "WHERE gm.parent IS NULL"; - } else { - $wheremapid = "WHERE gm.parent = {?}"; - } - $submapres = 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::v('mapid','')); - - global $globals; - - while ($c = $submapres->next()) { - $country = $c; - $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::i('mapid'), $sin, $cities); - $nbcities = count($cities); - $nocity = $nbcities == 0; - if ($sin instanceof UserSet) { - $set = $sin; - $SFields = array(); - } else { - $set = new UserSet(); - $SFields = $sin; - } - - 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(); - $joins = $fields->get_select_statement(); - $countryres = $set->get('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', - $joins, - $where, - 'map.map_id', - 'NULL'); - - $maxpop = 0; - $nbentities = $nbcities + count($countryres); - foreach ($countryres as $c) { - $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'], $sin, $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 enc=utf-8: -?> diff --git a/include/userset.inc.php b/include/userset.inc.php index 5251d44..be9e740 100644 --- a/include/userset.inc.php +++ b/include/userset.inc.php @@ -367,102 +367,6 @@ class TrombiView extends MultipageView } } -class GeolocView implements PlView -{ - private $set; - private $type; - private $params; - - public function __construct(PlSet &$set, $data, array $params) - { - $this->params = $params; - $this->set =& $set; - $this->type = $data; - } - - private function use_map() - { - return is_file(dirname(__FILE__) . '/../modules/geoloc/dynamap.swf') && - is_file(dirname(__FILE__) . '/../modules/geoloc/icon.swf'); - } - - public function args() - { - $args = $this->set->args(); - unset($args['initfile']); - unset($args['mapid']); - return $args; - } - - public function apply(PlPage &$page) - { - require_once 'geoloc.inc.php'; - require_once '../modules/search/search.inc.php'; - - switch ($this->type) { - case 'icon.swf': - header("Content-type: application/x-shockwave-flash"); - header("Pragma:"); - readfile(dirname(__FILE__).'/../modules/geoloc/icon.swf'); - exit; - - case 'dynamap.swf': - header("Content-type: application/x-shockwave-flash"); - header("Pragma:"); - readfile(dirname(__FILE__).'/../modules/geoloc/dynamap.swf'); - exit; - - case 'init': - $page->changeTpl('geoloc/init.tpl', NO_SKIN); - header('Content-Type: text/xml'); - header('Pragma:'); - if (!empty($GLOBALS['IS_XNET_SITE'])) { - $page->assign('background', 0xF2E9D0); - } - break; - - case 'city': - $page->changeTpl('geoloc/city.tpl', NO_SKIN); - header('Content-Type: text/xml'); - header('Pragma:'); - $only_current = Env::v('only_current', false)? ' AND FIND_IN_SET(\'current\', adrf.flags)' : ''; - $it =& $this->set->get('u.user_id AS id, u.prenom, u.nom, d.promo, al.alias', - "INNER JOIN profile-addresses AS adrf ON (adrf.pid = u.user_id $only_current) - INNER JOIN profile_display AS d ON (d.pid = u.user_id) - LEFT JOIN aliases AS al ON (u.user_id = al.id - AND FIND_IN_SET('bestalias', al.flags)) - INNER JOIN profile_addresses AS avg ON (" . getadr_join('avg') . ")", - 'adrf.localityId = ' . Env::i('cityid'), null, null, 11); - $page->assign('users', $it); - break; - - case 'country': - if (Env::has('debug')) { - $page->changeTpl('geoloc/country.tpl', SIMPLE); - } else { - $page->changeTpl('geoloc/country.tpl', NO_SKIN); - header('Content-Type: text/xml'); - header('Pragma:'); - } - $mapid = Env::has('mapid') ? Env::i('mapid', -2) : false; - list($countries, $cities) = geoloc_getData_subcountries($mapid, $this->set, 10); - $page->assign('countries', $countries); - $page->assign('cities', $cities); - break; - - default: - global $globals; - if (!$this->use_map()) { - $page->assign('request_geodesix', true); - } - $page->assign('annu', @$this->params['with_annu']); - $page->assign('protocole', @$_SERVER['HTTPS'] ? 'https' : 'http'); - $this->set->get('u.user_id', null, "u.perms != 'pending' AND u.deces = 0", "u.user_id", null); - return 'include/plview.geoloc.tpl'; - } - } -} - class GadgetView implements PlView { public function __construct(PlSet &$set, $data, array $params) diff --git a/modules/events.php b/modules/events.php index 191c6c5..c51aec9 100644 --- a/modules/events.php +++ b/modules/events.php @@ -128,9 +128,8 @@ class EventsModule extends PLModule $page->assign('photo_incitation', $res->fetchOneCell() == 0); // Geo-location onebox. - require_once 'geoloc.inc.php'; - $res = localize_addresses(S::user()->id()); - $page->assign('geoloc_incitation', count($res)); + require_once "geocoding.inc.php"; + $page->assign('geoloc_incitation', Geocoder::countNonGeocoded(S::user()->id())); // Direct link to the RSS feed, when available. if (S::rssActivated()) { diff --git a/modules/geoloc.php b/modules/geoloc.php deleted file mode 100644 index bb63263..0000000 --- a/modules/geoloc.php +++ /dev/null @@ -1,159 +0,0 @@ - $this->make_hook('default', AUTH_COOKIE), - 'admin/geoloc' => $this->make_hook('admin', AUTH_MDP, 'admin'), - 'admin/geoloc/dynamap' => $this->make_hook('admin_dynamap', AUTH_MDP, 'admin'), - 'admin/geoloc/country' => $this->make_hook('admin_country', AUTH_MDP, 'admin') - ); - } - - function handler_default(&$page, $action = null, $subaction = null) - { - global $globals; - - $set = new UserSet(); - $set->addMod('geoloc', 'Geolocalisation', true); - $set->apply('geoloc', $page, $action, $subaction); - } - - function handler_admin(&$page, $action = false) { - $page->changeTpl('geoloc/admin.tpl'); - require_once("geoloc.inc.php"); - $page->setTitle('Administration - Geolocalisation'); - - $nb_synchro = 0; - - if (Env::has('id') && is_numeric(Env::v('id'))) { - if (synchro_city(Env::v('id'))) $nb_synchro ++; - } - - if ($action == 'missinglat') { - $res = XDB::iterRow("SELECT id FROM geoloc_city WHERE lat = 0 AND lon = 0"); - while ($a = $res->next()) if (synchro_city($a[0])) $nb_synchro++; - } - - if ($nb_synchro) - $page->trigSuccess(($nb_synchro > 1)?($nb_synchro." villes ont été synchronisées"):"Une ville a été synchronisée"); - - $res = XDB::query("SELECT COUNT(*) FROM geoloc_city WHERE lat = 0 AND lon = 0"); - $page->assign("nb_missinglat", $res->fetchOneCell()); - } - - function handler_admin_dynamap(&$page, $action = false) { - $page->changeTpl('geoloc/admin_dynamap.tpl'); - - if ($action == 'cities_not_on_map') { - require_once('geoloc.inc.php'); - if (!fix_cities_not_on_map(20)) - $page->trigError("Impossible d'accéder au webservice"); - else - $refresh = true; - } - - if ($action == 'smallest_maps') { - require_once('geoloc.inc.php'); - set_smallest_levels(); - } - - if ($action == 'precise_coordinates') { - XDB::execute("UPDATE adresses AS a - INNER JOIN geoloc_city AS c ON(a.cityid = c.id) - SET a.glat = c.lat / 100000, a.glng = c.lon / 100000"); - } - - if ($action == 'newmaps') { - require_once('geoloc.inc.php'); - if (!get_new_maps(Env::v('url'))) - $page->trigError("Impossible d'accéder aux nouvelles cartes"); - } - - $countMissing = XDB::query("SELECT COUNT(*) FROM geoloc_city AS c LEFT JOIN geoloc_city_in_maps AS m ON(c.id = m.city_id) WHERE m.city_id IS NULL"); - $missing = $countMissing->fetchOneCell(); - - $countNoSmallest = XDB::query("SELECT SUM(IF(infos = 'smallest',1,0)) AS n FROM geoloc_city_in_maps GROUP BY city_id ORDER BY n"); - $noSmallest = $countNoSmallest->fetchOneCell() == 0; - - $countNoCoordinates = XDB::query("SELECT COUNT(*) FROM adresses WHERE cityid IS NOT NULL AND glat = 0 AND glng = 0"); - $noCoordinates = $countNoCoordinates->fetchOneCell(); - - if (isset($refresh) && $missing) { - $page->assign("pl_extra_header", ""); - } - $page->assign("nb_cities_not_on_map", $missing); - $page->assign("no_smallest", $noSmallest); - $page->assign("no_coordinates", $noCoordinates); - } - - function handler_admin_country(&$page, $action = 'list', $id = null) - { - $page->assign('xorg_title', 'Polytechnique.org - Administration - Pays'); - $page->assign('title', 'Gestion des pays'); - $table_editor = new PLTableEditor('admin/geoloc/country', 'geoloc_pays', 'a2', true); - $table_editor->describe('a2', 'alpha-2', true); - $table_editor->describe('a3', 'alpha-3', false); - $table_editor->describe('n3', 'ISO numeric', false); - $table_editor->describe('num', 'num', false); - $table_editor->describe('worldrgn', 'Continent', false); - $table_editor->describe('subd', 'Subdivisions territoriales', false); - $table_editor->describe('post', 'post', false); - $table_editor->describe('pays', 'Nom (fr)', true); - $table_editor->describe('country', 'Nom (en)', true); - $table_editor->describe('phoneprf', 'Préfixe téléphonique', true); - $table_editor->describe('phoneformat', 'Format du téléphone (ex: (+p) ### ## ## ##)', false); - $table_editor->describe('capital', 'Capitale', true); - $table_editor->describe('nat', 'Nationalité', true); - $table_editor->describe('display', 'Format des adresses', false); - - if ($action == 'update') { - if (Post::has('a2') && (Post::v('a2') == $id) && Post::has('phoneprf') && (Post::v('phoneprf') != '')) { - if (Post::has('phoneformat')) { - $new_format = Post::v('phoneformat'); - } else { - $new_format = ''; - } - $res = XDB::query("SELECT phoneformat - FROM geoloc_pays - WHERE phoneprf = {?} - LIMIT 1", - Post::v('phoneprf')); - $old_format = $res->fetchOneCell(); - if ($new_format != $old_format) { - require_once("profil.func.inc.php"); - XDB::execute("UPDATE geoloc_pays - SET phoneformat = {?} - WHERE phoneprf = {?}", - $new_format, Post::v('phoneprf')); - } - } - } - $table_editor->apply($page, $action, $id); - } - -} - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -?> diff --git a/modules/geoloc/.gitignore b/modules/geoloc/.gitignore deleted file mode 100644 index da97ff7..0000000 --- a/modules/geoloc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.swf diff --git a/modules/profile/mentor.inc.php b/modules/profile/mentor.inc.php index 2e9b8c2..5de721d 100644 --- a/modules/profile/mentor.inc.php +++ b/modules/profile/mentor.inc.php @@ -153,6 +153,10 @@ class ProfileMentor extends ProfilePage { $page->assign('secteurs_sel', XDB::iterator("SELECT id, name AS label FROM profile_job_sector_enum")); + + $page->assign('countryList', XDB::iterator("SELECT iso_3166_1_a2, countryFR + FROM geoloc_countries + ORDER BY countryFR")); } } diff --git a/plugins/function.display_address.php b/plugins/function.display_address.php index 47af0b0..7114a2b 100644 --- a/plugins/function.display_address.php +++ b/plugins/function.display_address.php @@ -39,7 +39,7 @@ function display_address_isIdentity($idt, $value, $test_reverse = true) function smarty_function_display_address($param, &$smarty) { require_once('geoloc.inc.php'); - $txtad = get_address_text($param['adr']); + $txtad = $param['adr']['text']; if (!$txtad && !$param['adr']['tels'] && !count($param['adr']['tels'])) { return ""; } diff --git a/plugins/function.geoloc_country.php b/plugins/function.geoloc_country.php deleted file mode 100644 index fd4c8d9..0000000 --- a/plugins/function.geoloc_country.php +++ /dev/null @@ -1,31 +0,0 @@ - diff --git a/plugins/function.geoloc_region.php b/plugins/function.geoloc_region.php deleted file mode 100644 index 1a66dae..0000000 --- a/plugins/function.geoloc_region.php +++ /dev/null @@ -1,31 +0,0 @@ - diff --git a/templates/admin/index.tpl b/templates/admin/index.tpl index ddf1c01..4fa3591 100644 --- a/templates/admin/index.tpl +++ b/templates/admin/index.tpl @@ -162,14 +162,6 @@ - Géoloc - - Synchro -   |   - Dynamap - - - Compte Skins diff --git a/templates/geoloc/admin.tpl b/templates/geoloc/admin.tpl deleted file mode 100644 index 9cbe2e1..0000000 --- a/templates/geoloc/admin.tpl +++ /dev/null @@ -1,36 +0,0 @@ -{**************************************************************************} -{* *} -{* Copyright (C) 2003-2009 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 *} -{* *} -{**************************************************************************} - -

Geoloc

- -

Synchroniser des villes avec geoloc.org

- -{if $nb_missinglat} -

[toutes les villes sans coordonnées ({$nb_missinglat})]

-{/if} - -
-

-La ville dont l'id est : -

-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/geoloc/admin_dynamap.tpl b/templates/geoloc/admin_dynamap.tpl deleted file mode 100644 index 490acd9..0000000 --- a/templates/geoloc/admin_dynamap.tpl +++ /dev/null @@ -1,64 +0,0 @@ -{**************************************************************************} -{* *} -{* Copyright (C) 2003-2009 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 *} -{* *} -{**************************************************************************} - -

- Administration de la dynamap -

- -

- Utiliser de nouvelles cartes -

-
-

- -
- -

-
- -

- Placement des villes sur les cartes -

-{if $nb_cities_not_on_map} -

- Il y a {$nb_cities_not_on_map} villes qui ne sont pas placées dans les cartes. - [Réparer] -

-{else} -

Toutes les villes de la base sont placées dans des cartes.

-{/if} -{if $no_smallest} -

- Il faut définir la plus petite carte - pour chaque ville (à ne faire qu'une fois quand on a placé toutes les villes). -

-{/if} -{if $no_coordinates} -

- Placement précis des adresses -

-

- {$no_coordinates} adresses n'ont pas été bien reconnues précisément. - [Mettre les coordonnées du centre de la ville] -

-{/if} -{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/geoloc/city.tpl b/templates/geoloc/city.tpl deleted file mode 100644 index d7fa392..0000000 --- a/templates/geoloc/city.tpl +++ /dev/null @@ -1,27 +0,0 @@ -{**************************************************************************} -{* *} -{* Copyright (C) 2003-2009 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 *} -{* *} - - - {assign var="beginning" value=true} - {assign var="nb_displayed" value=0} - {foreach from=$users item="user"}{if !$beginning}
{/if}{if $nb_displayed < 10}{$user.prenom} {$user.nom|strtolower|ucwords} - {$user.promo}{else}...{/if}{assign var="nb_displayed" value=$nb_displayed+1}{assign var="beginning" value=false}{/foreach} -
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/geoloc/country.tpl b/templates/geoloc/country.tpl deleted file mode 100644 index 46e2f18..0000000 --- a/templates/geoloc/country.tpl +++ /dev/null @@ -1,47 +0,0 @@ -{**************************************************************************} -{* *} -{* Copyright (C) 2003-2009 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 *} -{* *} -{**************************************************************************} - - - - {foreach from=$countries item="country"} - - - - - {if $country.nbPop > 0 or $country.id eq 0} - - - - {/if} - - {/foreach} - - - {foreach from=$cities item="city"} - - - - - {/foreach} - - -{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/geoloc/init.tpl b/templates/geoloc/init.tpl deleted file mode 100644 index 9fdda87..0000000 --- a/templates/geoloc/init.tpl +++ /dev/null @@ -1,59 +0,0 @@ -{**************************************************************************} -{* *} -{* Copyright (C) 2003-2009 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 *} -{* *} -{**************************************************************************} - - - - - - - - - - -{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/include/plview.geoloc.tpl b/templates/include/plview.geoloc.tpl deleted file mode 100644 index a0952fd..0000000 --- a/templates/include/plview.geoloc.tpl +++ /dev/null @@ -1,84 +0,0 @@ -{**************************************************************************} -{* *} -{* Copyright (C) 2003-2009 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 *} -{* *} -{**************************************************************************} - - - -{if !$request_geodesix} - -

- {if $smarty.request.only_current neq 'on'} - [Ne voir que les adresses principales] - {else} - [Voir toutes les adresses] - {/if} -

- -

- - - - - -

- {if $annu} -

- Lister les X présents sur cette carte -

- {/if} -

Carte fournie gracieusement par Geodesix.

-{else} -

Le moteur de carte n'a pas été installé sur cette version de plat/al. Veuillez contacter Geodesix.

-{/if} -

Pour toute question, problème ou suggestion tu peux envoyer un email à -{#globals.geoloc.email#}.

- -{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/profile/groupesx.tpl b/templates/profile/groupesx.tpl index b9c6b49..5261224 100644 --- a/templates/profile/groupesx.tpl +++ b/templates/profile/groupesx.tpl @@ -38,7 +38,6 @@