]> git.llucax.com Git - software/bife/bife-all.git/blob - src/BIFE/Container.php
- Moved some Generic functionality to Widget (attrs property).
[software/bife/bife-all.git] / src / BIFE / Container.php
1 <?php
2 // vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
3 // +--------------------------------------------------------------------+
4 // |                       BIFE - Buil It FastEr                        |
5 // +--------------------------------------------------------------------+
6 // | This file is part of BIFE.                                         |
7 // |                                                                    |
8 // | BIFE is free software; you can redistribute it and/or modify it    |
9 // | under the terms of the GNU General Public License as published by  |
10 // | the Free Software Foundation; either version 2 of the License, or  |
11 // | (at your option) any later version.                                |
12 // |                                                                    |
13 // | BIFE is distributed in the hope that it will be useful, but        |
14 // | WITHOUT ANY WARRANTY; without even the implied warranty of         |
15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   |
16 // | General Public License for more details.                           |
17 // |                                                                    |
18 // | You should have received a copy of the GNU General Public License  |
19 // | along with Hooks; if not, write to the Free Software Foundation,   |
20 // | Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA      |
21 // +--------------------------------------------------------------------+
22 // | Created: Wed May 17 18:16:54 ART 2003                              |
23 // | Authors: Leandro Lucarella <luca@lugmen.org.ar>                    |
24 // +--------------------------------------------------------------------+
25 //
26 // $Id$
27 //
28
29 // +X2C includes
30 require_once 'BIFE/Widget.php';
31 // ~X2C
32
33 // +X2C Class 5 :Container
34 /**
35  * Base container widget class.
36  *
37  * @access public
38  * @abstract
39  */
40 class BIFE_Container extends BIFE_Widget {
41     /**
42      * @var    array $contents
43      * @access public
44      */
45     var $contents;
46
47     // ~X2C
48
49     // +X2C Operation 48
50     /**
51      * Constructor.
52      *
53      * @return void
54      * @access public
55      */
56     function BIFE_Container() // ~X2C
57     {
58         $this->__construct();
59     }
60     // -X2C
61
62     // +X2C Operation 50
63     /**
64      * Constructor.
65      *
66      * @return void
67      * @access public
68      */
69     function __construct() // ~X2C
70     {
71         $this->contents = array();
72     }
73     // -X2C
74
75     // +X2C Operation 6
76     /**
77      * Adds contents to the container.
78      *
79      * @param  mixed &$contents Contents to add to the container.
80      *
81      * @return void
82      * @access public
83      */
84     function addContents(&$contents) // ~X2C
85     {
86         if (is_object($contents)) {
87             $this->contents[] =& $contents;
88         } else {
89             $this->contents[] = $contents;
90         }
91     }
92     // -X2C
93
94     // +X2C Operation 59
95     /**
96      * Renders the widget using a template returning a string with the results.
97      *
98      * @param  HTML_Template_Sigma &$template Template object to render the widget.
99      *
100      * @return string
101      * @access public
102      */
103     function render(&$template) // ~X2C
104     {
105         $c = count($this->contents);
106         $o = '';
107         for ($i = 0; $i < $c; $i++) {
108             if (is_object($this->contents[$i])) {
109                 $o .= $this->contents[$i]->render($template);
110             } else {
111                 $o .= $this->contents[$i];
112             }
113         }
114         return $o;
115     }
116     // -X2C
117
118 } // -X2C Class :Container
119
120 ?>