Changeset 611

Show
Ignore:
Timestamp:
10/15/07 22:22:37 (1 year ago)
Author:
laurentj
Message:

fixed bug #298: use of form plugin in a main template didn't generate JS link to jforms.js. To fix this bug, behavior of jTpl::fetch has changed : it now execute meta content like the metaFetch function. metaFetch is now deprecated.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0beta3.x/lib/jelix/plugins/tpl/html/block.form.php

    r602 r611  
    5656$t->_privateVars[\'__formbuilder\']->outputHeader(array('.$errdecorator.','.$helpdecorator.')); 
    5757$t->_privateVars[\'__displayed_ctrl\'] = array(); 
    58 if($GLOBALS[\'gJCoord\']->response!= null){ 
     58'; 
     59    $compiler->addMetaContent('if($GLOBALS[\'gJCoord\']->response!= null){ 
    5960    $GLOBALS[\'gJCoord\']->response->addJSLink($GLOBALS[\'gJConfig\']->urlengine[\'jelixWWWPath\'].\'js/jforms.js\'); 
    6061    $GLOBALS[\'gJCoord\']->response->addCSSLink($GLOBALS[\'gJConfig\']->urlengine[\'jelixWWWPath\'].\'design/jform.css\'); 
    6162} 
    62 '
     63')
    6364 
    6465    return $content; 
  • branches/1.0beta3.x/lib/jelix/plugins/tpl/html/block.form.php

    r602 r611  
    5656$t->_privateVars[\'__formbuilder\']->outputHeader(array('.$errdecorator.','.$helpdecorator.')); 
    5757$t->_privateVars[\'__displayed_ctrl\'] = array(); 
    58 if($GLOBALS[\'gJCoord\']->response!= null){ 
     58'; 
     59    $compiler->addMetaContent('if($GLOBALS[\'gJCoord\']->response!= null){ 
    5960    $GLOBALS[\'gJCoord\']->response->addJSLink($GLOBALS[\'gJConfig\']->urlengine[\'jelixWWWPath\'].\'js/jforms.js\'); 
    6061    $GLOBALS[\'gJCoord\']->response->addCSSLink($GLOBALS[\'gJConfig\']->urlengine[\'jelixWWWPath\'].\'design/jform.css\'); 
    6162} 
    62 '
     63')
    6364 
    6465    return $content; 
  • branches/1.0beta3.x/lib/jelix/tpl/jTpl.class.php

    r559 r611  
    162162    public function meta($tpl, $outputtype='', $trusted = true){ 
    163163        $this->getTemplate($tpl,'template_meta_', $outputtype, $trusted); 
     164        return $this->_meta; 
    164165    } 
    165166 
     
    215216     * @param string $outputtype the type of output (html, text etc..) 
    216217     * @param boolean $trusted  says if the template file is trusted or not 
     218     * @param boolean $callMeta false if meta should not be called 
    217219     * @return string the generated content 
    218220     */ 
    219     public function fetch ($tpl, $outputtype='', $trusted = true){ 
    220         ob_start (); 
    221         try{ 
    222            $this->getTemplate($tpl,'template_', $outputtype, $trusted); 
    223            $content = ob_get_clean(); 
    224         }catch(Exception $e){ 
    225            ob_end_clean(); 
    226            throw $e; 
    227         } 
    228         return $content; 
    229     } 
    230  
    231     /** 
    232      * optimized version of meta() + fetch() 
    233      * @param string $tpl template selector 
    234      * @param string $outputtype the type of output (html, text etc..) 
    235      * @param boolean $trusted  says if the template file is trusted or not 
    236      * @return string the generated content 
    237      * @since 1.0b1 
    238      */ 
    239     public function metaFetch ($tpl, $outputtype='', $trusted = true){ 
     221    public function fetch ($tpl, $outputtype='', $trusted = true, $callMeta=true){ 
     222        $content = ''; 
    240223        ob_start (); 
    241224        try{ 
     
    264247            $md = md5($tpl.'_'.$outputtype.($trusted?'_t':'')); 
    265248#endif 
    266             $fct = 'template_meta_'.$md; 
    267             $fct($this); 
     249            if ($callMeta) { 
     250                $fct = 'template_meta_'.$md; 
     251                $fct($this); 
     252            } 
    268253            $fct = 'template_'.$md; 
    269254            $fct($this); 
     
    276261    } 
    277262 
     263    /** 
     264     * deprecated function: optimized version of meta() + fetch(). 
     265     * Instead use fetch with true as $callMeta parameter. 
     266     * @param string $tpl template selector 
     267     * @param string $outputtype the type of output (html, text etc..) 
     268     * @param boolean $trusted  says if the template file is trusted or not 
     269     * @return string the generated content 
     270     * @deprecated 
     271     */ 
     272    public function metaFetch ($tpl, $outputtype='', $trusted = true){ 
     273        return $this->fetch ($tpl, $outputtype, $trusted,true); 
     274    } 
     275 
    278276 
    279277    /** 
  • branches/1.0beta3.x/lib/jelix/tpl/jTpl.class.php

    r559 r611  
    162162    public function meta($tpl, $outputtype='', $trusted = true){ 
    163163        $this->getTemplate($tpl,'template_meta_', $outputtype, $trusted); 
     164        return $this->_meta; 
    164165    } 
    165166 
     
    215216     * @param string $outputtype the type of output (html, text etc..) 
    216217     * @param boolean $trusted  says if the template file is trusted or not 
     218     * @param boolean $callMeta false if meta should not be called 
    217219     * @return string the generated content 
    218220     */ 
    219     public function fetch ($tpl, $outputtype='', $trusted = true){ 
    220         ob_start (); 
    221         try{ 
    222            $this->getTemplate($tpl,'template_', $outputtype, $trusted); 
    223            $content = ob_get_clean(); 
    224         }catch(Exception $e){ 
    225            ob_end_clean(); 
    226            throw $e; 
    227         } 
    228         return $content; 
    229     } 
    230  
    231     /** 
    232      * optimized version of meta() + fetch() 
    233      * @param string $tpl template selector 
    234      * @param string $outputtype the type of output (html, text etc..) 
    235      * @param boolean $trusted  says if the template file is trusted or not 
    236      * @return string the generated content 
    237      * @since 1.0b1 
    238      */ 
    239     public function metaFetch ($tpl, $outputtype='', $trusted = true){ 
     221    public function fetch ($tpl, $outputtype='', $trusted = true, $callMeta=true){ 
     222        $content = ''; 
    240223        ob_start (); 
    241224        try{ 
     
    264247            $md = md5($tpl.'_'.$outputtype.($trusted?'_t':'')); 
    265248#endif 
    266             $fct = 'template_meta_'.$md; 
    267             $fct($this); 
     249            if ($callMeta) { 
     250                $fct = 'template_meta_'.$md; 
     251                $fct($this); 
     252            } 
    268253            $fct = 'template_'.$md; 
    269254            $fct($this); 
     
    276261    } 
    277262 
     263    /** 
     264     * deprecated function: optimized version of meta() + fetch(). 
     265     * Instead use fetch with true as $callMeta parameter. 
     266     * @param string $tpl template selector 
     267     * @param string $outputtype the type of output (html, text etc..) 
     268     * @param boolean $trusted  says if the template file is trusted or not 
     269     * @return string the generated content 
     270     * @deprecated 
     271     */ 
     272    public function metaFetch ($tpl, $outputtype='', $trusted = true){ 
     273        return $this->fetch ($tpl, $outputtype, $trusted,true); 
     274    } 
     275 
    278276 
    279277    /** 
  • branches/1.0beta3.x/lib/jelix/tpl/jTplCompiler.class.php

    r571 r611  
    129129        $header.='function template_meta_'.md5($selector->module.'_'.$selector->resource.'_'.$this->outputType.($this->trusted?'_t':'')).'($t){'; 
    130130#endif 
    131         $header .="\n".$this->_metaBody."\nreturn \$t->_meta;\n}\n"; 
     131        $header .="\n".$this->_metaBody."\n}\n"; 
    132132 
    133133#if JTPL_STANDALONE 
     
    515515    } 
    516516 
     517    public function addMetaContent($content){ 
     518        $this->_metaBody.= $content."\n"; 
     519    } 
     520 
    517521    /** 
    518522     * try to find a plugin 
  • branches/1.0beta3.x/lib/jelix/tpl/jTplCompiler.class.php

    r571 r611  
    129129        $header.='function template_meta_'.md5($selector->module.'_'.$selector->resource.'_'.$this->outputType.($this->trusted?'_t':'')).'($t){'; 
    130130#endif 
    131         $header .="\n".$this->_metaBody."\nreturn \$t->_meta;\n}\n"; 
     131        $header .="\n".$this->_metaBody."\n}\n"; 
    132132 
    133133#if JTPL_STANDALONE 
     
    515515    } 
    516516 
     517    public function addMetaContent($content){ 
     518        $this->_metaBody.= $content."\n"; 
     519    } 
     520 
    517521    /** 
    518522     * try to find a plugin 
  • trunk/lib/jelix/plugins/tpl/html/block.form.php

    r610 r611  
    6161$t->_privateVars[\'__formbuilder\']->outputHeader(array('.$errdecorator.','.$helpdecorator.',\''.$method.'\')); 
    6262$t->_privateVars[\'__displayed_ctrl\'] = array(); 
    63 if($GLOBALS[\'gJCoord\']->response!= null){ 
     63'; 
     64    $compiler->addMetaContent('if($GLOBALS[\'gJCoord\']->response!= null){ 
    6465    $GLOBALS[\'gJCoord\']->response->addJSLink($GLOBALS[\'gJConfig\']->urlengine[\'jelixWWWPath\'].\'js/jforms.js\'); 
    6566    $GLOBALS[\'gJCoord\']->response->addCSSLink($GLOBALS[\'gJConfig\']->urlengine[\'jelixWWWPath\'].\'design/jform.css\'); 
    6667} 
    67 '
     68')
    6869 
    6970    return $content; 
  • trunk/lib/jelix/plugins/tpl/html/block.form.php

    r610 r611  
    6161$t->_privateVars[\'__formbuilder\']->outputHeader(array('.$errdecorator.','.$helpdecorator.',\''.$method.'\')); 
    6262$t->_privateVars[\'__displayed_ctrl\'] = array(); 
    63 if($GLOBALS[\'gJCoord\']->response!= null){ 
     63'; 
     64    $compiler->addMetaContent('if($GLOBALS[\'gJCoord\']->response!= null){ 
    6465    $GLOBALS[\'gJCoord\']->response->addJSLink($GLOBALS[\'gJConfig\']->urlengine[\'jelixWWWPath\'].\'js/jforms.js\'); 
    6566    $GLOBALS[\'gJCoord\']->response->addCSSLink($GLOBALS[\'gJConfig\']->urlengine[\'jelixWWWPath\'].\'design/jform.css\'); 
    6667} 
    67 '
     68')
    6869 
    6970    return $content; 
  • trunk/lib/jelix/tpl/jTpl.class.php

    r559 r611  
    162162    public function meta($tpl, $outputtype='', $trusted = true){ 
    163163        $this->getTemplate($tpl,'template_meta_', $outputtype, $trusted); 
     164        return $this->_meta; 
    164165    } 
    165166 
     
    215216     * @param string $outputtype the type of output (html, text etc..) 
    216217     * @param boolean $trusted  says if the template file is trusted or not 
     218     * @param boolean $callMeta false if meta should not be called 
    217219     * @return string the generated content 
    218220     */ 
    219     public function fetch ($tpl, $outputtype='', $trusted = true){ 
    220         ob_start (); 
    221         try{ 
    222            $this->getTemplate($tpl,'template_', $outputtype, $trusted); 
    223            $content = ob_get_clean(); 
    224         }catch(Exception $e){ 
    225            ob_end_clean(); 
    226            throw $e; 
    227         } 
    228         return $content; 
    229     } 
    230  
    231     /** 
    232      * optimized version of meta() + fetch() 
    233      * @param string $tpl template selector 
    234      * @param string $outputtype the type of output (html, text etc..) 
    235      * @param boolean $trusted  says if the template file is trusted or not 
    236      * @return string the generated content 
    237      * @since 1.0b1 
    238      */ 
    239     public function metaFetch ($tpl, $outputtype='', $trusted = true){ 
     221    public function fetch ($tpl, $outputtype='', $trusted = true, $callMeta=true){ 
     222        $content = ''; 
    240223        ob_start (); 
    241224        try{ 
     
    264247            $md = md5($tpl.'_'.$outputtype.($trusted?'_t':'')); 
    265248#endif 
    266             $fct = 'template_meta_'.$md; 
    267             $fct($this); 
     249            if ($callMeta) { 
     250                $fct = 'template_meta_'.$md; 
     251                $fct($this); 
     252            } 
    268253            $fct = 'template_'.$md; 
    269254            $fct($this); 
     
    276261    } 
    277262 
     263    /** 
     264     * deprecated function: optimized version of meta() + fetch(). 
     265     * Instead use fetch with true as $callMeta parameter. 
     266     * @param string $tpl template selector 
     267     * @param string $outputtype the type of output (html, text etc..) 
     268     * @param boolean $trusted  says if the template file is trusted or not 
     269     * @return string the generated content 
     270     * @deprecated 
     271     */ 
     272    public function metaFetch ($tpl, $outputtype='', $trusted = true){ 
     273        return $this->fetch ($tpl, $outputtype, $trusted,true); 
     274    } 
     275 
    278276 
    279277    /** 
  • trunk/lib/jelix/tpl/jTpl.class.php

    r559 r611  
    162162    public function meta($tpl, $outputtype='', $trusted = true){ 
    163163        $this->getTemplate($tpl,'template_meta_', $outputtype, $trusted); 
     164        return $this->_meta; 
    164165    } 
    165166 
     
    215216     * @param string $outputtype the type of output (html, text etc..) 
    216217     * @param boolean $trusted  says if the template file is trusted or not 
     218     * @param boolean $callMeta false if meta should not be called 
    217219     * @return string the generated content 
    218220     */ 
    219     public function fetch ($tpl, $outputtype='', $trusted = true){ 
    220         ob_start (); 
    221         try{ 
    222            $this->getTemplate($tpl,'template_', $outputtype, $trusted); 
    223            $content = ob_get_clean(); 
    224         }catch(Exception $e){ 
    225            ob_end_clean(); 
    226            throw $e; 
    227         } 
    228         return $content; 
    229     } 
    230  
    231     /** 
    232      * optimized version of meta() + fetch() 
    233      * @param string $tpl template selector 
    234      * @param string $outputtype the type of output (html, text etc..) 
    235      * @param boolean $trusted  says if the template file is trusted or not 
    236      * @return string the generated content 
    237      * @since 1.0b1 
    238      */ 
    239     public function metaFetch ($tpl, $outputtype='', $trusted = true){ 
     221    public function fetch ($tpl, $outputtype='', $trusted = true, $callMeta=true){ 
     222        $content = ''; 
    240223        ob_start (); 
    241224        try{ 
     
    264247            $md = md5($tpl.'_'.$outputtype.($trusted?'_t':'')); 
    265248#endif 
    266             $fct = 'template_meta_'.$md; 
    267             $fct($this); 
     249            if ($callMeta) { 
     250                $fct = 'template_meta_'.$md; 
     251                $fct($this); 
     252            } 
    268253            $fct = 'template_'.$md; 
    269254            $fct($this); 
     
    276261    } 
    277262 
     263    /** 
     264     * deprecated function: optimized version of meta() + fetch(). 
     265     * Instead use fetch with true as $callMeta parameter. 
     266     * @param string $tpl template selector 
     267     * @param string $outputtype the type of output (html, text etc..) 
     268     * @param boolean $trusted  says if the template file is trusted or not 
     269     * @return string the generated content 
     270     * @deprecated 
     271     */ 
     272    public function metaFetch ($tpl, $outputtype='', $trusted = true){ 
     273        return $this->fetch ($tpl, $outputtype, $trusted,true); 
     274    } 
     275 
    278276 
    279277    /** 
  • trunk/lib/jelix/tpl/jTplCompiler.class.php

    r571 r611  
    129129        $header.='function template_meta_'.md5($selector->module.'_'.$selector->resource.'_'.$this->outputType.($this->trusted?'_t':'')).'($t){'; 
    130130#endif 
    131         $header .="\n".$this->_metaBody."\nreturn \$t->_meta;\n}\n"; 
     131        $header .="\n".$this->_metaBody."\n}\n"; 
    132132 
    133133#if JTPL_STANDALONE 
     
    515515    } 
    516516 
     517    public function addMetaContent($content){ 
     518        $this->_metaBody.= $content."\n"; 
     519    } 
     520 
    517521    /** 
    518522     * try to find a plugin 
  • trunk/lib/jelix/tpl/jTplCompiler.class.php

    r571 r611  
    129129        $header.='function template_meta_'.md5($selector->module.'_'.$selector->resource.'_'.$this->outputType.($this->trusted?'_t':'')).'($t){'; 
    130130#endif 
    131         $header .="\n".$this->_metaBody."\nreturn \$t->_meta;\n}\n"; 
     131        $header .="\n".$this->_metaBody."\n}\n"; 
    132132 
    133133#if JTPL_STANDALONE 
     
    515515    } 
    516516 
     517    public function addMetaContent($content){ 
     518        $this->_metaBody.= $content."\n"; 
     519    } 
     520 
    517521    /** 
    518522     * try to find a plugin 
Download in other formats: Unified Diff Zip Archive