setConfigDir() public method

Set config directory
public setConfigDir ( $config_dir ) : Smarty
return Smarty current Smarty instance for chaining
Example #1
0
 /**
  * Initialize the view
  * Require the class to have an instance of the provider
  *
  * @param string $templateFolder Optional template folder to use instead of the default /frontend/module/views/
  * @return Viewable
  */
 protected function initializeView($templateFolder = null)
 {
     if (!$this->view) {
         $this->view = new \Smarty();
         $configuration = $this->getConfiguration();
         $appFolder = $configuration->get('system.app.folder');
         if ($templateFolder === null) {
             $module = $this->getModuleFromNamespace();
             $templateFolder = $appFolder . '/frontend/' . $module . '/views/';
         }
         // setup the template folder
         $this->view->setTemplateDir($templateFolder);
         // setup the temporary folders
         $tempFolder = $configuration->get('system.temp.folder');
         $this->view->setCompileDir($this->checkWritable($tempFolder . '/smarty_compiled/'));
         $this->view->setCacheDir($this->checkWritable($tempFolder . '/smarty_cache/'));
         $this->view->setConfigDir($this->checkWritable($tempFolder . '/smarty_config/'));
         // add all the plugin folders to the view
         foreach ($configuration->get('view.plugin.folders', array()) as $pluginFolder) {
             $this->view->addPluginsDir($pluginFolder);
         }
         $this->view->addPluginsDir($appFolder . '/../vendor/mystlabs/mistyforms/src/MistyForms/smarty_plugins');
         $this->view->addPluginsDir($appFolder . '/../vendor/mystlabs/mistyapp/src/MistyApp/smarty_plugins');
         // if we are in development mode we want to regenerate the views at every render
         if ($configuration->get('system.development.mode', false)) {
             $this->view->compile_check = true;
             $this->view->force_compile = true;
         }
     }
     return $this;
 }
Example #2
0
 public function __construct()
 {
     @session_start();
     $this->smarty = new Smarty();
     $this->smarty->setTemplateDir(realpath('../install/templates/'));
     $this->smarty->setCompileDir(nZEDb_LIBS . 'smarty/templates_c/');
     $this->smarty->setConfigDir(nZEDb_LIBS . 'smarty/configs/');
     $this->smarty->setCacheDir(nZEDb_LIBS . 'smarty/cache/');
 }
