+<?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 I T T E M P L A T E E X A M P L 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;
+//}}}
+
+?>