深圳全飞鸿

标题: smarty3的config_load研究 [打印本页]

作者: e54f    时间: 2019-9-5 11:09
标题: smarty3的config_load研究
文件:  \libs\sysplugins\smarty_internal_compile_config_load.php
代码:
  1. class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
  2. {
  3.     public $required_attributes = array('file');
  4.     public $shorttag_order = array('file', 'section');
  5.     public $optional_attributes = array('section', 'scope');
  6.     public $option_flags = array('nocache', 'noscope');
  7.     public $valid_scopes = array(
  8.         'local'  => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT,
  9.         'root'   => Smarty::SCOPE_ROOT, 'tpl_root' => Smarty::SCOPE_TPL_ROOT,
  10.         'smarty' => Smarty::SCOPE_SMARTY, 'global' => Smarty::SCOPE_SMARTY
  11.     );

  12.     public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
  13.     {
  14.         // check and get attributes
  15.         $_attr = $this->getAttributes($compiler, $args);
  16.         if ($_attr[ 'nocache' ] === true) {
  17.             $compiler->trigger_template_error('nocache option not allowed', null, true);
  18.         }
  19.         // save possible attributes
  20.         $conf_file = $_attr[ 'file' ];
  21.         if (isset($_attr[ 'section' ])) {
  22.             $section = $_attr[ 'section' ];
  23.         } else {
  24.             $section = 'null';
  25.         }
  26.         // scope setup
  27.         if ($_attr[ 'noscope' ]) {
  28.             $_scope = -1;
  29.         } else {
  30.             $_scope = $compiler->convertScope($_attr, $this->valid_scopes);
  31.         }
  32.         // create config object
  33.         $_output =
  34.             "<?php\n\$_smarty_tpl->smarty->ext->configLoad->_loadConfigFile(\$_smarty_tpl, {$conf_file}, {$section}, {$_scope});\n?>\n";
  35.         return $_output;
  36.     }
  37. }
复制代码







欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/) Powered by Discuz! X3.2