Changeset 2513 for trunk/include/template.class.php
- Timestamp:
- Sep 9, 2008, 11:53:31 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/template.class.php
r2502 r2513 63 63 $this->smarty->register_modifier( 'explode', array('Template', 'mod_explode') ); 64 64 $this->smarty->register_block('html_head', array(&$this, 'block_html_head') ); 65 $this->smarty->register_function('known_script', array(&$this, 'func_known_script'), false ); 65 66 $this->smarty->register_prefilter( array('Template', 'prefilter_white_space') ); 66 67 if ( $conf['compiled_template_cache_language'] ) … … 340 341 } 341 342 343 /** 344 * This smarty "known_script" functions allows to insert well known java scripts 345 * such as prototype, jquery, etc... only once. Examples: 346 * {known_script id="jquery" src="{$ROOT_URL}template-common/lib/jquery.packed.js"} 347 */ 348 function func_known_script($params, &$smarty ) 349 { 350 if (!isset($params['id'])) 351 { 352 $smarty->trigger_error("known_script: missing 'id' parameter"); 353 return; 354 } 355 $id = $params['id']; 356 if (! isset( $this->known_scripts[$id] ) ) 357 { 358 if (!isset($params['src'])) 359 { 360 $smarty->trigger_error("known_script: missing 'src' parameter"); 361 return; 362 } 363 $this->known_scripts[$id] = $params['src']; 364 $content = '<script type="text/javascript" src="'.$params['src'].'"></script>'; 365 if (isset($params['now']) and $params['now'] and empty($this->output) ) 366 { 367 return $content; 368 } 369 $repeat = false; 370 $this->block_html_head(null, $content, $smarty, $repeat); 371 } 372 } 373 342 374 /*static */ function prefilter_white_space($source, &$smarty) 343 375 {
Note: See TracChangeset
for help on using the changeset viewer.