Changeset 464 for trunk/patTemplate.php
- Timestamp:
- 06/20/07 16:05:14 (1 year ago)
- Files:
-
- trunk/patTemplate.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/patTemplate.php
r463 r464 1 <? PHP1 <?php 2 2 /** 3 3 * patTemplate … … 7 7 * powerful templating engine 8 8 * 9 * @version 3. 1.09 * @version 3.2.0 10 10 * @package patTemplate 11 11 * @author Stephan Schmidt <schst@php.net> 12 * @author gERD Schaufelberger <gerd@php-tools.net> 12 13 * @license LGPL 13 14 * @link http://www.php-tools.net … … 59 60 * powerful templating engine 60 61 * 61 * @version 3. 1.062 * @version 3.2.0 62 63 * @package patTemplate 63 64 * @author Stephan Schmidt <schst@php.net> 65 * @author gERD Schaufelberger <gerd@php-tools.net> 64 66 * @license LGPL 65 67 * @link http://www.php-tools.net … … 73 75 var $_systemVars = array( 74 76 'appName' => 'patTemplate', 75 'appVersion' => '3. 1.0',77 'appVersion' => '3.2.0', 76 78 'author' => array( 77 'Stephan Schmidt <schst@php.net>' 79 'Stephan Schmidt <schst@php.net>', 80 'gERD Schaufelberger <gerd@php-tools.net>' 78 81 ) 79 82 ); … … 85 88 */ 86 89 var $_defaultAttributes = array( 87 'type' => 'standard', 88 'visibility' => 'visible', 89 'loop' => 1, 90 'unusedvars' => 'strip', 91 'whitespace' => 'keep', 92 'autoclear' => 'off', 93 'autoload' => 'on' 90 'type' => 'standard', 91 'visibility' => 'visible', 92 'loop' => 1, 93 'unusedvars' => 'strip', 94 'whitespace' => 'keep', 95 'autoclear' => 'off', 96 'autoload' => 'on', 97 'attributeplaceholder' => 'ignore', 94 98 ); 95 99 … … 1218 1222 } 1219 1223 1220 $this->addVar( $name, $varname, $varspec['default'] );1224 // $this->addVar( $name, $varname, $varspec['default'] ); 1221 1225 } 1222 1226 … … 2003 2007 case 'simplecondition': 2004 2008 foreach ($this->_templates[$template]['attributes']['requiredvars'] as $var) { 2009 2005 2010 // different template scope 2006 2011 if( $var[0] !== $template ) { … … 2227 2232 } 2228 2233 2229 2230 2234 $iteration = $this->_templates[$template]['iteration']; 2231 2235 … … 2261 2265 $vars = array_merge( $vars, $this->_vars[$template]['rows'][$iteration] ); 2262 2266 } 2267 2268 /** 2269 * add global vars 2270 */ 2271 if( !empty( $this->_globals ) ) { 2272 $vars = array_merge( $this->_globals, $vars ); 2273 } 2274 2275 /** 2276 * add default variables 2277 */ 2278 if( !empty( $this->_templates[$template]['defaultVars'] ) ) { 2279 $vars = array_merge( $this->_templates[$template]['defaultVars'], $vars ); 2280 } 2263 2281 2264 2282 /** … … 2299 2317 } 2300 2318 2301 $this->_templates[$template]['vars'] = $vars;2302 if( empty( $this->_templates[$template]['defaultVars'] ) ) {2319 if( empty( $this->_templates[$template]['defaultVars'] ) || $this->_templates[$template]['attributes']['attributeplaceholder'] != 'replace' ) { 2320 $this->_templates[$template]['vars'] = $vars; 2303 2321 return true; 2304 2322 } … … 2312 2330 } 2313 2331 2314 foreach( $this->_templates[$template]['defaultVars'] as $k => &$v ) { 2332 foreach( $this->_templates[$template]['defaultVars'] as $k => $v ) { 2333 // check if replace is required and variable is still default 2315 2334 if( !strstr( $v, $this->_endTag ) ) { 2316 2335 continue; 2317 2336 } 2318 $v = str_replace( $search, $replace, $v ); 2337 2338 if( $v != $vars[$k] ) { 2339 continue; 2340 } 2341 2342 $vars[$k] = str_replace( $search, $replace, $v ); 2319 2343 } 2320 2344 2345 $this->_templates[$template]['vars'] = $vars; 2321 2346 return true; 2322 2347 }
