From 07f5140771388c9e0c8a99b0dd2e5d950bdb173b Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 14 Oct 2021 15:16:42 +1100 Subject: moving h-source subdir out. --- Library/Form/Checkbox.php | 49 ++++++++++++++++ Library/Form/Entry.php | 112 ++++++++++++++++++++++++++++++++++++ Library/Form/File.php | 56 ++++++++++++++++++ Library/Form/Form.php | 140 +++++++++++++++++++++++++++++++++++++++++++++ Library/Form/Hidden.php | 40 +++++++++++++ Library/Form/Html.php | 40 +++++++++++++ Library/Form/InputText.php | 49 ++++++++++++++++ Library/Form/Password.php | 49 ++++++++++++++++ Library/Form/Radio.php | 49 ++++++++++++++++ Library/Form/Select.php | 49 ++++++++++++++++ Library/Form/Textarea.php | 49 ++++++++++++++++ Library/Form/index.html | 1 + 12 files changed, 683 insertions(+) create mode 100755 Library/Form/Checkbox.php create mode 100755 Library/Form/Entry.php create mode 100644 Library/Form/File.php create mode 100755 Library/Form/Form.php create mode 100755 Library/Form/Hidden.php create mode 100644 Library/Form/Html.php create mode 100755 Library/Form/InputText.php create mode 100644 Library/Form/Password.php create mode 100755 Library/Form/Radio.php create mode 100755 Library/Form/Select.php create mode 100755 Library/Form/Textarea.php create mode 100644 Library/Form/index.html (limited to 'Library/Form') diff --git a/Library/Form/Checkbox.php b/Library/Form/Checkbox.php new file mode 100755 index 0000000..497c097 --- /dev/null +++ b/Library/Form/Checkbox.php @@ -0,0 +1,49 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +/** create the HTML of an input text entry */ +class Form_Checkbox extends Form_Entry +{ + + public function __construct($entryName = null) + { + $this->entryName = $entryName; + } + + public function render($value = null) + { + $wrap = $this->getWrapElements($value); + $returnString = $wrap[0]; + $returnString .= "
\n\t"; + $returnString .= $wrap[1]; + $returnString .= $this->getLabelTag(); + $returnString .= $wrap[2]; + $returnString .= Html_Form::checkbox($this->entryName, $value, $this->options, $this->className,$this->idName); + $returnString .= $wrap[3]; + $returnString .="
\n"; + $returnString .= $wrap[4]; + return $returnString; + } + +} diff --git a/Library/Form/Entry.php b/Library/Form/Entry.php new file mode 100755 index 0000000..6f45557 --- /dev/null +++ b/Library/Form/Entry.php @@ -0,0 +1,112 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +//base class of the form entries +abstract class Form_Entry { + + public $entryName = null; //the name of the entry + public $entryClass = null; //the class of the entry + public $idName = null; //the id of the input entry + public $className = null; //the class of the input entry + public $labelString = null; //label of the form + public $labelClass = null; //the class of the tag of the label + public $options = array(); //options (if the entry is a \n"; + } + $returnString .= $wrap[3]; + $returnString .="\n"; + $returnString .= $wrap[4]; + return $returnString; + } + +} diff --git a/Library/Form/Form.php b/Library/Form/Form.php new file mode 100755 index 0000000..a1a9fda --- /dev/null +++ b/Library/Form/Form.php @@ -0,0 +1,140 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +//create the HTML of the whole form +class Form_Form { + + public $entry = array(); //associative array containing the entries of the form (objects that inherit the class form_entryModel). Each element of the array corresponds to one field of the table + + public $action = null; //the action of the form + public $name = null; //the name of the form + public $className = 'formClass'; //the class of the form + public $id = null; + public $submit = array(); //the submit entries array('name'=>'value') + public $method = 'POST'; //the transmission method: POST/GET + public $enctype = null; //enctype attribute of the form + + public function __construct($action,$submit = array('generalAction'=>'save'),$method = 'POST',$enctype = null) + { + $this->action = $action; //action of the form: controller/action + $this->submit = $submit; + $this->method = $method; + $this->enctype = $enctype; + } + + //method to manage the $this->entry associative array + //entryType: the type of the object to be initialized, $entryName: the name of the entry + //$options: the list of options (if the entry is a \n\n"; + } + $htmlForm .= "\n"; + return $htmlForm; + } + +} diff --git a/Library/Form/Hidden.php b/Library/Form/Hidden.php new file mode 100755 index 0000000..c589662 --- /dev/null +++ b/Library/Form/Hidden.php @@ -0,0 +1,40 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +//create the HTML of an input hidden entry +class Form_Hidden extends Form_Entry +{ + + public function __construct($entryName = null) + { + $this->entryName = $entryName; + } + + public function render($value = null) + { + $returnString = Html_Form::hidden($this->entryName, $value); + return $returnString; + } + +} diff --git a/Library/Form/Html.php b/Library/Form/Html.php new file mode 100644 index 0000000..e5c9989 --- /dev/null +++ b/Library/Form/Html.php @@ -0,0 +1,40 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +//create the HTML of an input text entry +class Form_Html extends Form_Entry +{ + + public function __construct($entryName = null) + { + $this->entryName = $entryName; + } + + public function render($value = null) + { + $returnString = "
\n\t$value\n
\n"; + return $returnString; + } + +} diff --git a/Library/Form/InputText.php b/Library/Form/InputText.php new file mode 100755 index 0000000..344264e --- /dev/null +++ b/Library/Form/InputText.php @@ -0,0 +1,49 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +//create the HTML of an input text entry +class Form_InputText extends Form_Entry +{ + + public function __construct($entryName = null) + { + $this->entryName = $entryName; + } + + public function render($value = null) + { + $wrap = $this->getWrapElements($value); + $returnString = $wrap[0]; + $returnString .= "
\n\t"; + $returnString .= $wrap[1]; + $returnString .= $this->getLabelTag(); + $returnString .= $wrap[2]; + $returnString .= Html_Form::input($this->entryName, $value, $this->className, $this->idName); + $returnString .= $wrap[3]; + $returnString .="
\n"; + $returnString .= $wrap[4]; + return $returnString; + } + +} diff --git a/Library/Form/Password.php b/Library/Form/Password.php new file mode 100644 index 0000000..9bfc68b --- /dev/null +++ b/Library/Form/Password.php @@ -0,0 +1,49 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +//create the HTML of an input text entry +class Form_Password extends Form_Entry +{ + + public function __construct($entryName = null) + { + $this->entryName = $entryName; + } + + public function render($value = null) + { + $wrap = $this->getWrapElements($value); + $returnString = $wrap[0]; + $returnString .= "
\n\t"; + $returnString .= $wrap[1]; + $returnString .= $this->getLabelTag(); + $returnString .= $wrap[2]; + $returnString .= Html_Form::password($this->entryName, null, $this->className); + $returnString .= $wrap[3]; + $returnString .="
\n"; + $returnString .= $wrap[4]; + return $returnString; + } + +} diff --git a/Library/Form/Radio.php b/Library/Form/Radio.php new file mode 100755 index 0000000..4f596ed --- /dev/null +++ b/Library/Form/Radio.php @@ -0,0 +1,49 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +//create the HTML of a radio entry +class Form_Radio extends Form_Entry +{ + + public function __construct($entryName = null) + { + $this->entryName = $entryName; + } + + public function render($value = null) + { + $wrap = $this->getWrapElements($value); + $returnString = $wrap[0]; + $returnString .= "
\n\t"; + $returnString .= $wrap[1]; + $returnString .= $this->getLabelTag(); + $returnString .= $wrap[2]; + $returnString .= Html_Form::radio($this->entryName,$value,$this->options,$this->className, 'after', $this->idName); + $returnString .= $wrap[3]; + $returnString .="
\n"; + $returnString .= $wrap[4]; + return $returnString; + } + +} diff --git a/Library/Form/Select.php b/Library/Form/Select.php new file mode 100755 index 0000000..53d7632 --- /dev/null +++ b/Library/Form/Select.php @@ -0,0 +1,49 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +//create the HTML of an select entry +class Form_Select extends Form_Entry +{ + + public function __construct($entryName = null) + { + $this->entryName = $entryName; + } + + public function render($value = null) + { + $wrap = $this->getWrapElements($value); + $returnString = $wrap[0]; + $returnString .= "
\n\t"; + $returnString .= $wrap[1]; + $returnString .= $this->getLabelTag(); + $returnString .= $wrap[2]; + $returnString .= Html_Form::select($this->entryName,$value,$this->options,$this->className, $this->idName, $this->reverse); + $returnString .= $wrap[3]; + $returnString .="
\n"; + $returnString .= $wrap[4]; + return $returnString; + } + +} diff --git a/Library/Form/Textarea.php b/Library/Form/Textarea.php new file mode 100755 index 0000000..aaaf19e --- /dev/null +++ b/Library/Form/Textarea.php @@ -0,0 +1,49 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +//create the HTML of a textarea entry +class Form_Textarea extends Form_Entry +{ + + public function __construct($entryName = null) + { + $this->entryName = $entryName; + } + + public function render($value = null) + { + $wrap = $this->getWrapElements($value); + $returnString = $wrap[0]; + $returnString .= "
\n\t"; + $returnString .= $wrap[1]; + $returnString .= $this->getLabelTag(); + $returnString .= $wrap[2]; + $returnString .= Html_Form::textarea($this->entryName, $value, $this->className, $this->idName); + $returnString .= $wrap[3]; + $returnString .="
\n"; + $returnString .= $wrap[4]; + return $returnString; + } + +} diff --git a/Library/Form/index.html b/Library/Form/index.html new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/Library/Form/index.html @@ -0,0 +1 @@ + -- cgit v1.2.3