From 3ff03dc4f0a72432b34c00da620272cf011e4ddd Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 29 Jul 2021 14:17:20 +1000 Subject: Publishing h-node.org code. - this is the h-node.org code, except - removed a js file (3x copies at three different locations) without license / copyright headers - /Js/linkToForm.js - /Public/Js/linkToForm.js - /admin/Public/Js/linkToForm.js - removed config files containing credentials - /Application/Include/params.php - /Config/Config.php - /admin/Application/Include/params.php - /admin/Config/Config.php - added license and copyright header to one php file - /admin/Library/ErrorReporting.php (almost identical to /Library/ErrorReporting.php which has the headers) --- h-source/admin/Library/Html/Form.php | 168 +++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 h-source/admin/Library/Html/Form.php (limited to 'h-source/admin/Library/Html/Form.php') diff --git a/h-source/admin/Library/Html/Form.php b/h-source/admin/Library/Html/Form.php new file mode 100644 index 0000000..bddc13f --- /dev/null +++ b/h-source/admin/Library/Html/Form.php @@ -0,0 +1,168 @@ +'value') + //$className: the class name of the select + //$idName: name of the id + static public function select($name, $value, $options, $className = null, $idName = null) + { + $strClass = isset($className) ? "class='".$className."'" : null; + $idStr = isset($idName) ? "id='".$idName."'" : null; + + $returnString = null; + $returnString .= "\n"; + return $returnString; + } + + //return the HTML of an + //$name: the name of the input + //$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) + { + $strClass = isset($className) ? "class='".$className."'" : null; + $idStr = isset($idName) ? "id='".$idName."'" : null; + + $returnString ="\n"; + return $returnString; + } + + //return the HTML of a checkBox + //$name: name of the checkBox (string) + //$value: the value of the checkBox (string or number) + //$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) + { + $strClass = isset($className) ? "class='".$className."'" : null; + $idStr = isset($idName) ? "id='".$idName."'" : null; + + $str = (strcmp($value,$option) === 0) ? "checked = 'checked'" : null; + return "\n"; + } + + //return the HTML of a hidden entry + //$name: name of the hidden entry (string) + //$value: the value of the hidden entry (string or number) + static public function hidden($name, $value) + { + return "\n"; + } + + //return the HTML of a password entry + //$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) + { + $strClass = isset($className) ? "class='".$className."'" : null; + $idStr = isset($idName) ? "id='".$idName."'" : null; + + 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) + { + $strClass = isset($className) ? "class='".$className."'" : null; + $idStr = isset($idName) ? "id='".$idName."'" : null; + + return "\n"; + } + + //return the HTML of a radio button + //$name: name of the radio button + //$value: the selected value of the radio button (set $value equal to null if you don't want to select an option) + //$options: options of the radio button. This param can be a comma-separated list of options or an associative array ('name'=>'value') + //$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) + { + $strClass = isset($className) ? "class='".$className."'" : null; + $idStr = isset($idName) ? "id='".$idName."'" : null; + + $returnString = null; + + if (is_string($options)) { + $tempArray = explode(',',$options); + foreach ($tempArray as $item) + { + $optionsArray[$item] = $item; + } + } else { + $optionsArray = $options; + } + + foreach ($optionsArray as $optionName => $optionValue) { + + if ($position === 'before') + { + $before = $optionName; + $after = null; + } + else + { + $before = null; + $after = $optionName; + } + + $str= (strcmp($value,$optionValue) === 0) ? "checked='checked'" : null; + $returnString .= "$before$after\n"; + } + + return $returnString; + } + +} \ No newline at end of file -- cgit v1.2.3