addTemplateDir() public method

Add template directory(s)
public addTemplateDir ( string | array $template_dir, string $key = null ) : Smarty
$template_dir string | array directory(s) of template sources
$key string of the array element to assign the template dir to
return Smarty current Smarty instance for chaining
Esempio n. 1
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);
 }
Esempio n. 2
0
 /**
  * Adds template directory for this Template object.
  * Also set compile id if not exists.
  *
  * @param string $dir
  */
 function set_template_dir($dir)
 {
     $this->smarty->addTemplateDir($dir);
     if (!isset($this->smarty->compile_id)) {
         $compile_id = "1";
         $compile_id .= ($real_dir = realpath($dir)) === false ? $dir : $real_dir;
         $this->smarty->compile_id = base_convert(crc32($compile_id), 10, 36);
     }
 }
Esempio n. 3
0
 /**
  * 取得一个和 Theme 初始化一样的 Smarty 对象,只有这样才能正确处理缓存清理工作
  */
 private function getThemeSmarty()
 {
     $themeSmarty = new \Smarty();
     //设置 smarty 工作目录
     $themeSmarty->setCompileDir(RUNTIME_PATH . '/Smarty/Mobile/Compile');
     $themeSmarty->setCacheDir(RUNTIME_PATH . '/Smarty/Mobile/Cache');
     // 获取当前插件的根地址
     $currentThemeBasePath = realpath(dirname(__FILE__) . '/../../../');
     // 增加 smarty 模板搜索路径
     $themeSmarty->addTemplateDir($currentThemeBasePath . '/mobile/Tpl/');
     return $themeSmarty;
 }
Esempio n. 4
0
 /**
  * Processes a view script and returns the output.
  *
  * @param  string|ModelInterface $nameOrModel The script/resource process, or a view model
  * @param  array|\ArrayAccess $values Values to use during rendering
  * @throws \Zend\View\Exception\DomainException
  * @return string The script output.
  */
 public function render($nameOrModel, $values = array())
 {
     $model = null;
     if ($nameOrModel instanceof ModelInterface) {
         $model = $nameOrModel;
         $nameOrModel = $model->getTemplate();
         if (empty($nameOrModel)) {
             throw new Exception\DomainException(sprintf('%s: received View Model, but template is empty', __METHOD__));
         }
         $options = $model->getOptions();
         foreach ($options as $setting => $value) {
             $method = 'set' . $setting;
             if (method_exists($this, $method)) {
                 $this->{$method}($value);
             }
             unset($method, $setting, $value);
         }
         unset($options);
         $values = (array) $model->getVariables();
     }
     // check if we can render the template
     if (!$this->canRender($nameOrModel)) {
         return null;
     }
     // handle tree rendering
     if ($model && $this->canRenderTrees() && $model->hasChildren()) {
         if (!isset($values['content'])) {
             $values['content'] = '';
         }
         foreach ($model as $child) {
             /** @var \Zend\View\Model\ViewModel $child */
             if ($this->canRender($child->getTemplate())) {
                 $file = $this->resolver->resolve($child->getTemplate(), $this);
                 $this->smarty->addTemplateDir(dirname($file));
                 $childVariables = (array) $child->getVariables();
                 $childVariables['this'] = $this;
                 $this->smarty->assign($childVariables);
                 return $this->smarty->fetch($file);
             }
             $child->setOption('has_parent', true);
             $values['content'] .= $this->view->render($child);
         }
     }
     // give the template awareness of the Renderer
     $values['this'] = $this;
     // assign the variables
     $this->smarty->assign($values);
     // resolve the template
     $file = $this->resolver->resolve($nameOrModel);
     $this->smarty->addTemplateDir(dirname($file));
     // render
     return $this->smarty->fetch($file);
 }
