Ignore:
Timestamp:
Mar 21, 2010, 12:14:30 AM (14 years ago)
Author:
patdenice
Message:

feature 1522: Move local css local files and local language files to local directory.
Add $conftemplate_force_compile to help developpers.

File:
1 edited

Legend:

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

    r5196 r5208  
    5050    $this->smarty = new Smarty;
    5151    $this->smarty->debugging = $conf['debug_template'];
    52     $this->smarty->compile_check=$conf['template_compile_check'];
     52    $this->smarty->compile_check = $conf['template_compile_check'];
     53    $this->smarty->force_compile = $conf['template_force_compile'];
    5354
    5455    $compile_dir = $conf['local_data_dir'].'/templates_c';
     
    7172    $this->smarty->template_dir = array();
    7273    if ( !empty($theme) )
     74    {
    7375      $this->set_theme($root, $theme, $path);
     76      $this->set_prefilter( 'header', array('Template', 'prefilter_local_css') );
     77    }
    7478    else
    7579      $this->set_template_dir($root);
     
    546550    return $source;
    547551  }
     552
     553  static function prefilter_local_css($source, &$smarty)
     554  {
     555    $css = array();
     556
     557    foreach ($smarty->get_template_vars('themes') as $theme)
     558    {
     559      if (file_exists(PHPWG_ROOT_PATH.'local/css/'.$theme['id'].'-rules.css'))
     560      {
     561        array_push($css, '<link rel="stylesheet" type="text/css" href="{$ROOT_URL}local/css/'.$theme['id'].'-rules.css">');
     562      }
     563    }
     564    if (file_exists(PHPWG_ROOT_PATH.'local/css/rules.css'))
     565    {
     566      array_push($css, '<link rel="stylesheet" type="text/css" href="{$ROOT_URL}local/css/rules.css">');
     567    }
     568
     569    if (!empty($css))
     570    {
     571      $source = str_replace("\n</head>", "\n".implode( "\n", $css )."\n</head>", $source);
     572    }
     573
     574    return $source;
     575  }
    548576}
    549577
Note: See TracChangeset for help on using the changeset viewer.