1 <?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80:
2 -------------------------------------------------------------------------------
4 -------------------------------------------------------------------------------
5 This file is part of mlib.
7 mlib is free software; you can redistribute it and/or modify it under
8 the terms of the GNU Lesser General Public License as published by the Free
9 Software Foundation; either version 2 of the License, or (at your option)
12 mlib is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17 You should have received a copy of the GNU Lesser General Public License; if
18 not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19 Boston, MA 02111-1307 USA
20 -------------------------------------------------------------------------------
21 Created: lun ago 2 10:48:51 ART 2004
22 Authors: Martín Marrese <m_marrese@argentina.com>
23 Leandro Lucarella <luca@llucax.hn.org>
24 -------------------------------------------------------------------------------
26 -----------------------------------------------------------------------------*/
28 require_once 'MLIB/Widget.php';
31 * Container base class.
33 * @todo Add a global example using all the methods.
34 * @author Leandro Lucarella <luca@llucax.hn.org>
35 * @author Martín Marrese <m_marrese@argentina.com>
38 class MLIB_Widget_Container extends MLIB_Widget {
41 * Contents of the widget.
45 var $contents = array ();
48 * Adds new content to the container and returns the corresponding key.
50 * @param $content New content.
53 * @todo Add an example.
55 function addContent($content)
57 $this->contents[] = $content;
58 return key($this->contents);
62 * Sets new content erasing previous one.ng key.
64 * @param $content New content. It can be a single component or an array of
67 * @todo Add an example.
69 function setContent($content)
71 if (is_array($content))
73 $this->contents = $content;
77 $this->contents = array ($content);
84 * @param $raw If is true, this method will return the contents array,
85 * otherwise it will return a string as result of joining the
89 * @todo Add an example.
91 function getContent($raw = false)
95 return $this->contents;
100 foreach ($this->contents as $content)
102 if (is_object($content))
104 $output .= $content->__toString();