Esempio n. 5
0
 /**
  * Singleton instance
  * @return Smarty
  * @throws SmartyException
  */
 private function getSmarty()
 {
     if (!isset($this->smarty)) {
         $smarty = new Smarty();
         $smarty->addTemplateDir(VIEWS_DIR);
         $smarty->setCompileDir(BASE_DIR . '/cache/templates');
         $smarty->registerPlugin('modifier', 'lang', array('View', 'translate'));
         // translations
         $smarty->registerPlugin('function', 'profiler', array('Profiler', 'show'));
         // profiler
         $smarty->force_compile = true;
         $this->smarty = $smarty;
     }
     return $this->smarty;
 }
Esempio n. 6
0
 /**
  * Register the services here to make them general or register in the ModuleDefinition to make them module-specific
  */
 public function registerServices(DiInterface $di)
 {
     // Registering a dispatcher
     $di->set('dispatcher', function () {
         $dispatcher = new Dispatcher();
         $dispatcher->setDefaultNamespace("App\\Frontend\\Controllers\\");
         return $dispatcher;
     });
     //Registering a dispatcher
     /*$di->set('dispatcher', function(){
                 //Create an EventsManager
                 $eventsManager = new EventsManager();
                 //Attach a listener
                 $eventsManager->attach("dispatch", function($event, $dispatcher, $exception) {
                     //Handle controller or action doesn't exist
                     if ($event->getType() == 'beforeException') {
                         switch ($exception->getCode()) {
                             case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
                             case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
                                 $dispatcher->forward([
                                     'controller' => 'error',
                                     'action'     => 'index',
                                     'params'     => ['message' => $exception->getMessage()],
                                 ]);
                                 return false;
                         }
                     }
                 });
     
                 $dispatcher = new MvcDispatcher();
                 //$dispatcher->setDefaultNamespace('App\Controllers\\');
                 $dispatcher->setEventsManager($eventsManager);
                 return $dispatcher;
             });*/
     // Registering a smarty component
     $di->set('smarty', function () {
         $smarty = new \Smarty();
         $options = ['left_delimiter' => '<{', 'right_delimiter' => '}>', 'template_dir' => ROOT_DIR . '/app/Frontend/Views', 'compile_dir' => ROOT_DIR . '/runtime/Smarty/compile', 'cache_dir' => ROOT_DIR . '/runtime/Smarty/cache', 'error_reporting' => error_reporting() ^ E_NOTICE, 'escape_html' => true, 'force_compile' => false, 'compile_check' => true, 'caching' => false, 'debugging' => false];
         foreach ($options as $k => $v) {
             $smarty->{$k} = $v;
         }
         $config = (include ROOT_DIR . "/config/main.php");
         if (!empty($config['theme'])) {
             $smarty->addTemplateDir(ROOT_DIR . '/app/Frontend/Themes/' . $config['theme']);
         }
         return $smarty;
     });
 }
Esempio n. 7
0
    //CRAWLER
    $GLOBALS['crawl_cycle'] = Config::getConfigValueByName('crawl_cycle_length_in_minutes');
    //TEMPLATE
    $GLOBALS['template'] = Config::getConfigValueByName('template');
    //WEBSERVER
    $GLOBALS['url_to_netmon'] = Config::getConfigValueByName('url_to_netmon');
}
//load smarty template engine
require_once ROOT_DIR . '/lib/extern/smarty/Smarty.class.php';
$smarty = new Smarty();
$smarty->compile_check = true;
$smarty->debugging = false;
// base template directory
// this is used as a fallback if nothing is found in the custom template folder
// lookup ordered by param2
$smarty->addTemplateDir(ROOT_DIR . '/templates/base/html', 10);
// custom template folder - smarty will try here first ( order 0 )
$smarty->addTemplateDir(ROOT_DIR . '/templates/' . $GLOBALS['template'] . '/html', 0);
$smarty->compile_dir = ROOT_DIR . '/templates_c';
$smarty->assign('template', $GLOBALS['template']);
$smarty->assign('installed', $GLOBALS['installed']);
$smarty->assign('community_name', $GLOBALS['community_name']);
$smarty->assign('community_slogan', $GLOBALS['community_slogan']);
/**
 * Auto Login
 */
