/**
  * Constructor that will create a Smarty object and configure it according
  * to what's been specified in config.inc.
  */
 public function __construct()
 {
     /* Create a Smarty object. */
     $this->_smarty = new Smarty();
     # Stick it globally so we could refer the translations
     global $Smarty;
     $Smarty = $this->_smarty;
     global $lang;
     global $available_languages;
     /* Configure smarty. */
     $this->_smarty->compile_dir = SMARTY_DIR_COMPILE;
     $this->_smarty->cache_dir = SMARTY_DIR_CACHE;
     $this->_smarty->config_dir = SMARTY_DIR_CONFIG;
     $this->_smarty->request_use_auto_globals = SMARTY_USE_GLOBALS;
     $this->_smarty->caching = SMARTY_CACHING_ENABLE;
     $this->_smarty->cache_lifetime = SMARTY_CACHING_LIFETIME;
     $this->_smarty->compile_check = SMARTY_CACHING_COMPILE_CHECK;
     $this->_smarty->force_recheck = SMARTY_CACHING_FORCE_RECHECK;
     $this->_smarty->template_dir = array("templates_{$lang}", 'templates');
     $this->_smarty->compile_id = $lang;
     $this->_smarty->config_dir = ".";
     # First we read English, so al defaults are there
     $this->_smarty->config_load(DIR_LANG . "/lang.ini");
     # Now we try to read translations
     if (is_file($fname = DIR_LANG . "/lang.{$lang}.ini") && is_readable($fname)) {
         $this->_smarty->config_load($fname);
     }
     setlocale(LC_TIME, $Smarty->_config[0]['vars']['locale']);
     /**
      * Add a output-filter to make sure ampersands are properly encoded to
      * HTML-entities.
      */
     $this->_smarty->register_outputfilter(array(&$this, 'outputFilter'));
     /* Give Smarty-template access to date(). */
     $this->_smarty->register_modifier('date_f', array(&$this, 'date_f'));
     $this->_smarty->register_modifier('date_localized', array(&$this, 'date_localized'));
     /* Give Smarty-templates access to the ampersandEntity() function. */
     $this->_smarty->register_modifier('escapeAmpersand', array(&$this, 'ampersandEntity'));
     $this->_title = '';
     $this->_css_files = array();
     $this->_js_files = array();
     $this->_show_intro = false;
     $this->_content_title = '';
     $this->_content = '';
     /* The menus have caused an exception, need to skip them. */
     if (!ExceptionHandler::skipMenus()) {
         $menus = MenuModel::getAllMenus();
     }
     # Construct lang URL
     $pageurl = preg_replace('/\\?lang=[a-z]*$/', '', $_SERVER['REQUEST_URI']);
     /* Set up the common variables before displaying. */
     $vars = array('release' => RELEASE, 'baseurl' => URL_BASE, 'heroes_num' => HEROES_NUM, 'menus' => $menus, 'pageurl' => $pageurl, 'available_languages' => $available_languages);
     $this->_smarty->assign($vars);
 }
Exemple #2
0
 /**
  * Constructor that will create a Smarty object and configure it according
  * to what's been specified in config.inc.
  */
 public function __construct()
 {
     /* Create a Smarty object. */
     $this->_smarty = new Smarty();
     /* Configure smarty. */
     $this->_smarty->template_dir = SMARTY_DIR_TEMPLATE;
     $this->_smarty->compile_dir = SMARTY_DIR_COMPILE;
     $this->_smarty->cache_dir = SMARTY_DIR_CACHE;
     $this->_smarty->config_dir = SMARTY_DIR_CONFIG;
     $this->_smarty->request_use_auto_globals = SMARTY_USE_GLOBALS;
     $this->_smarty->caching = SMARTY_CACHING_ENABLE;
     $this->_smarty->cache_lifetime = SMARTY_CACHING_LIFETIME;
     $this->_smarty->compile_check = SMARTY_CACHING_COMPILE_CHECK;
     $this->_smarty->force_recheck = SMARTY_CACHING_FORCE_RECHECK;
     /**
      * Add a output-filter to make sure ampersands are properly encoded to
      * HTML-entities.
      */
     $this->_smarty->register_outputfilter(array(&$this, 'outputFilter'));
     /* Give Smarty-template access to date(). */
     $this->_smarty->register_modifier('date_f', array(&$this, 'date_f'));
     /* Give Smarty-templates access to the ampersandEntity() function. */
     $this->_smarty->register_modifier('escapeAmpersand', array(&$this, 'ampersandEntity'));
     $this->_title = '';
     $this->_css_files = array();
     $this->_js_files = array();
     $this->_show_intro = false;
     $this->_content_title = '';
     $this->_content = '';
     /* The menus have caused an exception, need to skip them. */
     if (!ExceptionHandler::skipMenus()) {
         $menus = MenuModel::getAllMenus();
     }
     /* Set up the common variables before displaying. */
     $vars = array('release' => RELEASE, 'baseurl' => URL_BASE, 'heroes_num' => HEROES_NUM, 'menus' => $menus);
     $this->_smarty->assign($vars);
 }