Changeset 1050
- Timestamp:
- 08/16/08 00:45:43 (4 months ago)
- Files:
-
- branches/experimental/jforms-groups/build/manifests/jelix-lib.mn (modified) (2 diffs)
- branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js (modified) (6 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler.class.php (modified) (3 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php (modified) (6 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_1.class.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php (modified) (3 diffs)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (22 diffs)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformscompiler.php (deleted)
- branches/experimental/jforms-groups/lib/jelix/plugins/tpl/html/block.formcontrols.php (modified) (3 diffs)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.compiler.html_cli.php (modified) (8 diffs)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.compiler_1_1.html_cli.php (modified) (5 diffs)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html_cli.php (modified) (64 diffs)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.htmlbuilder2.html_cli.php (modified) (7 diffs)
- trunk/build/manifests/jelix-lib.mn (modified) (2 diffs)
- trunk/lib/jelix-www/js/jforms.js (modified) (6 diffs)
- trunk/lib/jelix/forms/jFormsCompiler.class.php (modified) (3 diffs)
- trunk/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php (modified) (6 diffs)
- trunk/lib/jelix/forms/jFormsCompiler_jf_1_1.class.php (modified) (1 diff)
- trunk/lib/jelix/forms/jFormsControl.class.php (modified) (3 diffs)
- trunk/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (22 diffs)
- trunk/lib/jelix/plugins/jforms/html/html.jformscompiler.php (deleted)
- trunk/testapp/modules/jelix_tests/tests/jforms.compiler.html_cli.php (modified) (8 diffs)
- trunk/testapp/modules/jelix_tests/tests/jforms.compiler_1_1.html_cli.php (modified) (5 diffs)
- trunk/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html_cli.php (modified) (64 diffs)
- trunk/testapp/modules/jelix_tests/tests/jforms.htmlbuilder2.html_cli.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/experimental/jforms-groups/build/manifests/jelix-lib.mn
r1041 r1050 358 358 history.coord.ini.php.dist 359 359 360 cd lib/jelix/plugins/jforms/html361 html.jformscompiler.php362 html.jformsbuilder.php363 364 365 360 cd lib/jelix/plugins/db/intuition 366 361 intuition.dbconnection.php … … 390 385 oci.daobuilder.php 391 386 oci.dbtools.php 387 388 cd lib/jelix/plugins/jforms/html 389 html.jformsbuilder.php 392 390 393 391 cd lib/jelix/plugins/tpl/common branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js
r1041 r1050 404 404 * control with LocaleDateTime 405 405 */ 406 function jFormsControlLocale datetime(name, label) {406 function jFormsControlLocaleDatetime(name, label) { 407 407 this.name = name; 408 408 this.label = label; … … 413 413 this.lang=''; 414 414 }; 415 jFormsControlLocale datetime.prototype.check = function (val, jfrm) {415 jFormsControlLocaleDatetime.prototype.check = function (val, jfrm) { 416 416 var yy, mm, dd, th, tm, ts; 417 417 if(this.lang.indexOf('fr_') == 0) { … … 449 449 * control with localedate 450 450 */ 451 function jFormsControlLocale date(name, label) {451 function jFormsControlLocaleDate(name, label) { 452 452 this.name = name; 453 453 this.label = label; … … 458 458 this.lang=''; 459 459 }; 460 jFormsControlLocale date.prototype.check = function (val, jfrm) {460 jFormsControlLocaleDate.prototype.check = function (val, jfrm) { 461 461 var yy, mm, dd; 462 462 if(this.lang.indexOf('fr_') == 0) { … … 551 551 this.name = name; 552 552 this.label = label; 553 this.required = true;553 this.required = false; 554 554 this.errInvalid = ''; 555 555 this.errRequired = ''; … … 599 599 }; 600 600 601 602 603 601 /** 604 602 * Decorator to display errors in an alert dialog box branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler.class.php
r914 r1050 54 54 55 55 $srcBuilders=array(); 56 $buildersCompilers = array();57 56 foreach($gJConfig->_pluginsPathList_jforms as $buildername => $pluginPath) { 58 require_once($pluginPath.$buildername.'.jformscompiler.php');59 $classname = $buildername.'JformsCompiler';60 $buildersCompilers[$buildername] = new $classname($compiler);61 62 57 $srcBuilders[$buildername]=array(); 63 58 $srcBuilders[$buildername][] = '<?php '; 64 59 $srcBuilders[$buildername][] = ' require_once(\''.$pluginPath.$buildername.'.jformsbuilder.php\'); '; 65 $srcBuilders[$buildername][] = ' class '.$selector->getClass().'_builder_'.$buildername.' extends '.$buildername.'JformsBuilder '.'{';60 $srcBuilders[$buildername][] = ' class '.$selector->getClass().'_builder_'.$buildername.' extends '.$buildername.'JformsBuilder {'; 66 61 $srcBuilders[$buildername][] = ' public function __construct($form){'; 67 $srcBuilders[$buildername][] = ' parent::__construct($form); ';62 $srcBuilders[$buildername][] = ' parent::__construct($form);'; 68 63 $srcBuilders[$buildername][] = ' }'; 69 $srcBuilders[$buildername][] = $buildersCompilers[$buildername]->startCompile(); 70 64 71 65 $source[]=' \''.$buildername.'\'=>array(\''.$selector->getCompiledBuilderFilePath($buildername).'\',\''.$selector->getClass().'_builder_'.$buildername.'\'), '; 72 66 } … … 74 68 $source[]=' );'; 75 69 $source[]=' public function __construct($sel, &$container, $reset = false){'; 76 $source[]=' parent::__construct($sel, $container, $reset); ';70 $source[]=' parent::__construct($sel, $container, $reset);'; 77 71 78 $compiler->compile($doc, $source, $srcBuilders , $buildersCompilers);72 $compiler->compile($doc, $source, $srcBuilders); 79 73 80 74 $source[]=" }\n} ?>"; … … 82 76 83 77 foreach($gJConfig->_pluginsPathList_jforms as $buildername => $pluginPath) { 84 $srcBuilders[$buildername][]= $buildersCompilers[$buildername]->endCompile();85 78 $srcBuilders[$buildername][]= '} ?>'; 86 79 jFile::write($selector->getCompiledBuilderFilePath($buildername), implode("\n", $srcBuilders[$buildername])); branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php
r1022 r1050 25 25 26 26 protected $srcBuilders; 27 protected $buildersCompilers;28 27 29 28 public function __construct($sourceFile) { … … 31 30 } 32 31 33 public function compile ($doc, &$source, &$srcBuilders , &$buildersCompilers) {32 public function compile ($doc, &$source, &$srcBuilders) { 34 33 35 34 global $gJConfig; 36 35 37 36 $this->srcBuilders = &$srcBuilders; 38 $this->buildersCompilers = &$buildersCompilers;39 37 40 38 $xml = simplexml_import_dom($doc); … … 45 43 foreach ($xml->children() as $controltype=>$control) { 46 44 $source[] = $this->generatePHPControl($controltype, $control); 47 //foreach($gJConfig->_pluginsPathList_jforms as $buildername => $pluginPath) {48 // $srcBuilders[$buildername][]= $buildersCompilers[$buildername]->generateControl($controltype, $control);49 foreach($buildersCompilers as $buildername => $builder) {50 $srcBuilders[$buildername][]= $builder->generateControl($controltype, $control);51 }52 45 } 53 46 } … … 167 160 $this->attrDefaultvalue($source, $attributes); 168 161 $this->readLabel($source, $control, 'output'); 169 $this->readHelpHintAlert($source, $control);162 //$this->readHelpHintAlert($source, $control); 170 163 return false; 171 164 } … … 274 267 275 268 if(isset($control->help)){ 276 $source[]='$ctrl2->h asHelp=true;';269 $source[]='$ctrl2->help=$ctrl->help;'; 277 270 } 278 271 if(isset($control->hint)){ … … 359 352 protected function readHelpHintAlert(&$source, $control) { 360 353 if(isset($control->help)){ // help value is readed in the html compiler 361 $source[]='$ctrl->hasHelp=true;'; 354 if(isset($control->help['locale'])){ 355 $source[]='$ctrl->help=jLocale::get(\''.(string)$control->help['locale'].'\');'; 356 }else{ 357 $source[]='$ctrl->help=\''.str_replace("'","\\'",(string)$control->help).'\';'; 358 } 362 359 } 363 360 if(isset($control->hint)){ branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_1.class.php
r1041 r1050 191 191 $src[]='$topctrl->addChildControl($ctrl2'.$itemname.');'; 192 192 $source[]= implode("\n", $src); 193 /*foreach($gJConfig->_pluginsPathList_jforms as $buildername => $pluginPath) {194 $this->srcBuilders[$buildername][]= $this->buildersCompilers[$buildername]->generateControl($ctrltype, $control);195 }*/196 193 } 197 194 return $ctrlcount; branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php
r1041 r1050 23 23 public $label=''; 24 24 public $defaultValue=''; 25 public $h asHelp = false;25 public $help = ''; 26 26 public $hint=''; 27 27 public $alertInvalid=''; … … 199 199 public $type='secretconfirm'; 200 200 public $size=0; 201 /** 202 * ref value of the associated secret control 203 */ 201 204 public $primarySecret=''; 202 205 … … 265 268 class jFormsControlOutput extends jFormsControl { 266 269 public $type='output'; 270 271 function setValueFromRequest($request) { 272 } 267 273 268 274 public function check(){ branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php
r1041 r1050 17 17 */ 18 18 abstract class htmlJformsBuilder extends jFormsBuilderBase { 19 20 protected $options; 21 22 protected $isRootControl = true; 19 23 20 24 public function outputAllControls() { … … 89 93 */ 90 94 public function outputHeader($params){ 91 $ params = array_merge(array('errorDecorator'=>'jFormsErrorDecoratorAlert',95 $this->options = array_merge(array('errorDecorator'=>'jFormsErrorDecoratorAlert', 92 96 'helpDecorator'=>'jFormsHelpDecoratorAlert', 'method'=>'post'), $params); 93 97 94 98 $url = jUrl::get($this->_action, $this->_actionParams, 2); // retourne le jurl correspondant 95 echo '<form action="',$url-> scriptName,$url->pathInfo,'" method="'.$params['method'].'" id="', $this->_name,'"';99 echo '<form action="',$url->getPath(),'" method="'.$this->options['method'].'" id="', $this->_name,'"'; 96 100 if($this->_form->hasUpload()) 97 101 echo ' enctype="multipart/form-data">'; … … 99 103 echo '>'; 100 104 105 echo '<script type="text/javascript"> 106 //<![CDATA[ 107 jForms.tForm = new jFormsForm(\''.$this->_name.'\'); 108 jForms.tForm.setErrorDecorator(new '.$this->options['errorDecorator'].'()); 109 jForms.tForm.setHelpDecorator(new '.$this->options['helpDecorator'].'()); 110 jForms.declareForm(jForms.tForm); 111 //]]> 112 </script>'; 113 114 101 115 if(count($url->params) || count($this->_form->getHiddens())){ 102 116 echo '<div class="jforms-hiddens">'; … … 110 124 echo '</div>'; 111 125 } 112 echo '<script type="text/javascript"> 113 //<![CDATA[ 114 ', $this->getJavascriptCheck($params['errorDecorator'],$params['helpDecorator']),' 115 //]]> 116 </script>'; 126 117 127 $errors = $this->_form->getContainer()->errors; 118 128 if(count($errors)){ … … 143 153 } 144 154 155 protected $jsContent = ''; 156 145 157 public function outputFooter(){ 158 echo '<script type="text/javascript"> 159 //<![CDATA[ 160 '.$this->jsContent.' 161 //]]> 162 </script>'; 146 163 echo '</form>'; 147 164 } … … 171 188 $hint = ($ctrl->hint == ''?'':' title="'.htmlspecialchars($ctrl->hint).'"'); 172 189 $this->{'output'.$ctrl->type}($ctrl, $id, $class, $readonly, $hint); 190 $this->{'js'.$ctrl->type}($ctrl); 173 191 $this->outputHelp($ctrl); 192 } 193 194 protected function commonJs($ctrl) { 195 if($ctrl->help){ 196 $this->jsContent .="jForms.tControl.help='".str_replace("'","\\'",$ctrl->help)."';\n"; 197 } 198 199 if($ctrl->required){ 200 $this->jsContent .="jForms.tControl.required = true;\n"; 201 if($ctrl->alertRequired){ 202 $this->jsContent .="jForms.tControl.errRequired='".str_replace("'","\\'",$ctrl->alertRequired)."';\n"; 203 } 204 else { 205 $this->jsContent .="jForms.tControl.errRequired='".str_replace("'","\\'",jLocale::get('jelix~formserr.js.err.required', $ctrl->label))."';\n"; 206 } 207 } 208 209 if($ctrl->alertInvalid){ 210 $this->jsContent .="jForms.tControl.errInvalid='".str_replace("'","\\'",$ctrl->alertInvalid)."';\n"; 211 } 212 else { 213 $this->jsContent .="jForms.tControl.errInvalid='".str_replace("'","\\'",jLocale::get('jelix~formserr.js.err.invalid', $ctrl->label))."';\n"; 214 } 215 216 if ($this->isRootControl) $this->jsContent .="jForms.tForm.addControl(jForms.tControl);\n"; 174 217 } 175 218 … … 185 228 } 186 229 230 protected function jsInput($ctrl) { 231 232 $datatype = array('jDatatypeBoolean'=>'Boolean','jDatatypeDecimal'=>'Decimal','jDatatypeInteger'=>'Integer','jDatatypeHexadecimal'=>'Hexadecimal', 233 'jDatatypeDatetime'=>'Datetime','jDatatypeDate'=>'Date','jDatatypeTime'=>'Time', 234 'jDatatypeUrl'=>'Url','jDatatypeEmail'=>'Email','jDatatypeIPv4'=>'Ipv4','jDatatypeIPv6'=>'Ipv6'); 235 $isLocale = false; 236 if(isset($datatype[get_class($ctrl)])) 237 $dt = $datatype[get_class($ctrl)]; 238 else if ($ctrl->datatype instanceof jDatatypeLocaleTime) 239 { $dt = 'Time'; $isLocale = true; } 240 else if ($ctrl->datatype instanceof jDatatypeLocaleDate) 241 { $dt = 'LocaleDate'; $isLocale = true; } 242 else if ($ctrl->datatype instanceof jDatatypeLocaleDateTime) 243 { $dt = 'LocaleDatetime'; $isLocale = true; } 244 else 245 $dt = 'String'; 246 247 $this->jsContent .="jForms.tControl = new jFormsControl".$dt."('".$ctrl->ref."', '".str_replace("'","\'",$ctrl->label)."');\n"; 248 if ($isLocale) 249 $this->jsContent .="jForms.tControl.lang='".$GLOBALS['gJConfig']->locale."';\n"; 250 251 $maxl= $ctrl->datatype->getFacet('maxLength'); 252 if($maxl !== null) 253 $this->jsContent .="jForms.tControl.maxLength = '$maxl';\n"; 254 255 $minl= $ctrl->datatype->getFacet('minLength'); 256 if($minl !== null) 257 $this->jsContent .="jForms.tControl.minLength = '$minl';\n"; 258 259 $this->commonJs($ctrl); 260 } 261 187 262 protected function outputCheckbox($ctrl, $id, $class, $readonly, $hint) { 188 263 $value = $this->_form->getData($ctrl->ref); … … 194 269 } 195 270 echo '<input type="checkbox"',$id,$readonly,$hint,$class,$v,' value="',$ctrl->valueOnCheck,'"',$this->_endt; 271 } 272 273 protected function jsCheckbox($ctrl) { 274 275 $this->jsContent .="jForms.tControl = new jFormsControlBoolean('".$ctrl->ref."', '".str_replace("'","\'",$ctrl->label)."');\n"; 276 277 $this->commonJs($ctrl); 196 278 } 197 279 … … 225 307 } 226 308 309 protected function jsCheckboxes($ctrl) { 310 311 $this->jsContent .="jForms.tControl = new jFormsControlString('".$ctrl->ref."[]', '".str_replace("'","\'",$ctrl->label)."');\n"; 312 313 $this->commonJs($ctrl); 314 } 315 227 316 protected function outputRadiobuttons($ctrl, $id, $class, $readonly, $hint) { 228 317 $i=0; … … 243 332 } 244 333 334 protected function jsRadiobuttons($ctrl) { 335 336 $this->jsContent .="jForms.tControl = new jFormsControlString('".$ctrl->ref."', '".str_replace("'","\'",$ctrl->label)."');\n"; 337 338 $this->commonJs($ctrl); 339 } 340 245 341 protected function outputMenulist($ctrl, $id, $class, $readonly, $hint) { 246 342 echo '<select',$id,$hint,$class,' size="1">'; … … 259 355 } 260 356 echo '</select>'; 357 } 358 359 protected function jsMenulist($ctrl) { 360 361 $this->jsContent .="jForms.tControl = new jFormsControlString('".$ctrl->ref."', '".str_replace("'","\'",$ctrl->label)."');\n"; 362 363 $this->commonJs($ctrl); 261 364 } 262 365 … … 297 400 } 298 401 402 protected function jsListbox($ctrl) { 403 if($ctrl->multiple){ 404 $this->jsContent .= "jForms.tControl = new jFormsControlString('".$ctrl->ref."[]', '".str_replace("'","\'",$ctrl->label)."');\n"; 405 $this->jsContent .= "jForms.tControl.multiple = true;\n"; 406 } else { 407 $this->jsContent .="jForms.tControl = new jFormsControlString('".$ctrl->ref."', '".str_replace("'","\'",$ctrl->label)."');\n"; 408 } 409 410 $this->commonJs($ctrl); 411 } 412 299 413 protected function outputTextarea($ctrl, $id, $class, $readonly, $hint) { 300 414 $value = $this->_form->getData($ctrl->ref); … … 303 417 } 304 418 419 protected function jsTextarea($ctrl) { 420 $this->jsContent .="jForms.tControl = new jFormsControlString('".$ctrl->ref."', '".str_replace("'","\'",$ctrl->label)."');\n"; 421 422 $maxl= $ctrl->datatype->getFacet('maxLength'); 423 if($maxl !== null) 424 $this->jsContent .="jForms.tControl.maxLength = '$maxl';\n"; 425 426 $minl= $ctrl->datatype->getFacet('minLength'); 427 if($minl !== null) 428 $this->jsContent .="jForms.tControl.minLength = '$minl';\n"; 429 430 $this->commonJs($ctrl); 431 } 432 305 433 protected function outputHtmleditor($ctrl, $id, $class, $readonly, $hint) { 306 $engine = $GLOBALS['gJConfig']->htmleditors[$ctrl->config.'.engine.name'];307 echo '<script type="text/javascript">308 //<![CDATA[309 jelix_',$engine,'_',$ctrl->config.'("',$this->_name,'_',$ctrl->ref,'","',$this->_name,'");310 //]]>311 </script>';312 313 434 $value = $this->_form->getData($ctrl->ref); 314 435 $rows = ' rows="'.$ctrl->rows.'" cols="'.$ctrl->cols.'"'; 315 436 echo '<textarea',$id,$readonly,$hint,$class,$rows,'>',htmlspecialchars($value),'</textarea>'; 437 } 438 439 protected function jsHtmleditor($ctrl) { 440 $this->jsTextarea($ctrl); 441 $engine = $GLOBALS['gJConfig']->htmleditors[$ctrl->config.'.engine.name']; 442 $this->jsContent .= 'jelix_'.$engine.'_'.$ctrl->config.'("'.$this->_name.'_'.$ctrl->ref.'","'.$this->_name."\");\n"; 316 443 } 317 444 … … 321 448 } 322 449 450 protected function jsSecret($ctrl) { 451 $this->jsTextarea($ctrl); 452 } 453 323 454 protected function outputSecretconfirm($ctrl, $id, $class, $readonly, $hint) { 324 455 $size = ($ctrl->size == 0?'': ' size="'.$ctrl->size.'"'); … … 326 457 } 327 458 459 protected function jsSecretconfirm($ctrl) { 460 // we assume that a secret confirm control is just after a secret control in the list of controls 461 $this->jsContent .= "jForms.tControl.confirmField = new jFormsControlSecretConfirm('".$ctrl->ref."_confirm', '".str_replace("'","\\'",$ctrl->label)."');\n"; 462 } 463 328 464 protected function outputOutput($ctrl, $id, $class, $readonly, $hint) { 329 465 $value = $this->_form->getData($ctrl->ref); 330 466 echo '<input type="hidden"',$id,' value="',htmlspecialchars($value),'"',$this->_endt; 331 467 echo '<span class="jforms-value"',$hint,'>',htmlspecialchars($value),'</span>'; 468 } 469 470 protected function jsOutput($ctrl) { 332 471 } 333 472 … … 338 477 echo '<input type="file"',$id,$readonly,$hint,$class,' value=""',$this->_endt; // ',htmlspecialchars($this->_form->getData($ctrl->ref)),' 339 478 479 } 480 481 protected function jsUpload($ctrl) { 482 $this->jsContent .="jForms.tControl = new jFormsControlString('".$ctrl->ref."', '".str_replace("'","\'",$ctrl->label)."');\n"; 483 484 $this->commonJs($ctrl); 340 485 } 341 486 … … 352 497 } 353 498 499 protected function jsSubmit($ctrl) { 500 // no javascript 501 } 502 354 503 protected function outputReset($ctrl, $id, $class, $readonly, $hint) { 355 504 echo '<button type="reset"',$id,$hint,' class="jforms-reset">',htmlspecialchars($ctrl->label),'</button>'; 505 } 506 507 protected function jsReset($ctrl) { 508 // no javascript 356 509 } 357 510 … … 360 513 echo '<span class="jforms-captcha-question">',htmlspecialchars($ctrl->question),'</span> '; 361 514 echo '<input type="text"',$id,$hint,$class,' value=""',$this->_endt; 515 } 516 517 protected function jsCaptcha($ctrl) { 518 $this->jsTextarea($ctrl); 362 519 } 363 520 … … 377 534 } 378 535 536 protected function jsGroup($ctrl) { 537 //no javacript 538 } 539 379 540 protected function outputChoice($ctrl, $id, $class, $readonly, $hint) { 380 541 echo '<ul class="jforms-choice jforms-ctl-'.$ctrl->ref.'" >',"\n"; … … 390 551 $i=0; 391 552 $id=' name="'.$ctrl->ref.'" id="'.$this->_name.'_'.$ctrl->ref.'_'; 553 $this->jsChoiceInternal($ctrl); 554 $this->jsContent .="jForms.tControl2 = jForms.tControl;\n"; 555 $this->isRootControl = false; 392 556 foreach( $ctrl->items as $itemName=>$listctrl){ 393 557 echo '<li><label><input type="radio"',$id,$i,'" value="',htmlspecialchars($itemName),'"'; … … 401 565 // we remove readonly status so when a user change the choice and 402 566 // javascript is deactivated, it can still change the value of the control 403 $ro = $c->isReadOnly() && $readonly != '';404 if($ro ) $c->setReadOnly(false);567 $ro = $c->isReadOnly(); 568 if($ro && $readonly != '') $c->setReadOnly(false); 405 569 $this->outputControlLabel($c); 406 570 echo ' '; 407 571 $this->outputControl($c); 408 if($ro) $c->setReadOnly( $ro);572 if($ro) $c->setReadOnly(true); 409 573 echo "</span>\n"; 410 } 574 $this->jsContent .="jForms.tControl2.addControl(jForms.tControl, '".str_replace("'","\\'",$itemName)."');\n"; 575 } 576 if(!count($listctrl)) { 577 $this->jsContent .="jForms.tControl2.items['".str_replace("'","\\'",$itemName)."']=[];\n"; 578 } 579 411 580 echo "</li>\n"; 412 581 $i++; 413 582 } 414 583 echo "</ul>\n"; 415 416 echo '<script type="text/javascript"> 417 //<![CDATA[ 418 jForms.getForm("',$this->_name,'").getControl("',$ctrl->ref,'").activate("',$value,'"); 419 //]]> 420 </script>'; 421 } 422 584 $this->isRootControl = true; 585 } 586 587 protected function jsChoice($ctrl) { 588 $value = $this->_form->getData($ctrl->ref); 589 if(is_array($value)){ 590 if(isset($value[0])) 591 $value = $value[0]; 592 else 593 $value=''; 594 } 595 $this->jsContent .= "jForms.tControl2.activate('".$value."');\n"; 596 } 597 598 protected function jsChoiceInternal($ctrl) { 599 600 $this->jsContent .="jForms.tControl = new jFormsControlChoice('".$ctrl->ref."', '".str_replace("'","\'",$ctrl->label)."');\n"; 601 602 $this->commonJs($ctrl); 603 } 423 604 424 605 protected function outputHelp($ctrl) { 425 if ($ctrl->h asHelp) {606 if ($ctrl->help) { 426 607 if($ctrl->type == 'checkboxes' || ($ctrl->type == 'listbox' && $ctrl->multiple)){ 427 608 $name=$ctrl->ref.'[]'; … … 432 613 } 433 614 } 434 435 abstract public function getJavascriptCheck($errDecorator,$helpDecorator);436 615 } branches/experimental/jforms-groups/lib/jelix/plugins/tpl/html/block.formcontrols.php
r926 r1050 4 4 * @subpackage jtpl_plugin 5 5 * @author Jouanneau Laurent 6 * @contributor Mickaël Fradin, F.Fernandez, Dominique Papin 7 * @copyright 2007-2008 Jouanneau laurent, 2007 Mickaël Fradin, 2007 F.Fernandez, 2007 Dominique Papin 6 * @contributor Mickaël Fradin, F.Fernandez, Dominique Papin, Alexis Métaireau 7 * @copyright 2007-2008 Jouanneau laurent, 2007 Mickaël Fradin, 2007 F.Fernandez, 2007 Dominique Papin, 2008 Alexis Métaireau 8 8 * @link http://www.jelix.org 9 9 * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html … … 51 51 } 52 52 elseif(count($param) == 2){ 53 $content = 'if(is_array('.$param[0].') ){53 $content = 'if(is_array('.$param[0].') || '.$param[0].' === null){ 54 54 $ctrls_to_display = '.$param[0].'; 55 55 $ctrls_notto_display = '.$param[1].'; … … 95 95 && ( ($ctrls_to_display===null && $ctrls_notto_display === null) 96 96 || ($ctrls_to_display===null && !in_array($ctrlref, $ctrls_notto_display)) 97 || in_array($ctrlref, $ctrls_to_display))) {97 || (is_array($ctrls_to_display) && in_array($ctrlref, $ctrls_to_display) ))) { 98 98 $t->_privateVars[\'__ctrlref\'] = $ctrlref; 99 99 $t->_privateVars[\'__ctrl\'] = $ctrl; branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.compiler.html_cli.php
r985 r1050 16 16 require_once(JELIX_LIB_PATH.'forms/jFormsDatasource.class.php'); 17 17 require_once(JELIX_LIB_UTILS_PATH.'jDatatype.class.php'); 18 require_once(JELIX_LIB_PATH.'plugins/jforms/html/html.jformscompiler.php');19 20 18 21 19 … … 27 25 28 26 public function testPhpForm($doc){ 29 $dummysrc = $dummyBuilders = $dummyCompilers =array();30 return $this->compile($doc, $dummysrc, $dummyBuilders , $dummyCompilers);27 $dummysrc = $dummyBuilders = array(); 28 return $this->compile($doc, $dummysrc, $dummyBuilders); 31 29 } 32 30 … … 35 33 } 36 34 } 37 38 class testHtmlJformsCompiler extends htmlJformsCompiler {39 public function testControl($controltype, $control){40 return $this->generateControl($controltype, $control);41 }42 }43 44 35 45 36 class UTjformsCompiler extends jUnitTestCase { … … 510 501 42=>'$ctrl= new jFormsControlinput(\'nom\'); 511 502 $ctrl->label=\'Votre nom\'; 512 $ctrl->h asHelp=true;503 $ctrl->help=\'vous devez indiquer votre nom\'; 513 504 $this->addControl($ctrl);', 514 505 43=>'$ctrl= new jFormsControlinput(\'nom\'); … … 653 644 ); 654 645 655 656 protected $_JsControls = array(657 0=>'$label = \'Votre nom\';658 $js.="jForms.tControl = new jFormsControlString(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";659 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";660 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";661 $js.="jForms.tForm.addControl(jForms.tControl);\n";',662 1=>'$label = \'Votre nom\';663 $js.="jForms.tControl = new jFormsControlString(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";664 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";665 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";666 $js.="jForms.tForm.addControl(jForms.tControl);\n";',667 2=>'$label = \'Votre nom\';668 $js.="jForms.tControl = new jFormsControlString(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";669 $js.="jForms.tControl.required = true;\n";670 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";671 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";672 $js.="jForms.tForm.addControl(jForms.tControl);\n";',673 3=>'$label = jLocale::get(\'foo~bar\');674 $js.="jForms.tControl = new jFormsControlString(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";675 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";676 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";677 $js.="jForms.tForm.addControl(jForms.tControl);\n";',678 4=>'$label = \'Votre nom\';679 $js.="jForms.tControl = new jFormsControlString(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";680 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";681 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";682 $js.="jForms.tForm.addControl(jForms.tControl);\n";',683 5=>'$label = \'Votre nom\';684 $js.="jForms.tControl = new jFormsControlSecret(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";685 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";686 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";687 $js.="jForms.tForm.addControl(jForms.tControl);\n";',688 6=>'$label = \'Votre nom\';689 $js.="jForms.tControl = new jFormsControlString(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";690 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";691 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";692 $js.="jForms.tForm.addControl(jForms.tControl);\n";',693 7=>'$label = \'Votre nom\';694 $js.="jForms.tControl = new jFormsControlString(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";695 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";696 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";697 $js.="jForms.tForm.addControl(jForms.tControl);\n";',698 /*8=>'$label = \'Votre nom\';699 $js.="jForms.tControl = new jFormsControlString(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";700 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";701 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";702 $js.="jForms.tForm.addControl(jForms.tControl);\n";',703 9=>'$label = \'Votre nom\';704 $js.="jForms.tControl = new jFormsControlString(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";705 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";706 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";707 $js.="jForms.tForm.addControl(jForms.tControl);\n";',*/708 10=>'',709 11=>'$label = \'Votre nom\';710 $js.="jForms.tControl = new jFormsControlString(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";711 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";712 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";713 $js.="jForms.tForm.addControl(jForms.tControl);\n";',714 12=>'$label = \'Votre nom\';715 $js.="jForms.tControl = new jFormsControlBoolean(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";716 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";717 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";718 $js.="jForms.tForm.addControl(jForms.tControl);\n";',719 13=>'$label = \'Votre nom\';720 $js.="jForms.tControl = new jFormsControlDecimal(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";721 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";722 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";723 $js.="jForms.tForm.addControl(jForms.tControl);\n";',724 14=>'$label = \'Votre nom\';725 $js.="jForms.tControl = new jFormsControlInteger(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";726 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";727 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";728 $js.="jForms.tForm.addControl(jForms.tControl);\n";',729 15=>'$label = \'Votre nom\';730 $js.="jForms.tControl = new jFormsControlHexadecimal(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";731 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";732 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";733 $js.="jForms.tForm.addControl(jForms.tControl);\n";',734 16=>'$label = \'Votre nom\';735 $js.="jForms.tControl = new jFormsControlDatetime(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";736 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";737 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";738 $js.="jForms.tForm.addControl(jForms.tControl);\n";',739 17=>'$label = \'Votre nom\';740 $js.="jForms.tControl = new jFormsControlDate(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";741 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";742 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";743 $js.="jForms.tForm.addControl(jForms.tControl);\n";',744 18=>'$label = \'Votre nom\';745 $js.="jForms.tControl = new jFormsControlTime(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";746 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";747 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";748 $js.="jForms.tForm.addControl(jForms.tControl);\n";',749 19=>'$label = \'Votre nom\';750 $js.="jForms.tControl = new jFormsControlLocaledatetime(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";751 $js.="jForms.tControl.lang=\'".$GLOBALS[\'gJConfig\']->locale."\';\n";752 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";753 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";754 $js.="jForms.tForm.addControl(jForms.tControl);\n";',755 20=>'$label = \'Votre nom\';756 $js.="jForms.tControl = new jFormsControlLocaledate(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";757 $js.="jForms.tControl.lang=\'".$GLOBALS[\'gJConfig\']->locale."\';\n";758 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";759 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";760 $js.="jForms.tForm.addControl(jForms.tControl);\n";',761 21=>'$label = \'Votre nom\';762 $js.="jForms.tControl = new jFormsControlTime(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";763 $js.="jForms.tControl.lang=\'".$GLOBALS[\'gJConfig\']->locale."\';\n";764 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";765 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";766 $js.="jForms.tForm.addControl(jForms.tControl);\n";',767 22=>'$label = \'Votre nom\';768 $js.="jForms.tControl = new jFormsControlUrl(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";769 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";770 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";771 $js.="jForms.tForm.addControl(jForms.tControl);\n";',772 23=>'$label = \'Votre nom\';773 $js.="jForms.tControl = new jFormsControlEmail(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";774 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";775 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";776 $js.="jForms.tForm.addControl(jForms.tControl);\n";',777 24=>'$label = \'Votre nom\';778 $js.="jForms.tControl = new jFormsControlIpv4(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";779 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";780 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";781 $js.="jForms.tForm.addControl(jForms.tControl);\n";',782 25=>'$label = \'Votre nom\';783 $js.="jForms.tControl = new jFormsControlIpv6(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";784 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";785 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";786 $js.="jForms.tForm.addControl(jForms.tControl);\n";',787 26=>'$label = \'Avez-vous un nom ?\';788 $js.="jForms.tControl = new jFormsControlBoolean(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";789 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";790 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";791 $js.="jForms.tForm.addControl(jForms.tControl);\n";',792 27=>'$label = \'Votre nom\';793 $js.="jForms.tControl = new jFormsControlString(\'nom[]\', \'".str_replace("\'","\\\'",$label)."\');\n";794 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";795 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";796 $js.="jForms.tForm.addControl(jForms.tControl);\n";',797 28=>'$label = \'Votre nom\';798 $js.="jForms.tControl = new jFormsControlString(\'nom[]\', \'".str_replace("\'","\\\'",$label)."\');\n";799 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";800 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";801 $js.="jForms.tForm.addControl(jForms.tControl);\n";',802 29=>'$label = \'Votre nom\';803 $js.="jForms.tControl = new jFormsControlString(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";804 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";805 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";806 $js.="jForms.tForm.addControl(jForms.tControl);\n";',807 30=>'$label = \'Votre nom\';808 $js.="jForms.tControl = new jFormsControlString(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";809 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";810 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";811 $js.="jForms.tForm.addControl(jForms.tControl);\n";',812 31=>'$label = \'Votre nom\';813 $js.="jForms.tControl = new jFormsControlString(\'nom\', \'".str_replace("\'","\\\'",$label)."\');\n";814 $js.="jForms.tControl.errRequired=\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.required\',$label))."\';\n";815 $js.="jForms.tControl.errInvalid =\'".str_replace("\'","\\\'",jLocale::get(\'jelix~formserr.js.err.invalid\', $label))."\';\n";816 $js.="jForms.tForm.addControl(jForms.tControl);\n";',817
