From: Leandro Lucarella Date: Wed, 21 May 2003 03:38:13 +0000 (+0000) Subject: - Added a roadmap. X-Git-Tag: svn_import~53 X-Git-Url: https://git.llucax.com/software/bife/bife-all.git/commitdiff_plain/6040f3feab69010487b3e9b5b7ad532a0f44c50c?ds=inline - Added a roadmap. - Removed all rendering from the Parser class. - Added a parseString() method to the Parser (parse() is just for internal use). - Updated example. --- diff --git a/Doxyfile b/Doxyfile index 704aaeb..8206aa3 100644 --- a/Doxyfile +++ b/Doxyfile @@ -30,7 +30,7 @@ # General configuration options #--------------------------------------------------------------------------- PROJECT_NAME = "BIFE - Build It FastEr" -PROJECT_NUMBER = 0.5 +PROJECT_NUMBER = 0.6 OUTPUT_DIRECTORY = doc/api OUTPUT_LANGUAGE = English EXTRACT_ALL = YES diff --git a/doc/ROADMAP b/doc/ROADMAP new file mode 100644 index 0000000..c1e042c --- /dev/null +++ b/doc/ROADMAP @@ -0,0 +1,35 @@ +$Id$ + +Version 0.7 +=========== + + Parser: + - Implement the Fallback class. + + + +Version 0.8 +=========== + + General: + - Add a Root interface and derivate Page from Root. + - Make a Core Package with the core classes (Parser, Widget, Container, + Root, Fallback). + - Make a Basic (or Generic?) Package with simple implementations of all + classes in Core Package. + - Make other more specific Packages (like Album) with other widgets. + + Parser: + - Remove include statement, replace it with Root 'use' attribute. + + + +Version 0.9 +=========== + + Makefile: + - Make a way to put all classes in a package together in a single file to + avoid overhead in require_once calls. + + + diff --git a/doc/bife.xmi b/doc/bife.xmi index f36bd7e..d2bb8fd 100644 --- a/doc/bife.xmi +++ b/doc/bife.xmi @@ -9,7 +9,7 @@ - + @@ -73,12 +73,8 @@ - - - - - - + + @@ -97,11 +93,13 @@ - + - - + + + + @@ -190,10 +188,10 @@ - - + + diff --git a/examples/index.php b/examples/index.php index 5e21623..18f9ce3 100644 --- a/examples/index.php +++ b/examples/index.php @@ -43,8 +43,8 @@ $template =& new HTML_Template_Sigma('templates'); $template->setErrorHandling(PEAR_ERROR_PRINT); $parser =& new BIFE_Parser($template); -$parser->parseFile($file); -echo $parser->getOutput(); +$page =& $parser->parseFile($file); $parser->__destruct(); +echo $page->render($template); ?> diff --git a/src/BIFE/Generic.php b/src/BIFE/Generic.php index 1cca645..296a4c8 100644 --- a/src/BIFE/Generic.php +++ b/src/BIFE/Generic.php @@ -94,7 +94,9 @@ class BIFE_Generic extends BIFE_Container { if (is_string($contents)) { $contents = trim($contents); } - parent::addContents($contents); + if ($contents) { + parent::addContents($contents); + } } // -X2C @@ -109,13 +111,14 @@ class BIFE_Generic extends BIFE_Container { */ function render(&$template) // ~X2C { + $contents = parent::render($template); $template->loadTemplateFile(get_class($this).'.html'); $template->setVariable($this->attrs); - $template->setVariable('CONTENTS', parent::render($template)); + $template->setVariable('CONTENTS', $contents); return $template->get(); } // -X2C } // -X2C Class :Generic -?> +?> \ No newline at end of file diff --git a/src/BIFE/Parser.php b/src/BIFE/Parser.php index 001c76e..78ab5b0 100644 --- a/src/BIFE/Parser.php +++ b/src/BIFE/Parser.php @@ -34,12 +34,12 @@ */ class BIFE_Parser { /** - * Output string. + * Top level widget. * - * @var string $output + * @var BIFE_Widget $root * @access public */ - var $output; + var $root; /** * XML parser resource. @@ -71,12 +71,10 @@ class BIFE_Parser { /** * Constructor. * - * @param HTML_Template_Sigma &$template Template to use to render the widgets. - * * @return void * @access public */ - function BIFE_Parser(&$template) // ~X2C + function BIFE_Parser() // ~X2C { $this->__construct($template); } @@ -86,15 +84,13 @@ class BIFE_Parser { /** * Constructor. * - * @param HTML_Template_Sigma &$template Template to use to render the widgets. - * * @return void * @access public */ - function __construct(&$template) // ~X2C + function __construct() // ~X2C { $this->stack = array(); - $this->output = ''; + $this->root = null; $this->parser = xml_parser_create(); $this->template =& $template; xml_set_object($this->parser, $this); @@ -163,9 +159,9 @@ class BIFE_Parser { end($this->stack); $parent =& $this->stack[key($this->stack)]; if ($parent) { - $parent->addContents($current->render($this->template)); + $parent->addContents($current); } else { - $this->output = $current->render($this->template); + $this->root =& $current; } } // -X2C @@ -214,14 +210,14 @@ class BIFE_Parser { // +X2C Operation 37 /** - * Parse a XML file returning the rendered output. + * Parse a XML file with a complete and valid XML document. * * @param string $filename Filename to parse. * - * @return void + * @return &BIFE_Widget * @access public */ - function parseFile($filename) // ~X2C + function &parseFile($filename) // ~X2C { if ($fp = @fopen($filename, "r")) { while ($data = fread($fp, 4096)) { @@ -232,22 +228,27 @@ class BIFE_Parser { E_USER_WARNING); } fclose($fp); + return $this->root; } // -X2C - // +X2C Operation 38 + + // +X2C Operation 74 /** - * Get rendered output. + * Parse a XML string with a complete and valid XML document. + * + * @param string $data XML data to parse. * - * @return string + * @return &BIFE_Widget * @access public */ - function getOutput() // ~X2C + function &parseString($data) // ~X2C { - return $this->output; + $this->parse($data, true); + return $this->root; } // -X2C } // -X2C Class :Parser -?> \ No newline at end of file +?>