setCompileDir() public method

Set compile directory
public setCompileDir ( string $compile_dir ) : Smarty
$compile_dir string directory to store compiled templates in
return Smarty current Smarty instance for chaining
 /**
  * @param waSystem $system
  * @param array $options
  * @return waSmarty3View
  */
 public function __construct(waSystem $system, $options = array())
 {
     $this->smarty = new Smarty();
     parent::__construct($system, $options);
     if (isset($options['auto_literal'])) {
         $this->smarty->auto_literal = $options['auto_literal'];
     }
     if (isset($options['left_delimiter'])) {
         $this->smarty->left_delimiter = $options['left_delimiter'];
     }
     if (isset($options['right_delimiter'])) {
         $this->smarty->right_delimiter = $options['right_delimiter'];
     }
     $this->smarty->setTemplateDir(isset($options['template_dir']) ? $options['template_dir'] : $system->getAppPath());
     $this->smarty->setCompileDir(isset($options['compile_dir']) ? $options['compile_dir'] : $system->getAppCachePath('templates/compiled/'));
     $this->smarty->setCacheDir($system->getAppCachePath('templates/cache/'));
     if (ini_get('safe_mode')) {
         $this->smarty->use_sub_dirs = false;
     } else {
         $this->smarty->use_sub_dirs = true;
     }
     // not use
     //$this->smarty->setCompileCheck(wa()->getConfig()->isDebug()?true:false);
     $this->smarty->addPluginsDir($system->getConfig()->getPath('system') . '/vendors/smarty-plugins');
     $this->smarty->loadFilter('pre', 'translate');
 }
Beispiel #2
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;
 }
 /**
  * The default function
  */
 public function init()
 {
     $this->smarty = new \Smarty();
     $this->smarty->setCompileDir(ROOT . '/' . $this->compilDir);
     $this->smarty->use_sub_dirs = false;
     $this->smarty->assign('index', $this->request->index);
     $this->smarty->assign('base', $this->request->base);
 }
Beispiel #4
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/');
 }
Beispiel #5
0
 /**
  * Enables Smarty.
  */
 private function enableSmarty()
 {
     if ($this->smarty !== NULL) {
         return;
     }
     $this->smarty = new Smarty();
     $this->smarty->setTemplateDir(PUBLIC_DIR);
     $this->smarty->setCompileDir(PUBLIC_DIR . 'smarty' . DSC . 'compile');
     $this->smarty->setCacheDir(PUBLIC_DIR . 'smarty' . DSC . 'cache');
 }
Beispiel #6
0
 /**
  * Возращает экземпляр \Smarty использует синглтон
  *
  * @return \Smarty
  */
 public static function getSmarty()
 {
     if (self::$smarty === null) {
         self::$smarty = new \Smarty();
         list($compiledPath, $cachedPath) = self::getSmartyDirectories();
         self::$smarty->setTemplateDir(__DIR__ . '/../View/');
         self::$smarty->setCompileDir($compiledPath);
         self::$smarty->setCacheDir($cachedPath);
     }
     return self::$smarty;
 }
Beispiel #7
0
 /**
  * @param null $template
  * @param null $cache_id
  * @param null $compiled_id
  * @param null $parent
  * @return string
  *
  * @throws \SmartyException
  */
 public function get_template($template = null, $cache_id = null, $compiled_id = null, $parent = null)
 {
     $this->init_engine();
     $this->template_engine->setCompileDir($this->compile_dir);
     foreach ($this->template_dirs as $i => $dir) {
         $i == 0 && $this->template_engine->setTemplateDir($dir);
         $i > 0 && $this->template_engine->addTemplateDir($dir);
     }
     $this->load_lang_vars($this->get_lang_file());
     return $this->template_engine->getTemplate($template, $cache_id, $compiled_id, $parent);
 }
