From: Leandro Lucarella Date: Wed, 21 May 2003 01:04:55 +0000 (+0000) Subject: * Added __construc() method for PHP5 forward compatibility. X-Git-Tag: svn_import~54 X-Git-Url: https://git.llucax.com/software/bife/bife-all.git/commitdiff_plain/83c0aaf19ae9241ba9f30da47013479ee761685e?ds=sidebyside * Added __construc() method for PHP5 forward compatibility. * Updated and fixed UML diagram and generated code. * Changed internal contents management of Container class. * Fixed xmi2code config file. * Added a Fallback class to use when the Parser doesn't finds a class for a widget (TBD). --- diff --git a/doc/bife.xmi b/doc/bife.xmi index 120fc01..f36bd7e 100644 --- a/doc/bife.xmi +++ b/doc/bife.xmi @@ -5,47 +5,58 @@ umbrello uml modeller http://uml.sf.net 1.1 - + - + - + - - + + + + + + + + + + + - + - + - + + + + + + - + + + + @@ -92,55 +106,72 @@ results." name="render" static="0" scope="200" > + + + + + + + + + + - - - - - - + + + + + + + - - + + - + - - + + - - + + - - + + - - + + + + + + + + - - + + @@ -172,25 +203,36 @@ results." name="render" static="0" scope="200" > + + + + + + + + + + - + + diff --git a/examples/index.php b/examples/index.php index 57a35af..5e21623 100644 --- a/examples/index.php +++ b/examples/index.php @@ -30,7 +30,6 @@ $tmp = ini_get('include_path'); ini_set('include_path', "../src:$tmp"); unset($tmp); -require_once 'prepend.php'; require_once 'HTML/Template/Sigma.php'; require_once 'BIFE/Parser.php'; require_once 'BIFE/Page.php'; diff --git a/src/BIFE/Album.php b/src/BIFE/Album.php index 3b19ad4..07fb437 100644 --- a/src/BIFE/Album.php +++ b/src/BIFE/Album.php @@ -59,6 +59,21 @@ class BIFE_Album extends BIFE_Widget { * @access public */ function BIFE_Album($attrs) // ~X2C + { + $this->__construct($attrs); + } + // -X2C + + // +X2C Operation 57 + /** + * Constructor. + * + * @param array $attrs Attributes. + * + * @return void + * @access public + */ + function __construct($attrs) // ~X2C { $defaults = array( 'DIR' => '.', @@ -80,7 +95,7 @@ class BIFE_Album extends BIFE_Widget { * * @param HTML_Template_Sigma &$template Template to use to render the widget. * - * @return void + * @return string * @access public */ function render(&$template) // ~X2C diff --git a/src/BIFE/Container.php b/src/BIFE/Container.php index d1ea194..14c7105 100644 --- a/src/BIFE/Container.php +++ b/src/BIFE/Container.php @@ -38,22 +38,80 @@ require_once 'BIFE/Widget.php'; * @abstract */ class BIFE_Container extends BIFE_Widget { + /** + * @var array $contents + * @access public + */ + var $contents; + // ~X2C + // +X2C Operation 48 + /** + * Constructor. + * + * @return void + * @access public + */ + function BIFE_Container() // ~X2C + { + $this->__construct(); + } + // -X2C + + // +X2C Operation 50 + /** + * Constructor. + * + * @return void + * @access public + */ + function __construct() // ~X2C + { + $this->contents = array(); + } + // -X2C + // +X2C Operation 6 /** * Adds contents to the container. * - * @param string $contents Contents to add to the container. + * @param mixed &$contents Contents to add to the container. * * @return void * @access public - * @abstract */ - function addContents($contents) // ~X2C + function addContents(&$contents) // ~X2C + { + if (is_object($contents)) { + $this->contents[] =& $contents; + } else { + $this->contents[] = $contents; + } + } + // -X2C + + // +X2C Operation 59 + /** + * Renders the widget using a template returning a string with the results. + * + * @param HTML_Template_Sigma &$template Template object to render the widget. + * + * @return string + * @access public + */ + function render(&$template) // ~X2C { - trigger_error('Method not implemented '.get_class($this). - '::addContents().', E_USER_ERROR); + $c = count($this->contents); + $o = ''; + for ($i = 0; $i < $c; $i++) { + if (is_object($this->contents[$i])) { + $o .= $this->contents[$i]->render($template); + } else { + $o .= $this->contents[$i]; + } + } + return $o; } // -X2C diff --git a/src/BIFE/Fallback.php b/src/BIFE/Fallback.php new file mode 100644 index 0000000..ed6ebdd --- /dev/null +++ b/src/BIFE/Fallback.php @@ -0,0 +1,78 @@ + | +// +--------------------------------------------------------------------+ +// +// $Id$ +// + + + +// +X2C includes +require_once 'BIFE/Container.php'; +// ~X2C + +// +X2C Class 61 :Fallback +/** + * Fallback widget to use when no specific widget is implemented. + * + * @access public + * @abstract + */ +class BIFE_Fallback extends BIFE_Container { + // ~X2C + + // +X2C Operation 62 + /** + * Constructor. + * + * @param string $name Name of the widget to draw. + * @param array $attrs Attributes. + * + * @return void + * @access public + */ + function BIFE_Fallback($name, $attrs) // ~X2C + { + trigger_error('Not implemented!', E_USER_WARNING); + } + // -X2C + + // +X2C Operation 63 + /** + * Constructor. + * + * @param string $name Name of the widget. + * @param array $attrs Attributes. + * + * @return void + * @access public + */ + function __construct($name, $attrs) // ~X2C + { + trigger_error('Not implemented!', E_USER_WARNING); + } + // -X2C + +} // -X2C Class :Fallback +?> \ No newline at end of file diff --git a/src/BIFE/Generic.php b/src/BIFE/Generic.php index 6b5258e..1cca645 100644 --- a/src/BIFE/Generic.php +++ b/src/BIFE/Generic.php @@ -47,12 +47,6 @@ class BIFE_Generic extends BIFE_Container { */ var $attrs; - /** - * @var string $contents - * @access public - */ - var $contents; - // ~X2C // +X2C Operation 10 @@ -66,8 +60,23 @@ class BIFE_Generic extends BIFE_Container { */ function BIFE_Generic($attrs) // ~X2C { - $this->attrs = $attrs; - $this->contents = ''; + $this->__construct($attrs); + } + // -X2C + + // +X2C Operation 51 + /** + * Constructor. + * + * @param array $attrs Attributes. + * + * @return void + * @access public + */ + function __construct($attrs) // ~X2C + { + parent::__construct(); + $this->attrs = $attrs; } // -X2C @@ -75,14 +84,17 @@ class BIFE_Generic extends BIFE_Container { /** * Add contents to the widget. * - * @param string $contents Contents to add. + * @param mixed &$contents Contents to add. * * @return void * @access public */ - function addContents($contents) // ~X2C + function addContents(&$contents) // ~X2C { - $this->contents .= trim($contents); + if (is_string($contents)) { + $contents = trim($contents); + } + parent::addContents($contents); } // -X2C @@ -92,18 +104,18 @@ class BIFE_Generic extends BIFE_Container { * * @param HTML_Template_Sigma &$template Template to use to render the widget. * - * @return void + * @return string * @access public */ function render(&$template) // ~X2C { $template->loadTemplateFile(get_class($this).'.html'); $template->setVariable($this->attrs); - $template->setVariable('CONTENTS', $this->contents); + $template->setVariable('CONTENTS', parent::render($template)); return $template->get(); } // -X2C } // -X2C Class :Generic -?> \ No newline at end of file +?> diff --git a/src/BIFE/Page.php b/src/BIFE/Page.php index e1d8aaa..0d6455c 100644 --- a/src/BIFE/Page.php +++ b/src/BIFE/Page.php @@ -50,7 +50,22 @@ class BIFE_Page extends BIFE_Generic { */ function BIFE_Page($attrs) // ~X2C { - $this->BIFE_Generic($attrs); + $this->__construct($attrs); + } + // -X2C + + // +X2C Operation 53 + /** + * Constructor. + * + * @param array $attrs Attributes. + * + * @return void + * @access public + */ + function __construct($attrs) // ~X2C + { + parent::__construct($attrs); } // -X2C diff --git a/src/BIFE/Title.php b/src/BIFE/Title.php index 518ded2..6ff15cf 100644 --- a/src/BIFE/Title.php +++ b/src/BIFE/Title.php @@ -50,7 +50,22 @@ class BIFE_Title extends BIFE_Generic { */ function BIFE_Title($attrs) // ~X2C { - $this->BIFE_Generic($attrs); + $this->__construct($attrs); + } + // -X2C + + // +X2C Operation 55 + /** + * Constructor. + * + * @param array $attrs Attributes. + * + * @return void + * @access public + */ + function __construct($attrs) // ~X2C + { + parent::__construct($attrs); } // -X2C diff --git a/src/BIFE/Widget.php b/src/BIFE/Widget.php index 56ee704..96ecdd4 100644 --- a/src/BIFE/Widget.php +++ b/src/BIFE/Widget.php @@ -38,13 +38,11 @@ class BIFE_Widget { // +X2C Operation 4 /** - * Renders the widget returning a string. -Renders the widget using a template returning a string with the -results. + * Renders the widget using a template returning a string with the results. * * @param HTML_Template_Sigma &$template Template object to render the widget. * - * @return void + * @return string * @access public * @abstract */ diff --git a/xmi2code.config b/xmi2code.config index 9ef07d0..688b61e 100644 --- a/xmi2code.config +++ b/xmi2code.config @@ -1,28 +1,28 @@