Example #3
0
 /**
  * Constructor del nucleo
  *
  * Inicializa el objeto smarty y guarda los parametros
  *
  */
 private function __construct()
 {
     //Cargar Smarty Principal y su configuraci�n
     $this->smarty = new Smarty();
     $dirabs = "http://" . dirname($_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
     $this->smarty->setTemplateDir('app/vistas/');
     $this->smarty->setCompileDir('tmp/templates_c/');
     $this->smarty->setConfigDir('app/configuracion/');
     $this->smarty->setCacheDir('tmp/cache/');
     $this->smarty->assign("publico", $dirabs . '/app/publico');
     $this->smarty->caching = false;
     $this->parametros = $_REQUEST;
     $this->get = $_GET;
     $this->post = $_POST;
 }
Example #4
0
File: Page.php Project: jankal/mvc
 private static function prepareSmartyObject()
 {
     self::$smarty = new Smarty();
     self::$smarty->setTemplateDir(HOME_DIR . '/templates/' . app::get('template') . '/');
     self::$smarty->setCompileDir(HOME_DIR . '/templates_c/');
     self::$smarty->setConfigDir(HOME_DIR . '/configs/');
     self::$smarty->setCacheDir(HOME_DIR . '/cache/');
     self::$smarty->force_compile = true;
     self::$smarty->debugging = \app::get('debug');
     self::$smarty->caching = true;
     self::$smarty->cache_lifetime = 120;
     foreach (self::$assign as $key => $value) {
         self::$smarty->assign($key, $value);
     }
 }
Example #5
0
 /**
  * Get the evaluated contents of the view at the given path.
  *
  * @param string $path
  * @param array $data
  * @return string
  */
 protected function evaluatePath($__path, $__data)
 {
     $caching = $this->config('caching');
     $cache_lifetime = $this->config('cache_lifetime');
     $debugging = $this->config('debugging');
     $template_path = $this->config('template_path');
     $compile_path = $this->config('compile_path');
     $cache_path = $this->config('cache_path');
     $plugins_paths = (array) $this->config('plugins_paths');
     $config_paths = (array) $this->config('config_paths');
     $escape_html = $this->config('escape_html', false);
     // Create smarty object.
     $smarty = new \Smarty();
     $smarty->setTemplateDir($template_path);
     $smarty->setCompileDir($compile_path);
     $smarty->setCacheDir($cache_path);
     foreach ($plugins_paths as $path) {
         $smarty->addPluginsDir($path);
     }
     foreach ($config_paths as $path) {
         $smarty->setConfigDir($path);
     }
     $smarty->debugging = $debugging;
     $smarty->caching = $caching;
     $smarty->cache_lifetime = $cache_lifetime;
     $smarty->compile_check = true;
     // set the escape_html flag from the configuration value
     //
     $smarty->escape_html = $escape_html;
     $smarty->error_reporting = E_ALL & ~E_NOTICE;
     foreach ($__data as $var => $val) {
         $smarty->assign($var, $val);
     }
     return $smarty->fetch($__path);
 }
Example #6
0
function rx_set_smarty_paths(Smarty $viewModel)
{
    $viewModel->setTemplateDir(app\service\Smarty::$VIEW_PATH);
    $viewModel->setConfigDir(CONFIG_PATH);
    $CACHE_PATH = BUILD_PATH . 'smarty_cache';
    if (!file_exists($CACHE_PATH)) {
        if (!mkdir($CACHE_PATH, 0777, true)) {
            die('Failed to create folders:' . $CACHE_PATH);
        }
    }
    $viewModel->setCacheDir($CACHE_PATH);
    $TEMP_PATH = BUILD_PATH . 'smarty_temp';
    if (!file_exists($TEMP_PATH)) {
        if (!mkdir($TEMP_PATH, 0777, true)) {
            die('Failed to create folders:' . $TEMP_PATH);
        }
    }
    $viewModel->setCompileDir($TEMP_PATH);
    $LOCAL_PLUGIN_PATH = APP_PATH . "SMARTY_PLUGINS";
    if (file_exists($LOCAL_PLUGIN_PATH)) {
        $viewModel->addPluginsDir($LOCAL_PLUGIN_PATH);
    }
    foreach (app\service\Smarty::$PLUGINS_DIR as $path) {
        $viewModel->addPluginsDir($path);
    }
}
 /**
  * initTemplate($tmpl_path = '', array $options = [ ], array $extres = [ ])
  *
  * テンプレートエンジンのインスタンスを生成する
  *
  * @access    private
  *
  * @param     string $tmpl_path テンプレートファイルが格納されているディレクトリのパス
  * @param     array  $options Smartyに引き渡すオプション
  * @param     array  $extres 外部リソースの定義
  *
  * @return    object    テンプレートエンジンのインスタンス
  */
 private function initTemplate($tmpl_path = '', array $options = ['cache' => ['mode' => \Smarty::CACHING_LIFETIME_SAVED, 'lifetime' => 3600, 'modified_check' => true], 'compile' => ['check' => true, 'force' => false], 'debug' => ['enable' => false, 'ctrl' => 'NONE']], array $extres = [])
 {
     // テンプレートパスをアプリケーション格納フォルダ配下に限定
     $tmpl_path = str_replace(DS . DS, DS, RISOLUTO_APPS . 'RisolutoApps/' . str_replace('../', '', $tmpl_path));
     // テンプレートエンジン関連定義(Smartyを使用)
     $tmpl = new \Smarty();
     //--- テンプレートキャッシュの設定
     $tmpl->setCacheDir(RISOLUTO_CACHE);
     $tmpl->caching = isset($options['cache']['mode']) ? $options['cache']['mode'] : \Smarty::CACHING_LIFETIME_SAVED;
     $tmpl->cache_lifetime = isset($options['cache']['lifetime']) ? $options['cache']['lifetime'] : 3600;
     $tmpl->cache_modified_check = isset($options['cache']['modified_check']) ? $options['cache']['modified_check'] : true;
     //--- コンパイル済みテンプレートの設定
     $tmpl->setCompileDir(RISOLUTO_CACHE);
     $tmpl->compile_check = isset($options['compile']['check']) ? $options['compile']['check'] : true;
     $tmpl->force_compile = isset($options['compile']['force']) ? $options['compile']['force'] : false;
     //--- テンプレート用コンフィグファイルの設定
     $tmpl->setConfigDir($tmpl_path);
     //--- テンプレートのデバッグ設定
     $tmpl->debugging = isset($options['debug']['enable']) ? $options['debug']['enable'] : false;
     $tmpl->debugging_ctrl = isset($options['debug']['ctrl']) ? $options['debug']['ctrl'] : 'NONE';
     //--- テンプレートファイルのパス
     $tmpl->setTemplateDir($tmpl_path);
     // 外部リソースの登録
     if (isset($extres)) {
         foreach ($extres as $dat) {
             if (isset($dat['name']) and isset($dat['class'])) {
                 $tmpl->register_resource($dat['name'], [$dat['class'], 'getTemplate', 'getTimeStamp', 'getSecure', 'getTrusted']);
             }
         }
     }
     return $tmpl;
 }
Example #8
0
 function execute()
 {
     Load::file('Smarty.class.php', $this->source_dir);
     $smarty = new Smarty();
     $smarty->setCompileDir(File::mkdir(TEMP_DIR . DS . $this->name . DS . 'templates_c') . DS);
     $smarty->setConfigDir(File::mkdir(TEMP_DIR . DS . $this->name . DS . 'configs') . DS);
     $smarty->setCacheDir(File::mkdir(TEMP_DIR . DS . $this->name . DS . 'cache') . DS);
     return $smarty;
 }
Example #9
0
function initSmarty()
{
    $smarty = new Smarty();
    $smarty->setTemplateDir(__SITEPATH__ . '/smarty/templates');
    $smarty->setCompileDir(__SITEPATH__ . '/smarty/templates_c');
    $smarty->setCacheDir(__SITEPATH__ . '/smarty/cache');
    $smarty->setConfigDir(__SITEPATH__ . '/smarty/configs');
    return $smarty;
}
Example #10
0
function setup_smarty()
{
    $smarty = new Smarty();
    $smarty->setTemplateDir('templates/');
    $smarty->setCompileDir('libs/smarty/templates_c/');
    $smarty->setConfigDir('libs/smarty/configs/');
    $smarty->setCacheDir('libs/smarty/cache/');
    return $smarty;
}
Example #11
0
 public static function loadSmarty()
 {
     $smarty = new Smarty();
     // var_dump($smarty);
     $smarty->setTemplateDir(APPLICATION_PATH . 'smarty/templates');
     $smarty->setCompileDir(APPLICATION_PATH . 'smarty/templates_c');
     $smarty->setCacheDir(APPLICATION_PATH . 'smarty/cache');
     $smarty->setConfigDir(APPLICATION_PATH . 'smarty/configs');
     return $smarty;
 }
Example #12
0
 function setSmarty()
 {
     global $SMARTY;
     $view = new Smarty();
     $view->setTemplateDir($SMARTY[0]['template']);
     $view->setCompileDir($SMARTY[0]['logs']);
     $view->setCacheDir($SMARTY[0]['cache']);
     $view->setConfigDir($SMARTY[0]['config']);
     return $view;
 }
Example #13
0
 public static function GetTemplate()
 {
     $smarty = new Smarty();
     $smarty->setTemplateDir(TEMPLATE_PATH);
     $smarty->setCompileDir(COMPILE_PATH);
     $smarty->setConfigDir(CONF_PATH);
     $smarty->setCacheDir(CACHE_PATH);
     $smarty->addPluginsDir(TEMPLATE_PLUGINS_PATH);
     return $smarty;
 }
Example #14
0
 public function setUp()
 {
     $view = new \Smarty();
     $view->setTemplateDir(SMARTY_TMP_FOLDER);
     $view->setCompileDir(SMARTY_TMP_FOLDER);
     $view->setConfigDir(SMARTY_TMP_FOLDER);
     $view->setCacheDir(SMARTY_TMP_FOLDER);
     $view->addPluginsDir(__DIR__ . '/../../smarty_plugins/');
     $view->compile_check = true;
     $this->smarty = $view;
 }
Example #15
0
 public static function getSmarty()
 {
     $rootDir = dirname(__FILE__);
     require_once $rootDir . "/smarty/Smarty.class.php";
     $smarty = new Smarty();
     $smarty->setTemplateDir($rootDir . "/smarty/templates");
     $smarty->setCacheDir($rootDir . "/working_temp/cache");
     $smarty->setCompileDir($rootDir . "/working_temp/templates_c");
     $smarty->setConfigDir($rootDir . "/working_temp/configs");
     return $smarty;
 }
Example #16
0
 /**
  * @param string $basePath Application's base path ending with DIRECTORY_SEPARATOR
  * @param string $theme
  * @param \Skully\Application $app
  * @param array $additionalPluginsDir
  * @param int $caching
  */
 public function __construct($basePath, $theme = 'default', $app = null, $additionalPluginsDir = array(), $caching = 1)
 {
     $appName = $app->getAppName();
     $this->app = $app;
     $this->smarty = new \Smarty();
     $this->smarty->caching = $caching;
     $this->caching = $caching;
     $this->smarty->setCompileDir($basePath . implode(DIRECTORY_SEPARATOR, array($appName, 'smarty', 'templates_c')) . DIRECTORY_SEPARATOR);
     $this->smarty->setConfigDir($basePath . implode(DIRECTORY_SEPARATOR, array($appName, 'smarty', 'configs')) . DIRECTORY_SEPARATOR);
     $this->smarty->setCacheDir($basePath . implode(DIRECTORY_SEPARATOR, array($appName, 'smarty', 'cache')));
     $dirs = $this->app->getTheme()->getDirs();
     foreach ($dirs as $key => $dir) {
         if ($key == 'main' || $key == 'default') {
             $this->addTemplateDir($dir . DIRECTORY_SEPARATOR . $appName . DIRECTORY_SEPARATOR . 'views', $key);
         } else {
             $this->addTemplateDir($dir . DIRECTORY_SEPARATOR . 'views', $key);
         }
     }
     $plugins = array_merge($additionalPluginsDir, array($this->app->getRealpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'App' . DIRECTORY_SEPARATOR . 'smarty' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR, $this->app->getRealpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'Library' . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR . 'libs' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR));
     $this->setPluginsDir($plugins);
 }
Example #17
0
 protected function __construct()
 {
     PsLibs::inst()->Smarty();
     /*
      * Начиная с версии 5.4 в функции htmlentities параметр encoding был изменён на UTF-8, 
      * до этого момента после применения данного метода к тексту шаблона мы будем получать кракозябру.
      */
     SmartyCompilerException::$escape = is_phpver_is_or_greater(5, 4);
     //Получим и сконфигурируем экземпляр Smarty
     $this->smarty = new Smarty();
     $this->smarty->compile_check = true;
     $this->smarty->force_compile = false;
     //$this->smarty->caching = TRUE;
     /*
      * УПРАВЛЯЮЩИЕ ДИРЕКТОРИИ
      */
     //Директории с шаблонами .tpl : PSSmarty::template('common/citata.tpl');
     $this->smarty->setTemplateDir(ConfigIni::smartyTemplates());
     //Директория, в которую складываются скомпилированные шаблоны
     $this->smarty->setCompileDir(DirManager::autogen('/smarty/templates_c/')->absDirPath());
     //Директория, в которую складываются кеши
     $this->smarty->setCacheDir(DirManager::autogen('/smarty/cache/')->absDirPath());
     //Директория с конфигами
     $this->smarty->setConfigDir(PATH_BASE_DIR . PS_DIR_INCLUDES . '/smarty/configs/');
     //Директории с плагинами - блочными функциями, функциями, модификатор
     $this->smarty->addPluginsDir(ConfigIni::smartyPlugins());
     /*
      * Импортируем константы некоторых классов, чтобы на них можно было ссылаться через 
      * {$smarty.const.CONST_NAME}
      */
     //PsConstJs::defineAllConsts();
     /*
      * ПОДКЛЮЧИМ ФИЛЬТРЫ
      */
     PSSmartyFilter::inst()->bind($this->smarty);
     /*
      * ПОДКЛЮЧАЕМ ПЛАГИНЫ
      */
     PSSmartyPlugin::inst()->bind($this->smarty);
 }
Example #18
0
 public function __construct()
 {
     parent::__construct();
     $this->javascript_files = array();
     $this->javascript_texts = array();
     $file_path = dirname(__FILE__) . '/';
     $smarty_dir = $file_path . '../smarty/';
     parent::setTemplateDir($smarty_dir . 'templates/');
     parent::setCompileDir($smarty_dir . 'dev/template_c/');
     parent::setCacheDir($smarty_dir . 'dev/cache/');
     parent::setConfigDir($smarty_dir . 'configs/');
     $smarty_install_path = $file_path . '../../third_party/Smarty_3_1_0/';
     parent::setPluginsDir($smarty_install_path . 'libs/plugins');
     parent::addPluginsDir($smarty_install_path . 'libs/sysplugins');
 }
Example #19
0
 /**
  * 
  * @return Smarty
  */
 static function returnSmarty()
 {
     if (self::$smarty != NULL) {
         return self::$smarty;
     }
     $smarty = new Smarty();
     $smarty->setTemplateDir('templates');
     $smarty->setCompileDir('templates_c');
     $smarty->setCacheDir('cache');
     $smarty->setConfigDir('configs');
     $smarty->caching = 0;
     $smarty->compile_check = true;
     self::$smarty = $smarty;
     return $smarty;
 }
Example #20
0
 public function load_smarty($vars, $template)
 {
     // loads the PHP Smarty class
     require_once PATH . '/libs/Smarty.class.php';
     $smarty = new Smarty();
     $smarty->setTemplateDir(PATH . '/templates/');
     $smarty->setCompileDir(PATH . '/templates_c/');
     $smarty->setConfigDir(PATH . '/configs/');
     $smarty->setCacheDir(PATH . '/cache/');
     if (is_array($vars)) {
         foreach ($vars as $key => $value) {
             $smarty->assign($key, $value);
         }
     }
     $smarty->display($template);
 }
Example #21
0
 public static function getSmartyInstance()
 {
     if (self::$smarty == NULL) {
         require PHPLIB_DIR . '/smarty/Smarty.class.php';
         $smarty = new Smarty();
         $smarty->setTemplateDir(SMARTY_TEMPLATE_DIR);
         $smarty->setCompileDir(SMARTY_COMPILE_DIR);
         $smarty->setConfigDir(SMARTY_CONFIG_DIR);
         $smarty->setCacheDir(SMARTY_CACHE_DIR);
         $smarty->addPluginsDir(SMARTY_PLUGIN_DIR);
         $smarty->left_delimiter = SMARTY_LEFT_DELIMITER;
         $smarty->right_delimiter = SMARTY_RIGHT_DELIMITER;
         self::$smarty = $smarty;
     }
     return self::$smarty;
 }
Example #22
0
 /**
  * Render the template and return the HTML content
  *
  * @author salvipascual
  * @param Service $service, service to be rendered
  * @param Response $response, response object to render
  * @return String, template in HTML
  * @throw Exception
  */
 public function renderHTML($service, $response)
 {
     // if the response includes json, don't render HTML
     // this is used mainly to build email APIs
     if (!empty($response->json)) {
         return $response->json;
     }
     // get the path
     $di = \Phalcon\DI\FactoryDefault::getDefault();
     $wwwroot = $di->get('path')['root'];
     // select the right file to load
     if ($response->internal) {
         $userTemplateFile = "{$wwwroot}/app/templates/{$response->template}";
     } else {
         $userTemplateFile = "{$wwwroot}/services/{$service->serviceName}/templates/{$response->template}";
     }
     // creating and configuring a new Smarty object
     $smarty = new Smarty();
     $smarty->addPluginsDir("{$wwwroot}/app/plugins/");
     $smarty->setTemplateDir("{$wwwroot}/app/layouts/");
     $smarty->setCompileDir("{$wwwroot}/temp/templates_c/");
     $smarty->setCacheDir("{$wwwroot}/temp/cache/");
     $smarty->setConfigDir("{$wwwroot}/configs/");
     // disabling cache and debugging
     $smarty->force_compile = true;
     $smarty->debugging = false;
     $smarty->caching = false;
     // getting the ads
     $ads = $service->showAds ? $response->getAds() : array();
     // get the status of the mail list
     $connection = new Connection();
     $status = $connection->deepQuery("SELECT mail_list FROM person WHERE email='{$response->email}'");
     $onEmailList = empty($status) ? false : $status[0]->mail_list == 1;
     // list the system variables
     $systemVariables = array("APRETASTE_USER_TEMPLATE" => $userTemplateFile, "APRETASTE_SERVICE_NAME" => strtoupper($service->serviceName), "APRETASTE_SERVICE_RELATED" => $this->getServicesRelatedArray($service->serviceName), "APRETASTE_SERVICE_CREATOR" => $service->creatorEmail, "APRETASTE_ADS" => $ads, "APRETASTE_EMAIL_LIST" => $onEmailList, "WWWROOT" => $wwwroot);
     // merge all variable sets and assign them to Smarty
     $templateVariables = array_merge($systemVariables, $response->content);
     $smarty->assign($templateVariables);
     // renderig and removing tabs, double spaces and break lines
     $renderedTemplate = $smarty->fetch($response->layout);
     return preg_replace('/\\s+/S', " ", $renderedTemplate);
 }
Example #23
0
 /**
  * 获取模版对象 
  * @return void
  */
 private static function getTemplate()
 {
     if (null == self::$mTemplate) {
         $smarty = new Smarty();
         $smarty->setTemplateDir(TEMPLATE_DIR);
         //$smarty->template_dir = TEMPLATE_DIR;
         $smarty->setCompileDir(TEMPLATE_COMPILED);
         //$smarty->compile_dir = TEMPLATE_COMPILED;
         $smarty->setConfigDir(TEMPLATE_CONFIGS);
         //$smarty->config_dir = TEMPLATE_CONFIGS;
         $smarty->setCacheDir(TEMPLATE_CACHE);
         //$smarty->cache_dir = TEMPLATE_CACHE;
         $smarty->setPluginsDir(TEMPLATE_PLUGINS);
         //$smarty->plugins_dir = TEMPLATE_PLUGINS;
         $smarty->left_delimiter = '<{';
         $smarty->right_delimiter = '}>';
         self::$mTemplate = $smarty;
     }
     return self::$mTemplate;
 }
Example #24
0
function render_smarty($tpl = null, $data = array())
{
    $root = dirname(__FILE__) . '/';
    if (!$tpl) {
        $path = $_SERVER['REQUEST_URI'];
        $split = explode('/', $path);
        $last = array_pop($split);
        $len = count($split);
        if (($pos = strpos($path, '?')) !== false) {
            $path = substr($path, 0, $pos);
        }
        if (1 === $len) {
            $path .= '/index.tpl';
        } else {
            $path .= '.tpl';
        }
        $tpl = $root . 'template' . $path;
    }
    if (!file_exists($tpl)) {
        echo "404 Not Found";
        exit;
    }
    $data_path = str_replace('/template', '/test', $tpl);
    $data_path = str_replace('.tpl', '.php', $data_path);
    require_once $root . 'libs/smarty/Smarty.class.php';
    $smarty = new Smarty();
    $default_conf = array('template_dir' => 'template', 'config_dir' => 'config', 'plugins_dir' => array('libs/Bigpipe/runtime/plugins'), 'left_delimiter' => '{%', 'right_delimiter' => '%}');
    $smarty->setTemplateDir($root . $default_conf['template_dir']);
    $smarty->setConfigDir($root . $default_conf['config_dir']);
    foreach ($default_conf['plugins_dir'] as $dir) {
        $smarty->addPluginsDir($root . $dir);
    }
    $smarty->setLeftDelimiter($default_conf['left_delimiter']);
    $smarty->setRightDelimiter($default_conf['right_delimiter']);
    if (file_exists($data_path)) {
        require_once $data_path;
        $smarty->assign($fis_data);
    }
    $smarty->display($tpl);
}
Example #25
0
 /**
  * Prepares the cache folder for Smarty
  *
  * @return void
  */
 private function initSmartyCache()
 {
     if (!is_dir($this->cacheDir)) {
         Tools::mkdir($this->cacheDir, true);
     }
     // compiled templates dir
     $path = $this->cacheDir . DIRECTORY_SEPARATOR . 'templates_c' . DIRECTORY_SEPARATOR;
     if (!is_dir($path)) {
         Tools::mkdir($path, false);
     }
     $this->loader->setCompileDir($path);
     // cache dir
     $path = $this->cacheDir . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR;
     if (!is_dir($path)) {
         Tools::mkdir($path, false);
     }
     $this->loader->setCacheDir($path);
     // configs dir
     $path = $this->cacheDir . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR;
     if (!is_dir($path)) {
         Tools::mkdir($path, false);
     }
     $this->loader->setConfigDir($path);
 }
Example #26
0
 /**
  * Get the Smarty instance and create if not exists
  * @return Smarty
  */
 public static function getSmarty()
 {
     if (self::$_smarty === NULL) {
         # Setup smarty config
         require_once GWF_SMARTY_PATH;
         $smarty = new Smarty();
         $smarty->setTemplateDir(GWF_WWW_PATH . 'tpl/');
         $dir = rtrim(GWF_SMARTY_DIRS, '/') . '/';
         $smarty->setCompileDir($dir . 'tplc');
         $smarty->setCacheDir($dir . 'cache');
         $smarty->setConfigDir($dir . 'cfg');
         $smarty->addPluginsDir(GWF_CORE_PATH . 'inc/smartyplugins');
         # Assign common template vars
         //			$smarty->assign('db', gdo_db());
         $smarty->assign('gwff', GWF_SmartyFile::instance());
         $smarty->assign('gwmm', GWF_SmartyModuleMethod::instance());
         $smarty->assign('root', GWF_WEB_ROOT);
         $smarty->assign('core', GWF_CORE_PATH);
         $smarty->assign('iconset', GWF_ICON_SET);
         $smarty->assign('design', self::getDesign());
         self::$_smarty = $smarty;
     }
     return self::$_smarty;
 }
Example #27
0
 /**
  * Set up session / smarty / user variables.
  */
 public function __construct()
 {
     $this->https = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? true : false;
     session_set_cookie_params(0, '/', '', $this->https, true);
     @session_start();
     if (nZEDb_FLOOD_CHECK) {
         $this->floodCheck();
     }
     // Buffer settings/DB connection.
     $this->settings = new Settings();
     $this->smarty = new Smarty();
     $this->smarty->setCompileDir(SMARTY_DIR . 'templates_c/');
     $this->smarty->setConfigDir(SMARTY_DIR . 'configs/');
     $this->smarty->setCacheDir(SMARTY_DIR . 'cache/');
     $this->smarty->error_reporting = nZEDb_DEBUG ? E_ALL : E_ALL - E_NOTICE;
     if (isset($_SERVER['SERVER_NAME'])) {
         $this->serverurl = ($this->https === true ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' && $_SERVER['SERVER_PORT'] != '443' ? ':' . $_SERVER['SERVER_PORT'] : '') . WWW_TOP . '/';
         $this->smarty->assign('serverroot', $this->serverurl);
     }
     $this->page = isset($_GET['page']) ? $_GET['page'] : 'content';
     $this->users = new Users(['Settings' => $this->settings]);
     if ($this->users->isLoggedIn()) {
         $this->setUserPreferences();
     } else {
         $this->theme = $this->settings->getSetting('site.main.style');
         $this->smarty->assign('isadmin', 'false');
         $this->smarty->assign('ismod', 'false');
         $this->smarty->assign('loggedin', 'false');
     }
     if ($this->theme === '') {
         $this->theme = 'Default';
     }
     $this->smarty->assign('theme', $this->theme);
     $this->smarty->assign('site', $this->settings);
     $this->smarty->assign('page', $this);
 }
Example #28
0
    }
}
$current_lang = setlocale(LC_ALL, $languages);
if (isset($_GET['mobile']) && $_GET['mobile']) {
    $theme = 'mobile';
} else {
    $theme = $default_theme;
}
bindtextdomain('nixtape', $install_path . '/themes/' . $theme . '/locale/');
textdomain('nixtape');
$smarty = new Smarty();
$smarty->setTemplateDir(array($install_path . '/themes/' . $theme . '/templates/', $install_path . '/themes/thelist/templates/'));
$smarty->setPluginsDir(array(SMARTY_DIR . '/plugins/', $install_path . '/themes/' . $theme . '/plugins/', $install_path . '/themes/thelist/plugins/'));
$smarty->setCompileDir($install_path . '/themes/' . $theme . '/templates_c/');
$smarty->setCacheDir($install_path . '/cache/');
$smarty->setConfigDir(array($install_path . '/themes/' . $theme . '/config/', $install_path . '/themes/thelist/config/'));
$current_lang = preg_replace('/.UTF-8/', '', $current_lang);
$smarty->assign('casauth', $auth);
if ($auth) {
    $casuid = phpCAS::getUser();
    $smarty->assign('userid', phpCAS::getUser());
    $attr = phpCAS::getAttributes();
    $nickname = $attr['nickname'];
    $smarty->assign('handle', $nickname);
    $user = new User($casuid);
    $userid = $user->id;
    $makerid = $user->makerid;
    $smarty->assign('makerid', $makerid);
}
$smarty->assign('lang_selector_array', array($current_lang => 1));
$smarty->assign('base_url', $base_url);
Example #29
0
//Check if website is offline
if ($sz_status == false) {
    include_once 'themes' . DS . sz_config('theme') . DS . 'views' . DS . 'offline.php';
    exit;
}
//Define Smarty Template System directory
define('SMARTY_DIR', str_replace("\\", "/", sz_config('base_path')) . 'smarty/');
//include the database class to check for debugging
include_once $lib_path . 'dbconfig.php';
include_once $lib_path . 'database.php';
//Setup Smarty and it's PATHS
require_once SMARTY_DIR . 'Smarty.class.php';
$smarty = new Smarty();
$smarty->setTemplateDir(sz_config('base_path') . 'themes/');
$smarty->setCompileDir(sz_config('base_path') . 'themes_c/');
$smarty->setConfigDir(sz_config('base_path') . 'configs/');
$smarty->setCacheDir(sz_config('base_path') . 'cache/');
//Check if debugging is enabled and set Smarty's debugging accordingly
if (sz_config('debug')) {
    $smarty->debugging = true;
} else {
    $smarty->debugging = false;
}
include_once $lib_path . 'session.php';
include_once $lib_path . 'validation.php';
include_once $lib_path . 'language.php';
include_once $lib_path . 'user.php';
include_once $lib_path . 'web_elements.php';
include_once $lib_path . 'whmcs.php';
include_once $lib_path . 'template.php';
//Open a database connection. It is needed by all the functions using the database
Example #30
0
    $_INICONF['hostname'] = trim($_INICONF['hostname']);
    $_INICONF['inipath'] = $full_ini_path;
    $_INICONF['webdocroot'] = dirname(__FILE__);
    $_INICONF['firstrun'] = 0;
    updateConf($_INICONF);
    if (isset($_INICONF['webdocroot']) && file_exists($_INICONF['webdocroot'] . '/updated')) {
        unlink($_INICONF['webdocroot'] . '/updated');
    }
}
$_INICONF['version'] = file_get_contents($_INICONF['webdocroot'] . '/version');
//include and setup smarty right here. go ahead and
require_once $_INICONF['webdocroot'] . '/includes/smarty/Smarty.class.php';
$_VIEW = new Smarty();
$_VIEW->setTemplateDir($_INICONF['webdocroot'] . '/includes/tpl/themes/' . $_INICONF['webtheme'] . '/');
$_VIEW->setCompileDir($_INICONF['webdocroot'] . '/includes/smarty/templates_c/');
$_VIEW->setConfigDir($_INICONF['webdocroot'] . '/includes/smarty/configs/');
$_VIEW->setCacheDir($_INICONF['webdocroot'] . '/includes/smarty/cache/');
//$_VIEW->debugging = true; // show the debug console
//Pass the $_INICONF variable to smarty
$_VIEW->assign('_INICONF', $_INICONF);
//create the messages array
$_MSGS = array();
//"encourage" users to connect via SSL
if (empty($_SERVER['HTTPS'])) {
    $_MSGS[] = array('type' => 'warning', 'msg' => "You are accessing ARKontrol over an insecure connection. Please switch to <a href=\"https://{$_SERVER['SERVER_ADDR']}{$_SERVER['REQUEST_URI']}\">https://{$_SERVER['SERVER_ADDR']}{$_SERVER['REQUEST_URI']}</a> and don't be afraid to continue through the browser warnings.");
}
//everyone gets a session
session_start();
//move this at some point, please.
function updateConf($CONF)
{