From 3e6adf5872b79e027c5966c92a98da157eac5f4b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mart=C3=ADn=20Marrese?= Date: Wed, 4 Aug 2004 14:07:45 +0000 Subject: [PATCH] Se agrega la clase Widget y algunos derivados. Primer acercamiento, basicamente esta la estructura. --- lib/MLIB/Widget.php | 61 ++++++++++++++++ lib/MLIB/Widget/Base.php | 50 +++++++++++++ lib/MLIB/Widget/Container.php | 114 ++++++++++++++++++++++++++++++ lib/MLIB/Widget/Frame.php | 85 ++++++++++++++++++++++ lib/MLIB/Widget/Window.php | 129 ++++++++++++++++++++++++++++++++++ 5 files changed, 439 insertions(+) create mode 100644 lib/MLIB/Widget.php create mode 100644 lib/MLIB/Widget/Base.php create mode 100644 lib/MLIB/Widget/Container.php create mode 100644 lib/MLIB/Widget/Frame.php create mode 100644 lib/MLIB/Widget/Window.php diff --git a/lib/MLIB/Widget.php b/lib/MLIB/Widget.php new file mode 100644 index 0000000..a776803 --- /dev/null +++ b/lib/MLIB/Widget.php @@ -0,0 +1,61 @@ + + Leandro Lucarella +------------------------------------------------------------------------------- +$Id$ +-----------------------------------------------------------------------------*/ + +/** + * Interface / dummy class for all MLIB_Widget classes. + * + * @todo Add a global example using all the methods. + * @author Leandro Lucarella + * @author Martín Marrese + * @since 1.0 + */ +class /* interface */ MLIB_Widget { + + /** + * Converts the widget to a string that is human readable. + * + * @return The Widget "converted" to a string. + * @todo Add an example. + */ + function __toString() + { + trigger_error('Not implemented!', E_USER_ERROR); + } + + /** + * Draws in the screen the "converted" widget + * + * @return void. + * @todo Add an example. + */ + function draw() + { + trigger_error('Not implemented!', E_USER_ERROR); + } +} + +?> \ No newline at end of file diff --git a/lib/MLIB/Widget/Base.php b/lib/MLIB/Widget/Base.php new file mode 100644 index 0000000..6063910 --- /dev/null +++ b/lib/MLIB/Widget/Base.php @@ -0,0 +1,50 @@ + + Leandro Lucarella +------------------------------------------------------------------------------- +$Id$ +-----------------------------------------------------------------------------*/ + +/** + * Base class for all MLIB_Widget classes. + * + * @todo Add a global example using all the methods. + * @author Leandro Lucarella + * @author Martín Marrese + * @since 1.0 + */ +class MLIB_Widget_Base + + /** + * Draws in the screen the "converted" widget + * + * @return void. + * @todo Add an example. + */ + function draw() + { + echo $this->__toString(); + } +} + +?> \ No newline at end of file diff --git a/lib/MLIB/Widget/Container.php b/lib/MLIB/Widget/Container.php new file mode 100644 index 0000000..078fbfb --- /dev/null +++ b/lib/MLIB/Widget/Container.php @@ -0,0 +1,114 @@ + + 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; + } + } + } + } +} +?> \ No newline at end of file diff --git a/lib/MLIB/Widget/Frame.php b/lib/MLIB/Widget/Frame.php new file mode 100644 index 0000000..20671d4 --- /dev/null +++ b/lib/MLIB/Widget/Frame.php @@ -0,0 +1,85 @@ + + Leandro Lucarella +------------------------------------------------------------------------------- +$Id$ +-----------------------------------------------------------------------------*/ + +require_once 'MLIB/Widget/Window.php'; + +/** + * This class accelerates the process of creation of Web sites, creating a + * contextual frame where the programmer puts only the _local_ code. + * + * @todo Add a global example using all the methods. + * @author Leandro Lucarella + * @author Martín Marrese + * @since 1.0 + */ +class MLIB_Widget_Frame extends MLIB_Widget_Window { + + //Esta clase es la traduccion de MLIB_Marco. + //Esta es la que se utilizaria en los sistemas para agilizar el + //funcionamiento. + + /** + * Constructor. + * For PHP4 backward compatibility. + * + * @copydoc __construct() + * @see __construct() + */ + function MLIB_Widget_Frame($confFile, $permObject = null) + { + $this->__construct($confFile, $permObject); + } + + /** + * Constructor. + * + * @param conFile Location of the configuration file. + * @param permObject MLIB_Perm or a derived class of it. + * + * @todo Add an example. + */ + function __constructor($confFile, $permObject = null) + { + } + + /** + * Converts the widget to a string that is human readable. + * + * @copydoc MLIB_Widget::__toString() + * @todo Add an example. + */ + function __toString() + { + //Agrego el header. + //Titulo + //Agrego el body. + //Menues + //Cuerpo's (si son objetos llamos al metodo __toString y si este no + // existe al toHtml) + } +} +?> \ No newline at end of file diff --git a/lib/MLIB/Widget/Window.php b/lib/MLIB/Widget/Window.php new file mode 100644 index 0000000..4dcd04e --- /dev/null +++ b/lib/MLIB/Widget/Window.php @@ -0,0 +1,129 @@ + + Leandro Lucarella +------------------------------------------------------------------------------- +$Id$ +-----------------------------------------------------------------------------*/ + +require_once 'MLIB/Widget/Container.php'; + +/** + * Window base class. + * + * @todo Add a global example using all the methods. + * @author Leandro Lucarella + * @author Martín Marrese + * @since 1.0 + */ +class MLIB_Widget_Window extends MLIB_Widget_Container { + + /** + * Style selected for the window. + * + * @protected + */ + var $style = null; + + /** + * Property List. + * + * @protected + */ + var $properties = array (); + + + /** + * Constructor. + * For PHP4 backward compatibility. + * + * @copydoc __construct() + * @see __construct() + */ + function MLIB_Widget_Window($style) + { + $this->__construct($style); + } + + /** + * Constructor. + * + * @param style Style selected for the window. + * @todo Add an example. + */ + function __constructor($style) + { + $this->style = $style; + } + + /** + * Converts the widget to a string that is human readable. + * + * @return The Widget "converted" to a string. + * @todo Add an example. + */ + function __toString() + { + return $tpl->parse($this->style, $this->properties); + } + + /** + * Sets a property. + * + * @param key Name of the property. + * @param value Value of the property. + * + * @todo Add an example. + */ + function setProperty($key, $value) + { + //FixMe Tiene que haber una manera mejor de hacer esto. + $this->properties[$key][] = $value; + } + + /** + * Removes a property and returns the property value. + * + * @param key Name of the property. + * + * @return PropValue. + */ + function removeProperty($key) + { + $value = $this->properties[$key]; + unset($this->properties[$key]); + return $value; + } + + /** + * Gets a propertie value. + * + * @param key Name of the property. + * + * @return PropValue. + */ + function getProperty($key) + { + return $this->properties[$key]; + } +} +?> \ No newline at end of file -- 2.43.0