mirror of
https://github.com/friendica/friendica
synced 2024-10-11 07:04:33 +02:00
Merge pull request #1122 from tugelbend/master
Updated smarty template to 3.1.19
This commit is contained in:
commit
181ecc2197
|
@ -101,10 +101,6 @@
|
|||
});
|
||||
|
||||
// fancyboxes
|
||||
/*$("a.popupbox").fancybox({
|
||||
'transitionIn' : 'elastic',
|
||||
'transitionOut' : 'elastic'
|
||||
});*/
|
||||
$("a.popupbox").colorbox({
|
||||
'inline' : true,
|
||||
'transition' : 'elastic'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Smarty 3.1.11
|
||||
Smarty 3.1.19
|
||||
|
||||
Author: Monte Ohrt <monte at ohrt dot com >
|
||||
Author: Uwe Tews
|
||||
|
@ -120,7 +120,7 @@ $smarty->unregisterObject($object_name)
|
|||
$smarty->unregisterFilter($type, $function_name)
|
||||
$smarty->unregisterResource($resource_type)
|
||||
|
||||
$smarty->compileAllTemplates($extention = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null)
|
||||
$smarty->compileAllTemplates($extension = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null)
|
||||
$smarty->clearCompiledTemplate($resource_name = null, $compile_id = null, $exp_time = null)
|
||||
$smarty->testInstall()
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ Relative paths are available with {include file="..."} and
|
|||
$smarty->fetch('./foo.tpl') cannot be relative to a template, an
|
||||
exception is thrown.
|
||||
|
||||
Adressing a specific $template_dir
|
||||
Addressing a specific $template_dir
|
||||
|
||||
Smarty 3.1 introduces the $template_dir index notation.
|
||||
$smarty->fetch('[foo]bar.tpl') and {include file="[foo]bar.tpl"}
|
||||
|
|
|
@ -1,5 +1,298 @@
|
|||
===== trunk =====
|
||||
===== Smarty-3.1.11 =====
|
||||
===== 3.1.20-dev ===== (xx.xx.2014)
|
||||
===== 3.1.19 ===== (06.30.2014)
|
||||
20.06.2014
|
||||
- bugfix template variables could not be passed as paramter in {include} when the include was in a {nocache} section (topic 25131)
|
||||
|
||||
17.06.2014
|
||||
- bugfix large template text of some charsets could cause parsing errors (topic 24630)
|
||||
|
||||
08.06.2014
|
||||
- bugfix registered objects did not work after spelling fixes of 06.06.2014
|
||||
- bugfix {block} tags within {literal} .. {/literal} got not displayed correctly (topic 25024)
|
||||
- bugfix UNC WINDOWS PATH like "\\psf\path\to\dir" did not work as template directory (Issue 192)
|
||||
- bugfix {html_image} security check did fail on files relative to basedir (Issue 191)
|
||||
|
||||
06.06.2014
|
||||
- fixed PHPUnit outputFilterTrimWhitespaceTests.php assertion of test result
|
||||
- fixed spelling, PHPDoc , minor errors, code cleanup
|
||||
|
||||
02.06.2014
|
||||
- using multiple cwd with relative template dirs could result in identical compiled file names. (issue 194 and topic 25099)
|
||||
|
||||
19.04.2014
|
||||
- bugfix calling createTemplate(template, data) with empty data array caused notice of array to string conversion (Issue 189)
|
||||
- bugfix clearCompiledTemplate() did not delete files on WINDOWS when a compile_id was specified
|
||||
|
||||
18.04.2014
|
||||
- revert bugfix of 5.4.2014 because %-e date format is not supported on all operating systems
|
||||
|
||||
===== 3.1.18 ===== (07.04.2014)
|
||||
06.04.2014
|
||||
- bugfix template inheritance fail when using custom resource after patch of 8.3.2014 (Issue 187)
|
||||
- bugfix update of composer file (Issue 168 and 184)
|
||||
|
||||
05.04.2014
|
||||
- bugfix default date format leads to extra spaces when displaying dates with single digit days (Issue 165)
|
||||
|
||||
26.03.2014
|
||||
- bugfix Smart_Resource_Custom should not lowercase the resource name (Issue 183)
|
||||
|
||||
24.03.2014
|
||||
- bugfix using a {foreach} property like @iteration could fail when used in inheritance parent templates (Issue 182)
|
||||
|
||||
20.03.2014
|
||||
- bugfix $smarty->auto_literal and mbsting.func_overload 2, 6 or 7 did fail (forum topic 24899)
|
||||
|
||||
18.03.2014
|
||||
- revert change of 17.03.2014
|
||||
|
||||
17.03.2014
|
||||
- bugfix $smarty->auto_literal and mbsting.func_overload 2, 6 or 7 did fail (forum topic 24899)
|
||||
|
||||
15.03.2014
|
||||
- bugfix Smarty_CacheResource_Keyvaluestore did use different keys on read/writes and clearCache() calls (Issue 169)
|
||||
|
||||
13.03.2014
|
||||
- bugfix clearXxx() change of 27.1.2014 did not work when specifing cache_id or compile_id (forum topic 24868 and 24867)
|
||||
|
||||
===== 3.1.17 =====
|
||||
08.03.2014
|
||||
- bugfix relative file path {include} within {block} of child templates did throw exception on first call (Issue 177)
|
||||
|
||||
17.02.2014
|
||||
- bugfix Smarty failed when executing PHP on HHVM (Hip Hop 2.4) because uniqid('',true) does return string with ',' (forum topic 20343)
|
||||
|
||||
16.02.2014
|
||||
- bugfix a '//' or '\\' in template_dir path could produce wrong path on relative filepath in {include} (Issue 175)
|
||||
|
||||
05.02.2014
|
||||
- bugfix shared.literal_compiler_param.php did throw an exception when literal did contain a '-' (smarty-developers group)
|
||||
|
||||
27.01.2014
|
||||
- bugfix $smarty->debugging = true; did show the variable of the $smarty object not the variables used in display() call (forum topic 24764)
|
||||
- bugfix clearCompiledTemplate(), clearAll() and clear() should use realpath to avoid possible exception from RecursiveDirectoryIterator (Issue 171)
|
||||
|
||||
26.01.2014
|
||||
- bugfix undo block nesting checks for {nocache} for reasons like forum topic 23280 (forum topic 24762)
|
||||
|
||||
18.01.2014
|
||||
- bugfix the compiler did fail when using template inheritance and recursive {include} (smarty-developers group)
|
||||
|
||||
11.01.2014
|
||||
- bugfix "* }" (spaces before right delimiter) was interpreted by mistake as comment end tag (Issue 170)
|
||||
- internals content cache should be clear when updating cache file
|
||||
|
||||
08.01.2014
|
||||
- bugfix Smarty_CacheResource_Custom did not handle template resource type specifications on clearCache() calls (Issue 169)
|
||||
- bugfix SmartyBC.class.php should use require_once to load Smarty.class.php (forum topic 24683)
|
||||
|
||||
===== 3.1.16 =====
|
||||
15.12.2013
|
||||
- bugfix {include} with {block} tag handling (forum topic 24599, 24594, 24682) (Issue 161)
|
||||
Read 3.1.16_RELEASE_NOTES for more details
|
||||
- enhancement additional debug output at $smarty->_parserdebug = true;
|
||||
|
||||
07.11.2013
|
||||
- bugfix too restrictive handling of {include} within {block} tags. 3.1.15 did throw errors where 3.1.14 did not (forum topic 24599)
|
||||
- bugfix compiler could fail if PHP mbstring.func_overload is enabled (Issue 164)
|
||||
|
||||
28.10.2013
|
||||
- bugfix variable resource name at custom resource plugin did not work within {block} tags (Issue 163)
|
||||
- bugfix notice "Trying to get property of non-object" removed (Issue 163)
|
||||
- bugfix correction of modifier capitalize fix from 3.10.2013 (issue 159)
|
||||
- bugfix multiple {block}s with same name in parent did not work (forum topic 24631)
|
||||
|
||||
20.10.2013
|
||||
- bugfix a variable file name at {extends} tag did fail (forum topic 24618)
|
||||
|
||||
14.10.2013
|
||||
- bugfix yesterdays fix could result in an undefined variable
|
||||
|
||||
13.10.2013
|
||||
- bugfix variable names on {include} in template inheritance did unextepted error message (forum topic 24594) (Issue 161)
|
||||
.- bugfix relative includes with same name like {include './foo.tpl'} from different folder failed (forum topic 24590)(Issue 161)
|
||||
|
||||
04.10.2013
|
||||
- bugfix variable file names at {extends} had been disbabled by mistake with the rewrite of
|
||||
template inheritance of 24.08.2013 (forum topic 24585)
|
||||
|
||||
03.10.2013
|
||||
- bugfix loops using modifier capitalize did eat up memory (issue 159)
|
||||
|
||||
===== Smarty 3.1.15 =====
|
||||
01.10.2013
|
||||
- use current delimiters in compiler error messages (issue 157)
|
||||
- improvement on performance when using error handler and multiple template folders (issue 152)
|
||||
|
||||
17.09.2013
|
||||
- improvement added patch for additional SmartyCompilerException properties for better access to scource information (forum topic 24559)
|
||||
|
||||
16.09.2013
|
||||
- bugfix recompiled templates did not show on first request with zend opcache cache (forum topic 24320)
|
||||
|
||||
13.09.2013
|
||||
- bugfix html_select_time defaulting error for the Meridian dropdown (forum topic 24549)
|
||||
|
||||
09.09.2012
|
||||
- bugfix incorrect compiled code with array(object,method) callback at registered Variable Filter (forum topic 24542)
|
||||
|
||||
27.08.2013
|
||||
- bugfix delimiter followed by linebreak did not work as auto literal after update from 24.08.2013 (forum topic 24518)
|
||||
|
||||
24.08.2013
|
||||
- bugfix and enhancement
|
||||
Because several recent problems with template inheritance the {block} tag compiler has been rewriten
|
||||
- Error messages shown now the correct child template file and line number
|
||||
- The compiler could fail on some larger UTF-8 text block (forum topic 24455)
|
||||
- The {strip} tag can now be placed outside {block} tags in child templates (forum topic 24289)
|
||||
- change SmartyException::$escape is now false by default
|
||||
- change PHP traceback has been remove for SmartyException and SmartyCompilerException
|
||||
|
||||
14.08.2013
|
||||
- bugfix compiled filepath of config file did not observe different config_dir (forum topic 24493)
|
||||
|
||||
13.08.2013
|
||||
- bugfix the internal resource cache did not observe config_dir changes (forum topic 24493)
|
||||
|
||||
12.08.2013
|
||||
- bugfix internal $tmpx variables must be unique over all inheritance templates (Issue 149)
|
||||
|
||||
10.08.2013
|
||||
- bugfix a newline was eaten when a <?xml ... ?> was passed by a Smarty variable and caching was enabled (forum topic 24482)
|
||||
|
||||
29.07.2013
|
||||
- bugfix headers already send warning thrown when using 'SMARTY_DEBUG=on' from URL (Issue 148)
|
||||
|
||||
27.07.2013
|
||||
- enhancement allow access to properties of registered opjects for Smarty2 BC (forum topic 24344)
|
||||
|
||||
26.07.2013
|
||||
- bugfix template inheritance nesting problem (forum topic 24387)
|
||||
|
||||
15.7.2013
|
||||
- update code generated by PSR-2 standards fixer which introduced PHP 5.4 incompatibilities of 14.7.2013
|
||||
|
||||
14.7.2013
|
||||
- bugfix increase of internal maximum parser stacksize to allow more complex tag code {forum topic 24426}
|
||||
- update for PHP 5.4 compatibility
|
||||
- reformat source to PSR-2 standard
|
||||
|
||||
12.7.2013
|
||||
- bugfix Do not remove '//' from file path at normalization (Issue 142)
|
||||
|
||||
2.7.2013
|
||||
- bugfix trimwhitespace would replace captured items in wrong order (forum topic 24387)
|
||||
|
||||
===== Smarty-3.1.14 =====
|
||||
27.06.2013
|
||||
- bugfix removed PHP 5.5 deprecated preg_replace /e option in modifier capitalize (forum topic 24389)
|
||||
|
||||
17.06.2013
|
||||
- fixed spelling in sources and documentation (from smarty-developers forum Veres Lajos)
|
||||
- enhancement added constant SMARTY::CLEAR_EXPIRED for the change of 26.05.2013 (forum topic 24310)
|
||||
- bugfix added smarty_security.php to composer.json (Issue 135)
|
||||
|
||||
26.05.2013
|
||||
- enhancement an expire_time of -1 in clearCache() and clearAllCache() will delete outdated cache files
|
||||
by their individual cache_lifetime used at creation (forum topic 24310)
|
||||
|
||||
21.05.2013
|
||||
- bugfix modifier strip_tags:true was compiled into wrong code (Forum Topic 24287)
|
||||
- bugfix /n after ?> in Smarty.class.php did start output buffering (Issue 138)
|
||||
|
||||
25.04.2013
|
||||
- bugfix escape and wordrap modifier could be compiled into wrong code when used in {nocache}{/nocache}
|
||||
section but caching is disabled (Forum Topic 24260)
|
||||
|
||||
05.04.2013
|
||||
- bugfix post filter must not run when compiling inheritance child blocks (Forum Topic 24094)
|
||||
- bugfix after the fix for Issue #130 compiler exceptions got double escaped (Forum Topic 24199)
|
||||
|
||||
28.02.2013
|
||||
- bugfix nocache blocks could be lost when using CACHING_LIFETIME_SAVED (Issue #133)
|
||||
- bugfix Compile ID gets nulled when compiling child blocks (Issue #134)
|
||||
|
||||
|
||||
24.01.2013
|
||||
- bugfix wrong tag type in smarty_internal_templatecompilerbase.php could cause wrong plugin search order (Forum Topic 24028)
|
||||
|
||||
===== Smarty-3.1.13 =====
|
||||
13.01.2013
|
||||
- enhancement allow to disable exception message escaping by SmartyException::$escape = false; (Issue #130)
|
||||
|
||||
09.01.2013
|
||||
- bugfix compilation did fail when a prefilter did modify an {extends} tag c
|
||||
- bugfix template inheritance could fail if nested {block} tags in childs did contain {$smarty.block.child} (Issue #127)
|
||||
- bugfix template inheritance could fail if {block} tags in childs did have similar name as used plugins (Issue #128)
|
||||
- added abstract method declaration doCompile() in Smarty_Internal_TemplateCompilerBase (Forum Topic 23969)
|
||||
|
||||
06.01.2013
|
||||
- Allow '://' URL syntax in template names of stream resources (Issue #129)
|
||||
|
||||
27.11.2012
|
||||
- bugfix wrong variable usage in smarty_internal_utility.php (Issue #125)
|
||||
|
||||
26.11.2012
|
||||
- bugfix global variable assigned within template function are not seen after template function exit (Forum Topic 23800)
|
||||
|
||||
24.11.2012
|
||||
- made SmartyBC loadable via composer (Issue #124)
|
||||
|
||||
20.11.2012
|
||||
- bugfix assignGlobal() called from plugins did not work (Forum Topic 23771)
|
||||
|
||||
13.11.2012
|
||||
- adding attribute "strict" to html_options, html_checkboxes, html_radios to only print disabled/readonly attributes if their values are true or "disabled"/"readonly" (Issue #120)
|
||||
|
||||
01.11.2012
|
||||
- bugfix muteExcpetedErrors() would screw up for non-readable paths (Issue #118)
|
||||
|
||||
===== Smarty-3.1.12 =====
|
||||
14.09.2012
|
||||
- bugfix template inheritance failed to compile with delimiters {/ and /} (Forum Topic 23008)
|
||||
|
||||
11.09.2012
|
||||
- bugfix escape Smarty exception messages to avoid possible script execution
|
||||
|
||||
10.09.2012
|
||||
- bugfix tag option flags and shorttag attributes did not work when rdel started with '=' (Forum Topic 22979)
|
||||
|
||||
31.08.2012
|
||||
- bugfix resolving relative paths broke in some circumstances (Issue #114)
|
||||
|
||||
22.08.2012
|
||||
- bugfix test MBString availability through mb_split, as it could've been compiled without regex support (--enable-mbregex).
|
||||
Either we get MBstring's full package, or we pretend it's not there at all.
|
||||
|
||||
21.08.2012
|
||||
- bugfix $auto_literal = false did not work with { block} tags in child templates
|
||||
(problem was reintroduced after fix in 3.1.7)(Forum Topic 20581)
|
||||
|
||||
17.08.2012
|
||||
- bugfix compiled code of nocache sections could contain wrong escaping (Forum Topic 22810)
|
||||
|
||||
15.08.2012
|
||||
- bugfix template inheritance did produce wrong code if subtemplates with {block} was
|
||||
included several times (from smarty-developers forum)
|
||||
|
||||
14.08.2012
|
||||
- bugfix PHP5.2 compatibility compromised by SplFileInfo::getBasename() (Issue 110)
|
||||
|
||||
01.08.2012
|
||||
- bugfix avoid PHP error on $smarty->configLoad(...) with invalid section specification (Forum Topic 22608)
|
||||
|
||||
30.07.2012
|
||||
-bugfix {assign} in a nocache section should not overwrite existing variable values
|
||||
during compilation (issue 109)
|
||||
|
||||
28.07.2012
|
||||
- bugfix array access of config variables did not work (Forum Topic 22527)
|
||||
|
||||
19.07.2012
|
||||
- bugfix the default plugin handler did create wrong compiled code for static class methods
|
||||
from external script files (issue 108)
|
||||
|
||||
===== Smarty-3.1.11 =====
|
||||
30.06.2012
|
||||
- bugfix {block.. hide} did not work as nested child (Forum Topic 22216)
|
||||
|
||||
|
@ -342,7 +635,7 @@
|
|||
03/09/2011
|
||||
- bugfix createTemplate() must default to cache_id and compile_id of Smarty object
|
||||
- bugfix Smarty_CacheResource_KeyValueStore must include $source->uid in cache filepath to keep templates with same
|
||||
name but different folders seperated
|
||||
name but different folders separated
|
||||
- added cacheresource.apc.php example in demo folder
|
||||
|
||||
02/09/2011
|
||||
|
@ -533,7 +826,7 @@
|
|||
- changed ./ and ../ behaviour
|
||||
|
||||
14/02/2011
|
||||
- added {block ... hide} option to supress block if no child is defined
|
||||
- added {block ... hide} option to suppress block if no child is defined
|
||||
|
||||
13/02/2011
|
||||
- update handling of recursive subtemplate calls
|
||||
|
@ -647,7 +940,7 @@
|
|||
- bugfix on compiler object destruction. compiler_object property was by mistake unset.
|
||||
|
||||
09/03/2011
|
||||
-bugfix a variable filter should run before modifers on an output tag (see change of 23/07/2010)
|
||||
-bugfix a variable filter should run before modifiers on an output tag (see change of 23/07/2010)
|
||||
|
||||
08/03/2011
|
||||
- bugfix loading config file without section should load only defaults
|
||||
|
@ -951,10 +1244,10 @@ request_use_auto_globals
|
|||
- bugfix passing scope attributes in doublequoted strings did not work at {include} {assign} and {append}
|
||||
|
||||
25/07/2010
|
||||
- another bugfix of change from 23/07/2010 when compiling modifer
|
||||
- another bugfix of change from 23/07/2010 when compiling modifier
|
||||
|
||||
24/07/2010
|
||||
- bugfix of change from 23/07/2010 when compiling modifer
|
||||
- bugfix of change from 23/07/2010 when compiling modifier
|
||||
|
||||
23/07/2010
|
||||
- changed execution order. A variable filter does now run before modifiers on output of variables
|
||||
|
@ -1261,7 +1554,7 @@ request_use_auto_globals
|
|||
- bugfix on {if} tags
|
||||
|
||||
01/12/2010
|
||||
- changed back modifer handling in parser. Some restrictions still apply:
|
||||
- changed back modifier handling in parser. Some restrictions still apply:
|
||||
if modifiers are used in side {if...} expression or in mathematical expressions
|
||||
parentheses must be used.
|
||||
- bugfix the {function..} tag did not accept the name attribute in double quotes
|
||||
|
@ -1873,7 +2166,7 @@ NOTICE: existing compiled template and cache files must be deleted
|
|||
- fixed exceptions in function plugins
|
||||
- fixed notice error in Smarty.class.php
|
||||
- allow chained objects to span multiple lines
|
||||
- fixed error in modifers
|
||||
- fixed error in modifiers
|
||||
|
||||
03/20/2009
|
||||
- moved /plugins folder into /libs folder
|
||||
|
@ -1881,7 +2174,7 @@ NOTICE: existing compiled template and cache files must be deleted
|
|||
- autoappend a directory separator if the xxxxx_dir definition have no trailing one
|
||||
|
||||
03/19/2009
|
||||
- allow array definition as modifer parameter
|
||||
- allow array definition as modifier parameter
|
||||
- changed modifier to use multi byte string funktions.
|
||||
|
||||
03/17/2009
|
||||
|
|
|
@ -1,33 +1,30 @@
|
|||
<?php
|
||||
/**
|
||||
/**
|
||||
* Example Application
|
||||
|
||||
*
|
||||
* @package Example-application
|
||||
*/
|
||||
|
||||
require('../libs/Smarty.class.php');
|
||||
require '../libs/Smarty.class.php';
|
||||
|
||||
$smarty = new Smarty;
|
||||
|
||||
|
||||
|
||||
//$smarty->force_compile = true;
|
||||
$smarty->debugging = true;
|
||||
$smarty->caching = true;
|
||||
$smarty->cache_lifetime = 120;
|
||||
|
||||
$smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill",true);
|
||||
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
|
||||
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
|
||||
$smarty->assign("Class",array(array("A","B","C","D"), array("E", "F", "G", "H"),
|
||||
array("I", "J", "K", "L"), array("M", "N", "O", "P")));
|
||||
$smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);
|
||||
$smarty->assign("FirstName", array("John", "Mary", "James", "Henry"));
|
||||
$smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));
|
||||
$smarty->assign("Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"),
|
||||
array("I", "J", "K", "L"), array("M", "N", "O", "P")));
|
||||
|
||||
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
|
||||
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
|
||||
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
|
||||
|
||||
$smarty->assign("option_values", array("NY","NE","KS","IA","OK","TX"));
|
||||
$smarty->assign("option_output", array("New York","Nebraska","Kansas","Iowa","Oklahoma","Texas"));
|
||||
$smarty->assign("option_values", array("NY", "NE", "KS", "IA", "OK", "TX"));
|
||||
$smarty->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas"));
|
||||
$smarty->assign("option_selected", "NE");
|
||||
|
||||
$smarty->display('index.tpl');
|
||||
?>
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
/**
|
||||
* APC CacheResource
|
||||
*
|
||||
* CacheResource Implementation based on the KeyValueStore API to use
|
||||
* memcache as the storage resource for Smarty's output caching.
|
||||
* *
|
||||
*
|
||||
* @package CacheResource-examples
|
||||
* @author Uwe Tews
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore {
|
||||
|
||||
class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// test if APC is present
|
||||
if(!function_exists('apc_cache_info')) {
|
||||
if (!function_exists('apc_cache_info')) {
|
||||
throw new Exception('APC Template Caching Error: APC is not installed');
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,9 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore {
|
|||
/**
|
||||
* Read values for a set of keys from cache
|
||||
*
|
||||
* @param array $keys list of keys to fetch
|
||||
* @return array list of values with the given keys used as indexes
|
||||
* @param array $keys list of keys to fetch
|
||||
*
|
||||
* @return array list of values with the given keys used as indexes
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function read(array $keys)
|
||||
|
@ -33,28 +34,32 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore {
|
|||
foreach ($res as $k => $v) {
|
||||
$_res[$k] = $v;
|
||||
}
|
||||
|
||||
return $_res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save values for a set of keys to cache
|
||||
*
|
||||
* @param array $keys list of values to save
|
||||
* @param int $expire expiration time
|
||||
* @param array $keys list of values to save
|
||||
* @param int $expire expiration time
|
||||
*
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function write(array $keys, $expire=null)
|
||||
protected function write(array $keys, $expire = null)
|
||||
{
|
||||
foreach ($keys as $k => $v) {
|
||||
apc_store($k, $v, $expire);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove values from cache
|
||||
*
|
||||
* @param array $keys list of keys to delete
|
||||
* @param array $keys list of keys to delete
|
||||
*
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function delete(array $keys)
|
||||
|
@ -62,6 +67,7 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore {
|
|||
foreach ($keys as $k) {
|
||||
apc_delete($k);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,34 +2,35 @@
|
|||
|
||||
/**
|
||||
* Memcache CacheResource
|
||||
*
|
||||
* CacheResource Implementation based on the KeyValueStore API to use
|
||||
* memcache as the storage resource for Smarty's output caching.
|
||||
*
|
||||
* Note that memcache has a limitation of 256 characters per cache-key.
|
||||
* To avoid complications all cache-keys are translated to a sha1 hash.
|
||||
*
|
||||
* @package CacheResource-examples
|
||||
* @author Rodney Rehm
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore {
|
||||
class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
|
||||
{
|
||||
/**
|
||||
* memcache instance
|
||||
*
|
||||
* @var Memcache
|
||||
*/
|
||||
protected $memcache = null;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->memcache = new Memcache();
|
||||
$this->memcache->addServer( '127.0.0.1', 11211 );
|
||||
$this->memcache->addServer('127.0.0.1', 11211);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read values for a set of keys from cache
|
||||
*
|
||||
* @param array $keys list of keys to fetch
|
||||
* @return array list of values with the given keys used as indexes
|
||||
* @param array $keys list of keys to fetch
|
||||
*
|
||||
* @return array list of values with the given keys used as indexes
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function read(array $keys)
|
||||
|
@ -45,29 +46,33 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore {
|
|||
foreach ($res as $k => $v) {
|
||||
$_res[$lookup[$k]] = $v;
|
||||
}
|
||||
|
||||
return $_res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save values for a set of keys to cache
|
||||
*
|
||||
* @param array $keys list of values to save
|
||||
* @param int $expire expiration time
|
||||
* @param array $keys list of values to save
|
||||
* @param int $expire expiration time
|
||||
*
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function write(array $keys, $expire=null)
|
||||
protected function write(array $keys, $expire = null)
|
||||
{
|
||||
foreach ($keys as $k => $v) {
|
||||
$k = sha1($k);
|
||||
$this->memcache->set($k, $v, 0, $expire);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove values from cache
|
||||
*
|
||||
* @param array $keys list of keys to delete
|
||||
* @param array $keys list of keys to delete
|
||||
*
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function delete(array $keys)
|
||||
|
@ -76,6 +81,7 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore {
|
|||
$k = sha1($k);
|
||||
$this->memcache->delete($k);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -86,6 +92,6 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore {
|
|||
*/
|
||||
protected function purge()
|
||||
{
|
||||
return $this->memcache->flush();
|
||||
$this->memcache->flush();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
/**
|
||||
* MySQL CacheResource
|
||||
*
|
||||
* CacheResource Implementation based on the Custom API to use
|
||||
* MySQL as the storage resource for Smarty's output caching.
|
||||
*
|
||||
* Table definition:
|
||||
* <pre>CREATE TABLE IF NOT EXISTS `output_cache` (
|
||||
* `id` CHAR(40) NOT NULL COMMENT 'sha1 hash',
|
||||
|
@ -22,19 +20,22 @@
|
|||
* ) ENGINE = InnoDB;</pre>
|
||||
*
|
||||
* @package CacheResource-examples
|
||||
* @author Rodney Rehm
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
|
||||
class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
|
||||
{
|
||||
// PDO instance
|
||||
protected $db;
|
||||
protected $fetch;
|
||||
protected $fetchTimestamp;
|
||||
protected $save;
|
||||
|
||||
public function __construct() {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty");
|
||||
} catch (PDOException $e) {
|
||||
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
|
||||
}
|
||||
$this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id');
|
||||
|
@ -46,19 +47,20 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
|
|||
/**
|
||||
* fetch cached content and its modification time from data source
|
||||
*
|
||||
* @param string $id unique cache content identifier
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param string $content cached content
|
||||
* @param integer $mtime cache modification timestamp (epoch)
|
||||
* @param string $id unique cache content identifier
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param string $content cached content
|
||||
* @param integer $mtime cache modification timestamp (epoch)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime)
|
||||
{
|
||||
$this->fetch->execute(array('id' => $id));
|
||||
$row = $this->fetch->fetch();
|
||||
$this->fetch->closeCursor();
|
||||
$this->fetch->closeCursor();
|
||||
if ($row) {
|
||||
$content = $row['content'];
|
||||
$mtime = strtotime($row['modified']);
|
||||
|
@ -67,15 +69,17 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
|
|||
$mtime = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch cached content's modification timestamp from data source
|
||||
*
|
||||
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the complete cached content.
|
||||
* @param string $id unique cache content identifier
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
*
|
||||
* @param string $id unique cache content identifier
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
*
|
||||
* @return integer|boolean timestamp (epoch) the template was modified, or false if not found
|
||||
*/
|
||||
protected function fetchTimestamp($id, $name, $cache_id, $compile_id)
|
||||
|
@ -83,40 +87,44 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
|
|||
$this->fetchTimestamp->execute(array('id' => $id));
|
||||
$mtime = strtotime($this->fetchTimestamp->fetchColumn());
|
||||
$this->fetchTimestamp->closeCursor();
|
||||
|
||||
return $mtime;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save content to cache
|
||||
*
|
||||
* @param string $id unique cache content identifier
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param integer|null $exp_time seconds till expiration time in seconds or null
|
||||
* @param string $content content to cache
|
||||
* @return boolean success
|
||||
* @param string $id unique cache content identifier
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param integer|null $exp_time seconds till expiration time in seconds or null
|
||||
* @param string $content content to cache
|
||||
*
|
||||
* @return boolean success
|
||||
*/
|
||||
protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content)
|
||||
{
|
||||
$this->save->execute(array(
|
||||
'id' => $id,
|
||||
'name' => $name,
|
||||
'cache_id' => $cache_id,
|
||||
'compile_id' => $compile_id,
|
||||
'content' => $content,
|
||||
));
|
||||
'id' => $id,
|
||||
'name' => $name,
|
||||
'cache_id' => $cache_id,
|
||||
'compile_id' => $compile_id,
|
||||
'content' => $content,
|
||||
));
|
||||
|
||||
return !!$this->save->rowCount();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete content from cache
|
||||
*
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param integer|null $exp_time seconds till expiration or null
|
||||
* @return integer number of deleted caches
|
||||
* @param string $name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param integer|null $exp_time seconds till expiration or null
|
||||
*
|
||||
* @return integer number of deleted caches
|
||||
*/
|
||||
protected function delete($name, $cache_id, $compile_id, $exp_time)
|
||||
{
|
||||
|
@ -124,7 +132,8 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
|
|||
if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) {
|
||||
// returning the number of deleted caches would require a second query to count them
|
||||
$query = $this->db->query('TRUNCATE TABLE output_cache');
|
||||
return -1;
|
||||
|
||||
return - 1;
|
||||
}
|
||||
// build the filter
|
||||
$where = array();
|
||||
|
@ -142,11 +151,12 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
|
|||
}
|
||||
// equal test cache_id and match sub-groups
|
||||
if ($cache_id !== null) {
|
||||
$where[] = '(cache_id = '. $this->db->quote($cache_id)
|
||||
. ' OR cache_id LIKE '. $this->db->quote($cache_id .'|%') .')';
|
||||
$where[] = '(cache_id = ' . $this->db->quote($cache_id)
|
||||
. ' OR cache_id LIKE ' . $this->db->quote($cache_id . '|%') . ')';
|
||||
}
|
||||
// run delete query
|
||||
$query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where));
|
||||
|
||||
return $query->rowCount();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,49 +2,51 @@
|
|||
|
||||
/**
|
||||
* Extends All Resource
|
||||
*
|
||||
* Resource Implementation modifying the extends-Resource to walk
|
||||
* through the template_dirs and inherit all templates of the same name
|
||||
*
|
||||
*
|
||||
* @package Resource-examples
|
||||
* @author Rodney Rehm
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends {
|
||||
|
||||
class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends
|
||||
{
|
||||
/**
|
||||
* populate Source Object with meta data from Resource
|
||||
*
|
||||
* @param Smarty_Template_Source $source source object
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
* @param Smarty_Template_Source $source source object
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null)
|
||||
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
|
||||
{
|
||||
$uid = '';
|
||||
$sources = array();
|
||||
$exists = true;
|
||||
foreach ($_template->smarty->getTemplateDir() as $key => $directory) {
|
||||
try {
|
||||
$s = Smarty_Resource::source(null, $source->smarty, '[' . $key . ']' . $source->name );
|
||||
$s = Smarty_Resource::source(null, $source->smarty, '[' . $key . ']' . $source->name);
|
||||
if (!$s->exists) {
|
||||
continue;
|
||||
}
|
||||
$sources[$s->uid] = $s;
|
||||
$uid .= $s->filepath;
|
||||
}
|
||||
catch (SmartyException $e) {}
|
||||
catch (SmartyException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$sources) {
|
||||
$source->exists = false;
|
||||
$source->template = $_template;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$sources = array_reverse($sources, true);
|
||||
reset($sources);
|
||||
$s = current($sources);
|
||||
|
||||
|
||||
$source->components = $sources;
|
||||
$source->filepath = $s->filepath;
|
||||
$source->uid = sha1($uid);
|
||||
|
@ -55,6 +57,4 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends {
|
|||
// need the template at getContent()
|
||||
$source->template = $_template;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
/**
|
||||
* MySQL Resource
|
||||
*
|
||||
* Resource Implementation based on the Custom API to use
|
||||
* MySQL as the storage resource for Smarty's templates and configs.
|
||||
*
|
||||
* Table definition:
|
||||
* <pre>CREATE TABLE IF NOT EXISTS `templates` (
|
||||
* `name` varchar(100) NOT NULL,
|
||||
|
@ -13,14 +11,14 @@
|
|||
* `source` text,
|
||||
* PRIMARY KEY (`name`)
|
||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
|
||||
*
|
||||
* Demo data:
|
||||
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
|
||||
*
|
||||
* @package Resource-examples
|
||||
* @author Rodney Rehm
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_Resource_Mysql extends Smarty_Resource_Custom {
|
||||
class Smarty_Resource_Mysql extends Smarty_Resource_Custom
|
||||
{
|
||||
// PDO instance
|
||||
protected $db;
|
||||
// prepared fetch() statement
|
||||
|
@ -28,22 +26,25 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom {
|
|||
// prepared fetchTimestamp() statement
|
||||
protected $mtime;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty");
|
||||
} catch (PDOException $e) {
|
||||
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
|
||||
}
|
||||
$this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name');
|
||||
$this->mtime = $this->db->prepare('SELECT modified FROM templates WHERE name = :name');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch a template and its modification time from database
|
||||
*
|
||||
* @param string $name template name
|
||||
* @param string $source template source
|
||||
* @param integer $mtime template modification timestamp (epoch)
|
||||
* @param string $name template name
|
||||
* @param string $source template source
|
||||
* @param integer $mtime template modification timestamp (epoch)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function fetch($name, &$source, &$mtime)
|
||||
|
@ -59,18 +60,22 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom {
|
|||
$mtime = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch a template's modification time from database
|
||||
*
|
||||
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the comple template source.
|
||||
* @param string $name template name
|
||||
*
|
||||
* @param string $name template name
|
||||
*
|
||||
* @return integer timestamp (epoch) the template was modified
|
||||
*/
|
||||
protected function fetchTimestamp($name) {
|
||||
protected function fetchTimestamp($name)
|
||||
{
|
||||
$this->mtime->execute(array('name' => $name));
|
||||
$mtime = $this->mtime->fetchColumn();
|
||||
$this->mtime->closeCursor();
|
||||
|
||||
return strtotime($mtime);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,10 @@
|
|||
|
||||
/**
|
||||
* MySQL Resource
|
||||
*
|
||||
* Resource Implementation based on the Custom API to use
|
||||
* MySQL as the storage resource for Smarty's templates and configs.
|
||||
*
|
||||
* Note that this MySQL implementation fetches the source and timestamps in
|
||||
* a single database query, instead of two seperate like resource.mysql.php does.
|
||||
*
|
||||
* a single database query, instead of two separate like resource.mysql.php does.
|
||||
* Table definition:
|
||||
* <pre>CREATE TABLE IF NOT EXISTS `templates` (
|
||||
* `name` varchar(100) NOT NULL,
|
||||
|
@ -16,34 +13,37 @@
|
|||
* `source` text,
|
||||
* PRIMARY KEY (`name`)
|
||||
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
|
||||
*
|
||||
* Demo data:
|
||||
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
|
||||
*
|
||||
* @package Resource-examples
|
||||
* @author Rodney Rehm
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
class Smarty_Resource_Mysqls extends Smarty_Resource_Custom {
|
||||
class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
|
||||
{
|
||||
// PDO instance
|
||||
protected $db;
|
||||
// prepared fetch() statement
|
||||
protected $fetch;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty");
|
||||
} catch (PDOException $e) {
|
||||
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
|
||||
}
|
||||
$this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch a template and its modification time from database
|
||||
*
|
||||
* @param string $name template name
|
||||
* @param string $source template source
|
||||
* @param integer $mtime template modification timestamp (epoch)
|
||||
* @param string $name template name
|
||||
* @param string $source template source
|
||||
* @param integer $mtime template modification timestamp (epoch)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function fetch($name, &$source, &$mtime)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>{$title} - {$Name}</TITLE>
|
||||
<TITLE>{$title} - {$Name}</TITLE>
|
||||
</HEAD>
|
||||
<BODY bgcolor="#ffffff">
|
||||
|
|
|
@ -4,18 +4,18 @@
|
|||
<PRE>
|
||||
|
||||
{* bold and title are read from the config file *}
|
||||
{if #bold#}<b>{/if}
|
||||
{* capitalize the first letters of each word of the title *}
|
||||
Title: {#title#|capitalize}
|
||||
{if #bold#}</b>{/if}
|
||||
{if #bold#}<b>{/if}
|
||||
{* capitalize the first letters of each word of the title *}
|
||||
Title: {#title#|capitalize}
|
||||
{if #bold#}</b>{/if}
|
||||
|
||||
The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
|
||||
The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
|
||||
|
||||
The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}
|
||||
The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}
|
||||
|
||||
Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
|
||||
Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
|
||||
|
||||
The value of {ldelim}$Name{rdelim} is <b>{$Name}</b>
|
||||
The value of {ldelim}$Name{rdelim} is <b>{$Name}</b>
|
||||
|
||||
variable modifier example of {ldelim}$Name|upper{rdelim}
|
||||
|
||||
|
@ -24,59 +24,64 @@ variable modifier example of {ldelim}$Name|upper{rdelim}
|
|||
|
||||
An example of a section loop:
|
||||
|
||||
{section name=outer
|
||||
loop=$FirstName}
|
||||
{if $smarty.section.outer.index is odd by 2}
|
||||
{$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}
|
||||
{else}
|
||||
{$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}
|
||||
{/if}
|
||||
{sectionelse}
|
||||
none
|
||||
{/section}
|
||||
{section name=outer
|
||||
loop=$FirstName}
|
||||
{if $smarty.section.outer.index is odd by 2}
|
||||
{$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}
|
||||
{else}
|
||||
{$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}
|
||||
{/if}
|
||||
{sectionelse}
|
||||
none
|
||||
{/section}
|
||||
|
||||
An example of section looped key values:
|
||||
An example of section looped key values:
|
||||
|
||||
{section name=sec1 loop=$contacts}
|
||||
phone: {$contacts[sec1].phone}<br>
|
||||
fax: {$contacts[sec1].fax}<br>
|
||||
cell: {$contacts[sec1].cell}<br>
|
||||
{/section}
|
||||
<p>
|
||||
{section name=sec1 loop=$contacts}
|
||||
phone: {$contacts[sec1].phone}
|
||||
<br>
|
||||
|
||||
testing strip tags
|
||||
{strip}
|
||||
fax: {$contacts[sec1].fax}
|
||||
<br>
|
||||
|
||||
cell: {$contacts[sec1].cell}
|
||||
<br>
|
||||
{/section}
|
||||
<p>
|
||||
|
||||
testing strip tags
|
||||
{strip}
|
||||
<table border=0>
|
||||
<tr>
|
||||
<td>
|
||||
<A HREF="{$SCRIPT_NAME}">
|
||||
<font color="red">This is a test </font>
|
||||
</A>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<A HREF="{$SCRIPT_NAME}">
|
||||
<font color="red">This is a test </font>
|
||||
</A>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{/strip}
|
||||
{/strip}
|
||||
|
||||
</PRE>
|
||||
|
||||
This is an example of the html_select_date function:
|
||||
|
||||
<form>
|
||||
{html_select_date start_year=1998 end_year=2010}
|
||||
{html_select_date start_year=1998 end_year=2010}
|
||||
</form>
|
||||
|
||||
This is an example of the html_select_time function:
|
||||
|
||||
<form>
|
||||
{html_select_time use_24_hours=false}
|
||||
{html_select_time use_24_hours=false}
|
||||
</form>
|
||||
|
||||
This is an example of the html_options function:
|
||||
|
||||
<form>
|
||||
<select name=states>
|
||||
{html_options values=$option_values selected=$option_selected output=$option_output}
|
||||
</select>
|
||||
<select name=states>
|
||||
{html_options values=$option_values selected=$option_selected output=$option_output}
|
||||
</select>
|
||||
</form>
|
||||
|
||||
{include file="footer.tpl"}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,460 +1,467 @@
|
|||
<?php
|
||||
/**
|
||||
* Project: Smarty: the PHP compiling template engine
|
||||
* File: SmartyBC.class.php
|
||||
* SVN: $Id: $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* For questions, help, comments, discussion, etc., please join the
|
||||
* Smarty mailing list. Send a blank e-mail to
|
||||
* smarty-discussion-subscribe@googlegroups.com
|
||||
*
|
||||
* @link http://www.smarty.net/
|
||||
* @copyright 2008 New Digital Group, Inc.
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
* @author Rodney Rehm
|
||||
* @package Smarty
|
||||
*/
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require(dirname(__FILE__) . '/Smarty.class.php');
|
||||
|
||||
/**
|
||||
* Smarty Backward Compatability Wrapper Class
|
||||
*
|
||||
* @package Smarty
|
||||
*/
|
||||
class SmartyBC extends Smarty {
|
||||
|
||||
/**
|
||||
* Smarty 2 BC
|
||||
* @var string
|
||||
*/
|
||||
public $_version = self::SMARTY_VERSION;
|
||||
|
||||
/**
|
||||
* Initialize new SmartyBC object
|
||||
*
|
||||
* @param array $options options to set during initialization, e.g. array( 'forceCompile' => false )
|
||||
*/
|
||||
public function __construct(array $options=array())
|
||||
{
|
||||
parent::__construct($options);
|
||||
// register {php} tag
|
||||
$this->registerPlugin('block', 'php', 'smarty_php_tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper for assign_by_ref
|
||||
*
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param mixed &$value the referenced value to assign
|
||||
*/
|
||||
public function assign_by_ref($tpl_var, &$value)
|
||||
{
|
||||
$this->assignByRef($tpl_var, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper for append_by_ref
|
||||
*
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param mixed &$value the referenced value to append
|
||||
* @param boolean $merge flag if array elements shall be merged
|
||||
*/
|
||||
public function append_by_ref($tpl_var, &$value, $merge = false)
|
||||
{
|
||||
$this->appendByRef($tpl_var, $value, $merge);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear the given assigned template variable.
|
||||
*
|
||||
* @param string $tpl_var the template variable to clear
|
||||
*/
|
||||
public function clear_assign($tpl_var)
|
||||
{
|
||||
$this->clearAssign($tpl_var);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers custom function to be used in templates
|
||||
*
|
||||
* @param string $function the name of the template function
|
||||
* @param string $function_impl the name of the PHP function to register
|
||||
* @param bool $cacheable
|
||||
* @param mixed $cache_attrs
|
||||
*/
|
||||
public function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null)
|
||||
{
|
||||
$this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters custom function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
*/
|
||||
public function unregister_function($function)
|
||||
{
|
||||
$this->unregisterPlugin('function', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers object to be used in templates
|
||||
*
|
||||
* @param string $object name of template object
|
||||
* @param object $object_impl the referenced PHP object to register
|
||||
* @param array $allowed list of allowed methods (empty = all)
|
||||
* @param boolean $smarty_args smarty argument format, else traditional
|
||||
* @param array $block_functs list of methods that are block format
|
||||
*/
|
||||
public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
|
||||
{
|
||||
settype($allowed, 'array');
|
||||
settype($smarty_args, 'boolean');
|
||||
$this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters object
|
||||
*
|
||||
* @param string $object name of template object
|
||||
*/
|
||||
public function unregister_object($object)
|
||||
{
|
||||
$this->unregisterObject($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers block function to be used in templates
|
||||
*
|
||||
* @param string $block name of template block
|
||||
* @param string $block_impl PHP function to register
|
||||
* @param bool $cacheable
|
||||
* @param mixed $cache_attrs
|
||||
*/
|
||||
public function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null)
|
||||
{
|
||||
$this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters block function
|
||||
*
|
||||
* @param string $block name of template function
|
||||
*/
|
||||
public function unregister_block($block)
|
||||
{
|
||||
$this->unregisterPlugin('block', $block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers compiler function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
* @param string $function_impl name of PHP function to register
|
||||
* @param bool $cacheable
|
||||
*/
|
||||
public function register_compiler_function($function, $function_impl, $cacheable=true)
|
||||
{
|
||||
$this->registerPlugin('compiler', $function, $function_impl, $cacheable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters compiler function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
*/
|
||||
public function unregister_compiler_function($function)
|
||||
{
|
||||
$this->unregisterPlugin('compiler', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers modifier to be used in templates
|
||||
*
|
||||
* @param string $modifier name of template modifier
|
||||
* @param string $modifier_impl name of PHP function to register
|
||||
*/
|
||||
public function register_modifier($modifier, $modifier_impl)
|
||||
{
|
||||
$this->registerPlugin('modifier', $modifier, $modifier_impl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters modifier
|
||||
*
|
||||
* @param string $modifier name of template modifier
|
||||
*/
|
||||
public function unregister_modifier($modifier)
|
||||
{
|
||||
$this->unregisterPlugin('modifier', $modifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a resource to fetch a template
|
||||
*
|