深圳全飞鸿

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 612|回复: 0
打印 上一主题 下一主题

smarty3的config_load研究

[复制链接]

16

主题

32

帖子

194

积分

注册会员

Rank: 2

积分
194
跳转到指定楼层
楼主
发表于 2019-9-5 11:09:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
文件:  \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. }
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|nagomes  

GMT+8, 2025-5-5 05:22 , Processed in 0.024529 second(s), 21 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表