]> git.llucax.com Git - software/bife/base.git/commitdiff
Improved example. 0.11
authorLeandro Lucarella <llucax@gmail.com>
Sun, 6 Jul 2003 05:42:43 +0000 (05:42 +0000)
committerLeandro Lucarella <llucax@gmail.com>
Sun, 6 Jul 2003 05:42:43 +0000 (05:42 +0000)
examples/index.php
examples/index.xbf [new file with mode: 0644]
examples/link.xbf [new file with mode: 0644]

index 5a7e24a28748009d84c150ec259ef32fb721c65c..656561b771bc79b81c158bf9335674afe7afd73f 100644 (file)
@@ -1,5 +1,5 @@
-<?
-// vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
+<?php
+// vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker:
 // +--------------------------------------------------------------------+
 // |                       BIFE - Buil It FastEr                        |
 // +--------------------------------------------------------------------+
 // $Id$
 //
 
-ini_set('include_path', '../src:../../hit/src:../../bife/src:' .
+// Inicialization {{{
+ini_set('include_path', '../src:../../hit/src:../../bife/src:'.
     ini_get('include_path'));
 umask('002');
-
 require_once 'HTML/Template/HIT.php';
 require_once 'BIFE/Parser.php';
 require_once 'BIFE/Translate.php';
+// }}}
 
+// Selects the file to view {{{
 $file = isset($_REQUEST['BIFE']) ? $_REQUEST['BIFE'] : 'index.xbf';
 #$file = isset($_SERVER['PATH_INFO']) ? ".{$_SERVER['PATH_INFO']}" : 'index.xbf';
+// }}}
 
-$template =& new HTML_Template_HIT('templates');
+// Looks if we want to show the source {{{
+if (@$_REQUEST['S']) {
+    if (@$_REQUEST['B']) {
+        // We want to see the BIFE file source.
+        echo '<PRE>';
+        echo htmlentities(join('', file($file)));
+    } else {
+        // We want to see the php file source.
+        highlight_file($_SERVER['SCRIPT_FILENAME']);
+    }
+    exit;
+}
+// }}}
 
-$parser =& new BIFE_Parser('BIFE_Translate');
-$page =& $parser->parseFile($file);
+// If we are not looking at the source, we use BIFE to show the page {{{
+$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/examples/index.xbf b/examples/index.xbf
new file mode 100644 (file)
index 0000000..9b25516
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Page title="Hello world!">
+    <Title>BIFE is working!</Title>
+    <H3>Translate Fallback is working too!</H3>
+    <P>This is a very bad use for BIFE, because I'm writing HTML :-P</P>
+    <Title>A little of 'real' use</Title>
+    <P>Here's a <Link bife="link.xbf">link</Link> to another BIFE file</P>
+    <HR noshade="noshade" size="2"/>
+    <Link data-s="1" data-b="1">View BIFE (xbf) source</Link> |
+    <Link data-s="1">View PHP source</Link>
+</Page>
diff --git a/examples/link.xbf b/examples/link.xbf
new file mode 100644 (file)
index 0000000..41cef67
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Page title="Hi again!">
+    <Title>BIFE Links are working too!</Title>
+    <P>Go <Link bife="index.xbf">back</Link>.</P>
+    <HR noshade="noshade" size="2"/>
+    <Link bife="link.xbf" data-s="1" data-b="1">View BIFE (xbf) source</Link> |
+    <Link data-s="1">View PHP source</Link>
+</Page>