Changeset 442
- Timestamp:
- 05/22/07 23:18:05 (2 years ago)
- Files:
-
- branches/experimental/jforms/build/manifests/jelix-lib.mn (modified) (1 diff)
- branches/experimental/jforms/build/manifests/jelix-lib.mn (modified) (1 diff)
- branches/experimental/jforms/lib/jelix/docs/ns/jforms-controls.rng (modified) (5 diffs)
- branches/experimental/jforms/lib/jelix/docs/ns/jforms-controls.rng (modified) (5 diffs)
- branches/experimental/jforms/lib/jelix/forms/jFormsBuilderBase.class.php (modified) (2 diffs)
- branches/experimental/jforms/lib/jelix/forms/jFormsBuilderBase.class.php (modified) (2 diffs)
- branches/experimental/jforms/lib/jelix/forms/jFormsCompiler.class.php (modified) (3 diffs)
- branches/experimental/jforms/lib/jelix/forms/jFormsCompiler.class.php (modified) (3 diffs)
- branches/experimental/jforms/lib/jelix/forms/jFormsControl.class.php (modified) (1 diff)
- branches/experimental/jforms/lib/jelix/forms/jFormsControl.class.php (modified) (1 diff)
- branches/experimental/jforms/lib/jelix/tpl/jTpl.class.php (modified) (1 diff)
- branches/experimental/jforms/lib/jelix/tpl/jTpl.class.php (modified) (1 diff)
- branches/experimental/jforms/lib/jelix/tpl/plugins/html/block.form.php (modified) (2 diffs)
- branches/experimental/jforms/lib/jelix/tpl/plugins/html/block.form.php (modified) (2 diffs)
- branches/experimental/jforms/lib/jelix/tpl/plugins/html/block.formcontrols.php (added)
- branches/experimental/jforms/lib/jelix/tpl/plugins/html/block.formcontrols.php (added)
- branches/experimental/jforms/lib/jelix/tpl/plugins/html/function.ctrl_control.php (added)
- branches/experimental/jforms/lib/jelix/tpl/plugins/html/function.ctrl_control.php (added)
- branches/experimental/jforms/lib/jelix/tpl/plugins/html/function.ctrl_label.php (added)
- branches/experimental/jforms/lib/jelix/tpl/plugins/html/function.ctrl_label.php (added)
- branches/experimental/jforms/lib/jelix/tpl/plugins/html/function.ctrl_value.php (added)
- branches/experimental/jforms/lib/jelix/tpl/plugins/html/function.ctrl_value.php (added)
- branches/experimental/jforms/testapp/modules/testapp/controllers/sampleform.classic.php (modified) (1 diff)
- branches/experimental/jforms/testapp/modules/testapp/controllers/sampleform.classic.php (modified) (1 diff)
- branches/experimental/jforms/testapp/modules/testapp/forms/sample.form.xml (modified) (1 diff)
- branches/experimental/jforms/testapp/modules/testapp/forms/sample.form.xml (modified) (1 diff)
- branches/experimental/jforms/testapp/modules/testapp/templates/sampleform.tpl (modified) (1 diff)
- branches/experimental/jforms/testapp/modules/testapp/templates/sampleform.tpl (modified) (1 diff)
- branches/experimental/jforms/testapp/modules/testapp/templates/sampleformresult.tpl (modified) (1 diff)
- branches/experimental/jforms/testapp/modules/testapp/templates/sampleformresult.tpl (modified) (1 diff)
- branches/experimental/jforms/testapp/modules/unittest/classes/utjforms.class.php (modified) (1 diff)
- branches/experimental/jforms/testapp/modules/unittest/classes/utjforms.class.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/experimental/jforms/build/manifests/jelix-lib.mn
r441 r442 155 155 function.diff.php 156 156 block.form.php 157 block.formcontrols.php 158 function.ctrl_control.php 159 function.ctrl_label.php 160 function.ctrl_value.php 157 161 158 162 cd lib/jelix/tpl/plugins/ltx2pdf branches/experimental/jforms/build/manifests/jelix-lib.mn
r441 r442 155 155 function.diff.php 156 156 block.form.php 157 block.formcontrols.php 158 function.ctrl_control.php 159 function.ctrl_label.php 160 function.ctrl_value.php 157 161 158 162 cd lib/jelix/tpl/plugins/ltx2pdf branches/experimental/jforms/lib/jelix/docs/ns/jforms-controls.rng
r437 r442 38 38 <attribute name="appearance"> 39 39 <choice> 40 <value>full</value> 41 <value>compact</value> 42 <value>minimal</value> 40 <value>full</value> checkbox /radiobox 41 <value>compact</value> listbox multiple /listbox 42 <value>minimal</value> listbox multiple / combobox 43 43 </choice> 44 44 </attribute> … … 150 150 <ref name="UI.Common" /> 151 151 <ref name="List.UI.Common" /> 152 <optional> 152 <optional> 153 <attribute name="appearance"> 154 <choice> 155 <value>full</value> 156 <value>radiobox</value> 157 <value>compact</value> 158 <value>listbox</value> 159 <value>minimal</value> 160 <value>menulist</value> 161 </choice> 162 </attribute> 163 </optional> 164 165 <!-- <optional> 153 166 <attribute name="selection"> 154 167 <choice> … … 157 170 </choice> 158 171 </attribute> 159 </optional> 172 </optional>--> 160 173 </element> 161 174 </define> … … 167 180 <ref name="List.UI.Common" /> 168 181 <optional> 182 <attribute name="appearance"> 183 <choice> 184 <value>full</value> 185 <value>checkbox</value> 186 <value>compact</value> 187 <value>listbox</value> 188 </choice> 189 </attribute> 190 </optional> 191 <!--<optional> 169 192 <attribute name="selection"> 170 193 <choice> … … 173 196 </choice> 174 197 </attribute> 175 </optional> 198 </optional>--> 176 199 </element> 177 200 </define> branches/experimental/jforms/lib/jelix/docs/ns/jforms-controls.rng
r437 r442 38 38 <attribute name="appearance"> 39 39 <choice> 40 <value>full</value> 41 <value>compact</value> 42 <value>minimal</value> 40 <value>full</value> checkbox /radiobox 41 <value>compact</value> listbox multiple /listbox 42 <value>minimal</value> listbox multiple / combobox 43 43 </choice> 44 44 </attribute> … … 150 150 <ref name="UI.Common" /> 151 151 <ref name="List.UI.Common" /> 152 <optional> 152 <optional> 153 <attribute name="appearance"> 154 <choice> 155 <value>full</value> 156 <value>radiobox</value> 157 <value>compact</value> 158 <value>listbox</value> 159 <value>minimal</value> 160 <value>menulist</value> 161 </choice> 162 </attribute> 163 </optional> 164 165 <!-- <optional> 153 166 <attribute name="selection"> 154 167 <choice> … … 157 170 </choice> 158 171 </attribute> 159 </optional> 172 </optional>--> 160 173 </element> 161 174 </define> … … 167 180 <ref name="List.UI.Common" /> 168 181 <optional> 182 <attribute name="appearance"> 183 <choice> 184 <value>full</value> 185 <value>checkbox</value> 186 <value>compact</value> 187 <value>listbox</value> 188 </choice> 189 </attribute> 190 </optional> 191 <!--<optional> 169 192 <attribute name="selection"> 170 193 <choice> … … 173 196 </choice> 174 197 </attribute> 175 </optional> 198 </optional>--> 176 199 </element> 177 200 </define> branches/experimental/jforms/lib/jelix/forms/jFormsBuilderBase.class.php
r441 r442 55 55 } 56 56 57 public function getName(){ return $this->_name; } 57 58 58 59 abstract public function outputHeader(); 59 60 60 61 abstract public function outputFooter(); 62 63 abstract public function outputControl($ctrl); 64 abstract public function outputControlLabel($ctrl); 61 65 62 66 public static function generateFormName(){ … … 87 91 } 88 92 93 public function outputControlLabel($ctrl){ 94 if($ctrl->type == 'output'){ 95 echo htmlspecialchars($ctrl->label); 96 } 97 if($ctrl->type != 'submit'){ 98 $id = $this->_name.'_'.$ctrl->ref; 99 echo '<label for="'.$id.'">'.htmlspecialchars($ctrl->label).'</label>'; 100 } 101 } 102 103 public function outputControl($ctrl){ 104 $id = 'name="'.$ctrl->ref.'" id="'$this->_name.'_'.$ctrl->ref.'"'; 105 $readonly = ($ctrl->readonly?' readonly="readonly"':''); 106 switch($ctrl->type){ 107 case 'input': 108 echo '<input type="text" ',$id,$readonly,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"/>'; 109 break; 110 case 'select1': 111 break; 112 case 'select': 113 break; 114 case 'textarea': 115 echo '<textarea ',$id,$readonly,'>',htmlspecialchars($this->_form->getData($ctrl->ref)),'</textarea>'; 116 break; 117 case 'secret': 118 echo '<input type="password" ',$id,$readonly,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"/>'; 119 break; 120 case 'output': 121 echo '<input type="hidden" ',$id,$readonly,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"/>'; 122 echo htmlspecialchars($this->_form->getData($ctrl->ref)); 123 break; 124 case 'upload': 125 echo '<input type="file" ',$id,$readonly,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"/>'; 126 break; 127 case 'submit': 128 echo '<button type="submit" ',$id,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'">',htmlspecialchars($ctrl->label),'</button>'; 129 break; 130 } 131 } 132 133 89 134 abstract public function getJavascriptCheck(); 90 135 } branches/experimental/jforms/lib/jelix/forms/jFormsBuilderBase.class.php
r441 r442 55 55 } 56 56 57 public function getName(){ return $this->_name; } 57 58 58 59 abstract public function outputHeader(); 59 60 60 61 abstract public function outputFooter(); 62 63 abstract public function outputControl($ctrl); 64 abstract public function outputControlLabel($ctrl); 61 65 62 66 public static function generateFormName(){ … … 87 91 } 88 92 93 public function outputControlLabel($ctrl){ 94 if($ctrl->type == 'output'){ 95 echo htmlspecialchars($ctrl->label); 96 } 97 if($ctrl->type != 'submit'){ 98 $id = $this->_name.'_'.$ctrl->ref; 99 echo '<label for="'.$id.'">'.htmlspecialchars($ctrl->label).'</label>'; 100 } 101 } 102 103 public function outputControl($ctrl){ 104 $id = 'name="'.$ctrl->ref.'" id="'$this->_name.'_'.$ctrl->ref.'"'; 105 $readonly = ($ctrl->readonly?' readonly="readonly"':''); 106 switch($ctrl->type){ 107 case 'input': 108 echo '<input type="text" ',$id,$readonly,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"/>'; 109 break; 110 case 'select1': 111 break; 112 case 'select': 113 break; 114 case 'textarea': 115 echo '<textarea ',$id,$readonly,'>',htmlspecialchars($this->_form->getData($ctrl->ref)),'</textarea>'; 116 break; 117 case 'secret': 118 echo '<input type="password" ',$id,$readonly,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"/>'; 119 break; 120 case 'output': 121 echo '<input type="hidden" ',$id,$readonly,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"/>'; 122 echo htmlspecialchars($this->_form->getData($ctrl->ref)); 123 break; 124 case 'upload': 125 echo '<input type="file" ',$id,$readonly,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'"/>'; 126 break; 127 case 'submit': 128 echo '<button type="submit" ',$id,' value="',htmlspecialchars($this->_form->getData($ctrl->ref)),'">',htmlspecialchars($ctrl->label),'</button>'; 129 break; 130 } 131 } 132 133 89 134 abstract public function getJavascriptCheck(); 90 135 } branches/experimental/jforms/lib/jelix/forms/jFormsCompiler.class.php
r441 r442 132 132 $label=''; 133 133 $labellocale=(string)$control->label['locale']; 134 $source[]='$ctrl->label locale=\''.$labellocale.'\';';134 $source[]='$ctrl->label=jLocale::get(\''.$labellocale.'\');'; 135 135 }else{ 136 136 $label=(string)$control->label; … … 201 201 } 202 202 203 /* 204 203 /* 205 204 switch($controltype){ 206 205 case 'secret': … … 301 300 $js.="jForms.declareForm(gForm);\n"; 302 301 303 // le code php qui génère le php304 305 $js="gForm = new jFormsForm('".$this->getFormName()."');\n";306 $js.="gForm.setDecorator(new jFormsErrorDecoratorAlert());\n";307 $label = 'a label';308 ou309 $label = jLocale::get('mod~cle_locale_user');310 $js.="gControl = new jFormsControl('name', '".str_replace("'","\\'", $label)."', 'datatype');\n";311 $js.="gControl.required = true;\n";312 313 $invalid = jLocale::get('jelix~forms.check.invalid',$label));314 ou315 $invalid = jLocale::get('mod~cle_locale_user');316 ou317 $invalid = 'bla bla';318 $js.="gControl.errInvalid='".str_replace("'","\\'",$invalid)."';\n";319 320 321 $required = jLocale::get('jelix~forms.check.required',$label));322 ou323 $required = jLocale::get('mod~cle_locale_user');324 ou325 $required = 'bla bla';326 327 $js.="gControl.errRequired='".str_replace("'","\\'",$required)."';\n";328 $js.="gForm.addControl( gControl);\n";329 ...330 $js.="jForms.declareForm(gForm);\n";331 332 333 334 302 */ 335 336 337 303 } 338 304 339 /**340 *341 * @package jelix342 * @subpackage forms343 * @experimental344 */345 interface jIFormGenerator {346 347 // on indique un objet form348 // il renvoi dans un tableau le code généré correspondant349 /*350 startform : code généré pour le debut du formulaire (balise <form> en html) Peut contenir %ATTR%351 head : code généré à ajouter dans l'en-tête de page352 controls : tableau assoc de chaque contrôle généré. Peuvent contenir %ATTR%353 endform : code généré pour la fin du formulaire354 355 356 %ATTR% : remplacés par les attributs supplémentaires indiqués par l'utilisateur dans le template357 */358 function buildForm($formObject);359 360 }361 362 363 305 ?> branches/experimental/jforms/lib/jelix/forms/jFormsCompiler.class.php
r441 r442 132 132 $label=''; 133 133 $labellocale=(string)$control->label['locale']; 134 $source[]='$ctrl->label locale=\''.$labellocale.'\';';134 $source[]='$ctrl->label=jLocale::get(\''.$labellocale.'\');'; 135 135 }else{ 136 136 $label=(string)$control->label; … … 201 201 } 202 202 203 /* 204 203 /* 205 204 switch($controltype){ 206 205 case 'secret': … … 301 300 $js.="jForms.declareForm(gForm);\n"; 302 301 303 // le code php qui génère le php304 305 $js="gForm = new jFormsForm('".$this->getFormName()."');\n";306 $js.="gForm.setDecorator(new jFormsErrorDecoratorAlert());\n";307 $label = 'a label';308 ou309 $label = jLocale::get('mod~cle_locale_user');310 $js.="gControl = new jFormsControl('name', '".str_replace("'","\\'", $label)."', 'datatype');\n";311 $js.="gControl.required = true;\n";312 313 $invalid = jLocale::get('jelix~forms.check.invalid',$label));314 ou315 $invalid = jLocale::get('mod~cle_locale_user');316 ou317 $invalid = 'bla bla';318 $js.="gControl.errInvalid='".str_replace("'","\\'",$invalid)."';\n";319 320 321 $required = jLocale::get('jelix~forms.check.required',$label));322 ou323 $required = jLocale::get('mod~cle_locale_user');324 ou325 $required = 'bla bla';326 327 $js.="gControl.errRequired='".str_replace("'","\\'",$required)."';\n";328 $js.="gForm.addControl( gControl);\n";329 ...330 $js.="jForms.declareForm(gForm);\n";331 332 333 334 302 */ 335 336 337 303 } 338 304 339 /**340 *341 * @package jelix342 * @subpackage forms343 * @experimental344 */345 interface jIFormGenerator {346 347 // on indique un objet form348 // il renvoi dans un tableau le code généré correspondant349 /*350 startform : code généré pour le debut du formulaire (balise <form> en html) Peut contenir %ATTR%351 head : code généré à ajouter dans l'en-tête de page352 controls : tableau assoc de chaque contrôle généré. Peuvent contenir %ATTR%353 endform : code généré pour la fin du formulaire354 355 356 %ATTR% : remplacés par les attributs supplémentaires indiqués par l'utilisateur dans le template357 */358 function buildForm($formObject);359 360 }361 362 363 305 ?> branches/experimental/jforms/lib/jelix/forms/jFormsControl.class.php
r432 r442 23 23 public $readonly=false; 24 24 public $label=''; 25 public $labellocale='';26 25 27 26 public $value=''; branches/experimental/jforms/lib/jelix/forms/jFormsControl.class.php
r432 r442 23 23 public $readonly=false; 24 24 public $label=''; 25 public $labellocale='';26 25 27 26 public $value=''; branches/experimental/jforms/lib/jelix/tpl/jTpl.class.php
r436 r442 23 23 */ 24 24 public $_vars = array (); 25 26 /** 27 * temporary template variables for plugins. Public because Internal use. Don't touch it :-) 28 * @var array 29 */ 30 public $_privateVars = array (); 31 25 32 26 33 /** branches/experimental/jforms/lib/jelix/tpl/jTpl.class.php
r436 r442 23 23 */ 24 24 public $_vars = array (); 25 26 /** 27 * temporary template variables for plugins. Public because Internal use. Don't touch it :-) 28 * @var array 29 */ 30 public $_privateVars = array (); 31 25 32 26 33 /** branches/experimental/jforms/lib/jelix/tpl/plugins/html/block.form.php
r441 r442 24 24 25 25 if(!$begin){ 26 return '$builder->outputFooter(); $form = null; $builder=null;'; 26 return '$t->_privateVars[\'__builder\']->outputFooter(); 27 unset($t->_privateVars[\'__form\']); 28 unset($t->_privateVars[\'__builder\']);'; 27 29 } 28 30 … … 35 37 } 36 38 37 $content = ' $ form= '.$param[0].';38 $ builder = $form->getBuilder(\'html\', '.$param[1].','.$param[2].');39 $ builder->outputHeader();39 $content = ' $t->_privateVars[\'__form\'] = '.$param[0].'; 40 $t->_privateVars[\'__builder\'] = $t->_privateVars[\'__form\']->getBuilder(\'html\', '.$param[1].','.$param[2].'); 41 $t->_privateVars[\'__builder\']->outputHeader(); 40 42 '; 41 43 branches/experimental/jforms/lib/jelix/tpl/plugins/html/block.form.php
r441 r442 24 24 25 25 if(!$begin){ 26 return '$builder->outputFooter(); $form = null; $builder=null;'; 26 return '$t->_privateVars[\'__builder\']->outputFooter(); 27 unset($t->_privateVars[\'__form\']); 28 unset($t->_privateVars[\'__builder\']);'; 27 29 } 28 30 … … 35 37 } 36 38 37 $content = ' $ form= '.$param[0].';38 $ builder = $form->getBuilder(\'html\', '.$param[1].','.$param[2].');39 $ builder->outputHeader();39 $content = ' $t->_privateVars[\'__form\'] = '.$param[0].'; 40 $t->_privateVars[\'__builder\'] = $t->_privateVars[\'__form\']->getBuilder(\'html\', '.$param[1].','.$param[2].'); 41 $t->_privateVars[\'__builder\']->outputHeader(); 40 42 '; 41 43 branches/experimental/jforms/testapp/modules/testapp/controllers/sampleform.classic.php
r441 r442 53 53 54 54 if($form){ 55 $datas=$form->getContainer()->datas;56 57 55 $tpl = new jTpl(); 58 $tpl->assign('nom', $datas['nom']); 59 $tpl->assign('prenom', $datas['prenom']); 56 $tpl->assign('form', $form); 60 57 $rep->body->assign('MAIN',$tpl->fetch('sampleformresult')); 61 58 }else{ branches/experimental/jforms/testapp/modules/testapp/controllers/sampleform.classic.php
r441 r442 53 53 54 54 if($form){ 55 $datas=$form->getContainer()->datas;56 57 55 $tpl = new jTpl(); 58 $tpl->assign('nom', $datas['nom']); 59 $tpl->assign('prenom', $datas['prenom']); 56 $tpl->assign('form', $form); 60 57 $rep->body->assign('MAIN',$tpl->fetch('sampleformresult')); 61 58 }else{ branches/experimental/jforms/testapp/modules/testapp/forms/sample.form.xml
r436 r442 1 <?xml version="1.0" encoding=" iso-8859-1"?>1 <?xml version="1.0" encoding="utf-8"?> 2 2 <forms xmlns="http://jelix.org/ns/forms/1.0"> 3 3 branches/experimental/jforms/testapp/modules/testapp/forms/sample.form.xml
r436 r442 1 <?xml version="1.0" encoding=" iso-8859-1"?>1 <?xml version="1.0" encoding="utf-8"?> 2 2 <forms xmlns="http://jelix.org/ns/forms/1.0"> 3 3 branches/experimental/jforms/testapp/modules/testapp/templates/sampleform.tpl
r441 r442 4 4 <fieldset> 5 5 <legend>Votre identité</legend> 6 <p><label for="nom">Nom :</label> <input type="text" name="nom" id="nom" value="{$form->getData('nom')}"/></p>7 <p> <label for="prenom">Prenom :</label> <input type="text" name="prenom" id="prenom" value="{$form->getData('prenom')}" /></p>8 6 {formcontrols} 7 <p>{ctrl_label}: {ctrl_control}</p> 8 {/formcontrols} 9 9 </fieldset> 10 10 <p><input type="submit" value="ok" /></p> branches/experimental/jforms/testapp/modules/testapp/templates/sampleform.tpl
r441 r442 4 4 <fieldset> 5 5 <legend>Votre identité</legend> 6 <p><label for="nom">Nom :</label> <input type="text" name="nom" id="nom" value="{$form->getData('nom')}"/></p>7 <p> <label for="prenom">Prenom :</label> <input type="text" name="prenom" id="prenom" value="{$form->getData('prenom')}" /></p>8 6 {formcontrols} 7 <p>{ctrl_label}: {ctrl_control}</p> 8 {/formcontrols} 9 9 </fieldset> 10 10 <p><input type="submit" value="ok" /></p> branches/experimental/jforms/testapp/modules/testapp/templates/sampleformresult.tpl
r310 r442 2 2 <p>Contenu du formulaire :</p> 3 3 <dl> 4 <dt>Nom :</dt>5 <dd>{$nom}</dd>6 <dt>Prenom :</dt>7 <dd>{$prenom}</dd>4 {formcontrols $form} 5 <dt>{ctrl_label}</dt> 6 <dd>{ctrl_value}</dd> 7 {/formcontrols} 8 8 </dl> branches/experimental/jforms/testapp/modules/testapp/templates/sampleformresult.tpl
r310 r442 2 2 <p>Contenu du formulaire :</p> 3 3 <dl> 4 <dt>Nom :</dt>5 <dd>{$nom}</dd>6 <dt>Prenom :</dt>7 <dd>{$prenom}</dd>4 {formcontrols $form} 5 <dt>{ctrl_label}</dt> 6 <dd>{ctrl_value}</dd> 7 {/formcontrols} 8 8 </dl> branches/experimental/jforms/testapp/modules/unittest/classes/utjforms.class.php
r439 r442 143 143 3=>'$ctrl= new jFormsControlinput(\'nom\'); 144 144 $ctrl->datatype= new jDatatypeString(); 145 $ctrl->label locale=\'foo~bar\';145 $ctrl->label=jLocale::get(\'foo~bar\'); 146 146 $this->addControl($ctrl);', 147 147 branches/experimental/jforms/testapp/modules/unittest/classes/utjforms.class.php
r439 r442 143 143 3=>'$ctrl= new jFormsControlinput(\'nom\'); 144 144 $ctrl->datatype= new jDatatypeString(); 145 $ctrl->label locale=\'foo~bar\';145 $ctrl->label=jLocale::get(\'foo~bar\'); 146 146 $this->addControl($ctrl);', 147 147
