]> git.llucax.com Git - software/bife/bife-all.git/commitdiff
Draft 4 (v0.4):
authorLeandro Lucarella <llucax@gmail.com>
Sat, 17 May 2003 05:16:47 +0000 (05:16 +0000)
committerLeandro Lucarella <llucax@gmail.com>
Sat, 17 May 2003 05:16:47 +0000 (05:16 +0000)
* Updated UML diagrams.
* Generated classes with xmi2code in separeted files under BIFE directory.
* Changed extension of XML files to .xbf.

BIFE/Album.php [new file with mode: 0644]
BIFE/Container.php [new file with mode: 0644]
BIFE/Generic.php [new file with mode: 0644]
BIFE/Page.php [new file with mode: 0644]
BIFE/Parser.php [new file with mode: 0644]
BIFE/Title.php [new file with mode: 0644]
BIFE/Widget.php [new file with mode: 0644]
bife.xmi
index.php
simple.xbf [moved from simple.xml with 53% similarity]
templates/photo.html [moved from photo.html with 100% similarity]

diff --git a/BIFE/Album.php b/BIFE/Album.php
new file mode 100644 (file)
index 0000000..b854b8f
--- /dev/null
@@ -0,0 +1,96 @@
+<?php
+// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
+// +--------------------------------------------------------------------+
+// |                      BIFE - Buil It Fast & Easy                    |
+// +--------------------------------------------------------------------+
+// | This file is part of BIFE.                                         |
+// |                                                                    |
+// | BIFE is free software; you can redistribute it and/or modify it    |
+// | under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation; either version 2 of the License, or  |
+// | (at your option) any later version.                                |
+// |                                                                    |
+// | BIFE is distributed in the hope that it will be useful, but        |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   |
+// | General Public License for more details.                           |
+// |                                                                    |
+// | You should have received a copy of the GNU General Public License  |
+// | along with Hooks; if not, write to the Free Software Foundation,   |
+// | Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA      |
+// +--------------------------------------------------------------------+
+// | Created: @date
+// | Authors: @author
+// +--------------------------------------------------------------------+
+//
+// $Id$
+//
+
+// +X2C includes
+require_once 'BIFE/Widget.php';
+// ~X2C
+require_once 'Album.php';
+
+// +X2C Class 20 :Album
+/**
+ * Photo album widget.
+[TODO: Make a better explanation]
+ *
+ * @access public
+ */
+class BIFE_Album extends BIFE_Widget {
+    /**
+     * Attributes.
+     *
+     * @var    array $attrs
+     * @access public
+     */
+    var $attrs;
+
+    // ~X2C
+
+    // +X2C Operation 22
+    /**
+     * Constructor.
+     *
+     * @param  array $attrs Attributes.
+     *
+     * @return void
+     * @access public
+     */
+    function BIFE_Album($attrs) // ~X2C
+    {
+        $defaults = array(
+            'DIR'           => '.',
+            'RECURSIVE'     => true,
+            'THUMBSFORMAT'  => 'jpeg',
+            'THUMBSDIR'     => '.thumbs',
+            'EXTENSIONS'    => 'png,jpg,jpeg,gif',
+            'SELECTED'      => '',
+            'MAXROWS'       => 0,
+            'COLUMNS'       => 4,
+        );
+        $this->attrs = array_merge($defaults, $attrs);
+    }
+    // -X2C
+
+    // +X2C Operation 23
+    /**
+     * Renders the widget.
+     *
+     * @param  HTML_Template_Sigma &$template Template to use to render the widget.
+     *
+     * @return void
+     * @access public
+     */
+    function render(&$template) // ~X2C
+    {
+        extract($this->attrs, EXTR_SKIP);
+        $album =& new Hook_Album($DIR, $RECURSIVE, $THUMBSFORMAT, $THUMBSDIR, $EXTENSIONS);
+        return $album->album($template, $SELECTED, $MAXROWS, $COLUMNS);
+    }
+    // -X2C
+
+} // -X2C Class :Album
+
+?>
diff --git a/BIFE/Container.php b/BIFE/Container.php
new file mode 100644 (file)
index 0000000..e87f813
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
+// +--------------------------------------------------------------------+
+// |                      BIFE - Buil It Fast & Easy                    |
+// +--------------------------------------------------------------------+
+// | This file is part of BIFE.                                         |
+// |                                                                    |
+// | BIFE is free software; you can redistribute it and/or modify it    |
+// | under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation; either version 2 of the License, or  |
+// | (at your option) any later version.                                |
+// |                                                                    |
+// | BIFE is distributed in the hope that it will be useful, but        |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   |
+// | General Public License for more details.                           |
+// |                                                                    |
+// | You should have received a copy of the GNU General Public License  |
+// | along with Hooks; if not, write to the Free Software Foundation,   |
+// | Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA      |
+// +--------------------------------------------------------------------+
+// | Created: @date
+// | Authors: @author
+// +--------------------------------------------------------------------+
+//
+// $Id$
+//
+
+// +X2C includes
+require_once 'BIFE/Widget.php';
+// ~X2C
+
+// +X2C Class 5 :Container
+/**
+ * Base container widget class.
+ *
+ * @access public
+ * @abstract
+ */
+class BIFE_Container extends BIFE_Widget {
+    // ~X2C
+
+    // +X2C Operation 6
+    /**
+     * Adds contents to the container.
+     *
+     * @param  string $contents Contents to add to the container.
+     *
+     * @return void
+     * @access public
+     * @abstract
+     */
+    function addContents($contents) // ~X2C
+    {
+        trigger_error('Method not implemented '.get_class($this).
+            '::addContents().', E_USER_ERROR);
+    }
+    // -X2C
+
+} // -X2C Class :Container
+
+?>
\ No newline at end of file
diff --git a/BIFE/Generic.php b/BIFE/Generic.php
new file mode 100644 (file)
index 0000000..d10a577
--- /dev/null
@@ -0,0 +1,109 @@
+<?php
+// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
+// +--------------------------------------------------------------------+
+// |                      BIFE - Buil It Fast & Easy                    |
+// +--------------------------------------------------------------------+
+// | This file is part of BIFE.                                         |
+// |                                                                    |
+// | BIFE is free software; you can redistribute it and/or modify it    |
+// | under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation; either version 2 of the License, or  |
+// | (at your option) any later version.                                |
+// |                                                                    |
+// | BIFE is distributed in the hope that it will be useful, but        |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   |
+// | General Public License for more details.                           |
+// |                                                                    |
+// | You should have received a copy of the GNU General Public License  |
+// | along with Hooks; if not, write to the Free Software Foundation,   |
+// | Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA      |
+// +--------------------------------------------------------------------+
+// | Created: 
+// | Authors: Leandro Lucarella <luca@lugmen.org.ar>                    |
+// +--------------------------------------------------------------------+
+//
+// $Id$
+//
+
+
+// +X2C includes
+require_once 'BIFE/Container.php';
+// ~X2C
+
+// +X2C Class 7 :Generic
+/**
+ * This is a generic and simple BIFE_Container implementation.
+ *
+ * @access public
+ * @abstract
+ */
+class BIFE_Generic extends BIFE_Container {
+    /**
+     * Attribute list.
+     *
+     * @var    array $attrs
+     * @access public
+     */
+    var $attrs;
+
+    /**
+     * @var    string $contents
+     * @access public
+     */
+    var $contents;
+
+    // ~X2C
+
+    // +X2C Operation 10
+    /**
+     * Constructor.
+     *
+     * @param  array $attrs Attributes.
+     *
+     * @return void
+     * @access public
+     */
+    function BIFE_Generic($attrs) // ~X2C
+    {
+        $this->attrs    = $attrs;
+        $this->contents = '';
+    }
+    // -X2C
+
+    // +X2C Operation 11
+    /**
+     * Add contents to the widget.
+     *
+     * @param  string $contents Contents to add.
+     *
+     * @return void
+     * @access public
+     */
+    function addContents($contents) // ~X2C
+    {
+        $this->contents .= trim($contents);
+    }
+    // -X2C
+
+    // +X2C Operation 12
+    /**
+     * Renders the widget.
+     *
+     * @param  HTML_Template_Sigma &$template Template to use to render the widget.
+     *
+     * @return void
+     * @access public
+     */
+    function render(&$template) // ~X2C
+    {
+        $template->loadTemplateFile(get_class($this).'.html');
+        $template->setVariable($this->attrs);
+        $template->setVariable('CONTENTS', $this->contents);
+        return $template->get();
+    }
+    // -X2C
+
+} // -X2C Class :Generic
+
+?>
\ No newline at end of file
diff --git a/BIFE/Page.php b/BIFE/Page.php
new file mode 100644 (file)
index 0000000..d8ef88a
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
+// +--------------------------------------------------------------------+
+// |                      BIFE - Buil It Fast & Easy                    |
+// +--------------------------------------------------------------------+
+// | This file is part of BIFE.                                         |
+// |                                                                    |
+// | BIFE is free software; you can redistribute it and/or modify it    |
+// | under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation; either version 2 of the License, or  |
+// | (at your option) any later version.                                |
+// |                                                                    |
+// | BIFE is distributed in the hope that it will be useful, but        |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   |
+// | General Public License for more details.                           |
+// |                                                                    |
+// | You should have received a copy of the GNU General Public License  |
+// | along with Hooks; if not, write to the Free Software Foundation,   |
+// | Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA      |
+// +--------------------------------------------------------------------+
+// | Created: @date
+// | Authors: @author
+// +--------------------------------------------------------------------+
+//
+// $Id$
+//
+
+// +X2C includes
+require_once 'BIFE/Generic.php';
+// ~X2C
+
+// +X2C Class 14 :Page
+/**
+ * Page widget.
+ *
+ * @access public
+ */
+class BIFE_Page extends BIFE_Generic {
+    // ~X2C
+
+    // +X2C Operation 15
+    /**
+     * Constructor.
+     *
+     * @param  array $attrs Attributes.
+     *
+     * @return void
+     * @access public
+     */
+    function BIFE_Page($attrs) // ~X2C
+    {
+        $this->BIFE_Generic($attrs);
+    }
+    // -X2C
+
+} // -X2C Class :Page
+
+?>
\ No newline at end of file
diff --git a/BIFE/Parser.php b/BIFE/Parser.php
new file mode 100644 (file)
index 0000000..0b85636
--- /dev/null
@@ -0,0 +1,253 @@
+<?php
+// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
+// +--------------------------------------------------------------------+
+// |                      BIFE - Buil It Fast & Easy                    |
+// +--------------------------------------------------------------------+
+// | This file is part of BIFE.                                         |
+// |                                                                    |
+// | BIFE is free software; you can redistribute it and/or modify it    |
+// | under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation; either version 2 of the License, or  |
+// | (at your option) any later version.                                |
+// |                                                                    |
+// | BIFE is distributed in the hope that it will be useful, but        |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   |
+// | General Public License for more details.                           |
+// |                                                                    |
+// | You should have received a copy of the GNU General Public License  |
+// | along with Hooks; if not, write to the Free Software Foundation,   |
+// | Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA      |
+// +--------------------------------------------------------------------+
+// | Created: @date
+// | Authors: @author
+// +--------------------------------------------------------------------+
+//
+// $Id$
+//
+
+// +X2C Class 25 :Parser
+/**
+ * This is the XML Parser.
+ *
+ * @access public
+ */
+class BIFE_Parser {
+    /**
+     * Output string.
+     *
+     * @var    string $output
+     * @access public
+     */
+    var $output;
+
+    /**
+     * XML parser resource.
+     *
+     * @var    resource $parser
+     * @access public
+     */
+    var $parser;
+
+    /**
+     * Template to use to render the parsed file.
+     *
+     * @var    HTML_Template_Sigma $template
+     * @access public
+     */
+    var $template;
+
+    /**
+     * BIFE widgets stack.
+     *
+     * @var    array $stack
+     * @access public
+     */
+    var $stack;
+
+    // ~X2C
+
+    // +X2C Operation 30
+    /**
+     * Constructor.
+     *
+     * @param  HTML_Template_Sigma &$template Template to use to render the widgets.
+     *
+     * @return void
+     * @access public
+     */
+    function BIFE_Parser(&$template) // ~X2C
+    {
+        $this->__construct($template);
+    }
+    // -X2C
+
+    // +X2C Operation 31
+    /**
+     * Constructor.
+     *
+     * @param  HTML_Template_Sigma &$template Template to use to render the widgets.
+     *
+     * @return void
+     * @access public
+     */
+    function __construct(&$template) // ~X2C
+    {
+        $this->stack    = array();
+        $this->output   = '';
+        $this->parser   = xml_parser_create();
+        $this->template =& $template;
+        xml_set_object($this->parser, $this);
+        xml_set_element_handler($this->parser, 'startElement', 'endElement');
+        xml_set_character_data_handler($this->parser, 'characterData');
+    }
+    // -X2C
+
+    // +X2C Operation 32
+    /**
+     * Destructor.
+     *
+     * @return void
+     * @access public
+     */
+    function __destruct() // ~X2C
+    {
+        xml_parser_free($this->parser);
+    }
+    // -X2C
+
+    // +X2C Operation 33
+    /**
+     * XML parser start of element handler.
+     *
+     * @param  resource $parser XML parser resource.
+     * @param  string $name XML tag name.
+     * @param  array $attrs XML tag attributes.
+     *
+     * @return void
+     * @access public
+     */
+    function startElement($parser, $name, $attrs) // ~X2C
+    {
+        $class = "BIFE_$name";
+        if (!class_exists($class)) {
+            include_once 'BIFE/' . ucfirst(strtolower($name)) . '.php';
+        }
+        if (class_exists($class)) {
+            $obj =& new $class($attrs);
+            if (!is_a($obj, 'bife_widget')) {
+                trigger_error("Class '$class' is not a BIFE_Widget.", E_USER_WARNING);
+            }
+            $this->stack[] =& $obj;
+        } else {
+            trigger_error("Class not found '$class'.", E_USER_ERROR);
+        }
+    }
+    // -X2C
+
+    // +X2C Operation 34
+    /**
+     * XML parser end of element handler.
+     *
+     * @param  resource $parser XML parser resource.
+     * @param  string $name XML tag name.
+     *
+     * @return void
+     * @access public
+     */
+    function endElement($parser, $name) // ~X2C
+    {
+        end($this->stack);
+        $current =& $this->stack[key($this->stack)];
+        array_pop($this->stack);
+        end($this->stack);
+        $parent =& $this->stack[key($this->stack)];
+        if ($parent) {
+            $parent->addContents($current->render($this->template));
+        } else {
+            $this->output = $current->render($this->template);
+        }
+    }
+    // -X2C
+
+    // +X2C Operation 35
+    /**
+     * XML parser character data handler.
+     *
+     * @param  resource $parser XML parser resource.
+     * @param  string $data XML character data.
+     *
+     * @return void
+     * @access public
+     */
+    function characterData($parser, $data) // ~X2C
+    {
+        end($this->stack);
+        $current =& $this->stack[key($this->stack)];
+        $current->addContents($data);
+    }
+    // -X2C
+
+    // +X2C Operation 36
+    /**
+     * Parse a string with XML data.
+     *
+     * @param  string $data XML string to parse.
+     * @param  bool $final Indicates if is the last string to parse.
+     *
+     * @return void
+     * @access public
+     */
+    function parse($data, $final = true) // ~X2C
+    {
+        if (!xml_parse($this->parser, $data, $final)) {
+            trigger_error(
+                sprintf('XML error: %s at line %d.',
+                    xml_error_string(xml_get_error_code($this->parser)),
+                    xml_get_current_line_number($this->parser)
+                ),
+                E_USER_WARNING
+            );
+        }
+    }
+    // -X2C
+
+    // +X2C Operation 37
+    /**
+     * Parse a XML file returning the rendered output.
+     *
+     * @param  string $filename Filename to parse.
+     *
+     * @return void
+     * @access public
+     */
+    function parseFile($filename) // ~X2C
+    {
+        if ($fp = @fopen($filename, "r")) {
+            while ($data = fread($fp, 4096)) {
+                $this->parse($data, feof($fp));
+            }
+        } else {
+            trigger_error("Could not open BIFE XML input file '$filename'.",
+                E_USER_WARNING);
+        }
+        fclose($fp);
+    }
+    // -X2C
+
+    // +X2C Operation 38
+    /**
+     * Get rendered output.
+     *
+     * @return string
+     * @access public
+     */
+    function getOutput() // ~X2C
+    {
+        return $this->output;
+    }
+    // -X2C
+
+} // -X2C Class :Parser
+
+?>
diff --git a/BIFE/Title.php b/BIFE/Title.php
new file mode 100644 (file)
index 0000000..68a0538
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
+// +--------------------------------------------------------------------+
+// |                      BIFE - Buil It Fast & Easy                    |
+// +--------------------------------------------------------------------+
+// | This file is part of BIFE.                                         |
+// |                                                                    |
+// | BIFE is free software; you can redistribute it and/or modify it    |
+// | under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation; either version 2 of the License, or  |
+// | (at your option) any later version.                                |
+// |                                                                    |
+// | BIFE is distributed in the hope that it will be useful, but        |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   |
+// | General Public License for more details.                           |
+// |                                                                    |
+// | You should have received a copy of the GNU General Public License  |
+// | along with Hooks; if not, write to the Free Software Foundation,   |
+// | Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA      |
+// +--------------------------------------------------------------------+
+// | Created: @date
+// | Authors: @author
+// +--------------------------------------------------------------------+
+//
+// $Id$
+//
+
+// +X2C includes
+require_once 'BIFE/Generic.php';
+// ~X2C
+
+// +X2C Class 17 :Title
+/**
+ * Title widget.
+ *
+ * @access public
+ */
+class BIFE_Title extends BIFE_Generic {
+    // ~X2C
+
+    // +X2C Operation 18
+    /**
+     * Constructor.
+     *
+     * @param  array $attrs Attributes.
+     *
+     * @return void
+     * @access public
+     */
+    function BIFE_Title($attrs) // ~X2C
+    {
+        $this->BIFE_Generic($attrs);
+    }
+    // -X2C
+
+} // -X2C Class :Title
+
+?>
\ No newline at end of file
diff --git a/BIFE/Widget.php b/BIFE/Widget.php
new file mode 100644 (file)
index 0000000..36fe7d5
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
+// +--------------------------------------------------------------------+
+// |                      BIFE - Buil It Fast & Easy                    |
+// +--------------------------------------------------------------------+
+// | This file is part of BIFE.                                         |
+// |                                                                    |
+// | BIFE is free software; you can redistribute it and/or modify it    |
+// | under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation; either version 2 of the License, or  |
+// | (at your option) any later version.                                |
+// |                                                                    |
+// | BIFE is distributed in the hope that it will be useful, but        |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   |
+// | General Public License for more details.                           |
+// |                                                                    |
+// | You should have received a copy of the GNU General Public License  |
+// | along with Hooks; if not, write to the Free Software Foundation,   |
+// | Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA      |
+// +--------------------------------------------------------------------+
+// | Created: @date
+// | Authors: @author
+// +--------------------------------------------------------------------+
+//
+// $Id$
+//
+
+// +X2C Class 3 :Widget
+/**
+ * Base widget class.
+ *
+ * @access public
+ * @abstract
+ */
+class BIFE_Widget {
+    // ~X2C
+
+    // +X2C Operation 4
+    /**
+     * Renders the widget returning a string.
+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
+     * @access public
+     * @abstract
+     */
+    function render(&$template) // ~X2C
+    {
+        trigger_error('Method not implemented '.get_class($this).
+            '::addContents().', E_USER_ERROR);
+    }
+    // -X2C
+
+} // -X2C Class :Widget
+
+?>
\ No newline at end of file
index ca1e6c1c20658e4c2d01b712cd3ae73c8c28e5e2..120fc0147a55843b89ba6cdc2310f4316c669a28 100644 (file)
--- a/bife.xmi
+++ b/bife.xmi
@@ -9,7 +9,7 @@
   <XMI.metamodel xmi.name="UML" href="UML.xml" xmi.version="1.3" />
  </XMI.header>
  <XMI.content>
