<?php
namespace Engine\Smarty; class ExtendedSmarty extends \Smarty\Smarty { public function setupInstance() { $CFG = \Engine\Loader_Cfg::getInstance()->getGlobal(); $smartyBaseTemplates = sprintf("%s/%s", APP_REAL_PATH, $CFG['thirdParties']['smarty']['pathToCompiledTemplates']); $templatePermissions = 0777; $cleanModuleDirs = substr(str_replace('/', '_', MODULE_PATH), 0, -1); $this->setCompileDir($smartyBaseTemplates . $cleanModuleDirs); $this->setTemplateDir($CFG['thirdParties']['smarty']['pathToLocalTemplates']); if ( !is_dir($smartyBaseTemplates . $cleanModuleDirs) ) { if ( !is_dir($smartyBaseTemplates) ) { mkdir($smartyBaseTemplates, $templatePermissions); chmod($smartyBaseTemplates, $templatePermissions); } if ($cleanModuleDirs) { mkdir($smartyBaseTemplates . $cleanModuleDirs, $templatePermissions); chmod($smartyBaseTemplates . $cleanModuleDirs, $templatePermissions); } } } } 