Редакция 2 | Только различия | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 2 | Редакция 48 | ||
---|---|---|---|
1 | <?php
|
1 | <?php
|
2 | /**
|
2 | /**
|
3 | * Smarty plugin
|
3 | * Smarty plugin
|
4 | * @package Smarty
|
4 | * @package Smarty
|
5 | * @subpackage plugins
|
5 | * @subpackage plugins
|
6 | */
|
6 | */
|
7 | 7 | ||
8 | /**
|
8 | /**
|
9 | * called for included php files within templates
|
9 | * called for included php files within templates
|
10 | *
|
10 | *
|
11 | * @param string $smarty_file
|
11 | * @param string $smarty_file
|
12 | * @param string $smarty_assign variable to assign the included template's
|
12 | * @param string $smarty_assign variable to assign the included template's
|
13 | * output into
|
13 | * output into
|
14 | * @param boolean $smarty_once uses include_once if this is true
|
14 | * @param boolean $smarty_once uses include_once if this is true
|
15 | * @param array $smarty_include_vars associative array of vars from
|
15 | * @param array $smarty_include_vars associative array of vars from
|
16 | * {include file="blah" var=$var}
|
16 | * {include file="blah" var=$var}
|
17 | */
|
17 | */
|
18 | 18 | ||
19 | // $file, $assign, $once, $_smarty_include_vars
|
19 | // $file, $assign, $once, $_smarty_include_vars
|
20 | 20 | ||
21 | function smarty_core_smarty_include_php($params, &$smarty) |
21 | function smarty_core_smarty_include_php($params, &$smarty) |
22 | {
|
22 | {
|
23 | $_params = array('resource_name' => $params['smarty_file']); |
23 | $_params = array('resource_name' => $params['smarty_file']); |
24 | require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); |
24 | require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); |
25 | smarty_core_get_php_resource($_params, $smarty); |
25 | smarty_core_get_php_resource($_params, $smarty); |
26 | $_smarty_resource_type = $_params['resource_type']; |
26 | $_smarty_resource_type = $_params['resource_type']; |
27 | $_smarty_php_resource = $_params['php_resource']; |
27 | $_smarty_php_resource = $_params['php_resource']; |
28 | 28 | ||
29 | if (!empty($params['smarty_assign'])) { |
29 | if (!empty($params['smarty_assign'])) { |
30 | ob_start(); |
30 | ob_start(); |
31 | if ($_smarty_resource_type == 'file') { |
31 | if ($_smarty_resource_type == 'file') { |
32 | $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']); |
32 | $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']); |
33 | } else { |
33 | } else { |
34 | $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']); |
34 | $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']); |
35 | }
|
35 | }
|
36 | $smarty->assign($params['smarty_assign'], ob_get_contents()); |
36 | $smarty->assign($params['smarty_assign'], ob_get_contents()); |
37 | ob_end_clean(); |
37 | ob_end_clean(); |
38 | } else { |
38 | } else { |
39 | if ($_smarty_resource_type == 'file') { |
39 | if ($_smarty_resource_type == 'file') { |
40 | $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']); |
40 | $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']); |
41 | } else { |
41 | } else { |
42 | $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']); |
42 | $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']); |
43 | }
|
43 | }
|
44 | }
|
44 | }
|
45 | }
|
45 | }
|
46 | 46 | ||
47 | 47 | ||
48 | /* vim: set expandtab: */
|
48 | /* vim: set expandtab: */
|
49 | 49 | ||
50 | ?>
|
50 | ?>
|
51 | 51 |