- Removed all rendering from the Parser class.
- Added a parseString() method to the Parser (parse() is just for internal
use).
- Updated example.
# 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
--- /dev/null
+$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.
+
+
+
<XMI.metamodel xmi.name="UML" href="UML.xml" xmi.version="1.3" />
</XMI.header>
<XMI.content>
- <docsettings viewid="2" documentation="" uniqueid="72" />
+ <docsettings viewid="2" documentation="" uniqueid="75" />
<umlobjects>
<UML:Class stereotype="" package="BIFE" xmi.id="3" abstract="1" documentation="Base widget class." name="Widget" static="0" scope="200" >
<UML:Operation stereotype="" package="" xmi.id="4" type="string" abstract="1" documentation="Renders the widget using a template returning a string with the results." name="render" static="0" scope="200" >
<UML:Attribute stereotype="" package="" xmi.id="21" value="" type="array" abstract="0" documentation="Attributes." name="attrs" static="0" scope="200" />
</UML:Class>
<UML:Class stereotype="" package="BIFE" xmi.id="25" abstract="0" documentation="This is the XML Parser." name="Parser" static="0" scope="200" >
- <UML:Operation stereotype="" package="" xmi.id="30" type="void" abstract="0" documentation="Constructor." name="BIFE_Parser" static="0" scope="200" >
- <UML:Parameter stereotype="" package="" xmi.id="1" value="" type="&HTML_Template_Sigma" abstract="0" documentation="Template to use to render the widgets." name="template" static="0" scope="200" />
- </UML:Operation>
- <UML:Operation stereotype="" package="" xmi.id="31" type="void" abstract="0" documentation="Constructor." name="__construct" static="0" scope="200" >
- <UML:Parameter stereotype="" package="" xmi.id="1" value="" type="&HTML_Template_Sigma" abstract="0" documentation="Template to use to render the widgets." name="template" static="0" scope="200" />
- </UML:Operation>
+ <UML:Operation stereotype="" package="" xmi.id="30" type="void" abstract="0" documentation="Constructor." name="BIFE_Parser" static="0" scope="200" />
+ <UML:Operation stereotype="" package="" xmi.id="31" type="void" abstract="0" documentation="Constructor." name="__construct" static="0" scope="200" />
<UML:Operation stereotype="" package="" xmi.id="32" type="void" abstract="0" documentation="Destructor." name="__destruct" static="0" scope="200" />
<UML:Operation stereotype="" package="" xmi.id="33" type="void" abstract="0" documentation="XML parser start of element handler." name="startElement" static="0" scope="200" >
<UML:Parameter stereotype="" package="" xmi.id="1" value="" type="resource" abstract="0" documentation="XML parser resource." name="parser" static="0" scope="200" />
<UML:Parameter stereotype="" package="" xmi.id="1" value="" type="string" abstract="0" documentation="XML string to parse." name="data" static="0" scope="200" />
<UML:Parameter stereotype="" package="" xmi.id="2" value="true" type="bool" abstract="0" documentation="Indicates if is the last string to parse." name="final" static="0" scope="200" />
</UML:Operation>
- <UML:Operation stereotype="" package="" xmi.id="37" type="void" abstract="0" documentation="Parse a XML file returning the rendered output." name="parseFile" static="0" scope="200" >
+ <UML:Operation stereotype="" package="" xmi.id="37" type="&BIFE_Widget" abstract="0" documentation="Parse a XML file with a complete and valid XML document." name="parseFile" static="0" scope="200" >
<UML:Parameter stereotype="" package="" xmi.id="1" value="" type="string" abstract="0" documentation="Filename to parse." name="filename" static="0" scope="200" />
</UML:Operation>
- <UML:Operation stereotype="" package="" xmi.id="38" type="string" abstract="0" documentation="Get rendered output." name="getOutput" static="0" scope="200" />
- <UML:Attribute stereotype="" package="" xmi.id="26" value="" type="string" abstract="0" documentation="Output string." name="output" static="0" scope="200" />
+ <UML:Operation stereotype="" package="" xmi.id="74" type="&BIFE_Widget" abstract="0" documentation="Parse a XML string with a complete and valid XML document." name="parseString" static="0" scope="200" >
+ <UML:Parameter stereotype="" package="" xmi.id="1" value="" type="string" abstract="0" documentation="XML data to parse." name="data" static="0" scope="200" />
+ </UML:Operation>
+ <UML:Attribute stereotype="" package="" xmi.id="26" value="" type="BIFE_Widget" abstract="0" documentation="Top level widget." name="root" static="0" scope="200" />
<UML:Attribute stereotype="" package="" xmi.id="27" value="" type="resource" abstract="0" documentation="XML parser resource." name="parser" static="0" scope="200" />
<UML:Attribute stereotype="" package="" xmi.id="28" value="" type="HTML_Template_Sigma" abstract="0" documentation="Template to use to render the parsed file." name="template" static="0" scope="200" />
<UML:Attribute stereotype="" package="" xmi.id="29" value="" type="array" abstract="0" documentation="BIFE widgets stack." name="stack" static="0" scope="200" />
<listitem open="0" type="815" id="32" label="__destruct" />
<listitem open="0" type="815" id="35" label="characterData" />
<listitem open="0" type="815" id="34" label="endElement" />
- <listitem open="0" type="815" id="38" label="getOutput" />
- <listitem open="0" type="814" id="26" label="output" />
+ <listitem open="0" type="814" id="26" label="root" />
<listitem open="0" type="815" id="36" label="parse" />
<listitem open="0" type="815" id="37" label="parseFile" />
+ <listitem open="0" type="815" id="74" label="parseString" />
<listitem open="0" type="814" id="27" label="parser" />
<listitem open="0" type="814" id="29" label="stack" />
<listitem open="0" type="815" id="33" label="startElement" />
$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);
?>
if (is_string($contents)) {
$contents = trim($contents);
}
- parent::addContents($contents);
+ if ($contents) {
+ parent::addContents($contents);
+ }
}
// -X2C
*/
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
*/
class BIFE_Parser {
/**
- * Output string.
+ * Top level widget.
*
- * @var string $output
+ * @var BIFE_Widget $root
* @access public
*/
- var $output;
+ var $root;
/**
* XML parser resource.
/**
* 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);
}
/**
* 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);
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
// +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)) {
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
+?>