X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=plugins%2Ffunction.select_db_table.php;h=bc83d956b64545919de63bf346ff558ffd0b8800;hb=refs%2Fheads%2Fcore%2Fmaster;hp=85f86331c4867161e9f800bf42190b4cb0ab579e;hpb=a7f778a593a0a7e168a7112ec28cb84d032adaf3;p=platal.git diff --git a/plugins/function.select_db_table.php b/plugins/function.select_db_table.php index 85f8633..bc83d95 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 .= ''; @@ -47,7 +48,7 @@ function select_options($table,$valeur,$champ="text",$pad=false, $optgrp = $my_grp; } $html .= sprintf("\n", - $my_id, $valeur==$my_id ? $sel : "", pl_entities($my_text)); + $my_id, $value == $my_id ? $sel : '', pl_entities($my_text)); } if (!is_null($optgrp)) { $html .= ''; @@ -55,20 +56,23 @@ function select_options($table,$valeur,$champ="text",$pad=false, return $html; } -function smarty_function_select_db_table($params, &$smarty) { - if(empty($params['table'])) +function smarty_function_select_db_table($params, $smarty) { + if (empty($params['table']) || !array_key_exists('valeur', $params)) { 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: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: ?>