diff --git a/change_log.txt b/change_log.txt index 1e565267..0c255672 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,594 +1,594 @@ -11/05/2009 -- config_load method can now be called on data and template objects - -11/04/2009 -- added typecasting support for template variables -- bugfix on complex indexed special Smarty variables - -11/03/2009 -- fixed parser error on objects with special smarty vars -- fixed file dependency for {incude} inside {block} tag -- fixed not compiling on non existing compiled templates when compile_check = false -- renamed function names of autoloaded Smarty methods to Smarty_Method_.... -- new security_class property (default is Smarty_Security) - -11/02/2009 -- added neq,lte,gte,mod as aliases to if conditions -- throw exception on illegal Smarty() constructor calls - -10/31/2009 -- change of filenames in sysplugins folder for internal spl_autoload function -- lexer/parser changed for increased compilation speed - -10/27/2009 -- fixed missing quotes in include_php.php - -10/27/2009 -- fixed typo in method.register_resource -- pass {} through as literal - -10/26/2009 -- merge only compiled subtemplates into the compiled code of the main template - -10/24/2009 -- fixed nocache vars at internal block tags -- fixed merging of recursive includes - -10/23/2009 -- fixed nocache var problem - -10/22/2009 -- fix trimwhitespace outputfilter parameter - -10/21/2009 -- added {$foo++}{$foo--} syntax -- buxfix changed PHP "if (..):" to "if (..){" because of possible bad code when concenating PHP tags -- autoload Smarty internal classes -- fixed file dependency for config files -- some code optimizations -- fixed function definitions on some autoloaded methodes -- fixed nocache variable inside if condition of {if} tag - -10/20/2009 -- check at compile time for variable filter to improve rendering speed if no filter is used -- fixed bug at combination of {elseif} tag and {...} in double quoted strings of static class parameter - -10/19/2009 -- fixed compiled template merging on variable double quoted strings as name -- fixed bug in caching mode 2 and cache_lifetime -1 -- fixed modifier support on block tags - -10/17/2009 -- remove ?>\n'bar','foo2'=>'blar'); - $smarty->display('my.tpl',$data); - -09/29/2009 -- changed {php} tag handling -- removed support of Smarty::instance() -- removed support of PHP resource type -- improved execution speed of {foreach} tags -- fixed bug in {section} tag - -09/23/2009 -- improvements and bugfix on {include} tag handling -NOTICE: existing compiled template and cache files must be deleted - -09/19/2009 -- replace internal "eval()" calls by "include" during rendering process -- speed improvment for templates which have included subtemplates - the compiled code of included templates is merged into the compiled code of the parent template -- added logical operator "xor" for {if} tag -- changed parameter ordering for Smarty2 BC - fetch($template, $cache_id = null, $compile_id = null, $parent = null) - display($template, $cache_id = null, $compile_id = null, $parent = null) - createTemplate($template, $cache_id = null, $compile_id = null, $parent = null) -- property resource_char_set is now replaced by constant SMARTY_RESOURCE_CHAR_SET -- fixed handling of classes in registered blocks -- speed improvement of lexer on text sections - -09/01/2009 -- dropped nl2br as plugin -- added '<>' as comparission operator in {if} tags -- cached caching_lifetime property to cache_liftime for backward compatibility with Smarty2. - {include} optional attribute is also now cache_lifetime -- fixed trigger_error methode (moved into Smarty class) -- version is now Beta!!! - - -08/30/2009 -- some speed optimizations on loading internal plugins - - -08/29/2009 -- implemented caching of registered Resources -- new property 'auto_literal'. if true(default) '{ ' and ' }' interpreted as literal, not as Smarty delimiter - - -08/28/2009 -- Fix on line breaks inside {if} tags - -08/26/2009 -- implemented registered resources as in Smarty2. NOTE: caching does not work yet -- new property 'force_cache'. if true it forces the creation of a new cache file -- fixed modifiers on arrays -- some speed optimization on loading internal classes - - -08/24/2009 -- fixed typo in lexer definition for '!==' operator -- bugfix - the ouput of plugins was not cached -- added global variable SCRIPT_NAME - -08/21/2009 -- fixed problems whitespace in conjuction with custom delimiters -- Smarty tags can now be used as value anywhere - -08/18/2009 -- definition of template class name moded in internal.templatebase.php -- whitespace parser changes - -08/12/2009 -- fixed parser problems - -08/11/2009 -- fixed parser problems with custom delimiter - -08/10/2009 -- update of mb support in plugins - - -08/09/2009 -- fixed problems with doublequoted strings at name attribute of {block} tag -- bugfix at scope attribute of {append} tag - -08/08/2009 -- removed all internal calls of Smarty::instance() -- fixed code in double quoted strings - -08/05/2009 -- bugfix mb_string support -- bugfix of \n.\t etc in double quoted strings - -07/29/2009 -- added syntax for variable config vars like #$foo# - -07/28/2009 -- fixed parsing of $smarty.session vars containing objects - -07/22/2009 -- fix of "$" handling in double quoted strings - -07/21/2009 -- fix that {$smarty.current_dir} return correct value within {block} tags. - -07/20/2009 -- drop error message on unmatched {block} {/block} pairs - -07/01/2009 -- fixed smarty_function_html_options call in plugin function.html_select_date.php (missing ,) - -06/24/2009 -- fixed smarty_function_html_options call in plugin function.html_select_date.php - -06/22/2009 -- fix on \n and spaces inside smarty tags -- removed request_use_auto_globals propert as it is no longer needed because Smarty 3 will always run under PHP 5 - - -06/18/2009 -- fixed compilation of block plugins when caching enabled -- added $smarty.current_dir which returns the current working directory - -06/14/2009 -- fixed array access on super globals -- allow smarty tags within xml tags - -06/13/2009 -- bugfix at extend resource: create unique files for compiled template and cache for each combination of template files -- update extend resource to handle appen and prepend block attributes -- instantiate classes of plugins instead of calling them static - -06/03/2009 -- fixed repeat at block plugins - -05/25/2009 -- fixed problem with caching of compiler plugins - -05/14/2009 -- fixed directory separator handling - -05/09/2009 -- syntax change for stream variables -- fixed bug when using absolute template filepath and caching - -05/08/2009 -- fixed bug of {nocache} tag in included templates - -05/06/2009 -- allow that plugins_dir folder names can end without directory separator - -05/05/2009 -- fixed E_STRICT incompabilities -- {function} tag bug fix -- security policy definitions have been moved from plugins folder to file Security.class.php in libs folder -- added allow_super_global configuration to security - -04/30/2009 -- functions defined with the {function} tag now always have global scope - -04/29/2009 -- fixed problem with directory setter methodes -- allow that cache_dir can end without directory separator - -04/28/2009 -- the {function} tag can no longer overwrite standard smarty tags -- inherit functions defined by the {fuction} tag into subtemplates -- added {while } sytax to while tag - -04/26/2009 -- added trusted stream checking to security -- internal changes at file dependency check for caching - -04/24/2009 -- changed name of {template} tag to {function} -- added new {template} tag - -04/23/2009 -- fixed access of special smarty variables from included template - -04/22/2009 -- unified template stream syntax with standard Smarty resource syntax $smarty->display('mystream:mytemplate') - -04/21/2009 -- change of new style syntax for forach. Now: {foreach $array as $var} like in PHP - -04/20/2009 -- fixed "$foo.bar ..." variable replacement in double quoted strings -- fixed error in {include} tag with variable file attribute - -04/18/2009 -- added stream resources ($smarty->display('mystream://mytemplate')) -- added stream variables {$mystream:myvar} - -04/14/2009 -- fixed compile_id handling on {include} tags -- fixed append/prepend attributes in {block} tag -- added {if 'expression' is in 'array'} syntax -- use crc32 as hash for compiled config files. - -04/13/2009 -- fixed scope problem with parent variables when appending variables within templates. -- fixed code for {block} without childs (possible sources for notice errors removed) - -04/12/2009 -- added append and prepend attribute to {block} tag - -04/11/2009 -- fixed variables in 'file' attribute of {extend} tag -- fixed problems in modifiers (if mb string functions not present) - -04/10/2009 -- check if mb string functions available otherwise fallback to normal string functions -- added global variable scope SMARTY_GLOBAL_SCOPE -- enable 'variable' filter by default -- fixed {$smarty.block.parent.foo} -- implementation of a 'variable' filter as replacement for default modifier - -04/09/2009 -- fixed execution of filters defined by classes -- compile the always the content of {block} tags to make shure that the filters are running over it -- syntax corrections on variable object property -- syntax corrections on array access in dot syntax - -04/08/2009 -- allow variable object property - -04/07/2009 -- changed variable scopes to SMARTY_LOCAL_SCOPE, SMARTY_PARENT_SCOPE, SMARTY_ROOT_SCOPE to avoid possible conflicts with user constants -- Smarty variable global attribute replaced with scope attribute - -04/06/2009 -- variable scopes LOCAL_SCOPE, PARENT_SCOPE, ROOT_SCOPE -- more getter/setter methodes - -04/05/2009 -- replaced new array looping syntax {for $foo in $array} with {foreach $foo in $array} to avoid confusion -- added append array for short form of assign {$foo[]='bar'} and allow assignments to nested arrays {$foo['bla']['blue']='bar'} - -04/04/2009 -- make output of template default handlers cachable and save compiled source -- some fixes on yesterdays update - -04/03/2006 -- added registerDefaultTemplateHandler methode and functionallity -- added registerDefaultPluginHandler methode and functionallity -- added {append} tag to extend Smarty array variabled - -04/02/2009 -- added setter/getter methodes -- added $foo@first and $foo@last properties at {for} tag -- added $set_timezone (true/false) property to setup optionally the default time zone - -03/31/2009 -- bugfix smarty.class and internal.security_handler -- added compile_check configuration -- added setter/getter methodes - -03/30/2009 -- added all major setter/getter methodes - -03/28/2009 -- {block} tags can be nested now -- md5 hash function replace with crc32 for speed optimization -- file order for exted resource inverted -- clear_compiled_tpl and clear_cache_all will not touch .svn folder any longer - -03/27/2009 -- added extend resource - -03/26/2009 -- fixed parser not to create error on `word` in double quoted strings -- allow PHP array(...) -- implemented $smarty.block.name.parent to access parent block content -- fixed smarty.class - - -03/23/2009 -- fixed {foreachelse} and {forelse} tags - -03/22/2009 -- fixed possible sources for notice errors -- rearrange SVN into distribution and development folders - -03/21/2009 -- fixed exceptions in function plugins -- fixed notice error in Smarty.class.php -- allow chained objects to span multiple lines -- fixed error in modifers - -03/20/2009 -- moved /plugins folder into /libs folder -- added noprint modifier -- autoappend a directory separator if the xxxxx_dir definition have no trailing one - -03/19/2009 -- allow array definition as modifer paramter -- changed modifier to use multi byte string funktions. - -03/17/2009 -- bugfix - -03/15/2009 -- added {include_php} tag for BC -- removed @ error suppression -- bugfix fetch did always repeat output of first call when calling same template several times -- PHPunit tests extended - -03/13/2009 -- changed block syntax to be Smarty like {block:titel} -> {block name=titel} -- compiling of {block} and {extend} tags rewriten for better performance -- added special Smarty variable block ($smarty.block.foo} returns the parent definition of block foo -- optimization of {block} tag compiled code. -- fixed problem with escaped double quotes in double quoted strings - -03/12/2009 -- added support of template inheritance by {extend } and {block } tags. -- bugfix comments within literals -- added scope attribuie to {include} tag - -03/10/2009 -- couple of bugfixes and improvements -- PHPunit tests extended - -03/09/2009 -- added support for global template vars. {assign_global...} $smarty->assign_global(...) -- added direct_access_security -- PHPunit tests extended -- added missing {if} tag conditions like "is div by" etc. - -03/08/2009 -- splitted up the Compiler class to make it easier to use a coustom compiler -- made default plugins_dir relative to Smarty root and not current working directory -- some changes to make the lexer parser better configurable -- implemented {section} tag for Smarty2 BC - -03/07/2009 -- fixed problem with comment tags -- fixed problem with #xxxx in double quoted string -- new {while} tag implemented -- made lexer and paser class configurable as $smarty property -- Smarty method get_template_vars implemented -- Smarty method get_registered_object implemented -- Smarty method trigger_error implemented -- PHPunit tests extended - -03/06/2009 -- final changes on config variable handling -- parser change - unquoted strings will by be converted into single quoted strings -- PHPunit tests extended -- some code cleanup -- fixed problem on catenate strings with expression -- update of count_words modifier -- bugfix on comment tags - - -03/05/2009 -- bugfix on tag with caching enabled -- changes on exception handling (by Monte) - -03/04/2009 -- added support for config variables -- bugfix on tag - -03/02/2009 -- fixed unqouted strings within modifier parameter -- bugfix parsing of mofifier parameter - -03/01/2009 -- modifier chaining works now as in Smarty2 - -02/28/2009 -- changed handling of unqouted strings - -02/26/2009 -- bugfix -- changed $smarty.capture.foo to be global for Smarty2 BC. - -02/24/2009 -- bugfix {php} {/php} tags for backward compatibility -- bugfix for expressions on arrays -- fixed usage of "null" value -- added $smarty.foreach.foo.first and $smarty.foreach.foo.last - -02/06/2009 -- bugfix for request variables without index for example $smarty.get -- experimental solution for variable functions in static class - -02/05/2009 -- update of popup plugin -- added config variables to template parser (load config functions still missing) -- parser bugfix for empty quoted strings - -02/03/2009 -- allow array of objects as static class variabales. -- use htmlentities at source output at template errors. - -02/02/2009 -- changed search order on modifiers to look at plugins folder first -- parser bug fix for modifier on array elements $foo.bar|modifier -- parser bug fix on single quoted srings -- internal: splitted up compiler plugin files - -02/01/2009 -- allow method chaining on static classes -- special Smarty variables $smarty.... implemented -- added {PHP} {/PHP} tags for backward compatibility - -01/31/2009 -- added {math} plugin for Smarty2 BC -- added template_exists method -- changed Smarty3 method enable_security() to enableSecurity() to follow camelCase standards - -01/30/2009 -- bugfix in single quoted strings -- changed syntax for variable property access from $foo:property to $foo@property because of ambiguous syntax at modifiers - -01/29/2009 -- syntax for array definition changed from (1,2,3) to [1,2,3] to remove ambiguous syntax -- allow {for $foo in [1,2,3]} syntax -- bugfix in double quoted strings -- allow tags in template even if short_tags are enabled - -01/28/2009 -- fixed '!==' if condition. - -01/28/2009 -- added support of {strip} {/strip} tag. - -01/27/2009 -- bug fix on backticks in double quoted strings at objects - -01/25/2009 -- Smarty2 modfiers added to SVN - -01/25/2009 -- bugfix allow arrays at object properties in Smarty syntax -- the template object is now passed as additional parameter at plugin calls -- clear_compiled_tpl methode completed - -01/20/2009 -- access to class constants implemented ( class::CONSTANT ) -- access to static class variables implemented ( class::$variable ) -- call of static class methodes implemented ( class::methode() ) - -01/16/2009 -- reallow leading _ in variable names {$_var} -- allow array of objects {$array.index->methode()} syntax -- finished work on clear_cache and clear_cache_all methodes - -01/11/2009 -- added support of {literal} tag -- added support of {ldelim} and {rdelim} tags -- make code compatible to run with E_STRICT error setting - -01/08/2009 -- moved clear_assign and clear_all_assign to internal.templatebase.php -- added assign_by_ref, append and append_by_ref methodes - -01/02/2009 -- added load_filter methode -- fished work on filter handling -- optimization of plugin loading - -12/30/2008 -- added compiler support of registered object -- added backtick support in doubled quoted strings for backward compatibility -- some minor bug fixes and improvments - -12/23/2008 -- fixed problem of not working "not" operator in if-expressions -- added handling of compiler function plugins -- finished work on (un)register_compiler_function methode -- finished work on (un)register_modifier methode -- plugin handling from plugins folder changed for modifier plugins - deleted - internal.modifier.php -- added modifier chaining to parser - -12/17/2008 -- finished (un)register_function methode -- finished (un)register_block methode -- added security checking for PHP functions in PHP templates -- plugin handling from plugins folder rewritten - new - internal.plugin_handler.php - deleted - internal.block.php - deleted - internal.function.php -- removed plugin checking from security handler - -12/16/2008 - -- new start of this change_log file +11/05/2009 +- config_load method can now be called on data and template objects + +11/04/2009 +- added typecasting support for template variables +- bugfix on complex indexed special Smarty variables + +11/03/2009 +- fixed parser error on objects with special smarty vars +- fixed file dependency for {incude} inside {block} tag +- fixed not compiling on non existing compiled templates when compile_check = false +- renamed function names of autoloaded Smarty methods to Smarty_Method_.... +- new security_class property (default is Smarty_Security) + +11/02/2009 +- added neq,lte,gte,mod as aliases to if conditions +- throw exception on illegal Smarty() constructor calls + +10/31/2009 +- change of filenames in sysplugins folder for internal spl_autoload function +- lexer/parser changed for increased compilation speed + +10/27/2009 +- fixed missing quotes in include_php.php + +10/27/2009 +- fixed typo in method.register_resource +- pass {} through as literal + +10/26/2009 +- merge only compiled subtemplates into the compiled code of the main template + +10/24/2009 +- fixed nocache vars at internal block tags +- fixed merging of recursive includes + +10/23/2009 +- fixed nocache var problem + +10/22/2009 +- fix trimwhitespace outputfilter parameter + +10/21/2009 +- added {$foo++}{$foo--} syntax +- buxfix changed PHP "if (..):" to "if (..){" because of possible bad code when concenating PHP tags +- autoload Smarty internal classes +- fixed file dependency for config files +- some code optimizations +- fixed function definitions on some autoloaded methodes +- fixed nocache variable inside if condition of {if} tag + +10/20/2009 +- check at compile time for variable filter to improve rendering speed if no filter is used +- fixed bug at combination of {elseif} tag and {...} in double quoted strings of static class parameter + +10/19/2009 +- fixed compiled template merging on variable double quoted strings as name +- fixed bug in caching mode 2 and cache_lifetime -1 +- fixed modifier support on block tags + +10/17/2009 +- remove ?>\n'bar','foo2'=>'blar'); + $smarty->display('my.tpl',$data); + +09/29/2009 +- changed {php} tag handling +- removed support of Smarty::instance() +- removed support of PHP resource type +- improved execution speed of {foreach} tags +- fixed bug in {section} tag + +09/23/2009 +- improvements and bugfix on {include} tag handling +NOTICE: existing compiled template and cache files must be deleted + +09/19/2009 +- replace internal "eval()" calls by "include" during rendering process +- speed improvment for templates which have included subtemplates + the compiled code of included templates is merged into the compiled code of the parent template +- added logical operator "xor" for {if} tag +- changed parameter ordering for Smarty2 BC + fetch($template, $cache_id = null, $compile_id = null, $parent = null) + display($template, $cache_id = null, $compile_id = null, $parent = null) + createTemplate($template, $cache_id = null, $compile_id = null, $parent = null) +- property resource_char_set is now replaced by constant SMARTY_RESOURCE_CHAR_SET +- fixed handling of classes in registered blocks +- speed improvement of lexer on text sections + +09/01/2009 +- dropped nl2br as plugin +- added '<>' as comparission operator in {if} tags +- cached caching_lifetime property to cache_liftime for backward compatibility with Smarty2. + {include} optional attribute is also now cache_lifetime +- fixed trigger_error methode (moved into Smarty class) +- version is now Beta!!! + + +08/30/2009 +- some speed optimizations on loading internal plugins + + +08/29/2009 +- implemented caching of registered Resources +- new property 'auto_literal'. if true(default) '{ ' and ' }' interpreted as literal, not as Smarty delimiter + + +08/28/2009 +- Fix on line breaks inside {if} tags + +08/26/2009 +- implemented registered resources as in Smarty2. NOTE: caching does not work yet +- new property 'force_cache'. if true it forces the creation of a new cache file +- fixed modifiers on arrays +- some speed optimization on loading internal classes + + +08/24/2009 +- fixed typo in lexer definition for '!==' operator +- bugfix - the ouput of plugins was not cached +- added global variable SCRIPT_NAME + +08/21/2009 +- fixed problems whitespace in conjuction with custom delimiters +- Smarty tags can now be used as value anywhere + +08/18/2009 +- definition of template class name moded in internal.templatebase.php +- whitespace parser changes + +08/12/2009 +- fixed parser problems + +08/11/2009 +- fixed parser problems with custom delimiter + +08/10/2009 +- update of mb support in plugins + + +08/09/2009 +- fixed problems with doublequoted strings at name attribute of {block} tag +- bugfix at scope attribute of {append} tag + +08/08/2009 +- removed all internal calls of Smarty::instance() +- fixed code in double quoted strings + +08/05/2009 +- bugfix mb_string support +- bugfix of \n.\t etc in double quoted strings + +07/29/2009 +- added syntax for variable config vars like #$foo# + +07/28/2009 +- fixed parsing of $smarty.session vars containing objects + +07/22/2009 +- fix of "$" handling in double quoted strings + +07/21/2009 +- fix that {$smarty.current_dir} return correct value within {block} tags. + +07/20/2009 +- drop error message on unmatched {block} {/block} pairs + +07/01/2009 +- fixed smarty_function_html_options call in plugin function.html_select_date.php (missing ,) + +06/24/2009 +- fixed smarty_function_html_options call in plugin function.html_select_date.php + +06/22/2009 +- fix on \n and spaces inside smarty tags +- removed request_use_auto_globals propert as it is no longer needed because Smarty 3 will always run under PHP 5 + + +06/18/2009 +- fixed compilation of block plugins when caching enabled +- added $smarty.current_dir which returns the current working directory + +06/14/2009 +- fixed array access on super globals +- allow smarty tags within xml tags + +06/13/2009 +- bugfix at extend resource: create unique files for compiled template and cache for each combination of template files +- update extend resource to handle appen and prepend block attributes +- instantiate classes of plugins instead of calling them static + +06/03/2009 +- fixed repeat at block plugins + +05/25/2009 +- fixed problem with caching of compiler plugins + +05/14/2009 +- fixed directory separator handling + +05/09/2009 +- syntax change for stream variables +- fixed bug when using absolute template filepath and caching + +05/08/2009 +- fixed bug of {nocache} tag in included templates + +05/06/2009 +- allow that plugins_dir folder names can end without directory separator + +05/05/2009 +- fixed E_STRICT incompabilities +- {function} tag bug fix +- security policy definitions have been moved from plugins folder to file Security.class.php in libs folder +- added allow_super_global configuration to security + +04/30/2009 +- functions defined with the {function} tag now always have global scope + +04/29/2009 +- fixed problem with directory setter methodes +- allow that cache_dir can end without directory separator + +04/28/2009 +- the {function} tag can no longer overwrite standard smarty tags +- inherit functions defined by the {fuction} tag into subtemplates +- added {while } sytax to while tag + +04/26/2009 +- added trusted stream checking to security +- internal changes at file dependency check for caching + +04/24/2009 +- changed name of {template} tag to {function} +- added new {template} tag + +04/23/2009 +- fixed access of special smarty variables from included template + +04/22/2009 +- unified template stream syntax with standard Smarty resource syntax $smarty->display('mystream:mytemplate') + +04/21/2009 +- change of new style syntax for forach. Now: {foreach $array as $var} like in PHP + +04/20/2009 +- fixed "$foo.bar ..." variable replacement in double quoted strings +- fixed error in {include} tag with variable file attribute + +04/18/2009 +- added stream resources ($smarty->display('mystream://mytemplate')) +- added stream variables {$mystream:myvar} + +04/14/2009 +- fixed compile_id handling on {include} tags +- fixed append/prepend attributes in {block} tag +- added {if 'expression' is in 'array'} syntax +- use crc32 as hash for compiled config files. + +04/13/2009 +- fixed scope problem with parent variables when appending variables within templates. +- fixed code for {block} without childs (possible sources for notice errors removed) + +04/12/2009 +- added append and prepend attribute to {block} tag + +04/11/2009 +- fixed variables in 'file' attribute of {extend} tag +- fixed problems in modifiers (if mb string functions not present) + +04/10/2009 +- check if mb string functions available otherwise fallback to normal string functions +- added global variable scope SMARTY_GLOBAL_SCOPE +- enable 'variable' filter by default +- fixed {$smarty.block.parent.foo} +- implementation of a 'variable' filter as replacement for default modifier + +04/09/2009 +- fixed execution of filters defined by classes +- compile the always the content of {block} tags to make shure that the filters are running over it +- syntax corrections on variable object property +- syntax corrections on array access in dot syntax + +04/08/2009 +- allow variable object property + +04/07/2009 +- changed variable scopes to SMARTY_LOCAL_SCOPE, SMARTY_PARENT_SCOPE, SMARTY_ROOT_SCOPE to avoid possible conflicts with user constants +- Smarty variable global attribute replaced with scope attribute + +04/06/2009 +- variable scopes LOCAL_SCOPE, PARENT_SCOPE, ROOT_SCOPE +- more getter/setter methodes + +04/05/2009 +- replaced new array looping syntax {for $foo in $array} with {foreach $foo in $array} to avoid confusion +- added append array for short form of assign {$foo[]='bar'} and allow assignments to nested arrays {$foo['bla']['blue']='bar'} + +04/04/2009 +- make output of template default handlers cachable and save compiled source +- some fixes on yesterdays update + +04/03/2006 +- added registerDefaultTemplateHandler methode and functionallity +- added registerDefaultPluginHandler methode and functionallity +- added {append} tag to extend Smarty array variabled + +04/02/2009 +- added setter/getter methodes +- added $foo@first and $foo@last properties at {for} tag +- added $set_timezone (true/false) property to setup optionally the default time zone + +03/31/2009 +- bugfix smarty.class and internal.security_handler +- added compile_check configuration +- added setter/getter methodes + +03/30/2009 +- added all major setter/getter methodes + +03/28/2009 +- {block} tags can be nested now +- md5 hash function replace with crc32 for speed optimization +- file order for exted resource inverted +- clear_compiled_tpl and clear_cache_all will not touch .svn folder any longer + +03/27/2009 +- added extend resource + +03/26/2009 +- fixed parser not to create error on `word` in double quoted strings +- allow PHP array(...) +- implemented $smarty.block.name.parent to access parent block content +- fixed smarty.class + + +03/23/2009 +- fixed {foreachelse} and {forelse} tags + +03/22/2009 +- fixed possible sources for notice errors +- rearrange SVN into distribution and development folders + +03/21/2009 +- fixed exceptions in function plugins +- fixed notice error in Smarty.class.php +- allow chained objects to span multiple lines +- fixed error in modifers + +03/20/2009 +- moved /plugins folder into /libs folder +- added noprint modifier +- autoappend a directory separator if the xxxxx_dir definition have no trailing one + +03/19/2009 +- allow array definition as modifer paramter +- changed modifier to use multi byte string funktions. + +03/17/2009 +- bugfix + +03/15/2009 +- added {include_php} tag for BC +- removed @ error suppression +- bugfix fetch did always repeat output of first call when calling same template several times +- PHPunit tests extended + +03/13/2009 +- changed block syntax to be Smarty like {block:titel} -> {block name=titel} +- compiling of {block} and {extend} tags rewriten for better performance +- added special Smarty variable block ($smarty.block.foo} returns the parent definition of block foo +- optimization of {block} tag compiled code. +- fixed problem with escaped double quotes in double quoted strings + +03/12/2009 +- added support of template inheritance by {extend } and {block } tags. +- bugfix comments within literals +- added scope attribuie to {include} tag + +03/10/2009 +- couple of bugfixes and improvements +- PHPunit tests extended + +03/09/2009 +- added support for global template vars. {assign_global...} $smarty->assign_global(...) +- added direct_access_security +- PHPunit tests extended +- added missing {if} tag conditions like "is div by" etc. + +03/08/2009 +- splitted up the Compiler class to make it easier to use a coustom compiler +- made default plugins_dir relative to Smarty root and not current working directory +- some changes to make the lexer parser better configurable +- implemented {section} tag for Smarty2 BC + +03/07/2009 +- fixed problem with comment tags +- fixed problem with #xxxx in double quoted string +- new {while} tag implemented +- made lexer and paser class configurable as $smarty property +- Smarty method get_template_vars implemented +- Smarty method get_registered_object implemented +- Smarty method trigger_error implemented +- PHPunit tests extended + +03/06/2009 +- final changes on config variable handling +- parser change - unquoted strings will by be converted into single quoted strings +- PHPunit tests extended +- some code cleanup +- fixed problem on catenate strings with expression +- update of count_words modifier +- bugfix on comment tags + + +03/05/2009 +- bugfix on tag with caching enabled +- changes on exception handling (by Monte) + +03/04/2009 +- added support for config variables +- bugfix on tag + +03/02/2009 +- fixed unqouted strings within modifier parameter +- bugfix parsing of mofifier parameter + +03/01/2009 +- modifier chaining works now as in Smarty2 + +02/28/2009 +- changed handling of unqouted strings + +02/26/2009 +- bugfix +- changed $smarty.capture.foo to be global for Smarty2 BC. + +02/24/2009 +- bugfix {php} {/php} tags for backward compatibility +- bugfix for expressions on arrays +- fixed usage of "null" value +- added $smarty.foreach.foo.first and $smarty.foreach.foo.last + +02/06/2009 +- bugfix for request variables without index for example $smarty.get +- experimental solution for variable functions in static class + +02/05/2009 +- update of popup plugin +- added config variables to template parser (load config functions still missing) +- parser bugfix for empty quoted strings + +02/03/2009 +- allow array of objects as static class variabales. +- use htmlentities at source output at template errors. + +02/02/2009 +- changed search order on modifiers to look at plugins folder first +- parser bug fix for modifier on array elements $foo.bar|modifier +- parser bug fix on single quoted srings +- internal: splitted up compiler plugin files + +02/01/2009 +- allow method chaining on static classes +- special Smarty variables $smarty.... implemented +- added {PHP} {/PHP} tags for backward compatibility + +01/31/2009 +- added {math} plugin for Smarty2 BC +- added template_exists method +- changed Smarty3 method enable_security() to enableSecurity() to follow camelCase standards + +01/30/2009 +- bugfix in single quoted strings +- changed syntax for variable property access from $foo:property to $foo@property because of ambiguous syntax at modifiers + +01/29/2009 +- syntax for array definition changed from (1,2,3) to [1,2,3] to remove ambiguous syntax +- allow {for $foo in [1,2,3]} syntax +- bugfix in double quoted strings +- allow tags in template even if short_tags are enabled + +01/28/2009 +- fixed '!==' if condition. + +01/28/2009 +- added support of {strip} {/strip} tag. + +01/27/2009 +- bug fix on backticks in double quoted strings at objects + +01/25/2009 +- Smarty2 modfiers added to SVN + +01/25/2009 +- bugfix allow arrays at object properties in Smarty syntax +- the template object is now passed as additional parameter at plugin calls +- clear_compiled_tpl methode completed + +01/20/2009 +- access to class constants implemented ( class::CONSTANT ) +- access to static class variables implemented ( class::$variable ) +- call of static class methodes implemented ( class::methode() ) + +01/16/2009 +- reallow leading _ in variable names {$_var} +- allow array of objects {$array.index->methode()} syntax +- finished work on clear_cache and clear_cache_all methodes + +01/11/2009 +- added support of {literal} tag +- added support of {ldelim} and {rdelim} tags +- make code compatible to run with E_STRICT error setting + +01/08/2009 +- moved clear_assign and clear_all_assign to internal.templatebase.php +- added assign_by_ref, append and append_by_ref methodes + +01/02/2009 +- added load_filter methode +- fished work on filter handling +- optimization of plugin loading + +12/30/2008 +- added compiler support of registered object +- added backtick support in doubled quoted strings for backward compatibility +- some minor bug fixes and improvments + +12/23/2008 +- fixed problem of not working "not" operator in if-expressions +- added handling of compiler function plugins +- finished work on (un)register_compiler_function methode +- finished work on (un)register_modifier methode +- plugin handling from plugins folder changed for modifier plugins + deleted - internal.modifier.php +- added modifier chaining to parser + +12/17/2008 +- finished (un)register_function methode +- finished (un)register_block methode +- added security checking for PHP functions in PHP templates +- plugin handling from plugins folder rewritten + new - internal.plugin_handler.php + deleted - internal.block.php + deleted - internal.function.php +- removed plugin checking from security handler + +12/16/2008 + +- new start of this change_log file diff --git a/demo/configs/test.conf b/demo/configs/test.conf index 22a86497..5eac748e 100644 --- a/demo/configs/test.conf +++ b/demo/configs/test.conf @@ -1,5 +1,5 @@ -title = Welcome to Smarty! -cutoff_size = 40 - -[setup] -bold = true +title = Welcome to Smarty! +cutoff_size = 40 + +[setup] +bold = true diff --git a/demo/index.php b/demo/index.php index 8bada438..b9ec74ae 100644 --- a/demo/index.php +++ b/demo/index.php @@ -1,27 +1,27 @@ -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("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), - 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_selected", "NE"); - -$smarty->display('index.tpl'); -?> +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("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), + 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_selected", "NE"); + +$smarty->display('index.tpl'); +?> diff --git a/demo/templates/footer.tpl b/demo/templates/footer.tpl index c9e0d2e1..e04310fd 100644 --- a/demo/templates/footer.tpl +++ b/demo/templates/footer.tpl @@ -1,2 +1,2 @@ - - + + diff --git a/demo/templates/header.tpl b/demo/templates/header.tpl index 0df5a982..af8f6138 100644 --- a/demo/templates/header.tpl +++ b/demo/templates/header.tpl @@ -1,6 +1,6 @@ - - -{popup_init src="/javascripts/overlib.js"} -{$title} - {$Name} - - + + +{popup_init src="/javascripts/overlib.js"} +{$title} - {$Name} + + diff --git a/demo/templates/index.tpl b/demo/templates/index.tpl index 03623e8e..38d23341 100644 --- a/demo/templates/index.tpl +++ b/demo/templates/index.tpl @@ -1,82 +1,82 @@ -{config_load file="test.conf" section="setup"} -{include file="header.tpl" title=foo} - -
-
-{* bold and title are read from the config file *}
-{if #bold#}{/if}
-{* capitalize the first letters of each word of the title *}
-Title: {#title#|capitalize}
-{if #bold#}{/if}
-
-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}
-
-Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
-
-The value of {ldelim}$Name{rdelim} is {$Name}
-
-variable modifier example of {ldelim}$Name|upper{rdelim}
-
-{$Name|upper}
-
-
-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}
-
-An example of section looped key values:
-
-{section name=sec1 loop=$contacts}
-	phone: {$contacts[sec1].phone}
- fax: {$contacts[sec1].fax}
- cell: {$contacts[sec1].cell}
-{/section} -

- -testing strip tags -{strip} - - - - -
- - This is a test - -
-{/strip} - -

- -This is an example of the html_select_date function: - -
-{html_select_date start_year=1998 end_year=2010} -
- -This is an example of the html_select_time function: - -
-{html_select_time use_24_hours=false} -
- -This is an example of the html_options function: - -
- -
- -{include file="footer.tpl"} +{config_load file="test.conf" section="setup"} +{include file="header.tpl" title=foo} + +
+
+{* bold and title are read from the config file *}
+{if #bold#}{/if}
+{* capitalize the first letters of each word of the title *}
+Title: {#title#|capitalize}
+{if #bold#}{/if}
+
+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}
+
+Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
+
+The value of {ldelim}$Name{rdelim} is {$Name}
+
+variable modifier example of {ldelim}$Name|upper{rdelim}
+
+{$Name|upper}
+
+
+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}
+
+An example of section looped key values:
+
+{section name=sec1 loop=$contacts}
+	phone: {$contacts[sec1].phone}
+ fax: {$contacts[sec1].fax}
+ cell: {$contacts[sec1].cell}
+{/section} +

+ +testing strip tags +{strip} + + + + +
+ + This is a test + +
+{/strip} + +

+ +This is an example of the html_select_date function: + +
+{html_select_date start_year=1998 end_year=2010} +
+ +This is an example of the html_select_time function: + +
+{html_select_time use_24_hours=false} +
+ +This is an example of the html_options function: + +
+ +
+ +{include file="footer.tpl"} diff --git a/libs/debug.tpl b/libs/debug.tpl index bf823988..9fd46b15 100644 --- a/libs/debug.tpl +++ b/libs/debug.tpl @@ -1,136 +1,136 @@ -{capture assign=debug_output} - - - - Smarty Debug Console - - - - -

Smarty Debug Console - Total Time {$execution_time|string_format:"%.5f"}

- -

included templates & config files (load time in seconds)

- -
-{foreach $template_data as $template} - {$template.name} - - (compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"}) - -
-{/foreach} -
- -

assigned template variables

- - - {foreach $assigned_vars as $vars} - - - - {/foreach} -
${$vars@key|escape:'html'}{$vars|debug_print_var}
- -

assigned config file variables (outer template scope)

- - - {foreach $config_vars as $vars} - - - - {/foreach} - -
{$vars@key|escape:'html'}{$vars|debug_print_var}
- - -{/capture} - +{capture assign=debug_output} + + + + Smarty Debug Console + + + + +

Smarty Debug Console - Total Time {$execution_time|string_format:"%.5f"}

+ +

included templates & config files (load time in seconds)

+ +
+{foreach $template_data as $template} + {$template.name} + + (compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"}) + +
+{/foreach} +
+ +

assigned template variables

+ + + {foreach $assigned_vars as $vars} + + + + {/foreach} +
${$vars@key|escape:'html'}{$vars|debug_print_var}
+ +

assigned config file variables (outer template scope)

+ + + {foreach $config_vars as $vars} + + + + {/foreach} + +
{$vars@key|escape:'html'}{$vars|debug_print_var}
+ + +{/capture} + diff --git a/libs/plugins/block.php.php b/libs/plugins/block.php.php index cb7d5cba..362ec9c7 100644 --- a/libs/plugins/block.php.php +++ b/libs/plugins/block.php.php @@ -1,39 +1,39 @@ -security && isset($smarty->security_handler)) { - $sec_obj = $smarty->security_policy; - } else { - $sec_obj = $smarty; - } - if (is_null($content)) { - if (!$smarty->allow_php_tag) { - trigger_error("{php} is deprecated, set allow_php_tag = true to enable", E_USER_WARNING); - } - return; - } - - eval($content); - - return ''; -} - -?> +security && isset($smarty->security_handler)) { + $sec_obj = $smarty->security_policy; + } else { + $sec_obj = $smarty; + } + if (is_null($content)) { + if (!$smarty->allow_php_tag) { + trigger_error("{php} is deprecated, set allow_php_tag = true to enable", E_USER_WARNING); + } + return; + } + + eval($content); + + return ''; +} + +?> diff --git a/libs/plugins/block.textformat.php b/libs/plugins/block.textformat.php index e6d1bb8f..f578bfb9 100644 --- a/libs/plugins/block.textformat.php +++ b/libs/plugins/block.textformat.php @@ -1,103 +1,103 @@ - -* Name: textformat
-* Purpose: format text a certain way with preset styles -* or custom wrap/indent settings
-* -* @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat} - (Smarty online manual) -* @param array $params parameters -*
-* Params:   style: string (email)
-*            indent: integer (0)
-*            wrap: integer (80)
-*            wrap_char string ("\n")
-*            indent_char: string (" ")
-*            wrap_boundary: boolean (true)
-* 
-* @author Monte Ohrt -* @param string $content contents of the block -* @param object $smarty Smarty object -* @param boolean &$repeat repeat flag -* @param object $template template object -* @return string content re-formatted -*/ -function smarty_block_textformat($params, $content, $smarty, &$repeat, $template) -{ - if (is_null($content)) { - return; - } - - $style = null; - $indent = 0; - $indent_first = 0; - $indent_char = ' '; - $wrap = 80; - $wrap_char = "\n"; - $wrap_cut = false; - $assign = null; - - foreach ($params as $_key => $_val) { - switch ($_key) { - case 'style': - case 'indent_char': - case 'wrap_char': - case 'assign': - $$_key = (string)$_val; - break; - - case 'indent': - case 'indent_first': - case 'wrap': - $$_key = (int)$_val; - break; - - case 'wrap_cut': - $$_key = (bool)$_val; - break; - - default: - $smarty->trigger_error("textformat: unknown attribute '$_key'"); - } - } - - if ($style == 'email') { - $wrap = 72; - } - // split into paragraphs - $_paragraphs = preg_split('![\r\n][\r\n]!', $content); - $_output = ''; - - for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) { - if ($_paragraphs[$_x] == '') { - continue; - } - // convert mult. spaces & special chars to single space - $_paragraphs[$_x] = preg_replace(array('!\s+!', '!(^\s+)|(\s+$)!'), array(' ', ''), $_paragraphs[$_x]); - // indent first line - if ($indent_first > 0) { - $_paragraphs[$_x] = str_repeat($indent_char, $indent_first) . $_paragraphs[$_x]; - } - // wordwrap sentences - $_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut); - // indent lines - if ($indent > 0) { - $_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]); - } - } - $_output = implode($wrap_char . $wrap_char, $_paragraphs); - - return $assign ? $template->assign($assign, $_output) : $_output; -} - -?> + +* Name: textformat
+* Purpose: format text a certain way with preset styles +* or custom wrap/indent settings
+* +* @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat} + (Smarty online manual) +* @param array $params parameters +*
+* Params:   style: string (email)
+*            indent: integer (0)
+*            wrap: integer (80)
+*            wrap_char string ("\n")
+*            indent_char: string (" ")
+*            wrap_boundary: boolean (true)
+* 
+* @author Monte Ohrt +* @param string $content contents of the block +* @param object $smarty Smarty object +* @param boolean &$repeat repeat flag +* @param object $template template object +* @return string content re-formatted +*/ +function smarty_block_textformat($params, $content, $smarty, &$repeat, $template) +{ + if (is_null($content)) { + return; + } + + $style = null; + $indent = 0; + $indent_first = 0; + $indent_char = ' '; + $wrap = 80; + $wrap_char = "\n"; + $wrap_cut = false; + $assign = null; + + foreach ($params as $_key => $_val) { + switch ($_key) { + case 'style': + case 'indent_char': + case 'wrap_char': + case 'assign': + $$_key = (string)$_val; + break; + + case 'indent': + case 'indent_first': + case 'wrap': + $$_key = (int)$_val; + break; + + case 'wrap_cut': + $$_key = (bool)$_val; + break; + + default: + $smarty->trigger_error("textformat: unknown attribute '$_key'"); + } + } + + if ($style == 'email') { + $wrap = 72; + } + // split into paragraphs + $_paragraphs = preg_split('![\r\n][\r\n]!', $content); + $_output = ''; + + for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) { + if ($_paragraphs[$_x] == '') { + continue; + } + // convert mult. spaces & special chars to single space + $_paragraphs[$_x] = preg_replace(array('!\s+!', '!(^\s+)|(\s+$)!'), array(' ', ''), $_paragraphs[$_x]); + // indent first line + if ($indent_first > 0) { + $_paragraphs[$_x] = str_repeat($indent_char, $indent_first) . $_paragraphs[$_x]; + } + // wordwrap sentences + $_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut); + // indent lines + if ($indent > 0) { + $_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]); + } + } + $_output = implode($wrap_char . $wrap_char, $_paragraphs); + + return $assign ? $template->assign($assign, $_output) : $_output; +} + +?> diff --git a/libs/plugins/function.counter.php b/libs/plugins/function.counter.php index 1e5e457b..88e49d80 100644 --- a/libs/plugins/function.counter.php +++ b/libs/plugins/function.counter.php @@ -1,78 +1,78 @@ - - * Name: counter
- * Purpose: print out a counter value - * @author Monte Ohrt - * @link http://smarty.php.net/manual/en/language.function.counter.php {counter} - * (Smarty online manual) - * @param array $params parameters - * @param object $smarty Smarty object - * @param object $template template object - * @return string|null - */ -function smarty_function_counter($params, $smarty, $template) -{ - - $name = (isset($params['name'])) ? $params['name'] : 'default'; - if (!isset($template->plugin_data['counter'][$name])) { - $template->plugin_data['counter'][$name] = array( - 'start'=>1, - 'skip'=>1, - 'direction'=>'up', - 'count'=>1 - ); - } - $counter = &$template->plugin_data['counter'][$name]; - - if (isset($params['start'])) { - $counter['start'] = $counter['count'] = (int)$params['start']; - } - - if (!empty($params['assign'])) { - $counter['assign'] = $params['assign']; - } - - if (isset($counter['assign'])) { - $template->assign($counter['assign'], $counter['count']); - } - - if (isset($params['print'])) { - $print = (bool)$params['print']; - } else { - $print = empty($counter['assign']); - } - - if ($print) { - $retval = $counter['count']; - } else { - $retval = null; - } - - if (isset($params['skip'])) { - $counter['skip'] = $params['skip']; - } - - if (isset($params['direction'])) { - $counter['direction'] = $params['direction']; - } - - if ($counter['direction'] == "down") - $counter['count'] -= $counter['skip']; - else - $counter['count'] += $counter['skip']; - - return $retval; - -} - -?> + + * Name: counter
+ * Purpose: print out a counter value + * @author Monte Ohrt + * @link http://smarty.php.net/manual/en/language.function.counter.php {counter} + * (Smarty online manual) + * @param array $params parameters + * @param object $smarty Smarty object + * @param object $template template object + * @return string|null + */ +function smarty_function_counter($params, $smarty, $template) +{ + + $name = (isset($params['name'])) ? $params['name'] : 'default'; + if (!isset($template->plugin_data['counter'][$name])) { + $template->plugin_data['counter'][$name] = array( + 'start'=>1, + 'skip'=>1, + 'direction'=>'up', + 'count'=>1 + ); + } + $counter = &$template->plugin_data['counter'][$name]; + + if (isset($params['start'])) { + $counter['start'] = $counter['count'] = (int)$params['start']; + } + + if (!empty($params['assign'])) { + $counter['assign'] = $params['assign']; + } + + if (isset($counter['assign'])) { + $template->assign($counter['assign'], $counter['count']); + } + + if (isset($params['print'])) { + $print = (bool)$params['print']; + } else { + $print = empty($counter['assign']); + } + + if ($print) { + $retval = $counter['count']; + } else { + $retval = null; + } + + if (isset($params['skip'])) { + $counter['skip'] = $params['skip']; + } + + if (isset($params['direction'])) { + $counter['direction'] = $params['direction']; + } + + if ($counter['direction'] == "down") + $counter['count'] -= $counter['skip']; + else + $counter['count'] += $counter['skip']; + + return $retval; + +} + +?> diff --git a/libs/plugins/modifier.count_characters.php b/libs/plugins/modifier.count_characters.php index 675d0282..6d524655 100644 --- a/libs/plugins/modifier.count_characters.php +++ b/libs/plugins/modifier.count_characters.php @@ -1,29 +1,29 @@ - - * Name: count_characteres
- * Purpose: count the number of characters in a text - * @link http://smarty.php.net/manual/en/language.modifier.count.characters.php - * count_characters (Smarty online manual) - * @author Monte Ohrt - * @param string $string input string - * @param boolean $include_spaces include whitespace in the character count - * @return integer number of characters - */ -function smarty_modifier_count_characters($string, $include_spaces = false) -{ - if ($include_spaces) - return(strlen($string)); - - return preg_match_all("/[^\s]/",$string, $match); -} -?> + + * Name: count_characteres
+ * Purpose: count the number of characters in a text + * @link http://smarty.php.net/manual/en/language.modifier.count.characters.php + * count_characters (Smarty online manual) + * @author Monte Ohrt + * @param string $string input string + * @param boolean $include_spaces include whitespace in the character count + * @return integer number of characters + */ +function smarty_modifier_count_characters($string, $include_spaces = false) +{ + if ($include_spaces) + return(strlen($string)); + + return preg_match_all("/[^\s]/",$string, $match); +} +?> diff --git a/libs/plugins/modifier.debug_print_var.php b/libs/plugins/modifier.debug_print_var.php index bf58e35a..e976d12f 100644 --- a/libs/plugins/modifier.debug_print_var.php +++ b/libs/plugins/modifier.debug_print_var.php @@ -1,89 +1,89 @@ - -* Name: debug_print_var
-* Purpose: formats variable contents for display in the console -* -* @link http://smarty.php.net/manual/en/language.modifier.debug.print.var.php debug_print_var (Smarty online manual) -* @author Monte Ohrt -* @param array $ |object -* @param integer $ -* @param integer $ -* @return string -*/ -class Smarty_Modifier_Debug_Print_Var { - static function execute ($var, $depth = 0, $length = 40) - { - $_replace = array("\n" => '\n', - "\r" => '\r', - "\t" => '\t' - ); - - switch (gettype($var)) { - case 'array' : - $results = 'Array (' . count($var) . ')'; - foreach ($var as $curr_key => $curr_val) { - $results .= '
' . str_repeat(' ', $depth * 2) - . '' . strtr($curr_key, $_replace) . ' => ' - . self::execute($curr_val, ++$depth, $length); - $depth--; - } - break; - case 'object' : - $object_vars = get_object_vars($var); - $results = '' . get_class($var) . ' Object (' . count($object_vars) . ')'; - foreach ($object_vars as $curr_key => $curr_val) { - $results .= '
' . str_repeat(' ', $depth * 2) - . ' ->' . strtr($curr_key, $_replace) . ' = ' - . self::execute($curr_val, ++$depth, $length); - $depth--; - } - break; - case 'boolean' : - case 'NULL' : - case 'resource' : - if (true === $var) { - $results = 'true'; - } elseif (false === $var) { - $results = 'false'; - } elseif (null === $var) { - $results = 'null'; - } else { - $results = htmlspecialchars((string) $var); - } - $results = '' . $results . ''; - break; - case 'integer' : - case 'float' : - $results = htmlspecialchars((string) $var); - break; - case 'string' : - $results = strtr($var, $_replace); - if (strlen($var) > $length) { - $results = substr($var, 0, $length - 3) . '...'; - } - $results = htmlspecialchars('"' . $results . '"'); - break; - case 'unknown type' : - default : - $results = strtr((string) $var, $_replace); - if (strlen($results) > $length) { - $results = substr($results, 0, $length - 3) . '...'; - } - $results = htmlspecialchars($results); - } - - return $results; - } -} - -?> + +* Name: debug_print_var
+* Purpose: formats variable contents for display in the console +* +* @link http://smarty.php.net/manual/en/language.modifier.debug.print.var.php debug_print_var (Smarty online manual) +* @author Monte Ohrt +* @param array $ |object +* @param integer $ +* @param integer $ +* @return string +*/ +class Smarty_Modifier_Debug_Print_Var { + static function execute ($var, $depth = 0, $length = 40) + { + $_replace = array("\n" => '\n', + "\r" => '\r', + "\t" => '\t' + ); + + switch (gettype($var)) { + case 'array' : + $results = 'Array (' . count($var) . ')'; + foreach ($var as $curr_key => $curr_val) { + $results .= '
' . str_repeat(' ', $depth * 2) + . '' . strtr($curr_key, $_replace) . ' => ' + . self::execute($curr_val, ++$depth, $length); + $depth--; + } + break; + case 'object' : + $object_vars = get_object_vars($var); + $results = '' . get_class($var) . ' Object (' . count($object_vars) . ')'; + foreach ($object_vars as $curr_key => $curr_val) { + $results .= '
' . str_repeat(' ', $depth * 2) + . ' ->' . strtr($curr_key, $_replace) . ' = ' + . self::execute($curr_val, ++$depth, $length); + $depth--; + } + break; + case 'boolean' : + case 'NULL' : + case 'resource' : + if (true === $var) { + $results = 'true'; + } elseif (false === $var) { + $results = 'false'; + } elseif (null === $var) { + $results = 'null'; + } else { + $results = htmlspecialchars((string) $var); + } + $results = '' . $results . ''; + break; + case 'integer' : + case 'float' : + $results = htmlspecialchars((string) $var); + break; + case 'string' : + $results = strtr($var, $_replace); + if (strlen($var) > $length) { + $results = substr($var, 0, $length - 3) . '...'; + } + $results = htmlspecialchars('"' . $results . '"'); + break; + case 'unknown type' : + default : + $results = strtr((string) $var, $_replace); + if (strlen($results) > $length) { + $results = substr($results, 0, $length - 3) . '...'; + } + $results = htmlspecialchars($results); + } + + return $results; + } +} + +?> diff --git a/libs/plugins/modifier.regex_replace.php b/libs/plugins/modifier.regex_replace.php index 39cdf0a0..100b58ce 100644 --- a/libs/plugins/modifier.regex_replace.php +++ b/libs/plugins/modifier.regex_replace.php @@ -1,48 +1,48 @@ - - * Name: regex_replace
- * Purpose: regular expression search/replace - * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php - * regex_replace (Smarty online manual) - * @author Monte Ohrt - * @param string - * @param string|array - * @param string|array - * @return string - */ -function smarty_modifier_regex_replace($string, $search, $replace) -{ - if(is_array($search)) { - foreach($search as $idx => $s) - $search[$idx] = _smarty_regex_replace_check($s); - } else { - $search = _smarty_regex_replace_check($search); - } - - return preg_replace($search, $replace, $string); -} - -function _smarty_regex_replace_check($search) -{ - if (($pos = strpos($search,"\0")) !== false) - $search = substr($search,0,$pos); - if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) { - /* remove eval-modifier from $search */ - $search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]); - } - return $search; -} - -/* vim: set expandtab: */ - -?> + + * Name: regex_replace
+ * Purpose: regular expression search/replace + * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php + * regex_replace (Smarty online manual) + * @author Monte Ohrt + * @param string + * @param string|array + * @param string|array + * @return string + */ +function smarty_modifier_regex_replace($string, $search, $replace) +{ + if(is_array($search)) { + foreach($search as $idx => $s) + $search[$idx] = _smarty_regex_replace_check($s); + } else { + $search = _smarty_regex_replace_check($search); + } + + return preg_replace($search, $replace, $string); +} + +function _smarty_regex_replace_check($search) +{ + if (($pos = strpos($search,"\0")) !== false) + $search = substr($search,0,$pos); + if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) { + /* remove eval-modifier from $search */ + $search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]); + } + return $search; +} + +/* vim: set expandtab: */ + +?> diff --git a/libs/plugins/modifier.string_format.php b/libs/plugins/modifier.string_format.php index 45ef8d88..fd96c8b4 100644 --- a/libs/plugins/modifier.string_format.php +++ b/libs/plugins/modifier.string_format.php @@ -1,27 +1,27 @@ - -* Name: string_format
-* Purpose: format strings via sprintf -* -* @link http://smarty.php.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual) -* @author Monte Ohrt -* @param string $string input string -* @param string $format format string -* @return string formatted string -*/ - function smarty_modifier_string_format($string, $format) - { - return sprintf($format, $string); - } - -?> + +* Name: string_format
+* Purpose: format strings via sprintf +* +* @link http://smarty.php.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual) +* @author Monte Ohrt +* @param string $string input string +* @param string $format format string +* @return string formatted string +*/ + function smarty_modifier_string_format($string, $format) + { + return sprintf($format, $string); + } + +?> diff --git a/libs/plugins/modifier.truncate.php b/libs/plugins/modifier.truncate.php index efb867ef..943a8ab6 100644 --- a/libs/plugins/modifier.truncate.php +++ b/libs/plugins/modifier.truncate.php @@ -1,64 +1,64 @@ - -* Name: truncate
-* Purpose: Truncate a string to a certain length if necessary, -* optionally splitting in the middle of a word, and -* appending the $etc string or inserting $etc into the middle. -* -* @link http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual) -* @author Monte Ohrt -* @param string $string input string -* @param integer $length lenght of truncated text -* @param string $etc end string -* @param boolean $break_words truncate at word boundary -* @param boolean $middle truncate in the middle of text -* @return string truncated string -*/ -function smarty_modifier_truncate($string, $length = 80, $etc = '...', - $break_words = false, $middle = false) -{ - if ($length == 0) - return ''; - - if (is_callable('mb_strlen')) { - if (mb_strlen($string) > $length) { - $length -= min($length, mb_strlen($etc)); - if (!$break_words && !$middle) { - $string = mb_ereg_replace('/\s+?(\S+)?$/', '', mb_substr($string, 0, $length + 1), 'p'); - } - if (!$middle) { - return mb_substr($string, 0, $length) . $etc; - } else { - return mb_substr($string, 0, $length / 2) . $etc . mb_substr($string, - $length / 2); - } - } else { - return $string; - } - } else { - if (strlen($string) > $length) { - $length -= min($length, strlen($etc)); - if (!$break_words && !$middle) { - $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1)); - } - if (!$middle) { - return substr($string, 0, $length) . $etc; - } else { - return substr($string, 0, $length / 2) . $etc . substr($string, - $length / 2); - } - } else { - return $string; - } - } -} - -?> + +* Name: truncate
+* Purpose: Truncate a string to a certain length if necessary, +* optionally splitting in the middle of a word, and +* appending the $etc string or inserting $etc into the middle. +* +* @link http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual) +* @author Monte Ohrt +* @param string $string input string +* @param integer $length lenght of truncated text +* @param string $etc end string +* @param boolean $break_words truncate at word boundary +* @param boolean $middle truncate in the middle of text +* @return string truncated string +*/ +function smarty_modifier_truncate($string, $length = 80, $etc = '...', + $break_words = false, $middle = false) +{ + if ($length == 0) + return ''; + + if (is_callable('mb_strlen')) { + if (mb_strlen($string) > $length) { + $length -= min($length, mb_strlen($etc)); + if (!$break_words && !$middle) { + $string = mb_ereg_replace('/\s+?(\S+)?$/', '', mb_substr($string, 0, $length + 1), 'p'); + } + if (!$middle) { + return mb_substr($string, 0, $length) . $etc; + } else { + return mb_substr($string, 0, $length / 2) . $etc . mb_substr($string, - $length / 2); + } + } else { + return $string; + } + } else { + if (strlen($string) > $length) { + $length -= min($length, strlen($etc)); + if (!$break_words && !$middle) { + $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1)); + } + if (!$middle) { + return substr($string, 0, $length) . $etc; + } else { + return substr($string, 0, $length / 2) . $etc . substr($string, - $length / 2); + } + } else { + return $string; + } + } +} + +?> diff --git a/libs/plugins/outputfilter.trimwhitespace.php b/libs/plugins/outputfilter.trimwhitespace.php index 60f0ca73..ce5fde98 100644 --- a/libs/plugins/outputfilter.trimwhitespace.php +++ b/libs/plugins/outputfilter.trimwhitespace.php @@ -1,76 +1,76 @@ - - * Type: outputfilter
- * Name: trimwhitespace
- * Date: Jan 25, 2003
- * Purpose: trim leading white space and blank lines from - * template source after it gets interpreted, cleaning - * up code and saving bandwidth. Does not affect - * <
>
and blocks.
- * Install: Drop into the plugin directory, call - * $smarty->load_filter('output','trimwhitespace'); - * from application. - * @author Monte Ohrt - * @author Contributions from Lars Noschinski - * @version 1.3 - * @param string $source input string - * @param object &$smarty Smarty object - * @return string filtered output - */ -function smarty_outputfilter_trimwhitespace($source, $smarty) -{ - // Pull out the script blocks - preg_match_all("!]*?>.*?!is", $source, $match); - $_script_blocks = $match[0]; - $source = preg_replace("!]*?>.*?!is", - '@@@SMARTY:TRIM:SCRIPT@@@', $source); - - // Pull out the pre blocks - preg_match_all("!]*?>.*?!is", $source, $match); - $_pre_blocks = $match[0]; - $source = preg_replace("!]*?>.*?!is", - '@@@SMARTY:TRIM:PRE@@@', $source); - - // Pull out the textarea blocks - preg_match_all("!]*?>.*?!is", $source, $match); - $_textarea_blocks = $match[0]; - $source = preg_replace("!]*?>.*?!is", - '@@@SMARTY:TRIM:TEXTAREA@@@', $source); - - // remove all leading spaces, tabs and carriage returns NOT - // preceeded by a php close tag. - $source = trim(preg_replace('/((?)\n)[\s]+/m', '\1', $source)); - - // replace textarea blocks - smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source); - - // replace pre blocks - smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $source); - - // replace script blocks - smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source); - - return $source; -} - -function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject) { - $_len = strlen($search_str); - $_pos = 0; - for ($_i=0, $_count=count($replace); $_i<$_count; $_i++) - if (($_pos=strpos($subject, $search_str, $_pos))!==false) - $subject = substr_replace($subject, $replace[$_i], $_pos, $_len); - else - break; - -} - -?> + + * Type: outputfilter
+ * Name: trimwhitespace
+ * Date: Jan 25, 2003
+ * Purpose: trim leading white space and blank lines from + * template source after it gets interpreted, cleaning + * up code and saving bandwidth. Does not affect + * <
>
and blocks.
+ * Install: Drop into the plugin directory, call + * $smarty->load_filter('output','trimwhitespace'); + * from application. + * @author Monte Ohrt + * @author Contributions from Lars Noschinski + * @version 1.3 + * @param string $source input string + * @param object &$smarty Smarty object + * @return string filtered output + */ +function smarty_outputfilter_trimwhitespace($source, $smarty) +{ + // Pull out the script blocks + preg_match_all("!]*?>.*?!is", $source, $match); + $_script_blocks = $match[0]; + $source = preg_replace("!]*?>.*?!is", + '@@@SMARTY:TRIM:SCRIPT@@@', $source); + + // Pull out the pre blocks + preg_match_all("!]*?>.*?!is", $source, $match); + $_pre_blocks = $match[0]; + $source = preg_replace("!]*?>.*?!is", + '@@@SMARTY:TRIM:PRE@@@', $source); + + // Pull out the textarea blocks + preg_match_all("!]*?>.*?!is", $source, $match); + $_textarea_blocks = $match[0]; + $source = preg_replace("!]*?>.*?!is", + '@@@SMARTY:TRIM:TEXTAREA@@@', $source); + + // remove all leading spaces, tabs and carriage returns NOT + // preceeded by a php close tag. + $source = trim(preg_replace('/((?)\n)[\s]+/m', '\1', $source)); + + // replace textarea blocks + smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source); + + // replace pre blocks + smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $source); + + // replace script blocks + smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source); + + return $source; +} + +function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject) { + $_len = strlen($search_str); + $_pos = 0; + for ($_i=0, $_count=count($replace); $_i<$_count; $_i++) + if (($_pos=strpos($subject, $search_str, $_pos))!==false) + $subject = substr_replace($subject, $replace[$_i], $_pos, $_len); + else + break; + +} + +?> diff --git a/libs/plugins/variablefilter.htmlspecialchars.php b/libs/plugins/variablefilter.htmlspecialchars.php index 1130a992..08a57833 100644 --- a/libs/plugins/variablefilter.htmlspecialchars.php +++ b/libs/plugins/variablefilter.htmlspecialchars.php @@ -1,21 +1,21 @@ - + diff --git a/libs/sysplugins/smarty_internal_compile_block.php b/libs/sysplugins/smarty_internal_compile_block.php index 8cb59644..ab4ad259 100644 --- a/libs/sysplugins/smarty_internal_compile_block.php +++ b/libs/sysplugins/smarty_internal_compile_block.php @@ -1,91 +1,91 @@ -compiler = $compiler; - $this->required_attributes = array('name'); - $this->optional_attributes = array('assign'); - // check and get attributes - $_attr = $this->_get_attributes($args); - $save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code); - $this->_open_tag('block', $save); - $compiler->template->extract_code = true; - $compiler->template->extracted_compiled_code = ''; - $compiler->template->has_code = false; - return true; - } -} - -/** -* Smarty Internal Plugin Compile BlockClose Class -*/ -class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase { - /** - * Compiles code for the {/block} tag - * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @return string compiled code - */ - public function compile($args, $compiler) - { - $this->compiler = $compiler; - $this->smarty = $compiler->smarty; - $this->compiler->has_code = true; - // turn off block code extraction - $compiler->template->extract_code = false; - // check and get attributes - $this->optional_attributes = array('name'); - $_attr = $this->_get_attributes($args); - $saved_data = $this->_close_tag(array('block')); - // if name does match to opening tag - if (isset($_attr['name']) && $saved_data[0]['name'] != $_attr['name']) { - $this->compiler->trigger_template_error('mismatching name attributes "' . $saved_data[0]['name'] . '" and "' . $_attr['name'] . '"'); - } - $_name = trim($saved_data[0]['name'], "\"'"); - if (isset($this->smarty->block_data[$_name])) { - if (strpos($this->smarty->block_data[$_name]['compiled'], '%%%%SMARTY_PARENT%%%%') !== false) { - $_output = str_replace('%%%%SMARTY_PARENT%%%%', $compiler->template->extracted_compiled_code, $this->smarty->block_data[$_name]['compiled']); - } elseif ($this->smarty->block_data[$_name]['mode'] == 'prepend') { - $_output = $this->smarty->block_data[$_name]['compiled'] . $compiler->template->extracted_compiled_code; - } elseif ($this->smarty->block_data[$_name]['mode'] == 'append') { - $_output = $compiler->template->extracted_compiled_code . $this->smarty->block_data[$_name]['compiled']; - } elseif (!empty($this->smarty->block_data[$_name])) { - $_output = $this->smarty->block_data[$_name]['compiled']; - } - } else { - $_output = $compiler->template->extracted_compiled_code; - } - $compiler->template->extracted_compiled_code = $saved_data[1]; - $compiler->template->extract_code = $saved_data[2]; - // check for includes in block tags - preg_match('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>)/', $_output, $matches); - $_output = preg_replace(array('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>.*\n)/', '/(\<\?php if\(\!defined\(\'SMARTY_DIR\'\)\))(.*)(\?\>.*\n)/'), '', $_output); - if (isset($matches[2])) { - $prop = unserialize($matches[2]); - $compiler->template->properties['file_dependency'] = array_merge($compiler->template->properties['file_dependency'], $prop['file_dependency']); - } - return $_output; - } -} - -?> +compiler = $compiler; + $this->required_attributes = array('name'); + $this->optional_attributes = array('assign'); + // check and get attributes + $_attr = $this->_get_attributes($args); + $save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code); + $this->_open_tag('block', $save); + $compiler->template->extract_code = true; + $compiler->template->extracted_compiled_code = ''; + $compiler->template->has_code = false; + return true; + } +} + +/** +* Smarty Internal Plugin Compile BlockClose Class +*/ +class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase { + /** + * Compiles code for the {/block} tag + * + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @return string compiled code + */ + public function compile($args, $compiler) + { + $this->compiler = $compiler; + $this->smarty = $compiler->smarty; + $this->compiler->has_code = true; + // turn off block code extraction + $compiler->template->extract_code = false; + // check and get attributes + $this->optional_attributes = array('name'); + $_attr = $this->_get_attributes($args); + $saved_data = $this->_close_tag(array('block')); + // if name does match to opening tag + if (isset($_attr['name']) && $saved_data[0]['name'] != $_attr['name']) { + $this->compiler->trigger_template_error('mismatching name attributes "' . $saved_data[0]['name'] . '" and "' . $_attr['name'] . '"'); + } + $_name = trim($saved_data[0]['name'], "\"'"); + if (isset($this->smarty->block_data[$_name])) { + if (strpos($this->smarty->block_data[$_name]['compiled'], '%%%%SMARTY_PARENT%%%%') !== false) { + $_output = str_replace('%%%%SMARTY_PARENT%%%%', $compiler->template->extracted_compiled_code, $this->smarty->block_data[$_name]['compiled']); + } elseif ($this->smarty->block_data[$_name]['mode'] == 'prepend') { + $_output = $this->smarty->block_data[$_name]['compiled'] . $compiler->template->extracted_compiled_code; + } elseif ($this->smarty->block_data[$_name]['mode'] == 'append') { + $_output = $compiler->template->extracted_compiled_code . $this->smarty->block_data[$_name]['compiled']; + } elseif (!empty($this->smarty->block_data[$_name])) { + $_output = $this->smarty->block_data[$_name]['compiled']; + } + } else { + $_output = $compiler->template->extracted_compiled_code; + } + $compiler->template->extracted_compiled_code = $saved_data[1]; + $compiler->template->extract_code = $saved_data[2]; + // check for includes in block tags + preg_match('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>)/', $_output, $matches); + $_output = preg_replace(array('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>.*\n)/', '/(\<\?php if\(\!defined\(\'SMARTY_DIR\'\)\))(.*)(\?\>.*\n)/'), '', $_output); + if (isset($matches[2])) { + $prop = unserialize($matches[2]); + $compiler->template->properties['file_dependency'] = array_merge($compiler->template->properties['file_dependency'], $prop['file_dependency']); + } + return $_output; + } +} + +?> diff --git a/libs/sysplugins/smarty_internal_compile_block_plugin.php b/libs/sysplugins/smarty_internal_compile_block_plugin.php index 887a3890..5003fa5c 100644 --- a/libs/sysplugins/smarty_internal_compile_block_plugin.php +++ b/libs/sysplugins/smarty_internal_compile_block_plugin.php @@ -1,64 +1,64 @@ -compiler = $compiler; - if (strlen($tag) < 6 || substr_compare($tag, 'close', -5, 5) != 0) { - // opening tag of block plugin - $this->required_attributes = array(); - $this->optional_attributes = array('_any'); - // check and get attributes - $_attr = $this->_get_attributes($args); - // convert attributes into parameter array string - $_paramsArray = array(); - foreach ($_attr as $_key => $_value) { - $_paramsArray[] = "'$_key'=>$_value"; - } - $_params = 'array(' . implode(",", $_paramsArray) . ')'; - - $this->_open_tag($tag, array($_params, $this->compiler->nocache)); - // not cachable? - if (isset($this->compiler->smarty->registered_plugins[$tag]) && !$this->compiler->smarty->registered_plugins[$tag][2]) { - $this->compiler->nocache = true; - } - // maybe nocache because of nocache variables - $this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache; - // compile code - $output = 'smarty->plugin_handler->' . $tag . '(array(' . $_params . ', null, $_smarty_tpl->smarty, &$_block_repeat, $_smarty_tpl),\'block\');while ($_block_repeat) { ob_start();?>'; - } else { - // must endblock be nocache? - if ($this->compiler->nocache) { - $this->compiler->tag_nocache = true; - } - // closing tag of block plugin, restore nocache - list($_params, $this->compiler->nocache) = $this->_close_tag(substr($tag, 0, -5)); - // This tag does create output - $this->compiler->has_output = true; - // compile code - $output = 'smarty->plugin_handler->' . substr($tag, 0, -5) . '(array(' . $_params . ', $_block_content, $_smarty_tpl->smarty, &$_block_repeat, $_smarty_tpl),\'block\'); }?>'; - } - return $output; - } -} - -?> +compiler = $compiler; + if (strlen($tag) < 6 || substr_compare($tag, 'close', -5, 5) != 0) { + // opening tag of block plugin + $this->required_attributes = array(); + $this->optional_attributes = array('_any'); + // check and get attributes + $_attr = $this->_get_attributes($args); + // convert attributes into parameter array string + $_paramsArray = array(); + foreach ($_attr as $_key => $_value) { + $_paramsArray[] = "'$_key'=>$_value"; + } + $_params = 'array(' . implode(",", $_paramsArray) . ')'; + + $this->_open_tag($tag, array($_params, $this->compiler->nocache)); + // not cachable? + if (isset($this->compiler->smarty->registered_plugins[$tag]) && !$this->compiler->smarty->registered_plugins[$tag][2]) { + $this->compiler->nocache = true; + } + // maybe nocache because of nocache variables + $this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache; + // compile code + $output = 'smarty->plugin_handler->' . $tag . '(array(' . $_params . ', null, $_smarty_tpl->smarty, &$_block_repeat, $_smarty_tpl),\'block\');while ($_block_repeat) { ob_start();?>'; + } else { + // must endblock be nocache? + if ($this->compiler->nocache) { + $this->compiler->tag_nocache = true; + } + // closing tag of block plugin, restore nocache + list($_params, $this->compiler->nocache) = $this->_close_tag(substr($tag, 0, -5)); + // This tag does create output + $this->compiler->has_output = true; + // compile code + $output = 'smarty->plugin_handler->' . substr($tag, 0, -5) . '(array(' . $_params . ', $_block_content, $_smarty_tpl->smarty, &$_block_repeat, $_smarty_tpl),\'block\'); }?>'; + } + return $output; + } +} + +?> diff --git a/libs/sysplugins/smarty_internal_compile_capture.php b/libs/sysplugins/smarty_internal_compile_capture.php index fe8041d7..9a587859 100644 --- a/libs/sysplugins/smarty_internal_compile_capture.php +++ b/libs/sysplugins/smarty_internal_compile_capture.php @@ -1,72 +1,72 @@ -compiler = $compiler; - $this->optional_attributes = array('name', 'assign', 'append'); - // check and get attributes - $_attr = $this->_get_attributes($args); - - $buffer = isset($_attr['name']) ? $_attr['name'] : "'default'"; - $assign = isset($_attr['assign']) ? $_attr['assign'] : null; - $append = isset($_attr['append']) ? $_attr['append'] : null; - - $this->compiler->_capture_stack[] = array($buffer, $assign, $append); - - $_output = ""; - - return $_output; - } -} - -/** -* Smarty Internal Plugin Compile Captureclose Class -*/ -class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase { - /** - * Compiles code for the {/capture} tag - * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @return string compiled code - */ - public function compile($args, $compiler) - { - $this->compiler = $compiler; - // check and get attributes - $_attr = $this->_get_attributes($args); - - list($buffer, $assign, $append) = array_pop($this->compiler->_capture_stack); - - $_output = "assign($assign, ob_get_contents());"; - } - if (isset($append)) { - $_output .= " \$_smarty_tpl->append($append, ob_get_contents());"; - } - $_output .= " \$_smarty_tpl->smarty->_smarty_vars['capture'][$buffer]=ob_get_clean(); ?>"; - return $_output; - } -} - -?> +compiler = $compiler; + $this->optional_attributes = array('name', 'assign', 'append'); + // check and get attributes + $_attr = $this->_get_attributes($args); + + $buffer = isset($_attr['name']) ? $_attr['name'] : "'default'"; + $assign = isset($_attr['assign']) ? $_attr['assign'] : null; + $append = isset($_attr['append']) ? $_attr['append'] : null; + + $this->compiler->_capture_stack[] = array($buffer, $assign, $append); + + $_output = ""; + + return $_output; + } +} + +/** +* Smarty Internal Plugin Compile Captureclose Class +*/ +class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase { + /** + * Compiles code for the {/capture} tag + * + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @return string compiled code + */ + public function compile($args, $compiler) + { + $this->compiler = $compiler; + // check and get attributes + $_attr = $this->_get_attributes($args); + + list($buffer, $assign, $append) = array_pop($this->compiler->_capture_stack); + + $_output = "assign($assign, ob_get_contents());"; + } + if (isset($append)) { + $_output .= " \$_smarty_tpl->append($append, ob_get_contents());"; + } + $_output .= " \$_smarty_tpl->smarty->_smarty_vars['capture'][$buffer]=ob_get_clean(); ?>"; + return $_output; + } +} + +?> diff --git a/libs/sysplugins/smarty_internal_compile_debug.php b/libs/sysplugins/smarty_internal_compile_debug.php index 737d6216..8ff9671a 100644 --- a/libs/sysplugins/smarty_internal_compile_debug.php +++ b/libs/sysplugins/smarty_internal_compile_debug.php @@ -1,34 +1,34 @@ -compiler = $compiler; - // check and get attributes - $_attr = $this->_get_attributes($args); - - // display debug template - $_output = "smarty->loadPlugin('Smarty_Internal_Debug'); Smarty_Internal_Debug::display_debug(\$_smarty_tpl->smarty); ?>"; - return $_output; - } -} - -?> +compiler = $compiler; + // check and get attributes + $_attr = $this->_get_attributes($args); + + // display debug template + $_output = "smarty->loadPlugin('Smarty_Internal_Debug'); Smarty_Internal_Debug::display_debug(\$_smarty_tpl->smarty); ?>"; + return $_output; + } +} + +?> diff --git a/libs/sysplugins/smarty_internal_compile_for.php b/libs/sysplugins/smarty_internal_compile_for.php index a527ee18..4f4ef943 100644 --- a/libs/sysplugins/smarty_internal_compile_for.php +++ b/libs/sysplugins/smarty_internal_compile_for.php @@ -1,109 +1,109 @@ -compiler = $compiler; - // {for $x=0; $x<$y; $x++} syntax - $this->required_attributes = array('ifexp', 'start', 'loop', 'varloop'); - // check and get attributes - $_attr = $this->_get_attributes($args); - - $this->_open_tag('for', array('for',$this->compiler->nocache)); - // maybe nocache because of nocache variables - $this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache; - - $output = "tpl_vars[$_statement[var]] = new Smarty_Variable;"; - $output .= " \$_smarty_tpl->tpl_vars[$_statement[var]]->value = $_statement[value];\n"; - } - $output .= " if ($_attr[ifexp]){ for (\$_foo=true;$_attr[ifexp]; \$_smarty_tpl->tpl_vars[$_attr[varloop]]->value$_attr[loop]){\n"; - $output .= "?>"; - // return compiled code - return $output; - } -} - -/** -* Smarty Internal Plugin Compile Forelse Class -*/ -class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase { - /** - * Compiles code for the {forelse} tag - * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @return string compiled code - */ - public function compile($args, $compiler) - { - $this->compiler = $compiler; - // check and get attributes - $_attr = $this->_get_attributes($args); - - list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('for')); - $this->_open_tag('forelse',array('forelse', $this->compiler->nocache)); - return ""; - } -} - -/** -* Smarty Internal Plugin Compile Forclose Class -*/ -class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase { - /** - * Compiles code for the {/for} tag - * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @return string compiled code - */ - public function compile($args, $compiler) - { - $this->compiler = $compiler; - // check and get attributes - $_attr = $this->_get_attributes($args); - // must endblock be nocache? - if ($this->compiler->nocache) { - $this->compiler->tag_nocache = true; - } - - list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('for', 'forelse')); - if ($_open_tag == 'forelse') - return ""; - else - return ""; - } -} - -?> +compiler = $compiler; + // {for $x=0; $x<$y; $x++} syntax + $this->required_attributes = array('ifexp', 'start', 'loop', 'varloop'); + // check and get attributes + $_attr = $this->_get_attributes($args); + + $this->_open_tag('for', array('for',$this->compiler->nocache)); + // maybe nocache because of nocache variables + $this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache; + + $output = "tpl_vars[$_statement[var]] = new Smarty_Variable;"; + $output .= " \$_smarty_tpl->tpl_vars[$_statement[var]]->value = $_statement[value];\n"; + } + $output .= " if ($_attr[ifexp]){ for (\$_foo=true;$_attr[ifexp]; \$_smarty_tpl->tpl_vars[$_attr[varloop]]->value$_attr[loop]){\n"; + $output .= "?>"; + // return compiled code + return $output; + } +} + +/** +* Smarty Internal Plugin Compile Forelse Class +*/ +class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase { + /** + * Compiles code for the {forelse} tag + * + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @return string compiled code + */ + public function compile($args, $compiler) + { + $this->compiler = $compiler; + // check and get attributes + $_attr = $this->_get_attributes($args); + + list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('for')); + $this->_open_tag('forelse',array('forelse', $this->compiler->nocache)); + return ""; + } +} + +/** +* Smarty Internal Plugin Compile Forclose Class +*/ +class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase { + /** + * Compiles code for the {/for} tag + * + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @return string compiled code + */ + public function compile($args, $compiler) + { + $this->compiler = $compiler; + // check and get attributes + $_attr = $this->_get_attributes($args); + // must endblock be nocache? + if ($this->compiler->nocache) { + $this->compiler->tag_nocache = true; + } + + list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('for', 'forelse')); + if ($_open_tag == 'forelse') + return ""; + else + return ""; + } +} + +?> diff --git a/libs/sysplugins/smarty_internal_compile_foreach.php b/libs/sysplugins/smarty_internal_compile_foreach.php index 76a9fd66..6f7df8d4 100644 --- a/libs/sysplugins/smarty_internal_compile_foreach.php +++ b/libs/sysplugins/smarty_internal_compile_foreach.php @@ -1,192 +1,192 @@ -compiler = $compiler; - $this->required_attributes = array('from', 'item'); - $this->optional_attributes = array('name', 'key'); - $tpl = $compiler->template; - // check and get attributes - $_attr = $this->_get_attributes($args); - - $this->_open_tag('foreach', array('foreach',$this->compiler->nocache)); - // maybe nocache because of nocache variables - $this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache; - - $from = $_attr['from']; - $item = $_attr['item']; - - if (isset($_attr['key'])) { - $key = $_attr['key']; - } else { - $key = null; - } - - if (isset($_attr['name'])) { - $name = $_attr['name']; - $has_name = true; - $SmartyVarName = '$smarty.foreach.' . trim($name,'\'"') . '.'; - } else { - $name = null; - $has_name = false; - } - $ItemVarName = '$' . trim($item,'\'"') . '@'; - // evaluates which Smarty variables and properties have to be computed - if ($has_name) { - $usesSmartyFirst = strpos($tpl->template_source, $SmartyVarName . 'first') !== false; - $usesSmartyLast = strpos($tpl->template_source, $SmartyVarName . 'last') !== false; - $usesSmartyIndex = strpos($tpl->template_source, $SmartyVarName . 'index') !== false; - $usesSmartyIteration = strpos($tpl->template_source, $SmartyVarName . 'iteration') !== false; - $usesSmartyShow = strpos($tpl->template_source, $SmartyVarName . 'show') !== false; - $usesSmartyTotal = $usesSmartyLast || strpos($tpl->template_source, $SmartyVarName . 'total') !== false; - } else { - $usesSmartyFirst = false; - $usesSmartyLast = false; - $usesSmartyTotal = false; - } - - $usesPropFirst = $usesSmartyFirst || strpos($tpl->template_source, $ItemVarName . 'first') !== false; - $usesPropLast = $usesSmartyLast || strpos($tpl->template_source, $ItemVarName . 'last') !== false; - $usesPropIndex = $usesPropFirst || strpos($tpl->template_source, $ItemVarName . 'index') !== false; - $usesPropIteration = $usesPropLast || strpos($tpl->template_source, $ItemVarName . 'iteration') !== false; - $usesPropShow = strpos($tpl->template_source, $ItemVarName . 'show') !== false; - $usesPropTotal = $usesSmartyTotal || $usesPropLast || strpos($tpl->template_source, $ItemVarName . 'total') !== false; - // generate output code - $output = "tpl_vars[$item] = new Smarty_Variable;\n"; - if ($key != null) { - $output .= " \$_smarty_tpl->tpl_vars[$key] = new Smarty_Variable;\n"; - } - $output .= " \$_from = $from; if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array');}\n"; - if ($usesPropTotal) { - $output .= " \$_smarty_tpl->tpl_vars[$item]->total=count(\$_from);\n"; - } - if ($usesPropIteration) { - $output .= " \$_smarty_tpl->tpl_vars[$item]->iteration=0;\n"; - } - if ($usesPropIndex) { - $output .= " \$_smarty_tpl->tpl_vars[$item]->index=-1;\n"; - } - if ($has_name) { - if ($usesSmartyTotal) { - $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['total'] = \$_smarty_tpl->tpl_vars[$item]->total;\n"; - } - if ($usesSmartyIteration) { - $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['iteration']=0;\n"; - } - if ($usesSmartyIndex) { - $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['index']=-1;\n"; - } - } - $output .= "if (count(\$_from) > 0){\n"; - $output .= " foreach (\$_from as \$_smarty_tpl->tpl_vars[$item]->key => \$_smarty_tpl->tpl_vars[$item]->value){\n"; - if ($key != null) { - $output .= " \$_smarty_tpl->tpl_vars[$key]->value = \$_smarty_tpl->tpl_vars[$item]->key;\n"; - } - if ($usesPropIteration) { - $output .= " \$_smarty_tpl->tpl_vars[$item]->iteration++;\n"; - } - if ($usesPropIndex) { - $output .= " \$_smarty_tpl->tpl_vars[$item]->index++;\n"; - } - if ($usesPropFirst) { - $output .= " \$_smarty_tpl->tpl_vars[$item]->first = \$_smarty_tpl->tpl_vars[$item]->index === 0;\n"; - } - if ($usesPropLast) { - $output .= " \$_smarty_tpl->tpl_vars[$item]->last = \$_smarty_tpl->tpl_vars[$item]->iteration === \$_smarty_tpl->tpl_vars[$item]->total;\n"; - } - if ($has_name) { - if ($usesSmartyFirst) { - $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['first'] = \$_smarty_tpl->tpl_vars[$item]->first;\n"; - } - if ($usesSmartyIteration) { - $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['iteration']++;\n"; - } - if ($usesSmartyIndex) { - $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['index']++;\n"; - } - if ($usesSmartyLast) { - $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['last'] = \$_smarty_tpl->tpl_vars[$item]->last;\n"; - } - } - $output .= "?>"; - - return $output; - } -} - -/** -* Smarty Internal Plugin Compile Foreachelse Class -*/ -class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase { - /** - * Compiles code for the {foreachelse} tag - * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @return string compiled code - */ - public function compile($args, $compiler) - { - $this->compiler = $compiler; - // check and get attributes - $_attr = $this->_get_attributes($args); - - list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('foreach')); - $this->_open_tag('foreachelse',array('foreachelse', $this->compiler->nocache)); - - return ""; - } -} - -/** -* Smarty Internal Plugin Compile Foreachclose Class -*/ -class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase { - /** - * Compiles code for the {/foreach} tag - * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @return string compiled code - */ - public function compile($args, $compiler) - { - $this->compiler = $compiler; - // check and get attributes - $_attr = $this->_get_attributes($args); - - // must endblock be nocache? - if ($this->compiler->nocache) { - $this->compiler->tag_nocache = true; - } - - list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('foreach', 'foreachelse')); - - if ($_open_tag == 'foreachelse') - return ""; - else - return ""; - } -} - -?> +compiler = $compiler; + $this->required_attributes = array('from', 'item'); + $this->optional_attributes = array('name', 'key'); + $tpl = $compiler->template; + // check and get attributes + $_attr = $this->_get_attributes($args); + + $this->_open_tag('foreach', array('foreach',$this->compiler->nocache)); + // maybe nocache because of nocache variables + $this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache; + + $from = $_attr['from']; + $item = $_attr['item']; + + if (isset($_attr['key'])) { + $key = $_attr['key']; + } else { + $key = null; + } + + if (isset($_attr['name'])) { + $name = $_attr['name']; + $has_name = true; + $SmartyVarName = '$smarty.foreach.' . trim($name,'\'"') . '.'; + } else { + $name = null; + $has_name = false; + } + $ItemVarName = '$' . trim($item,'\'"') . '@'; + // evaluates which Smarty variables and properties have to be computed + if ($has_name) { + $usesSmartyFirst = strpos($tpl->template_source, $SmartyVarName . 'first') !== false; + $usesSmartyLast = strpos($tpl->template_source, $SmartyVarName . 'last') !== false; + $usesSmartyIndex = strpos($tpl->template_source, $SmartyVarName . 'index') !== false; + $usesSmartyIteration = strpos($tpl->template_source, $SmartyVarName . 'iteration') !== false; + $usesSmartyShow = strpos($tpl->template_source, $SmartyVarName . 'show') !== false; + $usesSmartyTotal = $usesSmartyLast || strpos($tpl->template_source, $SmartyVarName . 'total') !== false; + } else { + $usesSmartyFirst = false; + $usesSmartyLast = false; + $usesSmartyTotal = false; + } + + $usesPropFirst = $usesSmartyFirst || strpos($tpl->template_source, $ItemVarName . 'first') !== false; + $usesPropLast = $usesSmartyLast || strpos($tpl->template_source, $ItemVarName . 'last') !== false; + $usesPropIndex = $usesPropFirst || strpos($tpl->template_source, $ItemVarName . 'index') !== false; + $usesPropIteration = $usesPropLast || strpos($tpl->template_source, $ItemVarName . 'iteration') !== false; + $usesPropShow = strpos($tpl->template_source, $ItemVarName . 'show') !== false; + $usesPropTotal = $usesSmartyTotal || $usesPropLast || strpos($tpl->template_source, $ItemVarName . 'total') !== false; + // generate output code + $output = "tpl_vars[$item] = new Smarty_Variable;\n"; + if ($key != null) { + $output .= " \$_smarty_tpl->tpl_vars[$key] = new Smarty_Variable;\n"; + } + $output .= " \$_from = $from; if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array');}\n"; + if ($usesPropTotal) { + $output .= " \$_smarty_tpl->tpl_vars[$item]->total=count(\$_from);\n"; + } + if ($usesPropIteration) { + $output .= " \$_smarty_tpl->tpl_vars[$item]->iteration=0;\n"; + } + if ($usesPropIndex) { + $output .= " \$_smarty_tpl->tpl_vars[$item]->index=-1;\n"; + } + if ($has_name) { + if ($usesSmartyTotal) { + $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['total'] = \$_smarty_tpl->tpl_vars[$item]->total;\n"; + } + if ($usesSmartyIteration) { + $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['iteration']=0;\n"; + } + if ($usesSmartyIndex) { + $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['index']=-1;\n"; + } + } + $output .= "if (count(\$_from) > 0){\n"; + $output .= " foreach (\$_from as \$_smarty_tpl->tpl_vars[$item]->key => \$_smarty_tpl->tpl_vars[$item]->value){\n"; + if ($key != null) { + $output .= " \$_smarty_tpl->tpl_vars[$key]->value = \$_smarty_tpl->tpl_vars[$item]->key;\n"; + } + if ($usesPropIteration) { + $output .= " \$_smarty_tpl->tpl_vars[$item]->iteration++;\n"; + } + if ($usesPropIndex) { + $output .= " \$_smarty_tpl->tpl_vars[$item]->index++;\n"; + } + if ($usesPropFirst) { + $output .= " \$_smarty_tpl->tpl_vars[$item]->first = \$_smarty_tpl->tpl_vars[$item]->index === 0;\n"; + } + if ($usesPropLast) { + $output .= " \$_smarty_tpl->tpl_vars[$item]->last = \$_smarty_tpl->tpl_vars[$item]->iteration === \$_smarty_tpl->tpl_vars[$item]->total;\n"; + } + if ($has_name) { + if ($usesSmartyFirst) { + $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['first'] = \$_smarty_tpl->tpl_vars[$item]->first;\n"; + } + if ($usesSmartyIteration) { + $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['iteration']++;\n"; + } + if ($usesSmartyIndex) { + $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['index']++;\n"; + } + if ($usesSmartyLast) { + $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['last'] = \$_smarty_tpl->tpl_vars[$item]->last;\n"; + } + } + $output .= "?>"; + + return $output; + } +} + +/** +* Smarty Internal Plugin Compile Foreachelse Class +*/ +class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase { + /** + * Compiles code for the {foreachelse} tag + * + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @return string compiled code + */ + public function compile($args, $compiler) + { + $this->compiler = $compiler; + // check and get attributes + $_attr = $this->_get_attributes($args); + + list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('foreach')); + $this->_open_tag('foreachelse',array('foreachelse', $this->compiler->nocache)); + + return ""; + } +} + +/** +* Smarty Internal Plugin Compile Foreachclose Class +*/ +class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase { + /** + * Compiles code for the {/foreach} tag + * + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @return string compiled code + */ + public function compile($args, $compiler) + { + $this->compiler = $compiler; + // check and get attributes + $_attr = $this->_get_attributes($args); + + // must endblock be nocache? + if ($this->compiler->nocache) { + $this->compiler->tag_nocache = true; + } + + list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('foreach', 'foreachelse')); + + if ($_open_tag == 'foreachelse') + return ""; + else + return ""; + } +} + +?> diff --git a/libs/sysplugins/smarty_internal_compile_function.php b/libs/sysplugins/smarty_internal_compile_function.php index 16da54bd..56f451b7 100644 --- a/libs/sysplugins/smarty_internal_compile_function.php +++ b/libs/sysplugins/smarty_internal_compile_function.php @@ -1,79 +1,79 @@ -compiler = $compiler; - $this->required_attributes = array('name'); - $this->optional_attributes = array('_any'); - // check and get attributes - $_attr = $this->_get_attributes($args); - $save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code); - $this->_open_tag('function', $save); - $_name = trim($_attr['name'], "'"); - foreach ($_attr as $_key => $_data) { - $compiler->template->properties['function'][$_name]['parameter'][$_key] = $_data; - } - // make function known for recursive calls - $this->compiler->smarty->template_functions[$_name]['compiled'] = ''; - $compiler->template->extract_code = true; - $compiler->template->extracted_compiled_code = ''; - $compiler->template->has_code = false; - return true; - } -} - -/** -* Smarty Internal Plugin Compile Functionclose Class -*/ -class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase { - /** - * Compiles code for the {/function} tag - * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @return boolean true - */ - public function compile($args, $compiler) - { - $this->compiler = $compiler; - $this->compiler->has_code = false; - // turn off block code extraction - $compiler->template->extract_code = false; - // check and get attributes - $this->optional_attributes = array('name'); - $_attr = $this->_get_attributes($args); - $saved_data = $this->_close_tag(array('function')); - // if name does match to opening tag - if (isset($_attr['name']) && $saved_data[0]['name'] != $_attr['name']) { - $this->compiler->trigger_template_error('mismatching name attributes "' . $saved_data[0]['name'] . '" and "' . $_attr['name'] . '"'); - } - $_name = trim($saved_data[0]['name'], "'"); - $compiler->template->properties['function'][$_name]['compiled'] = str_replace("\n",'_%n',$compiler->template->extracted_compiled_code); - $this->compiler->smarty->template_functions[$_name]['compiled'] = $compiler->template->extracted_compiled_code; - $this->compiler->smarty->template_functions[$_name]['parameter'] = $compiler->template->properties['function'][$_name]['parameter']; - $compiler->template->extracted_compiled_code = $saved_data[1]; - $compiler->template->extract_code = $saved_data[2]; - return true; - } -} - -?> +compiler = $compiler; + $this->required_attributes = array('name'); + $this->optional_attributes = array('_any'); + // check and get attributes + $_attr = $this->_get_attributes($args); + $save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code); + $this->_open_tag('function', $save); + $_name = trim($_attr['name'], "'"); + foreach ($_attr as $_key => $_data) { + $compiler->template->properties['function'][$_name]['parameter'][$_key] = $_data; + } + // make function known for recursive calls + $this->compiler->smarty->template_functions[$_name]['compiled'] = ''; + $compiler->template->extract_code = true; + $compiler->template->extracted_compiled_code = ''; + $compiler->template->has_code = false; + return true; + } +} + +/** +* Smarty Internal Plugin Compile Functionclose Class +*/ +class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase { + /** + * Compiles code for the {/function} tag + * + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @return boolean true + */ + public function compile($args, $compiler) + { + $this->compiler = $compiler; + $this->compiler->has_code = false; + // turn off block code extraction + $compiler->template->extract_code = false; + // check and get attributes + $this->optional_attributes = array('name'); + $_attr = $this->_get_attributes($args); + $saved_data = $this->_close_tag(array('function')); + // if name does match to opening tag + if (isset($_attr['name']) && $saved_data[0]['name'] != $_attr['name']) { + $this->compiler->trigger_template_error('mismatching name attributes "' . $saved_data[0]['name'] . '" and "' . $_attr['name'] . '"'); + } + $_name = trim($saved_data[0]['name'], "'"); + $compiler->template->properties['function'][$_name]['compiled'] = str_replace("\n",'_%n',$compiler->template->extracted_compiled_code); + $this->compiler->smarty->template_functions[$_name]['compiled'] = $compiler->template->extracted_compiled_code; + $this->compiler->smarty->template_functions[$_name]['parameter'] = $compiler->template->properties['function'][$_name]['parameter']; + $compiler->template->extracted_compiled_code = $saved_data[1]; + $compiler->template->extract_code = $saved_data[2]; + return true; + } +} + +?> diff --git a/libs/sysplugins/smarty_internal_compile_if.php b/libs/sysplugins/smarty_internal_compile_if.php index 0095208d..fd0f1d71 100644 --- a/libs/sysplugins/smarty_internal_compile_if.php +++ b/libs/sysplugins/smarty_internal_compile_if.php @@ -1,114 +1,114 @@ -compiler = $compiler; - $this->required_attributes = array('if condition'); - // check and get attributes - $_attr = $this->_get_attributes($args); - $this->_open_tag('if',array(1,$compiler->tag_nocache)); - if (is_array($args['if condition'])) { - $_output = "tpl_vars[".$args['if condition']['var']."])) \$_smarty_tpl->tpl_vars[".$args['if condition']['var']."] = new Smarty_Variable;"; - $_output .= "if (\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."]->value = ".$args['if condition']['value']."){?>"; - return $_output; - } else { - return ''; - } - } -} - -/** -* Smarty Internal Plugin Compile Else Class -*/ -class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase { - /** - * Compiles code for the {else} tag - * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @return string compiled code - */ - public function compile($args, $compiler) - { - $this->compiler = $compiler; - list($nesting, $compiler->tag_nocache) = $this->_close_tag(array('if', 'elseif')); - $this->_open_tag('else',array($nesting,$compiler->tag_nocache)); - - return ''; - } -} - -/** -* Smarty Internal Plugin Compile ElseIf Class -*/ -class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase { - /** - * Compiles code for the {elseif} tag - * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @return string compiled code - */ - public function compile($args, $compiler) - { - $this->compiler = $compiler; - $this->required_attributes = array('if condition'); - // check and get attributes - $_attr = $this->_get_attributes($args); - - list($nesting, $compiler->tag_nocache) = $this->_close_tag(array('if', 'elseif')); - - if (empty($this->compiler->prefix_code)) { - $this->_open_tag('elseif', array($nesting, $compiler->tag_nocache)); - return ''; - } else { - $tmp = ''; - foreach ($this->compiler->prefix_code as $code) $tmp .= $code; - $this->compiler->prefix_code = array(); - $this->_open_tag('elseif', array($nesting + 1, $compiler->tag_nocache)); - return '' . $tmp . ''; - } - } -} - -/** -* Smarty Internal Plugin Compile Ifclose Class -*/ -class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase { - /** - * Compiles code for the {/if} tag - * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @return string compiled code - */ - public function compile($args, $compiler) - { - $this->compiler = $compiler; - list($nesting, $compiler->tag_nocache) = $this->_close_tag(array('if', 'else', 'elseif')); - $tmp = ''; - for ($i = 0; $i < $nesting ; $i++) $tmp .= '}'; - return ""; - } -} - -?> +compiler = $compiler; + $this->required_attributes = array('if condition'); + // check and get attributes + $_attr = $this->_get_attributes($args); + $this->_open_tag('if',array(1,$compiler->tag_nocache)); + if (is_array($args['if condition'])) { + $_output = "tpl_vars[".$args['if condition']['var']."])) \$_smarty_tpl->tpl_vars[".$args['if condition']['var']."] = new Smarty_Variable;"; + $_output .= "if (\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."]->value = ".$args['if condition']['value']."){?>"; + return $_output; + } else { + return ''; + } + } +} + +/** +* Smarty Internal Plugin Compile Else Class +*/ +class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase { + /** + * Compiles code for the {else} tag + * + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @return string compiled code + */ + public function compile($args, $compiler) + { + $this->compiler = $compiler; + list($nesting, $compiler->tag_nocache) = $this->_close_tag(array('if', 'elseif')); + $this->_open_tag('else',array($nesting,$compiler->tag_nocache)); + + return ''; + } +} + +/** +* Smarty Internal Plugin Compile ElseIf Class +*/ +class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase { + /** + * Compiles code for the {elseif} tag + * + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @return string compiled code + */ + public function compile($args, $compiler) + { + $this->compiler = $compiler; + $this->required_attributes = array('if condition'); + // check and get attributes + $_attr = $this->_get_attributes($args); + + list($nesting, $compiler->tag_nocache) = $this->_close_tag(array('if', 'elseif')); + + if (empty($this->compiler->prefix_code)) { + $this->_open_tag('elseif', array($nesting, $compiler->tag_nocache)); + return ''; + } else { + $tmp = ''; + foreach ($this->compiler->prefix_code as $code) $tmp .= $code; + $this->compiler->prefix_code = array(); + $this->_open_tag('elseif', array($nesting + 1, $compiler->tag_nocache)); + return '' . $tmp . ''; + } + } +} + +/** +* Smarty Internal Plugin Compile Ifclose Class +*/ +class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase { + /** + * Compiles code for the {/if} tag + * + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @return string compiled code + */ + public function compile($args, $compiler) + { + $this->compiler = $compiler; + list($nesting, $compiler->tag_nocache) = $this->_close_tag(array('if', 'else', 'elseif')); + $tmp = ''; + for ($i = 0; $i < $nesting ; $i++) $tmp .= '}'; + return ""; + } +} + +?> diff --git a/libs/sysplugins/smarty_internal_compile_include.php b/libs/sysplugins/smarty_internal_compile_include.php index 68e99ce6..151f0ee9 100644 --- a/libs/sysplugins/smarty_internal_compile_include.php +++ b/libs/sysplugins/smarty_internal_compile_include.php @@ -1,159 +1,159 @@ -compiler = $compiler; - $this->required_attributes = array('file'); - $this->optional_attributes = array('_any'); - // check and get attributes - $_attr = $this->_get_attributes($args); - // save posible attributes - $include_file = $_attr['file']; - $has_compiled_template = false; - if ($compiler->smarty->merge_compiled_includes) { - // check if compiled code can be merged (contains no variable part) - if (!$compiler->has_variable_string && (substr_count($include_file, '"') == 2 or substr_count($include_file, "'") == 2) and substr_count($include_file, '(') == 0) { - eval("\$tmp = $include_file;"); - if ($this->compiler->template->template_resource != $tmp) { - $tpl = $compiler->smarty->createTemplate ($tmp, $compiler->template->cache_id, $compiler->template->compile_id, $compiler->template); - if ($tpl->usesCompiler() && $tpl->isExisting()) { - do { - $must_compile = false; - $prop = array(); - $compiled_tpl = $tpl->getCompiledTemplate(); - preg_match('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>)/', $compiled_tpl, $matches); - $compiled_tpl = preg_replace(array('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>.*\n)/', '/(\<\?php if\(\!defined\(\'SMARTY_DIR\'\)\))(.*)(\?\>.*\n)/'), '', $compiled_tpl); - // var_dump($matches, $compiled_tpl); - if (isset($matches[2])) { - $prop = unserialize($matches[2]); - foreach ($prop['file_dependency'] as $_file_to_check) { - If (is_file($_file_to_check[0])) { - $mtime = filemtime($_file_to_check[0]); - } else { - $tpl->parseResourceName($_file_to_check[0], $resource_type, $resource_name, $resource_handler); - $mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name); - } - If ($mtime != $_file_to_check[1]) { - $must_compile = true; - break; - } - } - if ($must_compile) { - // recompile - $tpl->compileTemplateSource(); - } - } - } while ($must_compile); - if (isset($prop['file_dependency'])) { - $compiler->template->properties['file_dependency'] = array_merge($compiler->template->properties['file_dependency'], $prop['file_dependency']); - } - $has_compiled_template = true; - } - } - } - } - - if (isset($_attr['assign'])) { - // output will be stored in a smarty variable instead of beind displayed - $_assign = $_attr['assign']; - } - - $_parent_scope = SMARTY_LOCAL_SCOPE; - if (isset($_attr['scope'])) { - if ($_attr['scope'] == '\'parent\'') { - $_parent_scope = SMARTY_PARENT_SCOPE; - } elseif ($_attr['scope'] == '\'root\'') { - $_parent_scope = SMARTY_ROOT_SCOPE; - } elseif ($_attr['scope'] == '\'global\'') { - $_parent_scope = SMARTY_GLOBAL_SCOPE; - } - } - // default for included templates - if ($compiler->template->caching) { - $_caching = SMARTY_CACHING_LIFETIME_CURRENT; - } else { - $_caching = SMARTY_CACHING_OFF; - } - /* - * if the {include} tag provides individual parameter for caching - * it will not be included into the common cache file and treated like - * a nocache section - */ - if (isset($_attr['cache_lifetime'])) { - $_cache_lifetime = $_attr['cache_lifetime']; - $this->compiler->tag_nocache = true; - } - if (isset($_attr['nocache'])) { - if ($_attr['nocache'] == 'true') { - $this->compiler->tag_nocache = true; - } - } - if (isset($_attr['caching'])) { - if ($_attr['caching'] == 'true') { - $_caching = SMARTY_CACHING_LIFETIME_CURRENT; - } else { - $_caching = SMARTY_CACHING_OFF; - } - } - // create template object - $_output = "smarty, \$_smarty_tpl, \$_smarty_tpl->cache_id, \$_smarty_tpl->compile_id);"; - // delete {include} standard attributes - unset($_attr['file'], $_attr['assign'], $_attr['cache_lifetime'], $_attr['nocache'], $_attr['caching'], $_attr['scope']); - // remaining attributes must be assigned as smarty variable - if (!empty($_attr)) { - if ($_parent_scope == SMARTY_LOCAL_SCOPE) { - // create variables - foreach ($_attr as $_key => $_value) { - $_output .= "\$_template->assign('$_key',$_value);"; - } - } else { - $this->compiler->trigger_template_error('variable passing not allowed in parent/global scope'); - } - } - // add caching parameter if required - if (isset($_cache_lifetime)) { - $_output .= "\$_template->cache_lifetime = $_cache_lifetime;"; - $_caching = SMARTY_CACHING_LIFETIME_CURRENT; - } - $_output .= "\$_template->caching = $_caching;"; - // was there an assign attribute - if (isset($_assign)) { - $_output .= "\$_smarty_tpl->assign($_assign,\$_template->fetch()); ?>"; - } else { - if ($has_compiled_template) { - $_output .= " \$_tpl_stack[] = \$_smarty_tpl; \$_smarty_tpl = \$_template;?>\n"; - $_output .= $compiled_tpl . "getTemplateFilepath() . "\" */ ?>"; - $_output .= ""; - } else { - $_output .= " echo \$_template->fetch(); ?>"; - } - } - if ($_parent_scope != SMARTY_LOCAL_SCOPE) { - $_output .= "updateParentVariables($_parent_scope); ?>"; - } - $_output .= ""; - return $_output; - } -} - -?> +compiler = $compiler; + $this->required_attributes = array('file'); + $this->optional_attributes = array('_any'); + // check and get attributes + $_attr = $this->_get_attributes($args); + // save posible attributes + $include_file = $_attr['file']; + $has_compiled_template = false; + if ($compiler->smarty->merge_compiled_includes) { + // check if compiled code can be merged (contains no variable part) + if (!$compiler->has_variable_string && (substr_count($include_file, '"') == 2 or substr_count($include_file, "'") == 2) and substr_count($include_file, '(') == 0) { + eval("\$tmp = $include_file;"); + if ($this->compiler->template->template_resource != $tmp) { + $tpl = $compiler->smarty->createTemplate ($tmp, $compiler->template->cache_id, $compiler->template->compile_id, $compiler->template); + if ($tpl->usesCompiler() && $tpl->isExisting()) { + do { + $must_compile = false; + $prop = array(); + $compiled_tpl = $tpl->getCompiledTemplate(); + preg_match('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>)/', $compiled_tpl, $matches); + $compiled_tpl = preg_replace(array('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>.*\n)/', '/(\<\?php if\(\!defined\(\'SMARTY_DIR\'\)\))(.*)(\?\>.*\n)/'), '', $compiled_tpl); + // var_dump($matches, $compiled_tpl); + if (isset($matches[2])) { + $prop = unserialize($matches[2]); + foreach ($prop['file_dependency'] as $_file_to_check) { + If (is_file($_file_to_check[0])) { + $mtime = filemtime($_file_to_check[0]); + } else { + $tpl->parseResourceName($_file_to_check[0], $resource_type, $resource_name, $resource_handler); + $mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name); + } + If ($mtime != $_file_to_check[1]) { + $must_compile = true; + break; + } + } + if ($must_compile) { + // recompile + $tpl->compileTemplateSource(); + } + } + } while ($must_compile); + if (isset($prop['file_dependency'])) { + $compiler->template->properties['file_dependency'] = array_merge($compiler->template->properties['file_dependency'], $prop['file_dependency']); + } + $has_compiled_template = true; + } + } + } + } + + if (isset($_attr['assign'])) { + // output will be stored in a smarty variable instead of beind displayed + $_assign = $_attr['assign']; + } + + $_parent_scope = SMARTY_LOCAL_SCOPE; + if (isset($_attr['scope'])) { + if ($_attr['scope'] == '\'parent\'') { + $_parent_scope = SMARTY_PARENT_SCOPE; + } elseif ($_attr['scope'] == '\'root\'') { + $_parent_scope = SMARTY_ROOT_SCOPE; + } elseif ($_attr['scope'] == '\'global\'') { + $_parent_scope = SMARTY_GLOBAL_SCOPE; + } + } + // default for included templates + if ($compiler->template->caching) { + $_caching = SMARTY_CACHING_LIFETIME_CURRENT; + } else { + $_caching = SMARTY_CACHING_OFF; + } + /* + * if the {include} tag provides individual parameter for caching + * it will not be included into the common cache file and treated like + * a nocache section + */ + if (isset($_attr['cache_lifetime'])) { + $_cache_lifetime = $_attr['cache_lifetime']; + $this->compiler->tag_nocache = true; + } + if (isset($_attr['nocache'])) { + if ($_attr['nocache'] == 'true') { + $this->compiler->tag_nocache = true; + } + } + if (isset($_attr['caching'])) { + if ($_attr['caching'] == 'true') { + $_caching = SMARTY_CACHING_LIFETIME_CURRENT; + } else { + $_caching = SMARTY_CACHING_OFF; + } + } + // create template object + $_output = "smarty, \$_smarty_tpl, \$_smarty_tpl->cache_id, \$_smarty_tpl->compile_id);"; + // delete {include} standard attributes + unset($_attr['file'], $_attr['assign'], $_attr['cache_lifetime'], $_attr['nocache'], $_attr['caching'], $_attr['scope']); + // remaining attributes must be assigned as smarty variable + if (!empty($_attr)) { + if ($_parent_scope == SMARTY_LOCAL_SCOPE) { + // create variables + foreach ($_attr as $_key => $_value) { + $_output .= "\$_template->assign('$_key',$_value);"; + } + } else { + $this->compiler->trigger_template_error('variable passing not allowed in parent/global scope'); + } + } + // add caching parameter if required + if (isset($_cache_lifetime)) { + $_output .= "\$_template->cache_lifetime = $_cache_lifetime;"; + $_caching = SMARTY_CACHING_LIFETIME_CURRENT; + } + $_output .= "\$_template->caching = $_caching;"; + // was there an assign attribute + if (isset($_assign)) { + $_output .= "\$_smarty_tpl->assign($_assign,\$_template->fetch()); ?>"; + } else { + if ($has_compiled_template) { + $_output .= " \$_tpl_stack[] = \$_smarty_tpl; \$_smarty_tpl = \$_template;?>\n"; + $_output .= $compiled_tpl . "getTemplateFilepath() . "\" */ ?>"; + $_output .= ""; + } else { + $_output .= " echo \$_template->fetch(); ?>"; + } + } + if ($_parent_scope != SMARTY_LOCAL_SCOPE) { + $_output .= "updateParentVariables($_parent_scope); ?>"; + } + $_output .= ""; + return $_output; + } +} + +?> diff --git a/libs/sysplugins/smarty_internal_compile_section.php b/libs/sysplugins/smarty_internal_compile_section.php index 427af50b..f568cc74 100644 --- a/libs/sysplugins/smarty_internal_compile_section.php +++ b/libs/sysplugins/smarty_internal_compile_section.php @@ -1,170 +1,170 @@ -compiler = $compiler; - $this->required_attributes = array('name', 'loop'); - $this->optional_attributes = array('start', 'step', 'max', 'show'); - // check and get attributes - $_attr = $this->_get_attributes($args); - - $this->_open_tag('section', array('section',$this->compiler->nocache)); - // maybe nocache because of nocache variables - $this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache; - - $output = "tpl_vars['smarty']->value['section'][$section_name]);\n"; - $section_props = "\$_smarty_tpl->tpl_vars['smarty']->value['section'][$section_name]"; - - foreach ($_attr as $attr_name => $attr_value) { - switch ($attr_name) { - case 'loop': - $output .= "{$section_props}['loop'] = is_array(\$_loop=$attr_value) ? count(\$_loop) : max(0, (int)\$_loop); unset(\$_loop);\n"; - break; - - case 'show': - if (is_bool($attr_value)) - $show_attr_value = $attr_value ? 'true' : 'false'; - else - $show_attr_value = "(bool)$attr_value"; - $output .= "{$section_props}['show'] = $show_attr_value;\n"; - break; - - case 'name': - $output .= "{$section_props}['$attr_name'] = $attr_value;\n"; - break; - - case 'max': - case 'start': - $output .= "{$section_props}['$attr_name'] = (int)$attr_value;\n"; - break; - - case 'step': - $output .= "{$section_props}['$attr_name'] = ((int)$attr_value) == 0 ? 1 : (int)$attr_value;\n"; - break; - } - } - - if (!isset($_attr['show'])) - $output .= "{$section_props}['show'] = true;\n"; - - if (!isset($_attr['loop'])) - $output .= "{$section_props}['loop'] = 1;\n"; - - if (!isset($_attr['max'])) - $output .= "{$section_props}['max'] = {$section_props}['loop'];\n"; - else - $output .= "if ({$section_props}['max'] < 0)\n" . " {$section_props}['max'] = {$section_props}['loop'];\n"; - - if (!isset($_attr['step'])) - $output .= "{$section_props}['step'] = 1;\n"; - - if (!isset($_attr['start'])) - $output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n"; - else { - $output .= "if ({$section_props}['start'] < 0)\n" . " {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" . "else\n" . " {$section_props}['start'] = min({$section_props}['start'], {$section_props}['step'] > 0 ? {$section_props}['loop'] : {$section_props}['loop']-1);\n"; - } - - $output .= "if ({$section_props}['show']) {\n"; - if (!isset($_attr['start']) && !isset($_attr['step']) && !isset($_attr['max'])) { - $output .= " {$section_props}['total'] = {$section_props}['loop'];\n"; - } else { - $output .= " {$section_props}['total'] = min(ceil(({$section_props}['step'] > 0 ? {$section_props}['loop'] - {$section_props}['start'] : {$section_props}['start']+1)/abs({$section_props}['step'])), {$section_props}['max']);\n"; - } - $output .= " if ({$section_props}['total'] == 0)\n" . " {$section_props}['show'] = false;\n" . "} else\n" . " {$section_props}['total'] = 0;\n"; - - $output .= "if ({$section_props}['show']):\n"; - $output .= " - for ({$section_props}['index'] = {$section_props}['start'], {$section_props}['iteration'] = 1; - {$section_props}['iteration'] <= {$section_props}['total']; - {$section_props}['index'] += {$section_props}['step'], {$section_props}['iteration']++):\n"; - $output .= "{$section_props}['rownum'] = {$section_props}['iteration'];\n"; - $output .= "{$section_props}['index_prev'] = {$section_props}['index'] - {$section_props}['step'];\n"; - $output .= "{$section_props}['index_next'] = {$section_props}['index'] + {$section_props}['step'];\n"; - $output .= "{$section_props}['first'] = ({$section_props}['iteration'] == 1);\n"; - $output .= "{$section_props}['last'] = ({$section_props}['iteration'] == {$section_props}['total']);\n"; - - $output .= "?>"; - return $output; - } -} - -/** -* Smarty Internal Plugin Compile Sectionelse Class -*/ -class Smarty_Internal_Compile_Sectionelse extends Smarty_Internal_CompileBase { - /** - * Compiles code for the {sectionelse} tag - * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @return string compiled code - */ - public function compile($args, $compiler) - { - $this->compiler = $compiler; - // check and get attributes - $_attr = $this->_get_attributes($args); - - list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('section')); - $this->_open_tag('sectionelse',array('sectionelse', $this->compiler->nocache)); - - return ""; - } -} - -/** -* Smarty Internal Plugin Compile Sectionclose Class -*/ -class Smarty_Internal_Compile_Sectionclose extends Smarty_Internal_CompileBase { - /** - * Compiles code for the {/section} tag - * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @return string compiled code - */ - public function compile($args, $compiler) - { - $this->compiler = $compiler; - // check and get attributes - $_attr = $this->_get_attributes($args); - - // must endblock be nocache? - if ($this->compiler->nocache) { - $this->compiler->tag_nocache = true; - } - - list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('section', 'sectionelse')); - - if ($_open_tag == 'sectionelse') - return ""; - else - return ""; - } -} - - -?> +compiler = $compiler; + $this->required_attributes = array('name', 'loop'); + $this->optional_attributes = array('start', 'step', 'max', 'show'); + // check and get attributes + $_attr = $this->_get_attributes($args); + + $this->_open_tag('section', array('section',$this->compiler->nocache)); + // maybe nocache because of nocache variables + $this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache; + + $output = "tpl_vars['smarty']->value['section'][$section_name]);\n"; + $section_props = "\$_smarty_tpl->tpl_vars['smarty']->value['section'][$section_name]"; + + foreach ($_attr as $attr_name => $attr_value) { + switch ($attr_name) { + case 'loop': + $output .= "{$section_props}['loop'] = is_array(\$_loop=$attr_value) ? count(\$_loop) : max(0, (int)\$_loop); unset(\$_loop);\n"; + break; + + case 'show': + if (is_bool($attr_value)) + $show_attr_value = $attr_value ? 'true' : 'false'; + else + $show_attr_value = "(bool)$attr_value"; + $output .= "{$section_props}['show'] = $show_attr_value;\n"; + break; + + case 'name': + $output .= "{$section_props}['$attr_name'] = $attr_value;\n"; + break; + + case 'max': + case 'start': + $output .= "{$section_props}['$attr_name'] = (int)$attr_value;\n"; + break; + + case 'step': + $output .= "{$section_props}['$attr_name'] = ((int)$attr_value) == 0 ? 1 : (int)$attr_value;\n"; + break; + } + } + + if (!isset($_attr['show'])) + $output .= "{$section_props}['show'] = true;\n"; + + if (!isset($_attr['loop'])) + $output .= "{$section_props}['loop'] = 1;\n"; + + if (!isset($_attr['max'])) + $output .= "{$section_props}['max'] = {$section_props}['loop'];\n"; + else + $output .= "if ({$section_props}['max'] < 0)\n" . " {$section_props}['max'] = {$section_props}['loop'];\n"; + + if (!isset($_attr['step'])) + $output .= "{$section_props}['step'] = 1;\n"; + + if (!isset($_attr['start'])) + $output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n"; + else { + $output .= "if ({$section_props}['start'] < 0)\n" . " {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" . "else\n" . " {$section_props}['start'] = min({$section_props}['start'], {$section_props}['step'] > 0 ? {$section_props}['loop'] : {$section_props}['loop']-1);\n"; + } + + $output .= "if ({$section_props}['show']) {\n"; + if (!isset($_attr['start']) && !isset($_attr['step']) && !isset($_attr['max'])) { + $output .= " {$section_props}['total'] = {$section_props}['loop'];\n"; + } else { + $output .= " {$section_props}['total'] = min(ceil(({$section_props}['step'] > 0 ? {$section_props}['loop'] - {$section_props}['start'] : {$section_props}['start']+1)/abs({$section_props}['step'])), {$section_props}['max']);\n"; + } + $output .= " if ({$section_props}['total'] == 0)\n" . " {$section_props}['show'] = false;\n" . "} else\n" . " {$section_props}['total'] = 0;\n"; + + $output .= "if ({$section_props}['show']):\n"; + $output .= " + for ({$section_props}['index'] = {$section_props}['start'], {$section_props}['iteration'] = 1; + {$section_props}['iteration'] <= {$section_props}['total']; + {$section_props}['index'] += {$section_props}['step'], {$section_props}['iteration']++):\n"; + $output .= "{$section_props}['rownum'] = {$section_props}['iteration'];\n"; + $output .= "{$section_props}['index_prev'] = {$section_props}['index'] - {$section_props}['step'];\n"; + $output .= "{$section_props}['index_next'] = {$section_props}['index'] + {$section_props}['step'];\n"; + $output .= "{$section_props}['first'] = ({$section_props}['iteration'] == 1);\n"; + $output .= "{$section_props}['last'] = ({$section_props}['iteration'] == {$section_props}['total']);\n"; + + $output .= "?>"; + return $output; + } +} + +/** +* Smarty Internal Plugin Compile Sectionelse Class +*/ +class Smarty_Internal_Compile_Sectionelse extends Smarty_Internal_CompileBase { + /** + * Compiles code for the {sectionelse} tag + * + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @return string compiled code + */ + public function compile($args, $compiler) + { + $this->compiler = $compiler; + // check and get attributes + $_attr = $this->_get_attributes($args); + + list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('section')); + $this->_open_tag('sectionelse',array('sectionelse', $this->compiler->nocache)); + + return ""; + } +} + +/** +* Smarty Internal Plugin Compile Sectionclose Class +*/ +class Smarty_Internal_Compile_Sectionclose extends Smarty_Internal_CompileBase { + /** + * Compiles code for the {/section} tag + * + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @return string compiled code + */ + public function compile($args, $compiler) + { + $this->compiler = $compiler; + // check and get attributes + $_attr = $this->_get_attributes($args); + + // must endblock be nocache? + if ($this->compiler->nocache) { + $this->compiler->tag_nocache = true; + } + + list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('section', 'sectionelse')); + + if ($_open_tag == 'sectionelse') + return ""; + else + return ""; + } +} + + +?> diff --git a/libs/sysplugins/smarty_internal_compile_special_smarty_variable.php b/libs/sysplugins/smarty_internal_compile_special_smarty_variable.php index aec37c8e..3b053230 100644 --- a/libs/sysplugins/smarty_internal_compile_special_smarty_variable.php +++ b/libs/sysplugins/smarty_internal_compile_special_smarty_variable.php @@ -1,106 +1,106 @@ -getVariable('smarty')->value$args"; - case 'section': - return "\$_smarty_tpl->getVariable('smarty')->value$args"; - case 'capture': - return "\$_smarty_tpl->smarty->_smarty_vars$args"; - case 'now': - return 'time()'; - - case 'get': - $compiled_ref = "\$_GET"; - break; - - case 'post': - $compiled_ref = "\$_POST"; - break; - - case 'cookies': - $compiled_ref = "\$_COOKIE"; - break; - - case 'env': - $compiled_ref = "\$_ENV"; - break; - - case 'server': - $compiled_ref = "\$_SERVER"; - break; - - case 'session': - $compiled_ref = "\$_SESSION"; - break; - - case 'request': - $compiled_ref = "\$_REQUEST"; - break; - - case 'template': - $_template_name = basename($compiler->template->getTemplateFilepath()); - return "'$_template_name'"; - - case 'current_dir': - $_template_dir_name = dirname($compiler->template->getTemplateFilepath()); - return "'$_template_dir_name'"; - - case 'version': - $_version = Smarty::$_version; - return "'$_version'"; - - case 'const': - if ($compiler->smarty->security && !$compiler->smarty->security_policy->allow_constants) { - $compiler->trigger_template_error("(secure mode) constants not permitted"); - break; - } - return '@' . trim($_index[1], "'"); - - case 'config': - return "\$_smarty_tpl->getConfigVariable($_index[1])"; - case 'ldelim': - $_ldelim = $compiler->smarty->left_delimiter; - return "'$_ldelim'"; - - case 'rdelim': - $_rdelim = $compiler->smarty->right_delimiter; - return "'$_rdelim'"; - - default: - $compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is an unknown reference'); - break; - } - if (isset($_index[1])) { - array_shift($_index); - foreach ($_index as $_ind) { - $compiled_ref = $compiled_ref . "[$_ind]"; - } - } - return $compiled_ref; - } -} -?> +getVariable('smarty')->value$args"; + case 'section': + return "\$_smarty_tpl->getVariable('smarty')->value$args"; + case 'capture': + return "\$_smarty_tpl->smarty->_smarty_vars$args"; + case 'now': + return 'time()'; + + case 'get': + $compiled_ref = "\$_GET"; + break; + + case 'post': + $compiled_ref = "\$_POST"; + break; + + case 'cookies': + $compiled_ref = "\$_COOKIE"; + break; + + case 'env': + $compiled_ref = "\$_ENV"; + break; + + case 'server': + $compiled_ref = "\$_SERVER"; + break; + + case 'session': + $compiled_ref = "\$_SESSION"; + break; + + case 'request': + $compiled_ref = "\$_REQUEST"; + break; + + case 'template': + $_template_name = basename($compiler->template->getTemplateFilepath()); + return "'$_template_name'"; + + case 'current_dir': + $_template_dir_name = dirname($compiler->template->getTemplateFilepath()); + return "'$_template_dir_name'"; + + case 'version': + $_version = Smarty::$_version; + return "'$_version'"; + + case 'const': + if ($compiler->smarty->security && !$compiler->smarty->security_policy->allow_constants) { + $compiler->trigger_template_error("(secure mode) constants not permitted"); + break; + } + return '@' . trim($_index[1], "'"); + + case 'config': + return "\$_smarty_tpl->getConfigVariable($_index[1])"; + case 'ldelim': + $_ldelim = $compiler->smarty->left_delimiter; + return "'$_ldelim'"; + + case 'rdelim': + $_rdelim = $compiler->smarty->right_delimiter; + return "'$_rdelim'"; + + default: + $compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is an unknown reference'); + break; + } + if (isset($_index[1])) { + array_shift($_index); + foreach ($_index as $_ind) { + $compiled_ref = $compiled_ref . "[$_ind]"; + } + } + return $compiled_ref; + } +} +?> diff --git a/libs/sysplugins/smarty_internal_compile_strip.php b/libs/sysplugins/smarty_internal_compile_strip.php index 9bcc552d..a6b2a6fe 100644 --- a/libs/sysplugins/smarty_internal_compile_strip.php +++ b/libs/sysplugins/smarty_internal_compile_strip.php @@ -1,59 +1,59 @@ -compiler = $compiler; - // check and get attributes - $_attr = $this->_get_attributes($args); - - $this->_open_tag('strip'); - - $_output = ""; - - return $_output; - } -} - -/** -* Smarty Internal Plugin Compile Stripclose Class -*/ -class Smarty_Internal_Compile_Stripclose extends Smarty_Internal_CompileBase { - /** - * Compiles code for the {/strip} tag - * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @return string compiled code - */ - public function compile($args, $compiler) - { - $this->compiler = $compiler; - // check and get attributes - $_attr = $this->_get_attributes($args); - - $saved_attr = $this->_close_tag(array('strip')); - - $_output = "\n"; - return $_output; - } -} -?> +compiler = $compiler; + // check and get attributes + $_attr = $this->_get_attributes($args); + + $this->_open_tag('strip'); + + $_output = ""; + + return $_output; + } +} + +/** +* Smarty Internal Plugin Compile Stripclose Class +*/ +class Smarty_Internal_Compile_Stripclose extends Smarty_Internal_CompileBase { + /** + * Compiles code for the {/strip} tag + * + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @return string compiled code + */ + public function compile($args, $compiler) + { + $this->compiler = $compiler; + // check and get attributes + $_attr = $this->_get_attributes($args); + + $saved_attr = $this->_close_tag(array('strip')); + + $_output = "\n"; + return $_output; + } +} +?> diff --git a/libs/sysplugins/smarty_internal_compile_while.php b/libs/sysplugins/smarty_internal_compile_while.php index 5c83e366..6dc18046 100644 --- a/libs/sysplugins/smarty_internal_compile_while.php +++ b/libs/sysplugins/smarty_internal_compile_while.php @@ -1,66 +1,66 @@ -compiler = $compiler; - $this->required_attributes = array('if condition'); - // check and get attributes - $_attr = $this->_get_attributes($args); - $this->_open_tag('while', $this->compiler->nocache); - - // maybe nocache because of nocache variables - $this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache; - - - if (is_array($args['if condition'])) { - $_output = " tpl_vars[".$args['if condition']['var']."])) \$_smarty_tpl->tpl_vars[".$args['if condition']['var']."] = new Smarty_Variable;\n"; - $_output .= " while (\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."]->value = ".$args['if condition']['value'].") {\n ?>"; - return $_output; - } else { - return ''; - } - } -} - -/** -* Smarty Internal Plugin Compile Whileclose Class -*/ -class Smarty_Internal_Compile_Whileclose extends Smarty_Internal_CompileBase { - /** - * Compiles code for the {/while} tag - * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @return string compiled code - */ - public function compile($args, $compiler) - { - $this->compiler = $compiler; - // must endblock be nocache? - if ($this->compiler->nocache) { - $this->compiler->tag_nocache = true; - } - $this->compiler->nocache = $this->_close_tag(array('while')); - return ""; - } -} -?> +compiler = $compiler; + $this->required_attributes = array('if condition'); + // check and get attributes + $_attr = $this->_get_attributes($args); + $this->_open_tag('while', $this->compiler->nocache); + + // maybe nocache because of nocache variables + $this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache; + + + if (is_array($args['if condition'])) { + $_output = " tpl_vars[".$args['if condition']['var']."])) \$_smarty_tpl->tpl_vars[".$args['if condition']['var']."] = new Smarty_Variable;\n"; + $_output .= " while (\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."]->value = ".$args['if condition']['value'].") {\n ?>"; + return $_output; + } else { + return ''; + } + } +} + +/** +* Smarty Internal Plugin Compile Whileclose Class +*/ +class Smarty_Internal_Compile_Whileclose extends Smarty_Internal_CompileBase { + /** + * Compiles code for the {/while} tag + * + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @return string compiled code + */ + public function compile($args, $compiler) + { + $this->compiler = $compiler; + // must endblock be nocache? + if ($this->compiler->nocache) { + $this->compiler->tag_nocache = true; + } + $this->compiler->nocache = $this->_close_tag(array('while')); + return ""; + } +} +?> diff --git a/libs/sysplugins/smarty_security.php b/libs/sysplugins/smarty_security.php index adb368f0..5464c0db 100644 --- a/libs/sysplugins/smarty_security.php +++ b/libs/sysplugins/smarty_security.php @@ -1,84 +1,84 @@ -" tags in templates. - * possible values: - *
    - *
  • SMARTY_PHP_PASSTHRU -> echo PHP tags as they are
  • - *
  • SMARTY_PHP_QUOTE -> escape tags as entities
  • - *
  • SMARTY_PHP_REMOVE -> remove php tags
  • - *
  • SMARTY_PHP_ALLOW -> execute php tags
  • - *
- * - * @var integer - */ - public $php_handling = SMARTY_PHP_PASSTHRU; - - /** - * This is the list of template directories that are considered secure. - * One directory per array element. - * $template_dir is in this list implicitly. - * - * @var array - */ - public $secure_dir = array(); - - - /** - * This is an array of directories where trusted php scripts reside. - * {@link $security} is disabled during their inclusion/execution. - * - * @var array - */ - public $trusted_dir = array(); - - - /** - * This is an array of trusted PHP functions. - * - * If empty all functions are allowed. - * If set to 'none' none is allowed. - * @var array - */ - public $php_functions = array('isset', 'empty', - 'count', 'sizeof','in_array', 'is_array','time','nl2br'); - - /** - * This is an array of trusted modifers. - * - * If empty all modifiers are allowed. - * If set to 'none' none is allowed. - * @var array - */ - public $modifiers = array('escape','count'); - - /** - * This is an array of trusted streams. - * - * If empty all streams are allowed. - * If set to 'none' none is allowed. - * @var array - */ - public $streams = array('file'); - /** - + flag if constants can be accessed from template - */ - public $allow_constants = true; - /** - + flag if {php} tag can be executed - */ - public $allow_php_tag = false; -} - -?> +" tags in templates. + * possible values: + *
    + *
  • SMARTY_PHP_PASSTHRU -> echo PHP tags as they are
  • + *
  • SMARTY_PHP_QUOTE -> escape tags as entities
  • + *
  • SMARTY_PHP_REMOVE -> remove php tags
  • + *
  • SMARTY_PHP_ALLOW -> execute php tags
  • + *
+ * + * @var integer + */ + public $php_handling = SMARTY_PHP_PASSTHRU; + + /** + * This is the list of template directories that are considered secure. + * One directory per array element. + * $template_dir is in this list implicitly. + * + * @var array + */ + public $secure_dir = array(); + + + /** + * This is an array of directories where trusted php scripts reside. + * {@link $security} is disabled during their inclusion/execution. + * + * @var array + */ + public $trusted_dir = array(); + + + /** + * This is an array of trusted PHP functions. + * + * If empty all functions are allowed. + * If set to 'none' none is allowed. + * @var array + */ + public $php_functions = array('isset', 'empty', + 'count', 'sizeof','in_array', 'is_array','time','nl2br'); + + /** + * This is an array of trusted modifers. + * + * If empty all modifiers are allowed. + * If set to 'none' none is allowed. + * @var array + */ + public $modifiers = array('escape','count'); + + /** + * This is an array of trusted streams. + * + * If empty all streams are allowed. + * If set to 'none' none is allowed. + * @var array + */ + public $streams = array('file'); + /** + + flag if constants can be accessed from template + */ + public $allow_constants = true; + /** + + flag if {php} tag can be executed + */ + public $allow_php_tag = false; +} + +?>