-  <docsettings viewid="2" documentation="" uniqueid="24" />
+  <docsettings viewid="41" documentation="" uniqueid="46" />
   <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="void" abstract="1" documentation="Renders the widget returning a string.
@@ -19,9 +19,7 @@ results." name="render" static="0" scope="200" >
      <UML:Parameter stereotype="" package="" xmi.id="1" value="" type="&amp;HTML_Template_Sigma" abstract="0" documentation="Template object to render the widget." name="template" static="0" scope="200" />
     </UML:Operation>
    </UML:Class>
-   <UML:Class stereotype="" package="BIFE" xmi.id="5" abstract="1" documentation="Base container widget class.
-
-This is a widget that can contain data (and other widgets too)." name="Container" static="0" scope="200" >
+   <UML:Class stereotype="" package="BIFE" xmi.id="5" abstract="1" documentation="Base container widget class." name="Container" static="0" scope="200" >
     <UML:Operation stereotype="" package="" xmi.id="6" type="void" abstract="1" documentation="Adds contents to the container." name="addContents" static="0" scope="200" >
      <UML:Parameter stereotype="" package="" xmi.id="1" value="" type="string" abstract="0" documentation="Contents to add to the container." name="contents" static="0" scope="200" />
     </UML:Operation>
@@ -36,8 +34,8 @@ This is a widget that can contain data (and other widgets too)." name="Container
     <UML:Operation stereotype="" package="" xmi.id="12" type="void" abstract="0" documentation="Renders the widget." name="render" static="0" scope="200" >
      <UML:Parameter stereotype="" package="" xmi.id="1" value="" type="&amp;HTML_Template_Sigma" abstract="0" documentation="Template to use to render the widget." name="template" static="0" scope="200" />
     </UML:Operation>