if ($GLOBALS['installed']) {
    //if the user is not logged in and the remember me cookie is set
    if (!isset($_SESSION['user_id']) and !empty($_COOKIE["remember_me"])) {
        require_once ROOT_DIR . '/lib/core/user_old.class.php';
        require_once ROOT_DIR . '/lib/core/UserRememberMeList.class.php';
Esempio n. 8
0
 /**
  * Adds another Smarty template_dir to scan for templates
  *
  * @param string $dir
  * @return Ext_View_Smarty
  */
 public function addTemplateDir($dir)
 {
     $this->_smarty->addTemplateDir($dir);
     return $this;
 }
Esempio n. 9
0
 public static function getSmarty()
 {
     $smarty = new Smarty();
     //$smarty->left_delimiter = '<!--{';
     //$smarty->right_delimiter = '}-->';
     $smarty->template_dir = "global/smarty/";
     $smarty->addTemplateDir(Import::$uber_src_path . "/global/smarty/");
     $smarty->compile_dir = Import::$uber_src_path . "/server/Smarty-3.1.8/tmp";
     return $smarty;
 }
Esempio n. 10
0
<?php

/**
 * Code for the most sites for the beginning...
 */
require_once 'config.php';
date_default_timezone_set($GLOBALS["timezone"]);
require_once 'class/role.php';
require_once 'class/user.php';
require_once 'class/plugin.php';
require_once 'class/smarty/Smarty.class.php';
$messages = array();
$allcss = array();
$template = new Smarty();
$template->addTemplateDir("plugins/");
$jsscripts = array();
$dojorequire = array();
session_start();
//SECURE SQL-INJECTION
function sqlsec($value)
{
    $search = array("\\", "", "\n", "\r", "'", '"', "");
    $replace = array("\\\\", "\\0", "\\n", "\\r", "\\'", '\\"', "\\Z");
    return str_replace($search, $replace, $value);
}
//This stops SQL Injection in POST vars
foreach ($_POST as $key => $value) {
    $_POST[$key] = sqlsec($value);
}
//This stops SQL Injection in GET vars
foreach ($_GET as $key => $value) {
Esempio n. 11
0
<?php

/**
 * Example Application
 *
 * @package Example-application
 */
$smarty = new Smarty();
$smarty->setCacheDir(sys_get_temp_dir());
$smarty->setCompileDir(sys_get_temp_dir());
$smarty->addTemplateDir(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'templates');
$smarty->setConfigDir(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'configs');
$smarty->addPluginsDir(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins');
$smarty->debugging = true;
//Note: That "debug.tpl" inside phar is not accessible))
$smarty->debug_tpl = SMARTY_DEBUG_TPL;
$smarty->caching = false;
$smarty->cache_lifetime = 1;
$smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);
$smarty->assign("FirstName", array("John", "Mary", "James", "Henry"));
$smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));
$smarty->assign("Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"), array("I", "J", "K", "L"), array("M", "N", "O", "P")));
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
$smarty->assign("option_values", array("NY", "NE", "KS", "IA", "OK", "TX"));
$smarty->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas"));
$smarty->assign("option_selected", "NE");
$smarty->display('index.tpl', time(), time());
Esempio n. 12
0
 /**
  * Set Template dir
  *
  * @access public
  * @param string $directory
  */
 public function add_template_directory($directory)
 {
     $this->smarty->addTemplateDir($directory);
 }
Esempio n. 13
0
<?php

require_once 'vendor/autoload.php';
/* PHP requires setting a timezone. This will be fine,
   since the app doesn't require a time */
date_default_timezone_set('America/New_York');
/* If sendmail is available, send emails immediately.
   If not, place in hold_email table for later release */
