]> git.llucax.com Git - mecon/meconlib.git/commitdiff
Se agrega un ejemplo sobre la utilizacion de MLIB_Tpl_FileDir.
authorMartín Marrese <marrese@gmail.com>
Fri, 30 Jul 2004 21:23:25 +0000 (21:23 +0000)
committerMartín Marrese <marrese@gmail.com>
Fri, 30 Jul 2004 21:23:25 +0000 (21:23 +0000)
Quizas no se entienda demasiado pero sirve igual.

16 files changed:
test/Tpl/FileDir/TPLS/body.tpl.html [new file with mode: 0755]
test/Tpl/FileDir/TPLS/body/cell.tpl.html [new file with mode: 0755]
test/Tpl/FileDir/TPLS/body/row.tpl.html [new file with mode: 0755]
test/Tpl/FileDir/TPLS/body/table.tpl.html [new file with mode: 0755]
test/Tpl/FileDir/TPLS/footer/cell.tpl.html [new file with mode: 0755]
test/Tpl/FileDir/TPLS/footer/link_meconlib_dev.tpl.html [new file with mode: 0755]
test/Tpl/FileDir/TPLS/footer/row.tpl.html [new file with mode: 0755]
test/Tpl/FileDir/TPLS/footer/table.tpl.html [new file with mode: 0755]
test/Tpl/FileDir/TPLS/footer/text.tpl.html [new file with mode: 0755]
test/Tpl/FileDir/TPLS/header/cell.tpl.html [new file with mode: 0755]
test/Tpl/FileDir/TPLS/header/logo.tpl.html [new file with mode: 0755]
test/Tpl/FileDir/TPLS/header/row.tpl.html [new file with mode: 0755]
test/Tpl/FileDir/TPLS/header/table.tpl.html [new file with mode: 0755]
test/Tpl/FileDir/TPLS/source/div.tpl.html [new file with mode: 0755]
test/Tpl/FileDir/img/logo.jpg [new file with mode: 0755]
test/Tpl/FileDir/test_MLIB_Tpl_FileDir.php [new file with mode: 0755]