Beispiel #8
0
 /**
  * 构造方法
  *
  * @return void
  */
 protected function __construct()
 {
     \Yaf_Loader::import(APP_PATH . 'library/Thirdpart/Smarty/libs/Smarty.class.php');
     $this->_smarty = new \Smarty();
     $this->_smarty->setTemplateDir('');
     $this->_smarty->setCompileDir(TMP_PATH . 'smarty-compile/');
     $this->_smarty->setCacheDir(TMP_PATH . 'smarty-cache/');
     $this->_smarty->setPluginsDir(APP_PATH . 'library/Smarty/Plugins/');
     $this->_smarty->left_delimiter = '<!--{';
     $this->_smarty->right_delimiter = '}-->';
     $this->_smarty->enableSecurity('Comm\\Smarty_Security_Policy');
 }
 /**
  * Initialize view motor
  */
 public function initializeSmarty()
 {
     $this->smarty = new Smarty();
     $this->smarty->setCompileDir(_CACHE_DIR_ . DS . 'smarty' . DS . 'compile');
     $this->smarty->setCacheDir(_CACHE_DIR_ . DS . 'smarty' . DS . 'cache');
     $this->smarty->force_compile = Env::get('smarty.force_compile');
     $this->smarty->compile_check = Env::get('smarty.compile_check');
     // Assignation des variables utiles
     $this->smarty->assign('link', $this->link);
     $this->smarty->assign('tpl_dir', _VIEW_PATH_);
     $this->smarty->assign('base_uri', _BASE_URI_);
     $this->smarty->assign('app', Env::get('app'));
 }
Beispiel #10
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;
 }
Beispiel #11
0
 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);
     }
 }
Beispiel #12
0
 protected function _initalizeSmarty()
 {
     $configKey = $this->_sConfigKey;
     $caching = $this->config[$configKey . 'caching'];
     $cache_lifetime = $this->config[$configKey . 'cache_lifetime'];
     $debugging = $this->config[$configKey . 'debugging'];
     $template_path = $this->config[$configKey . 'template_path'];
     $compile_path = $this->config[$configKey . 'compile_path'];
     $cache_path = $this->config[$configKey . 'cache_path'];
     // Get the plugins path from the configuration
     $plugins_paths = $this->config[$configKey . 'plugins_paths'];
     //$this->_oSmarty = new \Smarty();
     require_once dirname(__FILE__) . '/Smarty/libs/Smarty.class.php';
     $this->_oSmarty = new \Smarty();
     $this->_oSmarty->setTemplateDir($template_path);
     $this->_oSmarty->setCompileDir($compile_path);
     $this->_oSmarty->setCacheDir($cache_path);
     // Add the plugin folder from the config to the Smarty object.
     // Note that I am using addPluginsDir here rather than setPluginsDir
     // because I want to add a secondary folder, not replace the
     // existing folder.
     foreach ($plugins_paths as $path) {
         $this->_oSmarty->addPluginsDir($path);
     }
     $this->_oSmarty->debugging = $debugging;
     $this->_oSmarty->caching = $caching;
     $this->_oSmarty->cache_lifetime = $cache_lifetime;
     $this->_oSmarty->compile_check = true;
 }
Beispiel #13
0
 public static function run($action)
 {
     ConfigurationChecks::loadChecks();
     ConfigurationChecks::performChecks();
     $smarty = new Smarty();
     $smarty->muteExpectedErrors();
     $smarty->setCacheDir(SYSTEM_ROOT . '/classes/smarty/cache/');
     $smarty->setCompileDir(SYSTEM_ROOT . '/classes/smarty/templates_c/');
     $smarty->setTemplateDir(SYSTEM_ROOT . '/install/view/');
     $smarty->caching = Smarty::CACHING_OFF;
     $smarty->force_compile = true;
     $smarty->assign('title', 'Installation');
     switch ($action) {
         case 'tables':
             self::insertTables($smarty);
             break;
         case 'user':
             self::createUser($smarty);
             break;
         case 'success':
             self::success($smarty);
             break;
         default:
             self::checkRequirements($smarty);
             break;
     }
 }
 /**
  * Create a new template object
  * @return object
  */
 public static function create()
 {
     // Try/catch statement
     try {
         // Required Smarty libraries
         require_once dirname(__DIR__) . '/smarty/libs/Smarty.class.php';
         // Optional - load custom security features
         //require_once(__DIR__.'/smartysecuritycustom.inc.php');
         // Smarty v3.1 or newer
         $smarty = new Smarty();
         $smarty->setTemplateDir(Config::read('smarty|templateDirectory'));
         $smarty->setCompileDir(Config::read('smarty|compileDirectory'));
         $smarty->setCacheDir(Config::read('smarty|cacheDirectory'));
         // Optional - override configs
         //$smarty->setConfigDir(Config::read('smarty|configDirectory'));
         // Optional - override plugins
         //$smarty->setPluginsDir(Config::read('smarty|pluginsDirectory'));
         $smarty->setCacheLifetime(Config::read('smarty|cacheLifetime'));
         // Disable caching
         $smarty->force_compile = true;
         $smarty->compile_check = true;
         $smarty->setCaching(Smarty::CACHING_OFF);
         // Optional - enable security restrictions
         //$smarty->enableSecurity('SmartySecurityCustom');
         // Return Smarty object
         return $smarty;
     } catch (Exception $e) {
         Log::error("Error while loading template engine");
         // Exception error
         return false;
     }
 }
