2009-03-17 Esteban Sanchez <estebans@artica.es>

* include/functions_html.php: Do not add id counter if it's 0 on
        print_select. It's a backwards compatibility workaround until we 
        take a decision on correct HTML elements. Fixed comment styles, please
        do not add comments in the same line.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1542 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
esanchezm 2009-03-17 11:19:36 +00:00
parent a1546eaf9f
commit 9433df0195
2 changed files with 25 additions and 15 deletions

View File

@ -1,3 +1,10 @@
2009-03-17 Esteban Sanchez <estebans@artica.es>
* include/functions_html.php: Do not add id counter if it's 0 on
print_select. It's a backwards compatibility workaround until we
take a decision on correct HTML elements. Fixed comment styles, please
do not add comments in the same line.
2009-03-17 Jorge Gonzalez <jorgegonz@svn.gnome.org> 2009-03-17 Jorge Gonzalez <jorgegonz@svn.gnome.org>
* include/languages/es.po, include/languages/es.mo: Updated Spanish * include/languages/es.po, include/languages/es.mo: Updated Spanish

View File

@ -48,7 +48,7 @@ function print_select ($fields, $name, $selected = '', $script = '', $nothing =
$idcounter[$name] = 0; $idcounter[$name] = 0;
} }
$id = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.$idcounter[$name]); $id = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.($idcounter[$name] ? $idcounter[$name] : ''));
$attributes = ""; $attributes = "";
if (!empty ($script)) { if (!empty ($script)) {
@ -74,7 +74,6 @@ function print_select ($fields, $name, $selected = '', $script = '', $nothing =
if ($nothing_value == $selected) { if ($nothing_value == $selected) {
$output .= ' selected="selected"'; $output .= ' selected="selected"';
} }
//You should pass a translated string already
$output .= '>'.$nothing.'</option>'; $output .= '>'.$nothing.'</option>';
} }
@ -86,9 +85,11 @@ function print_select ($fields, $name, $selected = '', $script = '', $nothing =
$output .= '<option value="'.$value.'"'; $output .= '<option value="'.$value.'"';
if (is_array ($selected) && in_array ($value, $selected)) { if (is_array ($selected) && in_array ($value, $selected)) {
$output .= ' selected="selected"'; $output .= ' selected="selected"';
} elseif (is_numeric ($value) && is_numeric ($selected) && $value == $selected) { //This fixes string ($value) to int ($selected) comparisons } elseif (is_numeric ($value) && is_numeric ($selected) && $value == $selected) {
//This fixes string ($value) to int ($selected) comparisons
$output .= ' selected="selected"'; $output .= ' selected="selected"';
} elseif ($value === $selected) { //Needs type comparison otherwise if $selected = 0 and $value = "string" this would evaluate to true } elseif ($value === $selected) {
//Needs type comparison otherwise if $selected = 0 and $value = "string" this would evaluate to true
$output .= ' selected="selected"'; $output .= ' selected="selected"';
} }
if ($label === '') { if ($label === '') {
@ -160,17 +161,17 @@ function print_select_from_sql ($sql, $name, $selected = '', $script = '', $noth
function print_input_text_extended ($name, $value, $id, $alt, $size, $maxlength, $disabled, $script, $attributes, $return = false, $password = false) { function print_input_text_extended ($name, $value, $id, $alt, $size, $maxlength, $disabled, $script, $attributes, $return = false, $password = false) {
static $idcounter = 0; static $idcounter = 0;
if ($maxlength == 0) if ($maxlength == 0)
$maxlength = 255; $maxlength = 255;
if ($size == 0) if ($size == 0)
$size = 10; $size = 10;
++$idcounter; ++$idcounter;
$valid_attrs = array ("accept", "disabled", "maxlength", "name", "readonly", "size", "value", $valid_attrs = array ("accept", "disabled", "maxlength", "name", "readonly", "size", "value",
"accesskey", "class", "dir", "id", "lang", "style", "tabindex", "title", "xml:lang", "accesskey", "class", "dir", "id", "lang", "style", "tabindex", "title", "xml:lang",
"onfocus", "onblur", "onselect", "onchange", "onclick", "ondblclick", "onmousedown", "onfocus", "onblur", "onselect", "onchange", "onclick", "ondblclick", "onmousedown",
"onmouseup", "onmouseover", "onmousemove", "onmouseout", "onkeypress", "onkeydown", "onkeyup"); "onmouseup", "onmouseover", "onmousemove", "onmouseout", "onkeypress", "onkeydown", "onkeyup");
$output = '<input '.($password ? 'type="password" ' : 'type="text" '); $output = '<input '.($password ? 'type="password" ' : 'type="text" ');
@ -191,7 +192,9 @@ function print_input_text_extended ($name, $value, $id, $alt, $size, $maxlength,
} }
//Attributes specified by function call //Attributes specified by function call
$attrs = array ("name" => "unnamed", "value" => "", "id" => "text-".sprintf ('%04d', $idcounter), "size" => "", "maxlength" => ""); $attrs = array ("name" => "unnamed", "value" => "",
"id" => "text-".sprintf ('%04d', $idcounter),
"size" => "", "maxlength" => "");
foreach ($attrs as $attribute => $default) { foreach ($attrs as $attribute => $default) {
if (array_key_exists ($attribute, $attributes)) { if (array_key_exists ($attribute, $attributes)) {