本文整理汇总了PHP中Smarty::setCacheDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty::setCacheDir方法的具体用法?PHP Smarty::setCacheDir怎么用?PHP Smarty::setCacheDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smarty
的用法示例。
在下文中一共展示了Smarty::setCacheDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @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');
}
示例2: initializeView
/**
* 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;
}
示例3: __construct
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/');
}
示例4: enableSmarty
/**
* 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');
}
示例5: getSmarty
/**
* Возращает экземпляр \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;
}
示例6: __construct
/**
* 构造方法
*
* @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');
}
示例7: __construct
/**
* Constructor
*
* @access public
*/
public function __construct()
{
$this->smarty = new \Smarty();
$this->smarty->compile_dir = TMP_PATH . '/templates_c/';
$this->smarty->setCacheDir(TMP_PATH . '/templates_t/');
$this->smarty->registerPlugin('block', 't', 'smarty_block_translation');
$this->smarty->registerPlugin('modifier', 'date_format', 'smarty_modifier_datetime_format');
$this->smarty->registerPlugin('modifier', 'datetime_format', 'smarty_modifier_datetime_format');
$this->smarty->registerPlugin('function', 'snippet', 'smarty_function_snippet');
$this->smarty->registerPlugin('modifier', 'markdown', 'smarty_modifier_markdown');
$this->smarty->debugging = Config::$debug;
$this->smarty->error_reporting = Config::$error_reporting;
}
示例8: initializeSmarty
/**
* 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'));
}
示例9: __construct
/**
* 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;
}
示例10: prepareSmartyObject
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);
}
}
示例11: create
/**
* 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;
}
}
示例12: Display
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.";
}
}
}
示例13: __invoke
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;
}
示例14: create
/**
* 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;
}
}
示例15: initTemplate
/**
* 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;
}