developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Ticket #307: jforms.diff

File jforms.diff, 14.0 KB (added by bballizlife, 14 years ago)
  • testapp/modules/jelix_tests/tests/jforms.compiler.html.php

     
    33* @package     testapp
    44* @subpackage  unittest module
    55* @author      Jouanneau Laurent
    6 * @contributor
     6* @contributor Loic Mathaud
    77* @copyright   2007 Jouanneau laurent
     8* @copyright   2007 Loic Mathaud
    89* @link        http://www.jelix.org
    910* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
    1011*/
     
    24624758=>'<upload ref="nom" xmlns="http://jelix.org/ns/forms/1.0" mimetype="image/gif;;image/png;">
    247248    <label>Votre nom</label>
    248249</upload>',
     25059=>'<input ref="nom" size="20" xmlns="http://jelix.org/ns/forms/1.0">
     251    <label>Votre nom</label>
     252</input>',
     25360=>'<secret ref="pwd" size="10" xmlns="http://jelix.org/ns/forms/1.0">
     254    <label>Votre mot de passe</label>
     255</secret>',
     25661=>'<secret ref="pwd" size="10" xmlns="http://jelix.org/ns/forms/1.0">
     257    <label>Votre mot de passe</label>
     258    <confirm>confirmez</confirm>
     259</secret>',
     26062=>'<textarea ref="nom" cols="15" xmlns="http://jelix.org/ns/forms/1.0">
     261    <label>Votre nom</label>
     262</textarea>',
     26363=>'<textarea ref="nom" rows="15" xmlns="http://jelix.org/ns/forms/1.0">
     264    <label>Votre nom</label>
     265</textarea>',
     26664=>'<textarea ref="nom" rows="15" cols="20" xmlns="http://jelix.org/ns/forms/1.0">
     267    <label>Votre nom</label>
     268</textarea>'
    249269    );
    250270
    251271    protected $_PhpControls = array(
     
    374394$this->addControl($ctrl);',
    37539532=>'$ctrl= new jFormsControllistbox(\'nom\');
    376396$ctrl->label=\'Votre nom\';
     397$ctrl->size=8;
    377398$ctrl->datasource= new jFormStaticDatasource();
    378399$ctrl->datasource->datas = array(
    379400\'aaa\'=>\'1aa\',
    380401\'bbb\'=>jLocale::get(\'locb\'),
    381402\'ccc\'=>\'ccc\',
    382403);
    383 $ctrl->size=8;
    384404$this->addControl($ctrl);',
    38540533=>'$ctrl= new jFormsControlmenulist(\'nom\');
    386406$ctrl->label=\'Votre nom\';
     
    562582  2 => \'image/png\',
    563583);
    564584$this->addControl($ctrl);',
     58559=>'$ctrl= new jFormsControlinput(\'nom\');
     586$ctrl->label=\'Votre nom\';
     587$ctrl->size=20;
     588$this->addControl($ctrl);',
     58960=>'$ctrl= new jFormsControlsecret(\'pwd\');
     590$ctrl->label=\'Votre mot de passe\';
     591$ctrl->size=10;
     592$this->addControl($ctrl);',
     59361=>'$ctrl= new jFormsControlsecret(\'pwd\');
     594$ctrl->label=\'Votre mot de passe\';
     595$ctrl->size=10;
     596$ctrl2 = new jFormsControlSecretConfirm(\'pwd_confirm\');
     597$ctrl2->primarySecret = \'pwd\';
     598$ctrl2->label=\'confirmez\';
     599$ctrl2->required = $ctrl->required;
     600$ctrl2->readonly = $ctrl->readonly;
     601$ctrl2->size=$ctrl->size;
     602$this->addControl($ctrl);
     603$this->addControl($ctrl2);',
     60462=>'$ctrl= new jFormsControltextarea(\'nom\');
     605$ctrl->label=\'Votre nom\';
     606$ctrl->cols=15;
     607$this->addControl($ctrl);',
     60863=>'$ctrl= new jFormsControltextarea(\'nom\');
     609$ctrl->label=\'Votre nom\';
     610$ctrl->rows=15;
     611$this->addControl($ctrl);',
     61264=>'$ctrl= new jFormsControltextarea(\'nom\');
     613$ctrl->label=\'Votre nom\';
     614$ctrl->rows=15;
     615$ctrl->cols=20;
     616$this->addControl($ctrl);'
    565617);
    566618
    567619
     
    871923$js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";
    872924$js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";
    873925$js.="jForms.tForm.addControl( jForms.tControl);\n";',
     92659=>'$label = str_replace("\'","\\\'",\'Votre nom\');
     927$js.="jForms.tControl = new jFormsControl(\'nom\', \'".$label."\', \'string\');\n";
     928$js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";
     929$js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";
     930$js.="jForms.tForm.addControl( jForms.tControl);\n";',
     93160=>'$label = str_replace("\'","\\\'",\'Votre mot de passe\');
     932$js.="jForms.tControl = new jFormsControl(\'pwd\', \'".$label."\', \'string\');\n";
     933$js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";
     934$js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";
     935$js.="jForms.tForm.addControl( jForms.tControl);\n";',
     93661=>'$label = str_replace("\'","\\\'",\'Votre mot de passe\');
     937$js.="jForms.tControl = new jFormsControl(\'pwd\', \'".$label."\', \'string\');\n";
     938$label2 = str_replace("\'","\\\'",\'confirmez\');
     939$js.="jForms.tControl2 = new jFormsControl(\'pwd_confirm\', \'".$label2."\', \'string\');\n";
     940$js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";
     941$js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";
     942$js.="jForms.tControl2.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label2))."\';\n";
     943$js.="jForms.tControl2.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label2))."\';\n";
     944$js.="jForms.tForm.addControl( jForms.tControl);\n";
     945$js.="jForms.tControl2.isConfirmField=true;\njForms.tControl2.confirmFieldOf=\'pwd\';\n";
     946$js.="jForms.tForm.addControl( jForms.tControl2);\n";',
     94762=>'$label = str_replace("\'","\\\'",\'Votre nom\');
     948$js.="jForms.tControl = new jFormsControl(\'nom\', \'".$label."\', \'string\');\n";
     949$js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";
     950$js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";
     951$js.="jForms.tForm.addControl( jForms.tControl);\n";',
     95263=>'$label = str_replace("\'","\\\'",\'Votre nom\');
     953$js.="jForms.tControl = new jFormsControl(\'nom\', \'".$label."\', \'string\');\n";
     954$js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";
     955$js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";
     956$js.="jForms.tForm.addControl( jForms.tControl);\n";',
     95764=>'$label = str_replace("\'","\\\'",\'Votre nom\');
     958$js.="jForms.tControl = new jFormsControl(\'nom\', \'".$label."\', \'string\');\n";
     959$js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";
     960$js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";
     961$js.="jForms.tForm.addControl( jForms.tControl);\n";'
    874962    );
    875963
    876964    function testPhpControl(){
     
    10651153    }
    10661154}
    10671155
    1068 ?>
    1069  Pas de fin de ligne à la fin du fichier
     1156?>
  • lib/jelix/forms/jFormsCompiler.class.php

     
    33* @package    jelix
    44* @subpackage forms
    55* @author     Laurent Jouanneau
    6 * @contributor
     6* @contributor Loic Mathaud
    77* @copyright   2006-2007 Laurent Jouanneau
     8* @copyright   2007 Loic Mathaud
    89* @link        http://www.jelix.org
    910* @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
    1011*/
     
    188189            if($alertRequired !='') $source[]=$alertRequired;
    189190            if($alertInvalid !='') $source[]=$alertInvalid;
    190191        }
     192        if(isset($control['size'])){
     193            if (!in_array($controltype, array('listbox', 'input', 'secret'))) {
     194                throw new jException('jelix~formserr.attribute.not.allowed',array('size',$controltype,$this->sourceFile));
     195            }
     196            $size = intval((string)$control['size']);
     197            if($size < 2) $size = 2;
     198            $source[]='$ctrl->size='.$size.';';
     199        }
    191200        $hasCtrl2 = false;
    192201        $hasSelectedValues = false;
    193202        switch($controltype){
     
    296305                    if(isset($control->hint)){
    297306                        $source[]='$ctrl2->hint=$ctrl->hint;';
    298307                    }
     308                    if (isset($control['size'])) {
     309                        $source[]='$ctrl2->size=$ctrl->size;';
     310                    }
    299311                    $hasCtrl2 = true;
    300312                }
    301313                break;
    302314        }
    303315
     316        if (isset($control['rows'])) {
     317            if ($controltype != 'textarea') {
     318                throw new jException('jelix~formserr.attribute.not.allowed',array('rows',$controltype,$this->sourceFile));
     319            }
     320            $rows = intval((string)$control['rows']);
     321            if($rows < 2) $size = 2;
     322            $source[]='$ctrl->rows='.$rows.';';
     323        }
     324        if (isset($control['cols'])) {
     325            if ($controltype != 'textarea') {
     326                throw new jException('jelix~formserr.attribute.not.allowed',array('cols',$controltype,$this->sourceFile));
     327            }
     328            $cols = intval((string)$control['cols']);
     329            if($cols < 2) $cols = 2;
     330            $source[]='$ctrl->cols='.$cols.';';
     331        }
    304332        if(isset($control['multiple'])){
    305333            if($controltype != 'listbox'){
    306334                throw new jException('jelix~formserr.attribute.not.allowed',array('multiple',$controltype,$this->sourceFile));
     
    308336            if('true' == (string)$control['multiple'])
    309337                $source[]='$ctrl->multiple=true;';
    310338        }
    311         if(isset($control['size'])){
    312             if($controltype != 'listbox'){
    313                 throw new jException('jelix~formserr.attribute.not.allowed',array('size',$controltype,$this->sourceFile));
    314             }
    315             $size = intval((string)$control['size']);
    316             if($size < 2) $size = 2;
    317             $source[]='$ctrl->size='.$size.';';
    318         }
    319339
    320340        if(isset($control['valueoncheck']) || isset($control['valueonuncheck'])){
    321341            if($controltype != 'checkbox'){
     
    456476    }
    457477}
    458478
    459 ?>
    460  Pas de fin de ligne à la fin du fichier
     479?>
  • lib/jelix/forms/jFormsControl.class.php

     
    33* @package     jelix
    44* @subpackage  forms
    55* @author      Laurent Jouanneau
    6 * @contributor
     6* @contributor Loic Mathaud
    77* @copyright   2006-2007 Laurent Jouanneau
     8* @copyright   2007 Loic Mathaud
    89* @link        http://www.jelix.org
    910* @licence     http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
    1011*/
     
    9293 */
    9394class jFormsControlInput extends jFormsControl {
    9495    public $type='input';
     96    public $size='';
    9597}
    9698
    9799/**
     
    193195 */
    194196class jFormsControlTextarea extends jFormsControl {
    195197    public $type='textarea';
     198    public $rows='';
     199    public $cols='';
    196200}
    197201
    198202/**
     
    202206 */
    203207class jFormsControlSecret extends jFormsControl {
    204208    public $type='secret';
     209    public $size='';
    205210}
    206211
    207212/**
     
    211216 */
    212217class jFormsControlSecretConfirm extends jFormsControl {
    213218    public $type='secretconfirm';
     219    public $size='';
    214220    public $primarySecret='';
    215221    function check($value, $form){
    216222        if($value != $form->getData($this->primarySecret))
     
    303309    }
    304310}
    305311
    306 ?>
    307  Pas de fin de ligne à la fin du fichier
     312?>
  • lib/jelix/forms/jFormsBuilderBase.class.php

     
    33* @package     jelix
    44* @subpackage  forms
    55* @author      Laurent Jouanneau
    6 * @contributor
     6* @contributor Loic Mathaud
    77* @copyright   2006-2007 Laurent Jouanneau
     8* @copyright   2007 Loic Mathaud
    89* @link        http://www.jelix.org
    910* @licence     http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
    1011*/
     
    138139                    }else{
    139140                        echo '<li>', jLocale::get('jelix~formserr.js.err.required', $ctrls[$cname]->label),'</li>';
    140141                    }
     142                }elseif ($err != '') {
     143                    echo '<li>', $err,'</li>';
    141144                }else{
    142145                    if($ctrls[$cname]->alertInvalid){
    143146                        echo '<li>', $ctrls[$cname]->alertInvalid,'</li>';
     
    175178        switch($ctrl->type){
    176179        case 'input':
    177180            $value = $this->_form->getData($ctrl->ref);
    178             echo '<input type="text"',$id,$readonly,$hint,$class,' value="',htmlspecialchars($value),'"',$this->_endt;
     181            $size = ($ctrl->size == ''?'' : ' size="'.$ctrl->size.'"');
     182            echo '<input type="text"',$id,$readonly,$hint,$class,$size,' value="',htmlspecialchars($value),'"',$this->_endt;
    179183            break;
    180184        case 'checkbox':
    181185            $value = $this->_form->getData($ctrl->ref);
     
    282286            break;
    283287        case 'textarea':
    284288            $value = $this->_form->getData($ctrl->ref);
    285             echo '<textarea',$id,$readonly,$hint,$class,'>',htmlspecialchars($value),'</textarea>';
     289            $rows = ($ctrl->rows == ''?'': ' rows="'.$ctrl->rows.'"');
     290            $cols = ($ctrl->cols == ''?'': ' cols="'.$ctrl->cols.'"');
     291            echo '<textarea',$id,$readonly,$hint,$class,$rows,$cols,'>',htmlspecialchars($value),'</textarea>';
    286292            break;
    287293        case 'secret':
    288294        case 'secretconfirm':
    289             echo '<input type="password"',$id,$readonly,$hint,$class,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"',$this->_endt;
     295            $size = ($ctrl->size == ''?'': ' size="'.$ctrl->size.'"');
     296            echo '<input type="password"',$id,$readonly,$hint,$class,$size,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"',$this->_endt;
    290297            break;
    291298        case 'output':
    292299            $value = $this->_form->getData($ctrl->ref);
     
    325332}
    326333
    327334
    328 ?>
    329  Pas de fin de ligne à la fin du fichier
     335?>