addPluginsDir() public method

Adds directory of plugin files
public addPluginsDir ( $plugins_dir ) : Smarty
return Smarty current Smarty instance for chaining
示例#1
0
 /**
  * @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
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;
 }
示例#3
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);
    }
}
示例#4
0
 /**
  * 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());
 }
示例#5
0
 /**
  * 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());
 }
示例#6
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;
 }
示例#7
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);
 }
 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;
 }
示例#9
0
文件: viewer.php 项目: i6ma/snp
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();
    }
}
示例#10
0
 /**
  * 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;
 }
示例#11
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);
 }
示例#12
0
 /**
  * Initialize smarty
  */
 protected function InitializeSmarty()
 {
     require_once GITPHP_SMARTYDIR . 'Smarty.class.php';
     $this->tpl = new Smarty();
     $this->tpl->error_reporting = E_ALL & ~E_NOTICE;
     $this->tpl->merge_compiled_includes = true;
     $this->tpl->addPluginsDir(GITPHP_INCLUDEDIR . 'smartyplugins');
     if ($this->config->GetValue('cache')) {
         $cacheDir = GITPHP_CACHEDIR . 'templates';
         if (file_exists($cacheDir)) {
             if (!is_dir($cacheDir)) {
                 throw new Exception($cacheDir . ' exists but is not a directory');
             } else {
                 if (!is_writable($cacheDir)) {
                     throw new Exception($cacheDir . ' is not writable');
                 }
             }
         } else {
             if (!mkdir($cacheDir, 0777)) {
                 throw new Exception($cacheDir . ' could not be created');
             }
             chmod($cacheDir, 0777);
         }
         $this->tpl->setCacheDir($cacheDir);
         $this->tpl->caching = Smarty::CACHING_LIFETIME_SAVED;
         if ($this->config->HasKey('cachelifetime')) {
             $this->tpl->cache_lifetime = $this->config->GetValue('cachelifetime');
         }
         $servers = $this->config->GetValue('memcache');
         if (isset($servers) && is_array($servers) && count($servers) > 0) {
             $this->tpl->registerCacheResource('memcache', new GitPHP_CacheResource_Memcache($servers));
             $this->tpl->caching_type = 'memcache';
         }
     }
 }
示例#13
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);
 }
示例#14
0
 /**
  * Constructor
  *
  * @param string $tmplPath
  * @param array $extraParams
  * @return void
  */
 public function __construct($tmplPath = null, $extraParams = array())
 {
     $this->_smarty = new Smarty();
     $this->_config = Zend_Registry::get('config');
     $this->_router = Zend_Registry::get('router');
     $templates_dir = $this->_config->serviceDir . "core";
     $this->_smarty->addPluginsDir($templates_dir . '/modules/calendar/site/smarty');
     $this->setScriptPath($templates_dir);
     $this->_smarty->template_dir = $templates_dir;
     $this->_smarty->compile_dir = $this->_config->serviceDir . $this->_config->view->compile_dir;
     /*	 dostep do _router z poziomu szablonow	*/
     $this->_smarty->assign('router', $this->_router);
     $this->_smarty->assign('config', $this->_config);
     foreach ($extraParams as $key => $value) {
         $this->_smarty->{$key} = $value;
     }
     //$this->_smarty->registerPlugin("function","import_css", "import_css");
 }
示例#15
0
 /**
  * smarty
  * @access private
  * @return void
  */
 private function setConfigure()
 {
     $this->smarty->left_delimiter = Config::get('smarty::left_delimiter');
     $this->smarty->right_delimiter = Config::get('smarty::right_delimiter');
     $this->smarty->setTemplateDir(Config::get('smarty::template_path'));
     $this->smarty->setCompileDir(Config::get('smarty::compile_path'));
     $this->smarty->setCacheDir(Config::get('smarty::cache_path'));
     //
     foreach (Config::get('smarty::plugins_paths') as $plugins) {
         $this->smarty->addPluginsDir($plugins);
     }
     $this->smarty->debugging = Config::get('smarty::debugging');
     $this->smarty->caching = Config::get('smarty::caching');
     $this->smarty->cache_lifetime = Config::get('smarty::cache_lifetime');
     $this->smarty->compile_check = Config::get('smarty::compile_check');
     $this->smarty->force_compile = true;
     $this->smarty->error_reporting = E_ALL & ~E_NOTICE;
 }
