Changeset 322

Show
Ignore:
Timestamp:
12/01/06 10:14:34 (2 years ago)
Author:
laurentj
Message:

mise à jour de myapp; ajout de jTpl::metaFetch pour optimisations

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build/lib/jBuild.inc.php

    r292 r322  
    113113 
    114114function init(){ 
    115     array_shift($_SERVER['argv']); // shift the script name 
    116  
    117115    $sws = array('-v'=>false, '-D'=>2); 
    118116    $params = array('ini'=>true); 
  • trunk/build/lib/jCmdUtils.class.php

    r292 r322  
    2020    private function __construct() {} 
    2121 
    22     public static function getOptionsAndParams($argv, $sws, $params) { 
     22    /** 
     23     * 
     24     * a list of options is a list of switches, a word or letter beginning by a "-" 
     25     * and following by an optionnal value. 
     26     * $sws is the list of switches : key = the switch name (ex: "-d") and the value is : 
     27     *   false if the switch doesn't expected a value 
     28     *   1 if a value is expected 
     29     *   2 if the switch can be repeated many times with different values 
     30     *  
     31     * a list of parameters is an array : 
     32     *    key = the parameter name 
     33     *    value : false if it is optionnal 
     34     * @param array $argv list of command line parameter (most of time, should be $_SERVER['argv']) 
     35     * @param array $sws list of possible switches 
     36     * @param array $params list of possible parameters 
     37     * @param boolean $fromArgv  true it $argv is $_SERVER['argv'] 
     38     */ 
     39    public static function getOptionsAndParams($argv, $sws, $params, $fromArgv=true) { 
    2340        $switches = array(); 
    2441        $parameters = array(); 
     42 
     43        if($fromArgv) 
     44            array_shift($argv); // shift the script name 
    2545 
    2646        //---------- get the switches 
     
    6080 
    6181        if (count($argv)) { 
     82var_dump($argv); 
    6283            throw new Exception("Error: two many parameters\n"); 
    6384        } 
  • trunk/build/manifests/myapp.mn

    r190 r322  
    2222cd myapp/var/config 
    2323  defaultconfig.ini.php.dist 
    24   config.classic.ini.php.dist 
    2524  dbprofils.ini.php.dist 
     25cd myapp/var/config/index 
     26  config.ini.php.dist 
    2627cd temp/myapp 
  • trunk/lib/jelix/CREDITS

    r321 r322  
    1313Contributeurs 
    1414------------- 
    15 (liste mise �our �vn-286
     15(liste mise �our �vn-320
    1616 
    1717Loic Mathaud (bballizlife) : 
     
    2525    Diverses am�orations (jClasses::inc(), jIniFile, jAppManager, dans jelix-scripts etc. ) 
    2626 
    27  
    2827Yannick Le Gu�rt (Torgan) 
    2928    driver auth jAuthDriverClass 
     
    3130    Divers bug fix et petites am�orations 
    3231    Contributions sur jResponseRss et jResponseAtom 
    33  
    34 Yann 
    35     Petite am�oration sur jResponseHtml (description et keywords) 
    3632 
    3733Nicolas Jeudy 
     
    4339    bug fixs sur le support de PDO dans jDb 
    4440 
     41Yann 
     42    Petite am�oration sur jResponseHtml (description et keywords) 
     43 
     44Cedric  
     45    patch correctif sur jFile::read 
     46 
     47 
    4548Gildas Givaja (Giviz) : testeur, corrections de bugs 
    4649Olivier Gambier (d-m-p) : review de code, corrections de bugs 
  • trunk/lib/jelix/tpl/jTpl.class.php

    r248 r322  
    1818class jTpl { 
    1919 
     20    /** 
     21     * all assigned template variables. Public because Internal use. Don't touch it :-) 
     22     * See methods of jTpl to manage template variables 
     23     * @var array 
     24     */ 
    2025    public $_vars = array (); 
     26 
     27    /** 
     28     * internal use 
     29     * @var array 
     30     */ 
    2131    public $_meta = array(); 
    2232 
    23     public function __construct(){ 
    24  
    25     } 
    26  
     33    public function __construct(){ } 
     34 
     35    /** 
     36     * assign a value in a template variable 
     37     * @param string|array $name the variable name, or an associative array 'name'=>'value' 
     38     * @param mixed  $value the value (or null if $name is an array) 
     39     */ 
    2740    public function assign ($name, $value = null){ 
    2841        if(is_array($name)){ 
     
    3548    } 
    3649 
     50    /** 
     51     * concat a value in with a value of an existing template variable 
     52     * @param string|array $name the variable name, or an associative array 'name'=>'value' 
     53     * @param mixed  $value the value (or null if $name is an array) 
     54     */ 
    3755    public function append ($name, $value = null){ 
    3856        if(is_array($name)){ 
     
    5169    } 
    5270 
     71    /** 
     72     * assign a value in a template variable, only if the template variable doesn't still exist  
     73     * @param string|array $name the variable name, or an associative array 'name'=>'value' 
     74     * @param mixed  $value the value (or null if $name is an array) 
     75     */ 
    5376    public function assignIfNone ($name, $value = null){ 
    5477        if(is_array($name)){ 
     
    6588 
    6689#ifndef JTPL_STANDALONE 
     90    /** 
     91     * assign a zone content to a template variable 
     92     * @param string $name the variable name 
     93     * @param string $zoneName  a zone selector 
     94     * @param array  $params  parameters for the zone 
     95     * @see jZone 
     96     */ 
    6797    function assignZone($name, $zoneName, $params=array()){ 
    6898        $this->_vars[$name] = jZone::processZone ($zoneName, $params); 
     
    70100#endif 
    71101 
     102    /** 
     103     * says if a template variable exists 
     104     * @param string $name the variable template name 
     105     * @return boolean true if the variable exists 
     106     */ 
    72107    public function isAssigned ($name){ 
    73108        return isset ($this->_vars[$name]); 
    74109    } 
    75110 
     111    /** 
     112     * return the value of a template variable 
     113     * @param string $name the variable template name 
     114     * @return mixed the value (or null if it isn't exist) 
     115     */ 
    76116    public function get ($name){ 
    77117        if (isset ($this->_vars[$name])){ 
     
    83123    } 
    84124 
     125    /** 
     126     * Return all template variables 
     127     * @return array 
     128     */ 
    85129    public function getTemplateVars (){ 
    86130        return $this->_vars; 
    87131    } 
    88132 
     133    /** 
     134     * process all meta instruction of a template 
     135     * @param string $tpl template selector 
     136     */ 
    89137    public function meta($tpl){ 
    90138        $this->getTemplate($tpl,'template_meta_'); 
    91139    } 
    92140 
     141    /** 
     142     * display the generated content from the given template 
     143     * @param string $tpl template selector 
     144     */ 
    93145    public function display ($tpl){ 
    94146        $this->getTemplate($tpl,'template_'); 
    95147    } 
    96148 
     149    /** 
     150     * include the compiled template file and call one of the generated function 
     151     * @param string $tpl template selector 
     152     * @param string $fctname the internal function name (meta or content) 
     153     */ 
    97154    protected function  getTemplate($tpl,$fctname){ 
    98155#ifndef JTPL_STANDALONE 
     
    124181    } 
    125182 
     183    /** 
     184     * return the generated content from the given template 
     185     * @param string $tpl template selector 
     186     * @return string the generated content 
     187     */ 
    126188    public function fetch ($tpl){ 
    127189        ob_start (); 
     
    136198    } 
    137199 
     200    /** 
     201     * optimized version of meta() + fetch() 
     202     * @param string $tpl template selector 
     203     * @return string the generated content 
     204     */ 
     205    public function metaFetch ($tpl){ 
     206        ob_start (); 
     207        try{ 
     208#ifndef JTPL_STANDALONE 
     209            $sel = new jSelectorTpl($tpl); 
     210            jIncluder::inc($sel); 
     211            $md = md5($sel->module.'_'.$sel->resource); 
     212#else 
     213            $tpl = JTPL_TEMPLATES_PATH . $tpl; 
     214            $filename = basename($tpl); 
     215            $cachefile = JTPL_CACHE_PATH . $filename; 
     216     
     217            $mustCompile = $GLOBALS['jTplConfig']['compilation_force']['force'] || !file_exists($cachefile); 
     218            if (!$mustCompile) { 
     219                if (filemtime($tpl) > filemtime($cachefile)) { 
     220                $mustCompile = true; 
     221                } 
     222            } 
     223 
     224            if ($mustCompile) { 
     225                include_once(JTPL_PATH . 'jTplCompiler.class.php'); 
     226                $compiler = new jTplCompiler(); 
     227                $compiler->compile($tpl); 
     228            } 
     229            require_once($cachefile); 
     230            $md = md5($tpl); 
     231#endif 
     232            $fct = 'template_meta_'.$md; 
     233            $fct($this); 
     234            $fct = 'template_'.$md; 
     235            $fct($this); 
     236            $content = ob_get_clean(); 
     237        }catch(Exception $e){ 
     238            ob_end_clean(); 
     239            throw $e; 
     240        } 
     241        return $content; 
     242    } 
    138243} 
    139244?> 
  • trunk/lib/jelix/utils/jZone.class.php

    r314 r322  
    196196    */ 
    197197    protected function _createContent (){ 
    198         if($this->_tplname != ''){ 
    199             $this->_tpl = new jTpl(); 
    200             $this->_tpl->assign($this->_params); 
    201             $this->_prepareTpl(); 
    202             $this->_tpl->meta($this->_tplname); 
    203             return $this->_tpl->fetch($this->_tplname); 
    204         } 
    205         return ''; 
     198        if($this->_tplname == '') return ''; 
     199        $this->_tpl = new jTpl(); 
     200        $this->_tpl->assign($this->_params); 
     201        $this->_prepareTpl(); 
     202        return $this->_tpl->metaFetch($this->_tplname); 
    206203    } 
    207204 
  • trunk/myapp/www/index.php

    r1 r322  
    1212 
    1313require_once ('../../lib/jelix/init.php'); 
    14 //require_once ('/usr/lib/jelix/1.0/jelix/init.php'); 
    15  
    16 require_once ('../../myapp/application.init.php'); 
    17 //require_once ('/usr/share/jelix/myapp/application.init.php'); 
    18  
     14require_once ('../application.init.php'); 
    1915require_once (JELIX_LIB_CORE_PATH.'request/jClassicRequest.class.php'); 
    2016 
    21 $config_file = 'config.classic.ini.php'; 
     17$config_file = 'index/config.ini.php'; 
    2218 
    2319$jelix = new jCoordinator($config_file); 
Download in other formats: Unified Diff Zip Archive