cvs: peardoc /en/package/html/html-template-it get.xml html-template-it.xml intro.xml loadtemplatefile.xml parse.xml parsecurrentblock.xml
setcurrentblock.xml setroot.xml settemplate.xml setvariable.xml show.xml touchblock.xml

From: Date: Tue, 05 Sep 2006 17:03:01 +0000
Subject: cvs: peardoc /en/package/html/html-template-it get.xml html-template-it.xml intro.xml loadtemplatefile.xml parse.xml parsecurrentblock.xml
setcurrentblock.xml setroot.xml settemplate.xml setvariable.xml show.xml touchblock.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-8397@lists.php.net to get a copy of this message
dsp Tue Sep 5 17:03:01 2006 UTC Modified files: /peardoc/en/package/html/html-template-it get.xml html-template-it.xml intro.xml loadtemplatefile.xml parse.xml parsecurrentblock.xml setcurrentblock.xml setroot.xml settemplate.xml setvariable.xml show.xml touchblock.xml Log: Translate every changes from the german translation to the english. This includes a lot of examples, reformatting, etc.

http://cvs.php.net/viewvc.cgi/peardoc/en/package/html/html-template-it/get.xml?r1=1.3&r2=1.4&diff_format=u Index: peardoc/en/package/html/html-template-it/get.xml diff -u peardoc/en/package/html/html-template-it/get.xml:1.3 peardoc/en/package/html/html-template-it/get.xml:1.4 --- peardoc/en/package/html/html-template-it/get.xml:1.3 Tue Jun 17 11:10:35 2003 +++ peardoc/en/package/html/html-template-it/get.xml Tue Sep 5 17:03:01 2006 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <refentry id="package.html.html-template-it.get"> <refnamediv> <refname>HTML_Template_IT::get()</refname> @@ -11,9 +11,9 @@ </funcsynopsisinfo> <funcprototype> <funcdef>string - <function>IntegratedTemplate::get</function></funcdef> + <function>HTML_Template_IT::get</function></funcdef> <paramdef>string - <parameter><optional>$block = "__global"</optional></parameter></paramdef> + <parameter><optional>$block = "__global__"</optional></parameter></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> @@ -41,7 +41,7 @@ &title.returns; <para> <parameter>string</parameter> - - the template with replacements + the template with all replacements done. </para> </refsect1> <refsect1 id="package.html.html-template-it.get.throws"> @@ -82,7 +82,14 @@ &title.note; &note.notstatic; </refsect1> - </refentry> + <refsect1 id="package.html.html-template-it.get.see"> + &title.see; + <para> + <link linkend="package.html.html-template-it.parse"> + <function>HTML_Template_IT::parse</function></link> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml http://cvs.php.net/viewvc.cgi/peardoc/en/package/html/html-template-it/html-template-it.xml?r1=1.1.1.1&r2=1.2&diff_format=u Index: peardoc/en/package/html/html-template-it/html-template-it.xml diff -u peardoc/en/package/html/html-template-it/html-template-it.xml:1.1.1.1 peardoc/en/package/html/html-template-it/html-template-it.xml:1.2 --- peardoc/en/package/html/html-template-it/html-template-it.xml:1.1.1.1 Tue Oct 1 03:23:12 2002 +++ peardoc/en/package/html/html-template-it/html-template-it.xml Tue Sep 5 17:03:01 2006 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.1.1.1 $ --> +<!-- $Revision: 1.2 $ --> <refentry id="package.html.html-template-it.html-template-it"> <refnamediv> <refname>HTML_Template_IT::HTML_Template_IT()</refname> @@ -11,16 +11,16 @@ </funcsynopsisinfo> <funcprototype> <funcdef>void - <function>IntegratedTemplate::IntegratedTemplate</function></funcdef> + <function>HTML_Template_IT::HTML_Template_IT</function></funcdef> <paramdef>string - <parameter><optional>$root = ""</optional></parameter></paramdef> + <parameter><optional>$root = '.'</optional></parameter></paramdef> </funcprototype> </funcsynopsis> </refsynopsisdiv> <refsect1 id="package.html.html-template-it.html-template-it.desc"> &title.desc; <para> - Constructor + Constructor. Create a new instance of HTML_Template_IT and sets the search path for templates. </para> </refsect1> <refsect1 id="package.html.html-template-it.html-template-it.parameter"> @@ -35,12 +35,25 @@ </listitem> </itemizedlist> </para> - </refsect1> - <refsect1 id="package.html.html-template-it.html-template-it.note"> + </refsect1> + <refsect1 id="package.html.html-template-it.html-template.it.return"> + &title.returns; + <para> + &type.object; - a new HTML_Template_IT object + </para> + </refsect1> + <refsect1 id="package.html.html-template-it.html-template-it.note"> &title.note; &note.canstatic; - </refsect1> - </refentry> + </refsect1> + <refsect1 id="package.html.html-template-it.html-template-it.see"> + &title.see; + <para> + <link linkend="package.html.html-template-it.setroot"> + <function>HTML_Template_IT::setRoot</function></link> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml http://cvs.php.net/viewvc.cgi/peardoc/en/package/html/html-template-it/intro.xml?r1=1.3&r2=1.4&diff_format=u Index: peardoc/en/package/html/html-template-it/intro.xml diff -u peardoc/en/package/html/html-template-it/intro.xml:1.3 peardoc/en/package/html/html-template-it/intro.xml:1.4 --- peardoc/en/package/html/html-template-it/intro.xml:1.3 Wed Apr 30 20:11:51 2003 +++ peardoc/en/package/html/html-template-it/intro.xml Tue Sep 5 17:03:01 2006 @@ -1,36 +1,85 @@ -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <refentry id="package.html.html-template-it.intro"> <refnamediv> <refname>Introduction</refname> <refpurpose>Creating and Parsing templates</refpurpose> </refnamediv> + <refsect1 id="package.html.html-template-it.intro.templates"> + <title>Templates</title> + <para> + A template consists of text and special labeled blocks and placeholders. + The content of blocks can be re-used and parsed multiple times with different + placeholder values. + </para> + <example> + <title>A typical template</title> + <programlisting role="html"> + <![CDATA[ +<html> + <body> + Userlist + <table> +<!-- BEGIN row --> + <tr> + <td>{USERNAME}</td> + <td>{EMAIL}</td> + </tr> +<!-- END row --> + </table> + </body> +</html> +]]> + </programlisting> + </example> + </refsect1> + <refsect1 id="package.html.html-template-it.intro.placeholder"> <title>Placeholder</title> <para> - The format of placeholder is + Placeholders can be defined in templates and are filled from + PHP code with content. + The format of placeholder up to version (1.1.x) is + </para> <programlisting> {[0-9A-Za-z_-]+} </programlisting> + <para> + Since version 1.2.x dots are allowed, too. + </para> + <programlisting> + {[\.0-9A-Za-z_-]+} + </programlisting> + <para> This means, the name of the placeholder can consist of upper- and lowercase letters, underscores and hypens. The name must be placed between curly - brackets without any spaces. Valid names are i.e.: + brackets without any spaces. + Valid names are i.e.: + </para> <simplelist> <member>{Placeholder}</member> <member>{place2_holder}</member> <member>{PLACEHOLDER1}</member> <member>{Place-Holder}</member> </simplelist> + <para> + Valid names since version 1.2.x + </para> + <simplelist> + <member>{Place.Holder}</member> + </simplelist> + <para> Non-valid names are i.e. + </para> <simplelist> <member>{ Placeholder 3 } (spaces)</member> <member>{place*holder} (char isn't permitted)</member> </simplelist> - </para> </refsect1> <refsect1 id="package.html.html-template-it.intro.block"> <title>Blocks</title> <para> The format of a block is + </para> <programlisting> <![CDATA[ <!-- BEGIN [0-9A-Za-z_-]+ --> @@ -38,6 +87,17 @@ <!-- END [0-9A-Za-z_-]+ --> ]]> </programlisting> + <para> + Since version 1.2.x dots are allowed in block definitions + </para> + <programlisting> + <![CDATA[ +<!-- BEGIN [\.0-9A-Za-z_-]+ --> +... block content ... +<!-- END [\.0-9A-Za-z_-]+ --> + ]]> + </programlisting> + <para> The rules for the block name are the same like for placeholders. In contrast to placeholders the spaces in the block markup are required. @@ -48,8 +108,8 @@ and then set and parse from inner to outer. </para> <para> - In IT the whole template file itself is nested in a virtual block called - <quote>__global</quote>. Most block-related functions use this block + In IT the whole template file itself is nested in a meta block called + <quote>__global__</quote>. Most block-related functions use this block name as default. </para> </refsect1> @@ -81,36 +141,35 @@ <title>The script</title> <programlisting role="php"> <![CDATA[ -<?php - require_once "HTML/Template/IT.php"; +<?php + require_once "HTML/Template/IT.php"; - $data = array - ( - "0" => array("Stig", "Bakken"), - "1" => array("Martin", "Jansen"), - "2" => array("Alexander", "Merz") - ); + $data = array + ( + "0" => array("Stig", "Bakken"), + "1" => array("Martin", "Jansen"), + "2" => array("Alexander", "Merz") + ); - $tpl = new HTML_Template_IT("./templates"); + $tpl = new HTML_Template_IT("./templates"); - $tpl->loadTemplatefile("main.tpl.htm", true, true); + $tpl->loadTemplatefile("main.tpl.htm", true, true); foreach($data as $name) { foreach($name as $cell) { - // Assign data to the inner block + // Assign data to the inner block $tpl->setCurrentBlock("cell") ; $tpl->setVariable("DATA", $cell) ; $tpl->parseCurrentBlock("cell") ; } - // Assign data and the inner block to the - // outer block - $tpl->setCurrentBlock("row") ; - $tpl->parseCurrentBlock("row") ; + + // parse outter block + $tpl->parse("row"); } // print the output - $tpl->show(); + $tpl->show(); -?> +?> ]]> </programlisting> </example> @@ -118,8 +177,8 @@ <title>The output</title> <programlisting> <![CDATA[ -<html> - <table border> +<html> + <table border> <tr> <td> Stig @@ -135,7 +194,7 @@ <td> Jansen </td> - </tr> + </tr> <tr> <td> Alexander @@ -143,15 +202,14 @@ <td> Merz </td> - </tr> - </table> -</html> + </tr> + </table> +</html> ]]> </programlisting> </example> </refsect1> - - </refentry> + </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml http://cvs.php.net/viewvc.cgi/peardoc/en/package/html/html-template-it/loadtemplatefile.xml?r1=1.2&r2=1.3&diff_format=u Index: peardoc/en/package/html/html-template-it/loadtemplatefile.xml diff -u peardoc/en/package/html/html-template-it/loadtemplatefile.xml:1.2 peardoc/en/package/html/html-template-it/loadtemplatefile.xml:1.3 --- peardoc/en/package/html/html-template-it/loadtemplatefile.xml:1.2 Sat Mar 11 21:06:11 2006 +++ peardoc/en/package/html/html-template-it/loadtemplatefile.xml Tue Sep 5 17:03:01 2006 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <refentry id="package.html.html-template-it.loadtemplatefile"> <refnamediv> <refname>HTML_Template_IT::loadTemplatefile()</refname> @@ -11,7 +11,7 @@ </funcsynopsisinfo> <funcprototype> <funcdef>boolean - <function>IntegratedTemplate::loadTemplatefile</function> + <function>HTML_Template_IT::loadTemplatefile</function> </funcdef> <paramdef>string <parameter>$filename</parameter></paramdef> @@ -31,7 +31,7 @@ <refsect1 id="package.html.html-template-it.loadtemplatefile.desc"> &title.desc; <para> - Loads a template from a file + Loads a template from a file and generates internal lists for blocks and variables. </para> </refsect1> <refsect1 id="package.html.html-template-it.loadtemplatefile.parameter"> @@ -54,7 +54,7 @@ <listitem> <para> <parameter>boolean $removeEmptyBlocks</parameter> - - if &true;, not touched blocks will be removed + if &true;, not touched blocks will be removed. Blocks can be touched with <function>HTML_Template_IT::touchBlock</function>. </para> </listitem> </itemizedlist> @@ -66,7 +66,71 @@ <parameter>boolean</parameter> - &return.success; </para> - </refsect1> + </refsect1> + <refsect1 id="package.html.html-template-it.loadtemplatefile.example"> + &title.example; + <example> + <title></title> + <para>Templatefile main.tpl.htm + <programlisting role="html"> + <![CDATA[ +<html> + <body> +User {USERNAME} logged in successfull as {ROLE}. + </body> +</html> + ]]> + </programlisting> + </para> + <para>Script with <parameter>$removeUnknownVariables</parameter> = &false; + <programlisting role="php"> +<![CDATA[ +<?php +require_once 'HTML/Template/IT.php'; + +$tpl = new HTML_Template_IT('.'); +$tpl->loadTemplatefile ('main.tpl.htm', false, false); + +$tpl->setVariable ('USERNAME', 'foo'); +// Placeholder ROLE is not set +$tpl->show(); +?> +]]> + </programlisting> + </para> + <para>Output + <programlisting> +<![CDATA[ +User foo logged in successfull as {ROLE}. +]]> + </programlisting> + </para> + <para>Script with <parameter>$removeUnknownVariables</parameter> = &true; + <programlisting role="php"> +<![CDATA[ +<?php +require_once 'HTML/Template/IT.php'; + +$tpl = new HTML_Template_IT('.'); +$tpl->loadTemplatefile ('main.tpl.htm', true, true); + +$tpl->setVariable ('USERNAME', 'foo'); +// Placeholder ROLE is not set, but $removeUnknownVariables is set to true. +$tpl->show(); +?> +]]> + </programlisting> + </para> + <para>Output + <programlisting> +<![CDATA[ +User foo logged in successfull as . +]]> + </programlisting> + </para> + </example> + </refsect1> + <refsect1 id="package.html.html-template-it.loadtemplatefile.note"> &title.note; &note.notstatic; http://cvs.php.net/viewvc.cgi/peardoc/en/package/html/html-template-it/parse.xml?r1=1.3&r2=1.4&diff_format=u Index: peardoc/en/package/html/html-template-it/parse.xml diff -u peardoc/en/package/html/html-template-it/parse.xml:1.3 peardoc/en/package/html/html-template-it/parse.xml:1.4 --- peardoc/en/package/html/html-template-it/parse.xml:1.3 Wed Aug 13 16:01:03 2003 +++ peardoc/en/package/html/html-template-it/parse.xml Tue Sep 5 17:03:01 2006 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <refentry id="package.html.html-template-it.parse"> <refnamediv> <refname>HTML_Template_IT::parse()</refname> @@ -11,9 +11,9 @@ </funcsynopsisinfo> <funcprototype> <funcdef>void - <function>IntegratedTemplate::parse</function></funcdef> + <function>HTML_Template_IT::parse</function></funcdef> <paramdef>string - <parameter><optional>$block = "__global"</optional></parameter> + <parameter><optional>$block = "__global__"</optional></parameter> </paramdef> <paramdef>boolean <parameter><optional>$flag_recursion = &false;</optional></parameter></paramdef> @@ -23,7 +23,8 @@ <refsect1 id="package.html.html-template-it.parse.desc"> &title.desc; <para> - Parses the defined block. + Parses the defined block, performs all substitutions and appends +the result to already parsed blocks. </para> </refsect1> <refsect1 id="package.html.html-template-it.parse.parameter"> @@ -33,19 +34,87 @@ <listitem> <para> <parameter>string $block</parameter> - - block to parse, when not set - the complete template will be parsed. + block to parse. When not set the complete template is used. </para> </listitem> <listitem> <para> <parameter>boolean $flag_recursion</parameter> - - can be ignored + Used internally. Can be ignored </para> </listitem> </itemizedlist> </para> </refsect1> + + <refsect1 id="package.html.html-template-it.parse.return"> + &title.returns; + <para> + <parameter>boolean</parameter> - + Returns &true if there was no placeholder to substitute, otherwise &false or IT_Error. + </para> + </refsect1> + + <refsect1 id="package.html.html-template-it.parse.example"> + &title.example; + <example> + <title>The template cvsnames.tpl.htm</title> + <programlisting role="html"> + <![CDATA[ +<html> + <table> +<!-- BEGIN row --> + <tr> + <td> + {CVS_USERNAME} + </td> + <td> + {REALNAME} + </td> + </tr> +<!-- END row --> + </table> +</html> + ]]> + </programlisting> + </example> + <example> + <title>The script</title> + <programlisting role="php"> + <![CDATA[ +<?php + require_once "HTML/Template/IT.php"; + + $data = array + ( + "0" => array("cvs_username" => "pajoye", + "realname" => "Pierre-Alain Joye"), + "1" => array("cvs_username" => "dsp", + "realname" => "David Soria Parra") + ); + + $tpl = new HTML_Template_IT("./templates"); + + $tpl->loadTemplatefile("cvsnames.tpl.htm", true, true); + + foreach($data as $name) { + + $tpl->setVariable("CVS_USERNAME", $name["cvs_username"]); + $tpl->setVariable("REALNAME", $name["realname"]); + + $tpl->parse("row"); + } + + // show() parses the __global__ block and + // print the output + $tpl->show(); + +?> + ]]> + </programlisting> + </example> + </refsect1> + <refsect1 id="package.html.html-template-it.parse.throws"> &title.throws; <para> @@ -84,6 +153,14 @@ &title.note; &note.notstatic; </refsect1> + <refsect1 id="package.html.html-template-it.parse.see"> + &title.see; + <para> + <link linkend="package.html.html-template-it.parsecurrentblock"> + <function>HTML_Template_it::parseCurrentBlock</function></link> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewvc.cgi/peardoc/en/package/html/html-template-it/parsecurrentblock.xml?r1=1.2&r2=1.3&diff_format=u Index: peardoc/en/package/html/html-template-it/parsecurrentblock.xml diff -u peardoc/en/package/html/html-template-it/parsecurrentblock.xml:1.2 peardoc/en/package/html/html-template-it/parsecurrentblock.xml:1.3 --- peardoc/en/package/html/html-template-it/parsecurrentblock.xml:1.2 Tue Jun 17 11:10:35 2003 +++ peardoc/en/package/html/html-template-it/parsecurrentblock.xml Tue Sep 5 17:03:01 2006 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <refentry id="package.html.html-template-it.parsecurrentblock"> <refnamediv> <refname>HTML_Template_IT::parseCurrentBlock()</refname> @@ -11,7 +11,7 @@ </funcsynopsisinfo> <funcprototype> <funcdef>void - <function>IntegratedTemplate::parseCurrentBlock</function></funcdef> + <function>HTML_Template_IT::parseCurrentBlock</function></funcdef> <paramdef></paramdef> </funcprototype> </funcsynopsis> @@ -19,9 +19,82 @@ <refsect1 id="package.html.html-template-it.parsecurrentblock.desc"> &title.desc; <para> - Parses the current block. + Parses the current block. The current block can be set with <function>HTML_Template_IT::setCurrentBlock</function>. </para> </refsect1> + + <refsect1 id="package.html.html-template-it.parsecurrentblock.return"> + &title.returns; + <para> + <parameter>boolean</parameter> - + Returns &true if there was no placeholder to substitute, otherwise &false or IT_Error. + </para> + </refsect1> + + <refsect1 id="package.html.html-template-it.parsecurrentblock.example"> + &title.example; + <example> + <title>The template cvsnames.tpl.htm</title> + <programlisting role="html"> + <![CDATA[ +<html> + <table> +<!-- BEGIN row --> + <tr> + <td> + {CVS_USERNAME} + </td> + <td> + {REALNAME} + </td> + </tr> +<!-- END row --> + </table> +</html> + ]]> + </programlisting> + </example> + <example> + <title>Script</title> + <programlisting role="php"> + <![CDATA[ +<?php + require_once "HTML/Template/IT.php"; + + $data = array + ( + "0" => array("cvs_username" => "pajoye", + "realname" => "Pierre-Alain Joye"), + "1" => array("cvs_username" => "dsp", + "realname" => "David Soria Parra") + ); + + $tpl = new HTML_Template_IT("./templates"); + + $tpl->loadTemplatefile("cvsnames.tpl.htm", true, true); + + // set the current block, which can now be used with parseCurrentBlock() + $tpl->setCurrentBlock("row"); + foreach($data as $name) { + // Assign data to the inner block + + $tpl->setVariable("CVS_USERNAME", $name["cvs_username"]); + $tpl->setVariable("REALNAME", $name["realname"]); + + // parse the current set block + $tpl->parseCurrentBlock(); + } + + // show() parses the __global__ block and + // print the output + $tpl->show(); + +?> + ]]> + </programlisting> + </example> + </refsect1> + <refsect1 id="package.html.html-template-it.parsecurrentblock.throws"> &title.throws; <para> @@ -55,12 +128,21 @@ </tgroup> </table> </para> - </refsect1> - <refsect1 id="package.html.html-template-it.parsecurrentblock.note"> - &title.note; - &note.notstatic; - </refsect1> - </refentry> + </refsect1> + <refsect1 id="package.html.html-template-it.parsecurrentblock.note"> + &title.note; + &note.notstatic; + </refsect1> + <refsect1 id="package.html.html-template-it.parsecurrentblock.see"> + &title.see; + <para> + <link linkend="package.html.html-template-it.parse"> + <function>HTML_Template_it::parse</function></link>, + <link linkend="package.html.html-template-it.setcurrentblock"> + <function>HTML_Template_it::setCurrentBlock</function></link> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml http://cvs.php.net/viewvc.cgi/peardoc/en/package/html/html-template-it/setcurrentblock.xml?r1=1.3&r2=1.4&diff_format=u Index: peardoc/en/package/html/html-template-it/setcurrentblock.xml diff -u peardoc/en/package/html/html-template-it/setcurrentblock.xml:1.3 peardoc/en/package/html/html-template-it/setcurrentblock.xml:1.4 --- peardoc/en/package/html/html-template-it/setcurrentblock.xml:1.3 Wed Aug 13 16:01:03 2003 +++ peardoc/en/package/html/html-template-it/setcurrentblock.xml Tue Sep 5 17:03:01 2006 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <refentry id="package.html.html-template-it.setcurrentblock"> <refnamediv> <refname>HTML_Template_IT::setCurrentBlock()</refname> @@ -11,9 +11,9 @@ </funcsynopsisinfo> <funcprototype> <funcdef>boolean - <function>IntegratedTemplate::setCurrentBlock</function></funcdef> + <function>HTML_Template_IT::setCurrentBlock</function></funcdef> <paramdef>string - <parameter><optional>$block = "__global"</optional></parameter> + <parameter><optional>$block = "__global__"</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> @@ -22,7 +22,7 @@ &title.desc; <para> Sets the name of the current block, where placeholder should be - substituted + substituted. The current block can be parsed with <function>HTML_Template_IT::parseCurrentTemplate</function>. </para> </refsect1> <refsect1 id="package.html.html-template-it.setcurrentblock.parameter"> @@ -42,7 +42,7 @@ &title.returns; <para> <parameter>boolean</parameter> - - &true;, if succcessful set + &true;, if found and succcessful set, otherwise IT_Error will be returned. </para> </refsect1> <refsect1 id="package.html.html-template-it.setcurrentblock.throws"> @@ -82,8 +82,15 @@ <refsect1 id="package.html.html-template-it.setcurrentblock.note"> &title.note; &note.notstatic; - </refsect1> - </refentry> + </refsect1> + <refsect1 id="package.html.html-template-it.setcurrentblock.see"> + &title.see; + <para> + <link linkend="package.html.html-template-it.parsecurrentblock"> + <function>HTML_Template_it::parseCurrentBlock</function></link>, + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml http://cvs.php.net/viewvc.cgi/peardoc/en/package/html/html-template-it/setroot.xml?r1=1.1.1.1&r2=1.2&diff_format=u Index: peardoc/en/package/html/html-template-it/setroot.xml diff -u peardoc/en/package/html/html-template-it/setroot.xml:1.1.1.1 peardoc/en/package/html/html-template-it/setroot.xml:1.2 --- peardoc/en/package/html/html-template-it/setroot.xml:1.1.1.1 Tue Oct 1 03:23:13 2002 +++ peardoc/en/package/html/html-template-it/setroot.xml Tue Sep 5 17:03:01 2006 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.1.1.1 $ --> +<!-- $Revision: 1.2 $ --> <refentry id="package.html.html-template-it.setroot"> <refnamediv> <refname>HTML_Template_IT::setRoot()</refname> @@ -11,7 +11,7 @@ </funcsynopsisinfo> <funcprototype> <funcdef>void - <function>IntegratedTemplate::setRoot</function></funcdef> + <function>HTML_Template_IT::setRoot</function></funcdef> <paramdef> string <parameter>$root</parameter> </paramdef> @@ -21,9 +21,8 @@ <refsect1 id="package.html.html-template-it.setroot.desc"> &title.desc; <para> - The given string will be prefixed to all file names passed - to the object. In the most cases, the directory where - the template files reside. + Sets the path to the template directory where <function>HTML_Template_IT::loadTemplatefile</function> +searches for templates. Every filename is prefixed with the given string. </para> </refsect1> <refsect1 id="package.html.html-template-it.setroot.parameter"> @@ -32,13 +31,71 @@ <itemizedlist> <listitem> <para> - <parameter>string $template</parameter> - - template + <parameter>string $root</parameter> - + Path to the template directory. </para> </listitem> </itemizedlist> </para> </refsect1> + <refsect1 id="package.html.html-template-it.setroot.example"> + &title.example; + <example> + <title>Directorytree.</title> + <programlisting> + <![CDATA[ +./ +./testscript.php +./templates/design01/main.tpl.htm +./templates/design01/table.tpl.htm +./templates/design02/main.tpl.htm +./templates/design02/table.tpl.htm + ]]> + </programlisting> + </example> + <example> + <title>script - testscript.php</title> + <programlisting role="php"> + <![CDATA[ +<?php + /* + * testscipt.php - sets a random design + */ + + require_once "HTML/Template/IT.php"; + + $tpl = new HTML_Template_IT(); + + $randomNumber = (int) round(rand(0,1)); + switch ($randomNumber) + { + case 0: + // Set root to design01 so the called main.tpl.htm is searched there + $tpl->setRoot("./templates/design01"); + break; + case 1: + default: + // Set root to design02 so the called main.tpl.htm is searched there + $tpl->setRoot("./templates/design02"); + break; + } + + /* Loads either ./templates/design01/main.tpl.htm + * or ./templates/design02/main.tpl.htm depending on the root directory set + * with setRoot in the switch */ + $tpl->loadTemplatefile("main.tpl.htm", true, true); + + /* ... assign variables .. */ + + // show + $tpl->show(); + +?> + ]]> + </programlisting> + </example> + </refsect1> + <refsect1 id="package.html.html-template-it.setroot.note"> &title.note; &note.notstatic; @@ -47,7 +104,9 @@ &title.see; <para> <link linkend="package.html.html-template-it.html-template-it"> - <function>HTML_Template_IT::HTML_Template_IT</function></link> + <function>HTML_Template_IT::HTML_Template_IT</function></link>, + <link linkend="package.html.html-template-it.loadtemplatefile"> + <function>HTML_Template_IT::loadTemplatefile</function></link> </para> </refsect1> </refentry> http://cvs.php.net/viewvc.cgi/peardoc/en/package/html/html-template-it/settemplate.xml?r1=1.2&r2=1.3&diff_format=u Index: peardoc/en/package/html/html-template-it/settemplate.xml diff -u peardoc/en/package/html/html-template-it/settemplate.xml:1.2 peardoc/en/package/html/html-template-it/settemplate.xml:1.3 --- peardoc/en/package/html/html-template-it/settemplate.xml:1.2 Mon Oct 13 11:09:27 2003 +++ peardoc/en/package/html/html-template-it/settemplate.xml Tue Sep 5 17:03:01 2006 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <refentry id="package.html.html-template-it.settemplate"> <refnamediv> <refname>HTML_Template_IT::setTemplate()</refname> @@ -11,7 +11,7 @@ </funcsynopsisinfo> <funcprototype> <funcdef>boolean - <function>IntegratedTemplate::setTemplate</function></funcdef> + <function>HTML_Template_IT::setTemplate</function></funcdef> <paramdef>string <parameter>$template</parameter> </paramdef> <paramdef>boolean @@ -26,7 +26,7 @@ <refsect1 id="package.html.html-template-it.settemplate.desc"> &title.desc; <para> - Sets the template and controls the behavior in case of unused + Loads template from a string and controls the behavior in case of unused variables and blocks </para> </refsect1> @@ -37,7 +37,7 @@ <listitem> <para> <parameter>string $template</parameter> - - template + The content of the template. </para> </listitem> <listitem> @@ -63,6 +63,62 @@ &return.success; </para> </refsect1> + <refsect1 id="package.html.html-template-it.settemplate.example"> + &title.example; + <example> + <title>Script</title> + <programlisting role="php"> + <![CDATA[ +<?php + require_once "HTML/Template/IT.php"; + + $data = array + ( + "0" => array("Stig", "Bakken"), + "1" => array("Martin", "Jansen"), + "2" => array("Alexander", "Merz") + ); + + $templateString = <<<EOD +<html> + <table> +<!-- BEGIN row --> + <tr> +<!-- BEGIN cell --> + <td> + {DATA} + </td> +<!-- END cell --> + </tr> +<!-- END row --> + </table> +</html> +EOD; + + + $tpl = new HTML_Template_IT(); + $tpl->setTemplate($templateString, true, true); + + foreach($data as $name) { + foreach($name as $cell) { + // Assign data to the inner block + $tpl->setCurrentBlock("cell") ; + $tpl->setVariable("DATA", $cell) ; + $tpl->parseCurrentBlock("cell") ; + } + + // parse outter block + $tpl->parse("row"); + } + // show + $tpl->show(); + +?> + ]]> + </programlisting> + </example> + </refsect1> + <refsect1 id="package.html.html-template-it.settemplate.note"> &title.note; &note.notstatic; http://cvs.php.net/viewvc.cgi/peardoc/en/package/html/html-template-it/setvariable.xml?r1=1.1.1.1&r2=1.2&diff_format=u Index: peardoc/en/package/html/html-template-it/setvariable.xml diff -u peardoc/en/package/html/html-template-it/setvariable.xml:1.1.1.1 peardoc/en/package/html/html-template-it/setvariable.xml:1.2 --- peardoc/en/package/html/html-template-it/setvariable.xml:1.1.1.1 Tue Oct 1 03:23:13 2002 +++ peardoc/en/package/html/html-template-it/setvariable.xml Tue Sep 5 17:03:01 2006 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.1.1.1 $ --> +<!-- $Revision: 1.2 $ --> <refentry id="package.html.html-template-it.setvariable"> <refnamediv> <refname>HTML_Template_IT::setVariable()</refname> @@ -11,7 +11,7 @@ </funcsynopsisinfo> <funcprototype> <funcdef>void - <function>IntegratedTemplate::setVariable</function></funcdef> + <function>HTML_Template_IT::setVariable</function></funcdef> <paramdef>mixed <parameter>$placeholder</parameter></paramdef> <paramdef>mixed @@ -22,7 +22,9 @@ <refsect1 id="package.html.html-template-it.setvariable.desc"> &title.desc; <para> - Set the value of a variable in the current template block + Set the value of a variable in the current template block. +If <parameter>$placeholder</parameter> is an array the key of an element +is treated as a placeholder name while the value is treated as it's substitution. </para> </refsect1> <refsect1 id="package.html.html-template-it.setvariable.parameter"> @@ -47,10 +49,100 @@ </itemizedlist> </para> </refsect1> + + <refsect1 id="package.html.html-template-it.setvariable.example"> + &title.example; + <example> + <title>Template - cvsnames.tpl.htm</title> + <programlisting role="html"> + <![CDATA[ +<html> + <table> +<!-- BEGIN row --> + <tr> + <td> + {CVS_USERNAME} + </td> + <td> + {REALNAME} + </td> + <td> + <ul> + <!-- BEGIN project_row --> + <li>{PROJECT}</li> + <!-- END project_row --> + </ul> + </td> + </tr> +<!-- END row --> + </table> +</html> + ]]> + </programlisting> + </example> + + <example> + <title>Script</title> + <programlisting role="php"> + <![CDATA[ +<?php + require_once "HTML/Template/IT.php"; + + $data = array + ( + "0" => array("cvs_username" => "pajoye", + "realname" => "Pierre-Alain Joye", + "projects" => array("PEAR", + "PEAR_Frontend_Web", + "PEAR_RemoteInstaller", + "HTML_Template_IT")), + "1" => array("cvs_username" => "dsp", + "realname" => "David Soria Parra", + "projects" => array("HTML_Template_IT")) + ); + + $tpl = new HTML_Template_IT("./templates"); + + $tpl->loadTemplatefile("cvsnames.tpl.htm", true, true); + + foreach($data as $name) { + // Assign data to the inner block + + $tpl->setCurrentBlock("project_row"); + foreach ($name['projects'] as $projectname) { + $tpl->setVariable("PROJECT", $projectname); + $tpl->parseCurrentBlock(); + } + + // use the possbility to set the placeholders using an assoc array + $tpl->setVariable( + array("CVS_USERNAME" => $name["cvs_username"], + "REALNAME" => $name["realname"]) + ); + + $tpl->parse("row"); + } + + // show() parses the __global__ block and + // print the output + $tpl->show(); + +?> + ]]> + </programlisting> + </example> + </refsect1> <refsect1 id="package.html.html-template-it.setvariable.note"> &title.note; &note.notstatic; </refsect1> + <refsect1 id="package.html.html-template-it.setvariable.see"> + &title.see; + <para> + <link linkend="package.html.html-template-it.parse"> + <function>HTML_Template_IT::parse</function></link> + </para> + </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: http://cvs.php.net/viewvc.cgi/peardoc/en/package/html/html-template-it/show.xml?r1=1.2&r2=1.3&diff_format=u Index: peardoc/en/package/html/html-template-it/show.xml diff -u peardoc/en/package/html/html-template-it/show.xml:1.2 peardoc/en/package/html/html-template-it/show.xml:1.3 --- peardoc/en/package/html/html-template-it/show.xml:1.2 Tue Jun 17 11:10:35 2003 +++ peardoc/en/package/html/html-template-it/show.xml Tue Sep 5 17:03:01 2006 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <refentry id="package.html.html-template-it.show"> <refnamediv> <refname>HTML_Template_IT::show()</refname> @@ -11,7 +11,7 @@ </funcsynopsisinfo> <funcprototype> <funcdef>void - <function>IntegratedTemplate::show</function></funcdef> + <function>HTML_Template_IT::show</function></funcdef> <paramdef> string <parameter><optional>$block</optional></parameter> </paramdef> @@ -38,13 +38,6 @@ </itemizedlist> </para> </refsect1> - <refsect1 id="package.html.html-template-it.show.return"> - &title.returns; - <para> - <parameter>string</parameter> - - the template with replacments - </para> - </refsect1> <refsect1 id="package.html.html-template-it.show.throws"> &title.throws; <para> @@ -83,7 +76,14 @@ &title.note; &note.notstatic; </refsect1> - </refentry> + <refsect1 id="package.html.html-template-it.show.see"> + &title.see; + <para> + <link linkend="package.html.html-template-it.get"> + <function>HTML_Template_IT::get</function></link> + </para> + </refsect1> + </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml http://cvs.php.net/viewvc.cgi/peardoc/en/package/html/html-template-it/touchblock.xml?r1=1.3&r2=1.4&diff_format=u Index: peardoc/en/package/html/html-template-it/touchblock.xml diff -u peardoc/en/package/html/html-template-it/touchblock.xml:1.3 peardoc/en/package/html/html-template-it/touchblock.xml:1.4 --- peardoc/en/package/html/html-template-it/touchblock.xml:1.3 Wed Aug 13 16:01:03 2003 +++ peardoc/en/package/html/html-template-it/touchblock.xml Tue Sep 5 17:03:01 2006 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <refentry id="package.html.html-template-it.touchblock"> <refnamediv> <refname>HTML_Template_IT::touchBlock()</refname> @@ -11,7 +11,7 @@ </funcsynopsisinfo> <funcprototype> <funcdef>boolean - <function>IntegratedTemplate::touchBlock</function></funcdef> + <function>HTML_Template_IT::touchBlock</function></funcdef> <paramdef>string <parameter>$block</parameter> </paramdef> @@ -21,7 +21,7 @@ <refsect1 id="package.html.html-template-it.touchblock.desc"> &title.desc; <para> - Preserves an empty template block, even if removeEmptyBlocks is &true; and + Preserves an empty template block, even if <parameter>$removeEmptyBlocks</parameter> is &true; and no substition of placeholders took place. </para> </refsect1> @@ -42,9 +42,54 @@ &title.returns; <para> <parameter>boolean</parameter> - - &true;, if block was found + &true;, if block was found, otherwise IT_Error. </para> </refsect1> + <refsect1 id="package.html.html-template-it.touchblock.example"> + &title.example; + <example> + <title>Template - login.tpl.htm</title> + <programlisting role="html"> + <![CDATA[ +<html> +<body> +<!-- BEGIN login_successfull --> +You have logged in successfully! +<!-- END login_successfull --> +<!-- BEGIN login_failed --> +Login failed +<!-- END login_failed --> +</body> +</html> + ]]> + </programlisting> + </example> + <example> + <title>Script</title> + <programlisting role="php"> + <![CDATA[ +<?php + require_once "HTML/Template/IT.php"; + + // Remove blocks with no placeholders, or no placeholders set ($removeEmptyBlocks=true) + $tpl->loadTemplatefile("login.tpl.htm", true, true); + + // hypothetical + if (login_successfull($username, $password)) { + // print login_successfull block. + // login_failed is removed, due to $removeEmptyBlocks = true + $tpl->touchBlock("login_successfull"); + } else { + $tpl->touchBlock("login_failed"); + + $tpl->show(); + +?> + ]]> + </programlisting> + </example> + </refsect1> + <refsect1 id="package.html.html-template-it.touchblock.throws"> &title.throws; <para>
« previous php.pear.doc (#8397) next »