From d30d70afd95653bb356603612db6519d6e6ebead Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Sat, 3 Dec 2011 12:30:25 +0000 Subject: improved i18n --- h-source/Library/Html/Form.php | 46 +++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'h-source/Library/Html/Form.php') diff --git a/h-source/Library/Html/Form.php b/h-source/Library/Html/Form.php index f82cd2d..0714d3c 100644 --- a/h-source/Library/Html/Form.php +++ b/h-source/Library/Html/Form.php @@ -31,13 +31,13 @@ class Html_Form { //$options: options of the select. This param can be a comma-separated list of options or an associative array ('name'=>'value') //$className: the class name of the select //$idName: name of the id - static public function select($name, $value, $options, $className = null, $idName = null) + static public function select($name, $value, $options, $className = null, $idName = null, $reverse = null, $attributes = null) { $strClass = isset($className) ? "class='".$className."'" : null; $idStr = isset($idName) ? "id='".$idName."'" : null; $returnString = null; - $returnString .= "\n"; if (is_string($options)) { $tempArray = explode(',',$options); foreach ($tempArray as $item) @@ -60,16 +60,26 @@ class Html_Form { $flag = 0; foreach ($optionsArray as $optionName => $optionValue) { - if (strcmp($optionValue,'optgroupOpen') === 0) + + $a = $optionName; + $b = $optionValue; + + if (strcmp($reverse,'yes') === 0) + { + $b = $optionName; + $a = $optionValue; + } + + if (strcmp($b,'optgroupOpen') === 0) { if ($flag === 1) $returnString .= "\n"; - $returnString .= "\n"; + $returnString .= "\n"; $flag = 1; } else { - $str= (strcmp($value,$optionValue) === 0) ? "selected='$optionValue'" : null; - $returnString .= "\n"; + $str= (strcmp($value,$b) === 0) ? "selected='$b'" : null; + $returnString .= "\n"; } } if ($flag === 1) $returnString .= "\n"; @@ -82,12 +92,12 @@ class Html_Form { //$value: the value of the input //$className: the class name of the input //$idName: name of the id - static public function input($name, $value, $className = null, $idName = null) + static public function input($name, $value, $className = null, $idName = null, $attributes = null) { $strClass = isset($className) ? "class='".$className."'" : null; $idStr = isset($idName) ? "id='".$idName."'" : null; - $returnString ="\n"; + $returnString ="\n"; return $returnString; } @@ -95,12 +105,12 @@ class Html_Form { //$name: the name of the input //$className: the class name of the input //$idName: name of the id - static public function fileUpload($name, $value, $className = null, $idName = null) + static public function fileUpload($name, $value, $className = null, $idName = null, $attributes = null) { $strClass = isset($className) ? "class='".$className."'" : null; $idStr = isset($idName) ? "id='".$idName."'" : null; - $returnString ="\n"; + $returnString ="\n"; return $returnString; } @@ -110,13 +120,13 @@ class Html_Form { //$option: option of the checkBox (string or number) //$className: the class name of the checkBox (string) //$idName: name of the id - static public function checkbox($name, $value, $option, $className = null, $idName = null) + static public function checkbox($name, $value, $option, $className = null, $idName = null, $attributes = null) { $strClass = isset($className) ? "class='".$className."'" : null; $idStr = isset($idName) ? "id='".$idName."'" : null; $str = (strcmp($value,$option) === 0) ? "checked = 'checked'" : null; - return "\n"; + return "\n"; } //return the HTML of a hidden entry @@ -131,24 +141,24 @@ class Html_Form { //$name: name of the password entry (string) //$value: the value of the password entry (string or number) //$idName: name of the id - static public function password($name, $value, $className = null, $idName = null) + static public function password($name, $value, $className = null, $idName = null, $attributes = null) { $strClass = isset($className) ? "class='".$className."'" : null; $idStr = isset($idName) ? "id='".$idName."'" : null; - return "\n"; + return "\n"; } //return the HTML of a textarea //$name: name of the textarea (string) //$value: the value of the textarea (string or number) //$idName: name of the id - static public function textarea($name, $value, $className = null, $idName = null) + static public function textarea($name, $value, $className = null, $idName = null, $attributes = null) { $strClass = isset($className) ? "class='".$className."'" : null; $idStr = isset($idName) ? "id='".$idName."'" : null; - return "\n"; + return "\n"; } //return the HTML of a radio button @@ -158,7 +168,7 @@ class Html_Form { //$className: the class name of the radio button //$position: position of the strings of the radio with respect to the "circles". It can be before or after //$idName: name of the id - static public function radio($name, $value, $options, $className = null, $position = 'after', $idName = null) + static public function radio($name, $value, $options, $className = null, $position = 'after', $idName = null, $attributes = null) { $strClass = isset($className) ? "class='".$className."'" : null; $idStr = isset($idName) ? "id='".$idName."'" : null; @@ -189,7 +199,7 @@ class Html_Form { } $str= (strcmp($value,$optionValue) === 0) ? "checked='checked'" : null; - $returnString .= "$before$after\n"; + $returnString .= "$before$after\n"; } return $returnString; -- cgit v1.2.3