Changeset 5925
- Timestamp:
- 01/11/12 23:08:24 (4 months ago)
- Location:
- trunk/core/viewhelper/form
- Files:
-
- 1 added
- 1 deleted
- 4 edited
- 6 moved
-
decorators (moved) (moved from trunk/core/viewhelper/form/formdecorators)
-
decorators/form/label.form.php (modified) (2 diffs)
-
decorators/form/table.form.php (modified) (1 diff)
-
elements (moved) (moved from trunk/core/viewhelper/form/formelements)
-
elements/hidden.form.php (modified) (2 diffs)
-
elements/securitytoken.form.php (modified) (1 diff)
-
form.php (moved) (moved from trunk/core/viewhelper/form/form.core.php) (3 diffs)
-
formdecorator.php (moved) (moved from trunk/core/viewhelper/form/formdecorator.core.php) (5 diffs)
-
formelement.php (moved) (moved from trunk/core/viewhelper/form/formelement.core.php) (3 diffs)
-
formelementdecorator.php (added)
-
formelementvalidator.php (moved) (moved from trunk/core/viewhelper/form/validator.php)
-
formgenerators (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/viewhelper/form/decorators/form/label.form.php
r5145 r5925 38 38 39 39 class Clansuite_Form_Decorator_Label extends Clansuite_Form_Decorator 40 { 40 { 41 41 /** 42 42 * Name of this decorator … … 50 50 */ 51 51 public function render($html_form_content) 52 { 53 52 { 53 echo 'some LABEL' . $html_form_content; 54 54 } 55 55 } -
trunk/core/viewhelper/form/decorators/form/table.form.php
r5145 r5925 48 48 public function render($html_form_content) 49 49 { 50 return $html_form_content,51 } 50 return 'TABLE' .$html_form_content; 51 } 52 52 } 53 53 ?> -
trunk/core/viewhelper/form/elements/hidden.form.php
r5353 r5925 37 37 } 38 38 39 # conditional include of the parent class40 if (false == class_exists('Clansuite_Formelement_Input',false))41 {42 include __DIR__ . '/input.form.php';43 }44 39 45 /**46 * Clansuite_Formelement47 * |48 * \- Clansuite_Formelement_Input49 * |50 * \- Clansuite_Formelement_Hidden51 */52 40 class Clansuite_Formelement_Hidden extends Clansuite_Formelement_Input implements Clansuite_Formelement_Interface 53 41 { … … 56 44 $this->type = 'hidden'; 57 45 } 46 47 public function addHiddenFieldForCharsetDetection() 48 { 49 return '<input name="_charset_" type="hidden" />'; 50 } 58 51 } 59 52 ?> -
trunk/core/viewhelper/form/elements/securitytoken.form.php
r4599 r5925 37 37 } 38 38 39 /** 40 * 41 * Clansuite_Form 42 * | 43 * \- Clansuite_Formelement_Securitytoken 44 */ 45 class Clansuite_Formelement_Securitytoken extends Clansuite_Formelement implements Clansuite_Formelement_Interface 39 40 class Clansuite_Formelement_Securitytoken extends Clansuite_Formelement_Hidden implements Clansuite_Formelement_Interface 46 41 { 42 public function __construct(l) 43 { 44 parent::__construct(); 45 46 $this->isRequired(); 47 $this->setValidator('NotEmpty'); 48 $this->initCsrfValidator(); 49 } 50 51 public function initCsrfValidator() 52 { 53 $session = $this->getSession(); 54 55 if (isset($session->hash)) 56 { 57 $validHash = $session->hash; 58 } 59 else 60 { 61 $validHash = null; 62 } 47 63 64 $this->addValidator('Identical', true, array($validHash)); 65 66 return $this; 67 } 68 69 # getHash 70 # setHashToSession 71 # getHashFromSession 72 # compare 73 74 public function render() 75 { 76 77 } 48 78 } 49 79 ?> -
trunk/core/viewhelper/form/form.php
r5923 r5925 1100 1100 if (false == class_exists($formelement_classname, false)) 1101 1101 { 1102 $file = ROOT_CORE . 'viewhelper/form/ formelements/'.$formelement.'.form.php';1102 $file = ROOT_CORE . 'viewhelper/form/elements/'.$formelement.'.form.php'; 1103 1103 1104 1104 if(is_file($file) === true) … … 1395 1395 * Factory method. Instantiates and returns a new formdecorator object. 1396 1396 * 1397 * @param string Name of Formdecorator. 1397 1398 * @return Clansuite_Formdecorator 1398 1399 */ 1399 public function decoratorFactory($formdecorator) 1400 { 1400 public function decoratorFactory($decorator) 1401 { 1402 # construct Clansuite_Form_Decorator_Name 1403 $class = 'Clansuite_Form_Decorator_' . ucfirst($decorator); 1404 1401 1405 # if not already loaded, require forelement file 1402 if(false == class_exists('Clansuite_Form_Decorator_' . $ formdecorator, false))1403 { 1404 $file = ROOT_CORE . 'viewhelper/form/ formdecorators/form/' . $formdecorator . '.form.php';1406 if(false == class_exists('Clansuite_Form_Decorator_' . $decorator, false)) 1407 { 1408 $file = ROOT_CORE . 'viewhelper/form/decorators/form/' . $decorator . '.form.php'; 1405 1409 1406 1410 if(is_file($file) === true) … … 1410 1414 } 1411 1415 1412 # construct Clansuite_Formdecorator_Name1413 $formdecorator_classname = 'Clansuite_Form_Decorator_' . ucfirst($formdecorator);1414 1416 # instantiate the new $formdecorator and return 1415 return new $ formdecorator_classname();1417 return new $class(); 1416 1418 } 1417 1419 -
trunk/core/viewhelper/form/formdecorator.php
r5922 r5925 37 37 } 38 38 39 interface Clansuite_Form_Decorator_Interface 40 { 41 public function decorateWith($form_decorator); 42 public function getName(); 43 } 44 39 45 /** 40 46 * Clansuite_Form_Decorator … … 72 78 # instance of form, which is to decorate 73 79 protected $form; 74 75 private $class, $id; 80 81 private $name, $class, $id; 82 83 public function getName() 84 { 85 return $this->name; 86 } 87 88 public function setName($name) 89 { 90 $this->name = $name; 91 } 76 92 77 93 /** … … 96 112 return $this->class; 97 113 } 98 114 99 115 /** 100 116 * Set id="" … … 162 178 } 163 179 } 164 180 165 181 /** 166 182 * __call Magic Method … … 176 192 { 177 193 return call_user_func_array( array($this->form, $method), $parameters); 178 } 194 } 179 195 } 180 196 } 181 182 /**183 * Clansuite_Formelement_Decorator184 *185 * @author Jens-André Koch <vain@clansuite.com>186 * @copyright Jens-André Koch (2005-onwards)187 *188 * @category Clansuite189 * @package Core190 * @subpackage Form191 */192 193 abstract class Clansuite_Formelement_Decorator implements Clansuite_Formelement_Decorator_Interface194 {195 # instance of formelement, which is to decorate196 protected $formelement;197 198 private $class;199 200 /**201 * Set class=""202 *203 * @param string $classname204 */205 public function setClass($classname)206 {207 $this->class = $classname;208 209 return $this->formelement;210 }211 212 /**213 * Get class="" values214 *215 * @return string216 */217 public function getClass()218 {219 return $this->class;220 }221 222 /**223 * Constructor224 *225 * @param $form Accepts a Clansuite_Form Object implementing the Clansuite_Form_Interface.226 */227 /*public function __construct(Clansuite_Form_Interface $form)228 {229 $this->decorate($form);230 }*/231 232 /**233 * Setter method to set the object which is to decorate.234 *235 * @param $form object of type Clansuite_Form_Interface or Clansuite_Form_Decorator_Interface236 */237 public function decorateWith($formelement)238 {239 $this->formelement = $formelement;240 }241 242 /**243 * Purpose of this method is to check, if this object or a decorator implements a certain method.244 *245 * @param $method246 * @return boolean247 */248 public function hasMethod($method)249 {250 # check if method exists in this object251 if(method_exists($this, $method))252 {253 return true;254 }255 # check if method exists in the decorator of this object256 elseif($this->formelement instanceof Clansuite_Formelement_Decorator)257 {258 return $this->formelement->hasMethod($method);259 }260 else # nope, method does not exist261 {262 return false;263 }264 }265 266 /**267 * __call Magic Method268 *269 * In general this calls a certain method with parameters on the object which is to decorate ($form).270 *271 * @param $method272 * @param $parameters273 */274 public function __call($method, $parameters)275 {276 return call_user_func_array(array($this->formelement, $method), $parameters);277 }278 }279 280 interface Clansuite_Formelement_Decorator_Interface281 {282 public function decorateWith($formelement_decorator);283 }284 285 interface Clansuite_Form_Decorator_Interface286 {287 public function decorateWith($form_decorator);288 }289 197 ?> -
trunk/core/viewhelper/form/formelement.php
r5923 r5925 557 557 public function getValidator($validator) 558 558 { 559 # load baseclass560 # @todo move to map / autoloader561 if(false == class_exists('Clansuite_Formelement_Validator', false))562 {563 include ROOT_CORE . 'viewhelper/form/validator.php';564 }565 566 559 # construct classname 567 560 $class = 'Clansuite_Formelement_Validator_' . ucfirst($validator); … … 847 840 public function decoratorFactory($decorator) 848 841 { 849 # construct Clansuite_Form decorator_Name842 # construct Clansuite_Formelement_Decorator_Name 850 843 $class = 'Clansuite_Formelement_Decorator_' . ucfirst($decorator); 851 844 … … 853 846 if(false == class_exists($class, false)) 854 847 { 855 $file = ROOT_CORE . 'viewhelper/form/ formdecorators/formelement/' . $decorator . '.form.php';848 $file = ROOT_CORE . 'viewhelper/form/decorators/formelement/' . $decorator . '.form.php'; 856 849 857 850 if(is_file($file) === true)
Note: See TracChangeset
for help on using the changeset viewer.
