Ignore:
Timestamp:
Mar 18, 2010, 7:40:00 PM (14 years ago)
Author:
rvelices
Message:
  • allow template class to be instantiated with an empty theme (in plugins for example)
  • local_head must now be defined in the themeconf.inc.php otherwise not taken into account (avoid several calls to file_exists)
  • renamed themeconftheme to themeconfname (this is what it is themeconf[theme] is confusing)
File:
1 edited

Legend:

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

    r5154 r5177  
    2525require_once(PHPWG_ROOT_PATH.'include/smarty/libs/Smarty.class.php');
    2626
    27 // migrate lang:XXX
    28 //    sed "s/{lang:\([^}]\+\)}/{\'\1\'|@translate}/g" my_template.tpl
    29 // migrate change root level vars {XXX}
    30 //    sed "s/{pwg_root}/{ROOT_URL}/g" my_template.tpl
    31 // migrate change root level vars {XXX}
    32 //    sed "s/{\([a-zA-Z_]\+\)}/{$\1}/g" my_template.tpl
    33 // migrate all
    34 //    cat my_template.tpl | sed "s/{lang:\([^}]\+\)}/{\'\1\'|@translate}/g" | sed "s/{pwg_root}/{ROOT_URL}/g" | sed "s/{\([a-zA-Z_]\+\)}/{$\1}/g"
    35 
    3627
    3728class Template {
     
    4940  // Templates prefilter from external sources (plugins)
    5041  var $external_filters = array();
    51  
     42
    5243  // used by html_head smarty block to add content before </head>
    5344  var $html_head_elements = array();
     
    7970
    8071    $this->smarty->template_dir = array();
    81     $this->set_theme($root, $theme, $path);
     72    if ( !empty($theme) )
     73      $this->set_theme($root, $theme, $path);
     74    else
     75      $this->set_template_dir($root);
    8276
    8377    $this->smarty->assign('lang_info', $lang_info);
     
    10498    }
    10599
    106     $tpl_var = array('name' => $themeconf['theme']);
    107     if (file_exists($root.'/'.$theme.'/local_head.tpl'))
    108     {
    109       $tpl_var['local_head'] = realpath($root.'/'.$theme.'/local_head.tpl');
     100    $tpl_var = array('name' => $themeconf['name']);
     101    if (!empty($themeconf['local_head']) )
     102    {
     103      $tpl_var['local_head'] = realpath($root.'/'.$theme.'/'.$themeconf['local_head'] );
    110104    }
    111105    $this->smarty->append('themes', $tpl_var);
     
    469463    ksort($this->external_filters[$handle]);
    470464  }
    471  
     465
    472466 /**
    473467   * This function actually triggers the filters on the tpl files.
     
    480474    {
    481475      $compile_id = '';
    482       foreach ($this->external_filters[$handle] as $filters) 
    483       {
    484         foreach ($filters as $filter) 
     476      foreach ($this->external_filters[$handle] as $filters)
     477      {
     478        foreach ($filters as $filter)
    485479        {
    486480          list($type, $callback) = $filter;
     
    497491    if (isset($this->external_filters[$handle]))
    498492    {
    499       foreach ($this->external_filters[$handle] as $filters) 
    500       {
    501         foreach ($filters as $filter) 
     493      foreach ($this->external_filters[$handle] as $filters)
     494      {
     495        foreach ($filters as $filter)
    502496        {
    503497          list($type, $callback) = $filter;
Note: See TracChangeset for help on using the changeset viewer.