1 <?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80 foldmethod=marker:
2 -------------------------------------------------------------------------------
4 -------------------------------------------------------------------------------
5 This file is part of mlib.
7 mlib is free software; you can redistribute it and/or modify it under
8 the terms of the GNU Lesser General Public License as published by the Free
9 Software Foundation; either version 2 of the License, or (at your option)
12 mlib is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17 You should have received a copy of the GNU Lesser General Public License; if
18 not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19 Boston, MA 02111-1307 USA
20 -------------------------------------------------------------------------------
21 Created: jue jul 29 09:42:56 ART 2004
22 Authors: MartÃn Marrese <m_marrese@argentina.com>
23 Leandro Lucarella <luca@llucax.hn.org>
24 -------------------------------------------------------------------------------
25 $Id: Tpl.php 584 2004-07-30 05:50:10Z luca $
26 -----------------------------------------------------------------------------*/
28 //{{{Explanation of this example.
29 // This example will create an html page with a header, body and a footer.
30 // In order to do this, I will use three template groups (header, body, footer).
31 // All this templates are located in TPLS directory.
35 require_once 'MLIB/Tpl/FileDir.php';
38 //{{{ The following variables are used as examples.
39 $table_width = 'width="700"';
40 $img_source = './img/logo.jpg';
43 //{{{ Create a page from a template.
44 $HIT =& new MLIB_Tpl_FileDir ('TPLS'); // Where TPLS is the subdirectory where I'll
45 // put my html_templates.
48 //{{{ Show this source
54 $BODY = highlight_file($_SERVER['SCRIPT_FILENAME'], true);
61 //{{{ Add header group of templates.
62 $HIT->pushGroup('header');
65 //{{{ Obtain the data cells of the first row.
66 $cells = $HIT->parse('cell',
68 'ATTR' => 'width="20%" align="center"', //Sets the width of the cell.
69 'CELL' => $HIT->parse('logo', //Add the logo image to this cell.
71 'SRC' => $img_source, //Source of the image.
72 'ATTR' => 'border="0"', //Image attributes
73 'ALT' => 'LOGO' //Alternative text.
78 $cells.= $HIT->parse('cell',
80 'ATTR' => 'width="80%" align="center"', //Sets the width of the cell.
81 'CELL' => 'MLIB_Tpl_FileDir Example' //Title.
86 // Obtain the first row of the header table.
87 $rows = $HIT->parse('row', 'CELL', $cells);
91 // Obtain the data cells of the first row.
92 $cells = $HIT->parse('cell',
94 'ATTR' => 'colspan="2" align="center"', //Sets the width of the cell.
95 'CELL' => '<b>This is the second row of the header table.</b>'
99 // Obtain the first row of the header table.
100 $rows.= $HIT->parse('row', 'CELL', $cells);
103 // Obtain the parsed templates and add it to the header "main" template.
104 $HEADER = $HIT->parse(
107 'ATTR' => $table_width . ' border="1" align="center"',
111 // Remove from the group stack the header group.
112 $HIT->popGroup('header');
115 //{{{ Add body group of templates.
116 $HIT->pushGroup('body');
119 $cells = $HIT->parse('cell',
121 'ATTR' => 'valign="center" align="center" height="370"', //Sets the width of the cell.
122 'CELL' => '<font size="1">BODY</font>' //Body Content
126 // Obtain the first row of the header table.
127 $rows = $HIT->parse('row', 'CELL', $cells);
130 // Obtain the parsed templates and add it to the header "main" template.
134 'ATTR' => $table_width . ' border="0" align="center"',
138 // Remove from the group stack the header group.
139 $HIT->popGroup('body');
142 //{{{ Add footer group of templates.
143 $HIT->pushGroup('footer');
146 //{{{ Obtain the data cells of the first row.
147 $cells = $HIT->parse('cell',
149 'ATTR' => 'align="center"', //Sets the width of the cell.
150 'CELL' => $HIT->parse(
153 $HIT->parse('link_meconlib_dev')
159 // Obtain the first row of the header table.
160 $rows = $HIT->parse('row', 'CELL', $cells);
164 // Obtain the parsed templates and add it to the header "main" template.
165 $FOOTER = $HIT->parse(
168 'ATTR' => $table_width . ' border="1" align="center"',
172 // Remove from the group stack the header group.
173 $HIT->popGroup('footer');
176 //{{{ Add SOURCE group of templates.
177 $HIT->pushGroup('source');
179 // Obtain the parsed templates and add it to the header "main" template.
180 $SOURCE = $HIT->parse('div');
181 // Remove from the group stack the header group.
182 $HIT->popGroup('source');
187 //{{{ Add all the parsed templates to the main template.
188 $RESULT = $HIT->parse(
191 'TITLE' => 'MLIB_Tpl_HIT Test',
192 'BODY' => $HEADER . $BODY . $FOOTER,
198 //{{{ Display the result.