Changeset 2334
- Timestamp:
- May 8, 2008, 3:13:13 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/config_default.inc.php
r2313 r2334 691 691 // or other plugin variables etc 692 692 $conf['local_data_dir'] = dirname(dirname(__FILE__)).'/_data'; 693 694 // if true, some language strings are replaced during template compilation 695 // (insted of template output). this results in better performance. however 696 // any change in the language file will not be propagated until you purge 697 // the compiled templates from the admin / maintenance menu 698 $conf['compiled_template_cache_language'] = false; 699 693 700 ?> -
trunk/include/template.class.php
r2299 r2334 44 44 var $files = array(); 45 45 46 // used by html_head smarty block to add content before </head> 47 var $html_head_elements = array(); 48 46 49 function Template($root = ".", $theme= "") 47 50 { … … 50 53 $this->smarty = new Smarty; 51 54 $this->smarty->debugging = $conf['debug_template']; 52 //$this->smarty->force_compile = true;53 55 54 56 if ( isset($conf['compiled_template_dir'] ) ) … … 77 79 $this->smarty->register_modifier( 'translate', array('Template', 'mod_translate') ); 78 80 $this->smarty->register_modifier( 'explode', array('Template', 'mod_explode') ); 81 $this->smarty->register_block('html_head', array(&$this, 'block_html_head') ); 82 if ( $conf['compiled_template_cache_language'] ) 83 { 84 $this->smarty->register_prefilter( array(&$this, 'prefilter_language') ); 85 } 79 86 80 87 if ( !empty($theme) ) … … 96 103 $real_dir = realpath($dir); 97 104 $compile_id = crc32( $real_dir===false ? $dir : $real_dir); 98 $this->smarty->compile_id = sprintf('%08X', $compile_id);105 $this->smarty->compile_id = base_convert($compile_id, 10, 36 ); 99 106 } 100 107 … … 224 231 $this->smarty->assign( 'TAG_INPUT_ENABLED', 225 232 ((is_adviser()) ? 'disabled="disabled" onclick="return false;"' : '')); 233 234 global $conf, $lang_info; 235 if ( $conf['compiled_template_cache_language'] and isset($lang_info['code']) ) 236 { 237 $save_compile_id = $this->smarty->compile_id; 238 $this->smarty->compile_id .= '.'.$lang_info['code']; 239 } 240 226 241 $v = $this->smarty->fetch($this->files[$handle], null, null, false); 242 243 if (isset ($save_compile_id) ) 244 { 245 $this->smarty->compile_id = $save_compile_id; 246 } 247 227 248 if ($return) 228 249 { … … 239 260 { 240 261 $this->parse($handle, false); 262 $this->flush(); 263 } 264 265 function flush() 266 { 267 if ( count($this->html_head_elements) ) 268 { 269 $search = "\n</head>"; 270 $pos = strpos( $this->output, $search ); 271 if ($pos !== false) 272 { 273 $this->output = substr_replace( $this->output, "\n".implode( "\n", $this->html_head_elements ), $pos, 0 ); 274 } //else maybe error or warning ? 275 $this->html_head_elements = array(); 276 } 241 277 echo $this->output; 242 278 $this->output=''; 243 244 } 245 279 } 246 280 247 281 /** flushes the output */ … … 250 284 $start = get_moment(); 251 285 252 echo $this->output; 253 $this->output=''; 286 $this->flush(); 254 287 255 288 if ($this->smarty->debugging) … … 284 317 return explode($delimiter, $text); 285 318 } 319 320 /** 321 * This smarty "html_head" block allows to add content just before 322 * </head> element in the output after the head has been parsed. This is 323 * handy in order to respect strict standards when <style> and <link> 324 * html elements must appear in the <head> element 325 */ 326 function block_html_head($params, $content, &$smarty, &$repeat) 327 { 328 $content = trim($content); 329 if ( !empty($content) ) 330 { // second call 331 if ( empty($this->output) ) 332 {//page header not parsed yet 333 $this->append('head_elements', $content); 334 } 335 else 336 { 337 $this->html_head_elements[] = $content; 338 } 339 } 340 } 341 342 /** 343 * Smarty prefilter to allow caching (whenever possible) language strings 344 * from templates. 345 */ 346 function prefilter_language($source, &$smarty) 347 { 348 global $lang; 349 $ldq = preg_quote($this->smarty->left_delimiter, '~'); 350 $rdq = preg_quote($this->smarty->right_delimiter, '~'); 351 352 $regex = "~$ldq *\'([^'$]+)\'\|@translate *$rdq~"; 353 $source = preg_replace( $regex.'e', 'isset($lang[\'$1\']) ? $lang[\'$1\'] : \'$0\'', $source); 354 355 $regex = "~$ldq *\'([^'$]+)\'\|@translate\|~"; 356 $source = preg_replace( $regex.'e', 'isset($lang[\'$1\']) ? \'{\'.var_export($lang[\'$1\'],true).\'|\' : \'$0\'', $source); 357 358 return $source; 359 } 286 360 } 287 361 -
trunk/template/yoga/admin/plugins_list.tpl
r2293 r2334 19 19 </tr> 20 20 </thead> 21 {html_head} {*add the style to html head for strict standard compliance*} 22 <style type="text/css"> 23 TABLE.table2 TR TD.pluginState {ldelim} 24 padding-left:16px; 25 } 26 TABLE.table2 TR TD.active {ldelim} 27 background: url({$ROOT_URL}{$themeconf.admin_icon_dir}/plugin_active.gif) no-repeat center left 28 } 29 TABLE.table2 TR TD.inactive {ldelim} 30 background: url({$ROOT_URL}{$themeconf.admin_icon_dir}/plugin_inactive.gif) no-repeat center left 31 } 32 </style> 33 {/html_head} 21 34 {foreach from=$plugins item=plugin name=plugins_loop} 22 35 <tr class="{if $smarty.foreach.plugins_loop.index is odd}row1{else}row2{/if}"> 23 <td style="padding-left:16px; {if not empty($plugin.STATE)}background: url({$ROOT_URL}{$themeconf.admin_icon_dir}/plugin_{$plugin.STATE}.gif) no-repeat center left{/if}">36 <td class="pluginState{if not empty($plugin.STATE)} {$plugin.STATE}{/if}"> 24 37 {$plugin.NAME} 25 38 </td> -
trunk/template/yoga/month_calendar.tpl
r2265 r2334 37 37 </tr> 38 38 </thead> 39 39 {html_head} {*add the style to html head for strict standard compliance*} 40 <style type="text/css"> 41 TABLE.calMonth TBODY TD, TABLE.calMonth TBODY TD DIV.calImg {ldelim} 42 width:{$chronology_calendar.month_view.CELL_WIDTH}px;height:{$chronology_calendar.month_view.CELL_HEIGHT}px; 43 } 44 </style> 45 {/html_head} 40 46 {foreach from=$chronology_calendar.month_view.weeks item=week} 41 47 <tr> … … 45 51 <td class="calDayCellFull"> 46 52 <div class="calBackDate">{$day.DAY}</div><div class="calForeDate">{$day.DAY}</div> 47 <div class="calImg" style="width:{$chronology_calendar.month_view.CELL_WIDTH}px;height:{$chronology_calendar.month_view.CELL_HEIGHT}px;">53 <div class="calImg"> 48 54 <a href="{$day.U_IMG_LINK}"> 49 55 <img style="{$day.IMAGE_STYLE}" src="{$day.IMAGE}" alt="{$day.IMAGE_ALT}" title="{$pwg->l10n_dec('%d element','%d elements', $day.NB_ELEMENTS)}" /> … … 51 57 </div> 52 58 {else} 53 <td class="calDayCellEmpty" style="width:{$chronology_calendar.month_view.CELL_WIDTH}px;height:{$chronology_calendar.month_view.CELL_HEIGHT}px;">{$day.DAY}59 <td class="calDayCellEmpty">{$day.DAY} 54 60 {/if} 55 61 {else} 56 <td class="calDayCellBlank" style="width:{$chronology_calendar.month_view.CELL_WIDTH}px;height:{$chronology_calendar.month_view.CELL_HEIGHT}px;">62 <td class="calDayCellBlank"> 57 63 {/if} 58 64 </td>
Note: See TracChangeset
for help on using the changeset viewer.