]> git.llucax.com Git - software/bife/bife-all.git/commitdiff
- Implemented Fallback class in the Parser.
authorLeandro Lucarella <llucax@gmail.com>
Thu, 22 May 2003 04:31:40 +0000 (04:31 +0000)
committerLeandro Lucarella <llucax@gmail.com>
Thu, 22 May 2003 04:31:40 +0000 (04:31 +0000)
- Added a simple Fallback class implementation, Copy, that copy the XML
  structure to the rendered output.
- Minor bugfixes.
- Updated example to use Copy Fallback class.

Makefile
doc/bife.xmi
examples/index.php
examples/simple.xbf
src/Album.php
src/BIFE/Copy.php [new file with mode: 0644]
src/BIFE/Parser.php

index f9c68d3624e941e1ce7f1c9a0b52e0e7d94bc930..808da6b2c327ce282e2751fee3ab262de555ead8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -42,3 +42,6 @@ clean-doc:
        rm -fvR doc/api/html doc/api/rtf doc/api/latex
 
 clean: clean-doc clean-backup
+
+tarball:
+       tar --exclude bife/doxygen.warn --exclude .svn --exclude .bak --exclude .swp --exclude 'bife/doc/api/*' -C .. -cvzf ../bife.tar.gz bife
index d2bb8fd5479e73202e88eff4264cd51df3c09741..ece1275812ee280b2e60060a83231ec8d44a0876 100644 (file)
@@ -5,11 +5,11 @@
    <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="/mnt/burns/luca/website/www/test/bife/doc/bife.xmi" />
+  <XMI.model xmi.name="bife" href="/home/llucar/public_html/bife/doc/bife.xmi" />
   <XMI.metamodel xmi.name="UML" href="UML.xml" xmi.version="1.3" />
  </XMI.header>
  <XMI.content>
-  <docsettings viewid="2" documentation="" uniqueid="75" />
+  <docsettings viewid="2" documentation="" uniqueid="84" />
   <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:Operation stereotype="" package="" xmi.id="31" type="void" abstract="0" documentation="Constructor." name="__construct" 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="string" abstract="0" documentation="Fallback class name (none if empty)." name="fallback" 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="string" abstract="0" documentation="Fallback class name (none if empty)." name="fallback" 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: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" />
+    <UML:Attribute stereotype="" package="" xmi.id="84" value="" type="string" abstract="0" documentation="" name="fallback" static="0" scope="200" />
    </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:Parameter stereotype="" package="" xmi.id="2" value="" type="array" abstract="0" documentation="Attributes." name="attrs" static="0" scope="200" />
     </UML:Operation>
    </UML:Class>
+   <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:Parameter stereotype="" package="" xmi.id="2" value="" type="array" abstract="0" documentation="Attributes." name="attrs" static="0" scope="200" />
+    </UML:Operation>
+    <UML:Operation stereotype="" package="" xmi.id="80" 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="Widget name." name="name" static="0" scope="200" />
+     <UML:Parameter stereotype="" package="" xmi.id="2" value="" type="array" abstract="0" documentation="Attributes." name="attrs" static="0" scope="200" />
+    </UML:Operation>
+    <UML:Operation stereotype="" package="" xmi.id="82" type="void" abstract="0" documentation="Renders the widget returning a string with the results." 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="78" value="" type="string" abstract="0" documentation="Widget name." name="name" static="0" scope="200" />
+    <UML:Attribute stereotype="" package="" xmi.id="77" value="" type="array" abstract="0" documentation="Attributes." name="attrs" static="0" scope="200" />
+   </UML:Class>
   </umlobjects>
   <diagrams>
-   <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" >
+   <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" >
     <widgets>
