X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=plugins%2Ffunction.select_db_table.php;h=ea1a1b3b48c0063302bc3fc3138522787ce2d551;hb=e92ecb8c24421ca1dd4f87ad7478d0d8277e1f60;hp=edea56231db8fadcf65f6e71a0f4b93a4aa466e0;hpb=787bb3d745141f2f85bd947ad7dd775d2c63f908;p=platal.git
diff --git a/plugins/function.select_db_table.php b/plugins/function.select_db_table.php
index edea562..ea1a1b3 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 .= '';
@@ -49,7 +48,7 @@ function select_options($table,$valeur,$champ="text",$pad=false,
$optgrp = $my_grp;
}
$html .= sprintf("\n",
- $my_id, ($valeur==$my_id?$sel:""), $my_text);
+ $my_id, $value == $my_id ? $sel : '', pl_entities($my_text));
}
if (!is_null($optgrp)) {
$html .= '';
@@ -58,16 +57,19 @@ 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']) || !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']);
}