X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=plugins%2Ffunction.select_nat.php;h=9e7edd5a75ccecd519b0cddeffcb241980b268d7;hb=f875fdc7a9cd2b879598a1e0ac0cb73456e4e809;hp=bc0401c8dff173498f6f25ef30d8b507bb36b9ce;hpb=756ff73fbb0cdd01cce2eda27ba18e1cc99bd735;p=platal.git diff --git a/plugins/function.select_nat.php b/plugins/function.select_nat.php index bc0401c..9e7edd5 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 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); }