Changeset 322
- Timestamp:
- 12/01/06 10:14:34 (2 years ago)
- Files:
-
- trunk/build/lib/jBuild.inc.php (modified) (1 diff)
- trunk/build/lib/jCmdUtils.class.php (modified) (2 diffs)
- trunk/build/manifests/myapp.mn (modified) (1 diff)
- trunk/lib/jelix/CREDITS (modified) (4 diffs)
- trunk/lib/jelix/tpl/jTpl.class.php (modified) (8 diffs)
- trunk/lib/jelix/utils/jZone.class.php (modified) (1 diff)
- trunk/myapp/var/config/config.classic.ini.php.dist (deleted)
- trunk/myapp/var/config/index (added)
- trunk/myapp/var/config/index/config.ini.php.dist (added)
- trunk/myapp/www/index.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/build/lib/jBuild.inc.php
r292 r322 113 113 114 114 function init(){ 115 array_shift($_SERVER['argv']); // shift the script name116 117 115 $sws = array('-v'=>false, '-D'=>2); 118 116 $params = array('ini'=>true); trunk/build/lib/jCmdUtils.class.php
r292 r322 20 20 private function __construct() {} 21 21 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) { 23 40 $switches = array(); 24 41 $parameters = array(); 42 43 if($fromArgv) 44 array_shift($argv); // shift the script name 25 45 26 46 //---------- get the switches … … 60 80 61 81 if (count($argv)) { 82 var_dump($argv); 62 83 throw new Exception("Error: two many parameters\n"); 63 84 } trunk/build/manifests/myapp.mn
r190 r322 22 22 cd myapp/var/config 23 23 defaultconfig.ini.php.dist 24 config.classic.ini.php.dist25 24 dbprofils.ini.php.dist 25 cd myapp/var/config/index 26 config.ini.php.dist 26 27 cd temp/myapp trunk/lib/jelix/CREDITS
r321 r322 13 13 Contributeurs 14 14 ------------- 15 (liste mise �our �vn- 286)15 (liste mise �our �vn-320) 16 16 17 17 Loic Mathaud (bballizlife) : … … 25 25 Diverses am�orations (jClasses::inc(), jIniFile, jAppManager, dans jelix-scripts etc. ) 26 26 27 28 27 Yannick Le Gu�rt (Torgan) 29 28 driver auth jAuthDriverClass … … 31 30 Divers bug fix et petites am�orations 32 31 Contributions sur jResponseRss et jResponseAtom 33 34 Yann35 Petite am�oration sur jResponseHtml (description et keywords)36 32 37 33 Nicolas Jeudy … … 43 39 bug fixs sur le support de PDO dans jDb 44 40 41 Yann 42 Petite am�oration sur jResponseHtml (description et keywords) 43 44 Cedric 45 patch correctif sur jFile::read 46 47 45 48 Gildas Givaja (Giviz) : testeur, corrections de bugs 46 49 Olivier Gambier (d-m-p) : review de code, corrections de bugs trunk/lib/jelix/tpl/jTpl.class.php
r248 r322 18 18 class jTpl { 19 19 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 */ 20 25 public $_vars = array (); 26 27 /** 28 * internal use 29 * @var array 30 */ 21 31 public $_meta = array(); 22 32 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 */ 27 40 public function assign ($name, $value = null){ 28 41 if(is_array($name)){ … … 35 48 } 36 49 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 */ 37 55 public function append ($name, $value = null){ 38 56 if(is_array($name)){ … … 51 69 } 52 70 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 */ 53 76 public function assignIfNone ($name, $value = null){ 54 77 if(is_array($name)){ … … 65 88 66 89 #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 */ 67 97 function assignZone($name, $zoneName, $params=array()){ 68 98 $this->_vars[$name] = jZone::processZone ($zoneName, $params); … … 70 100 #endif 71 101 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 */ 72 107 public function isAssigned ($name){ 73 108 return isset ($this->_vars[$name]); 74 109 } 75 110 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 */ 76 116 public function get ($name){ 77 117 if (isset ($this->_vars[$name])){ … … 83 123 } 84 124 125 /** 126 * Return all template variables 127 * @return array 128 */ 85 129 public function getTemplateVars (){ 86 130 return $this->_vars; 87 131 } 88 132 133 /** 134 * process all meta instruction of a template 135 * @param string $tpl template selector 136 */ 89 137 public function meta($tpl){ 90 138 $this->getTemplate($tpl,'template_meta_'); 91 139 } 92 140 141 /** 142 * display the generated content from the given template 143 * @param string $tpl template selector 144 */ 93 145 public function display ($tpl){ 94 146 $this->getTemplate($tpl,'template_'); 95 147 } 96 148 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 */ 97 154 protected function getTemplate($tpl,$fctname){ 98 155 #ifndef JTPL_STANDALONE … … 124 181 } 125 182 183 /** 184 * return the generated content from the given template 185 * @param string $tpl template selector 186 * @return string the generated content 187 */ 126 188 public function fetch ($tpl){ 127 189 ob_start (); … … 136 198 } 137 199 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 } 138 243 } 139 244 ?> trunk/lib/jelix/utils/jZone.class.php
r314 r322 196 196 */ 197 197 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); 206 203 } 207 204 trunk/myapp/www/index.php
r1 r322 12 12 13 13 require_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 14 require_once ('../application.init.php'); 19 15 require_once (JELIX_LIB_CORE_PATH.'request/jClassicRequest.class.php'); 20 16 21 $config_file = ' config.classic.ini.php';17 $config_file = 'index/config.ini.php'; 22 18 23 19 $jelix = new jCoordinator($config_file);