Beispiel #15
0
 /**
  * Create a new template object
  * @return object
  */
 public static function create()
 {
     // Try/catch statement
     try {
         // Smarty installation
         $configDir = Config::read('smarty');
         // Required Smarty libraries
         require_once $configDir . '/libs/Smarty.class.php';
         // Smarty v3.1 or newer
         $smarty = new Smarty();
         $smarty->setTemplateDir(Config::read('pwd') . '/templates/' . Config::read('template'));
         $smarty->setCompileDir($configDir . '/templates_c');
         $smarty->setCacheDir($configDir . '/cache');
         // Disable caching
         $smarty->force_compile = true;
         $smarty->compile_check = true;
         $smarty->setCaching(Smarty::CACHING_OFF);
         // Return Smarty object
         return $smarty;
     } catch (Exception $e) {
         Log::error("Error while loading template engine");
         // Exception error
         return false;
     }
 }
Beispiel #16
0
function tpl_display($view = '', $vars = array())
{
    $dir_sep = DIRECTORY_SEPARATOR;
    $dir_base = __DIR__ . $dir_sep;
    $dir_smarty = $dir_base . implode($dir_sep, array('..', 'smarty-3.1.16', 'libs', ''));
    $dir_tpls = $dir_base . 'tpls' . $dir_sep;
    $dir_tplc = $dir_base . 'tplc' . $dir_sep;
    $dir_plgs = $dir_base . 'plugins' . $dir_sep;
    require_once $dir_smarty . 'Smarty.class.php';
    $smarty = new Smarty();
    $smarty->left_delimiter = '<%';
    $smarty->right_delimiter = '%>';
    $smarty->setTemplateDir($dir_tpls);
    $smarty->setCompileDir($dir_tplc);
    $smarty->addPluginsDir($dir_plgs);
    $smarty->registerFilter('pre', 'tpl_pre_filter');
    if (isset($vars['debug'])) {
        $smarty->force_compile = true;
    }
    $smarty->assign($vars);
    $smarty->display($view . '.tpl');
    if (isset($vars['debug'])) {
        $smarty->clearCompiledTemplate();
    }
}
Beispiel #17
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);
    }
}
Beispiel #18
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);
 }
 /**
  * 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;
 }
 /**
  * Constructor of the class
  */
 public function __construct($tpl_name = null)
 {
     $smarty = new Smarty();
     // TODO: remove "APP_LOCAL_PATH" from the list in 2.4.1
     $smarty->setTemplateDir(array(APP_LOCAL_PATH . '/templates', APP_LOCAL_PATH, APP_TPL_PATH));
     $smarty->setCompileDir(APP_TPL_COMPILE_PATH);
     $smarty->addPluginsDir(array(APP_INC_PATH . '/smarty'));
     $smarty->registerPlugin('modifier', 'activateLinks', array('Link_Filter', 'activateLinks'));
     $smarty->registerPlugin('modifier', 'activateAttachmentLinks', array('Link_Filter', 'activateAttachmentLinks'));
     $smarty->registerPlugin('modifier', 'formatCustomValue', array('Custom_Field', 'formatValue'));
     $smarty->registerPlugin('modifier', 'bool', array('Misc', 'getBooleanDisplayValue'));
     $smarty->registerPlugin('modifier', 'format_date', array('Date_Helper', 'getFormattedDate'));
     // Fixes problem with CRM API and dynamic includes.
     // See https://code.google.com/p/smarty-php/source/browse/trunk/distribution/3.1.16_RELEASE_NOTES.txt?spec=svn4800&r=4800
     if (isset($smarty->inheritance_merge_compiled_includes)) {
         $smarty->inheritance_merge_compiled_includes = false;
     }
     // this avoids loading it twice when using composer
     if (function_exists('smarty_block_t')) {
         $smarty->registerPlugin('block', 't', 'smarty_block_t');
     }
     if ($tpl_name) {
         $this->setTemplate($tpl_name);
     }
     $this->smarty = $smarty;
 }
 public function Display($file = false, $echo = true)
 {
     global $CMS, $DB, $USER;
     $smarty = new Smarty();
     //set cache and compile dir
     $smarty->setCacheDir("./data/data__hoang_taka_com/cache/");
     $smarty->setCompileDir("./data/data__hoang_taka_com/template_c/");
     $smarty->force_compile = $this->force_compile;
     $smarty->debugging = $this->debugging;
     $smarty->caching = $this->caching;
     $smarty->cache_lifetime = $this->cache_lifetime;
     if ($file) {
         //check template website use.
         $file_dir = "themes/" . $file . ".tpl";
         if (is_file($file_dir)) {
             $smarty->assign($this->data);
             if ($echo) {
                 return $smarty->display($file_dir);
             } else {
                 return $smarty->fetch($file_dir);
             }
         } else {
             echo "File: <b>{$file_dir}</b> is missing.";
         }
     }
 }
 /**
  * Get the evaluated contents of the view.
  *
  * @param  string $path
  * @param  array  $data
  *
  * @throws \Exception
  * @return string
  */
 public function get($path, array $data = array())
 {
     ob_start();
     try {
         $smarty = new \Smarty();
         $smarty->caching = $this->config->get('smarty-view::caching');
         $smarty->debugging = $this->config->get('smarty-view::debugging');
         $smarty->cache_lifetime = $this->config->get('smarty-view::cache_lifetime');
         $smarty->compile_check = $this->config->get('smarty-view::compile_check');
         $smarty->error_reporting = $this->config->get('smarty-view::error_reporting');
         if (\App::environment('local')) {
             $smarty->force_compile = true;
         }
         $smarty->setTemplateDir($this->config->get('smarty-view::template_dir'));
         $smarty->setCompileDir($this->config->get('smarty-view::compile_dir'));
         $smarty->setCacheDir($this->config->get('smarty-view::cache_dir'));
         $smarty->registerResource('view', new ViewResource());
         $smarty->addPluginsDir(__DIR__ . '/plugins');
         foreach ((array) $this->config->get('smarty-view::plugins_path', array()) as $pluginPath) {
             $smarty->addPluginsDir($pluginPath);
         }
         foreach ($data as $key => $value) {
             $smarty->assign($key, $value);
         }
         $smarty->display($path);
     } catch (\Exception $e) {
         ob_get_clean();
         throw $e;
     }
     return ltrim(ob_get_clean());
 }
