Changeset 1031

Show
Ignore:
Timestamp:
07/20/08 00:45:53 (1 month ago)
Author:
laurentj
Message:

jforms: change the api of template plugin {form} and {formfull}.
now it is $form, $action, $action_parameters, $builder_name, $builder_options.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/jelix/forms/jFormsBase.class.php

    r1030 r1031  
    553553     */ 
    554554    public function getBuilder($buildertype){ 
     555        if($buildertype == '') $buildertype = 'html'; 
    555556        if(isset($this->builders[$buildertype])){ 
    556557            if(isset($this->builders[$buildertype]['inst'])) 
  • trunk/lib/jelix/plugins/jforms/html/html.jformsbuilder.php

    r1030 r1031  
    8282    /** 
    8383     * output the header content of the form 
    84      * @param array $params some parameters 0=>name of the javascript error decorator 
    85      *    1=> name of the javascript help decorator 
    86      *    2=> name of method 
     84     * @param array $params some parameters <ul> 
     85     *      <li>"errDecorator"=>"name of your javascript object for error listener"</li> 
     86     *      <li>"helpDecorator"=>"name of your javascript object for help listener"</li> 
     87     *      <li>"method" => "post" or "get". default is "post"</li> 
     88     *      </ul> 
    8789     */ 
    8890    public function outputHeader($params){ 
     91        $params = array_merge(array('errorDecorator'=>'jFormsErrorDecoratorAlert', 
     92                 'helpDecorator'=>'jFormsHelpDecoratorAlert', 'method'=>'post'), $params); 
     93 
    8994        $url = jUrl::get($this->_action, $this->_actionParams, 2); // retourne le jurl correspondant 
    90         echo '<form action="',$url->scriptName,$url->pathInfo,'" method="'.$params[2].'" id="', $this->_name,'"'; 
     95        echo '<form action="',$url->scriptName,$url->pathInfo,'" method="'.$params['method'].'" id="', $this->_name,'"'; 
    9196        if($this->_form->hasUpload()) 
    9297            echo ' enctype="multipart/form-data">'; 
     
    107112        echo '<script type="text/javascript"> 
    108113//<![CDATA[ 
    109 ', $this->getJavascriptCheck($params[0],$params[1]),' 
     114', $this->getJavascriptCheck($params['errorDecorator'],$params['helpDecorator']),' 
    110115//]]> 
    111116</script>'; 
  • trunk/lib/jelix/plugins/tpl/html/block.form.php

    r1030 r1031  
    1616 * usage : {form $theformobject,'submit_action', $submit_action_params} here form content {/form} 
    1717 * 
    18  * You can add this others parameters : 
    19  *   string $errDecorator name of your javascript object for error listener<br/> 
    20  *   string $helpDecorator name of your javascript object for help listener<br/> 
    21  *   string $method : the method of submit : post or get 
     18 * You can add this others parameters :<ul> 
     19 *   <li>string $builderName  (default is 'html')</li> 
     20 *   <li>array  $options for the builder. Example, for the 'html' builder : <ul> 
     21 *      <li>"errDecorator"=>"name of your javascript object for error listener"</li> 
     22 *      <li>"helpDecorator"=>"name of your javascript object for help listener"</li> 
     23 *      <li>"method" => "post" or "get". default is "post"</li> 
     24 *      </ul> 
     25 *    </li> 
     26 *  </ul> 
    2227 * 
    2328 * @param jTplCompiler $compiler the template compiler 
     
    2631 *                     1=>selector of submit action   
    2732 *                     2=>array of parameters for submit action  
    28  *                     3=>name of your javascript object for error listener 
    29  *                     4=>name of your javascript object for help listener 
    30  *                     5=>name of the method : 'post' or 'get' 
    31  *                     6=>name of the builder : default is html 
     33 *                     3=>name of the builder : default is html 
     34 *                     4=>array of options for the builder 
    3235 * @return string the php code corresponding to the begin or end of the block 
    3336 * @see jForms 
     
    4346    } 
    4447 
    45     if(count($param) < 2 || count($param) > 7){ 
    46         $compiler->doError2('errors.tplplugin.block.bad.argument.number','form','2-7'); 
     48    if(count($param) < 2 || count($param) > 5){ 
     49        $compiler->doError2('errors.tplplugin.block.bad.argument.number','form','2-5'); 
    4750        return ''; 
    4851    } 
     
    5255 
    5356    if(isset($param[3]) && $param[3] != '""'  && $param[3] != "''") 
    54         $errdecorator = $param[3]; 
    55     else 
    56         $errdecorator = "'jFormsErrorDecoratorAlert'"; 
    57  
    58     if(isset($param[4]) && $param[4] != '""'  && $param[4] != "''") 
    59         $helpdecorator = $param[4]; 
    60     else 
    61         $helpdecorator = "'jFormsHelpDecoratorAlert'"; 
    62  
    63     $method = isset($param[5])?$param[5]:'\'post\''; 
    64  
    65     if(isset($param[6]) && $param[6] != '""'  && $param[6] != "''") 
    66         $builder = $param[6]; 
     57        $builder = $param[3]; 
    6758    else 
    6859        $builder = "'html'"; 
     60 
     61    if(isset($param[4])) 
     62        $options = $param[4]; 
     63    else 
     64        $options = "array()"; 
    6965 
    7066    $content = ' $t->_privateVars[\'__form\'] = '.$param[0].'; 
    7167$t->_privateVars[\'__formbuilder\'] = $t->_privateVars[\'__form\']->getBuilder('.$builder.'); 
    7268$t->_privateVars[\'__formbuilder\']->setAction('.$param[1].','.$param[2].'); 
    73 $t->_privateVars[\'__formbuilder\']->outputHeader(array('.$errdecorator.','.$helpdecorator.','.$method.')); 
     69$t->_privateVars[\'__formbuilder\']->outputHeader('.$options.'); 
    7470$t->_privateVars[\'__displayed_ctrl\'] = array(); 
    7571'; 
  • trunk/lib/jelix/plugins/tpl/html/block.ifctrl.php

    r1026 r1031  
    1313 * TO BE USED inside a {formcontrols} block 
    1414 * 
    15  * {ifctrl 'name1','name2',...}some tpl{else}some other tpl{/ifctrl} 
     15 * {ifctrl 'name1','name2',...} some tpl {else} some other tpl {/ifctrl} 
    1616 * @param jTplCompiler $compiler the template compiler 
    1717 * @param boolean $begin true if it is the begin of block, else false 
  • trunk/lib/jelix/plugins/tpl/html/cfunction.formfull.php

    r955 r1031  
    1414 * Display a full form without the use of other plugins. 
    1515 * usage : {formfull $theformobject,'submit_action', $submit_action_params} 
    16  * You can add this others parameters : 
    17  *   string $errDecorator name of your javascript object for error listener<br/> 
    18  *   string $helpDecorator name of your javascript object for help listener<br/> 
    19  *   string $method : the method of submit : 'post' or 'get' 
    20  * 
     16 *  
     17 * You can add this others parameters :<ul> 
     18 *   <li>string $builderName  (default is 'html')</li> 
     19 *   <li>array  $options for the builder. Example, for the 'html' builder : <ul> 
     20 *      <li>"errDecorator"=>"name of your javascript object for error listener"</li> 
     21 *      <li>"helpDecorator"=>"name of your javascript object for help listener"</li> 
     22 *      <li>"method" => "post" or "get". default is "post"</li> 
     23 *      </ul> 
     24 *    </li> 
     25 *  </ul> 
    2126 * @param jTplCompiler $compiler the template compiler 
    22  * @param array $params 0=>form object 
    23  *                     1=>selector of submit action 
    24  *                     2=>array of parameters for submit action 
    25  *                     3=>name of your javascript object for error listener 
    26  *                     4=>name of your javascript object for help listener 
    27  *                     5=>name of the method : POST or GET 
    28  *                     6=>name of the builder : default is html 
     27 * @param array $param 0=>form object  
     28 *                     1=>selector of submit action   
     29 *                     2=>array of parameters for submit action  
     30 *                     3=>name of the builder : default is html 
     31 *                     4=>array of options for the builder 
    2932 * @return string the php code corresponding to the begin or end of the block 
    3033 */ 
    3134function jtpl_cfunction_html_formfull($compiler, $params=array()) 
    3235{ 
    33     if (count($params) < 2 || count($params) > 7) { 
    34         $compiler->doError2('errors.tplplugin.cfunction.bad.argument.number','formfull','2-7'); 
     36    if (count($params) < 2 || count($params) > 5) { 
     37        $compiler->doError2('errors.tplplugin.cfunction.bad.argument.number','formfull','2-5'); 
    3538    } 
    3639 
    37     if(isset($params[6]) && $params[6] != '""'  && $params[6] != "''")  
    38         $builder = $params[6]; 
    39     else  
     40    if(isset($param[3]) && $param[3] != '""'  && $param[3] != "''") 
     41        $builder = $param[3]; 
     42    else 
    4043        $builder = "'html'"; 
    4144 
     
    4548        $params[2] = 'array()'; 
    4649    } 
    47     if(isset($params[3]) && $params[3] != '""'  && $params[3] != "''") 
    48         $errdecorator = $params[3]; 
     50 
     51    if(isset($param[4])) 
     52        $options = $param[4]; 
    4953    else 
    50         $errdecorator = "'jFormsErrorDecoratorAlert'"; 
    51  
    52     if(isset($params[4]) && $params[4] != '""'  && $params[4] != "''") 
    53         $helpdecorator = $params[4]; 
    54     else 
    55         $helpdecorator = "'jFormsHelpDecoratorAlert'"; 
    56  
    57     $method = isset($params[5])?$params[5]:'\'post\''; 
     54        $options = "array()"; 
    5855 
    5956    $content = ' $formfull = '.$params[0].'; 
    6057    $formfullBuilder = $formfull->getBuilder('.$builder.'); 
    6158    $formfullBuilder->setAction('.$params[1].','.$params[2].'); 
    62     $formfullBuilder->outputHeader(array('.$errdecorator.','.$helpdecorator.','.$method.')); 
     59    $formfullBuilder->outputHeader('.$options.')); 
    6360    $formfullBuilder->outputAllControls(); 
    6461    $formfullBuilder->outputFooter();'; 
  • trunk/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html_cli.php

    r1030 r1031  
    4242        $this->builder->setAction('jelix_tests~urlsig:url1',array()); 
    4343        ob_start(); 
    44         $this->builder->outputHeader(array('','','post')); 
     44        $this->builder->outputHeader(array('method'=>'post')); 
    4545        $out = ob_get_clean(); 
    4646        $result ='<form action="'.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php" method="post" id="'.$this->builder->getName().'"><div class="jforms-hiddens"><input type="hidden" name="module" value="jelix_tests"/> 
     
    5555        $this->builder->setAction('jelix_tests~urlsig:url1',array('foo'=>'b>ar')); 
    5656        ob_start(); 
    57         $this->builder->outputHeader(array('','','get')); 
     57        $this->builder->outputHeader(array('method'=>'get')); 
    5858        $out = ob_get_clean(); 
    5959        $result ='<form action="'.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php" method="get" id="'.$this->builder->getName().'"><div class="jforms-hiddens"><input type="hidden" name="foo" value="b&gt;ar"/> 
     
    791791 
    792792        ob_start(); 
    793         $this->builder->outputHeader(array('','','post')); 
     793        $this->builder->outputHeader(array('method'=>'post')); 
    794794        $out = ob_get_clean(); 
    795795        $result ='<form action="'.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php" method="post" id="'.$this->formname.'" enctype="multipart/form-data"><div class="jforms-hiddens"><input type="hidden" name="foo" value="b&gt;ar"/> 
     
    867867 
    868868        ob_start(); 
    869         $this->builder->outputHeader(array('','','post')); 
     869        $this->builder->outputHeader(array('method'=>'post')); 
    870870        $out = ob_get_clean(); 
    871871        $result ='<form action="'.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php" method="post" id="'.$this->formname.'"><div class="jforms-hiddens"><input type="hidden" name="foo" value="b&gt;ar"/> 
     
    885885        $this->form->addControl($ctrl); 
    886886        ob_start(); 
    887         $this->builder->outputHeader(array('','','post')); 
     887        $this->builder->outputHeader(array('method'=>'post')); 
    888888        $out = ob_get_clean(); 
    889889        $result ='<form action="'.$GLOBALS['gJConfig']->urlengine['basePath'].'index.php" method="post" id="'.$this->formname.'"><div class="jforms-hiddens"><input type="hidden" name="foo" value="b&gt;ar"/> 
  • trunk/testapp/modules/jelix_tests/tests/jtpl.compiler.html_cli.php

    r998 r1031  
    210210                  'jelix~errors.tpl.tag.character.invalid',array('for ($i=0;$i<$p;$i++)','(',null) ), 
    211211         4=>array('{form ($foo,$params)} aa {/form}', 
    212                   'jelix~errors.tplplugin.block.bad.argument.number',array('form','2-7',null) ), 
     212                  'jelix~errors.tplplugin.block.bad.argument.number',array('form','2-5',null) ), 
    213213         5=>array('{($aaa)}', 
    214214                  'jelix~errors.tpl.tag.syntax.invalid',array('($aaa)',null) ), 
  • trunk/testapp/modules/testapp/templates/sampleform.tpl

    r1030 r1031  
    2727</script> 
    2828 
    29 {form $form,'sampleform:save', array(), 'myErrorDecorator'
     29{form $form,'sampleform:save', array(), 'html', array('errorDecorator'=>'myErrorDecorator')
    3030    {formcontrols} 
    3131    <div>{ctrl_label}: {ctrl_control}</div> 
Download in other formats: Unified Diff Zip Archive