- Added 'provides' to package.xml.
- Setted svn:ignore to api directories.
- Updated HIT documentation.
--- /dev/null
+<?php
+// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
+// +--------------------------------------------------------------------+
+// | BIFE - Buil It FastEr |
+// +--------------------------------------------------------------------+
+// | 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: Wed May 17 18:16:54 ART 2003 |
+// | Authors: Leandro Lucarella <luca@lugmen.org.ar> |
+// +--------------------------------------------------------------------+
+//
+// $Id$
+//
+
+// +X2C includes
+require_once 'BIFE/Widget.php';
+// ~X2C
+
+// +X2C Class 5 :Container
+/**
+ * Base container widget class.
+ *
+ * @package BIFE
+ * @access public
+ * @abstract
+ */
+class BIFE_Container extends BIFE_Widget {
+ /**
+ * Widget contents.
+ *
+ * @var array $contents
+ * @access public
+ */
+ var $contents = array();
+
+ // ~X2C
+
+ // +X2C Operation 6
+ /**
+ * Adds contents to the container.
+ *
+ * @param mixed &$contents Contents to add to the container.
+ *
+ * @return void
+ * @access public
+ */
+ 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_HIT &$template Template object to render the widget.
+ *
+ * @return string
+ * @access public
+ */
+ function renderContents(&$template) // ~X2C
+ {
+ $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
+
+
+} // -X2C Class :Container
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
+// +--------------------------------------------------------------------+
+// | BIFE - Buil It FastEr |
+// +--------------------------------------------------------------------+
+// | 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: Tue May 20 17:57:56 2003 |
+// | Authors: Leandro Lucarella <luca@lugmen.org.ar> |
+// +--------------------------------------------------------------------+
+//
+// $Id$
+//
+
+// +X2C includes
+require_once 'BIFE/Container.php';
+// ~X2C
+
+// +X2C Class 61 :Fallback
+/**
+ * Fallback widget to use when no specific widget is implemented.
+ *
+ * @package BIFE
+ * @access public
+ * @abstract
+ */
+class BIFE_Fallback extends BIFE_Container {
+ /**
+ * Name of the widget.
+ *
+ * @var string $name
+ * @access private
+ */
+ var $name = '';
+
+ // ~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
+ {
+ $this->__construct($name, $attrs);
+ }
+ // -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
+ {
+ parent::__construct($attrs);
+ $this->name = strtolower(strtr($name, ':', '_'));
+ }
+ // -X2C
+
+} // -X2C Class :Fallback
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
+// +--------------------------------------------------------------------+
+// | BIFE - Buil It FastEr |
+// +--------------------------------------------------------------------+
+// | 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: Sun Jun 1 20:00:20 2003 |
+// | Authors: Leandro Lucarella <luca@lugmen.org.ar> |
+// +--------------------------------------------------------------------+
+//
+// $Id$
+//
+
+// +X2C includes
+require_once 'BIFE/Container.php';
+// ~X2C
+
+// +X2C Class 110 :Link
+/**
+ * Link to another page.
+ *
+ * @package BIFE
+ * @access public
+ */
+class BIFE_Link extends BIFE_Container {
+ // ~X2C
+
+ // +X2C Operation 111
+ /**
+ * Constructor.
+ *
+ * @param array $attrs Attributes.
+ *
+ * @return void
+ * @access public
+ */
+ function BIFE_Link($attrs) // ~X2C
+ {
+ $this->__construct($attrs);
+ }
+ // -X2C
+
+ // +X2C Operation 112
+ /**
+ * Constructor.
+ *
+ * @param array $attrs Attributes.
+ *
+ * @return void
+ * @access public
+ */
+ function __construct($attrs) // ~X2C
+ {
+ $link_attrs['URL'] = $this->getURL($attrs);
+ $link_attrs['DESC'] = @$attrs['DESC'];
+ $link_attrs['TARGET'] = @$attrs['TARGET'];
+ parent::__construct($link_attrs);
+ }
+ // -X2C
+
+ // +X2C Operation 142
+ /**
+ * Gets a URL string based on Link attributes.
+ *
+ * @param array $attrs Link attributes.
+ *
+ * @return string
+ * @access public
+ */
+ function getURL($attrs) // ~X2C
+ {
+ $url = @$attrs['URL'];
+ unset($attrs['URL']);
+ if (isset($attrs['BIFE'])) {
+ $attrs['DATA-BIFE'] = $attrs['BIFE'];
+ unset($attrs['BIFE']);
+ }
+ $query = array();
+ foreach($attrs as $name => $value) {
+ if (substr($name, 0, 5) === 'DATA-') {
+ if ($name = substr($name, 5)) {
+ $query[] = urlencode($name) . '=' . urlencode($value);
+ }
+ }
+ }
+ if ($query) {
+ $url .= '?' . join('&', $query);
+ }
+ return $url;
+ }
+ // -X2C
+
+ // +X2C Operation 157
+ /**
+ * Renders the widget.
+ *
+ * @param HTML_Template_HIT &$template Template to use to render the widget.
+ *
+ * @return string
+ * @access public
+ */
+ function render(&$template) // ~X2C
+ {
+ $this->attrs['CONTENTS'] = $this->renderContents($template);
+ return $template->parse('bife_link', $this->attrs, '', '');
+ }
+ // -X2C
+
+} // -X2C Class :Link
+
+?>
\ No newline at end of file
--- /dev/null
+<?php
+// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
+// +--------------------------------------------------------------------+
+// | BIFE - Buil It FastEr |
+// +--------------------------------------------------------------------+
+// | 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: Wed May 17 18:16:54 ART 2003 |
+// | Authors: Leandro Lucarella <luca@lugmen.org.ar> |
+// +--------------------------------------------------------------------+
+//
+// $Id$
+//
+
+// +X2C Class 25 :Parser
+/**
+ * This is the XML Parser.
+ *
+ * @package BIFE
+ * @access public
+ */
+class BIFE_Parser {
+ /**
+ * Top level widget.
+ *
+ * @var BIFE_Widget $root
+ * @access protected
+ */
+ var $root = null;
+
+ /**
+ * XML parser resource.
+ *
+ * @var resource $parser
+ * @access protected
+ */
+ var $parser = null;
+
+ /**
+ * BIFE widgets stack.
+ *
+ * @var array $stack
+ * @access protected
+ */
+ var $stack = array();
+
+ /**
+ * Fallback class to use in case that a widget class is not found.
+ *
+ * @var string $fallback
+ * @access protected
+ */
+ var $fallback = '';
+
+ /**
+ * XML cache directory. Empty if no cahching must be done (for current dir use '.').
+ *
+ * @var string $cache
+ * @access protected
+ */
+ var $cache = '/tmp';
+
+ /**
+ * Files required by the parsed XML file.
+ *
+ * @var array $requires
+ * @access protected
+ */
+ var $requires = array();
+
+ // ~X2C
+
+ // +X2C Operation 30
+ /**
+ * Constructor.
+ *
+ * @param string $fallback Fallback class name (none if empty).
+ * @param string $cache XML cache directory. Empty is no caching will be done.
+ *
+ * @return void
+ * @access public
+ */
+ function BIFE_Parser($fallback = '', $cache = '/tmp') // ~X2C
+ {
+ $this->__construct($fallback, $cache);
+ }
+ // -X2C
+
+ // +X2C Operation 31
+ /**
+ * Constructor.
+ *
+ * @param string $fallback Fallback class name (none if empty).
+ * @param string $cache XML cache directory. Empty is no caching will be done.
+ *
+ * @return void
+ * @access public
+ */
+ function __construct($fallback = '', $cache = '/tmp') // ~X2C
+ {
+ $this->parser = xml_parser_create();
+ $this->fallback = $fallback;
+ $this->cache = $cache;
+ 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_' . strtolower(strtr($name, ':', '_'));
+ if (!class_exists($class)) {
+ $inc = 'BIFE/' .
+ strtr(ucwords(strtr(strtolower($name), ':', ' ')), ' ', '/') .
+ '.php';
+ if (@include_once $inc) {
+ $this->includes[] = $inc;
+ }
+ }
+ if (class_exists($class)) {
+ $obj =& new $class($attrs);
+ // XXX - Does this check make sense?
+ if (!is_a($obj, 'bife_widget')) {
+ trigger_error("Class '$class' is not a BIFE_Widget.", E_USER_WARNING);
+ }
+ $this->stack[] =& $obj;
+ } else {
+ if ($this->fallback) {
+ $class = $this->fallback;
+ $obj =& new $class($name, $attrs);
+ if (!is_a($obj, 'bife_fallback')) {
+ trigger_error("Class '$class' is not a BIFE_Fallback.", 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);
+ } else {
+ $this->root =& $current;
+ }
+ }
+ // -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 with a complete and valid XML document.
+ *
+ * @param string $filename Filename to parse.
+ *
+ * @return &BIFE_Widget
+ * @access public
+ */
+ function &parseFile($filename) // ~X2C
+ {
+ if ($this->cache) {
+ $cache = $this->cache . '/' . 'bife_parser_cache' . strtr(realpath($filename), '/', '_');
+ if (@filemtime($cache) > @filemtime($filename)) {
+ $file = file($cache);
+ foreach(unserialize(trim(array_shift($file))) as $required) {
+ include_once $required;
+ }
+ return unserialize(join('', $file));
+ }
+ }
+ 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);
+ if ($this->cache) {
+ $fp = fopen($cache, 'w');
+ fputs($fp, serialize($this->includes) . "\n");
+ fputs($fp, serialize($this->root));
+ fclose($fp);
+ }
+ return $this->root;
+ }
+ // -X2C
+
+ // +X2C Operation 74
+ /**
+ * Parse a XML string with a complete and valid XML document.
+ *
+ * @param string $data XML data to parse.
+ *
+ * @return &BIFE_Widget
+ * @access public
+ */
+ function &parseString($data) // ~X2C
+ {
+ $this->parse($data, true);
+ return $this->root;
+ }
+ // -X2C
+
+} // -X2C Class :Parser
+
+?>
\ No newline at end of file
/**
* This is a generic and simple (but very usefull) BIFE_Fallback implementation. Translate widgets using a template with it's name, prepended with 'bife_'. If not template is found, it copy the XML to the output.
*
+ * @package BIFE
* @access public
*/
class BIFE_Translate extends BIFE_Fallback {
} // -X2C Class :Translate
-?>
+?>
\ No newline at end of file
--- /dev/null
+<?php
+// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
+// +--------------------------------------------------------------------+
+// | BIFE - Buil It FastEr |
+// +--------------------------------------------------------------------+
+// | 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: Wed May 17 18:16:54 ART 2003 |
+// | Authors: Leandro Lucarella <luca@lugmen.org.ar> |
+// +--------------------------------------------------------------------+
+//
+// $Id$
+//
+
+// +X2C Class 3 :Widget
+/**
+ * Base widget class.
+ *
+ * @package BIFE
+ * @access public
+ * @abstract
+ */
+class BIFE_Widget {
+ /**
+ * Attribute list.
+ *
+ * @var array $attrs
+ * @access protected
+ */
+ var $attrs = array();
+
+ // ~X2C
+
+ // +X2C Operation 126
+ /**
+ * Constructor.
+ *
+ * @param array $attrs Attributes.
+ *
+ * @return void
+ * @access public
+ */
+ function BIFE_Widget($attrs) // ~X2C
+ {
+ $this->__construct($attrs);
+ }
+ // -X2C
+
+ // +X2C Operation 127
+ /**
+ * Constructor.
+ *
+ * @param array $attrs Attributes.
+ *
+ * @return void
+ * @access public
+ */
+ function __construct($attrs) // ~X2C
+ {
+ $this->attrs = $attrs;
+ }
+ // -X2C
+
+ // +X2C Operation 4
+ /**
+ * Renders the widget using a template returning a string with the results.
+ *
+ * @param HTML_Template_HIT &$template Template object to render the widget.
+ *
+ * @return string
+ * @access public
+ * @abstract
+ */
+ function render(&$template) // ~X2C
+ {
+ trigger_error('Method not implemented '.get_class($this).
+ '::render().', E_USER_ERROR);
+ }
+ // -X2C
+
+} // -X2C Class :Widget
+
+?>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE package SYSTEM "/usr/share/doc/pear/data/PEAR/package.dtd">
+<package version="1.0">
+ <name>BIFE</name>
+ <summary>Build It FastEr</summary>
+ <description>BIFE - Build It FastEr:
+BIFE is a framwork to separate the logic, contents and looks of a PHP
+application, inspired on BIF (Buil It Fast) but with speed and simplicity
+in mind. One of the main goals of BIFE is to be fast.
+ </description>
+ <license>GPL</license>
+ <maintainers>
+ <maintainer>
+ <user>luca</user>
+ <name>Leandro Lucarella</name>
+ <email>luca@lugmen.org.ar</email>
+ <role>lead</role>
+ </maintainer>
+ </maintainers>
+
+ <release>
+ <version>0.11</version>
+ <date>2003-06-29</date>
+ <state>alpha</state>
+ <notes>Check http://www.llucax.hn.org/desarrollo/bife/ for details.</notes>
+ <provides type="class" name="BIFE_Parser"/>
+ <provides type="class" name="BIFE_Widget"/>
+ <provides type="class" name="BIFE_Container"/>
+ <provides type="class" name="BIFE_Fallback"/>
+ <provides type="class" name="BIFE_Link"/>
+ <provides type="class" name="BIFE_Translate"/>
+ <filelist>
+ <!-- PHP -->
+ <file role="php">BIFE/Parser.php</file>
+ <file role="php">BIFE/Widget.php</file>
+ <file role="php">BIFE/Container.php</file>
+ <file role="php">BIFE/Fallback.php</file>
+ <file role="php">BIFE/Link.php</file>
+ <file role="php">BIFE/Translate.php</file>
+ <!-- DOC -->
+ <file role="doc">README</file>
+ <file role="doc">ROADMAP</file>
+ <file role="doc">examples/index.php</file>
+ <file role="doc">examples/index.xbf</file>
+ <file role="doc">examples/templates/bife_page.tpl.html</file>
+ <file role="doc">examples/templates/bife_title.tpl.html</file>
+ <file role="doc">examples/templates/bife_link.tpl.html</file>
+ </filelist>
+ </release>
+ <deps>
+ <dep type="php" rel="ge">4.2.3</dep>
+ <dep type="pkg" rel="ge" version="1.0.0beta">HTML_Template_HIT</dep>
+ </deps>
+</package>