Changeset 92

Show
Ignore:
Timestamp:
02/21/06 00:44:04 (3 years ago)
Author:
laurentj
Message:

travail sur jforms

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/jelix/core/jSelector.class.php

    r68 r92  
    367367} 
    368368 
     369class 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} 
    369384 
    370385 
  • trunk/lib/jelix/forms/jFormsCompiler.class.php

    r86 r92  
    1111*/ 
    1212 
     13require_once(JELIX_LIB_FORMS_PATH.'jFormsControl.class.php'); 
    1314 
    1415class jFormsCompiler implements jISimpleCompiler { 
    1516 
    16     public function compile($selector){ 
    17         global $gJCoord; 
    18         $sel = clone $selector; 
     17   public function compile($selector){ 
     18      global $gJCoord; 
     19      $sel = clone $selector; 
    1920 
    20         $sourceFile = $selector->getPath(); 
    21         $cachefile = $selector->getCompiledFilePath(); 
     21      $sourceFile = $selector->getPath(); 
     22      $cachefile = $selector->getCompiledFilePath(); 
    2223 
    23         // compilation du fichier xml 
    24         $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     
    2829 
    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      */ 
    3835 
    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      } 
    4067 
    4168 
  • trunk/lib/jelix/forms/jFormsControl.class.php

    r86 r92  
    1313 
    1414abstract class jFormsControl { 
    15    public $name; 
    1615   public $type = null; 
    17    public $ref
    18    public $refdao
    19    public $datatype; 
    20    public $required
    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=''
    2322 
    24    public $value; 
    25    public $defaultValue; 
     23   public $value=''; 
     24   public $defaultValue=''; 
     25//  public $pattern =null; 
    2626 
    27 //   var $regexp       =null;   // expression reguli� 
    28  
     27   function __construct($ref){ 
     28      $this->ref = $ref; 
     29   } 
    2930} 
    3031 
  • trunk/lib/jelix/utils/jDatatype.class.php

    r86 r92  
    1212 
    1313class jDatatype { 
    14    
     14 
    1515  protected $length=null; 
    1616  protected $minLength=null; 
     
    2424  protected $totalDigits=null; 
    2525  protected $fractionDigits=null; 
    26    
     26 
    2727  protected $hasFacets= false; 
    28   
     28 
    2929  protected $facets = array('length','minLength','maxLength', 'pattern', 'whitespace', 'maxInclusive', 
    3030            'minInclusive', 'maxExclusive', 'minExclusive', 'totalDigits', 'fractionDigits'); 
    31    
     31 
    3232  function __construct(){ 
    3333  } 
    34    
     34 
    3535  public function addFacets($type,$value=null){ 
    3636     $this->hasFacets = true; 
     
    5151      $this->$type = $value; 
    5252  } 
    53    
     53 
    5454  public function check($value){ 
    5555    if($this->_checkType($value)){ 
     
    6161      return false; 
    6262  } 
    63    
     63 
    6464  protected function _checkType($value) { return true; } 
    65    
     65 
    6666  protected function _checkFacets($value){ 
    6767    if($this->length !== null && strlen($value) > $this->length) 
     
    7575    return true; 
    7676  } 
    77   protected function _checkValueFacets($value){     
     77  protected function _checkValueFacets($value){ 
    7878    if($this->maxInclusive !== null && $value > $this->maxInclusive) 
    7979        return false; 
     
    9393 
    9494class 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; } 
    9698} 
    9799 
    98100class jDatatypeDecimal extends jDatatype { 
     101 // xxxx.yyyyy 
     102  protected function _checkType($value) { return ; }; 
    99103} 
    100104 
    101105class 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 
    102108} 
    103109 
    104110class jDatatypeDouble extends jDatatype { 
     111//m �2^e, avec m < 2^53, et -1075 <= e<= 970 
     112 
    105113} 
    106114 
    107115class jDatatypeDateTime extends jDatatype { 
     116//'-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)? 
     117 
    108118} 
    109119 
Download in other formats: Unified Diff Zip Archive