cvs: pear /HTML_Template_Xipe/docs/Cache index.php index.tpl /HTML_Template_Xipe/docs/Cache/tmp .htaccess /HTML_Template_Xipe/docs/autoBracesOff
index.php index.tpl /HTML_Template_Xipe/docs/autoBracesOff/tmp .htaccess
| From: | Wolfram Kriesing | Date: | Mon, 10 Feb 2003 22:18:46 +0000 |
| Subject: | cvs: pear /HTML_Template_Xipe/docs/Cache index.php index.tpl /HTML_Template_Xipe/docs/Cache/tmp .htaccess /HTML_Template_Xipe/docs/autoBracesOff index.php index.tpl /HTML_Template_Xipe/docs/autoBracesOff/tmp .htaccess |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-8805@lists.php.net to get a copy of this message | ||
cain Mon Feb 10 17:18:46 2003 EDT
Added files:
/pear/HTML_Template_Xipe/docs/autoBracesOff index.php index.tpl
/pear/HTML_Template_Xipe/docs/autoBracesOff/tmp .htaccess
/pear/HTML_Template_Xipe/docs/Cache index.php index.tpl
/pear/HTML_Template_Xipe/docs/Cache/tmp .htaccess
Log:
- moved here
Index: pear/HTML_Template_Xipe/docs/autoBracesOff/index.php +++ pear/HTML_Template_Xipe/docs/autoBracesOff/index.php <?php // // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.02 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Wolfram Kriesing <wolfram@kriesing.de> | // +----------------------------------------------------------------------+ // $Id: index.php,v 1.1 2003/02/10 22:18:46 cain Exp $ //ini_set('include_path',realpath(dirname(__FILE__).'/../../../../../').':'.realpath(dirname(__FILE__).'/../../../../../../includes').':'.ini_get('include_path')); //ini_set('error_reporting',E_ALL); // // include the files needed // require_once('HTML/Template/Xipe.php'); require_once('HTML/Template/Xipe/Filter/Basic.php'); // // make template class instance // $options = array( 'templateDir' => dirname(__FILE__), 'compileDir' => 'tmp', // use the compile dir 'tmp' under the tempalte dir 'autoBraces' => false ); $tpl = new HTML_Template_Xipe($options); // fill some vars $nums = array('one','two','three'); // // show the template // $tpl->compile('index.tpl'); include($tpl->getCompiledTemplate()); ?> Index: pear/HTML_Template_Xipe/docs/autoBracesOff/index.tpl +++ pear/HTML_Template_Xipe/docs/autoBracesOff/index.tpl <!--// // // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.02 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Wolfram Kriesing <wolfram@kriesing.de> | // +----------------------------------------------------------------------+ // $Id: index.tpl,v 1.1 2003/02/10 22:18:46 cain Exp $ //--> <html> <head> <title>Example - HTML_Template_Xipe - autoBraces:off</title> <link href="../style.css" type="text/css" rel="StyleSheet"> </head> <body> {if(sizeof($nums)>1):} {foreach($nums as $aNum):} {$aNum} <br> {endforeach;}{endif;} <!-- the same as above, just nicely formatted :-) --> {if(sizeof($nums)>1):} {foreach($nums as $aNum):} {$aNum} <br> {endforeach} {endif} </body> </html> Index: pear/HTML_Template_Xipe/docs/autoBracesOff/tmp/.htaccess +++ pear/HTML_Template_Xipe/docs/autoBracesOff/tmp/.htaccess Options -Indexes Index: pear/HTML_Template_Xipe/docs/Cache/index.php +++ pear/HTML_Template_Xipe/docs/Cache/index.php <?php // // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.02 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Wolfram Kriesing <wolfram@kriesing.de> | // +----------------------------------------------------------------------+ // $Id: index.php,v 1.1 2003/02/10 22:18:46 cain Exp $ // // include the files needed // //ini_set('include_path',realpath(dirname(__FILE__).'/../../../../../').':'.realpath(dirname(__FILE__).'/../../../../../../includes').':'.ini_get('include_path')); //ini_set('error_reporting',E_ALL); require_once 'HTML/Template/Xipe.php'; // // make template class instance // $options = array( 'templateDir' => dirname(__FILE__), 'compileDir' => 'tmp', // this is default too 'enable-Cache' => true, 'logLevel' => 1 //,'debug'=>1 ); $tpl = new HTML_Template_Xipe($options); $tplFile = 'index.tpl'; // if the final output is not cached do the heavy work here if( !$tpl->isCached($tplFile) ) { print 'CACHE MISS, GENERATING CACHE FILE NOW!'; } $tpl->compile($tplFile); // call this method also if cached, to generate the property used in getCompiledTemplate() // if the file is cached no compilation is done include($tpl->getCompiledTemplate()); // include the (cached) file ?> Index: pear/HTML_Template_Xipe/docs/Cache/index.tpl +++ pear/HTML_Template_Xipe/docs/Cache/index.tpl <!-- // // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.02 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Wolfram Kriesing <wolfram@kriesing.de> | // +----------------------------------------------------------------------+ // $Id: index.tpl,v 1.1 2003/02/10 22:18:46 cain Exp $ --> <!-- the caching options this could also be in a file 'config.xml' (as the name is by default) which needs to be located under the templateDir --> <HTML_Template_Xipe> <options> <cache> <time value="10" unit="seconds"/> </cache> </options> </HTML_Template_Xipe> <html> <head> <title>Example - HTML_Template_Xipe - Cache</title> <link href="../style.css" type="text/css" rel="StyleSheet"> </head> <body> <h1>Using the caching feature of HTML_Template_Xipe</h1> Turning the feature on.<br> As usual include the template engine and set the options. In the options you simply add 'enable-Cache' and set it to true and that's it.<br> <pre class="code"> require_once('HTML/Template/Xipe.php'); $options = array( 'templateDir' => dirname(__FILE__), 'compileDir' => 'tmp', 'enable-Cache' => true // turn caching on ); $tpl = new HTML_Template_Xipe($options); </pre> <br> Now you can cache any file you want, simply by adding a short xml tag either in the template file itself or you put it in a config-file which by default is named config.xml, this file must be found along the path to the template. The engine starts looking for the file in the template-dir and searched all the way to the current template. All the config-files found on the way are applied in the same order. The last config that gets applied is the one in the template itself if given.<br> The configuration of a template is as easy as you can see in the following: <pre class="code"> <Template-Xipe> <options> <cache> <time value="100" /> </cache> </options> </Template-Xipe> </pre> this would simply cache the template's output (the final html file) for 100 seconds.<br> <h2>Dependencies</h2> Mostly it is necessary to cache the output depending on some variables, such as some input parameters or depending on the values set by the previous/next logic of some kind of list view, etc.<br> Therefore you can use the additional tag 'depends' inside the 'cache' tag, which takes any kind of varible that is deinfed in the global namespace.<br> For example:<br> <pre class="code"> <Template-Xipe> <options> <cache> <time value="1" unit="week" /> <depends value="$_SESSION $myVar $anyVar" /> </cache> </options> </Template-Xipe> </pre> <br> BE WARNED: letting a cache-file depend on i.e. $_REQUEST makes it possible to run a DOS-attack, since a new cache file has to be created everytime any request parameter changes, i.e. 'http://your.site.com/index.php?whatever' this might flood your webservers diskspace. <h2>Syntax</h2> The syntax of the caching tag is:<br> <pre class="code"> <Template-Xipe> <options> <cache> <time value="x" [unit="week|weeks|day|days|hour|hours|minute|minutes|second"]/> [<depends value="$_SESSION $myVar $anyVar" />] </cache> </options> </Template-Xipe> </pre> </body></html> Index: pear/HTML_Template_Xipe/docs/Cache/tmp/.htaccess +++ pear/HTML_Template_Xipe/docs/Cache/tmp/.htaccess Options -Indexes
Index: pear/HTML_Template_Xipe/docs/autoBracesOff/index.php +++ pear/HTML_Template_Xipe/docs/autoBracesOff/index.php <?php // // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.02 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Wolfram Kriesing <wolfram@kriesing.de> | // +----------------------------------------------------------------------+ // $Id: index.php,v 1.1 2003/02/10 22:18:46 cain Exp $ //ini_set('include_path',realpath(dirname(__FILE__).'/../../../../../').':'.realpath(dirname(__FILE__).'/../../../../../../includes').':'.ini_get('include_path')); //ini_set('error_reporting',E_ALL); // // include the files needed // require_once('HTML/Template/Xipe.php'); require_once('HTML/Template/Xipe/Filter/Basic.php'); // // make template class instance // $options = array( 'templateDir' => dirname(__FILE__), 'compileDir' => 'tmp', // use the compile dir 'tmp' under the tempalte dir 'autoBraces' => false ); $tpl = new HTML_Template_Xipe($options); // fill some vars $nums = array('one','two','three'); // // show the template // $tpl->compile('index.tpl'); include($tpl->getCompiledTemplate()); ?> Index: pear/HTML_Template_Xipe/docs/autoBracesOff/index.tpl +++ pear/HTML_Template_Xipe/docs/autoBracesOff/index.tpl <!--// // // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.02 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Wolfram Kriesing <wolfram@kriesing.de> | // +----------------------------------------------------------------------+ // $Id: index.tpl,v 1.1 2003/02/10 22:18:46 cain Exp $ //--> <html> <head> <title>Example - HTML_Template_Xipe - autoBraces:off</title> <link href="../style.css" type="text/css" rel="StyleSheet"> </head> <body> {if(sizeof($nums)>1):} {foreach($nums as $aNum):} {$aNum} <br> {endforeach;}{endif;} <!-- the same as above, just nicely formatted :-) --> {if(sizeof($nums)>1):} {foreach($nums as $aNum):} {$aNum} <br> {endforeach} {endif} </body> </html> Index: pear/HTML_Template_Xipe/docs/autoBracesOff/tmp/.htaccess +++ pear/HTML_Template_Xipe/docs/autoBracesOff/tmp/.htaccess Options -Indexes Index: pear/HTML_Template_Xipe/docs/Cache/index.php +++ pear/HTML_Template_Xipe/docs/Cache/index.php <?php // // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.02 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Wolfram Kriesing <wolfram@kriesing.de> | // +----------------------------------------------------------------------+ // $Id: index.php,v 1.1 2003/02/10 22:18:46 cain Exp $ // // include the files needed // //ini_set('include_path',realpath(dirname(__FILE__).'/../../../../../').':'.realpath(dirname(__FILE__).'/../../../../../../includes').':'.ini_get('include_path')); //ini_set('error_reporting',E_ALL); require_once 'HTML/Template/Xipe.php'; // // make template class instance // $options = array( 'templateDir' => dirname(__FILE__), 'compileDir' => 'tmp', // this is default too 'enable-Cache' => true, 'logLevel' => 1 //,'debug'=>1 ); $tpl = new HTML_Template_Xipe($options); $tplFile = 'index.tpl'; // if the final output is not cached do the heavy work here if( !$tpl->isCached($tplFile) ) { print 'CACHE MISS, GENERATING CACHE FILE NOW!'; } $tpl->compile($tplFile); // call this method also if cached, to generate the property used in getCompiledTemplate() // if the file is cached no compilation is done include($tpl->getCompiledTemplate()); // include the (cached) file ?> Index: pear/HTML_Template_Xipe/docs/Cache/index.tpl +++ pear/HTML_Template_Xipe/docs/Cache/index.tpl <!-- // // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.02 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Wolfram Kriesing <wolfram@kriesing.de> | // +----------------------------------------------------------------------+ // $Id: index.tpl,v 1.1 2003/02/10 22:18:46 cain Exp $ --> <!-- the caching options this could also be in a file 'config.xml' (as the name is by default) which needs to be located under the templateDir --> <HTML_Template_Xipe> <options> <cache> <time value="10" unit="seconds"/> </cache> </options> </HTML_Template_Xipe> <html> <head> <title>Example - HTML_Template_Xipe - Cache</title> <link href="../style.css" type="text/css" rel="StyleSheet"> </head> <body> <h1>Using the caching feature of HTML_Template_Xipe</h1> Turning the feature on.<br> As usual include the template engine and set the options. In the options you simply add 'enable-Cache' and set it to true and that's it.<br> <pre class="code"> require_once('HTML/Template/Xipe.php'); $options = array( 'templateDir' => dirname(__FILE__), 'compileDir' => 'tmp', 'enable-Cache' => true // turn caching on ); $tpl = new HTML_Template_Xipe($options); </pre> <br> Now you can cache any file you want, simply by adding a short xml tag either in the template file itself or you put it in a config-file which by default is named config.xml, this file must be found along the path to the template. The engine starts looking for the file in the template-dir and searched all the way to the current template. All the config-files found on the way are applied in the same order. The last config that gets applied is the one in the template itself if given.<br> The configuration of a template is as easy as you can see in the following: <pre class="code"> <Template-Xipe> <options> <cache> <time value="100" /> </cache> </options> </Template-Xipe> </pre> this would simply cache the template's output (the final html file) for 100 seconds.<br> <h2>Dependencies</h2> Mostly it is necessary to cache the output depending on some variables, such as some input parameters or depending on the values set by the previous/next logic of some kind of list view, etc.<br> Therefore you can use the additional tag 'depends' inside the 'cache' tag, which takes any kind of varible that is deinfed in the global namespace.<br> For example:<br> <pre class="code"> <Template-Xipe> <options> <cache> <time value="1" unit="week" /> <depends value="$_SESSION $myVar $anyVar" /> </cache> </options> </Template-Xipe> </pre> <br> BE WARNED: letting a cache-file depend on i.e. $_REQUEST makes it possible to run a DOS-attack, since a new cache file has to be created everytime any request parameter changes, i.e. 'http://your.site.com/index.php?whatever' this might flood your webservers diskspace. <h2>Syntax</h2> The syntax of the caching tag is:<br> <pre class="code"> <Template-Xipe> <options> <cache> <time value="x" [unit="week|weeks|day|days|hour|hours|minute|minutes|second"]/> [<depends value="$_SESSION $myVar $anyVar" />] </cache> </options> </Template-Xipe> </pre> </body></html> Index: pear/HTML_Template_Xipe/docs/Cache/tmp/.htaccess +++ pear/HTML_Template_Xipe/docs/Cache/tmp/.htaccess Options -Indexes