コード例 #1
0
ファイル: TemplateProcessor.php プロジェクト: Maxlander/shixi
 /**
  * Constructor explains our requirements to Smarty
  *
  * @param SJB_TemplateSupplier $templatesupplier instatance of SJB_TemplateSupplier class
  * @return SJB_TemplateProcessor
  */
 function __construct($templatesupplier)
 {
     $this->htmlTagConverter = SJB_ObjectMother::createHTMLTagConverterInArray();
     $this->compile_check = true;
     $this->module_name = $templatesupplier->getModuleName();
     parent::__construct();
     $this->error_reporting = E_ALL ^ E_NOTICE;
     $this->setCompileDir(SJB_System::getSystemSettings('COMPILED_TEMPLATES_DIR') . SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') . '/' . $templatesupplier->getTheme());
     if (!@is_dir($this->getCompileDir())) {
         @mkdir($this->getCompileDir(), 0777, true);
     }
     $this->setCacheDir(SJB_System::getSystemSettings('COMPILED_TEMPLATES_DIR') . '/smarty_cache');
     if (!@is_dir($this->getCacheDir())) {
         @mkdir($this->getCacheDir(), 0777, true);
     }
     /**
      * Check for 'cache_control_file.cache' in compile dir. If exists - clear compile dir.
      * Then if 'highlight_templates' mode is ON, and user is 'admin' - create 'cache_control_file'.
      */
     $cacheControlFile = $this->compile_dir . '/cache_control_file.cache';
     if (file_exists($cacheControlFile)) {
         $this->clearAllCache();
         $this->clearCompiledTemplate();
     }
     if (SJB_Settings::getSettingByName('highlight_templates') == 1 && SJB_Request::getVar('admin_mode', false, 'COOKIE')) {
         $fp = fopen($cacheControlFile, 'w');
         fclose($fp);
     }
     /////////////////////////
     $this->registerPlugin('function', 'module', array(&$this, 'module'));
     $this->registerPlugin('function', 'hidden_form_fields', array(&$this, 'hidden_form_fields'));
     $this->registerPlugin('function', 'url', array(&$this, 'get_module_function_url'));
     $this->registerPlugin('function', 'event', array(&$this, 'dispatch_event'));
     $currencyFormatter = new SJB_CurrencyFormatter();
     $this->registerPlugin('function', 'currencyFormat', array($currencyFormatter, 'currencyFormat'));
     $this->registerPlugin('function', 'locationFormat', 'SJB_LocationManager::locationFormat');
     /////////////////////////
     $this->registerPlugin('block', 'title', array(&$this, '_tpl_title'));
     $this->registerPlugin('block', 'keywords', array(&$this, '_tpl_keywords'));
     $this->registerPlugin('block', 'description', array(&$this, '_tpl_description'));
     $this->registerPlugin('block', 'head', array(&$this, '_tpl_head'));
     $this->registerPlugin('block', 'breadcrumbs', array(&$this, '_tpl_breadcrumbs'));
     $this->registerFilter('pre', array(&$this, '_replace_translation_alias'));
     $this->registerPlugin('block', 'tr', array(&$this, 'translate'));
     $templatesupplier->registerResources($this);
     $this->templateSupplier = $templatesupplier;
     $this->registerPlugin('function', 'set_token_field', array(&$this, 'tpl_set_token_field'));
     $this->registerGlobalVariables();
 }