本文整理汇总了PHP中Smarty::getPluginsDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty::getPluginsDir方法的具体用法?PHP Smarty::getPluginsDir怎么用?PHP Smarty::getPluginsDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smarty
的用法示例。
在下文中一共展示了Smarty::getPluginsDir方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initSmarty
/**
* Initialise the template system
*/
private function initSmarty()
{
$this->smarty = new \Smarty();
$this->smarty->setTemplateDir(APP_DIR . 'templates');
$this->smarty->setCompileDir(APP_DIR . 'templates/compiled');
$pluginDirectories = $this->smarty->getPluginsDir();
$pluginDirectories[] = SYSTEM_DIR . 'Smarty';
$this->smarty->setPluginsDir($pluginDirectories);
}
示例2: Init
/**
* Инициализация модуля
*
*/
public function Init($bLocal = false)
{
$this->Hook_Run('viewer_init_start', compact('bLocal'));
/**
* Load template config
*/
if (!$bLocal) {
if (file_exists($sFile = Config::Get('path.smarty.template') . '/settings/config/config.php')) {
Config::LoadFromFile($sFile, false);
}
}
/**
* Заголовок HTML страницы
*/
$this->sHtmlTitle = Config::Get('view.name');
/**
* SEO ключевые слова страницы
*/
$this->sHtmlKeywords = Config::Get('view.keywords');
/**
* SEO описание страницы
*/
$this->sHtmlDescription = Config::Get('view.description');
/**
* Создаём объект Smarty и устанавливаем необходиму параметры
*/
$this->oSmarty = new lsSmarty();
$this->oSmarty->error_reporting = E_ALL ^ E_NOTICE;
// подавляем NOTICE ошибки - в этом вся прелесть смарти )
$this->oSmarty->setTemplateDir(array_merge((array) Config::Get('path.smarty.template'), array(Config::Get('path.root.server') . '/plugins/')));
/**
* Для каждого скина устанавливаем свою директорию компиляции шаблонов
*/
$sCompilePath = Config::Get('path.smarty.compiled') . '/' . Config::Get('view.skin');
if (!is_dir($sCompilePath)) {
@mkdir($sCompilePath);
}
$this->oSmarty->setCompileDir($sCompilePath);
$this->oSmarty->setCacheDir(Config::Get('path.smarty.cache'));
$this->oSmarty->setPluginsDir(array_merge(array(Config::Get('path.smarty.plug'), 'plugins'), $this->oSmarty->getPluginsDir()));
/**
* Получаем настройки блоков из конфигов
*/
$this->InitBlockParams();
/**
* Добавляем блоки по предзагруженным правилам из конфигов
*/
$this->BuildBlocks();
/**
* Получаем настройки JS, CSS файлов
*/
$this->InitFileParams();
$this->sCacheDir = Config::Get('path.smarty.cache');
}
示例3: loadPlugin
/**
* Takes unknown classes and loads plugin files for them
* class name format: Smarty_PluginType_PluginName
* plugin filename format: plugintype.pluginname.php
*
* @param \Smarty $smarty
* @param string $plugin_name class plugin name to load
* @param bool $check check if already loaded
*
* @return bool|string
* @throws \SmartyException
*/
public static function loadPlugin(Smarty $smarty, $plugin_name, $check)
{
// if function or class exists, exit silently (already loaded)
if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false))) {
return true;
}
// Plugin name is expected to be: Smarty_[Type]_[Name]
$_name_parts = explode('_', $plugin_name, 3);
// class name must have three parts to be valid plugin
// count($_name_parts) < 3 === !isset($_name_parts[2])
if (!isset($_name_parts[2]) || strtolower($_name_parts[0]) !== 'smarty') {
throw new SmartyException("plugin {$plugin_name} is not a valid name format");
}
// if type is "internal", get plugin from sysplugins
if (strtolower($_name_parts[1]) == 'internal') {
$file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php';
if (isset($smarty->_is_file_cache[$file]) ? $smarty->_is_file_cache[$file] : ($smarty->_is_file_cache[$file] = is_file($file))) {
require_once $file;
return $file;
} else {
return false;
}
}
// plugin filename is expected to be: [type].[name].php
$_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php";
// loop through plugin dirs and find the plugin
foreach ($smarty->getPluginsDir() as $_plugin_dir) {
$names = array($_plugin_dir . $_plugin_filename, $_plugin_dir . strtolower($_plugin_filename));
foreach ($names as $file) {
if (isset($smarty->_is_file_cache[$file]) ? $smarty->_is_file_cache[$file] : ($smarty->_is_file_cache[$file] = is_file($file))) {
require_once $file;
return $file;
}
if ($smarty->use_include_path && !preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $_plugin_dir)) {
// try PHP include_path
$file = Smarty_Internal_Get_Include_Path::getIncludePath($file);
if ($file !== false) {
require_once $file;
return $file;
}
}
}
}
// no plugin loaded
return false;
}
示例4: testInstall
/**
* diagnose Smarty setup
*
* If $errors is secified, the diagnostic report will be appended to the array, rather than being output.
*
* @param Smarty $smarty Smarty instance to test
* @param array $errors array to push results into rather than outputting them
* @return bool status, true if everything is fine, false else
*/
public static function testInstall(Smarty $smarty, &$errors = null)
{
$status = true;
if ($errors === null) {
echo "<PRE>\n";
echo "Smarty Installation test...\n";
echo "Testing template directory...\n";
}
// test if all registered template_dir are accessible
foreach ($smarty->getTemplateDir() as $template_dir) {
if (!is_dir($template_dir)) {
$status = false;
$message = "FAILED: {$template_dir} is not a directory";
if ($errors === null) {
echo $message . ".\n";
} else {
$errors['template_dir'] = $message;
}
} elseif (!is_readable($template_dir)) {
$status = false;
$message = "FAILED: {$template_dir} is not readable";
if ($errors === null) {
echo $message . ".\n";
} else {
$errors['template_dir'] = $message;
}
} else {
if ($errors === null) {
echo "{$template_dir} is OK.\n";
}
}
}
if ($errors === null) {
echo "Testing compile directory...\n";
}
// test if registered compile_dir is accessible
$_compile_dir = $smarty->getCompileDir();
if (!is_dir($_compile_dir)) {
$status = false;
$message = "FAILED: {$_compile_dir} is not a directory";
if ($errors === null) {
echo $message . ".\n";
} else {
$errors['compile_dir'] = $message;
}
} elseif (!is_readable($_compile_dir)) {
$status = false;
$message = "FAILED: {$_compile_dir} is not readable";
if ($errors === null) {
echo $message . ".\n";
} else {
$errors['compile_dir'] = $message;
}
} elseif (!is_writable($_compile_dir)) {
$status = false;
$message = "FAILED: {$_compile_dir} is not writable";
if ($errors === null) {
echo $message . ".\n";
} else {
$errors['compile_dir'] = $message;
}
} else {
if ($errors === null) {
echo "{$_compile_dir} is OK.\n";
}
}
if ($errors === null) {
echo "Testing plugins directory...\n";
}
// test if all registered plugins_dir are accessible
// and if core plugins directory is still registered
$_core_plugins_dir = realpath(dirname(__FILE__) . '/../plugins');
$_core_plugins_available = false;
foreach ($smarty->getPluginsDir() as $plugin_dir) {
if (!is_dir($plugin_dir)) {
$status = false;
$message = "FAILED: {$plugin_dir} is not a directory";
if ($errors === null) {
echo $message . ".\n";
} else {
$errors['plugins_dir'] = $message;
}
} elseif (!is_readable($plugin_dir)) {
$status = false;
$message = "FAILED: {$plugin_dir} is not readable";
if ($errors === null) {
echo $message . ".\n";
} else {
$errors['plugins_dir'] = $message;
}
} elseif ($_core_plugins_dir && $_core_plugins_dir == realpath($plugin_dir)) {
//.........这里部分代码省略.........
示例5: loadPlugin
/**
* Takes unknown classes and loads plugin files for them
* class name format: Smarty_PluginType_PluginName
* plugin filename format: plugintype.pluginname.php
*
* @param \Smarty $smarty
* @param string $plugin_name class plugin name to load
* @param bool $check check if already loaded
*
* @return bool|string
* @throws \SmartyException
*/
public static function loadPlugin(Smarty $smarty, $plugin_name, $check)
{
// if function or class exists, exit silently (already loaded)
if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false))) {
return true;
}
if (!preg_match('#^smarty_((internal)|([^_]+))_(.+)$#i', $plugin_name, $match)) {
throw new SmartyException("plugin {$plugin_name} is not a valid name format");
}
if (!empty($match[2])) {
$file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php';
if (isset($smarty->_is_file_cache[$file])) {
if ($smarty->_is_file_cache[$file] !== false) {
return $smarty->_is_file_cache[$file];
} else {
return false;
}
} else {
if (is_file($file)) {
$smarty->_is_file_cache[$file] = $file;
require_once $file;
return $file;
} else {
$smarty->_is_file_cache[$file] = false;
return false;
}
}
}
// plugin filename is expected to be: [type].[name].php
$_plugin_filename = "{$match[1]}.{$match[4]}.php";
$_lower_filename = strtolower($_plugin_filename);
$_different = $_lower_filename != $_plugin_filename;
// loop through plugin dirs and find the plugin
$names = array();
foreach ($smarty->getPluginsDir() as $_plugin_dir) {
$names[] = $_plugin_dir . $_plugin_filename;
if ($_different) {
$names[] = $_plugin_dir . $_lower_filename;
}
}
foreach ($names as $path) {
$file = $smarty->use_include_path ? $smarty->_realpath($path, false) : $path;
if (isset($smarty->_is_file_cache[$file])) {
if ($smarty->_is_file_cache[$file] !== false) {
return $smarty->_is_file_cache[$file];
}
}
if (is_file($file)) {
$smarty->_is_file_cache[$file] = $file;
require_once $file;
return $file;
}
$smarty->_is_file_cache[$file] = false;
}
if ($smarty->use_include_path) {
// try PHP include_path
$path = Smarty_Internal_Get_Include_Path::getIncludePath($names, null, $smarty);
if ($path !== false) {
$smarty->_is_file_cache[$path] = $path;
require_once $path;
return $path;
}
}
// no plugin loaded
return false;
}
示例6: getPluginsDir
/**
* @return array
*/
public function getPluginsDir()
{
return $this->smarty->getPluginsDir();
}