Esempio n. 1
0
 /**
  * Constructor - Sets the templateDir and compileDir for the Smarty files
  * @param <String> - $media Layout/Media name
  */
 function __construct($media = '')
 {
     parent::__construct();
     $THISDIR = dirname(__FILE__);
     $templatesDir = '';
     $compileDir = '';
     $templateDir = [];
     if (!empty($media)) {
         self::$currentLayout = $media;
         $customTemplatesDir = $THISDIR . '/../../custom/layouts/' . $media;
         $templateDir[] = $THISDIR . '/../../layouts/' . $media;
         $compileDir = $THISDIR . '/../../cache/templates_c/' . $media;
     }
     $defaultLayout = vglobal('defaultLayout');
     if ($defaultLayout && is_file(vglobal('root_directory') . '/layouts/' . $defaultLayout)) {
         $templateDir[] = $THISDIR . '/../../layouts/' . $defaultLayout;
     }
     if (empty($templatesDir) || !file_exists($templatesDir)) {
         self::$currentLayout = self::getDefaultLayoutName();
         $templateDir[] = $THISDIR . '/../../custom/layouts/' . self::getDefaultLayoutName();
         $templateDir[] = $THISDIR . '/../../layouts/' . self::getDefaultLayoutName();
         $compileDir = $THISDIR . '/../../cache/templates_c/' . self::getDefaultLayoutName();
     }
     if (!file_exists($compileDir)) {
         mkdir($compileDir, 0777, true);
     }
     $this->setTemplateDir($templateDir);
     $this->setCompileDir($compileDir);
     self::$debugViewer = SysDebug::get('DEBUG_VIEWER');
     // FOR SECURITY
     // Escape all {$variable} to overcome XSS
     // We need to use {$variable nofilter} to overcome double escaping
     // TODO: Until we review the use disabled.
     //$this->registerFilter('variable', array($this, 'safeHtmlFilter'));
     // FOR DEBUGGING: We need to have this only once.
     static $debugViewerURI = false;
     if (self::$debugViewer && $debugViewerURI === false) {
         $debugViewerURI = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
         if (!empty($_POST)) {
             $debugViewerURI .= '?' . http_build_query($_POST);
         } else {
             $debugViewerURI = $_SERVER['REQUEST_URI'];
         }
         $this->log("URI: {$debugViewerURI}, TYPE: " . $_SERVER['REQUEST_METHOD']);
     }
 }