Globalvar.php
1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?PHP
/**
* patTemplate function that enables adding global variables
* from within a template.
*
* $Id: Globalvar.php,v 1.2 2004/05/28 15:45:08 schst Exp $
*
* @package patTemplate
* @subpackage Functions
* @author Sebastian Mordziol <argh@php-tools.net>
* @author Stephan Schmidt <schst@php.net>
*/
/**
* patTemplate function that enables adding global variables
* from within a template.
*
* Available attributes:
*
* name > name of the variable
* default > default value of the variable
* hidden > whether to output the content of the variable: yes|no
*
* $Id: Globalvar.php,v 1.2 2004/05/28 15:45:08 schst Exp $
*
* @package patTemplate
* @subpackage Functions
* @author Sebastian Mordziol <argh@php-tools.net>
* @author Stephan Schmidt <schst@php.net>
*/
class patTemplate_Function_Globalvar extends patTemplate_Function
{
/**
* name of the function
* @access private
* @var string
*/
var $_name = 'Globalvar';
/**
* reference to the patTemplate object that instantiated the module
*
* @access protected
* @var object
*/
var $_tmpl;
/**
* set a reference to the patTemplate object that instantiated the reader
*
* @access public
* @param object patTemplate object
*/
function setTemplateReference( &$tmpl )
{
$this->_tmpl = &$tmpl;
}
/**
* call the function
*
* @access public
* @param array parameters of the function (= attributes of the tag)
* @param string content of the tag
* @return string content to insert into the template
*/
function call( $params, $content )
{
if( isset( $params['default'] ) )
{
$this->_tmpl->addGlobalVar( $params['name'], $params['default'] );
}
if( !isset( $params['hidden'] ) )
{
$params['hidden'] = 'no';
}
if( $params['hidden'] != 'yes' )
return $this->_tmpl->getOption('startTag').strtoupper($params['name']).$this->_tmpl->getOption('endTag');
return '';
}
}
?>