示例#16
0
 /**
  * 初始化环境变量
  * @param array $plugins
  * @return Leb_View_Smarty
  */
 protected function execute($template)
 {
     //init env
     $this->_initConfig();
     if (empty(self::$_smarty)) {
         require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Smarty/Smarty.class.php';
         self::$_smarty = new Smarty();
         // self::$_smarty->error_reporting = error_reporting() & ~E_NOTICE & ~E_WARNING;
         self::$_smarty->error_reporting = error_reporting() & ~E_NOTICE;
         //
         //compile dir must be set
         self::$_smarty->debugging = _DEBUG_;
         // delimiter
         $leftDelimiter = $this->getEnv('leftDelimiter');
         if (!isset($leftDelimiter)) {
             $leftDelimiter = "{{";
         }
         $rightDelimiter = $this->getEnv('rightDelimiter');
         if (!isset($rightDelimiter)) {
             $rightDelimiter = "}}";
         }
         self::$_smarty->left_delimiter = $leftDelimiter;
         // 设置左边符号
         self::$_smarty->right_delimiter = $rightDelimiter;
         // 设置友边符号
     }
     // compiled dir
     if ($compileDir = $this->getEnv('compileDir')) {
         self::$_smarty->compile_dir = $compileDir;
     } else {
         self::$_smarty->compile_dir = _APP_ . $this->getBase() . 'compiled';
     }
     //临时创建目录,正常使用时,可去掉
     if (!is_dir(self::$_smarty->compile_dir)) {
         mkdir(self::$_smarty->compile_dir);
     }
     // config dir
     if (!($configDirName = $this->getEnv('configDir'))) {
         $configDirName = 'config';
     }
     self::$_smarty->config_dir = _APP_ . $this->getBase() . $configDirName . '/';
     // print_r( self::$_smarty->config_dir) . "\n";
     // self::$_smarty->config_dir = null;
     // plugins dir
     if (!($pluginDirName = $this->getEnv('pluginDir'))) {
         $pluginDirName = 'plugins';
     }
     $pluginsDir = _APP_ . $this->getBase() . $pluginDirName . '/';
     $pluginDirApp = _APP_ . '_template/' . $pluginDirName . '/';
     // self::$_smarty->plugins_dir = array("plugins", $pluginDirApp, $pluginsDir);
     self::$_smarty->addPluginsDir($pluginDirApp);
     self::$_smarty->addPluginsDir($pluginsDir);
     // print_r(self::$_smarty->getPluginsDir());
     self::$_smarty->template_dir = array(_APP_ . $this->getBase(), _APP_ . '_template' . _DIR_SEPARATOR_);
     return $this->render($template);
 }
示例#17
0
 public static function GetTemplate()
 {
     $smarty = new Smarty();
     $smarty->setTemplateDir(TEMPLATE_PATH);
     $smarty->setCompileDir(COMPILE_PATH);
     $smarty->setConfigDir(CONF_PATH);
     $smarty->setCacheDir(CACHE_PATH);
     $smarty->addPluginsDir(TEMPLATE_PLUGINS_PATH);
     return $smarty;
 }
示例#18
0
 public function setUp()
 {
     $view = new \Smarty();
     $view->setTemplateDir(SMARTY_TMP_FOLDER);
     $view->setCompileDir(SMARTY_TMP_FOLDER);
     $view->setConfigDir(SMARTY_TMP_FOLDER);
     $view->setCacheDir(SMARTY_TMP_FOLDER);
     $view->addPluginsDir(__DIR__ . '/../../smarty_plugins/');
     $view->compile_check = true;
     $this->smarty = $view;
 }