-    <UML:Attribute stereotype="" package="" xmi.id="8" value="" type="array" abstract="0" documentation="Attribute list." name="attrs" static="0" scope="201" />
-    <UML:Attribute stereotype="" package="" xmi.id="9" value="" type="string" abstract="0" documentation="" name="contents" static="0" scope="201" />
+    <UML:Attribute stereotype="" package="" xmi.id="8" value="" type="array" abstract="0" documentation="Attribute list." name="attrs" static="0" scope="200" />
+    <UML:Attribute stereotype="" package="" xmi.id="9" value="" type="string" abstract="0" documentation="" name="contents" static="0" scope="200" />
    </UML:Class>
    <UML:Class stereotype="" package="BIFE" xmi.id="14" abstract="0" documentation="Page widget." name="Page" static="0" scope="200" >
     <UML:Operation stereotype="" package="" xmi.id="15" type="void" abstract="0" documentation="Constructor." name="BIFE_Page" static="0" scope="200" >
@@ -58,14 +56,48 @@ This is a widget that can contain data (and other widgets too)." name="Container
     <UML:Operation stereotype="" package="" xmi.id="23" type="void" abstract="0" documentation="Renders the widget." name="render" static="0" scope="200" >
      <UML:Parameter stereotype="" package="" xmi.id="1" value="" type="&amp;HTML_Template_Sigma" abstract="0" documentation="Template to use to render the widget." name="template" static="0" scope="200" />
     </UML:Operation>
