PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/framework/vendor/smarty3/lib/libs/sysplugins/smarty_internal_compile_assign.php

http://zoop.googlecode.com/
PHP | 65 lines | 38 code | 4 blank | 23 comment | 13 complexity | f855a3c5a0886950b5476b4ebe7344b3 MD5 | raw file
 1<?php
 2
 3/**
 4* Smarty Internal Plugin Compile Assign
 5* 
 6* Compiles the {assign} tag
 7* 
 8* @package Smarty
 9* @subpackage Compiler
10* @author Uwe Tews 
11*/
12/**
13* Smarty Internal Plugin Compile Assign Class
14*/
15class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase {
16    /**
17    * Compiles code for the {assign} tag
18    * 
19    * @param array $args array with attributes from parser
20    * @param object $compiler compiler object
21    * @return string compiled code
22    */
23    public function compile($args, $compiler)
24    {
25        $this->compiler = $compiler;
26        $this->required_attributes = array('var', 'value');
27        $this->optional_attributes = array('scope', 'nocache', 'smarty_internal_index');
28
29        $_nocache = 'null';
30        $_scope = 'null'; 
31        // check for nocache attribute before _get_attributes because
32        // it shall not controll caching of the compiled code, but is a parameter
33        if (isset($args['nocache'])) {
34            if ($args['nocache'] == 'true') {
35                $_nocache = 'true';
36                $_nocache_boolean = true;
37            } 
38            unset($args['nocache']);
39        } 
40        // check and get attributes
41        $_attr = $this->_get_attributes($args);
42
43        if (isset($_attr['scope'])) {
44            if ($_attr['scope'] == '\'parent\'') {
45                $_scope = SMARTY_PARENT_SCOPE;
46            } elseif ($_attr['scope'] == '\'root\'') {
47                $_scope = SMARTY_ROOT_SCOPE;
48           } elseif ($_attr['scope'] == '\'global\'') {
49                $_scope = SMARTY_GLOBAL_SCOPE;
50            } 
51        } 
52        // compiled output
53        if (isset($_attr['smarty_internal_index'])) {
54            if ($_attr['smarty_internal_index'] == '') {
55                return "<?php \$_smarty_tpl->append($_attr[var],$_attr[value],false,$_nocache,$_scope);?>";
56            } else {
57                return "<?php \$_tmp$_attr[smarty_internal_index] = $_attr[value]; \$_smarty_tpl->append($_attr[var],\$_tmp,true,$_nocache,$_scope); unset (\$_tmp);?>";
58            } 
59        } else {
60            return "<?php \$_smarty_tpl->assign($_attr[var],$_attr[value],$_nocache,$_scope);?>";
61        } 
62    } 
63} 
64
65?>