| 1: | <?php
|
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: |
|
| 10: |
|
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: |
|
| 17: | class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase
|
| 18: | {
|
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: |
|
| 25: | public $option_flags = array('nocache', 'noscope');
|
| 26: |
|
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: |
|
| 32: | public $valid_scopes = array(
|
| 33: | 'local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT,
|
| 34: | 'root' => Smarty::SCOPE_ROOT, 'global' => Smarty::SCOPE_GLOBAL,
|
| 35: | 'tpl_root' => Smarty::SCOPE_TPL_ROOT, 'smarty' => Smarty::SCOPE_SMARTY
|
| 36: | );
|
| 37: |
|
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | |
| 45: | |
| 46: | |
| 47: |
|
| 48: | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
| 49: | {
|
| 50: |
|
| 51: | $this->required_attributes = array('var', 'value');
|
| 52: | $this->shorttag_order = array('var', 'value');
|
| 53: | $this->optional_attributes = array('scope');
|
| 54: | $this->mapCache = array();
|
| 55: | $_nocache = false;
|
| 56: |
|
| 57: | $_attr = $this->getAttributes($compiler, $args);
|
| 58: |
|
| 59: | if ($_var = $compiler->getId($_attr[ 'var' ])) {
|
| 60: | $_var = "'{$_var}'";
|
| 61: | } else {
|
| 62: | $_var = $_attr[ 'var' ];
|
| 63: | }
|
| 64: | if ($compiler->tag_nocache || $compiler->nocache) {
|
| 65: | $_nocache = true;
|
| 66: |
|
| 67: | $compiler->setNocacheInVariable($_attr[ 'var' ]);
|
| 68: | }
|
| 69: |
|
| 70: | if ($_attr[ 'noscope' ]) {
|
| 71: | $_scope = -1;
|
| 72: | } else {
|
| 73: | $_scope = $compiler->convertScope($_attr, $this->valid_scopes);
|
| 74: | }
|
| 75: |
|
| 76: | $_params = '';
|
| 77: | if ($_nocache || $_scope) {
|
| 78: | $_params .= ' ,' . var_export($_nocache, true);
|
| 79: | }
|
| 80: | if ($_scope) {
|
| 81: | $_params .= ' ,' . $_scope;
|
| 82: | }
|
| 83: | if (isset($parameter[ 'smarty_internal_index' ])) {
|
| 84: | $output =
|
| 85: | "<?php \$_tmp_array = isset(\$_smarty_tpl->tpl_vars[{$_var}]) ? \$_smarty_tpl->tpl_vars[{$_var}]->value : array();\n";
|
| 86: | $output .= "if (!(is_array(\$_tmp_array) || \$_tmp_array instanceof ArrayAccess)) {\n";
|
| 87: | $output .= "settype(\$_tmp_array, 'array');\n";
|
| 88: | $output .= "}\n";
|
| 89: | $output .= "\$_tmp_array{$parameter['smarty_internal_index']} = {$_attr['value']};\n";
|
| 90: | $output .= "\$_smarty_tpl->_assignInScope({$_var}, \$_tmp_array{$_params});?>";
|
| 91: | } else {
|
| 92: | $output = "<?php \$_smarty_tpl->_assignInScope({$_var}, {$_attr['value']}{$_params});?>";
|
| 93: | }
|
| 94: | return $output;
|
| 95: | }
|
| 96: | }
|
| 97: | |