$on_line = false;
$email_direct = false;
$smarty = new Smarty();
$smarty->addTemplateDir(__DIR__ . '/templates');
$smarty->addPluginsDir(__DIR__ . '/plugins');
session_start();
if (isset($_SESSION['user_id'])) {
    $user_id = $_SESSION['user_id'];
    $smarty->assign('user_id', $user_id);
    $smarty->assign('HelloName', $_SESSION['HelloName']);
} else {
    $user_id = 0;
    if (!isset($login)) {
        header("Location: login.php");
    }
}
/* Set permissions.
   Viewer can see everyone's information, and suggest changes
   Editor can see info, and release suggested changes to live db
   Everyone can suggest changes to their own info -
     user_id == contact_id in people.tpl & edit_contact.tpl
*/
$rbac = new PhpRbac\Rbac();
Esempio n. 14
0
session_start();
//Objeto da classe LDAP
$ldap = new Ldap();
//Se a variável login não existir na sessão, não deixar passar do index
if (!array_key_exists('login', $_SESSION)) {
    header('Location: index.php');
    exit;
    //Se o usuário for um solicitante, ele não poderá alterar seus dados
} else {
    if ($ldap->userExists($_SESSION['login'], "ou=solicitacoes")) {
        header('Location: home.php');
    }
}
$s = new Smarty();
//Diretório de templates
$s->addTemplateDir("../view/templates");
//Diretório de templates compilados
$s->setCompileDir("../view/com_templates");
$usuario = $ldap->getUsuario($_SESSION['login']);
//Verifica se o usuário possui foto
if ($usuario->jpegPhoto) {
    //Se existir, baixar a foto para a pasta do site e associar valor verdadeiro à variável foto, usada no html da "home"
    file_put_contents("imagens/" . $usuario->uid . ".jpg", $usuario->jpegPhoto);
    //Este valor é utilizado num if. Se o usuário tiver foto, carregar a foto dele. Se não, carregar a imagem padrão
    $s->assign('foto', true);
} else {
    $s->assign('foto', false);
}
//Associa à variável usuário, um objeto recheado de valores para serem utilizados no html da home
$s->assign('usuario', $usuario);
if ($ldap->isAdmin($_SESSION['login'], "ou=usuarios")) {
Esempio n. 15
0
<?php

//------------------------------------------------------------------------
//------------------------------------------------------------------------
//php imports
//------------------------------------------------------------------------
//------------------------------------------------------------------------
require_once Import::$uber_src_path . "/server/Smarty-3.1.8/libs/Smarty.class.php";
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//init var
//------------------------------------------------------------------------
//------------------------------------------------------------------------
$obj = array();
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//init
//------------------------------------------------------------------------
//------------------------------------------------------------------------
$smarty = new Smarty();
$smarty->left_delimiter = '<!--{';
$smarty->right_delimiter = '}-->';
$smarty->template_dir = "global/smarty";
$smarty->addTemplateDir(Import::$uber_src_path . "/server/werm/smarty");
$smarty->compile_dir = Import::$uber_src_path . "/server/Smarty-3.1.8/tmp";
Esempio n. 16
0
 /**
  * Alias for setScriptPath
  *
  * @param string $path
  * @param string $prefix Unused
  * @return Oray_View_Smarty
  */
 public function addBasePath($path, $prefix = 'Zend_View')
 {
     $this->_smarty->addTemplateDir($path);
     return $this;
 }
Esempio n. 17
0
 /**
  * Add script path
  *
  * @param string $path
  */
 public function addPath($path)
 {
     $this->smarty->addTemplateDir($path);
 }
Esempio n. 18
0
 /**
  *
  * @param string $templateDir
  * @param string $compileDir
  * @return \Smarty
  */
 public function createSmarty($templateDir, $compileDir)
 {
     $smarty = new \Smarty();
     $smarty->addTemplateDir($templateDir);
     $smarty->setCompileDir($compileDir);
     return $smarty;
 }
Esempio n. 19
0
 /**
  * Returns the smarty prototype object, creating it if necessary
  *
  * @return   Smarty prototype object
  */
 public static function smarty_prototype()
 {
     // set time for benchmarking
     $time = microtime(TRUE);
     // see if we need to set up the prototype smarty object
     if (self::$_smarty_prototype === NULL) {
         // nearly everything can be done in the config file
         if (Kohana::VERSION > '3.2') {
             $config = Kohana::$config->load('smarty');
         } else {
             $config = Kohana::config('smarty');
         }
         // locate a Smarty class - first check if it is already loaded
         if (!class_exists('Smarty', false)) {
             // next check if a path is set in config/smarty.php
             if ($file = $config->smarty_class_file) {
                 require_once $file;
                 // save the location in case we have more than one Smarty version around
                 self::$_smarty_path = realpath(dirname($file)) . DIRECTORY_SEPARATOR;
             } elseif (!class_exists('Smarty')) {
                 // try and autoload it
                 // if it doesn't autoload, fall back to letting Kohana find the bundled version
                 $file = Kohana::find_file('vendor', 'smarty/libs/Smarty.class');
                 require_once $file;
                 // save the location in case we have more than one Smarty version around
                 self::$_smarty_path = realpath(dirname($file)) . DIRECTORY_SEPARATOR;
             }
         }
         // instantiate the prototype Smarty object
         $smarty = new Smarty();
         self::$_smarty_prototype = $smarty;
         // set up the prototype with options from config file
         foreach ($config->smarty_config as $key => $value) {
             $smarty->{$key} = $value;
         }
         // deal with config options that are not simple properties
         $smarty->php_handling = constant($config->php_handling);
         // add the path to the plugins for the located Smarty distro
         $smarty->addPluginsDir(self::$_smarty_path . 'plugins');
         // add views directories for all loaded modules (including Smarty3)
         $dirs = array();
         foreach (Kohana::modules() as $dir) {
             $dirs[] = "{$dir}views";
         }
         $smarty->addTemplateDir($dirs);
         if ($config->check_dirs) {
             // check we can write to the compiled templates directory
             if (!is_writeable($smarty->compile_dir)) {
                 self::create_dir($smarty->compile_dir, 'Smarty compiled template');
             }
             // if smarty caching is enabled, check we can write to the cache directory
             if ($smarty->caching && !is_writeable($smarty->cache_dir)) {
                 self::create_dir($smarty->cache_dir, 'Smarty cache');
             }
         }
         // now assign useful globals
         $smarty->assignGlobal('base_url', URL::base());
         $smarty->assignGlobal('helper', new Smarty_Helper());
         $bound = View::$_global_bound_variables;
         // register any globals
         foreach (View::$_global_data as $key => $value) {
             if (isset($bound[$key])) {
                 Smarty::$global_tpl_vars[$key] = new Smarty_variable($value);
                 Smarty::$global_tpl_vars[$key]->value =& $value;
             } else {
                 $smarty->assignGlobal($key, $value);
             }
         }
         // and register useful plugins
         // add to registered template engines
         View::$_smarty_is_loaded = TRUE;
         // set timing for benchmark
         self::$_init_time = microtime(TRUE) - $time;
     }
     return self::$_smarty_prototype;
 }
Esempio n. 20
0
File: index.php Progetto: oswida/lms
            if (!empty($plugins)) {
                foreach ($plugins as $plugin_name) {
                    if (is_readable($plugin_name)) {
                        include $plugin_name;
                    }
                }
            }
        }
    }
}
$SMARTY->assignByRef('LANGDEFS', $LANGDEFS);
$SMARTY->assignByRef('_ui_language', $LMS->ui_lang);
$SMARTY->assignByRef('_language', $LMS->lang);
$SMARTY->setTemplateDir(null);
$style = ConfigHelper::getConfig('userpanel.style', 'default');
$SMARTY->addTemplateDir(array(USERPANEL_DIR . '/style/' . $style . '/templates', USERPANEL_DIR . '/templates'));
$SMARTY->setCompileDir(SMARTY_COMPILE_DIR);
$SMARTY->debugging = ConfigHelper::checkConfig('phpui.smarty_debug');
require_once USERPANEL_LIB_DIR . '/smarty_addons.php';
$layout['upv'] = $USERPANEL->_version . ' (' . $USERPANEL->_revision . '/' . $SESSION->_revision . ')';
$layout['lmsdbv'] = $DB->GetVersion();
$layout['lmsv'] = $LMS->_version;
$layout['smarty_version'] = SMARTY_VERSION;
$layout['hostname'] = hostname();
$layout['dberrors'] =& $DB->GetErrors();
$SMARTY->assignByRef('modules', $USERPANEL->MODULES);
$SMARTY->assignByRef('layout', $layout);
header('X-Powered-By: LMS/' . $layout['lmsv']);
if ($SESSION->islogged) {
    $module = isset($_GET['m']) ? $_GET['m'] : '';
    if (isset($USERPANEL->MODULES[$module])) {
Esempio n. 21
0
File: index.php Progetto: askipl/lms
					if (!empty($plugins))
						foreach ($plugins as $plugin_name)
							if (is_readable($plugin_name))
								include($plugin_name);
				}
		}
	}
}

