From: x2003bruneau Date: Sun, 1 Apr 2007 22:10:35 +0000 (+0000) Subject: Initial work on #448: unified user-set interface X-Git-Tag: xorg/0.9.14~138 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=8c4a0c30c699f190cb7906746e22f67014df3368;p=platal.git Initial work on #448: unified user-set interface git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1648 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/classes/platalpage.php b/classes/platalpage.php index b0a561b..e2011dd 100644 --- a/classes/platalpage.php +++ b/classes/platalpage.php @@ -136,7 +136,7 @@ class PlatalPage extends Smarty } $this->assign('validate', true); - error_reporting(0); + #error_reporting(0); $result = $this->fetch($skin); $ttime = sprintf('Temps total: %.02fs - Mémoire totale : %dKo
', microtime(true) - $TIME_BEGIN , memory_get_peak_usage(true) / 1024); diff --git a/classes/plset.php b/classes/plset.php new file mode 100644 index 0000000..d2267d0 --- /dev/null +++ b/classes/plset.php @@ -0,0 +1,226 @@ +from = $from; + $this->joins = $joins; + $this->where = $where; + $this->groupby = $groupby; + } + + public function addMod($name, $description, $default = false, array $params = array()) + { + $name = strtolower($name); + $this->mods[$name] = $description; + $this->modParams[$name] = $params; + if ($default) { + $this->default = $name; + } + } + + public function rmMod($name) + { + $name = strtolower($name); + unset($this->mods[$name]); + } + + private function &query($fields, $from, $joins, $where, $groupby, $order, $limit) + { + if (trim($order)) { + $order = "ORDER BY $order"; + } + if (trim($where)) { + $where = "WHERE $where"; + } + if (trim($groupby)) { + $groupby = "GROUP BY $groupby"; + } + $query = "SELECT SQL_CALC_FOUND_ROWS + $fields + FROM $from + $joins + $where + $groupby + $order + $limit"; +// echo $query; +// print_r($this); + $it = XDB::iterator($query); + $count = XDB::query('SELECT FOUND_ROWS()'); + $this->count = intval($count->fetchOneCell()); + return $it; + } + + public function &get($fields, $joins, $where, $groupby, $order, $limitcount = null, $limitfrom = null) + { + if (!is_null($limitcount)) { + if (!is_null($limitfrom)) { + $limitcount = "$limitfrom,$limitcount"; + } + $limitcount = "LIMIT $limitcount"; + } + $joins = $this->joins . ' ' . $joins; + $where = $where; + if (trim($this->where)) { + if (trim($where)) { + $where .= ' AND '; + } + $where .= $this->where; + } + if (!$groupby) { + $groupby = $this->groupby; + } + return $this->query($fields, $this->from, $joins, $where, $groupby, $order, $limitcount); + } + + public function count() + { + return $this->count; + } + + private function &buildView($view, $data) + { + $view = strtolower($view); + if (!$view || !class_exists($view . 'View') || !isset($this->mods[$view])) { + $view = $this->default ? $this->default : $this->mods[0]; + } + $this->mod = $view; + $class = $view . 'View'; + if (!class_exists($class)) { + $view = null; + } else { + $view = new $class($this, $data, $this->modParams[$this->mod]); + if (!$view instanceof PlView) { + $view = null; + } + } + return $view; + } + + public function apply($baseurl, PlatalPage &$page, $view = null, $data = null) + { + $view =& $this->buildView($view, $data); + if (is_null($view)) { + return false; + } + $page->changeTpl('core/plset.tpl'); + $page->assign('plset_base', $baseurl); + $page->assign('plset_mods', $this->mods); + $page->assign('plset_mod', $this->mod); + foreach ($this->modParams[$this->mod] as $param=>$value) { + $page->assign($this->mod . '_' . $param, $value); + } + $page->assign('plset_content', $view->apply($page)); + $page->assign('plset_count', $this->count); + return true; + } +} + +interface PlView +{ + public function __construct(PlSet &$set, $data, array $params); + public function apply(PlatalPage &$page); +} + +abstract class MultipageView implements PlView +{ + protected $set; + + public $pages = 1; + public $page = 1; + public $offset = 0; + + protected $order = array(); + protected $entriesPerPage = 20; + protected $params = array(); + + public function __construct(PlSet &$set, $data, array $params) + { + $this->set =& $set; + $this->page = Env::i('page', 1); + $this->offset = $this->entriesPerPage * ($this->page - 1); + $this->params = $params; + } + + public function joins() + { + return null; + } + + public function where() + { + return null; + } + + public function groupBy() + { + return null; + } + + public function order() + { + foreach ($this->order as &$item) { + if ($item{0} == '-') { + $item = substr($item, 1) . ' DESC'; + } + } + return implode(', ', $this->order); + } + + abstract public function templateName(); + + public function apply(PlatalPage &$page) + { + $page->assign_by_ref('plview', $this); + $page->assign_by_ref('set', + $this->set->get($this->fields(), + $this->joins(), + $this->where(), + $this->groupBy(), + $this->order(), + $this->entriesPerPage, + $this->offset)); + $count = $this->set->count(); + $this->pages = intval(ceil($count / $this->entriesPerPage)); + + return 'include/plview.multipage.tpl'; + } +} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +?> diff --git a/include/geoloc.inc.php b/include/geoloc.inc.php index f951640..107a562 100644 --- a/include/geoloc.inc.php +++ b/include/geoloc.inc.php @@ -44,8 +44,9 @@ function geoloc_country($current, $avail_only = false) function _geoloc_country_smarty($params) { - if(!isset($params['country'])) + if(!isset($params['country'])) { return; + } return geoloc_country($params['country'], @$params['available']); } @@ -81,33 +82,23 @@ function geoloc_region($country, $current, $avail_only = false) function _geoloc_region_smarty($params) { - if(!isset($params['country'])) - return; - if(!isset($params['region'])) + if(!isset($params['country']) || !isset($params['region'])) { return; + } return geoloc_region($params['country'], $params['region'], @$params['available']); } $GLOBALS['page']->register_function('geoloc_region', '_geoloc_region_smarty'); // }}} -function geoloc_is_utf8($text) -{ - return (iconv('utf-8', 'utf-8', $text) == $text); -} - -function geoloc_utf8_decode($text) -{ - return geoloc_is_utf8($text) ? utf8_decode($text) : $text; -} - // {{{ 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) { +function get_address_infos($txt) +{ global $globals; - $url = $globals->geoloc->webservice_url."address.php?precise=1&txt=".urlencode(utf8_encode($txt)); + $url = $globals->geoloc->webservice_url."address.php?precise=1&txt=" . urlencode($txt); if (!($f = @fopen($url, 'r'))) return false; $keys = explode('|',fgets($f)); $vals = explode('|',fgets($f)); @@ -118,7 +109,7 @@ function get_address_infos($txt) { $infos[$key] = $vals[$i]; } else { $val = strtr($vals[$i], array(chr(197).chr(147) => "œ")); - $infos[$key] = geoloc_utf8_decode($val); + $infos[$key] = $val; } } } @@ -138,7 +129,7 @@ function get_cities_maps($array) { global $globals; implode("\n",$array); - $url = $globals->geoloc->webservice_url."findMaps.php?datatext=".urlencode(utf8_encode(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)) @@ -180,7 +171,8 @@ function get_new_maps($url) /** make the text of an address that can be read by a mailman * @param $adr an array with all the usual fields */ -function get_address_text($adr) { +function get_address_text($adr) +{ $t = ""; if (isset($adr['adr1']) && $adr['adr1']) $t.= $adr['adr1']; if (isset($adr['adr2']) && $adr['adr2']) $t.= "\n".$adr['adr2']; @@ -189,30 +181,29 @@ function get_address_text($adr) { if (isset($adr['display']) && $adr['display']) { $keys = explode(' ', $adr['display']); foreach ($keys as $key) { - if (isset($adr[$key])) + if (isset($adr[$key])) { $l .= " ".$adr[$key]; - else + } else { $l .= " ".$key; + } } - if ($l) $l = substr($l, 1); - } - else - { - if ($adr['country'] == 'US' || $adr['country'] == 'CA' || $adr['country'] == 'GB') { - if ($adr['city']) $l .= $adr['city'].",\n"; - if ($adr['region']) $l .= $adr['region']." "; - if ($adr['postcode']) $l .= $adr['postcode']; - } else { - if (isset($adr['postcode']) && $adr['postcode']) $l .= $adr['postcode']." "; - if (isset($adr['city']) && $adr['city']) $l .= $adr['city']; - } + if ($l) substr($l, 1); + } elseif ($adr['country'] == 'US' || $adr['country'] == 'CA' || $adr['country'] == 'GB') { + if ($adr['city']) $l .= $adr['city'].",\n"; + if ($adr['region']) $l .= $adr['region']." "; + if ($adr['postcode']) $l .= $adr['postcode']; + } else { + if (isset($adr['postcode']) && $adr['postcode']) $l .= $adr['postcode']." "; + if (isset($adr['city']) && $adr['city']) $l .= $adr['city']; } if ($l) $t .= "\n".trim($l); if ($adr['country'] != '00' && (!$adr['countrytxt'] || $adr['countrytxt'] == strtoupper($adr['countrytxt']))) { $res = XDB::query("SELECT pays FROM geoloc_pays WHERE a2 = {?}", $adr['country']); $adr['countrytxt'] = $res->fetchOneCell(); } - if (isset($adr['countrytxt']) && $adr['countrytxt']) $t .= "\n".$adr['countrytxt']; + if (isset($adr['countrytxt']) && $adr['countrytxt']) { + $t .= "\n".$adr['countrytxt']; + } return trim($t); } // }}} @@ -222,15 +213,22 @@ function get_address_text($adr) { * @param $a the raw text of an address * @param $b the raw text of a complete valid address */ -function compare_addresses_text($a, $b) { +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($l, $lb[$i]) > 3) return false; + if (count($lb) > count($la) + 1) { + return false; + } + foreach ($la as $i=>$l) { + if (levenshtein($l, $lb[$i]) > 3) { + return false; + } + } return true; } @@ -251,7 +249,8 @@ function empty_address() { } // create a simple address from a text without geoloc -function cut_address($txt) { +function cut_address($txt) +{ $txt = str_replace("\r\n", "\n", $txt); ereg("^([^\n]*)(\n([^\n]*)(\n(.*))?)?$", trim($txt), $a); return array("adr1" => trim($a[1]), "adr2" => trim($a[3]), "adr3" => trim(str_replace("\n", " ", $a[5]))); @@ -262,26 +261,31 @@ function cut_address($txt) { * 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); +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; + 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; @@ -295,154 +299,204 @@ function localize_addresses($uid) { /** synchronise the local geoloc_city base to geoloc.org * @param $id the id of the city to synchronize */ - function synchro_city($id) { +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; + if (!($f = @fopen($url, 'r'))) { + return false; + } $s = fgets($f); - if ($s) + 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":"")); + $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) - { + if ($maps) { $values = ""; - foreach ($maps as $cityid => $maps_c) - foreach ($maps_c as $map_id) + foreach ($maps as $cityid => $maps_c) { + foreach ($maps_c as $map_id) { $values .= ",($cityid, $map_id, '')"; - XDB::execute("REPLACE INTO geoloc_city_in_maps VALUES ".substr($values, 1)); - } - else + } + } + 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 - "); +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); + 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; } // }}} -function geoloc_to_x($lon, $lat) { return deg2rad(1) * $lon *100; } +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 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_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 size_of_territory($nb) +{ + return size_of_city($nb); +} -function geoloc_getData_subcities($mapid, $SFields, &$cities, $direct=true) { - 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); - +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(); - if ($where) $where = " AND ".$where; - - $cityres = 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) - { + 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', + "{$fields->get_select_statement()} + LEFT JOIN geoloc_city AS gc ON(gcim.city_id = gc.id)", + $where . ($direct ? "gcim.infos = 'smallest'" : '1'), + 'gc.id, gc.alias', + 'pop DESC'); + while ($c = $cityres->next()) { + if ($c['pop'] > 0) { $city = $c; - // $city['name'] = geoloc_utf8_decode($city['name']); - if (!geoloc_is_utf8($city['name'])) { - $city['name'] = utf8_encode($city['name']); - } $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) { +function geoloc_getData_subcountries($mapid, $sin, $minentities) +{ $countries = array(); $cities = array(); - if ($mapid === false) + if ($mapid === false) { $wheremapid = "WHERE gm.parent IS NULL"; - else + } 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','')); + gm.width, gm.height, gm.scale, 1 AS rat + FROM geoloc_maps AS gm + ". $wheremapid, Env::v('mapid','')); global $globals; - while ($c = $submapres->next()) - { + 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); + if ($mapid === false) { + return array($countries, $cities); + } - geoloc_getData_subcities(Env::i('mapid'), $SFields, $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')); - + 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 = 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); + $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', + $fields->get_select_statement(), + $fields->get_where_statement(), + 'map.map_id', + 'NULL'); $maxpop = 0; $nbentities = $nbcities + $countryres->total(); - while ($c = $countryres->next()) - { + while ($c = $countryres->next()) { $c['latPop'] /= $c['nbPop']; $c['lonPop'] /= $c['nbPop']; $c['rad'] = size_of_territory($c['nbPop']); @@ -452,22 +506,22 @@ function geoloc_getData_subcountries($mapid, $SFields, $minentities) { $countries[$c['id']] = array_merge($countries[$c['id']], $c); $nbcities += $c['nbCities']; - } + } - if ($nocity && $nbcities < $minentities) - { - foreach($countries as $i => $c) - { + 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); - } + 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; + 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); diff --git a/include/marketing.inc.php b/include/marketing.inc.php index 600f4f6..585603e 100644 --- a/include/marketing.inc.php +++ b/include/marketing.inc.php @@ -91,10 +91,9 @@ class Marketing if (!class_exists($class, false)) { $class= 'DefaultMarketing'; } - if (!is_subclass_of($class, 'MarketingEngine')) { + $engine = new $class($data, $from); + if (!$engine instanceof MarketingEngine) { $engine = null; - } else { - $engine = new $class($data, $from); } return $engine; } diff --git a/include/userset.inc.php b/include/userset.inc.php new file mode 100644 index 0000000..7201181 --- /dev/null +++ b/include/userset.inc.php @@ -0,0 +1,313 @@ +search->result_where_statement = ' + LEFT JOIN applis_ins AS ai0 ON (u.user_id = ai0.uid AND ai0.ordre = 0) + LEFT JOIN applis_def AS ad0 ON (ad0.id = ai0.aid) + LEFT JOIN applis_ins AS ai1 ON (u.user_id = ai1.uid AND ai1.ordre = 1) + LEFT JOIN applis_def AS ad1 ON (ad1.id = ai1.aid) + LEFT JOIN entreprises AS e ON (e.entrid = 0 AND e.uid = u.user_id) + LEFT JOIN emploi_secteur AS es ON (e.secteur = es.id) + LEFT JOIN fonctions_def AS ef ON (e.fonction = ef.id) + LEFT JOIN geoloc_pays AS n ON (u.nationalite = n.a2) + LEFT JOIN adresses AS adr ON (u.user_id = adr.uid AND FIND_IN_SET(\'active\',adr.statut)) + LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2) + LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region) + LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = \'active\')'; + +class UserSet extends PlSet +{ + public function __construct($joins = '', $where = '') + { + global $globals; + parent::__construct('auth_user_md5 AS u', + (!empty($GLOBALS['IS_XNET_SITE']) ? + 'INNER JOIN groupex.membres AS gxm ON (u.user_id = gxm.uid + AND gxm.asso_id = ' . $globals->asso('id') . ') ' : '') + . 'LEFT JOIN auth_user_quick AS q USING (user_id) + LEFT JOIN aliases AS a ON (a.id = u.user_id AND type = \'a_vie\') + ' . $joins, + $where, + 'u.user_id'); + } +} + +class SearchSet extends UserSet +{ + private $order = null; + private $quick = false; + + public function __construct($quick = false, $no_search = false) + { + require_once dirname(__FILE__).'/../modules/search/search.inc.php'; + + if ($no_search) { + return; + } + + $this->quick = $quick; + if ($quick) { + $this->getQuick(); + } else { + $this->getAdvanced(); + } + } + + private function getQuick() + { + require_once dirname(__FILE__).'/../modules/search/search.inc.php'; + global $globals; + if (!S::logged()) { + Env::kill('with_soundex'); + } + $qSearch = new QuickSearch('quick'); + $fields = new SFieldGroup(true, array($qSearch)); + if ($qSearch->isEmpty()) { + new ThrowError('Recherche trop générale.'); + } + parent::__construct($fields->get_select_statement() . ' ' . $globals->search->result_where_statement, + $fields->get_where_statement() . + (S::logged() && Env::has('nonins') ? ' AND u.perms="pending" AND u.deces=0' : '')); + + $this->order = implode(',',array_filter(array($fields->get_order_statement(), + 'u.promo DESC, NomSortKey, prenom'))); + } + + private function getAdvanced() + { + global $globals; + $fields = new SFieldGroup(true, advancedSearchFromInput()); + if ($fields->too_large()) { + new ThrowError('Recherche trop générale.'); + } + parent::__construct($fields->get_select_statement() . ' ' . $globals->search->result_where_statement, + $fields->get_where_statement()); + $this->order = implode(',',array_filter(array($fields->get_order_statement(), + 'promo DESC, NomSortKey, prenom'))); + } +} + +class MinificheView extends MultipageView +{ + public function __construct(PlSet &$set, $data, array $params) + { + require_once 'applis.func.inc.php'; + global $globals; + $this->entriesPerPage = $globals->search->per_page; + $this->order = explode(',', Env::v('order', 'nom,prenom,promo')); + parent::__construct($set, $data, $params); + } + + public function fields() + { + return "u.user_id AS id, + u.*, a.alias AS forlife, + u.perms != 'pending' AS inscrit, + u.perms != 'pending' AS wasinscrit, + u.deces != 0 AS dcd, u.deces, u.matricule_ax, + FIND_IN_SET('femme', u.flags) AS sexe, + e.entreprise, es.label AS secteur, ef.fonction_fr AS fonction, + IF(n.nat='',n.pays,n.nat) AS nat, n.a2 AS iso3166, + ad0.text AS app0text, ad0.url AS app0url, ai0.type AS app0type, + ad1.text AS app1text, ad1.url AS app1url, ai1.type AS app1type, + adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region, + IF(u.nom_usage<>'',u.nom_usage,u.nom) AS sortkey, + COUNT(em.email) > 0 AS actif" . (S::logged() ? ", c.contact AS contact" : ''); + } + + public function joins() + { + return ($this->set instanceof SearchSet ? "" : + "LEFT JOIN entreprises AS e ON (e.entrid = 0 AND e.uid = u.user_id) + LEFT JOIN emploi_secteur AS es ON (e.secteur = es.id) + LEFT JOIN fonctions_def AS ef ON (e.fonction = ef.id) + LEFT JOIN geoloc_pays AS n ON (u.nationalite = n.a2) + LEFT JOIN applis_ins AS ai0 ON (u.user_id = ai0.uid AND ai0.ordre = 0) + LEFT JOIN applis_def AS ad0 ON (ad0.id = ai0.aid) + LEFT JOIN applis_ins AS ai1 ON (u.user_id = ai1.uid AND ai1.ordre = 1) + LEFT JOIN applis_def AS ad1 ON (ad1.id = ai1.aid) + LEFT JOIN adresses AS adr ON (u.user_id = adr.uid + AND FIND_IN_SET('active', adr.statut)) + LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2) + LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region) + LEFT JOIN emails AS em ON (em.uid = u.user_id AND em.flags = 'active') + ") . (S::logged() ? + "LEFT JOIN contacts AS c On (c.contact = u.user_id AND c.uid = " . S::v('uid') . ")" + : ""); + } + + public function templateName() + { + return 'include/plview.minifiche.tpl'; + } +} + +class TrombiView extends MultipageView +{ + public function __construct(PlSet &$set, $data, array $params) + { + $this->entriesPerPage = 24; + $this->order = explode(',', Env::v('order', 'nom,prenom,promo')); + parent::__construct($set, $data, $params); + } + + public function fields() + { + return "u.user_id, IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom, u.prenom, u.promo, a.alias AS forlife "; + } + + public function joins() + { + return "INNER JOIN photo AS p ON (p.uid = u.user_id) "; + } + + public function templateName() + { + return 'include/plview.trombi.tpl'; + } + + public function apply(PlatalPage &$page) + { + if (!empty($GLOBALS['IS_XNET_SITE'])) { + global $globals; + $page->assign('mainsiteurl', 'https://' . $globals->core->secure_domain . '/'); + } + return parent::apply($page); + } +} + +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'); + } + + private function make_qs($urlencode = true) + { + $qs = ""; + foreach ($_GET as $v=>$a) { + if ($v != 'initfile' && $v != 'n' && $v != 'mapid') { + if (!$urlencode) { + $qs .= $v . '=' . $a . '&'; + } else { + $qs .= urlencode($v) . '=' . urlencode($a) . '&'; + } + } + } + return $qs; + } + + public function apply(PlatalPage &$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); + } + $page->assign('querystring', $this->make_qs()); + break; + + case 'city': + $page->changeTpl('geoloc/city.tpl', NO_SKIN); + header('Content-Type: text/xml'); + header('Pragma:'); + $it =& $this->set->get('u.user_id AS id, u.prenom, u.nom, u.promo, al.alias', + "INNER JOIN adresses AS adrf ON (adrf.uid = u.user_id) + LEFT JOIN aliases AS al ON (u.user_id = al.id + AND FIND_IN_SET(al.flags, 'bestalias')) + INNER JOIN adresses AS av ON (" . getadr_join('av') . ")", + 'adrf.cityid = ' . 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:'); + } + $querystring = $this->make_qs(); + $page->assign('searchvars', $querystring); + $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); + } + if (!empty($GLOBALS['IS_XNET_SITE'])) { + $page->assign('no_annu', true); + } + $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); + $url = '?' . $this->make_qs(false); + $page->assign('search_nourlencode', $url); + $page->assign('search', urlencode($url)); + return 'include/plview.geoloc.tpl'; + } + } +} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +?> diff --git a/modules/carnet.php b/modules/carnet.php index c968514..c970213 100644 --- a/modules/carnet.php +++ b/modules/carnet.php @@ -183,10 +183,8 @@ class CarnetModule extends PLModule return Array($total, $list); } - function handler_contacts(&$page, $action = null) + function handler_contacts(&$page, $action = null, $subaction = null) { - $page->changeTpl('carnet/mescontacts.tpl'); - require_once("applis.func.inc.php"); $page->assign('xorg_title','Polytechnique.org - Mes contacts'); $this->_add_rss_link($page); @@ -197,8 +195,8 @@ class CarnetModule extends PLModule case 'retirer': if (is_numeric($user)) { if (XDB::execute('DELETE FROM contacts - WHERE uid = {?} AND contact = {?}', - $uid, $user)) + WHERE uid = {?} AND contact = {?}', + $uid, $user)) { $page->trig("Contact retiré !"); } @@ -230,66 +228,13 @@ class CarnetModule extends PLModule } } - if ($action == 'trombi') { - $trombi = new Trombi(array($this, '_get_list')); - $trombi->setNbRows(4); - $page->assign_by_ref('trombi',$trombi); - - $order = Get::v('order'); - if ($order != 'promo' && $order != 'last') - $order = 'nom'; - $page->assign('order', $order); - $page->assign('inv', Get::v('inv')); - - } else { - - $order = Get::v('order'); - $orders = Array( - 'nom' => 'sortkey DESC, a.prenom, a.promo', - 'promo' => 'promo DESC, sortkey, a.prenom', - 'last' => 'a.date DESC, sortkey, a.prenom, promo'); - if ($order != 'promo' && $order != 'last') - $order = 'nom'; - $page->assign('order', $order); - $page->assign('inv', Get::v('inv')); - $order = $orders[$order]; - if (Get::v('inv') == '') - $order = str_replace(" DESC,", ",", $order); - - $sql = "SELECT contact AS id, - a.*, l.alias AS forlife, - 1 AS inscrit, - a.perms != 'pending' AS wasinscrit, - a.deces != 0 AS dcd, a.deces, a.matricule_ax, - FIND_IN_SET('femme', a.flags) AS sexe, - e.entreprise, es.label AS secteur, ef.fonction_fr AS fonction, - IF(n.nat='',n.pays,n.nat) AS nat, n.a2 AS iso3166, - ad0.text AS app0text, ad0.url AS app0url, ai0.type AS app0type, - ad1.text AS app1text, ad1.url AS app1url, ai1.type AS app1type, - adr.city, gp.a2, gp.pays AS countrytxt, gr.name AS region, - IF(a.nom_usage<>'',a.nom_usage,a.nom) AS sortkey, - COUNT(em.email) > 0 AS actif - FROM contacts AS c - INNER JOIN auth_user_md5 AS a ON (a.user_id = c.contact) - INNER JOIN aliases AS l ON (a.user_id = l.id AND l.type='a_vie') - LEFT JOIN entreprises AS e ON (e.entrid = 0 AND e.uid = a.user_id) - LEFT JOIN emploi_secteur AS es ON (e.secteur = es.id) - LEFT JOIN fonctions_def AS ef ON (e.fonction = ef.id) - LEFT JOIN geoloc_pays AS n ON (a.nationalite = n.a2) - LEFT JOIN applis_ins AS ai0 ON (a.user_id = ai0.uid AND ai0.ordre = 0) - LEFT JOIN applis_def AS ad0 ON (ad0.id = ai0.aid) - LEFT JOIN applis_ins AS ai1 ON (a.user_id = ai1.uid AND ai1.ordre = 1) - LEFT JOIN applis_def AS ad1 ON (ad1.id = ai1.aid) - LEFT JOIN adresses AS adr ON (a.user_id = adr.uid - AND FIND_IN_SET('active', adr.statut)) - LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2) - LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region) - LEFT JOIN emails AS em ON (em.uid = a.user_id AND em.flags = 'active') - WHERE c.uid = $uid - GROUP BY a.user_id - ORDER BY ".$order; - - $page->assign('citer', XDB::iterator($sql)); + $view = new UserSet("INNER JOIN contacts AS c2 ON (u.user_id = c2.contact)", " c2.uid = $uid "); + $view->addMod('minifiche', 'Mini-Fiches', true); + $view->addMod('trombi', 'Trombinoscope', false, array('with_admin' => false, 'with_promo' => true)); + $view->addMod('geoloc', 'Planisphère'); + $view->apply('carnet/contacts', $page, $action, $subaction); + if ($action != 'geoloc' || !$subaction) { + $page->changeTpl('carnet/mescontacts.tpl'); } } diff --git a/modules/geoloc.php b/modules/geoloc.php index 500e20d..e4b549e 100644 --- a/modules/geoloc.php +++ b/modules/geoloc.php @@ -24,12 +24,13 @@ class GeolocModule extends PLModule function handlers() { return array( +// 'icon.swf' => $this->make_hook('icon', AUTH_COOKIE), 'geoloc' => $this->make_hook('default', AUTH_COOKIE), - 'geoloc/icon.swf' => $this->make_hook('icon', AUTH_COOKIE), - 'geoloc/dynamap.swf' => $this->make_hook('dynamap', AUTH_COOKIE), - 'geoloc/init' => $this->make_hook('init', AUTH_COOKIE), - 'geoloc/city' => $this->make_hook('city', AUTH_COOKIE), - 'geoloc/country' => $this->make_hook('country', AUTH_COOKIE), +// 'geoloc/icon.swf' => $this->make_hook('icon', AUTH_COOKIE), +// 'geoloc/dynamap.swf' => $this->make_hook('dynamap', AUTH_COOKIE), +// 'geoloc/init' => $this->make_hook('init', AUTH_COOKIE), +// 'geoloc/city' => $this->make_hook('city', AUTH_COOKIE), +// 'geoloc/country' => $this->make_hook('country', AUTH_COOKIE), '%grp/geoloc' => $this->make_hook('default',AUTH_COOKIE), '%grp/geoloc/icon.swf' => $this->make_hook('icon', AUTH_COOKIE), '%grp/geoloc/dynamap.swf'=> $this->make_hook('dynamap',AUTH_COOKIE), @@ -60,10 +61,15 @@ class GeolocModule extends PLModule is_file(dirname(__FILE__).'/geoloc/icon.swf'); } - function handler_default(&$page) + function handler_default(&$page, $action = null, $subaction = null) { global $globals; + $set = new UserSet(); + $set->addMod('geoloc', 'Geolocalisation', true); + $set->apply('geoloc', $page, $action, $subaction); + return; + if (!$this->use_map()) $page->assign('request_geodesix', 1); diff --git a/modules/search.php b/modules/search.php index 29d4c0b..dfae635 100644 --- a/modules/search.php +++ b/modules/search.php @@ -165,29 +165,24 @@ class SearchModule extends PLModule return Array($liste, $nb_tot); } - function handler_quick(&$page) + function handler_quick(&$page, $action = null, $subaction = null) { global $globals; - require_once dirname(__FILE__).'/search/search.inc.php'; - - $page->changeTpl('search/index.tpl'); - - $page->assign('xorg_title','Polytechnique.org - Annuaire'); - require_once("applis.func.inc.php"); - require_once("geoloc.inc.php"); - - $page->assign('baseurl', $globals->baseurl); - - if (Env::has('quick')) { + if (Env::has('quick') || $action == 'geoloc') { $page->assign('formulaire', 0); - $search = new XOrgSearch(array($this, 'get_quick')); - $search->setNbLines($globals->search->per_page); - $search->addOrder('score', 'score', false, 'pertinence', AUTH_PUBLIC, true); - - $nb_tot = $search->show(); + require_once 'userset.inc.php'; + $view = new SearchSet(true, $action == 'geoloc' && substr($subaction, -3) == 'swf'); + $view->addMod('minifiche', 'Minifiches', true); + $view->addMod('trombi', 'Trombinoscope'); + $view->addMod('geoloc', 'Planishpère'); + $view->apply('search', $page, $action, $subaction); + $nb_tot = $view->count(); + if ($subaction) { + return; + } if (!S::logged() && $nb_tot > $globals->search->public_max) { new ThrowError('Votre recherche a généré trop de résultats pour un affichage public.'); } elseif ($nb_tot > $globals->search->private_max) { @@ -206,44 +201,38 @@ class SearchModule extends PLModule $page->addJsLink('ajax.js'); } - $page->register_modifier('display_lines', 'display_lines'); + $page->changeTpl('search/index.tpl'); + $page->assign('xorg_title','Polytechnique.org - Annuaire'); + $page->assign('baseurl', $globals->baseurl); } function handler_advanced(&$page, $mode = null) { global $globals; - - require_once dirname(__FILE__).'/search/search.inc.php'; - require_once 'applis.func.inc.php'; - require_once 'geoloc.inc.php'; - - - $page->changeTpl('search/index.tpl', $mode == 'mini' ? SIMPLE : SKINNED); - - $page->assign('advanced',1); - $page->assign('public_directory',0); - if (!Env::has('rechercher')) { $this->form_prepare(); } else { - $search = new XOrgSearch(array($this, 'get_advanced')); - $search->setNbLines($globals->search->per_page); - - $page->assign('url_search_form', $search->make_url(Array('rechercher'=>0))); - if (!Env::i('with_soundex')) { - $page->assign('with_soundex', $search->make_url(Array()) . "&with_soundex=1"); + require_once 'userset.inc.php'; + $view = new SearchSet(false, $action == 'geoloc' && substr($subaction, -3) == 'swf'); + $view->addMod('minifiche', 'Minifiches', true); + $view->addMod('trombi', 'Trombinoscope'); + $view->addMod('geoloc', 'Planishpère'); + $view->apply('search', $page, $action, $subaction); + + if ($subaction) { + return; } - $nb_tot = $search->show(); - + $nb_tot = $view->count(); if ($nb_tot > $globals->search->private_max) { $this->form_prepare(); new ThrowError('Recherche trop générale'); } - } + $page->changeTpl('search/index.tpl', $mode == 'mini' ? SIMPLE : SKINNED); $page->addJsLink('ajax.js'); - $page->register_modifier('display_lines', 'display_lines'); + $page->assign('advanced',1); + $page->assign('public_directory',0); } function handler_region(&$page, $country = null) diff --git a/templates/carnet/mescontacts.tpl b/templates/carnet/mescontacts.tpl index b6ae910..870fe42 100644 --- a/templates/carnet/mescontacts.tpl +++ b/templates/carnet/mescontacts.tpl @@ -39,7 +39,7 @@ il te suffit de cliquer sur l'icône {icon name=add} en face de son nom dans les résultats !

-{if $trombi || $citer->total()} +{if $plset_count}

Pour récupérer ta liste de contacts dans un PDF imprimable :
(attention, les photos font beaucoup grossir les fichiers !) @@ -72,43 +72,8 @@ Pour récupérer ta liste de contacts dans un PDF imprimable :
-{if $trombi} +{include file="core/plset.tpl"} -

Mon trombino de contacts

- -

-Pour afficher la liste détaillée de tes contacts: [vue classique] -

- -{include file=carnet/tricontacts.tpl order=$order} - -{$trombi->show()|smarty:nodefaults} - -{else} - -

- Vue classique des contacts -

- -

-[Afficher le trombi de tes contacts] -

- -{include file=carnet/tricontacts.tpl order=$order} - -
- -
-{iterate from=$citer item=contact} -{include file=include/minifiche.tpl c=$contact show_action="retirer"} -{/iterate} -
- -{/if} - -{else} -

Actuellement ta liste de contacts est vide...

{/if} - {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/core/plset.tpl b/templates/core/plset.tpl new file mode 100644 index 0000000..ef12a7a --- /dev/null +++ b/templates/core/plset.tpl @@ -0,0 +1,48 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2007 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 !$plset_count} + Aucune entrée + {elseif $plset_count eq 1} + 1 entrée + {else} + {$plset_count} entrées + {/if} +

+

+ {$plset_mods[$plset_mod]} + {if $plset_mods|@count > 1}[ + {foreach from=$plset_mods key=mod item=desc name=mods} + {if $mod neq $plset_mod} + {$desc} {if !$smarty.foreach.mods.last}| {/if} + {/if} + {/foreach} + ] + {/if} +

+
+ +{include file=$plset_content} + +{* 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 new file mode 100644 index 0000000..141e4d1 --- /dev/null +++ b/templates/include/plview.geoloc.tpl @@ -0,0 +1,102 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2007 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] +

+ {/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 mail à geoloc@staff.polytechnique.org

+ +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/include/plview.minifiche.tpl b/templates/include/plview.minifiche.tpl new file mode 100644 index 0000000..f366b26 --- /dev/null +++ b/templates/include/plview.minifiche.tpl @@ -0,0 +1,33 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2007 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 *} +{* *} +{**************************************************************************} + +
+{iterate from=$set item=res} + {if $res.contact} + {include file="include/minifiche.tpl" c=$res show_action="retirer"} + {else} + {include file="include/minifiche.tpl" c=$res show_action="ajouter"} + {/if} +{/iterate} +
+ +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/include/plview.multipage.tpl b/templates/include/plview.multipage.tpl new file mode 100644 index 0000000..f273327 --- /dev/null +++ b/templates/include/plview.multipage.tpl @@ -0,0 +1,53 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2007 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 *} +{* *} +{**************************************************************************} + +{capture name=pages} +{if $plview->pages > 1} +
+ {if $plview->page neq 1} + << + < + {/if} + {section name=page loop=$plview->pages+1 start=1} + {if $smarty.section.page.index eq $plview->page} + {$plview->page} + {else} + {$smarty.section.page.index} + {/if} + {/section} + {if $plview->page neq $plview->pages} + > + >> + {/if} +
+{/if} +{/capture} + +{$smarty.capture.pages|smarty:nodefaults} + +
+ {include file=$plview->templateName()} +
+ +{$smarty.capture.pages|smarty:nodefaults} + +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/include/plview.trombi.tpl b/templates/include/plview.trombi.tpl new file mode 100644 index 0000000..89a5d9b --- /dev/null +++ b/templates/include/plview.trombi.tpl @@ -0,0 +1,53 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2007 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 *} +{* *} +{**************************************************************************} + + + {iterate from=$set item=p} + {cycle values="1,2,3" assign="loop"} + {if $loop eq "1"} + + {/if} + + {if $loop eq "3"} + + {/if} + {/iterate} + {if $loop neq "3"} + {if $lopp eq "1"} + + {/if} + + {/if} +
+ +  [ PHOTO ] + + {if $trombi_with_admin && $smarty.session.perms->hasFlag('admin')} + {icon name=wrench title="[admin]"} + {/if} +
+ + {$p.prenom} {$p.nom}{if $trombi_with_promo} ({$p.promo}){/if} + +
+ +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/search/index.tpl b/templates/search/index.tpl index 21097f6..2a25ee6 100644 --- a/templates/search/index.tpl +++ b/templates/search/index.tpl @@ -30,45 +30,7 @@ {/if} {/if} - {if $search_results_nb == 0 or ($advanced and !$simple)} -

- {if $search_results_nb==0}Aucune{else}{$search_results_nb}{/if} réponse{if $search_results_nb>1}s{/if} - {if $search_results_nb and $advanced and !$simple} - -  (Voir sur une carte) - - {/if} -

- {/if} - - {if $search_results_nb > 1} -
- Trier par : - {foreach from=$search_order_link item=tri} - [ - {if $tri.asc or $tri.desc}{/if} - {$tri.text} - {if $tri.desc}tri ascendant{/if} - {if $tri.asc}tri descendant{/if} - {if $tri.asc or $tri.desc}{/if} - ] - {/foreach} -
- {/if} - - {if $search_results_nb} -
- {capture name=list} - {iterate item=res from=$search_results} - {if $res.contact || $res.watch} - {include file=include/minifiche.tpl c=$res show_action="retirer"} - {else} - {include file=include/minifiche.tpl c=$res show_action="ajouter"} - {/if} - {/iterate} - {/capture} - {$smarty.capture.list|smarty:nodefaults} -
+ {include file='core/plset.tpl'} {if $search_pages_nb > 1}

@@ -81,7 +43,6 @@ {/foreach}

{/if} - {/if} {if $smarty.session.auth ge AUTH_COOKIE}