Changeset 92
- Timestamp:
- 02/21/06 00:44:04 (3 years ago)
- Files:
-
- trunk/lib/jelix-modules/jelix/locales/en_US/formserr.ISO-8859-1.properties (added)
- trunk/lib/jelix-modules/jelix/locales/fr_FR/formserr.ISO-8859-1.properties (added)
- trunk/lib/jelix/core/jSelector.class.php (modified) (1 diff)
- trunk/lib/jelix/forms/jFormsCompiler.class.php (modified) (1 diff)
- trunk/lib/jelix/forms/jFormsControl.class.php (modified) (1 diff)
- trunk/lib/jelix/utils/jDatatype.class.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/jelix/core/jSelector.class.php
r68 r92 367 367 } 368 368 369 class jSelectorForm extends jSelectorModule { 370 public $type = 'form'; 371 372 function __construct($sel){ 373 global $gJConfig; 374 375 $this->_dirname = 'forms/'; 376 $this->_suffix = '.form.xml'; 377 $this->_cacheSuffix = '.php'; 378 $this->_compiler='jFormsCompiler'; 379 $this->_compilerPath=JELIX_LIB_FORMS_PATH.'jFormsCompiler.class.php'; 380 381 parent::__construct($sel); 382 } 383 } 369 384 370 385 trunk/lib/jelix/forms/jFormsCompiler.class.php
r86 r92 11 11 */ 12 12 13 require_once(JELIX_LIB_FORMS_PATH.'jFormsControl.class.php'); 13 14 14 15 class jFormsCompiler implements jISimpleCompiler { 15 16 16 public function compile($selector){17 global $gJCoord;18 $sel = clone $selector;17 public function compile($selector){ 18 global $gJCoord; 19 $sel = clone $selector; 19 20 20 $sourceFile = $selector->getPath();21 $cachefile = $selector->getCompiledFilePath();21 $sourceFile = $selector->getPath(); 22 $cachefile = $selector->getCompiledFilePath(); 22 23 23 // compilation du fichier xml24 $xml = simplexml_load_file ( $sourceFile);25 if(!$xml){26 return false;27 }24 // compilation du fichier xml 25 $xml = simplexml_load_file ( $sourceFile); 26 if(!$xml){ 27 return false; 28 } 28 29 29 $foundAction=false; 30 foreach($xml->request as $req){ 31 if(isset($req['type'])){ 32 $requesttype=$req['type']; 33 }else{ 34 trigger_error(jLocale::get('jelix~errors.ac.xml.request.type.attr.missing',array($sourceFile)), E_USER_ERROR); 35 jContext::pop(); 36 return false; 37 } 30 /*if(!isset($xml->model)){ 31 trigger_error(jLocale::get('jelix~formserr.missing.tag',array('model',$sourceFile)), E_USER_ERROR); 32 return false; 33 } 34 */ 38 35 39 } 36 $source=array(); 37 foreach($xml->children() as $controltype=>$control){ 38 39 $class = 'jFormsControl'.$controltype; 40 41 if(!class_exists($class,false)){ 42 trigger_error(jLocale::get('jelix~formserr.unknow.tag',array($controltype,$sourceFile)), E_USER_ERROR); 43 return false; 44 } 45 46 47 if(!isset($control['ref'])){ 48 trigger_error(jLocale::get('jelix~formserr.attribute.missing',array('ref',$controltype,$sourceFile)), E_USER_ERROR); 49 return false; 50 } 51 $source[]='$ctrl= new '.$class.'(\''.(string)$control['ref'].'\');'; 52 if(isset($control['type'])){ 53 $source[]='$ctrl->datatype=\''.(string)$control['type'].'\';'; 54 } 55 if(isset($control['readonly'])){ 56 $readonly=(string)$control['readonly']; 57 58 $source[]='$ctrl->readonly='.($readonly=='true'?'true':'false').';'; 59 } 60 if(isset($control['required'])){ 61 $required=(string)$control['required']; 62 $source[]='$ctrl->required='.($required=='true'?'true':'false').';'; 63 } 64 65 $source[]='$this->addControl($ctrl);'; 66 } 40 67 41 68 trunk/lib/jelix/forms/jFormsControl.class.php
r86 r92 13 13 14 14 abstract class jFormsControl { 15 public $name;16 15 public $type = null; 17 public $ref ;18 public $ refdao;19 public $ datatype;20 public $re quired;21 public $label ;22 public $labellocal ;16 public $ref=''; 17 public $datatype='string'; 18 public $required=false; 19 public $readonly=false; 20 public $label=''; 21 public $labellocal=''; 23 22 24 public $value; 25 public $defaultValue; 23 public $value=''; 24 public $defaultValue=''; 25 // public $pattern =null; 26 26 27 // var $regexp =null; // expression reguli� 28 27 function __construct($ref){ 28 $this->ref = $ref; 29 } 29 30 } 30 31 trunk/lib/jelix/utils/jDatatype.class.php
r86 r92 12 12 13 13 class jDatatype { 14 14 15 15 protected $length=null; 16 16 protected $minLength=null; … … 24 24 protected $totalDigits=null; 25 25 protected $fractionDigits=null; 26 26 27 27 protected $hasFacets= false; 28 28 29 29 protected $facets = array('length','minLength','maxLength', 'pattern', 'whitespace', 'maxInclusive', 30 30 'minInclusive', 'maxExclusive', 'minExclusive', 'totalDigits', 'fractionDigits'); 31 31 32 32 function __construct(){ 33 33 } 34 34 35 35 public function addFacets($type,$value=null){ 36 36 $this->hasFacets = true; … … 51 51 $this->$type = $value; 52 52 } 53 53 54 54 public function check($value){ 55 55 if($this->_checkType($value)){ … … 61 61 return false; 62 62 } 63 63 64 64 protected function _checkType($value) { return true; } 65 65 66 66 protected function _checkFacets($value){ 67 67 if($this->length !== null && strlen($value) > $this->length) … … 75 75 return true; 76 76 } 77 protected function _checkValueFacets($value){ 77 protected function _checkValueFacets($value){ 78 78 if($this->maxInclusive !== null && $value > $this->maxInclusive) 79 79 return false; … … 93 93 94 94 class jDatatypeBoolean extends jDatatype { 95 protected function _checkType($value) { return true; }; 95 protected function _checkType($value) { return ($value == 'true' || $value=='false'); }; 96 protected function _checkValueFacets($value){ return true; } 97 protected function _checkFacets($value){ return true; } 96 98 } 97 99 98 100 class jDatatypeDecimal extends jDatatype { 101 // xxxx.yyyyy 102 protected function _checkType($value) { return ; }; 99 103 } 100 104 101 105 class jDatatypeFloat extends jDatatype { 106 //m �2^e, avec m < 2^24, et -149 <= e <= 104 107 //1E4, 1267.43233E12, 12.78e-2, 12 , -0, 0 INF 102 108 } 103 109 104 110 class jDatatypeDouble extends jDatatype { 111 //m �2^e, avec m < 2^53, et -1075 <= e<= 970 112 105 113 } 106 114 107 115 class jDatatypeDateTime extends jDatatype { 116 //'-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)? 117 108 118 } 109 119