-    <UML:Attribute stereotype="" package="" xmi.id="21" value="" type="array" abstract="0" documentation="Attributes." name="attrs" static="0" scope="201" />
+    <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="&amp;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="&amp;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="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="2" value="" type="string" abstract="0" documentation="XML tag name." name="name" static="0" scope="200" />
+     <UML:Parameter stereotype="" package="" xmi.id="3" value="" type="array" abstract="0" documentation="XML tag attributes." name="attrs" static="0" scope="200" />
+    </UML:Operation>
+    <UML:Operation stereotype="" package="" xmi.id="34" type="void" abstract="0" documentation="XML parser end of element handler." name="endElement" 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="2" value="" type="string" abstract="0" documentation="XML tag name." name="name" static="0" scope="200" />
+    </UML:Operation>
+    <UML:Operation stereotype="" package="" xmi.id="35" type="void" abstract="0" documentation="XML parser character data handler." name="characterData" 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="2" value="" type="string" abstract="0" documentation="XML character data." name="data" static="0" scope="200" />
+    </UML:Operation>
+    <UML:Operation stereotype="" package="" xmi.id="36" type="void" abstract="0" documentation="Parse a string with XML data." name="parse" 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: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: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" />
    </UML:Class>
   </umlobjects>
   <diagrams>