Beispiel #23
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)
 {
     // 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/");
     // disabling cache and debugging
     $smarty->force_compile = true;
     $smarty->debugging = false;
     $smarty->caching = false;
     // 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_TOP_AD" => "", "APRETASTE_BOTTOM_AD" => "");
     // 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("email_default.tpl");
     return preg_replace('/\\s+/S', " ", $renderedTemplate);
 }
Beispiel #24
0
 function renderEntries(Search_ResultSet $entries)
 {
     global $tikipath;
     $smarty = new Smarty();
     $smarty->setCompileDir($tikipath . 'templates_c');
     $smarty->setTemplateDir(null);
     $smarty->setTemplateDir(dirname($this->templateFile));
     $smarty->setPluginsDir(array($tikipath . TIKI_SMARTY_DIR, SMARTY_DIR . 'plugins'));
     $secpol = new Tiki_Security_Policy($smarty);
     $secpol->secure_dir[] = dirname($this->templateFile);
     $smarty->enableSecurity($secpol);
     if ($this->changeDelimiters) {
         $smarty->left_delimiter = '{{';
         $smarty->right_delimiter = '}}';
     }
     foreach ($this->data as $key => $value) {
         $smarty->assign($key, $value);
     }
     $smarty->assign('results', $entries);
     $smarty->assign('facets', array_map(function ($facet) {
         return array('name' => $facet->getName(), 'label' => $facet->getLabel(), 'options' => $facet->getOptions());
     }, $entries->getFacets()));
     $smarty->assign('count', count($entries));
     $smarty->assign('offset', $entries->getOffset());
     $smarty->assign('offsetplusone', $entries->getOffset() + 1);
     $smarty->assign('offsetplusmaxRecords', $entries->getOffset() + $entries->getMaxRecords());
     $smarty->assign('maxRecords', $entries->getMaxRecords());
     return $smarty->fetch($this->templateFile);
 }
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $config = $container->get('Configuration');
     $config = $config['smarty'];
     /** @var $pathResolver \Zend\View\Resolver\TemplatePathStack */
     $pathResolver = clone $container->get('ViewTemplatePathStack');
     $pathResolver->setDefaultSuffix($config['suffix']);
     /** @var $resolver \Zend\View\Resolver\AggregateResolver */
     $resolver = $container->get('ViewResolver');
     $resolver->attach($pathResolver);
     $engine = new \Smarty();
     $engine->setCompileDir($config['compile_dir']);
     $engine->setEscapeHtml($config['escape_html']);
     $engine->setTemplateDir($pathResolver->getPaths()->toArray());
     $engine->setCaching($config['caching']);
     $engine->setCacheDir($config['cache_dir']);
     $engine->addPluginsDir($config['plugins_dir']);
     if (file_exists($config['config_file'])) {
         $engine->configLoad($config['config_file']);
     }
     $renderer = new Renderer();
     $renderer->setEngine($engine);
     $renderer->setSuffix($config['suffix']);
     $renderer->setResolver($resolver);
     return $renderer;
 }