$SMARTY->assignByRef('LANGDEFS', $LANGDEFS);
$SMARTY->assignByRef('_ui_language', $LMS->ui_lang);
$SMARTY->assignByRef('_language', $LMS->lang);
$SMARTY->setTemplateDir(null);
$style = ConfigHelper::getConfig('userpanel.style', 'default');
$SMARTY->addTemplateDir(array(
	USERPANEL_DIR . DIRECTORY_SEPARATOR . 'style' . DIRECTORY_SEPARATOR .  $style . DIRECTORY_SEPARATOR . 'templates',
	USERPANEL_DIR . DIRECTORY_SEPARATOR . 'templates',
));
$SMARTY->setCompileDir(SMARTY_COMPILE_DIR);
$SMARTY->debugging = ConfigHelper::checkConfig('phpui.smarty_debug');
require_once(USERPANEL_LIB_DIR . DIRECTORY_SEPARATOR . 'smarty_addons.php');

$layout['upv'] = $USERPANEL->_version.' ('.$USERPANEL->_revision.'/'.$SESSION->_revision.')';
$layout['lmsdbv'] = $DB->GetVersion();
$layout['lmsv'] = $LMS->_version;
$layout['smarty_version'] = SMARTY_VERSION;
$layout['hostname'] = hostname();
$layout['dberrors'] =& $DB->GetErrors();