-   <diagram snapgrid="0" showattsig="1" fillcolor="#ffffc0" showgrid="1" showopsig="1" usefillcolor="1" snapx="10" snapy="10" showatts="1" xmi.id="2" documentation="" type="402" showops="1" showpackage="1" name="class diagram" localid="30000" showstereotype="0" showscope="1" font="Helvetica,10,-1,5,48,0,0,0,0,0" linecolor="#ff0000" >
+   <diagram snapgrid="1" showattsig="1" fillcolor="#ffffc0" showgrid="1" showopsig="1" usefillcolor="1" snapx="10" snapy="10" showatts="1" xmi.id="2" documentation="" type="402" showops="1" showpackage="1" name="Class Diagram" localid="30000" showstereotype="0" showscope="1" font="Helvetica,10,-1,5,48,0,0,0,0,0" linecolor="#ff0000" >
     <widgets>
      <UML:ConceptWidget usesdiagramfillcolour="0" width="104" showattsigs="601" usesdiagramusefillcolour="0" x="170" linecolour="#ff0000" y="70" showopsigs="601" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="28" usefillcolor="1" showattributes="0" xmi.id="3" showoperations="0" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
-     <UML:ConceptWidget usesdiagramfillcolour="0" width="123" showattsigs="601" usesdiagramusefillcolour="0" x="83" linecolour="#ff0000" y="160" showopsigs="601" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="28" usefillcolor="1" showattributes="0" xmi.id="5" showoperations="0" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
+     <UML:ConceptWidget usesdiagramfillcolour="0" width="123" showattsigs="601" usesdiagramusefillcolour="0" x="80" linecolour="#ff0000" y="160" showopsigs="601" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="28" usefillcolor="1" showattributes="0" xmi.id="5" showoperations="0" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
      <UML:ConceptWidget usesdiagramfillcolour="0" width="109" showattsigs="601" usesdiagramusefillcolour="0" x="90" linecolour="#ff0000" y="260" showopsigs="601" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="28" usefillcolor="1" showattributes="0" xmi.id="7" showoperations="0" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
      <UML:ConceptWidget usesdiagramfillcolour="0" width="90" showattsigs="601" usesdiagramusefillcolour="0" x="30" linecolour="#ff0000" y="360" showopsigs="601" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="28" usefillcolor="1" showattributes="0" xmi.id="14" showoperations="0" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
      <UML:ConceptWidget usesdiagramfillcolour="0" width="84" showattsigs="601" usesdiagramusefillcolour="0" x="170" linecolour="#ff0000" y="360" showopsigs="601" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="28" usefillcolor="1" showattributes="0" xmi.id="17" showoperations="0" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
