X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=plugins%2Ffunction.select_db_table.php;h=80f20a0ab65ff5965fcf51b7e97fe689b969b220;hb=7e001f68b7928d80ccf32b8a8bca55d304476d3e;hp=5bc2bcb56d43cd4020e33912c15f6268d6e9d66b;hpb=5ddeb07cc787dd1dc3630a31f1528f5cc7c4d9b9;p=platal.git diff --git a/plugins/function.select_db_table.php b/plugins/function.select_db_table.php index 5bc2bcb..80f20a0 100644 --- a/plugins/function.select_db_table.php +++ b/plugins/function.select_db_table.php @@ -1,6 +1,6 @@ \n"; + $html .= '\n"; } $optgrp = null; - while (list($my_id,$my_text,$my_grp) = $res->next()) { + while (list($my_id, $my_text, $my_grp) = $res->next()) { if ($my_grp != $optgrp) { if (!is_null($optgrp)) { $html .= ''; } - $html .= ''; + $html .= ''; $optgrp = $my_grp; } - $html .= sprintf("\n", - $my_id, ($valeur==$my_id?$sel:""), $my_text); + $html .= sprintf("\n", + $my_id, $value == $my_id ? $sel : '', pl_entities($my_text)); } if (!is_null($optgrp)) { $html .= ''; @@ -57,18 +57,22 @@ function select_options($table,$valeur,$champ="text",$pad=false, } function smarty_function_select_db_table($params, &$smarty) { - if(empty($params['table'])) + if (empty($params['table']) || empty($params['valeur'])) { return; - if(empty($params['champ'])) + } + if (empty($params['champ'])) { $params['champ'] = 'text'; - if(empty($params['pad']) || !($params['pad'])) - $pad = false; - else - $pad = true; - if(empty($params['where'])) - $params['where'] = ''; + } + foreach (array('where', 'join', 'group') as $value) { + if (empty($params[$value])) { + $params[$value] = ''; + } + } + $pad = (!empty($params['pad']) && $params['pad']); + return select_options($params['table'], $params['valeur'], $params['champ'], $pad, $params['where'], $params['join'], $params['group']); } +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>