示例#19
0
function s_smarty_object()
{
    //生成新的Smarty对象
    $smarty = new Smarty();
    $smarty->addPluginsDir(SHF_DIR . '/dev/smarty/userplugins');
    $smarty_temp = $_SERVER['SINASRV_CACHE_DIR'] . (defined('APP_NAME') ? APP_NAME : 'smarty_autocreate');
    $smarty->setCacheDir($smarty_temp);
    $smarty->setCompileDir($smarty_temp . '/templates_c');
    $smarty->setTemplateDir($smarty_temp . '/templates');
    return $smarty;
}
示例#20
0
function s_smarty_object()
{
    //生成新的Smarty对象
    $smarty = new Smarty();
    $smarty->addPluginsDir(FRAMEWORK_DIR . '/dev/smarty/userplugins');
    $smarty_temp = '/tmp';
    $smarty->setCacheDir($smarty_temp);
    $smarty->setCompileDir($smarty_temp . '/templates_c');
    $smarty->setTemplateDir($smarty_temp . '/templates');
    return $smarty;
}
示例#21
0
 protected function __construct()
 {
     PsLibs::inst()->Smarty();
     /*
      * Начиная с версии 5.4 в функции htmlentities параметр encoding был изменён на UTF-8, 
      * до этого момента после применения данного метода к тексту шаблона мы будем получать кракозябру.
      */
     SmartyCompilerException::$escape = is_phpver_is_or_greater(5, 4);
     //Получим и сконфигурируем экземпляр Smarty
     $this->smarty = new Smarty();
     $this->smarty->compile_check = true;
     $this->smarty->force_compile = false;
     //$this->smarty->caching = TRUE;
     /*
      * УПРАВЛЯЮЩИЕ ДИРЕКТОРИИ
      */
     //Директории с шаблонами .tpl : PSSmarty::template('common/citata.tpl');
     $this->smarty->setTemplateDir(ConfigIni::smartyTemplates());
     //Директория, в которую складываются скомпилированные шаблоны
     $this->smarty->setCompileDir(DirManager::autogen('/smarty/templates_c/')->absDirPath());
     //Директория, в которую складываются кеши
     $this->smarty->setCacheDir(DirManager::autogen('/smarty/cache/')->absDirPath());
     //Директория с конфигами
     $this->smarty->setConfigDir(PATH_BASE_DIR . PS_DIR_INCLUDES . '/smarty/configs/');
     //Директории с плагинами - блочными функциями, функциями, модификатор
     $this->smarty->addPluginsDir(ConfigIni::smartyPlugins());
     /*
      * Импортируем константы некоторых классов, чтобы на них можно было ссылаться через 
      * {$smarty.const.CONST_NAME}
      */
     //PsConstJs::defineAllConsts();
     /*
      * ПОДКЛЮЧИМ ФИЛЬТРЫ
      */
     PSSmartyFilter::inst()->bind($this->smarty);
     /*
      * ПОДКЛЮЧАЕМ ПЛАГИНЫ
      */
     PSSmartyPlugin::inst()->bind($this->smarty);
 }
 /**
  * Инициализация модуля
  *
  */
 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);
         }
     }
     /**
      * Разделитель заголовков страниц
      */
     $this->SetHtmlTitleSeparation(Config::Get('view.title_separator'));
     /**
      * Заголовок HTML страницы
      */
     $this->AddHtmlTitle(Config::Get('view.name'));
     /**
      * SEO ключевые слова страницы
      */
     $this->sHtmlKeywords = Config::Get('view.keywords');
     /**
      * SEO описание страницы
      */
     $this->sHtmlDescription = Config::Get('view.description');
     /**
      * Создаём объект Smarty и устанавливаем необходимые параметры
      */
     $this->oSmarty = $this->CreateSmartyObject();
     $this->oSmarty->error_reporting = error_reporting() & ~E_NOTICE;
     // подавляем NOTICE ошибки - в этом вся прелесть смарти )
     $this->oSmarty->setTemplateDir(array_merge((array) Config::Get('path.smarty.template'), array(Config::Get('path.application.plugins.server') . '/')));
     $this->oSmarty->compile_check = Config::Get('smarty.compile_check');
     $this->oSmarty->force_compile = Config::Get('smarty.force_compile');
     /**
      * Для каждого скина устанавливаем свою директорию компиляции шаблонов
      */
     $sCompilePath = Config::Get('path.smarty.compiled') . '/' . Config::Get('view.skin');
     if (!is_dir($sCompilePath)) {
         @mkdir($sCompilePath, 0777, true);
     }
     $this->oSmarty->setCompileDir($sCompilePath);
     $sCachePath = Config::Get('path.smarty.cache');
     if (!is_dir($sCachePath)) {
         @mkdir($sCachePath, 0777, true);
     }
     $this->oSmarty->setCacheDir($sCachePath);
     $this->oSmarty->addPluginsDir(array(Config::Get('path.smarty.plug'), 'plugins'));
     $this->oSmarty->default_template_handler_func = array($this, 'SmartyDefaultTemplateHandler');
 }