@@ -75,14 +107,14 @@ This is a widget that can contain data (and other widgets too)." name="Container
     <associations>
      <UML:AssocWidget totalcounta="2" indexa="1" totalcountb="3" indexb="1" widgetbid="3" widgetaid="5" documentation="" type="500" >
       <linepath>
-       <startpoint startx="144" starty="160" />
+       <startpoint startx="141" starty="160" />
        <endpoint endx="204" endy="98" />
       </linepath>
      </UML:AssocWidget>
      <UML:AssocWidget totalcounta="2" indexa="1" totalcountb="2" indexb="1" widgetbid="5" widgetaid="7" documentation="" type="500" >
       <linepath>
        <startpoint startx="144" starty="260" />
-       <endpoint endx="144" endy="188" />
+       <endpoint endx="141" endy="188" />
       </linepath>
      </UML:AssocWidget>
      <UML:AssocWidget totalcounta="2" indexa="1" totalcountb="3" indexb="1" widgetbid="7" widgetaid="14" documentation="" type="500" >
@@ -105,35 +137,65 @@ This is a widget that can contain data (and other widgets too)." name="Container
      </UML:AssocWidget>
     </associations>
    </diagram>
+   <diagram snapgrid="0" showattsig="1" fillcolor="#ffffc0" showgrid="0" showopsig="1" usefillcolor="1" snapx="10" snapy="10" showatts="1" xmi.id="41" documentation="" type="403" showops="1" showpackage="0" name="Parse" localid="29998" showstereotype="0" showscope="1" font="Helvetica,12,-1,5,50,0,0,0,0,0" linecolor="#ff0000" >
+    <widgets>
+     <UML:ObjectWidget usesdiagramfillcolour="0" width="71" usesdiagramusefillcolour="0" x="62" linecolour="#ff0000" y="49" instancename="" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="31" usefillcolor="1" length="250" xmi.id="25" decon="0" localid="29999" multipleinstance="0" drawasactor="0" font="Helvetica,12,-1,5,50,0,0,0,0,0" />
+     <UML:ObjectWidget usesdiagramfillcolour="0" width="74" usesdiagramusefillcolour="0" x="478" linecolour="#ff0000" y="49" instancename="" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="31" usefillcolor="1" length="250" xmi.id="3" decon="0" localid="29998" multipleinstance="0" drawasactor="0" font="Helvetica,12,-1,5,50,0,0,0,0,0" />
+    </widgets>
+    <messages>
+     <UML:MessageWidget usesdiagramfillcolour="1" width="416" usesdiagramusefillcolour="1" x="98" linecolour="none" y="119" operation="render(template : &amp;HTML_Template_Sigma) : void" widgetbid="29998" usesdiagramlinecolour="1" fillcolour="none" height="8" usefillcolor="1" seqnum="" widgetaid="29999" textid="42" xmi.id="43" font="helvetica,12,-1,5,50,0,0,0,0,0" />
+    </messages>
+    <associations/>
+   </diagram>
   </diagrams>
   <listview>
    <listitem open="1" type="800" id="-1" label="Views" >
     <listitem open="1" type="801" id="-1" label="Logical View" >
