From afc02bc1c3db9ffe8c9bf660c8aa08666752edfb Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Sun, 8 May 2011 15:26:22 +0000 Subject: h-source:added new EasyGiant SVN version --- h-source/Library/Form/Checkbox.php | 12 ++++++---- h-source/Library/Form/Entry.php | 10 +++++++- h-source/Library/Form/File.php | 47 +++++++++++++++++++++++++++++++++++++ h-source/Library/Form/Form.php | 9 ++++--- h-source/Library/Form/InputText.php | 12 ++++++---- h-source/Library/Form/Password.php | 12 ++++++---- h-source/Library/Form/Radio.php | 12 ++++++---- h-source/Library/Form/Select.php | 12 ++++++---- 8 files changed, 97 insertions(+), 29 deletions(-) create mode 100644 h-source/Library/Form/File.php (limited to 'h-source/Library/Form') diff --git a/h-source/Library/Form/Checkbox.php b/h-source/Library/Form/Checkbox.php index a606e76..4074210 100755 --- a/h-source/Library/Form/Checkbox.php +++ b/h-source/Library/Form/Checkbox.php @@ -31,14 +31,16 @@ class Form_Checkbox extends Form_Entry public function render($value = null) { - $wrap = $this->getWrapElements(); - $returnString = "
\n\t"; - $returnString .= $wrap[0]; - $returnString .= $this->getLabelTag(); + $wrap = $this->getWrapElements($value); + $returnString = $wrap[0]; + $returnString .= "
\n\t"; $returnString .= $wrap[1]; - $returnString .= Html_Form::checkbox($this->entryName, $value, $this->options, $this->className,$this->idName); + $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 index 2582557..440ee2d 100755 --- a/h-source/Library/Form/Entry.php +++ b/h-source/Library/Form/Entry.php @@ -47,11 +47,19 @@ abstract class Form_Entry { return isset($this->entryClass) ? $this->entryClass : 'formEntry'; } - public function getWrapElements() + public function getWrapElements($value = null) { + //replace the ;;value;; variable + for ($i = 0; $i < count($this->wrap); $i++) + { + $this->wrap[$i] = str_replace(';;value;;',$value,$this->wrap[$i]); + } + $wrap[0] = isset($this->wrap[0]) ? $this->wrap[0] : null; $wrap[1] = isset($this->wrap[1]) ? $this->wrap[1] : null; $wrap[2] = isset($this->wrap[2]) ? $this->wrap[2] : null; + $wrap[3] = isset($this->wrap[3]) ? $this->wrap[3] : null; + $wrap[4] = isset($this->wrap[4]) ? $this->wrap[4] : null; return $wrap; } diff --git a/h-source/Library/Form/File.php b/h-source/Library/Form/File.php new file mode 100644 index 0000000..48030f7 --- /dev/null +++ b/h-source/Library/Form/File.php @@ -0,0 +1,47 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +//create the HTML of a file upload entry +class Form_File 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::fileUpload($this->entryName, $value, $this->className, $this->idName); + $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 index 9705666..9aba086 100755 --- a/h-source/Library/Form/Form.php +++ b/h-source/Library/Form/Form.php @@ -31,12 +31,14 @@ class Form_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') + 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 @@ -76,7 +78,7 @@ class Form_Form { $labelClass = array_key_exists('labelClass',$entry) ? $entry['labelClass'] : null; $defaultValue = array_key_exists('defaultValue',$entry) ? $entry['defaultValue'] : null; $wrap = array_key_exists('wrap',$entry) ? $entry['wrap'] : array(); - + $this->entry[$name]->entryClass = $entryClass; $this->entry[$name]->labelString = $labelString; $this->entry[$name]->idName = $idName; @@ -105,7 +107,8 @@ class Form_Form { $fid = isset($this->id) ? "id='".$this->id."'" : null; $fname = isset($this->name) ? "name='".$this->name."'" : null; $fclass = isset($this->className) ? "class='".$this->className."'" : null; - $htmlForm = "
\n"; + $fenctype = isset($this->enctype) ? " enctype=".$this->enctype." " : null; + $htmlForm = "\n"; $subset = (isset($subset)) ? explode(',',$subset) : array_keys($values); diff --git a/h-source/Library/Form/InputText.php b/h-source/Library/Form/InputText.php index 02315a6..5943fb9 100755 --- a/h-source/Library/Form/InputText.php +++ b/h-source/Library/Form/InputText.php @@ -31,14 +31,16 @@ class Form_InputText extends Form_Entry public function render($value = null) { - $wrap = $this->getWrapElements(); - $returnString = "
\n\t"; - $returnString .= $wrap[0]; - $returnString .= $this->getLabelTag(); + $wrap = $this->getWrapElements($value); + $returnString = $wrap[0]; + $returnString .= "
\n\t"; $returnString .= $wrap[1]; - $returnString .= Html_Form::input($this->entryName, $value, $this->className, $this->idName); + $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 index 02500af..1ac4492 100644 --- a/h-source/Library/Form/Password.php +++ b/h-source/Library/Form/Password.php @@ -31,14 +31,16 @@ class Form_Password extends Form_Entry public function render($value = null) { - $wrap = $this->getWrapElements(); - $returnString = "
\n\t"; - $returnString .= $wrap[0]; - $returnString .= $this->getLabelTag(); + $wrap = $this->getWrapElements($value); + $returnString = $wrap[0]; + $returnString .= "
\n\t"; $returnString .= $wrap[1]; - $returnString .= Html_Form::password($this->entryName, null, $this->className); + $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 index 49137c0..a10726a 100755 --- a/h-source/Library/Form/Radio.php +++ b/h-source/Library/Form/Radio.php @@ -31,14 +31,16 @@ class Form_Radio extends Form_Entry public function render($value = null) { - $wrap = $this->getWrapElements(); - $returnString = "
\n\t"; - $returnString .= $wrap[0]; - $returnString .= $this->getLabelTag(); + $wrap = $this->getWrapElements($value); + $returnString = $wrap[0]; + $returnString .= "
\n\t"; $returnString .= $wrap[1]; - $returnString .= Html_Form::radio($this->entryName,$value,$this->options,$this->className, 'after', $this->idName); + $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 index db88124..884b0b2 100755 --- a/h-source/Library/Form/Select.php +++ b/h-source/Library/Form/Select.php @@ -31,14 +31,16 @@ class Form_Select extends Form_Entry public function render($value = null) { - $wrap = $this->getWrapElements(); - $returnString = "
\n\t"; - $returnString .= $wrap[0]; - $returnString .= $this->getLabelTag(); + $wrap = $this->getWrapElements($value); + $returnString = $wrap[0]; + $returnString .= "
\n\t"; $returnString .= $wrap[1]; - $returnString .= Html_Form::select($this->entryName,$value,$this->options,$this->className, $this->idName); + $returnString .= $this->getLabelTag(); $returnString .= $wrap[2]; + $returnString .= Html_Form::select($this->entryName,$value,$this->options,$this->className, $this->idName); + $returnString .= $wrap[3]; $returnString .="
\n"; + $returnString .= $wrap[4]; return $returnString; } -- cgit v1.2.3