X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2Ffunction.select_nat.php;h=9a73f39268465f6cdc578156c364004ef3500dbc;hb=d4d395bbdf6fdb819eaf5af9b8b64cbc82d7e2e8;hp=917d9b089880b4b3ba187b6976e1bff1cd06d230;hpb=9e1816c7666767755abbc24f6a0df290efff81b6;p=platal.git
diff --git a/plugins/function.select_nat.php b/plugins/function.select_nat.php
index 917d9b0..9a73f39 100644
--- a/plugins/function.select_nat.php
+++ b/plugins/function.select_nat.php
@@ -20,27 +20,32 @@
***************************************************************************/
-function select_nat($valeur,$pad=false) {
- $sql = "SELECT a2 AS id,IF(nat='',pays,nat) AS text FROM geoloc_pays WHERE nat IS NOT NULL ORDER BY text";
- $res = XDB::iterRow($sql);
+function select_nat($valeur, $pad=false) {
+ $res = XDB::iterRow("SELECT iso_3166_1_a2 AS id, nationalityFR AS text
+ FROM geoloc_countries
+ WHERE nationalityFR IS NOT NULL
+ ORDER BY nationalityFR");
$sel = ' selected="selected"';
// on ajoute une entree vide si $pad est vrai
$html = "";
if ($pad) {
- $html.= '\n";
+ $html .= sprintf("\n", ($valeur ? $sel : ""));
}
- while (list($my_id,$my_text) = $res->next()) {
- $html .= sprintf("\n",$my_id,($valeur==$my_id?$sel:""),$my_text);
+ while (list($my_id, $my_text) = $res->next()) {
+ $html .= sprintf("\n", $my_id, ($valeur==$my_id ? $sel : ""), $my_text);
}
+
return $html;
}
function smarty_function_select_nat($params, &$smarty) {
- if(empty($params['pad']) || !($params['pad']))
- $pad = false;
- else
- $pad = true;
+ if (empty($params['pad']) || !($params['pad'])) {
+ $pad = false;
+ } else {
+ $pad = true;
+ }
+
return select_nat($params['valeur'], $pad);
}