-     <listitem open="0" type="813" id="20" label="Album" >
-      <listitem open="0" type="815" id="22" label="BIFE_Album" />
-      <listitem open="0" type="814" id="21" label="attrs" />
-      <listitem open="0" type="815" id="23" label="render" />
-     </listitem>
-     <listitem open="0" type="813" id="5" label="Container" >
-      <listitem open="0" type="815" id="6" label="addContents" />
-     </listitem>
-     <listitem open="0" type="813" id="7" label="Generic" >
-      <listitem open="0" type="815" id="10" label="BIFE_Generic" />
-      <listitem open="0" type="815" id="11" label="addContents" />
-      <listitem open="0" type="814" id="8" label="attrs" />
-      <listitem open="0" type="814" id="9" label="contents" />
-      <listitem open="0" type="815" id="12" label="render" />
-     </listitem>
-     <listitem open="0" type="813" id="14" label="Page" >
-      <listitem open="0" type="815" id="15" label="BIFE_Page" />
-     </listitem>
-     <listitem open="0" type="813" id="17" label="Title" >
-      <listitem open="0" type="815" id="18" label="BIFE_Title" />
+     <listitem open="1" type="803" id="-1" label="Parser" >
+      <listitem open="1" type="810" id="41" label="Parse" />
+      <listitem open="0" type="813" id="25" label="Parser" >
+       <listitem open="0" type="815" id="30" label="BIFE_Parser" />
+       <listitem open="0" type="815" id="31" label="__construct" />
+       <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="815" id="36" label="parse" />
+       <listitem open="0" type="815" id="37" label="parseFile" />
+       <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" />
+       <listitem open="0" type="814" id="28" label="template" />
+      </listitem>
      </listitem>
-     <listitem open="0" type="813" id="3" label="Widget" >
-      <listitem open="0" type="815" id="4" label="render" />
+     <listitem open="1" type="803" id="-1" label="Widgets" >
+      <listitem open="0" type="813" id="20" label="Album" >
+       <listitem open="0" type="815" id="22" label="BIFE_Album" />
+       <listitem open="0" type="814" id="21" label="attrs" />
+       <listitem open="0" type="815" id="23" label="render" />
+      </listitem>
+      <listitem open="0" type="807" id="2" label="Class Diagram" />
+      <listitem open="0" type="813" id="5" label="Container" >
+       <listitem open="0" type="815" id="6" label="addContents" />
+      </listitem>
+      <listitem open="0" type="813" id="7" label="Generic" >
+       <listitem open="0" type="815" id="10" label="BIFE_Generic" />
+       <listitem open="0" type="815" id="11" label="addContents" />
+       <listitem open="0" type="814" id="8" label="attrs" />
+       <listitem open="0" type="814" id="9" label="contents" />
+       <listitem open="0" type="815" id="12" label="render" />
+      </listitem>
+      <listitem open="0" type="813" id="14" label="Page" >
+       <listitem open="0" type="815" id="15" label="BIFE_Page" />
+      </listitem>
+      <listitem open="0" type="813" id="17" label="Title" >
+       <listitem open="0" type="815" id="18" label="BIFE_Title" />
+      </listitem>
+      <listitem open="0" type="813" id="3" label="Widget" >
+       <listitem open="0" type="815" id="4" label="render" />
+      </listitem>
      </listitem>
-     <listitem open="0" type="807" id="2" label="class diagram" />
     </listitem>
     <listitem open="1" type="802" id="-1" label="Use Case View" />
    </listitem>
index aabb4e9111541916494a00e3ec526acf9bc552de..8451d927e268489c9b9b627d855e79f3f9c08f50 100644 (file)
--- a/index.php
+++ b/index.php
 // BIFE: Build It FastEr - draft 4
 
 require_once 'HTML/Template/Sigma.php';
-require_once 'Album.php';
+require_once 'BIFE/Parser.php';
+require_once 'BIFE/Page.php';
+require_once 'BIFE/Title.php';
+require_once 'BIFE/Album.php';
+#require_once 'BIFE.php';
 
-$file = "simple.xml";
+$file = "simple.xbf";
 
 $template =& new HTML_Template_Sigma('templates');
 $template->setErrorHandling(PEAR_ERROR_PRINT);
 
