3 * patTemplate function that enables adding global variables
4 * from within a template.
6 * $Id: Globalvar.php 2 2007-11-03 04:59:01Z fishbone $
9 * @subpackage Functions
10 * @author Sebastian Mordziol <argh@php-tools.net>
11 * @author Stephan Schmidt <schst@php.net>
15 * patTemplate function that enables adding global variables
16 * from within a template.
18 * Available attributes:
20 * name > name of the variable
21 * default > default value of the variable
22 * hidden > whether to output the content of the variable: yes|no
24 * $Id: Globalvar.php 2 2007-11-03 04:59:01Z fishbone $
26 * @package patTemplate
27 * @subpackage Functions
28 * @author Sebastian Mordziol <argh@php-tools.net>
29 * @author Stephan Schmidt <schst@php.net>
31 class patTemplate_Function_Globalvar extends patTemplate_Function
34 * name of the function
38 var $_name = 'Globalvar';
41 * reference to the patTemplate object that instantiated the module
49 * set a reference to the patTemplate object that instantiated the reader
52 * @param object patTemplate object
54 function setTemplateReference( &$tmpl )
56 $this->_tmpl = &$tmpl;
63 * @param array parameters of the function (= attributes of the tag)
64 * @param string content of the tag
65 * @return string content to insert into the template
67 function call( $params, $content )
69 if( isset( $params['default'] ) )
71 $this->_tmpl->addGlobalVar( $params['name'], $params['default'] );
74 if( !isset( $params['hidden'] ) )
76 $params['hidden'] = 'no';
79 if( $params['hidden'] != 'yes' )
80 return $this->_tmpl->getOption('startTag').strtoupper($params['name']).$this->_tmpl->getOption('endTag');