Changeset 5925


Ignore:
Timestamp:
01/11/12 23:08:24 (4 months ago)
Author:
vain
Message:
  • renamed for simplicity
Location:
trunk/core/viewhelper/form
Files:
1 added
1 deleted
4 edited
6 moved

Legend:

Unmodified
Added
Removed
  • trunk/core/viewhelper/form/decorators/form/label.form.php

    r5145 r5925  
    3838 
    3939class Clansuite_Form_Decorator_Label extends Clansuite_Form_Decorator 
    40 {     
     40{ 
    4141    /** 
    4242     * Name of this decorator 
     
    5050     */ 
    5151    public function render($html_form_content) 
    52     {   
    53             
     52    { 
     53           echo 'some LABEL' . $html_form_content; 
    5454    } 
    5555} 
  • trunk/core/viewhelper/form/decorators/form/table.form.php

    r5145 r5925  
    4848    public function render($html_form_content) 
    4949    { 
    50         return $html_form_content, 
    51     }    
     50        return 'TABLE' .$html_form_content; 
     51    } 
    5252} 
    5353?> 
  • trunk/core/viewhelper/form/elements/hidden.form.php

    r5353 r5925  
    3737} 
    3838 
    39 # conditional include of the parent class 
    40 if (false == class_exists('Clansuite_Formelement_Input',false)) 
    41 {  
    42     include __DIR__ . '/input.form.php'; 
    43 } 
    4439 
    45 /** 
    46  *  Clansuite_Formelement 
    47  *  | 
    48  *  \- Clansuite_Formelement_Input 
    49  *      | 
    50  *      \- Clansuite_Formelement_Hidden 
    51  */ 
    5240class Clansuite_Formelement_Hidden extends Clansuite_Formelement_Input implements Clansuite_Formelement_Interface 
    5341{ 
     
    5644        $this->type = 'hidden'; 
    5745    } 
     46 
     47    public function addHiddenFieldForCharsetDetection() 
     48    { 
     49        return '<input name="_charset_" type="hidden" />'; 
     50    } 
    5851} 
    5952?> 
  • trunk/core/viewhelper/form/elements/securitytoken.form.php

    r4599 r5925  
    3737} 
    3838 
    39 /** 
    40  * 
    41  *  Clansuite_Form 
    42  *  | 
    43  *  \- Clansuite_Formelement_Securitytoken 
    44  */ 
    45 class Clansuite_Formelement_Securitytoken extends Clansuite_Formelement implements Clansuite_Formelement_Interface 
     39 
     40class Clansuite_Formelement_Securitytoken extends Clansuite_Formelement_Hidden implements Clansuite_Formelement_Interface 
    4641{ 
     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        } 
    4763 
     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    } 
    4878} 
    4979?> 
  • trunk/core/viewhelper/form/form.php

    r5923 r5925  
    11001100        if (false == class_exists($formelement_classname, false)) 
    11011101        { 
    1102             $file = ROOT_CORE . 'viewhelper/form/formelements/'.$formelement.'.form.php'; 
     1102            $file = ROOT_CORE . 'viewhelper/form/elements/'.$formelement.'.form.php'; 
    11031103 
    11041104            if(is_file($file) === true) 
     
    13951395     * Factory method. Instantiates and returns a new formdecorator object. 
    13961396     * 
     1397     * @param string Name of Formdecorator. 
    13971398     * @return Clansuite_Formdecorator 
    13981399     */ 
    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 
    14011405        # 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'; 
    14051409 
    14061410            if(is_file($file) === true) 
     
    14101414        } 
    14111415 
    1412         # construct Clansuite_Formdecorator_Name 
    1413         $formdecorator_classname = 'Clansuite_Form_Decorator_' . ucfirst($formdecorator); 
    14141416        # instantiate the new $formdecorator and return 
    1415         return new $formdecorator_classname(); 
     1417        return new $class(); 
    14161418    } 
    14171419 
  • trunk/core/viewhelper/form/formdecorator.php

    r5922 r5925  
    3737} 
    3838 
     39interface Clansuite_Form_Decorator_Interface 
     40{ 
     41    public function decorateWith($form_decorator); 
     42    public function getName(); 
     43} 
     44 
    3945/** 
    4046 * Clansuite_Form_Decorator 
     
    7278    # instance of form, which is to decorate 
    7379    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    } 
    7692 
    7793    /** 
     
    96112        return $this->class; 
    97113    } 
    98      
     114 
    99115    /** 
    100116    * Set id="" 
     
    162178        } 
    163179    } 
    164      
     180 
    165181    /** 
    166182     * __call Magic Method 
     
    176192        { 
    177193            return call_user_func_array( array($this->form, $method), $parameters); 
    178         }             
     194        } 
    179195    } 
    180196} 
    181  
    182 /** 
    183  * Clansuite_Formelement_Decorator 
    184  * 
    185  * @author     Jens-André Koch  <vain@clansuite.com> 
    186  * @copyright  Jens-André Koch (2005-onwards) 
    187  * 
    188  * @category    Clansuite 
    189  * @package     Core 
    190  * @subpackage  Form 
    191  */ 
    192  
    193 abstract class Clansuite_Formelement_Decorator implements Clansuite_Formelement_Decorator_Interface 
    194 { 
    195     # instance of formelement, which is to decorate 
    196     protected $formelement; 
    197  
    198     private $class; 
    199  
    200     /** 
    201     * Set class="" 
    202     * 
    203     * @param string $classname 
    204     */ 
    205     public function setClass($classname) 
    206     { 
    207         $this->class = $classname; 
    208  
    209         return $this->formelement; 
    210     } 
    211  
    212     /** 
    213     * Get class="" values 
    214     * 
    215     * @return string 
    216     */ 
    217     public function getClass() 
    218     { 
    219         return $this->class; 
    220     } 
    221  
    222     /** 
    223      * Constructor 
    224      * 
    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_Interface 
    236      */ 
    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 $method 
    246      * @return boolean 
    247      */ 
    248     public function hasMethod($method) 
    249     { 
    250         # check if method exists in this object 
    251         if(method_exists($this, $method)) 
    252         { 
    253             return true; 
    254         } 
    255         # check if method exists in the decorator of this object 
    256         elseif($this->formelement instanceof Clansuite_Formelement_Decorator) 
    257         { 
    258             return $this->formelement->hasMethod($method); 
    259         } 
    260         else # nope, method does not exist 
    261         { 
    262             return false; 
    263         } 
    264     } 
    265  
    266     /** 
    267      * __call Magic Method 
    268      * 
    269      * In general this calls a certain method with parameters on the object which is to decorate ($form). 
    270      * 
    271      * @param $method 
    272      * @param $parameters 
    273      */ 
    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_Interface 
    281 { 
    282     public function decorateWith($formelement_decorator); 
    283 } 
    284  
    285 interface Clansuite_Form_Decorator_Interface 
    286 { 
    287     public function decorateWith($form_decorator); 
    288 } 
    289197?> 
  • trunk/core/viewhelper/form/formelement.php

    r5923 r5925  
    557557    public function getValidator($validator) 
    558558    { 
    559         # load baseclass 
    560         # @todo move to map / autoloader 
    561         if(false == class_exists('Clansuite_Formelement_Validator', false)) 
    562         { 
    563             include ROOT_CORE . 'viewhelper/form/validator.php'; 
    564         } 
    565  
    566559        # construct classname 
    567560        $class = 'Clansuite_Formelement_Validator_' . ucfirst($validator); 
     
    847840    public function decoratorFactory($decorator) 
    848841    { 
    849         # construct Clansuite_Formdecorator_Name 
     842        # construct Clansuite_Formelement_Decorator_Name 
    850843        $class = 'Clansuite_Formelement_Decorator_' . ucfirst($decorator); 
    851844 
     
    853846        if(false == class_exists($class, false)) 
    854847        { 
    855             $file = ROOT_CORE . 'viewhelper/form/formdecorators/formelement/' . $decorator . '.form.php'; 
     848            $file = ROOT_CORE . 'viewhelper/form/decorators/formelement/' . $decorator . '.form.php'; 
    856849 
    857850            if(is_file($file) === true) 
Note: See TracChangeset for help on using the changeset viewer.