Changeset 840
- Timestamp:
- 03/25/08 15:40:30 (8 months ago)
- Files:
-
- trunk/build/manifests/jelix-lib.mn (modified) (3 diffs)
- trunk/build/manifests/jelix-lib.mn (modified) (3 diffs)
- trunk/build/manifests/jelix-lib.mn (modified) (3 diffs)
- trunk/lib/jelix/core-modules/jelix/locales/en_EN/captcha.ISO-8859-1.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/en_EN/captcha.ISO-8859-1.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/en_EN/captcha.ISO-8859-1.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/en_EN/captcha.ISO-8859-15.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/en_EN/captcha.ISO-8859-15.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/en_EN/captcha.ISO-8859-15.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/en_EN/captcha.UTF-8.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/en_EN/captcha.UTF-8.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/en_EN/captcha.UTF-8.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/en_US/captcha.ISO-8859-1.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/en_US/captcha.ISO-8859-1.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/en_US/captcha.ISO-8859-1.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/en_US/captcha.ISO-8859-15.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/en_US/captcha.ISO-8859-15.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/en_US/captcha.ISO-8859-15.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/en_US/captcha.UTF-8.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/en_US/captcha.UTF-8.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/en_US/captcha.UTF-8.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/fr_FR/captcha.ISO-8859-1.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/fr_FR/captcha.ISO-8859-1.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/fr_FR/captcha.ISO-8859-1.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/fr_FR/captcha.ISO-8859-15.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/fr_FR/captcha.ISO-8859-15.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/fr_FR/captcha.ISO-8859-15.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/fr_FR/captcha.UTF-8.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/fr_FR/captcha.UTF-8.properties (added)
- trunk/lib/jelix/core-modules/jelix/locales/fr_FR/captcha.UTF-8.properties (added)
- trunk/lib/jelix/forms/jFormsCompiler.class.php (modified) (2 diffs)
- trunk/lib/jelix/forms/jFormsCompiler.class.php (modified) (2 diffs)
- trunk/lib/jelix/forms/jFormsCompiler.class.php (modified) (2 diffs)
- trunk/lib/jelix/forms/jFormsControl.class.php (modified) (1 diff)
- trunk/lib/jelix/forms/jFormsControl.class.php (modified) (1 diff)
- trunk/lib/jelix/forms/jFormsControl.class.php (modified) (1 diff)
- trunk/lib/jelix/forms/jFormsDataContainer.class.php (modified) (2 diffs)
- trunk/lib/jelix/forms/jFormsDataContainer.class.php (modified) (2 diffs)
- trunk/lib/jelix/forms/jFormsDataContainer.class.php (modified) (2 diffs)
- trunk/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (1 diff)
- trunk/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (1 diff)
- trunk/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (1 diff)
- trunk/lib/jelix/plugins/tpl/html/block.formcontrols.php (modified) (1 diff)
- trunk/lib/jelix/plugins/tpl/html/block.formcontrols.php (modified) (1 diff)
- trunk/lib/jelix/plugins/tpl/html/block.formcontrols.php (modified) (1 diff)
- trunk/lib/jelix/plugins/tpl/html/function.ctrl_label.php (modified) (1 diff)
- trunk/lib/jelix/plugins/tpl/html/function.ctrl_label.php (modified) (1 diff)
- trunk/lib/jelix/plugins/tpl/html/function.ctrl_label.php (modified) (1 diff)
- trunk/lib/jelix/plugins/tpl/html/function.ctrl_value.php (modified) (1 diff)
- trunk/lib/jelix/plugins/tpl/html/function.ctrl_value.php (modified) (1 diff)
- trunk/lib/jelix/plugins/tpl/html/function.ctrl_value.php (modified) (1 diff)
- trunk/lib/jelix/plugins/tpl/html/function.formdatafull.php (modified) (1 diff)
- trunk/lib/jelix/plugins/tpl/html/function.formdatafull.php (modified) (1 diff)
- trunk/lib/jelix/plugins/tpl/html/function.formdatafull.php (modified) (1 diff)
- trunk/testapp/modules/jelix_tests/tests/jforms.check_datas.html_cli.php (modified) (1 diff)
- trunk/testapp/modules/jelix_tests/tests/jforms.check_datas.html_cli.php (modified) (1 diff)
- trunk/testapp/modules/jelix_tests/tests/jforms.check_datas.html_cli.php (modified) (1 diff)
- trunk/testapp/modules/jelix_tests/tests/jforms.compiler.html_cli.php (modified) (3 diffs)
- trunk/testapp/modules/jelix_tests/tests/jforms.compiler.html_cli.php (modified) (3 diffs)
- trunk/testapp/modules/jelix_tests/tests/jforms.compiler.html_cli.php (modified) (3 diffs)
- trunk/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html_cli.php (modified) (1 diff)
- trunk/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html_cli.php (modified) (1 diff)
- trunk/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html_cli.php (modified) (1 diff)
- trunk/testapp/modules/testapp/forms/sample.form.xml (modified) (1 diff)
- trunk/testapp/modules/testapp/forms/sample.form.xml (modified) (1 diff)
- trunk/testapp/modules/testapp/forms/sample.form.xml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/build/manifests/jelix-lib.mn
r839 r840 102 102 auth.ISO-8859-15.properties 103 103 auth.UTF-8.properties 104 captcha.ISO-8859-1.properties 105 captcha.ISO-8859-15.properties 106 captcha.UTF-8.properties 104 107 common.ISO-8859-1.properties 105 108 common.ISO-8859-15.properties … … 139 142 auth.ISO-8859-15.properties 140 143 auth.UTF-8.properties 144 captcha.ISO-8859-1.properties 145 captcha.ISO-8859-15.properties 146 captcha.UTF-8.properties 141 147 common.ISO-8859-1.properties 142 148 common.ISO-8859-15.properties … … 176 182 auth.ISO-8859-15.properties 177 183 auth.UTF-8.properties 184 captcha.ISO-8859-1.properties 185 captcha.ISO-8859-15.properties 186 captcha.UTF-8.properties 178 187 common.ISO-8859-1.properties 179 188 common.ISO-8859-15.properties trunk/build/manifests/jelix-lib.mn
r839 r840 102 102 auth.ISO-8859-15.properties 103 103 auth.UTF-8.properties 104 captcha.ISO-8859-1.properties 105 captcha.ISO-8859-15.properties 106 captcha.UTF-8.properties 104 107 common.ISO-8859-1.properties 105 108 common.ISO-8859-15.properties … … 139 142 auth.ISO-8859-15.properties 140 143 auth.UTF-8.properties 144 captcha.ISO-8859-1.properties 145 captcha.ISO-8859-15.properties 146 captcha.UTF-8.properties 141 147 common.ISO-8859-1.properties 142 148 common.ISO-8859-15.properties … … 176 182 auth.ISO-8859-15.properties 177 183 auth.UTF-8.properties 184 captcha.ISO-8859-1.properties 185 captcha.ISO-8859-15.properties 186 captcha.UTF-8.properties 178 187 common.ISO-8859-1.properties 179 188 common.ISO-8859-15.properties trunk/build/manifests/jelix-lib.mn
r839 r840 102 102 auth.ISO-8859-15.properties 103 103 auth.UTF-8.properties 104 captcha.ISO-8859-1.properties 105 captcha.ISO-8859-15.properties 106 captcha.UTF-8.properties 104 107 common.ISO-8859-1.properties 105 108 common.ISO-8859-15.properties … … 139 142 auth.ISO-8859-15.properties 140 143 auth.UTF-8.properties 144 captcha.ISO-8859-1.properties 145 captcha.ISO-8859-15.properties 146 captcha.UTF-8.properties 141 147 common.ISO-8859-1.properties 142 148 common.ISO-8859-15.properties … … 176 182 auth.ISO-8859-15.properties 177 183 auth.UTF-8.properties 184 captcha.ISO-8859-1.properties 185 captcha.ISO-8859-15.properties 186 captcha.UTF-8.properties 178 187 common.ISO-8859-1.properties 179 188 common.ISO-8859-15.properties trunk/lib/jelix/forms/jFormsCompiler.class.php
r839 r840 213 213 $this->readLabel($source, $control, 'output'); 214 214 $this->readHelpHintAlert($source, $control); 215 216 215 } 217 216 … … 347 346 } 348 347 } 348 349 protected function generateCaptcha(&$source, $control, &$attributes) { 350 $this->readLabel($source, $control, 'captcha'); 351 $this->readHelpHintAlert($source, $control); 352 } 353 354 355 349 356 350 357 protected function attrReadonly(&$source, &$attributes) { trunk/lib/jelix/forms/jFormsCompiler.class.php
r839 r840 213 213 $this->readLabel($source, $control, 'output'); 214 214 $this->readHelpHintAlert($source, $control); 215 216 215 } 217 216 … … 347 346 } 348 347 } 348 349 protected function generateCaptcha(&$source, $control, &$attributes) { 350 $this->readLabel($source, $control, 'captcha'); 351 $this->readHelpHintAlert($source, $control); 352 } 353 354 355 349 356 350 357 protected function attrReadonly(&$source, &$attributes) { trunk/lib/jelix/forms/jFormsCompiler.class.php
r839 r840 213 213 $this->readLabel($source, $control, 'output'); 214 214 $this->readHelpHintAlert($source, $control); 215 216 215 } 217 216 … … 347 346 } 348 347 } 348 349 protected function generateCaptcha(&$source, $control, &$attributes) { 350 $this->readLabel($source, $control, 'captcha'); 351 $this->readHelpHintAlert($source, $control); 352 } 353 354 355 349 356 350 357 protected function attrReadonly(&$source, &$attributes) { trunk/lib/jelix/forms/jFormsControl.class.php
r839 r840 218 218 } 219 219 220 220 /** 221 * captcha control 222 * @package jelix 223 * @subpackage forms 224 */ 225 class jFormsControlCaptcha extends jFormsControl { 226 public $type = 'captcha'; 227 public $question=''; 228 public $required = true; 229 function check($form){ 230 $value = $form->getContainer()->data[$this->ref]; 231 if($value == '') { 232 return jForms::ERRDATA_REQUIRED; 233 }elseif($value != $form->getContainer()->privateData[$this->ref]){ 234 return jForms::ERRDATA_INVALID; 235 } 236 return null; 237 } 238 239 function initExpectedValue($form){ 240 $numbers = jLocale::get('jelix~captcha.number'); 241 $id = rand(1,intval($numbers)); 242 $this->question = jLocale::get('jelix~captcha.question.'.$id); 243 $form->getContainer()->privateData[$this->ref] = jLocale::get('jelix~captcha.response.'.$id); 244 } 245 } 221 246 222 247 /** trunk/lib/jelix/forms/jFormsControl.class.php
r839 r840 218 218 } 219 219 220 220 /** 221 * captcha control 222 * @package jelix 223 * @subpackage forms 224 */ 225 class jFormsControlCaptcha extends jFormsControl { 226 public $type = 'captcha'; 227 public $question=''; 228 public $required = true; 229 function check($form){ 230 $value = $form->getContainer()->data[$this->ref]; 231 if($value == '') { 232 return jForms::ERRDATA_REQUIRED; 233 }elseif($value != $form->getContainer()->privateData[$this->ref]){ 234 return jForms::ERRDATA_INVALID; 235 } 236 return null; 237 } 238 239 function initExpectedValue($form){ 240 $numbers = jLocale::get('jelix~captcha.number'); 241 $id = rand(1,intval($numbers)); 242 $this->question = jLocale::get('jelix~captcha.question.'.$id); 243 $form->getContainer()->privateData[$this->ref] = jLocale::get('jelix~captcha.response.'.$id); 244 } 245 } 221 246 222 247 /** trunk/lib/jelix/forms/jFormsControl.class.php
r839 r840 218 218 } 219 219 220 220 /** 221 * captcha control 222 * @package jelix 223 * @subpackage forms 224 */ 225 class jFormsControlCaptcha extends jFormsControl { 226 public $type = 'captcha'; 227 public $question=''; 228 public $required = true; 229 function check($form){ 230 $value = $form->getContainer()->data[$this->ref]; 231 if($value == '') { 232 return jForms::ERRDATA_REQUIRED; 233 }elseif($value != $form->getContainer()->privateData[$this->ref]){ 234 return jForms::ERRDATA_INVALID; 235 } 236 return null; 237 } 238 239 function initExpectedValue($form){ 240 $numbers = jLocale::get('jelix~captcha.number'); 241 $id = rand(1,intval($numbers)); 242 $this->question = jLocale::get('jelix~captcha.question.'.$id); 243 $form->getContainer()->privateData[$this->ref] = jLocale::get('jelix~captcha.response.'.$id); 244 } 245 } 221 246 222 247 /** trunk/lib/jelix/forms/jFormsDataContainer.class.php
r839 r840 5 5 * @author Laurent Jouanneau 6 6 * @contributor 7 * @copyright 2006-200 7Laurent Jouanneau7 * @copyright 2006-2008 Laurent Jouanneau 8 8 * @link http://www.jelix.org 9 9 * @licence http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file … … 17 17 class jFormsDataContainer { 18 18 /** 19 * contains data provided by the user in each controls 19 20 * @var array 20 21 */ 21 22 public $data = array(); 23 24 /** 25 * internal use. Used by controls object to store some private data. (captcha for example) 26 * @var array 27 */ 28 public $privateData = array(); 29 22 30 /** 23 31 * the instance id of the form trunk/lib/jelix/forms/jFormsDataContainer.class.php
r839 r840 5 5 * @author Laurent Jouanneau 6 6 * @contributor 7 * @copyright 2006-200 7Laurent Jouanneau7 * @copyright 2006-2008 Laurent Jouanneau 8 8 * @link http://www.jelix.org 9 9 * @licence http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file … … 17 17 class jFormsDataContainer { 18 18 /** 19 * contains data provided by the user in each controls 19 20 * @var array 20 21 */ 21 22 public $data = array(); 23 24 /** 25 * internal use. Used by controls object to store some private data. (captcha for example) 26 * @var array 27 */ 28 public $privateData = array(); 29 22 30 /** 23 31 * the instance id of the form trunk/lib/jelix/forms/jFormsDataContainer.class.php
r839 r840 5 5 * @author Laurent Jouanneau 6 6 * @contributor 7 * @copyright 2006-200 7Laurent Jouanneau7 * @copyright 2006-2008 Laurent Jouanneau 8 8 * @link http://www.jelix.org 9 9 * @licence http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file … … 17 17 class jFormsDataContainer { 18 18 /** 19 * contains data provided by the user in each controls 19 20 * @var array 20 21 */ 21 22 public $data = array(); 23 24 /** 25 * internal use. Used by controls object to store some private data. (captcha for example) 26 * @var array 27 */ 28 public $privateData = array(); 29 22 30 /** 23 31 * the instance id of the form trunk/lib/jelix/plugins/jforms/html/html.jformsbuilder.php
r839 r840 243 243 echo '<button type="reset"',$id,$hint,' class="jforms-reset">',htmlspecialchars($ctrl->label),'</button>'; 244 244 break; 245 case 'captcha': 246 $ctrl->initExpectedValue($this->_form); 247 echo '<span class="jforms-captcha-question">',htmlspecialchars($ctrl->question),'</span> '; 248 echo '<input type="text"',$id,$hint,$class,' value=""',$this->_endt; 249 break; 245 250 } 246 251 trunk/lib/jelix/plugins/jforms/html/html.jformsbuilder.php
r839 r840 243 243 echo '<button type="reset"',$id,$hint,' class="jforms-reset">',htmlspecialchars($ctrl->label),'</button>'; 244 244 break; 245 case 'captcha': 246 $ctrl->initExpectedValue($this->_form); 247 echo '<span class="jforms-captcha-question">',htmlspecialchars($ctrl->question),'</span> '; 248 echo '<input type="text"',$id,$hint,$class,' value=""',$this->_endt; 249 break; 245 250 } 246 251 trunk/lib/jelix/plugins/jforms/html/html.jformsbuilder.php
r839 r840 243 243 echo '<button type="reset"',$id,$hint,' class="jforms-reset">',htmlspecialchars($ctrl->label),'</button>'; 244 244 break; 245 case 'captcha': 246 $ctrl->initExpectedValue($this->_form); 247 echo '<span class="jforms-captcha-question">',htmlspecialchars($ctrl->question),'</span> '; 248 echo '<input type="text"',$id,$hint,$class,' value=""',$this->_endt; 249 break; 245 250 } 246 251 trunk/lib/jelix/plugins/tpl/html/block.formcontrols.php
r831 r840 79 79 if($ctrl->type == \'reset\' || $ctrl->type == \'hidden\') continue; 80 80 if($ctrl->type == \'submit\' && (isset($t->_privateVars[\'__formbuilder\']) || $ctrl->standalone)) continue; 81 if($ctrl->type == \'captcha\' && !isset($t->_privateVars[\'__formbuilder\'])) continue; 81 82 if(!isset($t->_privateVars[\'__displayed_ctrl\'][$ctrlref]) 82 83 && ( ($ctrls_to_display===null && $ctrls_notto_display === null) trunk/lib/jelix/plugins/tpl/html/block.formcontrols.php
r831 r840 79 79 if($ctrl->type == \'reset\' || $ctrl->type == \'hidden\') continue; 80 80 if($ctrl->type == \'submit\' && (isset($t->_privateVars[\'__formbuilder\']) || $ctrl->standalone)) continue; 81 if($ctrl->type == \'captcha\' && !isset($t->_privateVars[\'__formbuilder\'])) continue; 81 82 if(!isset($t->_privateVars[\'__displayed_ctrl\'][$ctrlref]) 82 83 && ( ($ctrls_to_display===null && $ctrls_notto_display === null) trunk/lib/jelix/plugins/tpl/html/block.formcontrols.php
r831 r840 79 79 if($ctrl->type == \'reset\' || $ctrl->type == \'hidden\') continue; 80 80 if($ctrl->type == \'submit\' && (isset($t->_privateVars[\'__formbuilder\']) || $ctrl->standalone)) continue; 81 if($ctrl->type == \'captcha\' && !isset($t->_privateVars[\'__formbuilder\'])) continue; 81 82 if(!isset($t->_privateVars[\'__displayed_ctrl\'][$ctrlref]) 82 83 && ( ($ctrls_to_display===null && $ctrls_notto_display === null) trunk/lib/jelix/plugins/tpl/html/function.ctrl_label.php
r831 r840 29 29 if ($ctrl->type == 'hidden') 30 30 return; 31 32 // if _formbuilder exists, we are inside a {form} (so it displays a form) 33 // else we are inside a {formdata} 31 34 if(isset($tpl->_privateVars['__formbuilder'])){ 32 35 if($ctrl->type == 'submit' || $ctrl->type == 'reset') 33 36 return; 34 37 $tpl->_privateVars['__formbuilder']->outputControlLabel($ctrl); 35 }else 38 }else { 39 if($ctrl->type == 'captcha') 40 return; 36 41 echo htmlspecialchars($ctrl->label); 42 } 37 43 } 38 44 trunk/lib/jelix/plugins/tpl/html/function.ctrl_label.php
r831 r840 29 29 if ($ctrl->type == 'hidden') 30 30 return; 31 32 // if _formbuilder exists, we are inside a {form} (so it displays a form) 33 // else we are inside a {formdata} 31 34 if(isset($tpl->_privateVars['__formbuilder'])){ 32 35 if($ctrl->type == 'submit' || $ctrl->type == 'reset') 33 36 return; 34 37 $tpl->_privateVars['__formbuilder']->outputControlLabel($ctrl); 35 }else 38 }else { 39 if($ctrl->type == 'captcha') 40 return; 36 41 echo htmlspecialchars($ctrl->label); 42 } 37 43 } 38 44 trunk/lib/jelix/plugins/tpl/html/function.ctrl_label.php
r831 r840 29 29 if ($ctrl->type == 'hidden') 30 30 return; 31 32 // if _formbuilder exists, we are inside a {form} (so it displays a form) 33 // else we are inside a {formdata} 31 34 if(isset($tpl->_privateVars['__formbuilder'])){ 32 35 if($ctrl->type == 'submit' || $ctrl->type == 'reset') 33 36 return; 34 37 $tpl->_privateVars['__formbuilder']->outputControlLabel($ctrl); 35 }else 38 }else { 39 if($ctrl->type == 'captcha') 40 return; 36 41 echo htmlspecialchars($ctrl->label); 42 } 37 43 } 38 44 trunk/lib/jelix/plugins/tpl/html/function.ctrl_value.php
r836 r840 25 25 26 26 if($ctrlname =='') { 27 if($tpl->_privateVars['__ctrl']->type == 'hidden') 28 return; 29 if(($tpl->_privateVars['__ctrl']->type == 'submit') 30 && ($tpl->_privateVars['__ctrl']->standalone || $insideForm)){ 31 return; 32 } 33 if(($tpl->_privateVars['__ctrl']->type == 'reset') && $insideForm){ 34 return; 35 } 27 $ctrl = $tpl->_privateVars['__ctrl']; 36 28 $tpl->_privateVars['__displayed_ctrl'][$ctrlname] = true; 37 $ctrl = $tpl->_privateVars['__ctrl'];38 29 $ctrlname = $tpl->_privateVars['__ctrlref']; 39 30 }else{ 40 31 $ctrls = $tpl->_privateVars['__form']->getControls(); 41 if($ctrls[$ctrlname]->type == 'hidden')42 return;43 if(($ctrls[$ctrlname]->type == 'submit' || $ctrls[$ctrlname]->type == 'reset')44 && ($ctrls[$ctrlname]->standalone || $insideForm)){45 return;46 }47 32 $ctrl = $ctrls[$ctrlname]; 33 } 34 35 if($ctrl->type == 'hidden' || $ctrl->type == 'captcha') 36 return; 37 38 if($ctrl->type == 'submit' && ($ctrl->standalone || $insideForm)) 39 return; 40 41 if($ctrl->type == 'reset' && $insideForm){ 42 return; 48 43 } 49 44 trunk/lib/jelix/plugins/tpl/html/function.ctrl_value.php
r836 r840 25 25 26 26 if($ctrlname =='') { 27 if($tpl->_privateVars['__ctrl']->type == 'hidden') 28 return; 29 if(($tpl->_privateVars['__ctrl']->type == 'submit') 30 && ($tpl->_privateVars['__ctrl']->standalone || $insideForm)){ 31 return; 32 } 33 if(($tpl->_privateVars['__ctrl']->type == 'reset') && $insideForm){ 34 return; 35 } 27 $ctrl = $tpl->_privateVars['__ctrl']; 36 28 $tpl->_privateVars['__displayed_ctrl'][$ctrlname] = true; 37 $ctrl = $tpl->_privateVars['__ctrl'];38 29 $ctrlname = $tpl->_privateVars['__ctrlref']; 39 30 }else{ 40 31 $ctrls = $tpl->_privateVars['__form']->getControls(); 41 if($ctrls[$ctrlname]->type == 'hidden')42 return;43 if(($ctrls[$ctrlname]->type == 'submit' || $ctrls[$ctrlname]->type == 'reset')44 && ($ctrls[$ctrlname]->standalone || $insideForm)){45 return;46 }47 32 $ctrl = $ctrls[$ctrlname]; 33 } 34 35 if($ctrl->type == 'hidden' || $ctrl->type == 'captcha') 36 return; 37 38 if($ctrl->type == 'submit' && ($ctrl->standalone || $insideForm)) 39 return; 40 41 if($ctrl->type == 'reset' && $insideForm){ 42 return; 48 43 } 49 44 trunk/lib/jelix/plugins/tpl/html/function.ctrl_value.php
r836 r840 25 25 26 26 if($ctrlname =='') { 27 if($tpl->_privateVars['__ctrl']->type == 'hidden') 28 return; 29 if(($tpl->_privateVars['__ctrl']->type == 'submit') 30 && ($tpl->_privateVars['__ctrl']->standalone || $insideForm)){ 31 return; 32 } 33 if(($tpl->_privateVars['__ctrl']->type == 'reset') && $insideForm){ 34 return; 35 } 27 $ctrl = $tpl->_privateVars['__ctrl']; 36 28 $tpl->_privateVars['__displayed_ctrl'][$ctrlname] = true; 37 $ctrl = $tpl->_privateVars['__ctrl'];38 29 $ctrlname = $tpl->_privateVars['__ctrlref']; 39 30 }else{ 40 31 $ctrls = $tpl->_privateVars['__form']->getControls(); 41 if($ctrls[$ctrlname]->type == 'hidden')42 return;43 if(($ctrls[$ctrlname]->type == 'submit' || $ctrls[$ctrlname]->type == 'reset')44 && ($ctrls[$ctrlname]->standalone || $insideForm)){45 return;46 }47 32 $ctrl = $ctrls[$ctrlname]; 33 } 34 35 if($ctrl->type == 'hidden' || $ctrl->type == 'captcha') 36 return; 37 38 if($ctrl->type == 'submit' && ($ctrl->standalone || $insideForm)) 39 return; 40 41 if($ctrl->type == 'reset' && $insideForm){ 42 return; 48 43 } 49 44 trunk/lib/jelix/plugins/tpl/html/function.formdatafull.php
r839 r840 25 25 26 26 foreach( $form->getControls() as $ctrlref=>$ctrl){ 27 if($ctrl->type == 'submit' || $ctrl->type == 'reset' || $ctrl->type == 'hidden' ) continue;27 if($ctrl->type == 'submit' || $ctrl->type == 'reset' || $ctrl->type == 'hidden' || $ctrl->type == 'captcha') continue; 28 28 29 29 echo '<tr><th scope="row">'; trunk/lib/jelix/plugins/tpl/html/function.formdatafull.php
r839 r840 25 25 26 26 foreach( $form->getControls() as $ctrlref=>$ctrl){ 27 if($ctrl->type == 'submit' || $ctrl->type == 'reset' || $ctrl->type == 'hidden' ) continue;27 if($ctrl->type == 'submit' || $ctrl->type == 'reset' || $ctrl->type == 'hidden' || $ctrl->type == 'captcha') continue; 28 28 29 29 echo '<tr><th scope="row">'; trunk/lib/jelix/plugins/tpl/html/function.formdatafull.php
r839 r840 25 25 26 26 foreach( $form->getControls() as $ctrlref=>$ctrl){ 27 if($ctrl->type == 'submit' || $ctrl->type == 'reset' || $ctrl->type == 'hidden' ) continue;27 if($ctrl->type == 'submit' || $ctrl->type == 'reset' || $ctrl->type == 'hidden' || $ctrl->type == 'captcha') continue; 28 28 29 29 echo '<tr><th scope="row">'; trunk/testapp/modules/jelix_tests/tests/jforms.check_datas.html_cli.php
r839 r840 155 155 $this->form->addCtrl($ctrl); 156 156 $this->assertTrue($this->form->check()); 157 157 158 158 } 159 159 160 function testCaptcha() { 161 162 $ctrl = new jFormsControlCaptcha('captcha'); 163 $this->form->addCtrl($ctrl); 164 165 $ctrl->initExpectedValue($this->form); 166 167 $this->assertTrue(isset($this->form->getContainer()->privateData['captcha'])); 168 169 $expectedResponse = $this->form->getContainer()->privateData['captcha']; 170 $this->assertFalse($this->form->check()); 171 172 if( $expectedResponse == '1234') 173 $badresponse = '12345'; 174 else 175 $badresponse = '1234'; 176 177 $this->form->setData('captcha',$badresponse); 178 $this->assertFalse($this->form->check()); 179 180 $this->form->setData('captcha',$expectedResponse); 181 $this->assertTrue($this->form->check()); 182 } 160 183 } 161 184 trunk/testapp/modules/jelix_tests/tests/jforms.check_datas.html_cli.php
r839 r840 155 155 $this->form->addCtrl($ctrl); 156 156 $this->assertTrue($this->form->check()); 157 157 158 158 } 159 159 160 function testCaptcha() { 161 162 $ctrl = new jFormsControlCaptcha('captcha'); 163 $this->form->addCtrl($ctrl); 164 165 $ctrl->initExpectedValue($this->form); 166 167 $this->assertTrue(isset($this->form->getContainer()->privateData['captcha'])); 168 169 $expectedResponse = $this->form->getContainer()->privateData['captcha']; 170 $this->assertFalse($this->form->check()); 171 172 if( $expectedResponse == '1234') 173 $badresponse = '12345'; 174 else 175 $badresponse = '1234'; 176 177 $this->form->setData('captcha',$badresponse); 178 $this->assertFalse($this->form->check()); 179 180 $this->form->setData('captcha',$expectedResponse); 181 $this->assertTrue($this->form->check()); 182 } 160 183 } 161 184 trunk/testapp/modules/jelix_tests/tests/jforms.check_datas.html_cli.php
r839 r840 155 155 $this->form->addCtrl($ctrl); 156 156 $this->assertTrue($this->form->check()); 157 157 158 158 } 159 159 160 function testCaptcha() { 161 162 $ctrl = new jFormsControlCaptcha('captcha'); 163 $this->form->addCtrl($ctrl); 164 165 $ctrl->initExpectedValue($this->form); 166 167 $this->assertTrue(isset($this->form->getContainer()->privateData['captcha'])); 168 169 $expectedResponse = $this->form->getContainer()->privateData['captcha']; 170 $this->assertFalse($this->form->check()); 171 172 if( $expectedResponse == '1234') 173 $badresponse = '12345'; 174 else 175 $badresponse = '1234'; 176 177 $this->form->setData('captcha',$badresponse); 178 $this->assertFalse($this->form->check()); 179 180 $this->form->setData('captcha',$expectedResponse); 181 $this->assertTrue($this->form->check()); 182 } 160 183 } 161 184 trunk/testapp/modules/jelix_tests/tests/jforms.compiler.html_cli.php
r839 r840 295 295 <label>Votre nom</label> 296 296 </textarea>', 297 71=>'<captcha ref="cap" xmlns="http://jelix.org/ns/forms/1.0"> 298 <label>captcha</label> 299 </captcha>', 297 300 ); 298 301 … … 664 667 $ctrl->label=\'Votre nom\'; 665 668 $this->addControl($ctrl);', 669 71=>'$ctrl= new jFormsControlcaptcha(\'cap\'); 670 $ctrl->label=\'captcha\'; 671 $this->addControl($ctrl);', 666 672 ); 667 673 … … 1030 1036 70=>'$label = \'Votre nom\'; 1031 1037 $js.="jForms.tControl = new jFormsControl(\'nom\', \'".str_replace("\'","\\\'",$label)."\', \'string\');\n"; 1038 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n"; 1039 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~for
