Changeset 914
- Timestamp:
- 04/29/08 16:15:04 (3 months ago)
- Files:
-
- branches/experimental/jforms-groups/lib/jelix-modules/junittests/classes/junittestcase.class.php (modified) (2 diffs)
- branches/experimental/jforms-groups/lib/jelix-modules/junittests/classes/junittestcase.class.php (modified) (2 diffs)
- branches/experimental/jforms-groups/lib/jelix-modules/junittests/classes/junittestcase.class.php (modified) (2 diffs)
- branches/experimental/jforms-groups/lib/jelix-modules/junittests/classes/junittestcase.class.php (modified) (2 diffs)
- branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php (modified) (41 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php (modified) (41 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php (modified) (41 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php (modified) (41 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler.class.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler.class.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler.class.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler.class.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php (modified) (18 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php (modified) (18 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php (modified) (18 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_0.class.php (modified) (18 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_1.class.php (modified) (4 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_1.class.php (modified) (4 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_1.class.php (modified) (4 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsCompiler_jf_1_1.class.php (modified) (4 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php (modified) (24 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php (modified) (24 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php (modified) (24 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsControl.class.php (modified) (24 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsDataContainer.class.php (modified) (3 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsDataContainer.class.php (modified) (3 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsDataContainer.class.php (modified) (3 diffs)
- branches/experimental/jforms-groups/lib/jelix/forms/jFormsDataContainer.class.php (modified) (3 diffs)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (2 diffs)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (2 diffs)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (2 diffs)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformsbuilder.php (modified) (2 diffs)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformscompiler.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformscompiler.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformscompiler.php (modified) (1 diff)
- branches/experimental/jforms-groups/lib/jelix/plugins/jforms/html/html.jformscompiler.php (modified) (1 diff)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.check_datas.html_cli.php (modified) (1 diff)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.check_datas.html_cli.php (modified) (1 diff)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.check_datas.html_cli.php (modified) (1 diff)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.check_datas.html_cli.php (modified) (1 diff)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.compiler.html_cli.php (modified) (5 diffs)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.compiler.html_cli.php (modified) (5 diffs)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.compiler.html_cli.php (modified) (5 diffs)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.compiler.html_cli.php (modified) (5 diffs)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html_cli.php (modified) (2 diffs)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html_cli.php (modified) (2 diffs)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html_cli.php (modified) (2 diffs)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.htmlbuilder.html_cli.php (modified) (2 diffs)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.html_cli.php (modified) (13 diffs)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.html_cli.php (modified) (13 diffs)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.html_cli.php (modified) (13 diffs)
- branches/experimental/jforms-groups/testapp/modules/jelix_tests/tests/jforms.html_cli.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/experimental/jforms-groups/lib/jelix-modules/junittests/classes/junittestcase.class.php
r483 r914 143 143 $n = (string)$child['p']; 144 144 $v = $value->$n; 145 }elseif(isset($child['method'])){ 145 }elseif(isset($child['method'])){ // attribute method contain the method name and arguments 146 146 $n = (string)$child['method']; 147 147 eval('$v=$value->'.$n.';'); … … 180 180 $n = $key ++; 181 181 } 182 /*$this->dump($n, 'n=');183 $this->dump($value, 'value');184 if(isset($value[$n]))185 $this->dump($value[$n],'value de n OK');186 else187 $this->dump('!!!!! value de n pas ok');*/188 182 if($this->assertTrue(array_key_exists($n,$value),$name.'['.$n.'] doesn\'t exist arrrg'.$errormessage)){ 189 183 $v = $value[$n]; branches/experimental/jforms-groups/lib/jelix-modules/junittests/classes/junittestcase.class.php
r483 r914 143 143 $n = (string)$child['p']; 144 144 $v = $value->$n; 145 }elseif(isset($child['method'])){ 145 }elseif(isset($child['method'])){ // attribute method contain the method name and arguments 146 146 $n = (string)$child['method']; 147 147 eval('$v=$value->'.$n.';'); … … 180 180 $n = $key ++; 181 181 } 182 /*$this->dump($n, 'n=');183 $this->dump($value, 'value');184 if(isset($value[$n]))185 $this->dump($value[$n],'value de n OK');186 else187 $this->dump('!!!!! value de n pas ok');*/188 182 if($this->assertTrue(array_key_exists($n,$value),$name.'['.$n.'] doesn\'t exist arrrg'.$errormessage)){ 189 183 $v = $value[$n]; branches/experimental/jforms-groups/lib/jelix-modules/junittests/classes/junittestcase.class.php
r483 r914 143 143 $n = (string)$child['p']; 144 144 $v = $value->$n; 145 }elseif(isset($child['method'])){ 145 }elseif(isset($child['method'])){ // attribute method contain the method name and arguments 146 146 $n = (string)$child['method']; 147 147 eval('$v=$value->'.$n.';'); … … 180 180 $n = $key ++; 181 181 } 182 /*$this->dump($n, 'n=');183 $this->dump($value, 'value');184 if(isset($value[$n]))185 $this->dump($value[$n],'value de n OK');186 else187 $this->dump('!!!!! value de n pas ok');*/188 182 if($this->assertTrue(array_key_exists($n,$value),$name.'['.$n.'] doesn\'t exist arrrg'.$errormessage)){ 189 183 $v = $value[$n]; branches/experimental/jforms-groups/lib/jelix-modules/junittests/classes/junittestcase.class.php
r483 r914 143 143 $n = (string)$child['p']; 144 144 $v = $value->$n; 145 }elseif(isset($child['method'])){ 145 }elseif(isset($child['method'])){ // attribute method contain the method name and arguments 146 146 $n = (string)$child['method']; 147 147 eval('$v=$value->'.$n.';'); … … 180 180 $n = $key ++; 181 181 } 182 /*$this->dump($n, 'n=');183 $this->dump($value, 'value');184 if(isset($value[$n]))185 $this->dump($value[$n],'value de n OK');186 else187 $this->dump('!!!!! value de n pas ok');*/188 182 if($this->assertTrue(array_key_exists($n,$value),$name.'['.$n.'] doesn\'t exist arrrg'.$errormessage)){ 189 183 $v = $value[$n]; branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js
r862 r914 315 315 this.datatype = datatype; 316 316 this.required = false; 317 this.readonly = false;318 317 this.errInvalid = ''; 319 318 this.errRequired = ''; branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js
r862 r914 315 315 this.datatype = datatype; 316 316 this.required = false; 317 this.readonly = false;318 317 this.errInvalid = ''; 319 318 this.errRequired = ''; branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js
r862 r914 315 315 this.datatype = datatype; 316 316 this.required = false; 317 this.readonly = false;318 317 this.errInvalid = ''; 319 318 this.errRequired = ''; branches/experimental/jforms-groups/lib/jelix-www/js/jforms.js
r862 r914 315 315 this.datatype = datatype; 316 316 this.required = false; 317 this.readonly = false;318 317 this.errInvalid = ''; 319 318 this.errRequired = ''; branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php
r911 r914 40 40 * @see jFormsControl 41 41 */ 42 protected $ _controls = array();42 protected $controls = array(); 43 43 44 44 /** … … 48 48 * @see jFormsControl 49 49 */ 50 protected $ _topControls = array();50 protected $topControls = array(); 51 51 52 52 /** … … 56 56 * @see jFormsControl 57 57 */ 58 protected $ _submits = array();58 protected $submits = array(); 59 59 60 60 /** … … 64 64 * @since 1.0 65 65 */ 66 protected $ _reset = null;66 protected $reset = null; 67 67 68 68 /** … … 72 72 * @see jFormsControl 73 73 */ 74 protected $ _uploads = array();74 protected $uploads = array(); 75 75 76 76 /** … … 80 80 * @see jFormsControl 81 81 */ 82 protected $ _hiddens = array();82 protected $hiddens = array(); 83 83 84 84 /** … … 88 88 * @see jFormsControl 89 89 */ 90 protected $ _htmleditors = array();90 protected $htmleditors = array(); 91 91 92 92 /** … … 94 94 * @var jFormsDataContainer 95 95 */ 96 protected $ _container = null;96 protected $container = null; 97 97 98 98 /** … … 100 100 * @var boolean 101 101 */ 102 protected $ _builders = array();102 protected $builders = array(); 103 103 104 104 /** … … 107 107 * @var array 108 108 */ 109 protected $ _modifiedControls = array();109 protected $modifiedControls = array(); 110 110 /** 111 111 * the form selector 112 112 * @var string 113 113 */ 114 protected $ _sel;114 protected $sel; 115 115 116 116 /** … … 120 120 */ 121 121 public function __construct($sel, &$container, $reset = false){ 122 $this-> _container = & $container;122 $this->container = & $container; 123 123 if($reset){ 124 $this-> _container->clear();125 } 126 $this-> _container->updatetime = time();127 $this-> _sel = $sel;124 $this->container->clear(); 125 } 126 $this->container->updatetime = time(); 127 $this->sel = $sel; 128 128 } 129 129 … … 133 133 public function initFromRequest(){ 134 134 $req = $GLOBALS['gJCoord']->request; 135 $this-> _modifiedControls=array();136 foreach($this-> _topControls as $name=>$ctrl){137 if(!$this-> _container->isActivated($name) || $this->_container->isReadonly($name))135 $this->modifiedControls=array(); 136 foreach($this->topControls as $name=>$ctrl){ 137 if(!$this->container->isActivated($name) || $this->container->isReadOnly($name)) 138 138 continue; 139 $ this->setData($name, $ctrl->getValueFromRequest($req), true);139 $ctrl->setValueFromRequest($req); 140 140 } 141 141 } … … 146 146 */ 147 147 public function check(){ 148 $this->_container->errors = array(); 149 foreach($this->_controls as $name=>$ctrl){ 150 if(!$this->_container->isActivated($name)) 151 continue; 152 $err = $ctrl->check(); 153 if($err !== null) 154 $this->_container->errors[$name]= $err; 155 } 156 return count($this->_container->errors) == 0; 148 $this->container->errors = array(); 149 foreach($this->controls as $name=>$ctrl){ 150 if($this->container->isActivated($name)) 151 $ctrl->check(); 152 } 153 return count($this->container->errors) == 0; 157 154 } 158 155 … … 166 163 public function initFromDao($daoSelector, $key = null, $dbProfil=''){ 167 164 if($key === null) 168 $key = $this-> _container->formId;165 $key = $this->container->formId; 169 166 $dao = jDao::create($daoSelector, $dbProfil); 170 167 $daorec = $dao->get($key); … … 173 170 $key = var_export($key,true); 174 171 throw new jExceptionForms('jelix~formserr.bad.formid.for.dao', 175 array($daoSelector, $key, $this-> _sel));172 array($daoSelector, $key, $this->sel)); 176 173 } 177 174 178 175 $prop = $dao->getProperties(); 179 foreach($this-> _controls as $name=>$ctrl){176 foreach($this->controls as $name=>$ctrl){ 180 177 if(isset($prop[$name])) { 181 $ this->_container->data[$name] = $ctrl->prepareValueFromDao($daorec->$name, $prop[$name]['datatype']);178 $ctrl->setDataFromDao($daorec->$name, $prop[$name]['datatype']); 182 179 } 183 180 } … … 196 193 197 194 if($key === null) 198 $key = $this-> _container->formId;195 $key = $this->container->formId; 199 196 200 197 if($key != null && ($daorec = $dao->get($key))) { … … 208 205 209 206 $prop = $dao->getProperties(); 210 foreach($this-> _controls as $name=>$ctrl){207 foreach($this->controls as $name=>$ctrl){ 211 208 if(!isset($prop[$name])) 212 209 continue; 213 210 214 if(is_array($this-> _container->data[$name])){215 if( count ($this-> _container->data[$name]) ==1){216 $daorec->$name = $this-> _container->data[$name][0];211 if(is_array($this->container->data[$name])){ 212 if( count ($this->container->data[$name]) ==1){ 213 $daorec->$name = $this->container->data[$name][0]; 217 214 }else{ 218 215 // do nothing for arrays ? … … 220 217 } 221 218 }else{ 222 $daorec->$name = $this-> _container->data[$name];219 $daorec->$name = $this->container->data[$name]; 223 220 } 224 221 … … 283 280 * in this order : properties for the formId, followed by the property which contains 284 281 * the value. 285 * @param string $ controlName the name of the control282 * @param string $name the name of the control 286 283 * @param string $daoSelector the selector of a dao file 287 284 * @param mixed $primaryKey the primary key if the form have no id. (optional) … … 290 287 * @see jDao 291 288 */ 292 public function initControlFromDao($ controlName, $daoSelector, $primaryKey = null, $primaryKeyNames=null, $dbProfil=''){293 294 if(!$this-> _controls[$controlName]->isContainer()){295 throw new jExceptionForms('jelix~formserr.control.not.container', array($ controlName, $this->_sel));296 } 297 298 if(!$this-> _container->formId)299 throw new jExceptionForms('jelix~formserr.formid.undefined.for.dao', array($ controlName, $this->_sel));289 public function initControlFromDao($name, $daoSelector, $primaryKey = null, $primaryKeyNames=null, $dbProfil=''){ 290 291 if(!$this->controls[$name]->isContainer()){ 292 throw new jExceptionForms('jelix~formserr.control.not.container', array($name, $this->sel)); 293 } 294 295 if(!$this->container->formId) 296 throw new jExceptionForms('jelix~formserr.formid.undefined.for.dao', array($name, $this->sel)); 300 297 301 298 if($primaryKey === null) 302 $primaryKey = $this-> _container->formId;299 $primaryKey = $this->container->formId; 303 300 304 301 if(!is_array($primaryKey)) … … 323 320 $val[]=$res->$valuefield; 324 321 } 325 $this-> _container->data[$controlName]=$val;322 $this->controls[$name]->setData($val); 326 323 } 327 324 … … 355 352 public function saveControlToDao($controlName, $daoSelector, $primaryKey = null, $primaryKeyNames=null, $dbProfil=''){ 356 353 357 if(!$this-> _controls[$controlName]->isContainer()){358 throw new jExceptionForms('jelix~formserr.control.not.container', array($controlName, $this-> _sel));359 } 360 361 $values = $this-> _container->data[$controlName];354 if(!$this->controls[$controlName]->isContainer()){ 355 throw new jExceptionForms('jelix~formserr.control.not.container', array($controlName, $this->sel)); 356 } 357 358 $values = $this->container->data[$controlName]; 362 359 if(!is_array($values) && $values != '') 363 throw new jExceptionForms('jelix~formserr.value.not.array', array($controlName, $this-> _sel));364 365 if(!$this-> _container->formId && !$primaryKey)366 throw new jExceptionForms('jelix~formserr.formid.undefined.for.dao', array($controlName, $this-> _sel));360 throw new jExceptionForms('jelix~formserr.value.not.array', array($controlName, $this->sel)); 361 362 if(!$this->container->formId && !$primaryKey) 363 throw new jExceptionForms('jelix~formserr.formid.undefined.for.dao', array($controlName, $this->sel)); 367 364 368 365 if($primaryKey === null) 369 $primaryKey = $this-> _container->formId;366 $primaryKey = $this->container->formId; 370 367 371 368 if(!is_array($primaryKey)) … … 401 398 * @see jFormsBase::check 402 399 */ 403 public function getErrors(){ return $this-> _container->errors; }400 public function getErrors(){ return $this->container->errors; } 404 401 405 402 /** … … 409 406 */ 410 407 public function setErrorOn($field, $mesg){ 411 $this-> _container->errors[$field]=$mesg;408 $this->container->errors[$field]=$mesg; 412 409 } 413 410 … … 417 414 * @param string $value the data value 418 415 */ 419 public function setData($name, $value, $registerInModified = false){ 420 if($this->_controls[$name]->type == 'checkbox') { 421 if($value != $this->_controls[$name]->valueOnCheck){ 422 if($value =='on') 423 $value = $this->_controls[$name]->valueOnCheck; 424 else 425 $value = $this->_controls[$name]->valueOnUncheck; 426 } 427 } 428 if($registerInModified && $this->_container->data[$name] != $value) 429 $this->_modifiedControls[$name] = $this->_container->data[$name]; 430 $this->_container->data[$name]=$value; 416 public function setData($name, $value) { 417 $this->controls[$name]->setData($value); 431 418 } 432 419 433 420 /** 434 421 * 435 * @param string $name the name of the control/data422 * @param string $name the name of the control/data 436 423 * @return string the data value 437 424 */ 438 public function getData($name) {439 if(isset($this-> _container->data[$name]))440 return $this-> _container->data[$name];425 public function getData($name) { 426 if(isset($this->container->data[$name])) 427 return $this->container->data[$name]; 441 428 else return null; 442 429 } … … 445 432 * @return array form data 446 433 */ 447 public function getAllData(){ return $this->_container->data; } 434 public function getAllData(){ return $this->container->data; } 435 448 436 /** 449 437 * DEPRECATED, use getAllData() instead. … … 453 441 public function getDatas(){ 454 442 trigger_error('jFormsBase::getDatas is deprecated, use getAllData instead',E_USER_NOTICE); 455 return $this->_container->data; 456 } 443 return $this->container->data; 444 } 445 446 447 function setModifiedFlag($name){ 448 $this->modifiedControls[$name] = $this->container->data[$name]; 449 } 450 457 451 458 452 /** … … 463 457 */ 464 458 public function deactivate($name, $deactivation=true) { 465 $this->_container->deactivate($name, $deactivation); 466 if($this->_controls[$name] implements jFormsControlGroups) { 467 $this->_controls[$name]->deactivate($this, $r); 468 } 459 $this->controls[$name]->deactivate($deactivation); 469 460 } 470 461 … … 475 466 */ 476 467 public function isActivated($name) { 477 return $this-> _container->isActivated($name);468 return $this->container->isActivated($name); 478 469 } 479 470 … … 484 475 */ 485 476 public function setReadOnly($name, $r = true) { 486 $this->_container->setReadOnly($name, $r); 487 if($this->_controls[$name] implements jFormsControlGroups) { 488 $this->_controls[$name]->setReadOnly($this, $r); 489 } 477 $this->controls[$name]->setReadOnly($r); 490 478 } 491 479 … … 495 483 */ 496 484 public function isReadOnly($name) { 497 return $this-> _container->isReadOnly($name);485 return $this->container->isReadOnly($name); 498 486 } 499 487 … … 502 490 * @return jFormsDataContainer 503 491 */ 504 public function getContainer(){ return $this-> _container; }492 public function getContainer(){ return $this->container; } 505 493 506 494 /** 507 495 * @return array of jFormsControl objects 508 496 */ 509 public function getControls(){ return $this-> _controls; }497 public function getControls(){ return $this->controls; } 510 498 511 499 /** … … 514 502 * @since jelix 1.0 515 503 */ 516 public function getControl($name){ return $this-> _controls[$name]; }504 public function getControl($name){ return $this->controls[$name]; } 517 505 518 506 /** 519 507 * @return array of jFormsControl objects 520 508 */ 521 public function getSubmits(){ return $this-> _submits; }509 public function getSubmits(){ return $this->submits; } 522 510 523 511 /** … … 525 513 * @since 1.1 526 514 */ 527 public function getHiddens(){ return $this-> _hiddens; }515 public function getHiddens(){ return $this->hiddens; } 528 516 529 517 /** … … 531 519 * @since 1.1 532 520 */ 533 public function getHtmlEditors(){ return $this-> _htmleditors; }521 public function getHtmlEditors(){ return $this->htmleditors; } 534 522 535 523 /** … … 537 525 * @since 1.1 538 526 */ 539 public function getModifiedControls(){ return $this-> _modifiedControls; }527 public function getModifiedControls(){ return $this->modifiedControls; } 540 528 541 529 /** 542 530 * @return array of jFormsControl objects 543 531 */ 544 public function getReset(){ return $this-> _reset; }532 public function getReset(){ return $this->reset; } 545 533 546 534 /** 547 535 * @return string the formId 548 536 */ 549 public function id(){ return $this-> _container->formId; }537 public function id(){ return $this->container->formId; } 550 538 551 539 /** 552 540 * @return boolean 553 541 */ 554 public function hasUpload() { return count($this-> _uploads)>0; }542 public function hasUpload() { return count($this->uploads)>0; } 555 543 556 544 /** … … 559 547 */ 560 548 public function getBuilder($buildertype){ 561 if(isset($this-> _builders[$buildertype])){562 if(isset($this-> _builders[$buildertype]['inst']))563 return $this-> _builders[$buildertype]['inst'];549 if(isset($this->builders[$buildertype])){ 550 if(isset($this->builders[$buildertype]['inst'])) 551 return $this->builders[$buildertype]['inst']; 564 552 include_once(JELIX_LIB_PATH.'forms/jFormsBuilderBase.class.php'); 565 include_once ($this-> _builders[$buildertype][0]);566 $c = $this->_builders[$buildertype][1];567 $o = $this-> _builders[$buildertype]['inst'] = new $c($this);553 include_once ($this->builders[$buildertype][0]); 554 $c = $this->builders[$buildertype][1]; 555 $o = $this->builders[$buildertype]['inst'] = new $c($this); 568 556 return $o; 569 557 }else{ 570 throw new jExceptionForms('jelix~formserr.invalid.form.builder', array($buildertype, $this-> _sel));558 throw new jExceptionForms('jelix~formserr.invalid.form.builder', array($buildertype, $this->sel)); 571 559 } 572 560 } … … 584 572 public function saveFile($controlName, $path='', $alternateName='') { 585 573 if ($path == '') { 586 $path = JELIX_APP_VAR_PATH.'uploads/'.$this-> _sel.'/';574 $path = JELIX_APP_VAR_PATH.'uploads/'.$this->sel.'/'; 587 575 } else if (substr($path, -1, 1) != '/') { 588 576 $path.='/'; 589 577 } 590 578 591 if(!isset($this-> _controls[$controlName]) || $this->_controls[$controlName]->type != 'upload')592 throw new jExceptionForms('jelix~formserr.invalid.upload.control.name', array($controlName, $this-> _sel));579 if(!isset($this->controls[$controlName]) || $this->controls[$controlName]->type != 'upload') 580 throw new jExceptionForms('jelix~formserr.invalid.upload.control.name', array($controlName, $this->sel)); 593 581 594 582 if(!isset($_FILES[$controlName]) || $_FILES[$controlName]['error']!= UPLOAD_ERR_OK) 595 583 return false; 596 584 597 if($this-> _controls[$controlName]->maxsize && $_FILES[$controlName]['size'] > $this->_controls[$controlName]->maxsize){585 if($this->controls[$controlName]->maxsize && $_FILES[$controlName]['size'] > $this->controls[$controlName]->maxsize){ 598 586 return false; 599 587 } … … 615 603 public function saveAllFiles($path='') { 616 604 if ($path == '') { 617 $path = JELIX_APP_VAR_PATH.'uploads/'.$this-> _sel.'/';605 $path = JELIX_APP_VAR_PATH.'uploads/'.$this->sel.'/'; 618 606 } else if (substr($path, -1, 1) != '/') { 619 607 $path.='/'; 620 608 } 621 609 622 if(count($this-> _uploads))610 if(count($this->uploads)) 623 611 jFile::createDir($path); 624 612 625 foreach($this-> _uploads as $ref=>$ctrl){613 foreach($this->uploads as $ref=>$ctrl){ 626 614 627 615 if(!isset($_FILES[$ref]) || $_FILES[$ref]['error']!= UPLOAD_ERR_OK) … … 639 627 */ 640 628 protected function addControl($control){ 641 if(!$subcontrol) { 642 $this->_topControls [$control->ref] = $control; 643 } 629 $this->topControls [$control->ref] = $control; 644 630 $this->addChildControl($control); 645 631 … … 655 641 */ 656 642 protected function addChildControl($control){ 657 $this-> _controls [$control->ref] = $control;643 $this->controls [$control->ref] = $control; 658 644 if($control->type =='submit') 659 $this-> _submits [$control->ref] = $control;645 $this->submits [$control->ref] = $control; 660 646 else if($control->type =='reset') 661 $this-> _reset = $control;647 $this->reset = $control; 662 648 else if($control->type =='upload') 663 $this-> _uploads [$control->ref] = $control;649 $this->uploads [$control->ref] = $control; 664 650 else if($control->type =='hidden') 665 $this-> _hiddens [$control->ref] = $control;651 $this->hiddens [$control->ref] = $control; 666 652 else if($control->type == 'htmleditor') 667 $this-> _htmleditors [$control->ref] = $control;653 $this->htmleditors [$control->ref] = $control; 668 654 669 655 $control->setForm($this); 670 656 671 if(!isset($this-> _container->data[$control->ref])){657 if(!isset($this->container->data[$control->ref])){ 672 658 if ( $control->datatype instanceof jDatatypeDateTime && $control->defaultValue == 'now') { 673 659 $dt = new jDateTime(); 674 660 $dt->now(); 675 $this-> _container->data[$control->ref] = $dt->toString($control->datatype->getFormat());661 $this->container->data[$control->ref] = $dt->toString($control->datatype->getFormat()); 676 662 } 677 663 else { 678 $this-> _container->data[$control->ref] = $control->defaultValue;664 $this->container->data[$control->ref] = $control->defaultValue; 679 665 } 680 666 } branches/experimental/jforms-groups/lib/jelix/forms/jFormsBase.class.php
r911 r914 40 40 * @see jFormsControl 41 41 */ 42 protected $ _controls = array();42 protected $controls = array(); 43 43 44 44 /** … … 48 48 * @see jFormsControl 49 49 */ 50 protected $ _topControls = array();50 protected $topControls = array(); 51 51 52 52 /** … … 56 56 * @see jFormsControl 57 57 */ 58 protected $ _submits = array();58 protected $submits = array(); 59 59 60 60 /** … … 64 64 * @since 1.0 65 65 */ 66 protected $ _reset = null;66 protected $reset = null; 67 67 68 68 /** … … 72 72 * @see jFormsControl 73 73 */ 74 protected $ _uploads = array();74 protected $uploads = array(); 75 75 76 76 /** … … 80 80 * @see jFormsControl 81 81 */ 82 protected $ _hiddens = array();82 protected $hiddens = array(); 83 83 84 84 /** … … 88 88 * @see jFormsControl 89 89 */ 90 protected $ _htmleditors = array();90 protected $htmleditors = array(); 91 91 92 92 /** … … 94 94 * @var jFormsDataContainer 95 95 */ 96 protected $ _container = null;96 protected $container = null; 97 97 98 98 /** … … 100 100 * @var boolean 101 101 */ 102 protected $ _builders = array();102 protected $builders = array(); 103 103 104 104 /** … … 107 107 * @var array 108 108 */ 109 protected $ _modifiedControls = array();109 protected $modifiedControls = array(); 110 110 /** 111 111 * the form selector 112 112 * @var string 113 113 */ 114 protected $ _sel;114 protected $sel; 115 115 116<
