Ignore:
Timestamp:
Jan 17, 2012, 10:58:18 PM (12 years ago)
Author:
rvelices
Message:

feature 2548 multisize - code cleanup + better usage in category_cats + i.php logs memory usage peak

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/template.class.php

    r12908 r12920  
    2323
    2424
    25 require_once(PHPWG_ROOT_PATH.'include/smarty/libs/Smarty.class.php');
    26 
    27 
    2825class Template {
    2926
     
    4340  // used by html_head smarty block to add content before </head>
    4441  var $html_head_elements = array();
     42  private $html_style = '';
    4543
    4644  const COMBINED_SCRIPTS_TAG = '<!-- COMBINED_SCRIPTS -->';
     
    113111    $this->smarty->register_modifier( 'get_extent', array(&$this, 'get_extent') );
    114112    $this->smarty->register_block('html_head', array(&$this, 'block_html_head') );
     113    $this->smarty->register_block('html_style', array(&$this, 'block_html_style') );
    115114    $this->smarty->register_function('combine_script', array(&$this, 'func_combine_script') );
    116115    $this->smarty->register_function('get_combined_scripts', array(&$this, 'func_get_combined_scripts') );
     
    467466    }
    468467
    469     if ( count($this->html_head_elements) )
     468    if ( count($this->html_head_elements) || strlen($this->html_style) )
    470469    {
    471470      $search = "\n</head>";
     
    473472      if ($pos !== false)
    474473      {
    475         $this->output = substr_replace( $this->output, "\n".implode( "\n", $this->html_head_elements ), $pos, 0 );
     474        $rep = "\n".implode( "\n", $this->html_head_elements );
     475        if (strlen($this->html_style))
     476        {
     477          $rep='<style type="text/css">'.$this->html_style.'</style>';
     478        }
     479        $this->output = substr_replace( $this->output, $rep, $pos, 0 );
    476480      } //else maybe error or warning ?
    477481      $this->html_head_elements = array();
     482      $this->html_style = '';
    478483    }
    479484
     
    530535    { // second call
    531536      $this->html_head_elements[] = $content;
     537    }
     538  }
     539
     540  function block_html_style($params, $content, &$smarty, &$repeat)
     541  {
     542    $content = trim($content);
     543    if ( !empty($content) )
     544    { // second call
     545      $this->html_style .= $content;
    532546    }
    533547  }
     
    843857    return call_user_func_array('sprintf',  $args );
    844858  }
    845  
     859
    846860  function derivative_url($type, $img)
    847861  {
Note: See TracChangeset for help on using the changeset viewer.