From: Martín Marrese Date: Fri, 30 Jul 2004 21:23:25 +0000 (+0000) Subject: Se agrega un ejemplo sobre la utilizacion de MLIB_Tpl_FileDir. X-Git-Tag: svn_import~19 X-Git-Url: https://git.llucax.com/mecon/meconlib.git/commitdiff_plain/ef6da0a420f91323dccab700e71c5b5955924085?ds=sidebyside Se agrega un ejemplo sobre la utilizacion de MLIB_Tpl_FileDir. Quizas no se entienda demasiado pero sirve igual. --- diff --git a/test/Tpl/FileDir/TPLS/body.tpl.html b/test/Tpl/FileDir/TPLS/body.tpl.html new file mode 100755 index 0000000..3587b62 --- /dev/null +++ b/test/Tpl/FileDir/TPLS/body.tpl.html @@ -0,0 +1,11 @@ + + + {TITLE} + + + + {BODY} + {SOURCE} + + + diff --git a/test/Tpl/FileDir/TPLS/body/cell.tpl.html b/test/Tpl/FileDir/TPLS/body/cell.tpl.html new file mode 100755 index 0000000..869592b --- /dev/null +++ b/test/Tpl/FileDir/TPLS/body/cell.tpl.html @@ -0,0 +1,3 @@ + + {CELL} + diff --git a/test/Tpl/FileDir/TPLS/body/row.tpl.html b/test/Tpl/FileDir/TPLS/body/row.tpl.html new file mode 100755 index 0000000..6d1c99d --- /dev/null +++ b/test/Tpl/FileDir/TPLS/body/row.tpl.html @@ -0,0 +1,3 @@ + + {CELL} + diff --git a/test/Tpl/FileDir/TPLS/body/table.tpl.html b/test/Tpl/FileDir/TPLS/body/table.tpl.html new file mode 100755 index 0000000..16a2d72 --- /dev/null +++ b/test/Tpl/FileDir/TPLS/body/table.tpl.html @@ -0,0 +1,3 @@ + + {ROWS} +
diff --git a/test/Tpl/FileDir/TPLS/footer/cell.tpl.html b/test/Tpl/FileDir/TPLS/footer/cell.tpl.html new file mode 100755 index 0000000..869592b --- /dev/null +++ b/test/Tpl/FileDir/TPLS/footer/cell.tpl.html @@ -0,0 +1,3 @@ + + {CELL} + 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 index 0000000..1b044d3 --- /dev/null +++ b/test/Tpl/FileDir/TPLS/footer/link_meconlib_dev.tpl.html @@ -0,0 +1 @@ +Meconlib-dev diff --git a/test/Tpl/FileDir/TPLS/footer/row.tpl.html b/test/Tpl/FileDir/TPLS/footer/row.tpl.html new file mode 100755 index 0000000..6d1c99d --- /dev/null +++ b/test/Tpl/FileDir/TPLS/footer/row.tpl.html @@ -0,0 +1,3 @@ + + {CELL} + diff --git a/test/Tpl/FileDir/TPLS/footer/table.tpl.html b/test/Tpl/FileDir/TPLS/footer/table.tpl.html new file mode 100755 index 0000000..16a2d72 --- /dev/null +++ b/test/Tpl/FileDir/TPLS/footer/table.tpl.html @@ -0,0 +1,3 @@ + + {ROWS} +
diff --git a/test/Tpl/FileDir/TPLS/footer/text.tpl.html b/test/Tpl/FileDir/TPLS/footer/text.tpl.html new file mode 100755 index 0000000..5ada559 --- /dev/null +++ b/test/Tpl/FileDir/TPLS/footer/text.tpl.html @@ -0,0 +1,2 @@ +If you wan't to know more about this library, you can join the +developer list:  {LINK} diff --git a/test/Tpl/FileDir/TPLS/header/cell.tpl.html b/test/Tpl/FileDir/TPLS/header/cell.tpl.html new file mode 100755 index 0000000..869592b --- /dev/null +++ b/test/Tpl/FileDir/TPLS/header/cell.tpl.html @@ -0,0 +1,3 @@ + + {CELL} + diff --git a/test/Tpl/FileDir/TPLS/header/logo.tpl.html b/test/Tpl/FileDir/TPLS/header/logo.tpl.html new file mode 100755 index 0000000..9c981e7 --- /dev/null +++ b/test/Tpl/FileDir/TPLS/header/logo.tpl.html @@ -0,0 +1 @@ +{ALT} diff --git a/test/Tpl/FileDir/TPLS/header/row.tpl.html b/test/Tpl/FileDir/TPLS/header/row.tpl.html new file mode 100755 index 0000000..6d1c99d --- /dev/null +++ b/test/Tpl/FileDir/TPLS/header/row.tpl.html @@ -0,0 +1,3 @@ + + {CELL} + diff --git a/test/Tpl/FileDir/TPLS/header/table.tpl.html b/test/Tpl/FileDir/TPLS/header/table.tpl.html new file mode 100755 index 0000000..16a2d72 --- /dev/null +++ b/test/Tpl/FileDir/TPLS/header/table.tpl.html @@ -0,0 +1,3 @@ + + {ROWS} +
diff --git a/test/Tpl/FileDir/TPLS/source/div.tpl.html b/test/Tpl/FileDir/TPLS/source/div.tpl.html new file mode 100755 index 0000000..5f0fc90 --- /dev/null +++ b/test/Tpl/FileDir/TPLS/source/div.tpl.html @@ -0,0 +1,6 @@ + + + + +
View Source +
diff --git a/test/Tpl/FileDir/img/logo.jpg b/test/Tpl/FileDir/img/logo.jpg new file mode 100755 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 index 0000000..68de83b --- /dev/null +++ b/test/Tpl/FileDir/test_MLIB_Tpl_FileDir.php @@ -0,0 +1,202 @@ + + Leandro Lucarella +------------------------------------------------------------------------------- +$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' => 'This is the second row of the header table.' + ) + ); + + // 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' => 'BODY' //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; +//}}} + +?>