本文整理汇总了PHP中Smarty::setTemplateDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty::setTemplateDir方法的具体用法?PHP Smarty::setTemplateDir怎么用?PHP Smarty::setTemplateDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smarty
的用法示例。
在下文中一共展示了Smarty::setTemplateDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderEntries
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);
}
示例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: initTemplateEngine
/**
* Initialise Twig
*
* @return void
*/
protected function initTemplateEngine()
{
$this->loader = new \Smarty();
$this->loader->muteExpectedErrors();
$this->loader->setTemplateDir($this->getTemplateDir());
$this->loader->addPluginsDir(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'SmartyPlugins');
$this->initSmartyCache();
Logger::debug("Smarty Cache: " . $this->loader->getCacheDir());
}
示例5: 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');
}
示例6: 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;
}
示例7: get_template
/**
* @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);
}
示例8: fetch
public function fetch($template, $dataHolder = null, $templateDir = null)
{
if ($templateDir != null) {
$this->smarty->setTemplateDir($templateDir);
}
//\org\equinox\utils\debug\DebugBarFactory::add(debug_backtrace(), 'backtrace');
$smartyData = $this->smarty->createData($this->smarty);
if ($dataHolder != null) {
foreach ($dataHolder as $key => $value) {
$smartyData->assign($key, $value);
}
}
return $this->smarty->fetch($template, $dataHolder);
}
示例9: get
public function get($file, $assigned_variables)
{
// First set all the variables
$this->assigned_variables = $assigned_variables;
// Load Smarty
$this->loadSmarty();
// Set the directory
$this->smartyInstance->setTemplateDir($this->directory);
// Then assign all variables
foreach ($this->assigned_variables as $key => $value) {
$this->smartyInstance->assign($key, $value);
}
// And finally, load the template
return $this->smartyInstance->fetch($file);
}
示例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: __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;
}
示例12: _initalizeSmarty
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;
}
示例13: 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;
}
}
示例14: rx_set_smarty_paths
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);
}
}
示例15: run
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;
}
}