- bife module is now called core and moved out from modules dir.
- Fixed Parser to autoinclude files.
- Root lost its sense since 'use' attribute lost it sense with Parser
autoinclude (now the parser manages all needed includes). It might
be gone in the future.
- Updated example (it's working again).
- Updated Makefiles (need some more work).
* Top level widget.
*
* @var BIFE_Root $root
- * @access public
+ * @access protected
*/
- var $root;
+ var $root = null;
/**
* XML parser resource.
*
* @var resource $parser
- * @access public
+ * @access protected
*/
- var $parser;
+ var $parser = null;
/**
* BIFE widgets stack.
*
* @var array $stack
- * @access public
+ * @access protected
*/
- var $stack;
+ var $stack = array();
/**
* Fallback class to use in case that a widget class is not found.
*
* @var string $fallback
- * @access public
+ * @access protected
*/
var $fallback = '';
*/
var $cache = '/tmp';
+ /**
+ * Files required by the parsed XML file.
+ *
+ * @var array $requires
+ * @access protected
+ */
+ var $requires = array();
+
// ~X2C
// +X2C Operation 30
*/
function __construct($fallback = '', $cache = '/tmp') // ~X2C
{
- $this->stack = array();
- $this->root = null;
$this->parser = xml_parser_create();
$this->fallback = $fallback;
$this->cache = $cache;
*/
function startElement($parser, $name, $attrs) // ~X2C
{
- $class = "BIFE_$name";
+ $class = 'bife_' . strtolower(strtr($name, ':', '_'));
if (!class_exists($class)) {
- @include_once 'BIFE/' . ucfirst(strtolower($name)) . '.php';
+ $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);
}
if ($this->cache) {
$cache = $this->cache . '/' . 'bife_parser_cache' . strtr(realpath($filename), '/', '_');
if (@filemtime($cache) > @filemtime($filename)) {
- // FIXME - replace with file_get_contents()
$file = file($cache);
foreach(unserialize(trim(array_shift($file))) as $required) {
- require_once $required;
+ include_once $required;
}
return unserialize(join('', $file));
}
fclose($fp);
if ($this->cache) {
$fp = fopen($cache, 'w');
- fputs($fp, serialize($this->root->getRequiredFiles()) . "\n");
+ fputs($fp, serialize($this->includes) . "\n");
fputs($fp, serialize($this->root));
fclose($fp);
}
}
// -X2C
-
// +X2C Operation 74
/**
* Parse a XML string with a complete and valid XML document.
} // -X2C Class :Parser
-?>
\ No newline at end of file
+?>
*/
function __construct($attrs) // ~X2C
{
+ /*
if (@$attrs['USE']) {
foreach (split(':', $attrs['USE']) as $require) {
require_once "BIFE/$require.php";
}
unset($attrs['USE']);
}
+ */
parent::__construct($attrs);
}
// -X2C
// +X2C Operation 150
/**
- * Gets required files.
+ * Gets required files. (FIXME - DEPRECATED)
*
* @return array
* @access public
} // -X2C Class :Root
-?>
\ No newline at end of file
+?>
# $Id$
#
+VERSION=0.10
+MODULE_FILE=BIFE.php
+MODULE_NAME=Core
+PHP_FILES=$(filter-out $(MODULE_FILE),$(subst ./,,$(shell find -name '*.php')))
+X2C_TEMPLATE=../xmi2code.tpl.php
+
+all: $(MODULE_FILE)
+
code: bife.xmi xmi2code.config
@xmi2code
-clean-code:
+code-clean:
@find -name '*.bak' | xargs rm -vf
-clean: clean-code
-
+$(MODULE_FILE): code $(PHP_FILES) $(X2C_TEMPLATE)
+ @( \
+ ( \
+ cat $(X2C_TEMPLATE) | \
+ grep -v '@@date' | \
+ grep -v '$$Id' | \
+ egrep -v '^//$$' \
+ ); \
+ echo '//'; \
+ echo -n '// BIFE $(MODULE_NAME) (version $(VERSION)) - '; \
+ date; \
+ echo '//'; \
+ ( \
+ cat $(PHP_FILES) | \
+ grep -v require_once | \
+ grep -v '?>' | \
+ grep -v '<?php' | \
+ egrep -v '^\s*//' \
+ ); \
+ echo -n '?>' \
+ ) > $(MODULE_FILE)
<XMI.exporter>umbrello uml modeller http://uml.sf.net</XMI.exporter>
<XMI.exporterVersion>1.1</XMI.exporterVersion>
</XMI.documentation>
- <XMI.model xmi.name="bife" href="/home/luca/website/www/test/bife/doc/uml/bife.xmi" />
+ <XMI.model xmi.name="bife" href="/home/luca/website/www/test/bife/core/bife.xmi" />
<XMI.metamodel xmi.name="UML" href="UML.xml" xmi.version="1.3" />
</XMI.header>
<XMI.content>
- <docsettings viewid="2" documentation="Parse XML data getting widgets." uniqueid="155" />
+ <docsettings viewid="2" documentation="Parse XML data getting widgets." uniqueid="156" />
<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="126" type="void" abstract="0" documentation="Constructor." name="BIFE_Widget" static="0" scope="200" >
<UML:Operation stereotype="" package="" xmi.id="74" type="&BIFE_Root" 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_Root" 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="29" value="" type="array" abstract="0" documentation="BIFE widgets stack." name="stack" static="0" scope="200" />
- <UML:Attribute stereotype="" package="" xmi.id="84" value="''" type="string" abstract="0" documentation="Fallback class to use in case that a widget class is not found." name="fallback" static="0" scope="200" />
+ <UML:Attribute stereotype="" package="" xmi.id="26" value="null" type="BIFE_Root" abstract="0" documentation="Top level widget." name="root" static="0" scope="202" />
+ <UML:Attribute stereotype="" package="" xmi.id="27" value="null" type="resource" abstract="0" documentation="XML parser resource." name="parser" static="0" scope="202" />
+ <UML:Attribute stereotype="" package="" xmi.id="29" value="array()" type="array" abstract="0" documentation="BIFE widgets stack." name="stack" static="0" scope="202" />
+ <UML:Attribute stereotype="" package="" xmi.id="84" value="''" type="string" abstract="0" documentation="Fallback class to use in case that a widget class is not found." name="fallback" static="0" scope="202" />
<UML:Attribute stereotype="" package="" xmi.id="148" value="'/tmp'" type="string" abstract="0" documentation="XML cache directory. Empty if no cahching must be done (for current dir use '.')." name="cache" static="0" scope="202" />
+ <UML:Attribute stereotype="" package="" xmi.id="156" value="array()" type="array" abstract="0" documentation="Files required by the parsed XML file." name="requires" static="0" scope="202" />
</UML:Class>
<UML:Class stereotype="" package="BIFE" xmi.id="61" abstract="1" documentation="Fallback widget to use when no specific widget is implemented." name="Fallback" static="0" scope="200" >
<UML:Operation stereotype="" package="" xmi.id="62" type="void" abstract="0" documentation="Constructor." name="BIFE_Fallback" static="0" scope="200" >
<UML:Operation stereotype="" package="" xmi.id="88" type="void" abstract="0" documentation="Constructor." name="__construct" static="0" scope="200" >
<UML:Parameter stereotype="" package="" xmi.id="1" value="" type="string" abstract="0" documentation="Attributes." name="attrs" static="0" scope="200" />
</UML:Operation>
- <UML:Operation stereotype="" package="" xmi.id="150" type="array" abstract="0" documentation="Gets required files." name="getRequiredFiles" static="0" scope="200" />
+ <UML:Operation stereotype="" package="" xmi.id="150" type="array" abstract="0" documentation="Gets required files. (FIXME - DEPRECATED)" name="getRequiredFiles" static="0" scope="200" />
<UML:Attribute stereotype="" package="" xmi.id="149" value="array()" type="array" abstract="0" documentation="Root widget's required files." name="required" static="0" scope="202" />
</UML:Class>
<UML:Class stereotype="" package="HTML/Template" xmi.id="130" abstract="0" documentation="Hooks vs. IT (HIT) is a simple template implementation, based on hooks and IT template systems." name="HIT" static="0" scope="200" >
<UML:ConceptWidget usesdiagramfillcolour="0" width="127" showattsigs="601" usesdiagramusefillcolour="0" x="91" linecolour="#ff0000" y="150" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="90" usefillcolor="1" showattributes="1" xmi.id="5" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,9,-1,5,48,0,0,0,0,0" />
<UML:ConceptWidget usesdiagramfillcolour="0" width="118" showattsigs="601" usesdiagramusefillcolour="0" x="31" linecolour="#ff0000" y="319" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="60" usefillcolor="1" showattributes="1" xmi.id="61" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,9,-1,5,48,0,0,0,0,0" />
<UML:ConceptWidget usesdiagramfillcolour="0" width="168" showattsigs="601" usesdiagramusefillcolour="0" x="191" linecolour="#ff0000" y="319" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="75" usefillcolor="1" showattributes="1" xmi.id="85" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,9,-1,5,48,0,0,0,0,0" />
- <UML:ConceptWidget usesdiagramfillcolour="0" width="156" showattsigs="601" usesdiagramusefillcolour="0" x="301" linecolour="#ff0000" y="20" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="225" usefillcolor="1" showattributes="1" xmi.id="25" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,9,-1,5,48,0,0,0,0,0" />
+ <UML:ConceptWidget usesdiagramfillcolour="0" width="168" showattsigs="601" usesdiagramusefillcolour="0" x="301" linecolour="#ff0000" y="20" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="240" usefillcolor="1" showattributes="1" xmi.id="25" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,9,-1,5,48,0,0,0,0,0" />
</widgets>
<messages/>
<associations>
<listitem open="0" type="815" id="63" label="__construct" />
<listitem open="0" type="814" id="129" label="name" />
</listitem>
- <listitem open="0" type="813" id="25" label="Parser" >
+ <listitem open="1" 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="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="156" label="requires" />
<listitem open="0" type="814" id="26" label="root" />
<listitem open="0" type="814" id="29" label="stack" />
<listitem open="0" type="815" id="33" label="startElement" />
// $Id$
//
+$incs = array(
+ '../core',
+ '../modules/album',
+ '../modules/basic',
+ '../modules/menu',
+// '../modules/',
+);
$tmp = ini_get('include_path');
-ini_set('include_path', "../src:$tmp");
+ini_set('include_path', join(':', $incs) . ":$tmp");
unset($tmp);
umask('002');
require_once 'HTML/Template/HIT.php';
require_once 'BIFE/Parser.php';
require_once 'BIFE/Copy.php';
-require_once 'BIFE/Page.php';
-require_once 'BIFE/Title.php';
require_once 'BIFE/Link.php';
-#require_once 'BIFE/Album.php';
-#require_once 'BIFE/AlbumPhoto.php';
-#require_once 'BIFE.php';
$file = isset($_REQUEST['BIFE']) ? $_REQUEST['BIFE'] : 'index.xbf';
<?xml version="1.0" encoding="UTF-8"?>
-<Page title="Hola mundo!" menu="true" use="Album">
+<Page title="Hola mundo!" menu="true">
<Title>Datos!</Title>
<H3>Photo album</H3>
- <Album dir="../.." columns="8"/>
+ <Album:Thumbs dir="../.." columns="8"/>
<HR color="blue" size="3"/>
</Page>
<?xml version="1.0" encoding="UTF-8"?>
<Page title="Foto" use="AlbumPhoto">
- <AlbumPhoto/>
+ <Album:Photo/>
</Page>
// +X2C includes
-require_once 'BIFE.php';
+require_once 'BIFE/Widget.php';
// ~X2C
// +X2C Class 151 :Pager
//
// +X2C includes
-require_once 'BIFE.php';
+require_once 'BIFE/Widget.php';
// ~X2C
// +X2C Class 103 :Photo
//
// +X2C includes
-require_once 'BIFE.php';
+require_once 'BIFE/Widget.php';
// ~X2C
require_once 'Image/Transform.php';
# $Id$
#
-code: album.xmi xmi2code.config
+MODULE=album
+
+code: $(MODULE).xmi xmi2code.config
@xmi2code
-clean-code:
+code-clean:
@find -name '*.bak' | xargs rm -vf
-clean: clean-code
-
<docsettings viewid="114" documentation="Parse XML data getting widgets." uniqueid="155" />
<umlobjects>
<UML:Class stereotype="" package="BIFE" xmi.id="3" abstract="1" documentation="Base widget class.
-x2c:extern
-x2c:include: BIFE.php" name="Widget" static="0" scope="200" />
+x2c:extern" name="Widget" static="0" scope="200" />
<UML:Class stereotype="" package="BIFE/Album" xmi.id="20" abstract="0" documentation="Photo album widget. [TODO: Make a better explanation]" name="Thumbs" static="0" scope="200" >
<UML:Operation stereotype="" package="" xmi.id="22" type="void" abstract="0" documentation="Constructor." name="BIFE_Album_Thumbs" static="0" scope="200" >
<UML:Parameter stereotype="" package="" xmi.id="1" value="" type="array" abstract="0" documentation="Attributes." name="attrs" static="0" scope="200" />
//
// +X2C includes
-require_once 'BIFE.php';
+require_once 'BIFE/Fallback.php';
// ~X2C
// +X2C Class 76 :Copy
//
// +X2C includes
-require_once 'BIFE.php';
+require_once 'BIFE/Container.php';
// ~X2C
// +X2C Class 7 :Generic
//
// +X2C includes
-require_once 'BIFE.php';
+require_once 'BIFE/Root.php';
// ~X2C
// +X2C Class 14 :Page
# $Id$
#
-code: basic.xmi xmi2code.config
+MODULE=basic
+
+code: $(MODULE).xmi xmi2code.config
@xmi2code
-clean-code:
+code-clean:
@find -name '*.bak' | xargs rm -vf
-clean: clean-code
-
<XMI.exporter>umbrello uml modeller http://uml.sf.net</XMI.exporter>
<XMI.exporterVersion>1.1</XMI.exporterVersion>
</XMI.documentation>
- <XMI.model xmi.name="basic" href="/home/luca/website/www/test/bife/doc/uml/basic.xmi" />
+ <XMI.model xmi.name="basic" href="/home/luca/website/www/test/bife/modules/basic/basic.xmi" />
<XMI.metamodel xmi.name="UML" href="UML.xml" xmi.version="1.3" />
</XMI.header>
<XMI.content>
<docsettings viewid="113" documentation="Parse XML data getting widgets." uniqueid="155" />
<umlobjects>
<UML:Class stereotype="" package="BIFE" xmi.id="5" abstract="1" documentation="Base container widget class.
-x2c:extern
-x2c:include: BIFE.php" name="Container" static="0" scope="200" />
+x2c:extern" name="Container" static="0" scope="200" />
<UML:Class stereotype="" package="BIFE" xmi.id="7" abstract="1" documentation="This is a generic and simple BIFE_Container implementation." name="Generic" static="0" scope="200" >
<UML:Operation stereotype="" package="" xmi.id="10" type="void" abstract="0" documentation="Constructor." name="BIFE_Generic" static="0" scope="200" >
<UML:Parameter stereotype="" package="" xmi.id="1" value="" type="array" abstract="0" documentation="Attributes." name="attrs" static="0" scope="200" />
</UML:Operation>
</UML:Class>
<UML:Class stereotype="" package="BIFE" xmi.id="61" abstract="1" documentation="Fallback widget to use when no specific widget is implemented.
-x2c:extern
-x2c:include: BIFE.php" name="Fallback" static="0" scope="200" />
+x2c:extern" name="Fallback" static="0" scope="200" />
<UML:Class stereotype="" package="BIFE" xmi.id="76" abstract="0" documentation="Fallback widget that copies the XML." name="Copy" static="0" scope="200" >
<UML:Operation stereotype="" package="" xmi.id="79" type="void" abstract="0" documentation="Constructor." name="BIFE_Copy" static="0" scope="200" >
<UML:Parameter stereotype="" package="" xmi.id="1" value="" type="string" abstract="0" documentation="Widget name." name="name" static="0" scope="200" />
</UML:Operation>
</UML:Class>
<UML:Class stereotype="" package="BIFE" xmi.id="85" abstract="1" documentation="Root container class.
-x2c:extern
-x2c:include: BIFE.php" name="Root" static="0" scope="200" />
+x2c:extern" name="Root" static="0" scope="200" />
<UML:Class stereotype="" package="BIFE" xmi.id="110" abstract="0" documentation="Link to another page." name="Link" static="0" scope="200" >
<UML:Operation stereotype="" package="" xmi.id="111" type="void" abstract="0" documentation="Constructor." name="BIFE_Link" static="0" scope="200" >
<UML:Parameter stereotype="" package="" xmi.id="1" value="" type="array" abstract="0" documentation="Attributes." name="attrs" static="0" scope="200" />
// +X2C includes
-require_once 'BIFE.php';
+require_once 'BIFE/Widget.php';
// ~X2C
// +X2C Class 115 :Menu
# $Id$
#
-code: menu.xmi xmi2code.config
+MODULE=menu
+
+code: $(MODULE).xmi xmi2code.config
@xmi2code
-clean-code:
+code-clean:
@find -name '*.bak' | xargs rm -vf
-clean: clean-code
-
<docsettings viewid="116" documentation="Parse XML data getting widgets." uniqueid="156" />
<umlobjects>
<UML:Class stereotype="" package="BIFE" xmi.id="3" abstract="1" documentation="Base widget class.
-x2c:extern
-x2c:include: BIFE.php" name="Widget" static="0" scope="200" />
+x2c:extern" name="Widget" static="0" scope="200" />
<UML:Class stereotype="" package="BIFE/Menu" xmi.id="115" abstract="0" documentation="Dynamic Menu." name="Menu" static="0" scope="200" >
<UML:Operation stereotype="" package="" xmi.id="121" type="void" abstract="0" documentation="Constructor." name="BIFE_Menu_Menu" static="0" scope="200" >
<UML:Parameter stereotype="" package="" xmi.id="1" value="" type="array" abstract="0" documentation="Attributes." name="attrs" static="0" scope="200" />
<diagrams>
<diagram snapgrid="0" showattsig="1" fillcolor="#ffffc0" showgrid="1" showopsig="0" usefillcolor="1" snapx="10" snapy="10" showatts="1" xmi.id="116" documentation="" type="402" showops="1" showpackage="1" name="Menu Classes" localid="30000" showstereotype="0" showscope="1" font="Helvetica,9,-1,5,48,0,0,0,0,0" linecolor="#ff0000" >
<widgets>
- <UML:ConceptWidget usesdiagramfillcolour="0" width="145" showattsigs="601" usesdiagramusefillcolour="0" x="61" linecolour="#ff0000" y="138" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="67" usefillcolor="1" showattributes="1" xmi.id="115" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,9,-1,5,48,0,0,0,0,0" />
+ <UML:ConceptWidget usesdiagramfillcolour="0" width="145" showattsigs="601" usesdiagramusefillcolour="0" x="50" linecolour="#ff0000" y="137" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="67" usefillcolor="1" showattributes="1" xmi.id="115" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,9,-1,5,48,0,0,0,0,0" />
<UML:ConceptWidget usesdiagramfillcolour="0" width="90" showattsigs="600" usesdiagramusefillcolour="0" x="77" linecolour="#ff0000" y="51" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#dcdcdc" height="25" usefillcolor="1" showattributes="0" xmi.id="3" showoperations="0" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,9,-1,5,48,0,0,0,0,0" />
</widgets>
<messages/>
<associations>
<UML:AssocWidget totalcounta="2" indexa="1" totalcountb="2" indexb="1" widgetbid="3" widgetaid="115" documentation="" type="500" >
<linepath>
- <startpoint startx="133" starty="138" />
+ <startpoint startx="122" starty="137" />
<endpoint endx="122" endy="76" />
</linepath>
</UML:AssocWidget>