Exemple #1
0
 /**
  * init smarty engine and custom theme support object
  *
  * this is called once from index.php when ALL other initializations
  * are complete.
  */
 public static function init($debug = false)
 {
     global $sourcedir, $settings, $boarddir, $context;
     self::$_is_Debug = $debug;
     @(require_once $sourcedir . '/lib/Smarty/Smarty.class.php');
     self::$_smartyInstance = new Smarty();
     self::$_smartyInstance->caching = 0;
     // this is *STATIC* caching of generated pages, we don't want (or even need) this for a forum...
     if (is_callable('theme_support_autoload')) {
         // theme_support.php (if present) was previously loaded in loadTheme().
         self::$_configInstance = theme_support_autoload(self::$_smartyInstance);
     } else {
         self::$_configInstance = new EoS_Smarty_Template_Support(self::$_smartyInstance);
     }
     $firstdir = 0;
     if (MOBILE) {
         self::$_smartyInstance->setTemplateDir($settings['default_theme_dir'] . '/m');
         $firstdir++;
     }
     if ($settings['allow_template_overrides']) {
         // allow overrides (mod setting)
         self::$_smartyInstance->setTemplateDir($settings['default_theme_dir'] . '/tpl/overrides');
         $firstdir++;
     }
     foreach ($settings['template_dirs'] as $dir) {
         if (!$firstdir) {
             self::$_smartyInstance->setTemplateDir($dir . '/tpl');
         } else {
             self::$_smartyInstance->addTemplateDir($dir . '/tpl');
         }
         $firstdir++;
     }
     self::$_smartyInstance->setCompileDir(rtrim($boarddir, '/') . '/template_cache');
     // TODO: make this customizable
     $context['clip_image_src'] = $settings['images_url'] . '/' . $settings['clip_image_src'][$context['theme_variant']];
     $context['sprite_image_src'] = $settings['images_url'] . '/' . $settings['sprite_image_src'][$context['theme_variant']];
     /*
      * this hook could be used to re-configure smarty (for example, add additional template dir(s)),
      * or register hook template fragments via $_configInstance->registerTemplateHook()
      */
     HookAPI::callHook('smarty_init', array(&self::$_smartyInstance, &self::$_configInstance));
 }