Changeset 1070 for trunk/lib

Show
Ignore:
Timestamp:
08/31/08 11:25:39 (4 months ago)
Author:
laurentj
Message:

jforms plugins: added a check on the existence of the control when calling ctrl_* plugin

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/jelix/core-modules/jelix/locales/en_EN/formserr.UTF-8.properties

    r1062 r1070  
    2121bad.root.tag=(820) the root element %1$s is incorrect, it should have the name "form" (fichier %2$s) 
    2222 
     23unknow.control=(830) The control "%1$s" doesn't exist in the form "%2$s" (template %3$s) 
     24 
    2325js.err.invalid= "%s" field is invalid 
    2426js.err.required= "%s" field is required 
  • trunk/lib/jelix/core-modules/jelix/locales/en_US/formserr.UTF-8.properties

    r1062 r1070  
    2121bad.root.tag=(820) the root element %1$s is incorrect, it should have the name "form" (fichier %2$s) 
    2222 
     23unknow.control=(830) The control "%1$s" doesn't exist in the form "%2$s" (template %3$s) 
     24 
    2325js.err.invalid= "%s" field is invalid 
    2426js.err.required= "%s" field is required 
  • trunk/lib/jelix/core-modules/jelix/locales/fr_FR/formserr.UTF-8.properties

    r1062 r1070  
    2121bad.root.tag=(820) la balise racine %1$s est incorrecte, elle devrait avoir pour nom "form" (fichier %2$s) 
    2222 
     23unknow.control=(830) Le contrĂ´le "%1$s" n'existe pas dans le formulaire "%2$s" (template "%3$s") 
     24 
    2325js.err.invalid=La saisie de "%s" est invalide 
    2426js.err.required=La saisie de "%s" est obligatoire 
  • trunk/lib/jelix/plugins/tpl/html/function.ctrl_control.php

    r877 r1070  
    2828    else { 
    2929        $ctrls = $tpl->_privateVars['__form']->getControls(); 
     30        if (!isset($ctrls[$ctrlname])) { 
     31            throw new jException('jelix~formserr.unknow.control', 
     32                array($ctrlname, $tpl->_privateVars['__form']->getSelector(),$tpl->_templateName)); 
     33        } 
    3034        $ctrl = $ctrls[$ctrlname]; 
    3135    } 
  • trunk/lib/jelix/plugins/tpl/html/function.ctrl_label.php

    r877 r1070  
    2525    }else{ 
    2626        $ctrls = $tpl->_privateVars['__form']->getControls(); 
     27        if (!isset($ctrls[$ctrlname])) { 
     28            throw new jException('jelix~formserr.unknow.control', 
     29                array($ctrlname, $tpl->_privateVars['__form']->getSelector(),$tpl->_templateName)); 
     30        } 
    2731        $ctrl=$ctrls[$ctrlname]; 
    2832    } 
  • trunk/lib/jelix/plugins/tpl/html/function.ctrl_value.php

    r1016 r1070  
    2929        $tpl->_privateVars['__displayed_ctrl'][$ctrlname] = true; 
    3030        $ctrlname = $tpl->_privateVars['__ctrlref']; 
    31     }else
     31    } else
    3232        $ctrls = $tpl->_privateVars['__form']->getControls(); 
     33        if (!isset($ctrls[$ctrlname])) { 
     34            throw new jException('jelix~formserr.unknow.control', 
     35                array($ctrlname, $tpl->_privateVars['__form']->getSelector(),$tpl->_templateName)); 
     36        } 
    3337        $ctrl = $ctrls[$ctrlname]; 
    3438    } 
  • trunk/lib/jelix/tpl/jTpl.class.php

    r1001 r1070  
    208208 
    209209    /** 
     210     * contains the name of the template file 
     211     * It have a public access only for plugins. So you musn't use directly this property 
     212     * except from tpl plugins. 
     213     * @var string 
     214     * @since 1.1 
     215     */ 
     216    public $_templateName; 
     217 
     218    /** 
    210219     * include the compiled template file and call one of the generated function 
    211220     * @param string $tpl template selector 
     
    220229        $sel->userFunctions = $this->userFunctions; 
    221230        jIncluder::inc($sel); 
     231        $this->_templateName = $sel->toString(); 
    222232        $fct = $fctname.md5($sel->module.'_'.$sel->resource.'_'.$sel->outputType.($trusted?'_t':'')); 
    223233#else 
    224234        $tpl = JTPL_TEMPLATES_PATH . $tpl; 
    225         $filename = basename($tpl); 
    226         $cachefile = JTPL_CACHE_PATH.$outputtype.($trusted?'_t':'').'_'.$filename; 
     235        $this->_templateName = basename($tpl); 
     236        $cachefile = JTPL_CACHE_PATH.$outputtype.($trusted?'_t':'').'_'.$this->_templateName; 
    227237 
    228238        $mustCompile = $GLOBALS['jTplConfig']['compilation_force']['force'] || !file_exists($cachefile); 
     
    260270#ifnot JTPL_STANDALONE 
    261271            $sel = new jSelectorTpl($tpl, $outputtype, $trusted); 
     272            $sel->userModifiers = $this->userModifiers; 
     273            $sel->userFunctions = $this->userFunctions; 
    262274            jIncluder::inc($sel); 
    263275            $md = md5($sel->module.'_'.$sel->resource.'_'.$sel->outputType.($trusted?'_t':'')); 
     276            $this->_templateName = $sel->toString(); 
    264277#else 
    265278            $tpl = JTPL_TEMPLATES_PATH . $tpl; 
    266             $filename = basename($tpl); 
    267             $cachefile = JTPL_CACHE_PATH.$outputtype.($trusted?'_t':'').'_'.$filename; 
     279            $this->_templateName = basename($tpl); 
     280            $cachefile = JTPL_CACHE_PATH.$outputtype.($trusted?'_t':'').'_'.$this->_templateName; 
    268281 
    269282            $mustCompile = $GLOBALS['jTplConfig']['compilation_force']['force'] || !file_exists($cachefile); 
     
    277290                include_once(JTPL_PATH . 'jTplCompiler.class.php'); 
    278291                $compiler = new jTplCompiler(); 
     292                $compiler->setUserPlugins( $this->userModifiers, $this->userFunctions); 
    279293                $compiler->compile($tpl,$outputtype,$trusted); 
    280294            } 
Download in other formats: Unified Diff Zip Archive