aboutsummaryrefslogtreecommitdiff
path: root/h-source/Library/Html
diff options
context:
space:
mode:
authorAntonio Gallo <tonicucoz@gmail.com>2011-12-03 12:30:25 +0000
committerAntonio Gallo <tonicucoz@gmail.com>2011-12-03 12:30:25 +0000
commitd30d70afd95653bb356603612db6519d6e6ebead (patch)
tree8ca2f2a7f24eeea1203b0042015d25f18f97496b /h-source/Library/Html
parentf56fa1fc50484d99906a0a22e2931f9c1fe708b6 (diff)
improved i18n
Diffstat (limited to 'h-source/Library/Html')
-rw-r--r--h-source/Library/Html/Form.php46
1 files changed, 28 insertions, 18 deletions
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 .= "<select ".$idStr." $strClass name='".$name."'>\n";
+ $returnString .= "<select $attributes ".$idStr." $strClass name='".$name."'>\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 .= "</optgroup>\n";
- $returnString .= "<optgroup label=" . $optionName . ">\n";
+ $returnString .= "<optgroup label='" . $a . "'>\n";
$flag = 1;
}
else
{
- $str= (strcmp($value,$optionValue) === 0) ? "selected='$optionValue'" : null;
- $returnString .= "<option value='".$optionValue."' $str>$optionName</option>\n";
+ $str= (strcmp($value,$b) === 0) ? "selected='$b'" : null;
+ $returnString .= "<option value='".$b."' $str>$a</option>\n";
}
}
if ($flag === 1) $returnString .= "</optgroup>\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 ="<input ".$idStr." $strClass type='text' name='" .$name. "' value = '$value'>\n";
+ $returnString ="<input $attributes ".$idStr." $strClass type='text' name='" .$name. "' value = '$value' />\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 ="<input ".$idStr." $strClass type='file' name='" .$name. "'>\n";
+ $returnString ="<input $attributes ".$idStr." $strClass type='file' name='" .$name. "' />\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 "<input ".$idStr." $strClass type='checkbox' name='".$name."' value='".$option."' $str>\n";
+ return "<input $attributes ".$idStr." $strClass type='checkbox' name='".$name."' value='".$option."' $str />\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 "<input ".$idStr." $strClass type='password' name='" .$name. "' value='$value'>\n";
+ return "<input $attributes ".$idStr." $strClass type='password' name='" .$name. "' value='$value' />\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 "<textarea ".$idStr." $strClass name='" .$name. "'>$value</textarea>\n";
+ return "<textarea $attributes ".$idStr." $strClass name='" .$name. "'>$value</textarea>\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<input ".$idStr." $strClass type='radio' name='".$name."' value='".$optionValue."' $str>$after\n";
+ $returnString .= "$before<input $attributes ".$idStr." $strClass type='radio' name='".$name."' value='".$optionValue."' $str />$after\n";
}
return $returnString;