OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / include / lib / patTemplate / patTemplate / Function / Globalvar.php
1 <?PHP
2 /**
3  * patTemplate function that enables adding global variables
4  * from within a template.
5  *
6  * $Id: Globalvar.php 2 2007-11-03 04:59:01Z fishbone $
7  *
8  * @package             patTemplate
9  * @subpackage  Functions
10  * @author              Sebastian Mordziol <argh@php-tools.net>
11  * @author              Stephan Schmidt <schst@php.net>
12  */
13
14 /**
15  * patTemplate function that enables adding global variables
16  * from within a template.
17  *
18  * Available attributes:
19  *
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
23  *
24  * $Id: Globalvar.php 2 2007-11-03 04:59:01Z fishbone $
25  *
26  * @package             patTemplate
27  * @subpackage  Functions
28  * @author              Sebastian Mordziol <argh@php-tools.net>
29  * @author              Stephan Schmidt <schst@php.net>
30  */
31 class patTemplate_Function_Globalvar extends patTemplate_Function
32 {
33    /**
34         * name of the function
35         * @access       private
36         * @var          string
37         */
38         var $_name      =       'Globalvar';
39
40    /**
41     * reference to the patTemplate object that instantiated the module
42         *
43         * @access       protected
44         * @var  object
45         */
46         var     $_tmpl;
47
48    /**
49     * set a reference to the patTemplate object that instantiated the reader
50         *
51         * @access       public
52         * @param        object          patTemplate object
53         */
54         function setTemplateReference( &$tmpl )
55         {
56                 $this->_tmpl            =       &$tmpl;
57         }
58
59    /**
60         * call the function
61         *
62         * @access       public
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
66         */ 
67         function call( $params, $content )
68         {
69                 if( isset( $params['default'] ) )
70                 {
71                         $this->_tmpl->addGlobalVar( $params['name'], $params['default'] );
72                 }
73                 
74                 if( !isset( $params['hidden'] ) )
75                 {
76                         $params['hidden'] = 'no';
77                 }
78                 
79                 if( $params['hidden'] != 'yes' )
80                         return $this->_tmpl->getOption('startTag').strtoupper($params['name']).$this->_tmpl->getOption('endTag');
81                         
82                 return '';
83         }
84 }
85 ?>