X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=plugins%2Ffunction.select_nat.php;h=0d39a7b44874b1382dd957265b82dbf2adf2ea94;hb=4f247453ac4a734953df893117b72168c60dd22e;hp=ebfa2f3b2c7c0ce0250046da8fdf3b5a927fc090;hpb=59bec5bc5512a4f962ebac7b0346f59cdf56f901;p=platal.git
diff --git a/plugins/function.select_nat.php b/plugins/function.select_nat.php
index ebfa2f3..0d39a7b 100644
--- a/plugins/function.select_nat.php
+++ b/plugins/function.select_nat.php
@@ -20,27 +20,30 @@
***************************************************************************/
-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";
+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);
$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);
}