Редакция 2 | К новейшей редакции | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 2 | Редакция 3 | ||
---|---|---|---|
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 | * Smarty {assign} compiler function plugin
|
9 | * Smarty {assign} compiler function plugin
|
10 | *
|
10 | *
|
11 | * Type: compiler function<br>
|
11 | * Type: compiler function<br>
|
12 | * Name: assign<br>
|
12 | * Name: assign<br>
|
13 | * Purpose: assign a value to a template variable
|
13 | * Purpose: assign a value to a template variable
|
14 | * @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign}
|
14 | * @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign}
|
15 | * (Smarty online manual)
|
15 | * (Smarty online manual)
|
16 | * @author Monte Ohrt <monte at ohrt dot com> (initial author)
|
16 | * @author Monte Ohrt <monte at ohrt dot com> (initial author)
|
17 | * @author messju mohr <messju at lammfellpuschen dot de> (conversion to compiler function)
|
17 | * @author messju mohr <messju at lammfellpuschen dot de> (conversion to compiler function)
|
18 | * @param string containing var-attribute and value-attribute
|
18 | * @param string containing var-attribute and value-attribute
|
19 | * @param Smarty_Compiler
|
19 | * @param Smarty_Compiler
|
20 | */
|
20 | */
|
21 | function smarty_compiler_assign($tag_attrs, &$compiler) |
21 | function smarty_compiler_assign($tag_attrs, &$compiler) |
22 | {
|
22 | {
|
23 | $_params = $compiler->_parse_attrs($tag_attrs); |
23 | $_params = $compiler->_parse_attrs($tag_attrs); |
24 | 24 | ||
25 | if (!isset($_params['var'])) { |
25 | if (!isset($_params['var'])) { |
26 | $compiler->_syntax_error("assign: missing 'var' parameter", E_USER_WARNING); |
26 | $compiler->_syntax_error("assign: missing 'var' parameter", E_USER_WARNING); |
27 | return; |
27 | return; |
28 | }
|
28 | }
|
29 | 29 | ||
30 | if (!isset($_params['value'])) { |
30 | if (!isset($_params['value'])) { |
31 | $compiler->_syntax_error("assign: missing 'value' parameter", E_USER_WARNING); |
31 | $compiler->_syntax_error("assign: missing 'value' parameter", E_USER_WARNING); |
32 | return; |
32 | return; |
33 | }
|
33 | }
|
34 | 34 | ||
35 | return "\$this->assign({$_params['var']}, {$_params['value']});"; |
35 | return "\$this->assign({$_params['var']}, {$_params['value']});"; |
36 | }
|
36 | }
|
37 | 37 | ||
38 | /* vim: set expandtab: */
|
38 | /* vim: set expandtab: */
|
39 | 39 | ||
40 | ?>
|
40 | ?>
|
41 | 41 |