Changeset 2716


Ignore:
Timestamp:
Oct 11, 2008, 7:21:52 PM (16 years ago)
Author:
patdenice
Message:
  • Remove known_template function.
  • Replace it by a modifier function: get_extent.
Location:
trunk
Files:
2 edited

Legend:

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

    r2712 r2716  
    6565    $this->smarty->register_modifier( 'translate', array('Template', 'mod_translate') );
    6666    $this->smarty->register_modifier( 'explode', array('Template', 'mod_explode') );
     67    $this->smarty->register_modifier( 'get_extent', array(&$this, 'get_extent') );
    6768    $this->smarty->register_block('html_head', array(&$this, 'block_html_head') );
    6869    $this->smarty->register_function('known_script', array(&$this, 'func_known_script') );
    69     $this->smarty->register_function('known_template', array(&$this, 'func_known_template') );
    7070    $this->smarty->register_prefilter( array('Template', 'prefilter_white_space') );
    7171    if ( $conf['compiled_template_cache_language'] )
     
    154154        unset($this->files[$handle]);
    155155      }
    156       elseif (isset($this->extents[$handle]))
    157       {
    158         $this->files[$handle] = $this->extents[$handle];
    159       }
    160156      else
    161157      {
    162         $this->files[$handle] = $filename;
     158        $this->files[$handle] = $this->get_extent($filename, $handle);
    163159      }
    164160    }
     
    209205    }
    210206    return true;
     207  }
     208 
     209  /** return template extension if exists  */
     210  function get_extent($filename='', $handle='')
     211  {
     212    if (isset($this->extents[$handle]))
     213    {
     214      $filename = $this->extents[$handle];
     215    }
     216    return $filename;
    211217  }
    212218
     
    410416  }
    411417
    412  /**
    413    * This smarty "known_template" functions allows to include template
    414    * If extent[$params['id']] exists, include template extension
    415    * else include $params[$file]
    416    */ 
    417   function func_known_template($params, &$smarty )
    418   {
    419     if (!isset($params['file']))
    420     {
    421       $smarty->trigger_error("known_template: missing 'file' parameter");
    422       return;
    423     }
    424 
    425     if (isset($params['id']) and isset($this->extents[$params['id']]))
    426     {
    427       $file = $this->extents[$params['id']];
    428     }
    429     else
    430     {
    431       $file = $params['file'];
    432     }
    433 
    434     return $smarty->_smarty_include(array(
    435              'smarty_include_tpl_file' => $file,
    436              'smarty_include_vars' => array()
    437              ));
    438   }
    439 
    440418  static function prefilter_white_space($source, &$smarty)
    441419  {
  • trunk/template/yoga/menubar.tpl

    r2712 r2716  
    55        <dl id="{$id}">
    66                {if not empty($block->template)}
    7                 {known_template id=$id file=$block->template }
     7                {include file=$block->template|@get_extent:$id }
    88                {else}
    99                {$block->raw_content|@default}
Note: See TracChangeset for help on using the changeset viewer.