示例#23
0
function s_smarty_object()
{
    //生成新的Smarty对象
    $smarty = new Smarty();
    $smarty->addPluginsDir(ROOT_DIR . '/dev/smarty/userplugins');
    $smarty_temp = "saemc://smartytpl/";
    mkdir($smarty_temp);
    $smarty->compile_locking = false;
    $smarty->setCacheDir($smarty_temp);
    $smarty->setCompileDir($smarty_temp . '/templates_c');
    $smarty->setTemplateDir($smarty_temp . '/templates');
    return $smarty;
}
示例#24
0
 /**
  * Returns the cached smarty instance or creates and caches a new instance
  *
  * Not every Slim route will use Smarty, so by implementing this function,
  * we save those routes from having unnecessary overhead.
  *
  * @return \Smarty
  */
 protected function getSmartyInstance()
 {
     if ($this->smarty) {
         return $this->smarty;
     }
     $smarty = new \Smarty();
     $smarty->setTemplateDir($this->template_dir);
     $smarty->setCompileDir($this->compile_dir);
     $smarty->setCacheDir($this->cache_dir);
     $smarty->setErrorReporting(0);
     if ($this->plugin_dir) {
         $smarty->addPluginsDir($this->plugin_dir);
     }
     return $this->smarty = $smarty;
 }
示例#25
0
 public function __construct()
 {
     parent::__construct();
     $this->javascript_files = array();
     $this->javascript_texts = array();
     $file_path = dirname(__FILE__) . '/';
     $smarty_dir = $file_path . '../smarty/';
     parent::setTemplateDir($smarty_dir . 'templates/');
     parent::setCompileDir($smarty_dir . 'dev/template_c/');
     parent::setCacheDir($smarty_dir . 'dev/cache/');
     parent::setConfigDir($smarty_dir . 'configs/');
     $smarty_install_path = $file_path . '../../third_party/Smarty_3_1_0/';
     parent::setPluginsDir($smarty_install_path . 'libs/plugins');
     parent::addPluginsDir($smarty_install_path . 'libs/sysplugins');
 }
示例#26
0
 public static function getSmartyInstance()
 {
     if (self::$smarty == NULL) {
         require PHPLIB_DIR . '/smarty/Smarty.class.php';
         $smarty = new Smarty();
         $smarty->setTemplateDir(SMARTY_TEMPLATE_DIR);
         $smarty->setCompileDir(SMARTY_COMPILE_DIR);
         $smarty->setConfigDir(SMARTY_CONFIG_DIR);
         $smarty->setCacheDir(SMARTY_CACHE_DIR);
         $smarty->addPluginsDir(SMARTY_PLUGIN_DIR);
         $smarty->left_delimiter = SMARTY_LEFT_DELIMITER;
         $smarty->right_delimiter = SMARTY_RIGHT_DELIMITER;
         self::$smarty = $smarty;
     }
     return self::$smarty;
 }
示例#27
0
 /**
  * Инициализация шаблонизатора
  *
  */
 protected function _tplInit()
 {
     if ($this->oSmarty) {
         return;
     }
     // * Создаём объект Smarty
     $this->oSmarty = $this->CreateSmartyObject();
     // * Устанавливаем необходимые параметры для Smarty
     $this->oSmarty->compile_check = (bool) Config::Get('smarty.compile_check');
     $this->oSmarty->force_compile = (bool) Config::Get('smarty.force_compile');
     $this->oSmarty->merge_compiled_includes = (bool) Config::Get('smarty.merge_compiled_includes');
     // * Подавляем NOTICE ошибки - в этом вся прелесть смарти )
     $this->oSmarty->error_reporting = error_reporting() & ~E_NOTICE;
     // * Папки расположения шаблонов по умолчанию
     $aDirs = F::File_NormPath(F::Str2Array(Config::Get('path.smarty.template')));
     if (sizeof($aDirs) == 1) {
         $sDir = $aDirs[0];
         $aDirs['themes'] = F::File_NormPath($sDir . '/themes');
         $aDirs['tpls'] = F::File_NormPath($sDir . '/tpls');
     }
     $this->oSmarty->setTemplateDir($aDirs);
     if (Config::Get('smarty.dir.templates')) {
         $this->oSmarty->addTemplateDir(F::File_NormPath(F::Str2Array(Config::Get('smarty.dir.templates'))));
     }
     // * Для каждого скина устанавливаем свою директорию компиляции шаблонов
     $sCompilePath = F::File_NormPath(Config::Get('path.smarty.compiled'));
     F::File_CheckDir($sCompilePath);
     $this->oSmarty->setCompileDir($sCompilePath);
     $this->oSmarty->setCacheDir(Config::Get('path.smarty.cache'));
     // * Папки расположения пдагинов Smarty
     $this->oSmarty->addPluginsDir(array(Config::Get('path.smarty.plug'), 'plugins'));
     if (Config::Get('smarty.dir.plugins')) {
         $this->oSmarty->addPluginsDir(F::File_NormPath(F::Str2Array(Config::Get('smarty.dir.plugins'))));
     }
     $this->oSmarty->default_template_handler_func = array($this, 'SmartyDefaultTemplateHandler');
     // * Параметры кеширования, если заданы
     if (Config::Get('smarty.cache_lifetime')) {
         $this->oSmarty->caching = Smarty::CACHING_LIFETIME_SAVED;
         $this->oSmarty->cache_lifetime = F::ToSeconds(Config::Get('smarty.cache_lifetime'));
     }
     // Settings for Smarty 3.1.16 and more
     $this->oSmarty->inheritance_merge_compiled_includes = false;
     F::IncludeFile('./plugs/resource.file.php');
     $this->oSmarty->registerResource('file', new Smarty_Resource_File());
     // Mutes expected Smarty minor errors
     $this->oSmarty->muteExpectedErrors();
 }
