]> git.llucax.com Git - software/bife/base.git/commitdiff
Base package is splited (again), so BIFE no longer depends on
authorLeandro Lucarella <llucax@gmail.com>
Sun, 6 Jul 2003 00:45:56 +0000 (00:45 +0000)
committerLeandro Lucarella <llucax@gmail.com>
Sun, 6 Jul 2003 00:45:56 +0000 (00:45 +0000)
HTML_Template_HIT. A new structure in modules is tested.

BIFE/Link.php [new file with mode: 0644]
BIFE/Translate.php [new file with mode: 0644]
README [new file with mode: 0644]
ROADMAP [new file with mode: 0644]
bife.xmi [new file with mode: 0644]
examples/index.php [new file with mode: 0644]
package.xml [new file with mode: 0644]
xmi2code.config [new file with mode: 0644]

diff --git a/BIFE/Link.php b/BIFE/Link.php
new file mode 100644 (file)
index 0000000..8204db0
--- /dev/null
@@ -0,0 +1,126 @@
+<?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
diff --git a/BIFE/Translate.php b/BIFE/Translate.php
new file mode 100644 (file)
index 0000000..4c1fe05
--- /dev/null
@@ -0,0 +1,77 @@
+<?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/Fallback.php';
+// ~X2C
+
+// +X2C Class 7 :Translate
+/**
+ * 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
+
+    // +X2C Operation 12
+    /**
+     * Renders the widget.
+     *
+     * @param  HTML_Template_HIT &$template Template to use to render the widget.
+     *
+     * @return string
+     * @access public
+     */
+    function render(&$template) // ~X2C
+    {
+        $name = "bife_{$this->name}";
+        if ($template->exists($name, '')) {
+            $this->attrs['CONTENTS'] = $this->renderContents($template);
+            $out = $template->parse($name, $this->attrs, '', '');
+        } else {
+            $name = $this->name;
+            $out = "<$name";
+            foreach ($this->attrs as $attr => $val) {
+                $out .= sprintf(' %s="%s"', $attr, $val);
+            }
+            $contents = $this->renderContents($template);
+            if ($contents !== '') {
+                $out .= ">$contents</$name>";
+            } else {
+                $out .= "/>";
+            }
+        }
+        return $out;
+    }
+    // -X2C
+
+} // -X2C Class :Translate
+
+?>
\ No newline at end of file
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..13737e0
--- /dev/null
+++ b/README
@@ -0,0 +1,6 @@
+$Id$
+
+This is a basic implementation of BIFE to make a simple website or to use it
+to make more complex widgets.
+
+There's a tentative roadmap in ROADMAP.
diff --git a/ROADMAP b/ROADMAP
new file mode 100644 (file)
index 0000000..801d858
--- /dev/null
+++ b/ROADMAP
@@ -0,0 +1,21 @@
+$Id$
+
+
+Version 0.12
+============
+
+    - Look if using $_SERVER['PATH_INFO'] in Link is viable.
+
+
+Version 0.13
+============
+
+    - Start using config file for default widgets attributes.
+
+...
+
+Version 0.x
+============
+    - Make a way to put all classes in a package together in a single file to
+      avoid overhead in require_once calls (to be reviewed).
+
diff --git a/bife.xmi b/bife.xmi
new file mode 100644 (file)
index 0000000..bdf7124
--- /dev/null
+++ b/bife.xmi
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<XMI xmlns:UML="org.omg/standards/UML" verified="false" timestamp="" xmi.version="1.2" >
+ <XMI.header>
+  <XMI.documentation>
+   <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/base/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="159" />
+  <umlobjects>
+   <UML:Class stereotype="" package="BIFE" xmi.id="5" abstract="1" documentation="Base container widget class." name="Container" static="0" scope="200" />
+   <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:Class stereotype="" package="BIFE" xmi.id="7" abstract="0" documentation="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." name="Translate" static="0" scope="200" >
+    <UML:Operation stereotype="" package="" xmi.id="12" type="string" abstract="0" documentation="Renders the widget." name="render" static="0" scope="200" >
+     <UML:Parameter stereotype="" package="" xmi.id="1" value="" type="&amp;HTML_Template_HIT" abstract="0" documentation="Template to use to render the widget." name="template" static="0" scope="200" />
+    </UML:Operation>
+   </UML:Class>
+   <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" />
+    </UML:Operation>
+    <UML:Operation stereotype="" package="" xmi.id="112" type="void" abstract="0" documentation="Constructor." name="__construct" 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:Operation stereotype="" package="" xmi.id="142" type="string" abstract="0" documentation="Gets a URL string based on Link attributes." name="getURL" static="0" scope="200" >
+     <UML:Parameter stereotype="" package="" xmi.id="1" value="" type="array" abstract="0" documentation="Link attributes." name="attrs" static="0" scope="200" />
+    </UML:Operation>
+    <UML:Operation stereotype="" package="" xmi.id="157" type="string" abstract="0" documentation="Renders the widget." name="render" static="0" scope="200" >
+     <UML:Parameter stereotype="" package="" xmi.id="1" value="" type="&amp;HTML_Template_HIT" abstract="0" documentation="Template to use to render the widget." name="template" static="0" scope="200" />
+    </UML:Operation>
+   </UML:Class>
+  </umlobjects>
+  <diagrams>
+   <diagram snapgrid="0" showattsig="1" fillcolor="#ffffc0" showgrid="1" showopsig="0" usefillcolor="1" snapx="10" snapy="10" showatts="1" xmi.id="2" documentation="" type="402" showops="1" showpackage="1" name="Basic 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="106" showattsigs="600" usesdiagramusefillcolour="0" x="82" linecolour="#ff0000" y="11" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#dcdcdc" height="25" usefillcolor="1" showattributes="0" xmi.id="5" showoperations="0" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,9,-1,5,48,0,0,0,0,0" />
+     <UML:ConceptWidget usesdiagramfillcolour="0" width="97" showattsigs="601" usesdiagramusefillcolour="0" x="15" linecolour="#ff0000" y="90" showopsigs="600" usesdiagramlinecolour="0" fillcolour="#dcdcdc" height="25" usefillcolor="1" showattributes="0" xmi.id="61" showoperations="0" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,9,-1,5,48,0,0,0,0,0" />
+     <UML:ConceptWidget usesdiagramfillcolour="1" width="107" showattsigs="601" usesdiagramusefillcolour="1" x="152" linecolour="none" y="89" showopsigs="600" usesdiagramlinecolour="1" fillcolour="none" height="82" usefillcolor="1" showattributes="1" xmi.id="110" showoperations="1" showpackage="1" showscope="1" showstereotype="0" font="Helvetica,9,-1,5,48,0,0,0,0,0" />
+     <UML:ConceptWidget usesdiagramfillcolour="1" width="104" showattsigs="601" usesdiagramusefillcolour="1" x="11" linecolour="none" y="150" showopsigs="600" usesdiagramlinecolour="1" fillcolour="none" height="37" usefillcolor="1" showattributes="1" xmi.id="7" showoperations="1" 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="3" indexb="1" widgetbid="5" widgetaid="61" documentation="" type="500" >
+      <linepath>
+       <startpoint startx="63" starty="90" />
+       <endpoint endx="117" endy="36" />
+      </linepath>
+     </UML:AssocWidget>
+     <UML:AssocWidget totalcounta="2" indexa="1" totalcountb="3" indexb="2" widgetbid="5" widgetaid="110" documentation="" type="500" >
+      <linepath>
+       <startpoint startx="205" starty="89" />
+       <endpoint endx="152" endy="36" />
+      </linepath>
+     </UML:AssocWidget>
+     <UML:AssocWidget totalcounta="2" indexa="1" totalcountb="2" indexb="1" widgetbid="61" widgetaid="7" documentation="" type="500" >
+      <linepath>
+       <startpoint startx="63" starty="150" />
+       <endpoint endx="63" endy="115" />
+      </linepath>
+     </UML:AssocWidget>
+    </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="1" type="803" id="-1" label="BIFE" >
+      <listitem open="0" type="807" id="2" label="Basic Classes" />
+      <listitem open="0" type="813" id="5" label="Container" />
+      <listitem open="0" type="813" id="61" label="Fallback" />
+      <listitem open="0" type="813" id="110" label="Link" >
+       <listitem open="0" type="815" id="111" label="BIFE_Link" />
+       <listitem open="0" type="815" id="112" label="__construct" />
+       <listitem open="0" type="815" id="142" label="getURL" />
+       <listitem open="0" type="815" id="157" label="render" />
+      </listitem>
+      <listitem open="0" type="813" id="7" label="Translate" >
+       <listitem open="0" type="815" id="12" label="render" />
+      </listitem>
+     </listitem>
+    </listitem>
+    <listitem open="1" type="802" id="-1" label="Use Case View" />
+   </listitem>
+  </listview>
+ </XMI.content>
+</XMI>
diff --git a/examples/index.php b/examples/index.php
new file mode 100644 (file)
index 0000000..c38ac9c
--- /dev/null
@@ -0,0 +1,48 @@
+<?
+// 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$
+//
+
+$tmp = ini_get('include_path');
+ini_set('include_path', "..:$tmp");
+unset($tmp);
+umask('002');
+
+require_once 'HTML/Template/HIT.php';
+require_once 'BIFE/Parser.php';
+require_once 'BIFE/Translate.php';
+
+$file = isset($_REQUEST['BIFE']) ? $_REQUEST['BIFE'] : 'index.xbf';
+#$file = isset($_SERVER['PATH_INFO']) ? ".{$_SERVER['PATH_INFO']}" : 'index.xbf';
+
+$template =& new HTML_Template_HIT('templates');
+
+$parser =& new BIFE_Parser('BIFE_Translate');
+$page =& $parser->parseFile($file);
+$parser->__destruct();
+echo $page->render($template);
+
+?>
diff --git a/package.xml b/package.xml
new file mode 100644 (file)
index 0000000..3cfff25
--- /dev/null
@@ -0,0 +1,44 @@
+<?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_Base</name>
+    <summary>BIFE's basic implementation to make a simple website</summary>
+    <description>BIFE Base (tbd) <!-- TODO -->
+    </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>1.0.0beta1</version>
+        <date>2003-06-29</date>
+        <state>beta</state>
+        <notes>Check http://bife.llucax.hn.org/ for details.</notes>
+        <provides type="class" name="BIFE_Link"/>
+        <provides type="class" name="BIFE_Translate"/>
+        <filelist>
+            <!-- PHP -->
+            <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.0beta1">BIFE</dep>
+        <dep type="pkg" rel="ge" version="1.0.0beta1">HTML_Template_HIT</dep>
+    </deps>
+</package>
diff --git a/xmi2code.config b/xmi2code.config
new file mode 100644 (file)
index 0000000..7540819
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ! 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: Mon May 19 00:16:56 ART 2003                              *
+ ! * Authors: Leandro Lucarella <luca@lugmen.org.ar>                    *
+ ! *********************************************************************+
+ ! 
+ ! $Id$
+ ! 
+ !-->
+
+<xmi2code>
+  <option key="target" value="*"/>
+  <option key="xmi-input" value="base.xmi"/>
+  <option key="config-file" value="xmi2code.config"/>
+  <option key="config-file-set" value="false"/>
+  <option key="handler" value="umbrello"/>
+  <option key="generator-path" value="."/>
+  <option key="use-package-as-dir" value="true"/>
+  <option key="indent" value="    "/>
+  <option key="files-case" value="preserve"/>
+  <option key="generator" value="php.pear"/>
+  <option key="template-path" value="."/>
+  <option key="php.template" value="xmi2code.tpl.php"/>
+  <option key="php.default-code" value="trigger_error('Not implemented!', E_USER_WARNING);"/>
+  <option key="php.pear.use-package-in-classnames" value="true"/>
+  <option key="php.pear.underscore-in-nonpublic" value="false"/>
+</xmi2code>