Ignore:
Timestamp:
Mar 13, 2010, 1:00:52 AM (14 years ago)
Author:
plg
Message:

feature 1502: based on Dotclear model, P@t has reorganized the way Piwigo
manages template/theme in a simpler "theme only level" architecture. It
supports multiple level inheritance.

File:
1 edited

Legend:

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

    r5101 r5123  
    5353  var $html_head_elements = array();
    5454
    55   function Template($root = ".", $theme= "")
     55  function Template($root = ".", $theme= "", $path = "template")
    5656  {
    5757    global $conf, $lang_info;
     
    7878    }
    7979
     80    $this->smarty->template_dir = array();
    8081    if ( !empty($theme) )
    8182    {
    82       include($root.'/theme/'.$theme.'/themeconf.inc.php');
    83       $this->smarty->assign('themeconf', $themeconf);
     83      $this->set_theme($root, $theme, $path);
    8484    }
    8585
    8686    $this->smarty->assign('lang_info', $lang_info);
    87 
    88     $this->set_template_dir($root);
    8987
    9088    if (!defined('IN_ADMIN') and isset($conf['extents_for_templates']))
     
    9694
    9795  /**
    98    * Sets the template root directory for this Template object.
    99    * Revised from Piwigo 2.1 to add modeling support
    100    */
     96   * Load theme's parameters.
     97   */
     98  function set_theme($root, $theme, $path)
     99  {
     100    $this->set_template_dir($root.'/'.$theme.'/'.$path);
     101
     102    include($root.'/'.$theme.'/themeconf.inc.php');
     103
     104    if (isset($themeconf['parent']))
     105    {
     106      $this->set_theme($root, $themeconf['parent'], $path);
     107    }
     108
     109    $tpl_var = array('name' => $themeconf['theme']);
     110    if (file_exists($root.'/'.$theme.'/local_head.tpl'))
     111    {
     112      $tpl_var['local_head'] = realpath($root.'/'.$theme.'/local_head.tpl');
     113    }
     114    $this->smarty->append('themes', $tpl_var);
     115    $this->smarty->append('themeconf', $themeconf, true);
     116  }
     117
    101118  function set_template_dir($dir)
    102119  {
    103     $modeling = $this->get_themeconf('modeling');
    104         if (!defined('IN_ADMIN') and ($modeling !== false))
    105         { // Modeling is active only on gallery side and never in admin
    106           // Set the normal directory
    107       $this->smarty->template_dir = array($dir);
    108           // Modeling by theme parameter
    109           $model = './template/' . $modeling;
    110       if ( $model != './template/' and is_dir($model))
    111           {
    112                 $this->smarty->template_dir[] = $model;
    113       }
    114           // Default template directory
    115           $this->smarty->template_dir[] = './template/default';
    116         }
    117     else
    118         {
    119       $this->smarty->template_dir = $dir;
    120         }
    121     $real_dir = realpath($dir);
    122     $compile_id = crc32( $real_dir===false ? $dir : $real_dir);
    123     $this->smarty->compile_id = base_convert($compile_id, 10, 36 );
     120    $this->smarty->template_dir[] = $dir;
     121
     122    if (!isset($this->smarty->compile_id))
     123    {
     124      $real_dir = realpath($dir);
     125      $compile_id = crc32( $real_dir===false ? $dir : $real_dir);
     126      $this->smarty->compile_id = base_convert($compile_id, 10, 36 );
     127    }
    124128  }
    125129
     
    197201  function set_extents($filename_array, $dir='', $overwrite=true)
    198202  {
     203    global $user;
     204
    199205    if (!is_array($filename_array))
    200206    {
     
    221227
    222228      if ((stripos(implode('',array_keys($_GET)), '/'.$param) !== false or $param == 'N/A')
    223         and (preg_match('/'.preg_quote($tpl,'/').'$/', $this->get_template_dir()) or $tpl == 'N/A')
     229        and ($tpl == $user['theme'] or $tpl == 'N/A')
    224230        and (!isset($this->extents[$handle]) or $overwrite)
    225231        and file_exists($dir . $filename))
Note: See TracChangeset for help on using the changeset viewer.