-     <UML:ConceptWidget usesdiagramfillcolour="0" width="104" showattsigs="601" usesdiagramusefillcolour="0" x="270" linecolour="#ff0000" y="30" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="42" usefillcolor="1" showattributes="1" xmi.id="3" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
-     <UML:ConceptWidget usesdiagramfillcolour="0" width="145" showattsigs="601" usesdiagramusefillcolour="0" x="160" linecolour="#ff0000" y="130" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="102" usefillcolor="1" showattributes="1" xmi.id="5" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
-     <UML:ConceptWidget usesdiagramfillcolour="0" width="131" showattsigs="601" usesdiagramusefillcolour="0" x="100" linecolour="#ff0000" y="290" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="102" usefillcolor="1" showattributes="1" xmi.id="7" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
-     <UML:ConceptWidget usesdiagramfillcolour="0" width="120" showattsigs="601" usesdiagramusefillcolour="0" x="30" linecolour="#ff0000" y="460" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="59" usefillcolor="1" showattributes="1" xmi.id="14" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
-     <UML:ConceptWidget usesdiagramfillcolour="0" width="120" showattsigs="600" usesdiagramusefillcolour="0" x="190" linecolour="#ff0000" y="460" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="59" usefillcolor="1" showattributes="1" xmi.id="17" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
-     <UML:ConceptWidget usesdiagramfillcolour="0" width="120" showattsigs="601" usesdiagramusefillcolour="0" x="360" linecolour="#ff0000" y="130" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="85" usefillcolor="1" showattributes="1" xmi.id="20" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
-     <UML:ConceptWidget usesdiagramfillcolour="0" width="134" showattsigs="601" usesdiagramusefillcolour="0" x="260" linecolour="#ff0000" y="290" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="59" usefillcolor="1" showattributes="1" xmi.id="61" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
+     <UML:ConceptWidget usesdiagramfillcolour="0" width="104" showattsigs="601" usesdiagramusefillcolour="0" x="320" linecolour="#ff0000" y="30" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="45" usefillcolor="1" showattributes="1" xmi.id="3" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
+     <UML:ConceptWidget usesdiagramfillcolour="0" width="145" showattsigs="601" usesdiagramusefillcolour="0" x="210" linecolour="#ff0000" y="130" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="108" usefillcolor="1" showattributes="1" xmi.id="5" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
+     <UML:ConceptWidget usesdiagramfillcolour="0" width="131" showattsigs="601" usesdiagramusefillcolour="0" x="120" linecolour="#ff0000" y="310" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="108" usefillcolor="1" showattributes="1" xmi.id="7" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
+     <UML:ConceptWidget usesdiagramfillcolour="0" width="120" showattsigs="601" usesdiagramusefillcolour="0" x="50" linecolour="#ff0000" y="480" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="63" usefillcolor="1" showattributes="1" xmi.id="14" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
+     <UML:ConceptWidget usesdiagramfillcolour="0" width="120" showattsigs="600" usesdiagramusefillcolour="0" x="210" linecolour="#ff0000" y="480" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="63" usefillcolor="1" showattributes="1" xmi.id="17" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
+     <UML:ConceptWidget usesdiagramfillcolour="0" width="120" showattsigs="601" usesdiagramusefillcolour="0" x="410" linecolour="#ff0000" y="130" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="90" usefillcolor="1" showattributes="1" xmi.id="20" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
+     <UML:ConceptWidget usesdiagramfillcolour="0" width="134" showattsigs="601" usesdiagramusefillcolour="0" x="360" linecolour="#ff0000" y="310" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="63" usefillcolor="1" showattributes="1" xmi.id="61" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
+     <UML:ConceptWidget usesdiagramfillcolour="0" width="120" showattsigs="601" usesdiagramusefillcolour="0" x="367" linecolour="#ff0000" y="436" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#ffffc0" height="108" usefillcolor="1" showattributes="1" xmi.id="76" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,10,-1,5,48,0,0,0,0,0" />
     </widgets>
     <messages/>
     <associations>
      <UML:AssocWidget totalcounta="2" indexa="1" totalcountb="3" indexb="1" widgetbid="3" widgetaid="5" documentation="" type="500" >
       <linepath>
-       <startpoint startx="232" starty="130" />
-       <endpoint endx="304" endy="72" />
+       <startpoint startx="282" starty="130" />
+       <endpoint endx="354" endy="75" />
       </linepath>
      </UML:AssocWidget>
      <UML:AssocWidget totalcounta="2" indexa="1" totalcountb="3" indexb="1" widgetbid="5" widgetaid="7" documentation="" type="500" >
       <linepath>
-       <startpoint startx="165" starty="290" />
-       <endpoint endx="208" endy="232" />
+       <startpoint startx="185" starty="310" />
+       <endpoint endx="258" endy="238" />
       </linepath>
      </UML:AssocWidget>
      <UML:AssocWidget totalcounta="2" indexa="1" totalcountb="3" indexb="1" widgetbid="7" widgetaid="14" documentation="" type="500" >
       <linepath>
-       <startpoint startx="90" starty="460" />
-       <endpoint endx="143" endy="392" />
+       <startpoint startx="110" starty="480" />
+       <endpoint endx="163" endy="418" />
       </linepath>
      </UML:AssocWidget>
      <UML:AssocWidget totalcounta="2" indexa="1" totalcountb="3" indexb="2" widgetbid="7" widgetaid="17" documentation="" type="500" >
       <linepath>