Beispiel #26
0
 /**
  * executes & displays the template results
  *
  * 是否压缩传输默认是开启的,最终还是取决于浏览器和服务器
  *
  * @param $template string
  *            模板文件名
  * @param $return bool
  *            是否返回到php变量
  */
 public function render($tplvar = array(), $template = null)
 {
     header('content-type:text/html;charset=utf-8');
     if ($template == null) {
         $template = FL_PAGE_MOD . '/' . FL_PAGE_ACT;
     }
     $template .= '.html';
     $smarty = new \Smarty();
     $smarty->allow_php_templates = true;
     $smarty->left_delimiter = '{';
     $smarty->right_delimiter = '}';
     // $this->addPluginsDir ( __FASTLIB__ . FastLoad::getplatform ( true ) .
     // '/smarty_plug' ); // 加入PLUG目录
     $smarty->setTemplateDir(FL_PAGE_DIR . '/templates');
     $smarty->setCompileDir(FL_TMP . '/templates_c/' . FL_PAGE_DIR . '/compile');
     $smarty->assign($tplvar);
     // $this->registerFilter ( 'pre', create_function ( '$tplString',
     // 'return strtr($tplString,array(\'<!--{\'=>\'{\',\'}-->\'=>\'}\'));' )
     // );
     // $this->registerFilter ( 'pre', create_function ( '$tplString',
     // 'return
     // preg_replace_callback("/\{{$delimiter}[^\{$delimiter}]+{$delimiter}\}/",
     // array(fasttpl,gettextCompiler), $tplString);' ) );
     if (FL_DEBUG) {
         $smarty->compile_check = true;
         $smarty->caching = false;
     } else {
         $smarty->compile_check = false;
         $smarty->caching = false;
         $smarty->merge_compiled_includes = true;
     }
     $smarty->display($template);
 }
