- fix issue outlined by Emmanuel Engelhart <emmanuel@engelhart.org> on wikitech-l
[mediawiki.git] / PHPTAL-NP-0.7.0 / libs / PHPTAL / Cache.php
blob68217895741b448715947653cc91241e2aee3186
1 <?php
2 /* vim: set expandtab tabstop=4 shiftwidth=4: */
3 //
4 // Copyright (c) 2003 Laurent Bedubourg
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // Authors: Laurent Bedubourg <laurent.bedubourg@free.fr>
21 //
23 /**
24 * Interface to PHPTAL cache system.
26 * Implement this interface and use PHPTAL_Template::setCacheManager() method
27 * to intercept macro and template execution with your own cache system.
29 * The aim of this system is to fine grain the caching of PHPTAL results
30 * allowing the php coder to use whatever cache system he prefers with a
31 * good granularity as he can cache result of specific templates execution,
32 * and specific macros calls.
34 * @see Documentation.txt
35 * @author Laurent Bedubourg <laurent.bedubourg@free.fr>
37 class PHPTAL_Cache
39 /**
40 * Called each time a template has to be executed.
42 * This method must return the cache value or the template execution
43 * return.
45 * function template(&$tpl, $path, &$context)
46 * {
47 * // return cache if exists
48 * // else realy process template
49 * $res = $tpl->_process();
50 * // cache the result if needed
51 * // and return it
52 * return $res;
53 * }
55 * @param PHPTAL_Template -- the template that must be cached/executed
56 * @param string $path -- the template path
57 * @param PHPTAL_Context $ctx -- the execution context
59 * @return string
61 function template(&$tpl, $path, &$context)
63 return $tpl->_process();
67 /**
68 * Called each time a macro needs to be executed.
70 * This method allow cache on macro result. It must return the cache value
71 * or at least the macro execution result.
73 * function macro(&$macro, $file, $name, &$context)
74 * {
75 * // return cache if exists
76 * // else really process macro
77 * $res = $macro->_process();
78 * // cache the result if needed
79 * // and return it
80 * return $res
81 * }
84 * @param PHPTAL_Macro -- the macro to executed
85 * @param string $file -- the macro source file
86 * @param string $name -- the macro name
87 * @param PHPTAL_Context $context -- the current execution context
89 * @return string
91 function macro(&$macro, $file, $name, &$context)
93 return $macro->_process();