From 129934f892850a90f98f8f5a0e7746cfe57bb958 Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Mon, 28 May 2012 15:31:57 +0000 Subject: added new EasyGiant library --- h-source/Library/Form/Checkbox.php | 49 +++++++++++++ h-source/Library/Form/Entry.php | 112 +++++++++++++++++++++++++++++ h-source/Library/Form/File.php | 56 +++++++++++++++ h-source/Library/Form/Form.php | 140 ++++++++++++++++++++++++++++++++++++ h-source/Library/Form/Hidden.php | 40 +++++++++++ h-source/Library/Form/Html.php | 40 +++++++++++ h-source/Library/Form/InputText.php | 49 +++++++++++++ h-source/Library/Form/Password.php | 49 +++++++++++++ h-source/Library/Form/Radio.php | 49 +++++++++++++ h-source/Library/Form/Select.php | 49 +++++++++++++ h-source/Library/Form/Textarea.php | 49 +++++++++++++ h-source/Library/Form/index.html | 1 + 12 files changed, 683 insertions(+) create mode 100755 h-source/Library/Form/Checkbox.php create mode 100755 h-source/Library/Form/Entry.php create mode 100644 h-source/Library/Form/File.php create mode 100755 h-source/Library/Form/Form.php create mode 100755 h-source/Library/Form/Hidden.php create mode 100644 h-source/Library/Form/Html.php create mode 100755 h-source/Library/Form/InputText.php create mode 100644 h-source/Library/Form/Password.php create mode 100755 h-source/Library/Form/Radio.php create mode 100755 h-source/Library/Form/Select.php create mode 100755 h-source/Library/Form/Textarea.php create mode 100644 h-source/Library/Form/index.html (limited to 'h-source/Library/Form') diff --git a/h-source/Library/Form/Checkbox.php b/h-source/Library/Form/Checkbox.php new file mode 100755 index 0000000..497c097 --- /dev/null +++ b/h-source/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/h-source/Library/Form/Entry.php b/h-source/Library/Form/Entry.php new file mode 100755 index 0000000..6f45557 --- /dev/null +++ b/h-source/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/h-source/Library/Form/Form.php b/h-source/Library/Form/Form.php new file mode 100755 index 0000000..a1a9fda --- /dev/null +++ b/h-source/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/h-source/Library/Form/Hidden.php b/h-source/Library/Form/Hidden.php new file mode 100755 index 0000000..c589662 --- /dev/null +++ b/h-source/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/h-source/Library/Form/Html.php b/h-source/Library/Form/Html.php new file mode 100644 index 0000000..e5c9989 --- /dev/null +++ b/h-source/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/h-source/Library/Form/InputText.php b/h-source/Library/Form/InputText.php new file mode 100755 index 0000000..344264e --- /dev/null +++ b/h-source/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/h-source/Library/Form/Password.php b/h-source/Library/Form/Password.php new file mode 100644 index 0000000..9bfc68b --- /dev/null +++ b/h-source/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/h-source/Library/Form/Radio.php b/h-source/Library/Form/Radio.php new file mode 100755 index 0000000..4f596ed --- /dev/null +++ b/h-source/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/h-source/Library/Form/Select.php b/h-source/Library/Form/Select.php new file mode 100755 index 0000000..53d7632 --- /dev/null +++ b/h-source/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/h-source/Library/Form/Textarea.php b/h-source/Library/Form/Textarea.php new file mode 100755 index 0000000..aaaf19e --- /dev/null +++ b/h-source/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/h-source/Library/Form/index.html b/h-source/Library/Form/index.html new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/h-source/Library/Form/index.html @@ -0,0 +1 @@ + -- cgit v1.2.3