X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=plugins%2Ffunction.select_nat.php;h=3c9b4d02f97b4393d4464d6e06c529d946dbcf24;hb=9acf22511d818b70dcd4d69bef360916b1050272;hp=ebfa2f3b2c7c0ce0250046da8fdf3b5a927fc090;hpb=8230e9f8eff954fb1103c8bdcf0d22557d419ae7;p=platal.git
diff --git a/plugins/function.select_nat.php b/plugins/function.select_nat.php
index ebfa2f3..3c9b4d0 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);
}