Leandro Lucarella ------------------------------------------------------------------------------- $Id$ -----------------------------------------------------------------------------*/ require_once 'MLIB/Widget.php'; /** * Container base class. * * @todo Add a global example using all the methods. * @author Leandro Lucarella * @author Martín Marrese * @since 1.0 */ class MLIB_Widget_Container extends MLIB_Widget { /** * Contents of the widget. * * @protected */ var $contents = array (); /** * Adds new content to the container and returns the corresponding key. * * @param $content New content. * * @return Key * @todo Add an example. */ function addContent($content) { $this->contents[] = $content; return key($this->contents); } /** * Sets new content erasing previous one.ng key. * * @param $content New content. It can be a single component or an array of * components. * * @todo Add an example. */ function setContent($content) { if (is_array($content)) { $this->contents = $content; } else { $this->contents = array ($content); } } /** * Gets a content. * * @param $raw If is true, this method will return the contents array, * otherwise it will return a string as result of joining the * array components. * * @return mixed * @todo Add an example. */ function getContent($raw = false) { if ($raw) { return $this->contents; } else { $output = ''; foreach ($this->contents as $content) { if (is_object($content)) { $output .= $content->__toString(); } else { $output .= $content; } } } } } ?>