$SMARTY->assignByRef('modules', $USERPANEL->MODULES);
$SMARTY->assignByRef('layout', $layout);
Esempio n. 22
0
        $layout['v_errors_connect'] = TRUE;
        $CONFIG['voip']['enabled'] = 0;
    }
} else {
    $voip = NULL;
}
if (get_conf('sms.service') == 'serwersms') {
    require_once LIB_DIR . '/SerwerSMS_api.php';
}
if (get_conf('jambox.enabled', 0)) {
    require_once LIB_DIR . '/LMS.tv.class.php';
    $LMSTV = new LMSTV($DB, $AUTH, $CONFIG);
}
// Set some template and layout variables
$SMARTY->setTemplateDir(NULL);
$SMARTY->addTemplateDir(array(SMARTY_TEMPLATES_DIR . '/custom', SMARTY_TEMPLATES_DIR));
$SMARTY->compile_dir = SMARTY_COMPILE_DIR;
$SMARTY->debugging = isset($CONFIG['phpui']['smarty_debug']) ? chkconfig($CONFIG['phpui']['smarty_debug']) : FALSE;
$SMARTY->use_sub_dirs = TRUE;
//$SMARTY->error_reporting = false;
$SMARTY->error_unassigned = false;
$my_security_policy = new Smarty_Security($SMARTY);
$my_security_policy->allow_php_tag = true;
$my_security_policy->php_functions = array();
$my_security_policy->php_handling = Smarty::PHP_PASSTHRU;
$my_security_policy->php_modifier = array();
$my_security_policy->modifiers = array();
$SMARTY->assignByRef('layout', $layout);
$SMARTY->assignByRef('LANGDEFS', $LANGDEFS);
$SMARTY->assignByRef('_ui_language', $LMS->ui_lang);
$SMARTY->assignByRef('_language', $LMS->lang);
Esempio n. 23
0
 /**
  * Выполняет загрузку необходимых (возможно даже системных :)) переменных в шаблонизатор
  */
 public function VarAssign()
 {
     // * Загружаем весь $_REQUEST, предварительно обработав его функцией F::HtmlSpecialChars()
     $aRequest = $_REQUEST;
     F::HtmlSpecialChars($aRequest);
     $this->Assign('_aRequest', $aRequest);
     // * Параметры стандартной сессии
     // TODO: Убрать! Не должно этого быть на страницах сайта
     $this->Assign('_sPhpSessionName', session_name());
     $this->Assign('_sPhpSessionId', session_id());
     // * Загружаем роутинг с учетом правил rewrite
     $aRouter = array();
     $aPages = Config::Get('router.page');
     if (!$aPages || !is_array($aPages)) {
         throw new Exception('Router rules is underfined.');
     }
     foreach ($aPages as $sPage => $aAction) {
         $aRouter[$sPage] = R::GetPath($sPage);
     }
     $this->Assign('aRouter', $aRouter);
     // * Загружаем виджеты
     $this->Assign('aWidgets', $this->GetWidgets());
     // * Загружаем HTML заголовки
     $this->Assign('sHtmlTitle', $this->GetHtmlTitle());
     $this->Assign('sHtmlKeywords', $this->GetHtmlKeywords());
     $this->Assign('sHtmlDescription', $this->GetHtmlDescription());
     $this->Assign('aHtmlHeadFiles', $this->aHtmlHeadFiles);
     $this->Assign('aHtmlRssAlternate', $this->aHtmlRssAlternate);
     $this->Assign('sHtmlCanonical', $this->sHtmlCanonical);
     $this->Assign('aHtmlHeadTags', $this->aHtmlHeadTags);
     $this->Assign('aJsAssets', E::ModuleViewerAsset()->GetPreparedAssetLinks());
     // * Загружаем список активных плагинов
     $aPlugins = E::GetActivePlugins();
     $this->Assign('aPluginActive', array_fill_keys(array_keys($aPlugins), true));
     // * Загружаем пути до шаблонов плагинов
     $aPluginsTemplateUrl = array();
     $aPluginsTemplateDir = array();
     /** @var Plugin $oPlugin */
     foreach ($aPlugins as $sPlugin => $oPlugin) {
         $sDir = Plugin::GetTemplateDir(get_class($oPlugin));
         if ($sDir) {
             $this->oSmarty->addTemplateDir(array($sDir . 'tpls/', $sDir), $oPlugin->GetName(false));
             $aPluginsTemplateDir[$sPlugin] = $sDir;
             $aPluginsTemplateUrl[$sPlugin] = Plugin::GetTemplateUrl(get_class($oPlugin));
         }
     }
     if (E::ActivePlugin('ls')) {
         // LS-compatible //
         $this->Assign('aTemplateWebPathPlugin', $aPluginsTemplateUrl);
         $this->Assign('aTemplatePathPlugin', $aPluginsTemplateDir);
     }
     $sSkinTheme = $this->GetConfigTheme();
     if (!$sSkinTheme) {
         $sSkinTheme = 'default';
     }
     // Проверка существования темы
     if ($this->CheckTheme($sSkinTheme)) {
         $this->oSmarty->compile_id = $sSkinTheme;
     }
     $this->Assign('sSkinTheme', $sSkinTheme);
 }
Esempio n. 24
0
 /**
  * Add template directory(s)
  *
  * @param  string|array    $template_dir directory(s) of template sources
  * @param  string          $key          of the array element to assign the template dir to
  */
 public function addTemplateDir($template_dir, $key = null)
 {
     $this->smarty->addTemplateDir($template_dir, $key);
 }