示例#28
0
 private function getSmarty()
 {
     \Smarty::$_DATE_FORMAT = '%Y-%m-%d %H:%M:%S';
     $smarty = new \Smarty();
     $smarty->left_delimiter = '{{';
     $smarty->right_delimiter = '}}';
     $smarty->default_modifiers = array('escape:"html"');
     $smarty->compile_dir = HIANO_APP_PATH . '/Cache/smarty/templates_c/';
     $smarty->cache_dir = HIANO_APP_PATH . '/Cache/smarty/cache/';
     $smarty->registerPlugin('function', 'url', array($this, 'function_url'));
     $smarty->registerPlugin('function', 'link', array($this, 'function_link'));
     $smarty->registerPlugin('block', 'form', array($this, 'block_form'));
     $plugins_dir = HIANO_APP_PATH . '/Plugin/Smarty';
     if (file_exists($plugins_dir)) {
         $smarty->addPluginsDir($plugins_dir);
     }
     return $smarty;
 }
示例#29
0
 private static function initializeSmarty()
 {
     require_once self::basePath() . '/protect/smarty/Smarty.class.php';
     $s = new \Smarty();
     $s->setCompileDir(self::basePath() . '/cashe');
     $template = self::$_config['app']['template'];
     $s->setTemplateDir(self::basePath() . '/templates/' . $template);
     $s->force_compile = true;
     if (!self::$_config['app']['debug']) {
         $s->force_compile = false;
         $s->compile_check = false;
     }
     $s->addPluginsDir(self::basePath() . '/protect/smarty_plugins/');
     foreach (self::$_config as $key => $value) {
         $s->assign($key, $value);
     }
     $s->assign('relative_tpl', '/templates/' . $template);
     self::$_smarty = $s;
 }
示例#30
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)
 {
     $configKey = 'smarty::';
     $caching = $this->config[$configKey . 'caching'];
     $cache_lifetime = $this->config[$configKey . 'cache_lifetime'];
     $debugging = $this->config[$configKey . 'debugging'];
     $left_delimiter = $this->config[$configKey . 'left_delimiter'];
     $right_delimiter = $this->config[$configKey . 'right_delimiter'];
     $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'];
     // 取得config path为了fis map.json
     $configs_paths = $this->config[$configKey . 'configs_paths'];
     // Create smarty object.
     $smarty = new \Smarty();
     $smarty->setTemplateDir($template_path);
     $smarty->setCompileDir($compile_path);
     $smarty->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) {
         $smarty->addPluginsDir($path);
     }
     foreach ($configs_paths as $path) {
         $smarty->addConfigDir($path);
     }
     $smarty->debugging = $debugging;
     $smarty->caching = $caching;
     $smarty->cache_lifetime = $cache_lifetime;
     $smarty->compile_check = true;
     $smarty->left_delimiter = $left_delimiter;
     $smarty->right_delimiter = $right_delimiter;
     // $smarty->escape_html = true;
     $smarty->error_reporting = E_ALL & ~E_NOTICE;
     foreach ($__data as $var => $val) {
         $smarty->assign($var, $val);
     }
     return $smarty->fetch($__path);
 }