projects
/
platal.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge remote branch 'origin/core-1.1.0' into core
[platal.git]
/
plugins
/
function.select_db_table.php
diff --git
a/plugins/function.select_db_table.php
b/plugins/function.select_db_table.php
index
eef9e1d
..
80f20a0
100644
(file)
--- a/
plugins/function.select_db_table.php
+++ b/
plugins/function.select_db_table.php
@@
-1,6
+1,6
@@
<?php
/***************************************************************************
<?php
/***************************************************************************
- * Copyright (C) 2003-20
07
Polytechnique.org *
+ * Copyright (C) 2003-20
10
Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
@@
-19,28
+19,27
@@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once 'platal.inc.php';
-
-function select_options($table,$valeur,$champ="text",$pad=false,
- $where="",$join="",$group="")
+function select_options($table, $value, $field, $pad, $where, $join, $group)
{
{
- $fields = 't.id,' . $
champ
;
- $order = $
champ
;
+ $fields = 't.id,' . $
field
;
+ $order = $
field
;
if ($group) {
$fields .= ',' . $group;
$order = $group . ',' . $order;
if ($group) {
$fields .= ',' . $group;
$order = $group . ',' . $order;
+ } else {
+ $fields .= ', NULL';
}
$sql = "SELECT $fields FROM $table AS t $join $where ORDER BY $order";
$res = XDB::iterRow($sql);
$sel = ' selected="selected"';
}
$sql = "SELECT $fields FROM $table AS t $join $where ORDER BY $order";
$res = XDB::iterRow($sql);
$sel = ' selected="selected"';
- //
on ajoute une entree vide si $pad est vrai
- $html =
""
;
+ //
An empty entry is added when $pad is true.
+ $html =
''
;
if ($pad) {
if ($pad) {
- $html
.= '<option value="0"'.($valeur==0?$sel:"").">
</option>\n";
+ $html
.= '<option value="0"' . ($value == 0 ? $sel : '') . ">
</option>\n";
}
$optgrp = null;
}
$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 .= '</optgroup>';
if ($my_grp != $optgrp) {
if (!is_null($optgrp)) {
$html .= '</optgroup>';
@@
-49,7
+48,7
@@
function select_options($table,$valeur,$champ="text",$pad=false,
$optgrp = $my_grp;
}
$html .= sprintf("<option value=\"%s\" %s>%s</option>\n",
$optgrp = $my_grp;
}
$html .= sprintf("<option value=\"%s\" %s>%s</option>\n",
- $my_id, $val
eur==$my_id ? $sel : ""
, pl_entities($my_text));
+ $my_id, $val
ue == $my_id ? $sel : ''
, pl_entities($my_text));
}
if (!is_null($optgrp)) {
$html .= '</optgroup>';
}
if (!is_null($optgrp)) {
$html .= '</optgroup>';
@@
-58,16
+57,19
@@
function select_options($table,$valeur,$champ="text",$pad=false,
}
function smarty_function_select_db_table($params, &$smarty) {
}
function smarty_function_select_db_table($params, &$smarty) {
- if
(empty($params['table']))
+ if
(empty($params['table']) || empty($params['valeur'])) {
return;
return;
- if(empty($params['champ']))
+ }
+ if (empty($params['champ'])) {
$params['champ'] = 'text';
$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']);
}
return select_options($params['table'], $params['valeur'], $params['champ'], $pad,
$params['where'], $params['join'], $params['group']);
}