Beispiel #27
0
 /**
  * The constructor
  *
  * It instances the Smarty class
  * and sets the template location
  */
 public function __construct()
 {
     $this->setTemplateName(TEMPLATE);
     //The default Template Name
     $this->smarty = new Smarty();
     $this->smarty->setTemplateDir(TPLDIR . '/' . $this->templateName);
     $this->smarty->setCompileDir(IFCDIR . '/cache');
     defined('T_URL') || define('T_URL', MAINURL . '/tpl/' . $this->templateName);
     defined('T_CSSURL') || define('T_CSSURL', MAINURL . '/tpl/' . $this->templateName . '/res/css');
     defined('T_JSURL') || define('T_JSURL', MAINURL . '/tpl/' . $this->templateName . '/res/js');
     defined('T_IMGURL') || define('T_IMGURL', MAINURL . '/tpl/' . $this->templateName . '/res/images');
     defined('T_FONTURL') || define('T_FONTURL', MAINURL . '/tpl/' . $this->templateName . '/res/fonts');
     defined('T_CSSDIR') || define('T_CSSDIR', MAINDIR . '/tpl/' . $this->templateName . '/res/css');
     defined('T_JSDIR') || define('T_JSDIR', MAINDIR . '/tpl/' . $this->templateName . '/res/js');
     defined('T_IMGDIR') || define('T_IMGDIR', MAINDIR . '/tpl/' . $this->templateName . '/res/images');
     defined('T_FONTDIR') || define('T_FONTDIR', MAINDIR . '/tpl/' . $this->templateName . '/res/fonts');
 }
Beispiel #28
0
 /**
  * Set the path to the compiled templates
  *
  * @param string $path The directory to set as the path.
  * @return Oray_View_Smarty
  */
 public function setCompilePath($path)
 {
     if (is_readable($path)) {
         $this->_smarty->setCompileDir($path);
         return $this;
     }
     throw new Exception('Invalid path provided');
 }
Beispiel #29
0
 public function action_default()
 {
     if (\count($this->arguments) < 2) {
         \Core::show_404();
     }
     $uri_arr = $this->arguments;
     $app = \array_shift($uri_arr) . DS . \array_shift($uri_arr);
     if (!$uri_arr) {
         $uri_arr = array('index');
     }
     # 检查是否已开启
     if (!is_file(\DIR_APPS . $app . \DS . '.installed')) {
         $this->show_error('指定的APP还没有安装,请先安装');
     }
     # 配置文件
     $config_file = \DIR_APPS . $app . \DS . 'config.ini';
     # 读取配置文件
     if (\is_file($config_file)) {
         $app_config = @\parse_ini_file($config_file, \INI_SCANNER_NORMAL, true);
         if (!$app_config) {
             $app_config = array();
         }
     }
     # 当前控制器
     $controller = \DIR_APPS . $app . \DS . '[admin]' . \DS . \implode(\DS, $uri_arr) . '.html';
     if (!\is_file($controller)) {
         $this->show_error('指定的APP控制器不存在');
     }
     # 载入APP类库
     $libraries = \Core::config('core.libraries.app');
     if ($libraries) {
         # 逆向排序
         \rsort($libraries);
         foreach ($libraries as $library_name) {
             if (!$library_name) {
                 continue;
             }
             \Core::import_library($library_name);
         }
     }
     # Smarty缓存目录
     $big_dir = \DIR_CACHE . 'apps' . \DS . $app . \DS . 'smarty' . \DS . 'admin' . \DS;
     $smarty = new \Smarty();
     # 设置缓存目录
     $smarty->setCacheDir($big_dir . 'cache' . \DS);
     # 设置模板编译目录
     $smarty->setCompileDir($big_dir . 'templates_c' . \DS);
     # 设置模板目录
     $smarty->setTemplateDir(\DIR_APPS . $app . \DS . '[admin]' . \DS . 'tpl' . \DS);
     foreach (\Core::$include_puth as $path) {
         if (\is_dir($path . 'smarty_plugins')) {
             # 增加Smarty插件目录
             $smarty->addPluginsDir($path . 'smarty_plugins');
         }
     }
     # 输出
     $smarty->display($controller);
 }
Beispiel #30
0
 /**
  * Loads a Smarty instance if it is not already loaded.
  */
 private function loadSmarty()
 {
     if (is_null($this->smartyInstance)) {
         $this->smartyInstance = new Smarty();
         // Then prepare all variables
         $this->smartyInstance->setCompileDir(Core::$tempDir . DS . 'Smarty' . DS . 'Compile');
         $this->smartyInstance->setCacheDir(Core::$tempDir . DS . 'Smarty');
     }
 }