1: | <?php
|
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: |
|
9: |
|
10: | |
11: | |
12: | |
13: | |
14: | |
15: | |
16: | |
17: |
|
18: | class Smarty_Template_Config extends Smarty_Template_Source
|
19: | {
|
20: | |
21: | |
22: | |
23: | |
24: |
|
25: | public $config_sections = null;
|
26: |
|
27: | |
28: | |
29: | |
30: | |
31: |
|
32: | public $scope = 0;
|
33: |
|
34: | |
35: | |
36: | |
37: | |
38: |
|
39: | public $isConfig = true;
|
40: |
|
41: | |
42: | |
43: | |
44: | |
45: |
|
46: | public $compiler_class = 'Smarty_Internal_Config_File_Compiler';
|
47: |
|
48: | |
49: | |
50: | |
51: | |
52: |
|
53: | public $template_lexer_class = 'Smarty_Internal_Configfilelexer';
|
54: |
|
55: | |
56: | |
57: | |
58: | |
59: |
|
60: | public $template_parser_class = 'Smarty_Internal_Configfileparser';
|
61: |
|
62: | |
63: | |
64: | |
65: | |
66: | |
67: | |
68: | |
69: | |
70: | |
71: | |
72: |
|
73: | public static function load(
|
74: | Smarty_Internal_Template $_template = null,
|
75: | Smarty $smarty = null,
|
76: | $template_resource = null
|
77: | ) {
|
78: | static $_incompatible_resources = array('extends' => true, 'php' => true);
|
79: | if ($_template) {
|
80: | $smarty = $_template->smarty;
|
81: | $template_resource = $_template->template_resource;
|
82: | }
|
83: | if (empty($template_resource)) {
|
84: | throw new SmartyException('Source: Missing name');
|
85: | }
|
86: |
|
87: | list($name, $type) = Smarty_Resource::parseResourceName($template_resource, $smarty->default_config_type);
|
88: |
|
89: | if (isset($_incompatible_resources[ $type ])) {
|
90: | throw new SmartyException("Unable to use resource '{$type}' for config");
|
91: | }
|
92: | $source = new Smarty_Template_Config($smarty, $template_resource, $type, $name);
|
93: | $source->handler->populate($source, $_template);
|
94: | if (!$source->exists && isset($smarty->default_config_handler_func)) {
|
95: | Smarty_Internal_Method_RegisterDefaultTemplateHandler::_getDefaultTemplate($source);
|
96: | $source->handler->populate($source, $_template);
|
97: | }
|
98: | return $source;
|
99: | }
|
100: | }
|
101: | |