-$output = '';
-$stack = array();
-
-function startElement($parser, $name, $attrs) {
-    global $stack;
-    $class = "BIFE_$name";
-    if (class_exists($class)) {
-        $obj =& new $class($attrs);
-        if (!is_a($obj, 'bife_base')) {
-            trigger_error("Class '$class' is not a BIFE_Base.", E_USER_WARNING);
-        }
-        $stack[] =& $obj;
-    } else {
-        trigger_error("Class not found '$class'.", E_USER_ERROR);
-    }
-}
-
-function endElement($parser, $name) {
-    global $stack, $template, $output;
-    end($stack);
-    $current =& $stack[key($stack)];
-    array_pop($stack);
-    end($stack);
-    $parent =& $stack[key($stack)];
-    if ($parent) {
-        $parent->addContents($current->process($template));
-    } else {
-        $output = $current->process($template);
-    }
-}
-
-function characterData($parser, $data) {
-    global $stack;
-    end($stack);
-    $current =& $stack[key($stack)];
-    $current->addContents($data);
-}
-
-$xml_parser = xml_parser_create();
-xml_set_element_handler($xml_parser, "startElement", "endElement");
-xml_set_character_data_handler($xml_parser, "characterData");
-if (!($fp = @fopen($file, "r"))) {
-    die("could not open XML input\n");
-}
-
-while ($data = fread($fp, 4096)) {
-    if (!xml_parse($xml_parser, $data, feof($fp))) {
-        die(sprintf("XML error: %s at line %d\n",
-                    xml_error_string(xml_get_error_code($xml_parser)),
-                    xml_get_current_line_number($xml_parser)));
-    }
-}
-xml_parser_free($xml_parser);
-
-class BIFE_Base {
-
-    function BIFE_Base() {
-        trigger_error('Can\'t instanciate abstract class BIFE_Base.',
-            E_USER_ERROR);
-    }
-
-    function process(&$template) {
-        trigger_error('Method not implemented '.get_class($this).
-            '::addContents().', E_USER_ERROR);
-    }
-
-}
-
-class BIFE_Container extends BIFE_Base {
-
-    function BIFE_Container() {
-        trigger_error('Can\'t instanciate abstract class BIFE_Container.',
-            E_USER_ERROR);
-    }
-
-    function addContents($contents) {
-        trigger_error('Method not implemented '.get_class($this).
-            '::addContents().', E_USER_ERROR);
-    }
-
-}
-
-class BIFE_Generic extends BIFE_Container {
-
-    var $attrs;
-    var $contents;
-
-    function BIFE_Generic($attrs) {
-        $this->attrs    = $attrs;
-        $this->contents = '';
-    }
-
-    function addContents($contents) {
-        $this->contents .= trim($contents);
-    }
-
-    function process(&$template) {
-        $template->loadTemplateFile(get_class($this).'.html');
-        $template->setVariable($this->attrs);
-        $template->setVariable('CONTENTS', $this->contents);
-        return $template->get();
-    }
-
-}
-
-class BIFE_Page extends BIFE_Generic {
-    function BIFE_Page($attrs) {
-        $this->BIFE_Generic($attrs);
-    }
-}
-
-class BIFE_Title extends BIFE_Generic {
-    function BIFE_Title($attrs) {
-        $this->BIFE_Generic($attrs);
-    }
-}
-
-class BIFE_Album extends BIFE_Base {
-    var $attrs;
-    function BIFE_Album($attrs) {
-        $defaults = array(
-            'DIR'           => '.',
-            'RECURSIVE'     => true,
-            'THUMBSFORMAT'  => 'jpeg',
-            'THUMBSDIR'     => '.thumbs',
-            'EXTENSIONS'    => 'png,jpg,jpeg,gif',
-            'SELECTED'      => '',
-            'MAXROWS'       => 0,
-            'COLUMNS'       => 4,
-        );
-        $this->attrs = array_merge($defaults, $attrs);
-    }
-    function addContents($contents) {
-        trigger_error('BIFE_Album is not a container, you can\'t add contents.',
-            E_USER_ERROR);
-    }
-    function process(&$template) {
-        extract($this->attrs, EXTR_SKIP);
-        $album =& new Hook_Album($DIR, $RECURSIVE, $THUMBSFORMAT, $THUMBSDIR, $EXTENSIONS);
-        return $album->album($template, $SELECTED, $MAXROWS, $COLUMNS);
-    }
-}
-
-echo $output;
+$parser =& new BIFE_Parser($template);
+$parser->parseFile($file);
+echo $parser->getOutput();
+$parser->__destruct();
 
 ?>
similarity index 53%
rename from simple.xml
rename to simple.xbf
index 8a2fbf2be9860b462e52033c5e4915fbb3834db7..bbf267a43702b2cf40c90264b49664b734c6a815 100644 (file)
@@ -1,4 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <Page title="Hola mundo!" menu="true" use="Album:Perfil">
     <Title>Datos!</Title>
-    <Album dir=".." columns="8"/>
+    <Album dir="imagenes" columns="8"/>
 </Page>
similarity index 100%
rename from photo.html
rename to templates/photo.html