diff --git a/test/Tpl/FileDir/TPLS/body.tpl.html b/test/Tpl/FileDir/TPLS/body.tpl.html
new file mode 100755 (executable)
index 0000000..3587b62
--- /dev/null
@@ -0,0 +1,11 @@
+<HTML>
+    <HEAD>
+        <TITLE>{TITLE}</TITLE>
+    </HEAD>
+    <BODY>
+        <!-- BODY START -->
+        {BODY}
+        {SOURCE}
+        <!-- BODY END -->
+    </BODY>
+</HTML>
diff --git a/test/Tpl/FileDir/TPLS/body/cell.tpl.html b/test/Tpl/FileDir/TPLS/body/cell.tpl.html
new file mode 100755 (executable)
index 0000000..869592b
--- /dev/null
@@ -0,0 +1,3 @@
+<TD {ATTR}> 
+    {CELL}
+</TD>
diff --git a/test/Tpl/FileDir/TPLS/body/row.tpl.html b/test/Tpl/FileDir/TPLS/body/row.tpl.html
new file mode 100755 (executable)
index 0000000..6d1c99d
--- /dev/null
@@ -0,0 +1,3 @@
+<TR> 
+    {CELL}
+</TR>
diff --git a/test/Tpl/FileDir/TPLS/body/table.tpl.html b/test/Tpl/FileDir/TPLS/body/table.tpl.html
new file mode 100755 (executable)
index 0000000..16a2d72
--- /dev/null
@@ -0,0 +1,3 @@
+<TABLE {ATTR}>
+    {ROWS}
+</TABLE>
diff --git a/test/Tpl/FileDir/TPLS/footer/cell.tpl.html b/test/Tpl/FileDir/TPLS/footer/cell.tpl.html
new file mode 100755 (executable)
index 0000000..869592b
--- /dev/null
@@ -0,0 +1,3 @@
+<TD {ATTR}> 
+    {CELL}
+</TD>
diff --git a/test/Tpl/FileDir/TPLS/footer/link_meconlib_dev.tpl.html b/test/Tpl/FileDir/TPLS/footer/link_meconlib_dev.tpl.html
new file mode 100755 (executable)
index 0000000..1b044d3
--- /dev/null
@@ -0,0 +1 @@
+<a href="http://www.llucax.hn.org/mailman/listinfo/meconlib-dev">Meconlib-dev</a>
diff --git a/test/Tpl/FileDir/TPLS/footer/row.tpl.html b/test/Tpl/FileDir/TPLS/footer/row.tpl.html
new file mode 100755 (executable)
index 0000000..6d1c99d
--- /dev/null
@@ -0,0 +1,3 @@
+<TR> 
+    {CELL}
+</TR>
diff --git a/test/Tpl/FileDir/TPLS/footer/table.tpl.html b/test/Tpl/FileDir/TPLS/footer/table.tpl.html
new file mode 100755 (executable)
index 0000000..16a2d72
--- /dev/null
@@ -0,0 +1,3 @@
+<TABLE {ATTR}>
+    {ROWS}
+</TABLE>
diff --git a/test/Tpl/FileDir/TPLS/footer/text.tpl.html b/test/Tpl/FileDir/TPLS/footer/text.tpl.html
new file mode 100755 (executable)
index 0000000..5ada559
--- /dev/null
@@ -0,0 +1,2 @@
+<font size="2">If you wan't to know more about this library, you can join the
+developer list:&nbsp; {LINK}</font>
diff --git a/test/Tpl/FileDir/TPLS/header/cell.tpl.html b/test/Tpl/FileDir/TPLS/header/cell.tpl.html
new file mode 100755 (executable)
index 0000000..869592b
--- /dev/null
@@ -0,0 +1,3 @@
+<TD {ATTR}> 
+    {CELL}
+</TD>
diff --git a/test/Tpl/FileDir/TPLS/header/logo.tpl.html b/test/Tpl/FileDir/TPLS/header/logo.tpl.html
new file mode 100755 (executable)
index 0000000..9c981e7
--- /dev/null
@@ -0,0 +1 @@
+<img src="{SRC}" alt="{ALT}" {ATTR}>
diff --git a/test/Tpl/FileDir/TPLS/header/row.tpl.html b/test/Tpl/FileDir/TPLS/header/row.tpl.html
new file mode 100755 (executable)
index 0000000..6d1c99d
--- /dev/null
@@ -0,0 +1,3 @@
+<TR> 
+    {CELL}
+</TR>
diff --git a/test/Tpl/FileDir/TPLS/header/table.tpl.html b/test/Tpl/FileDir/TPLS/header/table.tpl.html
new file mode 100755 (executable)
index 0000000..16a2d72
--- /dev/null
@@ -0,0 +1,3 @@
+<TABLE {ATTR}>
+    {ROWS}
+</TABLE>
diff --git a/test/Tpl/FileDir/TPLS/source/div.tpl.html b/test/Tpl/FileDir/TPLS/source/div.tpl.html
new file mode 100755 (executable)
index 0000000..5f0fc90
--- /dev/null
@@ -0,0 +1,6 @@
+<TABLE width="700" border="0" align="center">
+    <TR> 
+        <TD align="right"><FONT size="1"><A href="?source=1">View Source</A></FONT>
+        </TD>
+    </TR>
+</TABLE>
diff --git a/test/Tpl/FileDir/img/logo.jpg b/test/Tpl/FileDir/img/logo.jpg
new file mode 100755 (executable)
index 0000000..b4f58b3
Binary files /dev/null and b/test/Tpl/FileDir/img/logo.jpg differ
diff --git a/test/Tpl/FileDir/test_MLIB_Tpl_FileDir.php b/test/Tpl/FileDir/test_MLIB_Tpl_FileDir.php
new file mode 100755 (executable)
index 0000000..68de83b
--- /dev/null
@@ -0,0 +1,202 @@
+<?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80 foldmethod=marker:
+-------------------------------------------------------------------------------
+                                    mlib
+-------------------------------------------------------------------------------
+This file is part of mlib.
+
+mlib is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option)
+any later version.
+
+mlib 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 Lesser General Public License for more 
+details.
+You should have received a copy of the GNU Lesser General Public License; if 
+not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+Boston, MA  02111-1307  USA
+-------------------------------------------------------------------------------
+Created: jue jul 29 09:42:56 ART 2004
+Authors: Martín Marrese <m_marrese@argentina.com>
+         Leandro Lucarella <luca@llucax.hn.org>
+-------------------------------------------------------------------------------
+$Id: Tpl.php 584 2004-07-30 05:50:10Z luca $
+-----------------------------------------------------------------------------*/
+
+//{{{Explanation of this example.
+// This example will create an html page with a header, body and a footer.
+// In order to do this, I will use three template groups (header, body, footer).
+// All this templates are located in TPLS directory.
+//}}}
+
+//{{{ Require Once.
+require_once 'MLIB/Tpl/FileDir.php';
+//}}}
+
+//{{{ The following variables are used as examples.
+$table_width = 'width="700"';
+$img_source = './img/logo.jpg';
+//}}}
+
+//{{{ Create a page from a template.
+$HIT =& new MLIB_Tpl_FileDir ('TPLS'); // Where TPLS is the subdirectory where I'll
+                                   // put my html_templates.
+//}}}
+
+//{{{ Show this source
+if (@$_GET['source'])
+{
+    $HEADER = '';
+    $FOOTER = '';
+    $SOURCE = '';
+    $BODY   = highlight_file($_SERVER['SCRIPT_FILENAME'], true);
+}
+//}}}
+
+//{{{ Example
+else
+{
+    //{{{ Add header group of templates.
+    $HIT->pushGroup('header');
+
+    //{{{ First ROW
+    //{{{ Obtain the data cells of the first row.
+    $cells = $HIT->parse('cell', 
+            array (
+                'ATTR' => 'width="20%" align="center"', //Sets the width of the cell.
+                'CELL' => $HIT->parse('logo', //Add the logo image to this cell.
+                    array(
+                        'SRC' => $img_source,   //Source of the image.
+                        'ATTR' => 'border="0"', //Image attributes
+                        'ALT' => 'LOGO'         //Alternative text.
+                        )
+                    )
+                )
+            );
+    $cells.= $HIT->parse('cell', 
+            array (
+                'ATTR' => 'width="80%" align="center"', //Sets the width of the cell.
+                'CELL' => 'H&nbsp;I&nbsp;T&nbsp;&nbsp;T&nbsp;E&nbsp;M&nbsp;P&nbsp;L&nbsp;A&nbsp;T&nbsp;E&nbsp;&nbsp;E&nbsp;X&nbsp;A&nbsp;M&nbsp;P&nbsp;L&nbsp;E' //Title.
+                )
+            );
+    //}}}
+
+    // Obtain the first row of the header table.
+    $rows = $HIT->parse('row', 'CELL', $cells);
+    //}}}
+
+    //{{{ Second Row
+    // Obtain the data cells of the first row.
+    $cells = $HIT->parse('cell', 
+            array (
+                'ATTR' => 'colspan="2" align="center"', //Sets the width of the cell.
+                'CELL' => '<b>This is the second row of the header table.</b>'
+                )
+            );
+
+    // Obtain the first row of the header table.
+    $rows.= $HIT->parse('row', 'CELL', $cells);
+    //}}}
+
+    // Obtain the parsed templates and add it to the header "main" template.
+    $HEADER = $HIT->parse(
+            'table',
+            array (
+                'ATTR' => $table_width . ' border="1" align="center"',
+                'ROWS' => $rows
+                )
+            );
+    // Remove from the group stack the header group.
+    $HIT->popGroup('header');
+    //}}}
+
+    //{{{ Add body group of templates.
+    $HIT->pushGroup('body');
+
+    //{{{ First ROW
+    $cells = $HIT->parse('cell', 
+            array (
+                'ATTR' => 'valign="center" align="center" height="370"', //Sets the width of the cell.
+                'CELL' => '<font size="1">BODY</font>'    //Body Content
+                )
+            );
+
+    // Obtain the first row of the header table.
+    $rows = $HIT->parse('row', 'CELL', $cells);
+    //}}}
+
+    // Obtain the parsed templates and add it to the header "main" template.
+    $BODY = $HIT->parse(
+            'table',
+            array (
+                'ATTR' => $table_width . ' border="0" align="center"',
+                'ROWS' => $rows
+                )
+            );
+    // Remove from the group stack the header group.
+    $HIT->popGroup('body');
+    //}}}
+
+    //{{{ Add footer group of templates.
+    $HIT->pushGroup('footer');
+
+    //{{{ First ROW
+    //{{{ Obtain the data cells of the first row.
+    $cells = $HIT->parse('cell', 
+            array (
+                'ATTR' => 'align="center"', //Sets the width of the cell.
+                'CELL' => $HIT->parse(
+                    'text', 
+                    'LINK',
+                    $HIT->parse('link_meconlib_dev')
+                    )
+                )
+            );
+    //}}}
+
+    // Obtain the first row of the header table.
+    $rows = $HIT->parse('row', 'CELL', $cells);
+    //}}}
+
+
+    // Obtain the parsed templates and add it to the header "main" template.
+    $FOOTER = $HIT->parse(
+            'table',
+            array (
+                'ATTR' => $table_width . ' border="1" align="center"',
+                'ROWS' => $rows
+                )
+            );
+    // Remove from the group stack the header group.
+    $HIT->popGroup('footer');
+    //}}}
+
+    //{{{ Add SOURCE group of templates.
+    $HIT->pushGroup('source');
+
+    // Obtain the parsed templates and add it to the header "main" template.
+    $SOURCE = $HIT->parse('div');
+    // Remove from the group stack the header group.
+    $HIT->popGroup('source');
+    //}}}
+}
+//}}}
+
+//{{{ Add all the parsed templates to the main template.
+$RESULT = $HIT->parse(
+        'body',
+        array (
+            'TITLE'  => 'MLIB_Tpl_HIT Test',
+            'BODY'   => $HEADER . $BODY . $FOOTER,
+            'SOURCE' => $SOURCE
+            )
+        );
+//}}}
+
+//{{{ Display the result.
+echo $RESULT;
+//}}}
+
+?>