-       <startpoint startx="250" starty="460" />
-       <endpoint endx="187" endy="392" />
+       <startpoint startx="270" starty="480" />
+       <endpoint endx="207" endy="418" />
       </linepath>
      </UML:AssocWidget>
      <UML:AssocWidget totalcounta="2" indexa="1" totalcountb="3" indexb="2" widgetbid="3" widgetaid="20" documentation="" type="500" >
       <linepath>
-       <startpoint startx="420" starty="130" />
-       <endpoint endx="339" endy="72" />
+       <startpoint startx="470" starty="130" />
+       <endpoint endx="389" endy="75" />
       </linepath>
      </UML:AssocWidget>
      <UML:AssocWidget totalcounta="2" indexa="1" totalcountb="3" indexb="2" widgetbid="5" widgetaid="61" documentation="" type="500" >
       <linepath>
-       <startpoint startx="327" starty="290" />
-       <endpoint endx="256" endy="232" />
+       <startpoint startx="427" starty="310" />
+       <endpoint endx="306" endy="238" />
+      </linepath>
+     </UML:AssocWidget>
+     <UML:AssocWidget totalcounta="2" indexa="1" totalcountb="2" indexb="1" widgetbid="61" widgetaid="76" documentation="" type="500" >
+      <linepath>
+       <startpoint startx="427" starty="436" />
+       <endpoint endx="427" endy="373" />
       </linepath>
      </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="29" 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="29" 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" />
+     <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" />
        <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="814" id="26" label="root" />
+       <listitem open="0" type="814" id="84" label="fallback" />
        <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="26" label="root" />
        <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="1" type="803" id="-1" label="Widgets" >
        <listitem open="0" type="814" id="47" label="contents" />
        <listitem open="0" type="815" id="59" label="render" />
       </listitem>
+      <listitem open="1" type="813" id="76" label="Copy" >
+       <listitem open="0" type="815" id="79" label="BIFE_Copy" />
+       <listitem open="0" type="815" id="80" label="__construct" />
+       <listitem open="0" type="814" id="77" label="attrs" />
+       <listitem open="0" type="814" id="78" label="name" />
+       <listitem open="0" type="815" id="82" label="render" />
+      </listitem>
       <listitem open="0" type="813" id="61" label="Fallback" >
        <listitem open="0" type="815" id="62" label="BIFE_Fallback" />
        <listitem open="0" type="815" id="63" label="__construct" />
index 18f9ce3e8388621ca1acbbd96af5d5fea17e94f2..cd198be55009f6e7ace6e42a59165105e8da559e 100644 (file)
@@ -32,6 +32,7 @@ unset($tmp);
 
 require_once 'HTML/Template/Sigma.php';
 require_once 'BIFE/Parser.php';
+require_once 'BIFE/Copy.php';
 require_once 'BIFE/Page.php';
 require_once 'BIFE/Title.php';
 require_once 'BIFE/Album.php';
@@ -42,7 +43,7 @@ $file = 'simple.xbf';
 $template =& new HTML_Template_Sigma('templates');
 $template->setErrorHandling(PEAR_ERROR_PRINT);
 
-$parser =& new BIFE_Parser($template);
+$parser =& new BIFE_Parser('BIFE_Copy');
 $page =& $parser->parseFile($file);
 $parser->__destruct();
 echo $page->render($template);
index fe44fa394944df584919fecfeb6fdb58a94ee36c..e3dcd892ffd9de2c6c0ddfce1f1c5ebaf661910b 100644 (file)
@@ -1,5 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Page title="Hola mundo!" menu="true" use="Album:Perfil">
     <Title>Datos!</Title>
+    <H3>Photo album</H3>
     <Album dir="../.." columns="8"/>
+    <HR color="blue" size="3"/>
 </Page>
