PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://zoop.googlecode.com/
PHP | 63 lines | 33 code | 2 blank | 28 comment | 7 complexity | 69f707442629a55136c6ded7527e7bcc MD5 | raw file
 1<?php
 2
 3/**
 4* Smarty Internal Plugin Compile Function_Call
 5* 
 6* Compiles the calls of user defined tags defined by {function}
 7* 
 8* @package Smarty
 9* @subpackage Compiler
10* @author Uwe Tews 
11*/
12/**
13* Smarty Internal Plugin Compile Function_Call Class
14*/
15class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase {
16    /**
17    * Compiles the calls of user defined tags defined by {function}
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('name');
27        $this->optional_attributes = array('_any'); 
28        // check and get attributes
29        $_attr = $this->_get_attributes($args); 
30        // save posible attributes
31        if (isset($_attr['assign'])) {
32            // output will be stored in a smarty variable instead of beind displayed
33            $_assign = $_attr['assign'];
34        } 
35        // set flag (compiled code of {function} must be included in cache file
36        if ($this->compiler->nocache || $this->compiler->tag_nocache) {
37            $nocache = 'true';
38        } else {
39            $nocache = 'false';
40        } 
41        // create template object
42        $_output = "<?php \$_template = new Smarty_Internal_Function_Call_Handler ({$_attr['name']}, \$_smarty_tpl->smarty, \$_smarty_tpl, {$nocache});\n"; 
43        // delete {include} standard attributes
44        unset($_attr['name'], $_attr['assign']); 
45        // remaining attributes must be assigned as smarty variable
46        if (!empty($_attr)) {
47            // create variables
48            foreach ($_attr as $_key => $_value) {
49                $_output .= "\$_template->assign('$_key',$_value);\n";
50            } 
51        } 
52        // was there an assign attribute
53        if (isset($_assign)) {
54            $_output .= "\$_smarty_tpl->assign({$_assign},\$_template->getRenderedTemplate());\n";
55        } else {
56            $_output .= "echo \$_template->getRenderedTemplate();\n";
57        } 
58        $_output .= 'unset($_template);?>';
59        return $_output;
60    } 
61} 
62
63?>