Changeset 374
- Timestamp:
- 03/01/07 10:39:38 (2 years ago)
- Files:
-
- branches/experimental (added)
- branches/experimental/jforms (copied) (copied from trunk)
- branches/experimental/jforms/lib/jelix-www/js/jforms.js (added)
- branches/experimental/jforms/lib/jelix/forms/jFormsBase.class.php (modified) (2 diffs)
- branches/experimental/jforms/lib/jelix/forms/jFormsBuilderBase.class.php (added)
- branches/experimental/jforms/lib/jelix/forms/jFormsCompiler.class.php (modified) (5 diffs)
- branches/experimental/jforms/lib/jelix/forms/jforms_jstemplate.php (added)
- branches/experimental/jforms/lib/jelix/tpl/plugins/html/block.form.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/experimental/jforms/lib/jelix/forms/jFormsBase.class.php
r324 r374 5 5 * @author Laurent Jouanneau 6 6 * @contributor 7 * @copyright 2006 Laurent Jouanneau7 * @copyright 2006-2007 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 … … 180 180 181 181 /** 182 * @return array of jFormsControl objects 183 */ 184 public function getControls(){ return $this->_controls; } 185 186 /** 182 187 * @return string the formId 183 188 */ branches/experimental/jforms/lib/jelix/forms/jFormsCompiler.class.php
r335 r374 5 5 * @author Laurent Jouanneau 6 6 * @contributor 7 * @copyright 2006 Laurent Jouanneau7 * @copyright 2006-2007 Laurent Jouanneau 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 … … 29 29 $sourceFile = $selector->getPath(); 30 30 $cachefile = $selector->getCompiledFilePath(); 31 $cachebuildfile = $selector->getCompiledBuildFilePath (); 31 32 32 33 // compilation du fichier xml … … 46 47 $source[]=' public function __construct(&$container, $reset = false){'; 47 48 $source[]=' parent::__construct($container, $reset); '; 49 50 51 $srcbuild=array(); 52 $srcbuild[]='<?php class '.$selector->getClass().'_HtmlBuilder extends jFormsHtmlBuilderBase {'; 53 $srcbuild[]=' public function __construct($form, $action){'; 54 $srcbuild[]=' parent::__construct($form, $action); '; 55 $srcbuild[]=' }'; 56 57 $srcjs=array(); 58 59 48 60 foreach($xml->children() as $controltype=>$control){ 49 61 … … 83 95 84 96 if(isset($control->label['locale'])){ 85 $source[]='$ctrl->labellocale=\''.(string)$control->label['locale'].'\';'; 97 $label=''; 98 $labellocale=(string)$control->label['locale']; 99 $source[]='$ctrl->labellocale=\''.$labellocale.'\';'; 86 100 }else{ 87 $source[]='$ctrl->label=\''.str_replace("'","\\'",(string)$control->label).'\';'; 88 } 101 $label=(string)$control->label; 102 $labellocale=''; 103 $source[]='$ctrl->label=\''.str_replace("'","\\'",$label).'\';'; 104 } 105 106 if(!isset($control->label)){ 107 throw new jException('jelix~formserr.tag.missing',array('label',$controltype,$sourceFile)); 108 } 109 110 if(isset($control->label['locale'])){ 111 $label=''; 112 $labellocale=(string)$control->label['locale']; 113 $source[]='$ctrl->labellocale=\''.$labellocale.'\';'; 114 }else{ 115 $label=(string)$control->label; 116 $labellocale=''; 117 $source[]='$ctrl->label=\''.str_replace("'","\\'",$label).'\';'; 118 } 119 120 121 89 122 switch($controltype){ 90 123 case 'input': … … 142 175 143 176 jFile::write($cachefile, implode("\n", $source)); 177 178 179 $srcbuild[]=' public function getJavascriptCheck(){'; 180 $srcbuild[]= implode("\n", $srcjs); 181 $srcbuild[]=' return $verif; }'; 182 $srcbuild[]='} ?>'; 183 184 jFile::write($cachebuildfile, implode("\n", $srcbuild)); 185 144 186 return true; 145 187 } 146 188 189 190 /* on g�re en php, du php qui g�re du javascript ! oui oui :-D 191 192 au final, le javascript g�r�ans la page html doit ressembler �ela 193 194 gForm = new jFormsForm('name'); 195 gForm.setDecorator(new jFormsErrorDecoratorAlert()); 196 197 gControl = new jFormsControl('name', 'a label', 'datatype'); 198 gControl.required = true; 199 gControl.errInvalid=''; 200 gControl.errRequired=''; 201 gForm.addControl( gControl); 202 ... 203 jForms.declareForm(gForm); 204 205 206 onsubmit="return jForms.verifyForm(this)" 207 208 209 // le code php g�r�ans le builder 210 211 $js="gForm = new jFormsForm('".$this->getFormName()."');\n"; 212 $js.="gForm.setDecorator(new jFormsErrorDecoratorAlert());\n"; 213 $label = 'a label'; 214 ou 215 $label = jLocale::get('mod~cle_locale_user'); 216 $js.="gControl = new jFormsControl('name', '".str_replace("'","\\'", $label)."', 'datatype');\n"; 217 $js.="gControl.required = true;\n"; 218 219 $invalid = jLocale::get('jelix~forms.check.invalid',$label)); 220 ou 221 $invalid = jLocale::get('mod~cle_locale_user'); 222 ou 223 $invalid = 'bla bla'; 224 $js.="gControl.errInvalid='".str_replace("'","\\'",$invalid)."';\n"; 225 226 227 $required = jLocale::get('jelix~forms.check.required',$label)); 228 ou 229 $required = jLocale::get('mod~cle_locale_user'); 230 ou 231 $required = 'bla bla'; 232 233 $js.="gControl.errRequired='".str_replace("'","\\'",$required)."';\n"; 234 $js.="gForm.addControl( gControl);\n"; 235 ... 236 $js.="jForms.declareForm(gForm);\n"; 237 238 // le code php qui g�re le php 239 240 241 242 243 */ 244 245 147 246 } 148 149 247 150 248 /**