index 5cb8c8d55059cf6f010389a3a3eb5a26486313d2..24c0826b890cee5b0e16d81c0f1c58af5f651733 100644 (file)
@@ -176,7 +176,7 @@ class Hook_Album {
         $img->load($photo);
         // If image is larger than the maximum size, we resize it.
         if ($img->img_x > $size or $img->img_y > $size ) {
-            if (!is_dir($path) and !mkdir($path)) {
+            if (!@is_dir($path) and !@mkdir($path)) {
                 return false;
             }
             if (PEAR::isError($img)) {
diff --git a/src/BIFE/Copy.php b/src/BIFE/Copy.php
new file mode 100644 (file)
index 0000000..1d39031
--- /dev/null
@@ -0,0 +1,119 @@
+<?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 21 15:55:29 2003                                  |
+// | Authors: Leandro Lucarella <luca@lugmen.org.ar>                    |
+// +--------------------------------------------------------------------+
+//
+// $Id$
+//
+
+// +X2C includes
+require_once 'BIFE/Fallback.php';
+// ~X2C
+
+// +X2C Class 76 :Copy
+/**
+ * Fallback widget that copies the XML.
+ *
+ * @access public
+ */
+class BIFE_Copy extends BIFE_Fallback {
+    /**
+     * Widget name.
+     *
+     * @var    string $name
+     * @access public
+     */
+    var $name;
+
+    /**
+     * Attributes.
+     *
+     * @var    array $attrs
+     * @access public
+     */
+    var $attrs;
+
+    // ~X2C
+
+    // +X2C Operation 79
+    /**
+     * Constructor.
+     *
+     * @param  string $name Widget name.
+     * @param  array $attrs Attributes.
+     *
+     * @return void
+     * @access public
+     */
+    function BIFE_Copy($name, $attrs) // ~X2C
+    {
+        $this->__construct($name, $attrs);
+    }
+    // -X2C
+
+    // +X2C Operation 80
+    /**
+     * Constructor.
+     *
+     * @param  string $name Widget name.
+     * @param  array $attrs Attributes.
+     *
+     * @return void
+     * @access public
+     */
+    function __construct($name, $attrs) // ~X2C
+    {
+        $this->name  = $name;
+        $this->attrs = $attrs;
+    }
+    // -X2C
+
+    // +X2C Operation 82
+    /**
+     * Renders the widget returning a string with the results.
+     *
+     * @param  HTML_Template_Sigma &$template Template to use to render the widget.
+     *
+     * @return void
+     * @access public
+     */
+    function render(&$template) // ~X2C
+    {
+        $name = $this->name;
+        $ret = "<$name";
+        foreach ($this->attrs as $attr => $val) {
+            $ret .= sprintf(' %s="%s"', $attr, $val);
+        }
+        $contents = parent::render($template);
+        if ($contents) {
+            $ret .= ">$contents</$name>";
+        } else {
+            $ret .= "/>";
+        }
+        return $ret;
+    }
+    // -X2C
+
+} // -X2C Class :Copy
+
+?>
index 78ab5b02cf876e9b998d2d18b787598112a958dd..bf9632626a5f523de86227521254ea0b57ecf406 100644 (file)
@@ -50,20 +50,18 @@ class BIFE_Parser {
     var $parser;
 
     /**
-     * Template to use to render the parsed file.
+     * BIFE widgets stack.
      *
-     * @var    HTML_Template_Sigma $template
+     * @var    array $stack
      * @access public
      */
-    var $template;
+    var $stack;
 
     /**
-     * BIFE widgets stack.
-     *
-     * @var    array $stack
+     * @var    string $fallback
      * @access public
      */
-    var $stack;
+    var $fallback;
 
     // ~X2C
 
@@ -71,12 +69,14 @@ class BIFE_Parser {
     /**
      * Constructor.
      *
+     * @param  string $fallback Fallback class name (none if empty).
+     *
      * @return void
      * @access public
      */
-    function BIFE_Parser() // ~X2C
+    function BIFE_Parser($fallback = '') // ~X2C
     {
-        $this->__construct($template);
+        $this->__construct($fallback);
     }
     // -X2C
 
@@ -84,15 +84,17 @@ class BIFE_Parser {
     /**
      * Constructor.
      *
+     * @param  string $fallback Fallback class name (none if empty).
+     *
      * @return void
      * @access public
      */
-    function __construct() // ~X2C
+    function __construct($fallback = '') // ~X2C
     {
         $this->stack    = array();
         $this->root     = null;
         $this->parser   = xml_parser_create();
-        $this->template =& $template;
+        $this->fallback = $fallback;
         xml_set_object($this->parser, $this);
         xml_set_element_handler($this->parser, 'startElement', 'endElement');
         xml_set_character_data_handler($this->parser, 'characterData');
@@ -127,7 +129,7 @@ class BIFE_Parser {
     {
         $class = "BIFE_$name";
         if (!class_exists($class)) {
-            include_once 'BIFE/' . ucfirst(strtolower($name)) . '.php';
+            @include_once 'BIFE/' . ucfirst(strtolower($name)) . '.php';
         }
         if (class_exists($class)) {
             $obj =& new $class($attrs);
@@ -136,7 +138,16 @@ class BIFE_Parser {
             }
             $this->stack[] =& $obj;
         } else {
-            trigger_error("Class not found '$class'.", E_USER_ERROR);
+            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