aboutsummaryrefslogtreecommitdiffstats
path: root/library/Smarty
diff options
context:
space:
mode:
Diffstat (limited to 'library/Smarty')
-rw-r--r--library/Smarty/INHERITANCE_RELEASE_NOTES.txt35
-rw-r--r--library/Smarty/NEW_FEATURES.txt86
-rw-r--r--library/Smarty/README.md52
-rw-r--r--library/Smarty/SMARTY_2_BC_NOTES.txt109
-rw-r--r--library/Smarty/SMARTY_3.0_BC_NOTES.txt24
-rw-r--r--library/Smarty/SMARTY_3.1_NOTES.txt306
-rw-r--r--library/Smarty/demo/configs/test.conf5
-rw-r--r--library/Smarty/demo/index.php30
-rw-r--r--library/Smarty/demo/plugins/cacheresource.apc.php83
-rw-r--r--library/Smarty/demo/plugins/cacheresource.memcache.php97
-rw-r--r--library/Smarty/demo/plugins/cacheresource.mysql.php162
-rw-r--r--library/Smarty/demo/plugins/cacheresource.pdo.php322
-rw-r--r--library/Smarty/demo/plugins/cacheresource.pdo_gzip.php43
-rw-r--r--library/Smarty/demo/plugins/resource.extendsall.php60
-rw-r--r--library/Smarty/demo/plugins/resource.mysql.php81
-rw-r--r--library/Smarty/demo/plugins/resource.mysqls.php62
-rw-r--r--library/Smarty/demo/templates/footer.tpl2
-rw-r--r--library/Smarty/demo/templates/header.tpl5
-rw-r--r--library/Smarty/demo/templates/index.tpl87
-rw-r--r--library/Smarty/lexer/smarty_internal_configfilelexer.plex318
-rw-r--r--library/Smarty/lexer/smarty_internal_configfileparser.y362
-rw-r--r--library/Smarty/lexer/smarty_internal_templatelexer.plex770
-rw-r--r--library/Smarty/lexer/smarty_internal_templateparser.y1329
23 files changed, 0 insertions, 4430 deletions
diff --git a/library/Smarty/INHERITANCE_RELEASE_NOTES.txt b/library/Smarty/INHERITANCE_RELEASE_NOTES.txt
deleted file mode 100644
index a7d285f0a..000000000
--- a/library/Smarty/INHERITANCE_RELEASE_NOTES.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-In Smarty 3.1 template inheritance is a compile time process. All the extending of {block} tags
-is done at compile time and the parent and child templates are compiled in a single compiled template.
-{include} subtemplate could also {block} tags. Such subtemplate could not compiled by it's own because
-it could be used in other context where the {block} extended with a different result. For that reasion
-the compiled code of {include} subtemplates gets also merged in compiled inheritance template.
-
-Merging the code into a single compile template has some drawbacks.
-1. You could not use variable file names in {include} Smarty would use the {include} of compilation time.
-2. You could not use individual compile_id in {include}
-3. Seperate caching of subtemplate was not possible
-4. Any change of the template directory structure between calls was not necessarily seen.
-
-Starting with 3.1.15 some of the above conditions got checked and resulted in an exception. It turned out
-that a couple of users did use some of above and now got exceptions.
-
-To resolve this starting with 3.1.16 there is a new configuration parameter $inheritance_merge_compiled_includes.
-For most backward compatibility its default setting is true.
-With this setting all {include} subtemplate will be merge into the compiled inheritance template, but the above cases
-could be rejected by exception.
-
-
-If $smarty->inheritance_merge_compiled_includes = false; {include} subtemplate will not be merged.
-You must now manually merge all {include} subtemplate which do contain {block} tags. This is done by setting the "inline" option.
-{include file='foo.bar' inline}
-
-1. In case of a variable file name like {include file=$foo inline} you must use the variable in a compile_id $smarty->compile_id = $foo;
-2. If you use individual compile_id in {include file='foo.tpl' compile_id=$bar inline} it must be used in the
- global compile_id as well $smarty->compile_id = $bar;
-3. If call templates with different template_dir configurations and a parent could same named child template from different folders
- you must make the folder name part of the compile_id.
-
-
-In the upcomming major release Smarty 3.2 inheritance will no longer be a compile time process.
-All restrictions will be then removed.
-
diff --git a/library/Smarty/NEW_FEATURES.txt b/library/Smarty/NEW_FEATURES.txt
deleted file mode 100644
index b2c18c99b..000000000
--- a/library/Smarty/NEW_FEATURES.txt
+++ /dev/null
@@ -1,86 +0,0 @@
-
-
-This file contains a brief description of new features which have been added to Smarty 3.1
-
-Smarty 3.1.22
-
- Namespace support within templates
- ==================================
- Within templates you can now use namespace specifications on:
- - Constants like foo\bar\FOO
- - Class names like foo\bar\Baz::FOO, foo\bar\Baz::$foo, foo\bar\Baz::foo()
- - PHP function names like foo\bar\baz()
-
- Security
- ========
- - disable special $smarty variable -
- The Smarty_Security class has the new property $disabled_special_smarty_vars.
- It's an array which can be loaded with the $smarty special variable names like
- 'template_object', 'template', 'current_dir' and others which will be disabled.
- Note: That this security check is performed at compile time.
-
- - limit template nesting -
- Property $max_template_nesting of Smarty_Security does set the maximum template nesting level.
- The main template is level 1. The nesting level is checked at run time. When the maximum will be exceeded
- an Exception will be thrown. The default setting is 0 which does disable this check.
-
- - trusted static methods -
- The Smarty_Security class has the new property $trusted_static_methods to restrict access to static methods.
- It's an nested array of trusted class and method names.
- Format:
- array (
- 'class_1' => array('method_1', 'method_2'), // allowed methods
- 'class_2' => array(), // all methods of class allowed
- )
- To disable access for all methods of all classes set $trusted_static_methods = null;
- The default value is an empty array() which does enables all methods of all classes, but for backward compatibility
- the setting of $static_classes will be checked.
- Note: That this security check is performed at compile time.
-
- - trusted static properties -
- The Smarty_Security class has the new property $trusted_static_properties to restrict access to static properties.
- It's an nested array of trusted class and property names.
- Format:
- array (
- 'class_1' => array('prop_1', 'prop_2'), // allowed properties listed
- 'class_2' => array(), // all properties of class allowed
- }
- To disable access for all properties of all classes set $trusted_static_properties = null;
- The default value is an empty array() which does enables all properties of all classes, but for backward compatibility
- the setting of $static_classes will be checked.
- Note: That this security check is performed at compile time.
-
- - trusted constants .
- The Smarty_Security class has the new property $trusted_constants to restrict access to constants.
- It's an array of trusted constant names.
- Format:
- array (
- 'SMARTY_DIR' , // allowed constant
- }
- If the array is empty (default) the usage of constants can be controlled with the
- Smarty_Security::$allow_constants property (default true)
-
-
-
- Compiled Templates
- ==================
- Smarty does now automatically detects a change of the $merge_compiled_includes and $escape_html
- property and creates different compiled templates files depending on the setting.
-
- Same applies to config files and the $config_overwrite, $config_booleanize and
- $config_read_hidden properties.
-
- Debugging
- =========
- The layout of the debug window has been changed for better readability
-
- New class constants
- Smarty::DEBUG_OFF
- Smarty::DEBUG_ON
- Smarty::DEBUG_INDIVIDUAL
- have been introduced for setting the $debugging property.
-
- Smarty::DEBUG_INDIVIDUAL will create for each display() and fetch() call an individual gebug window.
-
- .
- \ No newline at end of file
diff --git a/library/Smarty/README.md b/library/Smarty/README.md
deleted file mode 100644
index f5f93fa95..000000000
--- a/library/Smarty/README.md
+++ /dev/null
@@ -1,52 +0,0 @@
-#Smarty 3 template engine
-##Distribution repository
-
-*Read the NEW_FEATURES file for recent extensions to Smarty 3.1 functionality*
-
-Smarty versions 3.1.11 or later are now on github and can be installed with Composer.
-
-
-The "smarty/smarty" package will start at libs/.... subfolder.
-
-To get the latest stable version of Smarty 3.1 use
-
- "require": {
- "smarty/smarty": "~3.1"
- }
-
-in your composer.json file.
-
- To get the trunk version use
-
- "require": {
- "smarty/smarty": "~3.1@dev"
- }
-
-For a specific version use something like
-
- "require": {
- "smarty/smarty": "3.1.19"
- }
-
-PHPUnit test can be installed by corresponding composer entries like
-
- "require": {
- "smarty/smarty-phpunit": "3.1.19"
- }
-
-Similar applies for the lexer/parser generator
-
- "require": {
- "smarty/smarty-lexer": "3.1.19"
- }
-
-Or you could use
-
- "require": {
- "smarty/smarty-dev": "3.1.19"
- }
-
-Which is a wrapper to install all 3 packages
-
-
-Composer can also be used for Smarty2 versions 2.6.24 to 2.6.28
diff --git a/library/Smarty/SMARTY_2_BC_NOTES.txt b/library/Smarty/SMARTY_2_BC_NOTES.txt
deleted file mode 100644
index 79a2cb1b6..000000000
--- a/library/Smarty/SMARTY_2_BC_NOTES.txt
+++ /dev/null
@@ -1,109 +0,0 @@
-= Known incompatibilities with Smarty 2 =
-
-== Syntax ==
-
-Smarty 3 API has a new syntax. Much of the Smarty 2 syntax is supported
-by a wrapper but deprecated. See the README that comes with Smarty 3 for more
-information.
-
-The {$array|@mod} syntax has always been a bit confusing, where an "@" is required
-to apply a modifier to an array instead of the individual elements. Normally you
-always want the modifier to apply to the variable regardless of its type. In Smarty 3,
-{$array|mod} and {$array|@mod} behave identical. It is safe to drop the "@" and the
-modifier will still apply to the array. If you really want the modifier to apply to
-each array element, you must loop the array in-template, or use a custom modifier that
-supports array iteration. Most smarty functions already escape values where necessary
-such as {html_options}
-
-== PHP Version ==
-Smarty 3 is PHP 5 only. It will not work with PHP 4.
-
-== {php} Tag ==
-The {php} tag is disabled by default. The use of {php} tags is
-deprecated. It can be enabled with $smarty->allow_php_tag=true.
-
-But if you scatter PHP code which belongs together into several
-{php} tags it may not work any longer.
-
-== Delimiters and whitespace ==
-Delimiters surrounded by whitespace are no longer treated as Smarty tags.
-Therefore, { foo } will not compile as a tag, you must use {foo}. This change
-Makes Javascript/CSS easier to work with, eliminating the need for {literal}.
-This can be disabled by setting $smarty->auto_literal = false;
-
-== Unquoted Strings ==
-Smarty 2 was a bit more forgiving (and ambiguous) when it comes to unquoted strings
-in parameters. Smarty3 is more restrictive. You can still pass strings without quotes
-so long as they contain no special characters. (anything outside of A-Za-z0-9_)
-
-For example filename strings must be quoted
-<source lang="smarty">
-{include file='path/foo.tpl'}
-</source>
-
-== Extending the Smarty class ==
-Smarty 3 makes use of the __construct method for initialization. If you are extending
-the Smarty class, its constructor is not called implicitly if the your child class defines
-its own constructor. In order to run Smarty's constructor, a call to parent::__construct()
-within your child constructor is required.
-
-<source lang="php">
-class MySmarty extends Smarty {
- function __construct() {
- parent::__construct();
-
- // your initialization code goes here
-
- }
-}
-</source>
-
-== Autoloader ==
-Smarty 3 does register its own autoloader with spl_autoload_register. If your code has
-an existing __autoload function then this function must be explicitly registered on
-the __autoload stack. See http://us3.php.net/manual/en/function.spl-autoload-register.php
-for further details.
-
-== Plugin Filenames ==
-Smarty 3 optionally supports the PHP spl_autoloader. The autoloader requires filenames
-to be lower case. Because of this, Smarty plugin file names must also be lowercase.
-In Smarty 2, mixed case file names did work.
-
-== Scope of Special Smarty Variables ==
-In Smarty 2 the special Smarty variables $smarty.section... and $smarty.foreach...
-had global scope. If you had loops with the same name in subtemplates you could accidentally
-overwrite values of parent template.
-
-In Smarty 3 these special Smarty variable have only local scope in the template which
-is defining the loop. If you need their value in a subtemplate you have to pass them
-as parameter.
-<source lang="smarty">
-{include file='path/foo.tpl' index=$smarty.section.foo.index}
-</source>
-
-== SMARTY_RESOURCE_CHAR_SET ==
-Smarty 3 sets the constant SMARTY_RESOURCE_CHAR_SET to utf-8 as default template charset.
-This is now used also on modifiers like escape as default charset. If your templates use
-other charsets make sure that you define the constant accordingly. Otherwise you may not
-get any output.
-
-== newline at {if} tags ==
-A \n was added to the compiled code of the {if},{else},{elseif},{/if} tags to get output of newlines as expected by the template source.
-If one of the {if} tags is at the line end you will now get a newline in the HTML output.
-
-== trigger_error() ==
-The API function trigger_error() has been removed because it did just map to PHP trigger_error.
-However it's still included in the Smarty2 API wrapper.
-
-== Smarty constants ==
-The constants
-SMARTY_PHP_PASSTHRU
-SMARTY_PHP_QUOTE
-SMARTY_PHP_REMOVE
-SMARTY_PHP_ALLOW
-have been replaced with class constants
-Smarty::PHP_PASSTHRU
-Smarty::PHP_QUOTE
-Smarty::PHP_REMOVE
-Smarty::PHP_ALLOW
-
diff --git a/library/Smarty/SMARTY_3.0_BC_NOTES.txt b/library/Smarty/SMARTY_3.0_BC_NOTES.txt
deleted file mode 100644
index fd8b540c2..000000000
--- a/library/Smarty/SMARTY_3.0_BC_NOTES.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-== Smarty2 backward compatibility ==
-All Smarty2 specific API functions and deprecated functionallity has been moved
-to the SmartyBC class.
-
-== {php} Tag ==
-The {php} tag is no longer available in the standard Smarty calls.
-The use of {php} tags is deprecated and only available in the SmartyBC class.
-
-== {include_php} Tag ==
-The {include_php} tag is no longer available in the standard Smarty calls.
-The use of {include_php} tags is deprecated and only available in the SmartyBC class.
-
-== php template resource ==
-The support of the php template resource is removed.
-
-== $cache_dir, $compile_dir, $config_dir, $template_dir access ==
-The mentioned properties can't be accessed directly any longer. You must use
-corresponding getter/setters like addConfigDir(), setConfigDir(), getConfigDir()
-
-== obsolete Smarty class properties ==
-The following no longer used properties are removed:
-$allow_php_tag
-$allow_php_template
-$deprecation_notices \ No newline at end of file
diff --git a/library/Smarty/SMARTY_3.1_NOTES.txt b/library/Smarty/SMARTY_3.1_NOTES.txt
deleted file mode 100644
index 57709f0d7..000000000
--- a/library/Smarty/SMARTY_3.1_NOTES.txt
+++ /dev/null
@@ -1,306 +0,0 @@
-Smarty 3.1 Notes
-================
-
-Smarty 3.1 is a departure from 2.0 compatibility. Most notably, all
-backward compatibility has been moved to a separate class file named
-SmartyBC.class.php. If you require compatibility with 2.0, you will
-need to use this class.
-
-Some differences from 3.0 are also present. 3.1 begins the journey of
-requiring setters/getters for property access. So far this is only
-implemented on the five directory properties: template_dir,
-plugins_dir, configs_dir, compile_dir and cache_dir. These properties
-are now protected, it is required to use the setters/getters instead.
-That said, direct property access will still work, however slightly
-slower since they will now fall through __set() and __get() and in
-turn passed through the setter/getter methods. 3.2 will exhibit a full
-list of setter/getter methods for all (currently) public properties,
-so code-completion in your IDE will work as expected.
-
-There is absolutely no PHP allowed in templates any more. All
-deprecated features of Smarty 2.0 are gone. Again, use the SmartyBC
-class if you need any backward compatibility.
-
-Internal Changes
-
- Full UTF-8 Compatibility
-
-The plugins shipped with Smarty 3.1 have been rewritten to fully
-support UTF-8 strings if Multibyte String is available. Without
-MBString UTF-8 cannot be handled properly. For those rare cases where
-templates themselves have to juggle encodings, the new modifiers
-to_charset and from_charset may come in handy.
-
- Plugin API and Performance
-
-All Plugins (modifiers, functions, blocks, resources,
-default_template_handlers, etc) are now receiving the
-Smarty_Internal_Template instance, where they were supplied with the
-Smarty instance in Smarty 3.0. *. As The Smarty_Internal_Template
-mimics the behavior of Smarty, this API simplification should not
-require any changes to custom plugins.
-
-The plugins shipped with Smarty 3.1 have been rewritten for better
-performance. Most notably {html_select_date} and {html_select_time}
-have been improved vastly. Performance aside, plugins have also been
-reviewed and generalized in their API. {html_select_date} and
-{html_select_time} now share almost all available options.
-
-The escape modifier now knows the $double_encode option, which will
-prevent entities from being encoded again.
-
-The capitalize modifier now know the $lc_rest option, which makes sure
-all letters following a captial letter are lower-cased.
-
-The count_sentences modifier now accepts (.?!) as
-legitimate endings of a sentence - previously only (.) was
-accepted
-
-The new unescape modifier is there to reverse the effects of the
-escape modifier. This applies to the escape formats html, htmlall and
-entity.
-
- default_template_handler_func
-
-The invocation of $smarty->$default_template_handler_func had to be
-altered. Instead of a Smarty_Internal_Template, the fifth argument is
-now provided with the Smarty instance. New footprint:
-
-
-/**
- * Default Template Handler
- *
- * called when Smarty's file: resource is unable to load a requested file
- *
- * @param string $type resource type (e.g. "file", "string", "eval", "resource")
- * @param string $name resource name (e.g. "foo/bar.tpl")
- * @param string &$content template's content
- * @param integer &$modified template's modification time
- * @param Smarty $smarty Smarty instance
- * @return string|boolean path to file or boolean true if $content and $modified
- * have been filled, boolean false if no default template
- * could be loaded
- */
-function default_template_handler_func($type, $name, &$content, &$modified, Smarty $smarty) {
- if (false) {
- // return corrected filepath
- return "/tmp/some/foobar.tpl";
- } elseif (false) {
- // return a template directly
- $content = "the template source";
- $modified = time();
- return true;
- } else {
- // tell smarty that we failed
- return false;
- }
-}
-
- Stuff done to the compiler
-
-Many performance improvements have happened internally. One notable
-improvement is that all compiled templates are now handled as PHP
-functions. This speeds up repeated templates tremendously, as each one
-calls an (in-memory) PHP function instead of performing another file
-include/scan.
-
-New Features
-
- Template syntax
-
- {block}..{/block}
-
-The {block} tag has a new hide option flag. It does suppress the block
-content if no corresponding child block exists.
-EXAMPLE:
-parent.tpl
-{block name=body hide} child content "{$smarty.block.child}" was
-inserted {block}
-In the above example the whole block will be suppressed if no child
-block "body" is existing.
-
- {setfilter}..{/setfilter}
-
-The new {setfilter} block tag allows the definition of filters which
-run on variable output.
-SYNTAX:
-{setfilter filter1|filter2|filter3....}
-Smarty3 will lookup up matching filters in the following search order:
-1. varibale filter plugin in plugins_dir.
-2. a valid modifier. A modifier specification will also accept
-additional parameter like filter2:'foo'
-3. a PHP function
-{/setfilter} will turn previous filter setting off again.
-{setfilter} tags can be nested.
-EXAMPLE:
-{setfilter filter1}
- {$foo}
- {setfilter filter2}
- {$bar}
- {/setfilter}
- {$buh}
-{/setfilter}
-{$blar}
-In the above example filter1 will run on the output of $foo, filter2
-on $bar, filter1 again on $buh and no filter on $blar.
-NOTES:
-- {$foo nofilter} will suppress the filters
-- These filters will run in addition to filters defined by
-registerFilter('variable',...), autoLoadFilter('variable',...) and
-defined default modifier.
-- {setfilter} will effect only the current template, not included
-subtemplates.
-
- Resource API
-
-Smarty 3.1 features a new approach to resource management. The
-Smarty_Resource API allows simple, yet powerful integration of custom
-resources for templates and configuration files. It offers simple
-functions for loading data from a custom resource (e.g. database) as
-well as define new template types adhering to the special
-non-compiling (e,g, plain php) and non-compile-caching (e.g. eval:
-resource type) resources.
-
-See demo/plugins/resource.mysql.php for an example custom database
-resource.
-
-Note that old-fashioned registration of callbacks for resource
-management has been deprecated but is still possible with SmartyBC.
-
- CacheResource API
-
-In line with the Resource API, the CacheResource API offers a more
-comfortable handling of output-cache data. With the
-Smarty_CacheResource_Custom accessing databases is made simple. With
-the introduction of Smarty_CacheResource_KeyValueStore the
-implementation of resources like memcache or APC became a no-brainer;
-simple hash-based storage systems are now supporting hierarchical
-output-caches.
-
-See demo/plugins/cacheresource.mysql.php for an example custom
-database CacheResource.
-See demo/plugins/cacheresource.memcache.php for an example custom
-memcache CacheResource using the KeyValueStore helper.
-
-Note that old-fashioned registration of $cache_handler is not possible
-anymore. As the functionality had not been ported to Smarty 3.0.x
-properly, it has been dropped from 3.1 completely.
-
-Locking facilities have been implemented to avoid concurrent cache
-generation. Enable cache locking by setting
-$smarty->cache_locking = true;
-
- Relative Paths in Templates (File-Resource)
-
-As of Smarty 3.1 {include file="../foo.tpl"} and {include
-file="./foo.tpl"} will resolve relative to the template they're in.
-Relative paths are available with {include file="..."} and
-{extends file="..."}. As $smarty->fetch('../foo.tpl') and
-$smarty->fetch('./foo.tpl') cannot be relative to a template, an
-exception is thrown.
-
- Addressing a specific $template_dir
-
-Smarty 3.1 introduces the $template_dir index notation.
-$smarty->fetch('[foo]bar.tpl') and {include file="[foo]bar.tpl"}
-require the template bar.tpl to be loaded from $template_dir['foo'];
-Smarty::setTemplateDir() and Smarty::addTemplateDir() offer ways to
-define indexes along with the actual directories.
-
- Mixing Resources in extends-Resource
-
-Taking the php extends: template resource one step further, it is now
-possible to mix resources within an extends: call like
-$smarty->fetch("extends:file:foo.tpl|db:bar.tpl");
-
-To make eval: and string: resources available to the inheritance
-chain, eval:base64:TPL_STRING and eval:urlencode:TPL_STRING have been
-introduced. Supplying the base64 or urlencode flags will trigger
-decoding the TPL_STRING in with either base64_decode() or urldecode().
-
- extends-Resource in template inheritance
-
-Template based inheritance may now inherit from php's extends:
-resource like {extends file="extends:foo.tpl|db:bar.tpl"}.
-
- New Smarty property escape_html
-
-$smarty->escape_html = true will autoescape all template variable
-output by calling htmlspecialchars({$output}, ENT_QUOTES,
-SMARTY_RESOURCE_CHAR_SET).
-NOTE:
-This is a compile time option. If you change the setting you must make
-sure that the templates get recompiled.
-
- New option at Smarty property compile_check
-
-The automatic recompilation of modified templates can now be
-controlled by the following settings:
-$smarty->compile_check = COMPILECHECK_OFF (false) - template files
-will not be checked
-$smarty->compile_check = COMPILECHECK_ON (true) - template files will
-always be checked
-$smarty->compile_check = COMPILECHECK_CACHEMISS - template files will
-be checked if caching is enabled and there is no existing cache file
-or it has expired
-
- Automatic recompilation on Smarty version change
-
-Templates will now be automatically recompiled on Smarty version
-changes to avoide incompatibillities in the compiled code. Compiled
-template checked against the current setting of the SMARTY_VERSION
-constant.
-
- default_config_handler_func()
-
-Analogous to the default_template_handler_func()
-default_config_handler_func() has been introduced.
-
- default_plugin_handler_func()
-
-An optional default_plugin_handler_func() can be defined which gets called
-by the compiler on tags which can't be resolved internally or by plugins.
-The default_plugin_handler() can map tags to plugins on the fly.
-
-New getters/setters
-
-The following setters/getters will be part of the official
-documentation, and will be strongly recommended. Direct property
-access will still work for the foreseeable future... it will be
-transparently routed through the setters/getters, and consequently a
-bit slower.
-
-array|string getTemplateDir( [string $index] )
-replaces $smarty->template_dir; and $smarty->template_dir[$index];
-Smarty setTemplateDir( array|string $path )
-replaces $smarty->template_dir = "foo"; and $smarty->template_dir =
-array("foo", "bar");
-Smarty addTemplateDir( array|string $path, [string $index])
-replaces $smarty->template_dir[] = "bar"; and
-$smarty->template_dir[$index] = "bar";
-
-array|string getConfigDir( [string $index] )
-replaces $smarty->config_dir; and $smarty->config_dir[$index];
-Smarty setConfigDir( array|string $path )
-replaces $smarty->config_dir = "foo"; and $smarty->config_dir =
-array("foo", "bar");
-Smarty addConfigDir( array|string $path, [string $index])
-replaces $smarty->config_dir[] = "bar"; and
-$smarty->config_dir[$index] = "bar";
-
-array getPluginsDir()
-replaces $smarty->plugins_dir;
-Smarty setPluginsDir( array|string $path )
-replaces $smarty->plugins_dir = "foo";
-Smarty addPluginsDir( array|string $path )
-replaces $smarty->plugins_dir[] = "bar";
-
-string getCompileDir()
-replaces $smarty->compile_dir;
-Smarty setCompileDir( string $path )
-replaces $smarty->compile_dir = "foo";
-
-string getCacheDir()
-replaces $smarty->cache_dir;
-Smarty setCacheDir( string $path )
-replaces $smarty->cache_dir;
diff --git a/library/Smarty/demo/configs/test.conf b/library/Smarty/demo/configs/test.conf
deleted file mode 100644
index 5eac748ec..000000000
--- a/library/Smarty/demo/configs/test.conf
+++ /dev/null
@@ -1,5 +0,0 @@
-title = Welcome to Smarty!
-cutoff_size = 40
-
-[setup]
-bold = true
diff --git a/library/Smarty/demo/index.php b/library/Smarty/demo/index.php
deleted file mode 100644
index 33f3035c5..000000000
--- a/library/Smarty/demo/index.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-/**
- * Example Application
- *
- * @package Example-application
- */
-
-require '../libs/Smarty.class.php';
-
-$smarty = new Smarty;
-
-//$smarty->force_compile = true;
-$smarty->debugging = true;
-$smarty->caching = true;
-$smarty->cache_lifetime = 120;
-
-$smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);
-$smarty->assign("FirstName", array("John", "Mary", "James", "Henry"));
-$smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));
-$smarty->assign("Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"),
- array("I", "J", "K", "L"), array("M", "N", "O", "P")));
-
-$smarty->assign("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/library/Smarty/demo/plugins/cacheresource.apc.php b/library/Smarty/demo/plugins/cacheresource.apc.php
deleted file mode 100644
index d7336f2bf..000000000
--- a/library/Smarty/demo/plugins/cacheresource.apc.php
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-
-/**
- * APC CacheResource
- * CacheResource Implementation based on the KeyValueStore API to use
- * memcache as the storage resource for Smarty's output caching.
- * *
- *
- * @package CacheResource-examples
- * @author Uwe Tews
- */
-class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
-{
- public function __construct()
- {
- // test if APC is present
- if (!function_exists('apc_cache_info')) {
- throw new Exception('APC Template Caching Error: APC is not installed');
- }
- }
-
- /**
- * Read values for a set of keys from cache
- *
- * @param array $keys list of keys to fetch
- *
- * @return array list of values with the given keys used as indexes
- * @return boolean true on success, false on failure
- */
- protected function read(array $keys)
- {
- $_res = array();
- $res = apc_fetch($keys);
- foreach ($res as $k => $v) {
- $_res[$k] = $v;
- }
-
- return $_res;
- }
-
- /**
- * Save values for a set of keys to cache
- *
- * @param array $keys list of values to save
- * @param int $expire expiration time
- *
- * @return boolean true on success, false on failure
- */
- protected function write(array $keys, $expire = null)
- {
- foreach ($keys as $k => $v) {
- apc_store($k, $v, $expire);
- }
-
- return true;
- }
-
- /**
- * Remove values from cache
- *
- * @param array $keys list of keys to delete
- *
- * @return boolean true on success, false on failure
- */
- protected function delete(array $keys)
- {
- foreach ($keys as $k) {
- apc_delete($k);
- }
-
- return true;
- }
-
- /**
- * Remove *all* values from cache
- *
- * @return boolean true on success, false on failure
- */
- protected function purge()
- {
- return apc_clear_cache('user');
- }
-}
diff --git a/library/Smarty/demo/plugins/cacheresource.memcache.php b/library/Smarty/demo/plugins/cacheresource.memcache.php
deleted file mode 100644
index e265365fb..000000000
--- a/library/Smarty/demo/plugins/cacheresource.memcache.php
+++ /dev/null
@@ -1,97 +0,0 @@
-<?php
-
-/**
- * Memcache CacheResource
- * CacheResource Implementation based on the KeyValueStore API to use
- * memcache as the storage resource for Smarty's output caching.
- * Note that memcache has a limitation of 256 characters per cache-key.
- * To avoid complications all cache-keys are translated to a sha1 hash.
- *
- * @package CacheResource-examples
- * @author Rodney Rehm
- */
-class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
-{
- /**
- * memcache instance
- *
- * @var Memcache
- */
- protected $memcache = null;
-
- public function __construct()
- {
- $this->memcache = new Memcache();
- $this->memcache->addServer('127.0.0.1', 11211);
- }
-
- /**
- * Read values for a set of keys from cache
- *
- * @param array $keys list of keys to fetch
- *
- * @return array list of values with the given keys used as indexes
- * @return boolean true on success, false on failure
- */
- protected function read(array $keys)
- {
- $_keys = $lookup = array();
- foreach ($keys as $k) {
- $_k = sha1($k);
- $_keys[] = $_k;
- $lookup[$_k] = $k;
- }
- $_res = array();
- $res = $this->memcache->get($_keys);
- foreach ($res as $k => $v) {
- $_res[$lookup[$k]] = $v;
- }
-
- return $_res;
- }
-
- /**
- * Save values for a set of keys to cache
- *
- * @param array $keys list of values to save
- * @param int $expire expiration time
- *
- * @return boolean true on success, false on failure
- */
- protected function write(array $keys, $expire = null)
- {
- foreach ($keys as $k => $v) {
- $k = sha1($k);
- $this->memcache->set($k, $v, 0, $expire);
- }
-
- return true;
- }
-
- /**
- * Remove values from cache
- *
- * @param array $keys list of keys to delete
- *
- * @return boolean true on success, false on failure
- */
- protected function delete(array $keys)
- {
- foreach ($keys as $k) {
- $k = sha1($k);
- $this->memcache->delete($k);
- }
-
- return true;
- }
-
- /**
- * Remove *all* values from cache
- *
- * @return boolean true on success, false on failure
- */
- protected function purge()
- {
- $this->memcache->flush();
- }
-}
diff --git a/library/Smarty/demo/plugins/cacheresource.mysql.php b/library/Smarty/demo/plugins/cacheresource.mysql.php
deleted file mode 100644
index d8d00ab26..000000000
--- a/library/Smarty/demo/plugins/cacheresource.mysql.php
+++ /dev/null
@@ -1,162 +0,0 @@
-<?php
-
-/**
- * MySQL CacheResource
- * CacheResource Implementation based on the Custom API to use
- * MySQL as the storage resource for Smarty's output caching.
- * Table definition:
- * <pre>CREATE TABLE IF NOT EXISTS `output_cache` (
- * `id` CHAR(40) NOT NULL COMMENT 'sha1 hash',
- * `name` VARCHAR(250) NOT NULL,
- * `cache_id` VARCHAR(250) NULL DEFAULT NULL,
- * `compile_id` VARCHAR(250) NULL DEFAULT NULL,
- * `modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
- * `content` LONGTEXT NOT NULL,
- * PRIMARY KEY (`id`),
- * INDEX(`name`),
- * INDEX(`cache_id`),
- * INDEX(`compile_id`),
- * INDEX(`modified`)
- * ) ENGINE = InnoDB;</pre>
- *
- * @package CacheResource-examples
- * @author Rodney Rehm
- */
-class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
-{
- // PDO instance
- protected $db;
- protected $fetch;
- protected $fetchTimestamp;
- protected $save;
-
- public function __construct()
- {
- try {
- $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
- }
- catch (PDOException $e) {
- throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
- }
- $this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id');
- $this->fetchTimestamp = $this->db->prepare('SELECT modified FROM output_cache WHERE id = :id');
- $this->save = $this->db->prepare('REPLACE INTO output_cache (id, name, cache_id, compile_id, content)
- VALUES (:id, :name, :cache_id, :compile_id, :content)');
- }
-
- /**
- * fetch cached content and its modification time from data source
- *
- * @param string $id unique cache content identifier
- * @param string $name template name
- * @param string $cache_id cache id
- * @param string $compile_id compile id
- * @param string $content cached content
- * @param integer $mtime cache modification timestamp (epoch)
- *
- * @return void
- */
- protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime)
- {
- $this->fetch->execute(array('id' => $id));
- $row = $this->fetch->fetch();
- $this->fetch->closeCursor();
- if ($row) {
- $content = $row['content'];
- $mtime = strtotime($row['modified']);
- } else {
- $content = null;
- $mtime = null;
- }
- }
-
- /**
- * Fetch cached content's modification timestamp from data source
- *
- * @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the complete cached content.
- *
- * @param string $id unique cache content identifier
- * @param string $name template name
- * @param string $cache_id cache id
- * @param string $compile_id compile id
- *
- * @return integer|boolean timestamp (epoch) the template was modified, or false if not found
- */
- protected function fetchTimestamp($id, $name, $cache_id, $compile_id)
- {
- $this->fetchTimestamp->execute(array('id' => $id));
- $mtime = strtotime($this->fetchTimestamp->fetchColumn());
- $this->fetchTimestamp->closeCursor();
-
- return $mtime;
- }
-
- /**
- * Save content to cache
- *
- * @param string $id unique cache content identifier
- * @param string $name template name
- * @param string $cache_id cache id
- * @param string $compile_id compile id
- * @param integer|null $exp_time seconds till expiration time in seconds or null
- * @param string $content content to cache
- *
- * @return boolean success
- */
- protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content)
- {
- $this->save->execute(array(
- 'id' => $id,
- 'name' => $name,
- 'cache_id' => $cache_id,
- 'compile_id' => $compile_id,
- 'content' => $content,
- ));
-
- return !!$this->save->rowCount();
- }
-
- /**
- * Delete content from cache
- *
- * @param string $name template name
- * @param string $cache_id cache id
- * @param string $compile_id compile id
- * @param integer|null $exp_time seconds till expiration or null
- *
- * @return integer number of deleted caches
- */
- protected function delete($name, $cache_id, $compile_id, $exp_time)
- {
- // delete the whole cache
- if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) {
- // returning the number of deleted caches would require a second query to count them
- $query = $this->db->query('TRUNCATE TABLE output_cache');
-
- return - 1;
- }
- // build the filter
- $where = array();
- // equal test name
- if ($name !== null) {
- $where[] = 'name = ' . $this->db->quote($name);
- }
- // equal test compile_id
- if ($compile_id !== null) {
- $where[] = 'compile_id = ' . $this->db->quote($compile_id);
- }
- // range test expiration time
- if ($exp_time !== null) {
- $where[] = 'modified < DATE_SUB(NOW(), INTERVAL ' . intval($exp_time) . ' SECOND)';
- }
- // equal test cache_id and match sub-groups
- if ($cache_id !== null) {
- $where[] = '(cache_id = ' . $this->db->quote($cache_id)
- . ' OR cache_id LIKE ' . $this->db->quote($cache_id . '|%') . ')';
- }
- // run delete query
- $query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where));
-
- return $query->rowCount();
- }
-}
diff --git a/library/Smarty/demo/plugins/cacheresource.pdo.php b/library/Smarty/demo/plugins/cacheresource.pdo.php
deleted file mode 100644
index 569193aa4..000000000
--- a/library/Smarty/demo/plugins/cacheresource.pdo.php
+++ /dev/null
@@ -1,322 +0,0 @@
-<?php
-
-/**
- * PDO Cache Handler
- * Allows you to store Smarty Cache files into your db.
- * Example table :
- * CREATE TABLE `smarty_cache` (
- * `id` char(40) NOT NULL COMMENT 'sha1 hash',
- * `name` varchar(250) NOT NULL,
- * `cache_id` varchar(250) DEFAULT NULL,
- * `compile_id` varchar(250) DEFAULT NULL,
- * `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- * `expire` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
- * `content` mediumblob NOT NULL,
- * PRIMARY KEY (`id`),
- * KEY `name` (`name`),
- * KEY `cache_id` (`cache_id`),
- * KEY `compile_id` (`compile_id`),
- * KEY `modified` (`modified`),
- * KEY `expire` (`expire`)
- * ) ENGINE=InnoDB
- * Example usage :
- * $cnx = new PDO("mysql:host=localhost;dbname=mydb", "username", "password");
- * $smarty->setCachingType('pdo');
- * $smarty->loadPlugin('Smarty_CacheResource_Pdo');
- * $smarty->registerCacheResource('pdo', new Smarty_CacheResource_Pdo($cnx, 'smarty_cache'));
- *
- * @author Beno!t POLASZEK - 2014
- */
-class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
-{
-
- protected $fetchStatements = Array('default' => 'SELECT %2$s
- FROM %1$s
- WHERE 1
- AND id = :id
- AND cache_id IS NULL
- AND compile_id IS NULL',
-
- 'withCacheId' => 'SELECT %2$s
- FROM %1$s
- WHERE 1
- AND id = :id
- AND cache_id = :cache_id
- AND compile_id IS NULL',
-
- 'withCompileId' => 'SELECT %2$s
- FROM %1$s
- WHERE 1
- AND id = :id
- AND compile_id = :compile_id
- AND cache_id IS NULL',
-
- 'withCacheIdAndCompileId' => 'SELECT %2$s
- FROM %1$s
- WHERE 1
- AND id = :id
- AND cache_id = :cache_id
- AND compile_id = :compile_id');
- protected $insertStatement = 'INSERT INTO %s
-
- SET id = :id,
- name = :name,
- cache_id = :cache_id,
- compile_id = :compile_id,
- modified = CURRENT_TIMESTAMP,
- expire = DATE_ADD(CURRENT_TIMESTAMP, INTERVAL :expire SECOND),
- content = :content
-
- ON DUPLICATE KEY UPDATE
- name = :name,
- cache_id = :cache_id,
- compile_id = :compile_id,
- modified = CURRENT_TIMESTAMP,
- expire = DATE_ADD(CURRENT_TIMESTAMP, INTERVAL :expire SECOND),
- content = :content';
-
- protected $deleteStatement = 'DELETE FROM %1$s WHERE %2$s';
- protected $truncateStatement = 'TRUNCATE TABLE %s';
-
- protected $fetchColumns = 'modified, content';
- protected $fetchTimestampColumns = 'modified';
-
- protected $pdo, $table, $database;
-
- /*
- * Constructor
- *
- * @param PDO $pdo PDO : active connection
- * @param string $table : table (or view) name
- * @param string $database : optionnal - if table is located in another db
- */
- public function __construct(PDO $pdo, $table, $database = null)
- {
-
- if (is_null($table)) {
- throw new SmartyException("Table name for caching can't be null");
- }
-
- $this->pdo = $pdo;
- $this->table = $table;
- $this->database = $database;
-
- $this->fillStatementsWithTableName();
- }
-
- /*
- * Fills the table name into the statements.
- *
- * @return Current Instance
- * @access protected
- */
- protected function fillStatementsWithTableName()
- {
-
- foreach ($this->fetchStatements AS &$statement) {
- $statement = sprintf($statement, $this->getTableName(), '%s');
- }
-
- $this->insertStatement = sprintf($this->insertStatement, $this->getTableName());
- $this->deleteStatement = sprintf($this->deleteStatement, $this->getTableName(), '%s');
- $this->truncateStatement = sprintf($this->truncateStatement, $this->getTableName());
-
- return $this;
- }
-
- /*
- * Gets the fetch statement, depending on what you specify
- *
- * @param string $columns : the column(s) name(s) you want to retrieve from the database
- * @param string $id unique cache content identifier
- * @param string|null $cache_id cache id
- * @param string|null $compile_id compile id
- * @access protected
- */
- protected function getFetchStatement($columns, $id, $cache_id = null, $compile_id = null)
- {
-
- if (!is_null($cache_id) && !is_null($compile_id)) {
- $query = $this->fetchStatements['withCacheIdAndCompileId'] AND $args = Array('id' => $id, 'cache_id' => $cache_id, 'compile_id' => $compile_id);
- } elseif (is_null($cache_id) && !is_null($compile_id)) {
- $query = $this->fetchStatements['withCompileId'] AND $args = Array('id' => $id, 'compile_id' => $compile_id);
- } elseif (!is_null($cache_id) && is_null($compile_id)) {
- $query = $this->fetchStatements['withCacheId'] AND $args = Array('id' => $id, 'cache_id' => $cache_id);
- } else {
- $query = $this->fetchStatements['default'] AND $args = Array('id' => $id);
- }
-
- $query = sprintf($query, $columns);
-
- $stmt = $this->pdo->prepare($query);
-
- foreach ($args AS $key => $value) {
- $stmt->bindValue($key, $value);
- }
-
- return $stmt;
- }
-
- /**
- * fetch cached content and its modification time from data source
- *
- * @param string $id unique cache content identifier
- * @param string $name template name
- * @param string|null $cache_id cache id
- * @param string|null $compile_id compile id
- * @param string $content cached content
- * @param integer $mtime cache modification timestamp (epoch)
- *
- * @return void
- * @access protected
- */
- protected function fetch($id, $name, $cache_id = null, $compile_id = null, &$content, &$mtime)
- {
-
- $stmt = $this->getFetchStatement($this->fetchColumns, $id, $cache_id, $compile_id);
- $stmt ->execute();
- $row = $stmt->fetch();
- $stmt ->closeCursor();
-
- if ($row) {
- $content = $this->outputContent($row['content']);
- $mtime = strtotime($row['modified']);
- } else {
- $content = null;
- $mtime = null;
- }
- }
-
- /**
- * Fetch cached content's modification timestamp from data source
- * {@internal implementing this method is optional.
- * Only implement it if modification times can be accessed faster than loading the complete cached content.}}
- *
- * @param string $id unique cache content identifier
- * @param string $name template name
- * @param string|null $cache_id cache id
- * @param string|null $compile_id compile id
- *
- * @return integer|boolean timestamp (epoch) the template was modified, or false if not found
- * @access protected
- */
- // protected function fetchTimestamp($id, $name, $cache_id = null, $compile_id = null) {
- // $stmt = $this->getFetchStatement($this->fetchTimestampColumns, $id, $cache_id, $compile_id);
- // $stmt -> execute();
- // $mtime = strtotime($stmt->fetchColumn());
- // $stmt -> closeCursor();
- // return $mtime;
- // }
-
- /**
- * Save content to cache
- *
- * @param string $id unique cache content identifier
- * @param string $name template name
- * @param string|null $cache_id cache id
- * @param string|null $compile_id compile id
- * @param integer|null $exp_time seconds till expiration time in seconds or null
- * @param string $content content to cache
- *
- * @return boolean success
- * @access protected
- */
- protected function save($id, $name, $cache_id = null, $compile_id = null, $exp_time, $content)
- {
-
- $stmt = $this->pdo->prepare($this->insertStatement);
-
- $stmt ->bindValue('id', $id);
- $stmt ->bindValue('name', $name);
- $stmt ->bindValue('cache_id', $cache_id, (is_null($cache_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR);
- $stmt ->bindValue('compile_id', $compile_id, (is_null($compile_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR);
- $stmt ->bindValue('expire', (int) $exp_time, PDO::PARAM_INT);
- $stmt ->bindValue('content', $this->inputContent($content));
- $stmt ->execute();
-
- return !!$stmt->rowCount();
- }
-
- /*
- * Encodes the content before saving to database
- *
- * @param string $content
- * @return string $content
- * @access protected
- */
- protected function inputContent($content)
- {
- return $content;
- }
-
- /*
- * Decodes the content before saving to database
- *
- * @param string $content
- * @return string $content
- * @access protected
- */
- protected function outputContent($content)
- {
- return $content;
- }
-
- /**
- * Delete content from cache
- *
- * @param string|null $name template name
- * @param string|null $cache_id cache id
- * @param string|null $compile_id compile id
- * @param integer|null|-1 $exp_time seconds till expiration or null
- *
- * @return integer number of deleted caches
- * @access protected
- */
- protected function delete($name = null, $cache_id = null, $compile_id = null, $exp_time = null)
- {
-
- // delete the whole cache
- if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) {
- // returning the number of deleted caches would require a second query to count them
- $this->pdo->query($this->truncateStatement);
- return - 1;
- }
- // build the filter
- $where = array();
- // equal test name
- if ($name !== null) {
- $where[] = 'name = ' . $this->pdo->quote($name);
- }
- // equal test cache_id and match sub-groups
- if ($cache_id !== null) {
- $where[] = '(cache_id = ' . $this->pdo->quote($cache_id)
- . ' OR cache_id LIKE ' . $this->pdo->quote($cache_id . '|%') . ')';
- }
- // equal test compile_id
- if ($compile_id !== null) {
- $where[] = 'compile_id = ' . $this->pdo->quote($compile_id);
- }
- // for clearing expired caches
- if ($exp_time === Smarty::CLEAR_EXPIRED) {
- $where[] = 'expire < CURRENT_TIMESTAMP';
- } // range test expiration time
- elseif ($exp_time !== null) {
- $where[] = 'modified < DATE_SUB(NOW(), INTERVAL ' . intval($exp_time) . ' SECOND)';
- }
- // run delete query
- $query = $this->pdo->query(sprintf($this->deleteStatement, join(' AND ', $where)));
- return $query->rowCount();
- }
-
- /**
- * Gets the formatted table name
- *
- * @return string
- * @access protected
- */
- protected function getTableName()
- {
- return (is_null($this->database)) ? "`{$this->table}`" : "`{$this->database}`.`{$this->table}`";
- }
-}
- \ No newline at end of file
diff --git a/library/Smarty/demo/plugins/cacheresource.pdo_gzip.php b/library/Smarty/demo/plugins/cacheresource.pdo_gzip.php
deleted file mode 100644
index 8a9e0a5dd..000000000
--- a/library/Smarty/demo/plugins/cacheresource.pdo_gzip.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-
-/**
- * PDO Cache Handler with GZIP support
- * Example usage :
- * $cnx = new PDO("mysql:host=localhost;dbname=mydb", "username", "password");
- * $smarty->setCachingType('pdo_gzip');
- * $smarty->loadPlugin('Smarty_CacheResource_Pdo_Gzip');
- * $smarty->registerCacheResource('pdo_gzip', new Smarty_CacheResource_Pdo_Gzip($cnx, 'smarty_cache'));
- *
- * @require Smarty_CacheResource_Pdo class
- * @author Beno!t POLASZEK - 2014
- */
-require_once 'cacheresource.pdo.php';
-
-class Smarty_CacheResource_Pdo_Gzip extends Smarty_CacheResource_Pdo
-{
-
- /*
- * Encodes the content before saving to database
- *
- * @param string $content
- * @return string $content
- * @access protected
- */
- protected function inputContent($content)
- {
- return gzdeflate($content);
- }
-
- /*
- * Decodes the content before saving to database
- *
- * @param string $content
- * @return string $content
- * @access protected
- */
- protected function outputContent($content)
- {
- return gzinflate($content);
- }
-}
- \ No newline at end of file
diff --git a/library/Smarty/demo/plugins/resource.extendsall.php b/library/Smarty/demo/plugins/resource.extendsall.php
deleted file mode 100644
index 500b3c862..000000000
--- a/library/Smarty/demo/plugins/resource.extendsall.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-
-/**
- * Extends All Resource
- * Resource Implementation modifying the extends-Resource to walk
- * through the template_dirs and inherit all templates of the same name
- *
- * @package Resource-examples
- * @author Rodney Rehm
- */
-class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends
-{
- /**
- * populate Source Object with meta data from Resource
- *
- * @param Smarty_Template_Source $source source object
- * @param Smarty_Internal_Template $_template template object
- *
- * @return void
- */
- public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
- {
- $uid = '';
- $sources = array();
- $exists = true;
- foreach ($_template->smarty->getTemplateDir() as $key => $directory) {
- try {
- $s = Smarty_Resource::source(null, $source->smarty, '[' . $key . ']' . $source->name);
- if (!$s->exists) {
- continue;
- }
- $sources[$s->uid] = $s;
- $uid .= $s->filepath;
- }
- catch (SmartyException $e) {
- }
- }
-
- if (!$sources) {
- $source->exists = false;
- $source->template = $_template;
-
- return;
- }
-
- $sources = array_reverse($sources, true);
- reset($sources);
- $s = current($sources);
-
- $source->components = $sources;
- $source->filepath = $s->filepath;
- $source->uid = sha1($uid);
- $source->exists = $exists;
- if ($_template && $_template->smarty->compile_check) {
- $source->timestamp = $s->timestamp;
- }
- // need the template at getContent()
- $source->template = $_template;
- }
-}
diff --git a/library/Smarty/demo/plugins/resource.mysql.php b/library/Smarty/demo/plugins/resource.mysql.php
deleted file mode 100644
index dfc9606b4..000000000
--- a/library/Smarty/demo/plugins/resource.mysql.php
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-
-/**
- * MySQL Resource
- * Resource Implementation based on the Custom API to use
- * MySQL as the storage resource for Smarty's templates and configs.
- * Table definition:
- * <pre>CREATE TABLE IF NOT EXISTS `templates` (
- * `name` varchar(100) NOT NULL,
- * `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
- * `source` text,
- * PRIMARY KEY (`name`)
- * ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
- * Demo data:
- * <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
- *
- * @package Resource-examples
- * @author Rodney Rehm
- */
-class Smarty_Resource_Mysql extends Smarty_Resource_Custom
-{
- // PDO instance
- protected $db;
- // prepared fetch() statement
- protected $fetch;
- // prepared fetchTimestamp() statement
- protected $mtime;
-
- public function __construct()
- {
- try {
- $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
- }
- catch (PDOException $e) {
- throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
- }
- $this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name');
- $this->mtime = $this->db->prepare('SELECT modified FROM templates WHERE name = :name');
- }
-
- /**
- * Fetch a template and its modification time from database
- *
- * @param string $name template name
- * @param string $source template source
- * @param integer $mtime template modification timestamp (epoch)
- *
- * @return void
- */
- protected function fetch($name, &$source, &$mtime)
- {
- $this->fetch->execute(array('name' => $name));
- $row = $this->fetch->fetch();
- $this->fetch->closeCursor();
- if ($row) {
- $source = $row['source'];
- $mtime = strtotime($row['modified']);
- } else {
- $source = null;
- $mtime = null;
- }
- }
-
- /**
- * Fetch a template's modification time from database
- *
- * @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the comple template source.
- *
- * @param string $name template name
- *
- * @return integer timestamp (epoch) the template was modified
- */
- protected function fetchTimestamp($name)
- {
- $this->mtime->execute(array('name' => $name));
- $mtime = $this->mtime->fetchColumn();
- $this->mtime->closeCursor();
-
- return strtotime($mtime);
- }
-}
diff --git a/library/Smarty/demo/plugins/resource.mysqls.php b/library/Smarty/demo/plugins/resource.mysqls.php
deleted file mode 100644
index f694ddf11..000000000
--- a/library/Smarty/demo/plugins/resource.mysqls.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-
-/**
- * MySQL Resource
- * Resource Implementation based on the Custom API to use
- * MySQL as the storage resource for Smarty's templates and configs.
- * Note that this MySQL implementation fetches the source and timestamps in
- * a single database query, instead of two separate like resource.mysql.php does.
- * Table definition:
- * <pre>CREATE TABLE IF NOT EXISTS `templates` (
- * `name` varchar(100) NOT NULL,
- * `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
- * `source` text,
- * PRIMARY KEY (`name`)
- * ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
- * Demo data:
- * <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
- *
- * @package Resource-examples
- * @author Rodney Rehm
- */
-class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
-{
- // PDO instance
- protected $db;
- // prepared fetch() statement
- protected $fetch;
-
- public function __construct()
- {
- try {
- $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
- }
- catch (PDOException $e) {
- throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
- }
- $this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name');
- }
-
- /**
- * Fetch a template and its modification time from database
- *
- * @param string $name template name
- * @param string $source template source
- * @param integer $mtime template modification timestamp (epoch)
- *
- * @return void
- */
- protected function fetch($name, &$source, &$mtime)
- {
- $this->fetch->execute(array('name' => $name));
- $row = $this->fetch->fetch();
- $this->fetch->closeCursor();
- if ($row) {
- $source = $row['source'];
- $mtime = strtotime($row['modified']);
- } else {
- $source = null;
- $mtime = null;
- }
- }
-}
diff --git a/library/Smarty/demo/templates/footer.tpl b/library/Smarty/demo/templates/footer.tpl
deleted file mode 100644
index e04310fdd..000000000
--- a/library/Smarty/demo/templates/footer.tpl
+++ /dev/null
@@ -1,2 +0,0 @@
-</BODY>
-</HTML>
diff --git a/library/Smarty/demo/templates/header.tpl b/library/Smarty/demo/templates/header.tpl
deleted file mode 100644
index 783210a18..000000000
--- a/library/Smarty/demo/templates/header.tpl
+++ /dev/null
@@ -1,5 +0,0 @@
-<HTML>
-<HEAD>
-<TITLE>{$title} - {$Name}</TITLE>
-</HEAD>
-<BODY bgcolor="#ffffff">
diff --git a/library/Smarty/demo/templates/index.tpl b/library/Smarty/demo/templates/index.tpl
deleted file mode 100644
index 1fbb6d379..000000000
--- a/library/Smarty/demo/templates/index.tpl
+++ /dev/null
@@ -1,87 +0,0 @@
-{config_load file="test.conf" section="setup"}
-{include file="header.tpl" title=foo}
-
-<PRE>
-
-{* bold and title are read from the config file *}
- {if #bold#}<b>{/if}
- {* capitalize the first letters of each word of the title *}
- Title: {#title#|capitalize}
- {if #bold#}</b>{/if}
-
- 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 <b>{$Name}</b>
-
-variable modifier example of {ldelim}$Name|upper{rdelim}
-
-<b>{$Name|upper}</b>
-
-
-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}
- <br>
-
- fax: {$contacts[sec1].fax}
- <br>
-
- cell: {$contacts[sec1].cell}
- <br>
- {/section}
- <p>
-
- testing strip tags
- {strip}
-<table border=0>
- <tr>
- <td>
- <A HREF="{$SCRIPT_NAME}">
- <font color="red">This is a test </font>
- </A>
- </td>
- </tr>
-</table>
- {/strip}
-
-</PRE>
-
-This is an example of the html_select_date function:
-
-<form>
- {html_select_date start_year=1998 end_year=2010}
-</form>
-
-This is an example of the html_select_time function:
-
-<form>
- {html_select_time use_24_hours=false}
-</form>
-
-This is an example of the html_options function:
-
-<form>
- <select name=states>
- {html_options values=$option_values selected=$option_selected output=$option_output}
- </select>
-</form>
-
-{include file="footer.tpl"}
diff --git a/library/Smarty/lexer/smarty_internal_configfilelexer.plex b/library/Smarty/lexer/smarty_internal_configfilelexer.plex
deleted file mode 100644
index 94196be5f..000000000
--- a/library/Smarty/lexer/smarty_internal_configfilelexer.plex
+++ /dev/null
@@ -1,318 +0,0 @@
-<?php
-/**
-* Smarty Internal Plugin Configfilelexer
-*
-* This is the lexer to break the config file source into tokens
-* @package Smarty
-* @subpackage Config
-* @author Uwe Tews
-*/
-/**
-* Smarty_Internal_Configfilelexer
-*
-* This is the config file lexer.
-* It is generated from the smarty_internal_configfilelexer.plex file
-*
-* @package Smarty
-* @subpackage Compiler
-* @author Uwe Tews
-*/
-class Smarty_Internal_Configfilelexer
-{
- /**
- * Source
- *
- * @var string
- */
- public $data;
- /**
- * byte counter
- *
- * @var int
- */
- public $counter;
- /**
- * token number
- *
- * @var int
- */
- public $token;
- /**
- * token value
- *
- * @var string
- */
- public $value;
- /**
- * current line
- *
- * @var int
- */
- public $line;
- /**
- * state number
- *
- * @var int
- */
- public $state = 1;
- /**
- * Smarty object
- *
- * @var Smarty
- */
- public $smarty = null;
- /**
- * compiler object
- *
- * @var Smarty_Internal_Config_File_Compiler
- */
- private $compiler = null;
- /**
- * copy of config_booleanize
- *
- * @var bool
- */
- private $configBooleanize = false;
- /**
- * trace file
- *
- * @var resource
- */
- public $yyTraceFILE;
- /**
- * trace prompt
- *
- * @var string
- */
- public $yyTracePrompt;
- /**
- * state names
- *
- * @var array
- */
- public $state_name = array(1 => 'START', 2 => 'VALUE', 3 => 'NAKED_STRING_VALUE', 4 => 'COMMENT', 5 => 'SECTION', 6 => 'TRIPPLE');
-
- /**
- * storage for assembled token patterns
- *
- * @var sring
- */
- private $yy_global_pattern1 = null;
- private $yy_global_pattern2 = null;
- private $yy_global_pattern3 = null;
- private $yy_global_pattern4 = null;
- private $yy_global_pattern5 = null;
- private $yy_global_pattern6 = null;
-
- /**
- * token names
- *
- * @var array
- */
- public $smarty_token_names = array( // Text for parser error messages
- );
-
- /**
- * constructor
- *
- * @param string $data template source
- * @param Smarty_Internal_Config_File_Compiler $compiler
- */
- function __construct($data, Smarty_Internal_Config_File_Compiler $compiler)
- {
- // set instance object
- self::instance($this);
- $this->data = $data . "\n"; //now all lines are \n-terminated
- $this->counter = 0;
- if (preg_match('/^\xEF\xBB\xBF/', $this->data, $match)) {
- $this->counter += strlen($match[0]);
- }
- $this->line = 1;
- $this->compiler = $compiler;
- $this->smarty = $compiler->smarty;
- $this->configBooleanize = $this->smarty->config_booleanize;
- }
-
- public static function &instance($new_instance = null)
- {
- static $instance = null;
- if (isset($new_instance) && is_object($new_instance)) {
- $instance = $new_instance;
- }
- return $instance;
- }
-
- public function PrintTrace()
- {
- $this->yyTraceFILE = fopen('php://output', 'w');
- $this->yyTracePrompt = '<br>';
- }
-
-
-/*!lex2php
-%input $this->data
-%counter $this->counter
-%token $this->token
-%value $this->value
-%line $this->line
-commentstart = /#|;/
-openB = /\[/
-closeB = /\]/
-section = /.*?(?=[\.=\[\]\r\n])/
-equal = /=/
-whitespace = /[ \t\r]+/
-dot = /\./
-id = /[0-9]*[a-zA-Z_]\w*/
-newline = /\n/
-single_quoted_string = /'[^'\\]*(?:\\.[^'\\]*)*'(?=[ \t\r]*[\n#;])/
-double_quoted_string = /"[^"\\]*(?:\\.[^"\\]*)*"(?=[ \t\r]*[\n#;])/
-tripple_quotes = /"""/
-tripple_quotes_end = /"""(?=[ \t\r]*[\n#;])/
-text = /[\S\s]/
-float = /\d+\.\d+(?=[ \t\r]*[\n#;])/
-int = /\d+(?=[ \t\r]*[\n#;])/
-maybe_bool = /[a-zA-Z]+(?=[ \t\r]*[\n#;])/
-naked_string = /[^\n]+?(?=[ \t\r]*\n)/
-*/
-
-/*!lex2php
-%statename START
-
-commentstart {
- $this->token = Smarty_Internal_Configfileparser::TPC_COMMENTSTART;
- $this->yypushstate(self::COMMENT);
-}
-openB {
- $this->token = Smarty_Internal_Configfileparser::TPC_OPENB;
- $this->yypushstate(self::SECTION);
-}
-closeB {
- $this->token = Smarty_Internal_Configfileparser::TPC_CLOSEB;
-}
-equal {
- $this->token = Smarty_Internal_Configfileparser::TPC_EQUAL;
- $this->yypushstate(self::VALUE);
-}
-whitespace {
- return false;
-}
-newline {
- $this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE;
-}
-id {
- $this->token = Smarty_Internal_Configfileparser::TPC_ID;
-}
-text {
- $this->token = Smarty_Internal_Configfileparser::TPC_OTHER;
-}
-
-*/
-
-/*!lex2php
-%statename VALUE
-
-whitespace {
- return false;
-}
-float {
- $this->token = Smarty_Internal_Configfileparser::TPC_FLOAT;
- $this->yypopstate();
-}
-int {
- $this->token = Smarty_Internal_Configfileparser::TPC_INT;
- $this->yypopstate();
-}
-tripple_quotes {
- $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES;
- $this->yypushstate(self::TRIPPLE);
-}
-single_quoted_string {
- $this->token = Smarty_Internal_Configfileparser::TPC_SINGLE_QUOTED_STRING;
- $this->yypopstate();
-}
-double_quoted_string {
- $this->token = Smarty_Internal_Configfileparser::TPC_DOUBLE_QUOTED_STRING;
- $this->yypopstate();
-}
-maybe_bool {
- if (!$this->configBooleanize || !in_array(strtolower($this->value), Array("true", "false", "on", "off", "yes", "no")) ) {
- $this->yypopstate();
- $this->yypushstate(self::NAKED_STRING_VALUE);
- return true; //reprocess in new state
- } else {
- $this->token = Smarty_Internal_Configfileparser::TPC_BOOL;
- $this->yypopstate();
- }
-}
-naked_string {
- $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
- $this->yypopstate();
-}
-newline {
- $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
- $this->value = "";
- $this->yypopstate();
-}
-
-*/
-
-/*!lex2php
-%statename NAKED_STRING_VALUE
-
-naked_string {
- $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
- $this->yypopstate();
-}
-
-*/
-
-/*!lex2php
-%statename COMMENT
-
-whitespace {
- return false;
-}
-naked_string {
- $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
-}
-newline {
- $this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE;
- $this->yypopstate();
-}
-
-*/
-
-/*!lex2php
-%statename SECTION
-
-dot {
- $this->token = Smarty_Internal_Configfileparser::TPC_DOT;
-}
-section {
- $this->token = Smarty_Internal_Configfileparser::TPC_SECTION;
- $this->yypopstate();
-}
-
-*/
-/*!lex2php
-%statename TRIPPLE
-
-tripple_quotes_end {
- $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES_END;
- $this->yypopstate();
- $this->yypushstate(self::START);
-}
-text {
- $to = strlen($this->data);
- preg_match("/\"\"\"[ \t\r]*[\n#;]/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
- if (isset($match[0][1])) {
- $to = $match[0][1];
- } else {
- $this->compiler->trigger_template_error ("missing or misspelled literal closing tag");
- }
- $this->value = substr($this->data,$this->counter,$to-$this->counter);
- $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_TEXT;
-}
-*/
-
-}
diff --git a/library/Smarty/lexer/smarty_internal_configfileparser.y b/library/Smarty/lexer/smarty_internal_configfileparser.y
deleted file mode 100644
index ac961772d..000000000
--- a/library/Smarty/lexer/smarty_internal_configfileparser.y
+++ /dev/null
@@ -1,362 +0,0 @@
-/**
-* Smarty Internal Plugin Configfileparser
-*
-* This is the config file parser
-*
-*
-* @package Smarty
-* @subpackage Config
-* @author Uwe Tews
-*/
-%name TPC_
-%declare_class {
-/**
-* Smarty Internal Plugin Configfileparse
-*
-* This is the config file parser.
-* It is generated from the smarty_internal_configfileparser.y file
-* @package Smarty
-* @subpackage Compiler
-* @author Uwe Tews
-*/
-class Smarty_Internal_Configfileparser
-}
-%include_class
-{
- /**
- * result status
- *
- * @var bool
- */
- public $successful = true;
- /**
- * return value
- *
- * @var mixed
- */
- public $retvalue = 0;
- /**
- * @var
- */
- public $yymajor;
- /**
- * lexer object
- *
- * @var Smarty_Internal_Configfilelexer
- */
- private $lex;
- /**
- * internal error flag
- *
- * @var bool
- */
- private $internalError = false;
- /**
- * compiler object
- *
- * @var Smarty_Internal_Config_File_Compiler
- */
- public $compiler = null;
- /**
- * smarty object
- *
- * @var Smarty
- */
- public $smarty = null;
- /**
- * copy of config_overwrite property
- *
- * @var bool
- */
- private $configOverwrite = false;
- /**
- * copy of config_read_hidden property
- *
- * @var bool
- */
- private $configReadHidden = false;
- /**
- * helper map
- *
- * @var array
- */
- private static $escapes_single = Array('\\' => '\\',
- '\'' => '\'');
-
- /**
- * constructor
- *
- * @param Smarty_Internal_Configfilelexer $lex
- * @param Smarty_Internal_Config_File_Compiler $compiler
- */
- function __construct(Smarty_Internal_Configfilelexer $lex, Smarty_Internal_Config_File_Compiler $compiler)
- {
- // set instance object
- self::instance($this);
- $this->lex = $lex;
- $this->smarty = $compiler->smarty;
- $this->compiler = $compiler;
- $this->configOverwrite = $this->smarty->config_overwrite;
- $this->configReadHidden = $this->smarty->config_read_hidden;
- }
-
- /**
- * @param null $new_instance
- *
- * @return null
- */
- public static function &instance($new_instance = null)
- {
- static $instance = null;
- if (isset($new_instance) && is_object($new_instance)) {
- $instance = $new_instance;
- }
- return $instance;
- }
-
- /**
- * parse optional boolean keywords
- *
- * @param string $str
- *
- * @return bool
- */
- private function parse_bool($str)
- {
- $str = strtolower($str);
- if (in_array($str, array('on', 'yes', 'true'))) {
- $res = true;
- } else {
- $res = false;
- }
- return $res;
- }
-
- /**
- * parse single quoted string
- * remove outer quotes
- * unescape inner quotes
- *
- * @param string $qstr
- *
- * @return string
- */
- private static function parse_single_quoted_string($qstr)
- {
- $escaped_string = substr($qstr, 1, strlen($qstr) - 2); //remove outer quotes
-
- $ss = preg_split('/(\\\\.)/', $escaped_string, - 1, PREG_SPLIT_DELIM_CAPTURE);
-
- $str = "";
- foreach ($ss as $s) {
- if (strlen($s) === 2 && $s[0] === '\\') {
- if (isset(self::$escapes_single[$s[1]])) {
- $s = self::$escapes_single[$s[1]];
- }
- }
- $str .= $s;
- }
- return $str;
- }
-
- /**
- * parse double quoted string
- *
- * @param string $qstr
- *
- * @return string
- */
- private static function parse_double_quoted_string($qstr)
- {
- $inner_str = substr($qstr, 1, strlen($qstr) - 2);
- return stripcslashes($inner_str);
- }
-
- /**
- * parse triple quoted string
- *
- * @param string $qstr
- *
- * @return string
- */
- private static function parse_tripple_double_quoted_string($qstr)
- {
- return stripcslashes($qstr);
- }
-
- /**
- * set a config variable in target array
- *
- * @param array $var
- * @param array $target_array
- */
- private function set_var(Array $var, Array &$target_array)
- {
- $key = $var["key"];
- $value = $var["value"];
-
- if ($this->configOverwrite || !isset($target_array['vars'][$key])) {
- $target_array['vars'][$key] = $value;
- } else {
- settype($target_array['vars'][$key], 'array');
- $target_array['vars'][$key][] = $value;
- }
- }
-
- /**
- * add config variable to global vars
- *
- * @param array $vars
- */
- private function add_global_vars(Array $vars)
- {
- if (!isset($this->compiler->config_data['vars'])) {
- $this->compiler->config_data['vars'] = Array();
- }
- foreach ($vars as $var) {
- $this->set_var($var, $this->compiler->config_data);
- }
- }
-
- /**
- * add config variable to section
- *
- * @param string $section_name
- * @param array $vars
- */
- private function add_section_vars($section_name, Array $vars)
- {
- if (!isset($this->compiler->config_data['sections'][$section_name]['vars'])) {
- $this->compiler->config_data['sections'][$section_name]['vars'] = Array();
- }
- foreach ($vars as $var) {
- $this->set_var($var, $this->compiler->config_data['sections'][$section_name]);
- }
- }
-}
-
-%token_prefix TPC_
-
-%parse_accept
-{
- $this->successful = !$this->internalError;
- $this->internalError = false;
- $this->retvalue = $this->_retvalue;
-}
-
-%syntax_error
-{
- $this->internalError = true;
- $this->yymajor = $yymajor;
- $this->compiler->trigger_config_file_error();
-}
-
-%stack_overflow
-{
- $this->internalError = true;
- $this->compiler->trigger_config_file_error("Stack overflow in configfile parser");
-}
-
-// Complete config file
-start(res) ::= global_vars sections. {
- res = null;
-}
-
-// Global vars
-global_vars(res) ::= var_list(vl). {
- $this->add_global_vars(vl);
- res = null;
-}
-
-// Sections
-sections(res) ::= sections section. {
- res = null;
-}
-
-sections(res) ::= . {
- res = null;
-}
-
-section(res) ::= OPENB SECTION(i) CLOSEB newline var_list(vars). {
- $this->add_section_vars(i, vars);
- res = null;
-}
-
-section(res) ::= OPENB DOT SECTION(i) CLOSEB newline var_list(vars). {
- if ($this->configReadHidden) {
- $this->add_section_vars(i, vars);
- }
- res = null;
-}
-
-// Var list
-var_list(res) ::= var_list(vl) newline. {
- res = vl;
-}
-
-var_list(res) ::= var_list(vl) var(v). {
- res = array_merge(vl, Array(v));
-}
-
-var_list(res) ::= . {
- res = Array();
-}
-
-
-// Var
-var(res) ::= ID(id) EQUAL value(v). {
- res = Array("key" => id, "value" => v);
-}
-
-
-value(res) ::= FLOAT(i). {
- res = (float) i;
-}
-
-value(res) ::= INT(i). {
- res = (int) i;
-}
-
-value(res) ::= BOOL(i). {
- res = $this->parse_bool(i);
-}
-
-value(res) ::= SINGLE_QUOTED_STRING(i). {
- res = self::parse_single_quoted_string(i);
-}
-
-value(res) ::= DOUBLE_QUOTED_STRING(i). {
- res = self::parse_double_quoted_string(i);
-}
-
-value(res) ::= TRIPPLE_QUOTES(i) TRIPPLE_TEXT(c) TRIPPLE_QUOTES_END(ii). {
- res = self::parse_tripple_double_quoted_string(c);
-}
-
-value(res) ::= TRIPPLE_QUOTES(i) TRIPPLE_QUOTES_END(ii). {
- res = '';
-}
-
-value(res) ::= NAKED_STRING(i). {
- res = i;
-}
-
-// NOTE: this is not a valid rule
-// It is added hier to produce a usefull error message on a missing '=';
-value(res) ::= OTHER(i). {
- res = i;
-}
-
-
-// Newline and comments
-newline(res) ::= NEWLINE. {
- res = null;
-}
-
-newline(res) ::= COMMENTSTART NEWLINE. {
- res = null;
-}
-
-newline(res) ::= COMMENTSTART NAKED_STRING NEWLINE. {
- res = null;
-}
diff --git a/library/Smarty/lexer/smarty_internal_templatelexer.plex b/library/Smarty/lexer/smarty_internal_templatelexer.plex
deleted file mode 100644
index e36df5970..000000000
--- a/library/Smarty/lexer/smarty_internal_templatelexer.plex
+++ /dev/null
@@ -1,770 +0,0 @@
-<?php
-/**
- * Smarty Internal Plugin Templatelexer
- * This is the lexer to break the template source into tokens
- *
- * @package Smarty
- * @subpackage Compiler
- * @author Uwe Tews
- */
-
-/**
- * Smarty_Internal_Templatelexer
- * This is the template file lexer.
- * It is generated from the smarty_internal_templatelexer.plex file
- *
- * @package Smarty
- * @subpackage Compiler
- * @author Uwe Tews
- */
-class Smarty_Internal_Templatelexer
-{
- /**
- * Source
- *
- * @var string
- */
- public $data;
- /**
- * byte counter
- *
- * @var int
- */
- public $counter;
- /**
- * token number
- *
- * @var int
- */
- public $token;
- /**
- * token value
- *
- * @var string
- */
- public $value;
- /**
- * current line
- *
- * @var int
- */
- public $line;
- /**
- * tag start line
- *
- * @var
- */
- public $taglineno;
- /**
- * php code type
- *
- * @var string
- */
- public $phpType = '';
- /**
- * escaped left delimiter
- *
- * @var string
- */
- public $ldel = '';
- /**
- * escaped left delimiter length
- *
- * @var int
- */
- public $ldel_length = 0;
- /**
- * escaped right delimiter
- *
- * @var string
- */
- public $rdel = '';
- /**
- * escaped right delimiter length
- *
- * @var int
- */
- public $rdel_length = 0;
- /**
- * state number
- *
- * @var int
- */
- public $state = 1;
- /**
- * Smarty object
- *
- * @var Smarty
- */
- public $smarty = null;
- /**
- * compiler object
- *
- * @var Smarty_Internal_TemplateCompilerBase
- */
- public $compiler = null;
- /**
- * literal tag nesting level
- *
- * @var int
- */
- private $literal_cnt = 0;
-
- /**
- * PHP start tag string
- *
- * @var string
- */
-
- /**
- * trace file
- *
- * @var resource
- */
- public $yyTraceFILE;
-
- /**
- * trace prompt
- *
- * @var string
- */
- public $yyTracePrompt;
-
- /**
- * XML flag true while processing xml
- *
- * @var bool
- */
- public $is_xml = false;
-
- /**
- * state names
- *
- * @var array
- */
- public $state_name = array(1 => 'TEXT', 2 => 'TAG', 3 => 'TAGBODY', 4 => 'LITERAL', 5 => 'DOUBLEQUOTEDSTRING',
- 6 => 'CHILDBODY', 7 => 'CHILDBLOCK', 8 => 'CHILDLITERAL');
-
- /**
- * storage for assembled token patterns
- *
- * @var string
- */
- private $yy_global_pattern1 = null;
-
- private $yy_global_pattern2 = null;
-
- private $yy_global_pattern3 = null;
-
- private $yy_global_pattern4 = null;
-
- private $yy_global_pattern5 = null;
-
- private $yy_global_pattern6 = null;
-
- private $yy_global_pattern7 = null;
-
- private $yy_global_pattern8 = null;
-
- /**
- * token names
- *
- * @var array
- */
- public $smarty_token_names = array( // Text for parser error messages
- 'NOT' => '(!,not)',
- 'OPENP' => '(',
- 'CLOSEP' => ')',
- 'OPENB' => '[',
- 'CLOSEB' => ']',
- 'PTR' => '->',
- 'APTR' => '=>',
- 'EQUAL' => '=',
- 'NUMBER' => 'number',
- 'UNIMATH' => '+" , "-',
- 'MATH' => '*" , "/" , "%',
- 'INCDEC' => '++" , "--',
- 'SPACE' => ' ',
- 'DOLLAR' => '$',
- 'SEMICOLON' => ';',
- 'COLON' => ':',
- 'DOUBLECOLON' => '::',
- 'AT' => '@',
- 'HATCH' => '#',
- 'QUOTE' => '"',
- 'BACKTICK' => '`',
- 'VERT' => '"|" modifier',
- 'DOT' => '.',
- 'COMMA' => '","',
- 'QMARK' => '"?"',
- 'ID' => 'id, name',
- 'TEXT' => 'text',
- 'LDELSLASH' => '{/..} closing tag',
- 'LDEL' => '{...} Smarty tag',
- 'COMMENT' => 'comment',
- 'AS' => 'as',
- 'TO' => 'to',
- 'PHP' => '"<?php", "<%", "{php}" tag',
- 'LOGOP' => '"<", "==" ... logical operator',
- 'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition',
- 'SCOND' => '"is even" ... if condition',
- );
-
- /**
- * constructor
- *
- * @param string $data template source
- * @param Smarty_Internal_TemplateCompilerBase $compiler
- */
- function __construct($data, Smarty_Internal_TemplateCompilerBase $compiler)
- {
- $this->data = $data;
- $this->counter = 0;
- if (preg_match('~^\xEF\xBB\xBF~i', $this->data, $match)) {
- $this->counter += strlen($match[0]);
- }
- $this->line = 1;
- $this->smarty = $compiler->smarty;
- $this->compiler = $compiler;
- $this->ldel = preg_quote($this->smarty->left_delimiter, '~');
- $this->ldel_length = strlen($this->smarty->left_delimiter);
- $this->rdel = preg_quote($this->smarty->right_delimiter, '~');
- $this->rdel_length = strlen($this->smarty->right_delimiter);
- $this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter;
- $this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter;
- }
-
- public function PrintTrace()
- {
- $this->yyTraceFILE = fopen('php://output', 'w');
- $this->yyTracePrompt = '<br>';
- }
-
- /*
- * Check if this tag is autoliteral
- */
- public function isAutoLiteral ()
- {
- return $this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false;
- }
-
- /*!lex2php
- %input $this->data
- %counter $this->counter
- %token $this->token
- %value $this->value
- %line $this->line
- linebreak = ~[\t ]*[\r\n]+[\t ]*~
- text = ~[\S\s]~
- textdoublequoted = ~([^"\\]*?)((?:\\.[^"\\]*?)*?)(?=(SMARTYldel|\$|`\$|"))~
- namespace = ~([0-9]*[a-zA-Z_]\w*)?(\\[0-9]*[a-zA-Z_]\w*)+~
- all = ~[\S\s]+~
- emptyjava = ~[{][}]~
- phpstart = ~(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*["']?\s*php\s*["']?\s*>)|([?][>])|([%][>])|(SMARTYldel\s*php(.*?)SMARTYrdel)|(SMARTYldel\s*[/]phpSMARTYrdel)~
- slash = ~[/]~
- ldel = ~SMARTYldel\s*~
- rdel = ~\s*SMARTYrdel~
- nocacherdel = ~(\s+nocache)?\s*SMARTYrdel~
- notblockid = ~(?:(?!block)[0-9]*[a-zA-Z_]\w*)~
- smartyblockchildparent = ~[\$]smarty\.block\.(child|parent)~
- integer = ~\d+~
- hex = ~0[xX][0-9a-fA-F]+~
- math = ~\s*([*]{1,2}|[%/^&]|[<>]{2})\s*~
- comment = ~SMARTYldel[*]~
- incdec = ~([+]|[-]){2}~
- unimath = ~\s*([+]|[-])\s*~
- openP = ~\s*[(]\s*~
- closeP = ~\s*[)]~
- openB = ~\[\s*~
- closeB = ~\s*\]~
- dollar = ~[$]~
- dot = ~[.]~
- comma = ~\s*[,]\s*~
- doublecolon = ~[:]{2}~
- colon = ~\s*[:]\s*~
- at = ~[@]~
- hatch = ~[#]~
- semicolon = ~\s*[;]\s*~
- equal = ~\s*[=]\s*~
- space = ~\s+~
- ptr = ~\s*[-][>]\s*~
- aptr = ~\s*[=][>]\s*~
- singlequotestring = ~'[^'\\]*(?:\\.[^'\\]*)*'~
- backtick = ~[`]~
- vert = ~[|]~
- qmark = ~\s*[?]\s*~
- constant = ~([_]+[A-Z0-9][0-9A-Z_]*|[A-Z][0-9A-Z_]*)(?![0-9A-Z_]*[a-z])~
- attr = ~\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\s*[=]\s*~
- id = ~[0-9]*[a-zA-Z_]\w*~
- literal = ~literal~
- strip = ~strip~
- lop = ~\s*(([!=][=]{1,2})|([<][=>]?)|([>][=]?)|[&|]{2})\s*~
- tlop = ~\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor|(is\s+(not\s+)?(odd|even|div)\s+by))\s+~
- scond = ~\s+is\s+(not\s+)?(odd|even)~
- isin = ~\s+is\s+in\s+~
- as = ~\s+as\s+~
- to = ~\s+to\s+~
- step = ~\s+step\s+~
- block = ~block~
- if = ~(if|elseif|else if|while)\s+~
- for = ~for\s+~
- foreach = ~foreach(?![^\s])~
- setfilter = ~setfilter\s+~
- instanceof = ~\s+instanceof\s+~
- not = ~([!]\s*)|(not\s+)~
- typecast = ~[(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\s*~
- double_quote = ~["]~
- single_quote = ~[']~
- */
- /*!lex2php
- %statename TEXT
- emptyjava {
- $this->token = Smarty_Internal_Templateparser::TP_TEXT;
- }
- comment {
- preg_match("~[*]{$this->rdel}~",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
- if (isset($match[0][1])) {
- $to = $match[0][1] + strlen($match[0][0]);
- } else {
- $this->compiler->trigger_template_error ("missing or misspelled comment closing tag '*{$this->smarty->right_delimiter}'");
- }
- $this->value = substr($this->data,$this->counter,$to-$this->counter);
- return false;
- }
- phpstart {
- $obj = new Smarty_Internal_Compile_Private_Php();
- $obj->parsePhp($this);
- }
- ldel literal rdel {
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_TEXT;
- } else {
- $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
- $this->yypushstate(self::LITERAL);
- }
- }
- ldel {
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_TEXT;
- } else {
- $this->yypushstate(self::TAG);
- return true;
- }
- }
- rdel {
- $this->token = Smarty_Internal_Templateparser::TP_TEXT;
- }
- text {
- $to = strlen($this->data);
- preg_match("~($this->ldel)|([<]script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*[>])|([<][?])|([<][%])|([?][>])|([%][>])~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
- if (isset($match[0][1])) {
- $to = $match[0][1];
- }
- $this->value = substr($this->data,$this->counter,$to-$this->counter);
- $this->token = Smarty_Internal_Templateparser::TP_TEXT;
- }
- */
- /*!lex2php
- %statename TAG
- ldel if {
- $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
- $this->yybegin(self::TAGBODY);
- $this->taglineno = $this->line;
- }
- ldel for {
- $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
- $this->yybegin(self::TAGBODY);
- $this->taglineno = $this->line;
- }
- ldel foreach {
- $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
- $this->yybegin(self::TAGBODY);
- $this->taglineno = $this->line;
- }
- ldel setfilter {
- $this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER;
- $this->yybegin(self::TAGBODY);
- $this->taglineno = $this->line;
- }
- ldel id nocacherdel {
- $this->yypopstate();
- $this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG;
- $this->taglineno = $this->line;
- }
- ldel slash notblockid rdel {
- $this->yypopstate();
- $this->token = Smarty_Internal_Templateparser::TP_CLOSETAG;
- $this->taglineno = $this->line;
- }
- ldel dollar id nocacherdel {
- if ($this->_yy_stack[count($this->_yy_stack)-1] == self::TEXT) {
- $this->yypopstate();
- $this->token = Smarty_Internal_Templateparser::TP_SIMPLEOUTPUT;
- $this->taglineno = $this->line;
- } else {
- $this->value = $this->smarty->left_delimiter;
- $this->token = Smarty_Internal_Templateparser::TP_LDEL;
- $this->yybegin(self::TAGBODY);
- $this->taglineno = $this->line;
- }
- }
- ldel slash {
- $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
- $this->yybegin(self::TAGBODY);
- $this->taglineno = $this->line;
- }
- ldel {
- $this->token = Smarty_Internal_Templateparser::TP_LDEL;
- $this->yybegin(self::TAGBODY);
- $this->taglineno = $this->line;
- }
- */
- /*!lex2php
- %statename TAGBODY
- rdel {
- $this->token = Smarty_Internal_Templateparser::TP_RDEL;
- $this->yypopstate();
- }
- double_quote {
- $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
- $this->yypushstate(self::DOUBLEQUOTEDSTRING);
- }
- singlequotestring {
- $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
- }
- smartyblockchildparent {
- $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT;
- $this->taglineno = $this->line;
- }
- dollar id {
- $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
- }
- dollar {
- $this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
- }
- isin {
- $this->token = Smarty_Internal_Templateparser::TP_ISIN;
- }
- as {
- $this->token = Smarty_Internal_Templateparser::TP_AS;
- }
- to {
- $this->token = Smarty_Internal_Templateparser::TP_TO;
- }
- step {
- $this->token = Smarty_Internal_Templateparser::TP_STEP;
- }
- instanceof {
- $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
- }
- lop {
- $this->token = Smarty_Internal_Templateparser::TP_LOGOP;
- }
- tlop {
- $this->token = Smarty_Internal_Templateparser::TP_TLOGOP;
- }
- scond {
- $this->token = Smarty_Internal_Templateparser::TP_SINGLECOND;
- }
- not{
- $this->token = Smarty_Internal_Templateparser::TP_NOT;
- }
- typecast {
- $this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
- }
- openP {
- $this->token = Smarty_Internal_Templateparser::TP_OPENP;
- }
- closeP {
- $this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
- }
- openB {
- $this->token = Smarty_Internal_Templateparser::TP_OPENB;
- }
- closeB {
- $this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
- }
- ptr {
- $this->token = Smarty_Internal_Templateparser::TP_PTR;
- }
- aptr {
- $this->token = Smarty_Internal_Templateparser::TP_APTR;
- }
- equal {
- $this->token = Smarty_Internal_Templateparser::TP_EQUAL;
- }
- incdec {
- $this->token = Smarty_Internal_Templateparser::TP_INCDEC;
- }
- unimath {
- $this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
- }
- math {
- $this->token = Smarty_Internal_Templateparser::TP_MATH;
- }
- at {
- $this->token = Smarty_Internal_Templateparser::TP_AT;
- }
- hatch {
- $this->token = Smarty_Internal_Templateparser::TP_HATCH;
- }
- attr {
- // resolve conflicts with shorttag and right_delimiter starting with '='
- if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) == $this->smarty->right_delimiter) {
- preg_match("~\s+~",$this->value,$match);
- $this->value = $match[0];
- $this->token = Smarty_Internal_Templateparser::TP_SPACE;
- } else {
- $this->token = Smarty_Internal_Templateparser::TP_ATTR;
- }
- }
- namespace {
- $this->token = Smarty_Internal_Templateparser::TP_NAMESPACE;
- }
- id {
- $this->token = Smarty_Internal_Templateparser::TP_ID;
- }
- integer {
- $this->token = Smarty_Internal_Templateparser::TP_INTEGER;
- }
- backtick {
- $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
- $this->yypopstate();
- }
- vert {
- $this->token = Smarty_Internal_Templateparser::TP_VERT;
- }
- dot {
- $this->token = Smarty_Internal_Templateparser::TP_DOT;
- }
- comma {
- $this->token = Smarty_Internal_Templateparser::TP_COMMA;
- }
- semicolon {
- $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
- }
- doublecolon {
- $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
- }
- colon {
- $this->token = Smarty_Internal_Templateparser::TP_COLON;
- }
- qmark {
- $this->token = Smarty_Internal_Templateparser::TP_QMARK;
- }
- hex {
- $this->token = Smarty_Internal_Templateparser::TP_HEX;
- }
- space {
- $this->token = Smarty_Internal_Templateparser::TP_SPACE;
- }
- ldel {
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_TEXT;
- } else {
- $this->yypushstate(self::TAG);
- return true;
- }
- }
- text {
- $this->token = Smarty_Internal_Templateparser::TP_TEXT;
- }
- */
-
- /*!lex2php
- %statename LITERAL
- ldel literal rdel {
- $this->literal_cnt++;
- $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
- }
- ldel slash literal rdel {
- if ($this->literal_cnt) {
- $this->literal_cnt--;
- $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
- } else {
- $this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
- $this->yypopstate();
- }
- }
- text {
- $to = strlen($this->data);
- preg_match("~{$this->ldel}[/]?literal{$this->rdel}~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
- if (isset($match[0][1])) {
- $to = $match[0][1];
- } else {
- $this->compiler->trigger_template_error ("missing or misspelled literal closing tag");
- }
- $this->value = substr($this->data,$this->counter,$to-$this->counter);
- $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
- }
- */
- /*!lex2php
- %statename DOUBLEQUOTEDSTRING
- ldel literal rdel {
- $this->token = Smarty_Internal_Templateparser::TP_TEXT;
- }
- ldel slash literal rdel {
- $this->token = Smarty_Internal_Templateparser::TP_TEXT;
- }
- ldel slash {
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_TEXT;
- } else {
- $this->yypushstate(self::TAG);
- return true;
- }
- }
- ldel id {
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_TEXT;
- } else {
- $this->yypushstate(self::TAG);
- return true;
- }
- }
- ldel {
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_TEXT;
- } else {
- $this->token = Smarty_Internal_Templateparser::TP_LDEL;
- $this->taglineno = $this->line;
- $this->yypushstate(self::TAGBODY);
- }
- }
- double_quote {
- $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
- $this->yypopstate();
- }
- backtick dollar {
- $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
- $this->value = substr($this->value,0,-1);
- $this->yypushstate(self::TAGBODY);
- $this->taglineno = $this->line;
- }
- dollar id {
- $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
- }
- dollar {
- $this->token = Smarty_Internal_Templateparser::TP_TEXT;
- }
- textdoublequoted {
- $this->token = Smarty_Internal_Templateparser::TP_TEXT;
- }
- text {
- $to = strlen($this->data);
- $this->value = substr($this->data,$this->counter,$to-$this->counter);
- $this->token = Smarty_Internal_Templateparser::TP_TEXT;
- }
- */
- /*!lex2php
- %statename CHILDBODY
- ldel strip rdel {
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- return false;
- } else {
- $this->token = Smarty_Internal_Templateparser::TP_STRIPON;
- }
- }
- ldel slash strip rdel {
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- return false;
- } else {
- $this->token = Smarty_Internal_Templateparser::TP_STRIPOFF;
- }
- }
- ldel block {
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- return false;
- } else {
- $this->yypopstate();
- return true;
- }
- }
- text {
- $to = strlen($this->data);
- preg_match("~SMARTYldel\s*(([/])?strip\s*SMARTYrdel|block\s+)~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
- if (isset($match[0][1])) {
- $to = $match[0][1];
- }
- $this->value = substr($this->data,$this->counter,$to-$this->counter);
- return false;
- }
-
- */
- /*!lex2php
- %statename CHILDBLOCK
- ldel literal rdel {
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- } else {
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- $this->yypushstate(self::CHILDLITERAL);
- }
- }
- ldel block {
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- } else {
- $this->yypopstate();
- return true;
- }
- }
- ldel slash block {
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- } else {
- $this->yypopstate();
- return true;
- }
- }
- ldel smartyblockchildparent {
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- } else {
- $this->yypopstate();
- return true;
- }
- }
- text {
- $to = strlen($this->data);
- preg_match("~SMARTYldel\s*(literal\s*SMARTYrdel|([/])?block(\s|SMARTYrdel)|[\$]smarty\.block\.(child|parent))~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
- if (isset($match[0][1])) {
- $to = $match[0][1];
- }
- $this->value = substr($this->data,$this->counter,$to-$this->counter);
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- }
- */
- /*!lex2php
- %statename CHILDLITERAL
- ldel literal rdel {
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- } else {
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- $this->yypushstate(self::CHILDLITERAL);
- }
- }
- ldel slash literal rdel {
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- } else {
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- $this->yypopstate();
- }
- }
- text {
- $to = strlen($this->data);
- preg_match("~{$this->ldel}[/]?literal\s*{$this->rdel}~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
- if (isset($match[0][1])) {
- $to = $match[0][1];
- } else {
- $this->compiler->trigger_template_error ("missing or misspelled literal closing tag");
- }
- $this->value = substr($this->data,$this->counter,$to-$this->counter);
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- }
- */
- }
-
- \ No newline at end of file
diff --git a/library/Smarty/lexer/smarty_internal_templateparser.y b/library/Smarty/lexer/smarty_internal_templateparser.y
deleted file mode 100644
index 225f71b24..000000000
--- a/library/Smarty/lexer/smarty_internal_templateparser.y
+++ /dev/null
@@ -1,1329 +0,0 @@
-/**
-* Smarty Internal Plugin Templateparser
-*
-* This is the template parser
-*
-*
-* @package Smarty
-* @subpackage Compiler
-* @author Uwe Tews
-*/
-%stack_size 500
-%name TP_
-%declare_class {
-/**
-* Smarty Internal Plugin Templateparser
-*
-* This is the template parser.
-* It is generated from the smarty_internal_templateparser.y file
-* @package Smarty
-* @subpackage Compiler
-* @author Uwe Tews
-*/
-class Smarty_Internal_Templateparser
-}
-%include_class
-{
- const Err1 = "Security error: Call to private object member not allowed";
- const Err2 = "Security error: Call to dynamic object member not allowed";
- const Err3 = "PHP in template not allowed. Use SmartyBC to enable it";
-
- /**
- * result status
- *
- * @var bool
- */
- public $successful = true;
- /**
- * return value
- *
- * @var mixed
- */
- public $retvalue = 0;
- /**
- * counter for prefix code
- *
- * @var int
- */
- public static $prefix_number = 0;
- /**
- * @var
- */
- public $yymajor;
- /**
- * last index of array variable
- *
- * @var mixed
- */
- public $last_index;
- /**
- * last variable name
- *
- * @var string
- */
- public $last_variable;
- /**
- * root parse tree buffer
- *
- * @var Smarty_Internal_ParseTree
- */
- public $root_buffer;
- /**
- * current parse tree object
- *
- * @var Smarty_Internal_ParseTree
- */
- public $current_buffer;
- /**
- * lexer object
- *
- * @var Smarty_Internal_Templatelexer
- */
- private $lex;
- /**
- * internal error flag
- *
- * @var bool
- */
- private $internalError = false;
- /**
- * {strip} status
- *
- * @var bool
- */
- public $strip = false;
- /**
- * compiler object
- *
- * @var Smarty_Internal_TemplateCompilerBase
- */
- public $compiler = null;
- /**
- * smarty object
- *
- * @var Smarty
- */
- public $smarty = null;
- /**
- * template object
- *
- * @var Smarty_Internal_Template
- */
- public $template = null;
- /**
- * block nesting level
- *
- * @var int
- */
- public $block_nesting_level = 0;
-
- /**
- * security object
- *
- * @var Smarty_Security
- */
- private $security = null;
-
- /**
- * constructor
- *
- * @param Smarty_Internal_Templatelexer $lex
- * @param Smarty_Internal_TemplateCompilerBase $compiler
- */
- function __construct(Smarty_Internal_Templatelexer $lex, Smarty_Internal_TemplateCompilerBase $compiler)
- {
- $this->lex = $lex;
- $this->compiler = $compiler;
- $this->template = $this->compiler->template;
- $this->smarty = $this->template->smarty;
- $this->security = isset($this->smarty->security_policy) ? $this->smarty->security_policy : false;
- $this->current_buffer = $this->root_buffer = new Smarty_Internal_ParseTree_Template($this);
- }
-
- /**
- * insert PHP code in current buffer
- *
- * @param string $code
- */
- public function insertPhpCode($code)
- {
- $this->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($this, $code));
- }
-
- /**
- * merge PHP code with prefix code and return parse tree tag object
- *
- * @param string $code
- *
- * @return Smarty_Internal_ParseTree_Tag
- */
- public function mergePrefixCode($code)
- {
- $tmp ='';
- foreach ($this->compiler->prefix_code as $preCode) {
- $tmp = empty($tmp) ? $preCode : $this->compiler->appendCode($tmp, $preCode);
- }
- $this->compiler->prefix_code=array();
- $tmp = empty($tmp) ? $code : $this->compiler->appendCode($tmp, $code);
- return new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode($tmp,true));
- }
-
-}
-
-%token_prefix TP_
-
-%parse_accept
-{
- $this->successful = !$this->internalError;
- $this->internalError = false;
- $this->retvalue = $this->_retvalue;
-}
-
-%syntax_error
-{
- $this->internalError = true;
- $this->yymajor = $yymajor;
- $this->compiler->trigger_template_error();
-}
-
-%stack_overflow
-{
- $this->internalError = true;
- $this->compiler->trigger_template_error("Stack overflow in template parser");
-}
-
-%left VERT.
-%left COLON.
-
- //
- // complete template
- //
-start(res) ::= template. {
- res = $this->root_buffer->to_smarty_php();
-}
-
- //
- // loop over template elements
- //
- // single template element
-template ::= template_element(e). {
- if (e != null) {
- $this->current_buffer->append_subtree(e);
- }
-}
-
- // loop of elements
-template ::= template template_element(e). {
- if (e != null) {
- // because of possible code injection
- $this->current_buffer->append_subtree(e);
- }
-}
-
- // empty template
-template ::= .
-
-//
-// template elements
-//
- // Smarty tag
-template_element(res)::= smartytag(st). {
- if ($this->compiler->has_code) {
- res = $this->mergePrefixCode(st);
- } else {
- res = null;
- }
- $this->compiler->has_variable_string = false;
- $this->block_nesting_level = count($this->compiler->_tag_stack);
-}
-
- // Literal
-template_element(res) ::= literal(l). {
- res = new Smarty_Internal_ParseTree_Text($this, l);
-}
- // php tags
-template_element(res)::= PHP(o). {
- $code = $this->compiler->compileTag('private_php',array(array('code' => o), array('type' => $this->lex->phpType )),array());
- if ($this->compiler->has_code && !empty($code)) {
- $tmp =''; foreach ($this->compiler->prefix_code as $code) {$tmp.=$code;} $this->compiler->prefix_code=array();
- res = new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode($tmp.$code,true));
- } else {
- res = null;
- }
-}
-
- // nocache code
-template_element(res)::= NOCACHE(c). {
- $this->compiler->tag_nocache = true;
- $save = $this->template->has_nocache_code;
- res = new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode("<?php echo '{c}';?>\n", $this->compiler, true));
- $this->template->has_nocache_code = $save;
-}
- // template text
-template_element(res)::= text_content(t). {
- res = $this->compiler->processText(t);
-}
-
-text_content(res) ::= TEXT(o). {
- res = o;
-}
-
-text_content(res) ::= text_content(t) TEXT(o). {
- res = t . o;
-}
-
- // strip on
-template_element ::= STRIPON(d). {
- $this->strip = true;
-}
- // strip off
-template_element ::= STRIPOFF(d). {
- $this->strip = false;
-}
- // process source of inheritance child block
-template_element ::= BLOCKSOURCE(s). {
- if ($this->strip) {
- SMARTY_INTERNAL_COMPILE_BLOCK::blockSource($this->compiler, preg_replace('![\t ]*[\r\n]+[\t ]*!', '', s));
- } else {
- SMARTY_INTERNAL_COMPILE_BLOCK::blockSource($this->compiler, s);
- }
-}
-
- // Litteral
-literal(res) ::= LITERALSTART LITERALEND. {
- res = '';
-}
-
-literal(res) ::= LITERALSTART literal_elements(l) LITERALEND. {
- res = l;
-}
-
-literal_elements(res) ::= literal_elements(l1) literal_element(l2). {
- res = l1.l2;
-}
-
-literal_elements(res) ::= . {
- res = '';
-}
-
-literal_element(res) ::= literal(l). {
- res = l;
-}
-
-literal_element(res) ::= LITERAL(l). {
- res = l;
-}
-
-smartytag(res) ::= tag(t) RDEL. {
- res = t;
-}
-//
-// output tags start here
-//
-smartytag(res) ::= SIMPLEOUTPUT(i). {
- $var = trim(substr(i, $this->lex->ldel_length, -$this->lex->rdel_length), ' $');
- if (preg_match('/^(.*)(\s+nocache)$/', $var, $match)) {
- res = $this->compiler->compileTag('private_print_expression',array('nocache'),array('value'=>$this->compiler->compileVariable('\''.$match[1].'\'')));
- } else {
- res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>$this->compiler->compileVariable('\''.$var.'\'')));
- }
-}
-
- // output with optional attributes
-tag(res) ::= LDEL variable(e). {
- res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>e));
-}
-
-tag(res) ::= LDEL variable(e) attributes(a). {
- res = $this->compiler->compileTag('private_print_expression',a,array('value'=>e));
-}
-tag(res) ::= LDEL value(e). {
- res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>e));
-}
-tag(res) ::= LDEL value(e) attributes(a). {
- res = $this->compiler->compileTag('private_print_expression',a,array('value'=>e));
-}
-
-tag(res) ::= LDEL expr(e). {
- res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>e));
-}
-
-tag(res) ::= LDEL expr(e) attributes(a). {
- res = $this->compiler->compileTag('private_print_expression',a,array('value'=>e));
-}
-
-//
-// Smarty tags start here
-//
-
- // assign new style
-tag(res) ::= LDEL DOLLARID(i) EQUAL value(e). {
- res = $this->compiler->compileTag('assign',array(array('value'=>e),array('var'=>'\''.substr(i,1).'\'')));
-}
-
-tag(res) ::= LDEL DOLLARID(i) EQUAL expr(e). {
- res = $this->compiler->compileTag('assign',array(array('value'=>e),array('var'=>'\''.substr(i,1).'\'')));
-}
-
-tag(res) ::= LDEL DOLLARID(i) EQUAL expr(e) attributes(a). {
- res = $this->compiler->compileTag('assign',array_merge(array(array('value'=>e),array('var'=>'\''.substr(i,1).'\'')),a));
-}
-
-tag(res) ::= LDEL varindexed(vi) EQUAL expr(e) attributes(a). {
- res = $this->compiler->compileTag('assign',array_merge(array(array('value'=>e),array('var'=>vi['var'])),a),array('smarty_internal_index'=>vi['smarty_internal_index']));
-}
-
-// simple tag like {name}
-smartytag(res)::= SIMPLETAG(t). {
- $tag = trim(substr(t, $this->lex->ldel_length, -$this->lex->rdel_length));
- if ($tag == 'strip') {
- $this->strip = true;
- res = null;;
- } else {
- if (defined($tag)) {
- if ($this->security) {
- $this->security->isTrustedConstant($tag, $this->compiler);
- }
- res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>$tag));
- } else {
- if (preg_match('/^(.*)(\s+nocache)$/', $tag, $match)) {
- res = $this->compiler->compileTag($match[1],array("'nocache'"));
- } else {
- res = $this->compiler->compileTag($tag,array());
- }
- }
- }
-}
-
- // tag with optional Smarty2 style attributes
-tag(res) ::= LDEL ID(i) attributes(a). {
- if (defined(i)) {
- if ($this->security) {
- $this->security->isTrustedConstant(i, $this->compiler);
- }
- res = $this->compiler->compileTag('private_print_expression',a,array('value'=>i));
- } else {
- res = $this->compiler->compileTag(i,a);
- }
-}
-tag(res) ::= LDEL ID(i). {
- if (defined(i)) {
- if ($this->security) {
- $this->security->isTrustedConstant(i, $this->compiler);
- }
- res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>i));
- } else {
- res = $this->compiler->compileTag(i,array());
- }
-}
-
-
- // tag with modifier and optional Smarty2 style attributes
-tag(res) ::= LDEL ID(i) modifierlist(l)attributes(a). {
- if (defined(i)) {
- if ($this->security) {
- $this->security->isTrustedConstant(i, $this->compiler);
- }
- res = $this->compiler->compileTag('private_print_expression',a,array('value'=>i, 'modifierlist'=>l));
- } else {
- res = '<?php ob_start();?>'.$this->compiler->compileTag(i,a).'<?php echo ';
- res .= $this->compiler->compileTag('private_modifier',array(),array('modifierlist'=>l,'value'=>'ob_get_clean()')).';?>';
- }
-}
-
- // registered object tag
-tag(res) ::= LDEL ID(i) PTR ID(m) attributes(a). {
- res = $this->compiler->compileTag(i,a,array('object_method'=>m));
-}
-
- // registered object tag with modifiers
-tag(res) ::= LDEL ID(i) PTR ID(me) modifierlist(l) attributes(a). {
- res = '<?php ob_start();?>'.$this->compiler->compileTag(i,a,array('object_method'=>me)).'<?php echo ';
- res .= $this->compiler->compileTag('private_modifier',array(),array('modifierlist'=>l,'value'=>'ob_get_clean()')).';?>';
-}
-
- // {if}, {elseif} and {while} tag
-tag(res) ::= LDELIF(i) expr(ie). {
- $tag = trim(substr(i,$this->lex->ldel_length));
- res = $this->compiler->compileTag(($tag == 'else if')? 'elseif' : $tag,array(),array('if condition'=>ie));
-}
-
-tag(res) ::= LDELIF(i) expr(ie) attributes(a). {
- $tag = trim(substr(i,$this->lex->ldel_length));
- res = $this->compiler->compileTag(($tag == 'else if')? 'elseif' : $tag,a,array('if condition'=>ie));
-}
-
-tag(res) ::= LDELIF(i) statement(ie). {
- $tag = trim(substr(i,$this->lex->ldel_length));
- res = $this->compiler->compileTag(($tag == 'else if')? 'elseif' : $tag,array(),array('if condition'=>ie));
-}
-
-tag(res) ::= LDELIF(i) statement(ie) attributes(a). {
- $tag = trim(substr(i,$this->lex->ldel_length));
- res = $this->compiler->compileTag(($tag == 'else if')? 'elseif' : $tag,a,array('if condition'=>ie));
-}
-
- // {for} tag
-tag(res) ::= LDELFOR statements(st) SEMICOLON expr(ie) SEMICOLON varindexed(v2) foraction(e2) attributes(a). {
- res = $this->compiler->compileTag('for',array_merge(a,array(array('start'=>st),array('ifexp'=>ie),array('var'=>v2),array('step'=>e2))),1);
-}
-
- foraction(res) ::= EQUAL expr(e). {
- res = '='.e;
-}
-
- foraction(res) ::= INCDEC(e). {
- res = e;
-}
-
-tag(res) ::= LDELFOR statement(st) TO expr(v) attributes(a). {
- res = $this->compiler->compileTag('for',array_merge(a,array(array('start'=>st),array('to'=>v))),0);
-}
-
-tag(res) ::= LDELFOR statement(st) TO expr(v) STEP expr(v2) attributes(a). {
- res = $this->compiler->compileTag('for',array_merge(a,array(array('start'=>st),array('to'=>v),array('step'=>v2))),0);
-}
-
- // {foreach} tag
-tag(res) ::= LDELFOREACH attributes(a). {
- res = $this->compiler->compileTag('foreach',a);
-}
-
- // {foreach $array as $var} tag
-tag(res) ::= LDELFOREACH SPACE value(v1) AS varvar(v0) attributes(a). {
- res = $this->compiler->compileTag('foreach',array_merge(a,array(array('from'=>v1),array('item'=>v0))));
-}
-
-tag(res) ::= LDELFOREACH SPACE value(v1) AS varvar(v2) APTR varvar(v0) attributes(a). {
- res = $this->compiler->compileTag('foreach',array_merge(a,array(array('from'=>v1),array('item'=>v0),array('key'=>v2))));
-}
-
-tag(res) ::= LDELFOREACH SPACE expr(e) AS varvar(v0) attributes(a). {
- res = $this->compiler->compileTag('foreach',array_merge(a,array(array('from'=>e),array('item'=>v0))));
-}
-
-tag(res) ::= LDELFOREACH SPACE expr(e) AS varvar(v1) APTR varvar(v0) attributes(a). {
- res = $this->compiler->compileTag('foreach',array_merge(a,array(array('from'=>e),array('item'=>v0),array('key'=>v1))));
-}
-
- // {setfilter}
-tag(res) ::= LDELSETFILTER ID(m) modparameters(p). {
- res = $this->compiler->compileTag('setfilter',array(),array('modifier_list'=>array(array_merge(array(m),p))));
-}
-
-tag(res) ::= LDELSETFILTER ID(m) modparameters(p) modifierlist(l). {
- res = $this->compiler->compileTag('setfilter',array(),array('modifier_list'=>array_merge(array(array_merge(array(m),p)),l)));
-}
-
- // {$smarty.block.child} or {$smarty.block.parent}
-tag(res) ::= LDEL SMARTYBLOCKCHILDPARENT(i). {
- $j = strrpos(i,'.');
- if (i[$j+1] == 'c') {
- // {$smarty.block.child}
- res = SMARTY_INTERNAL_COMPILE_BLOCK::compileChildBlock($this->compiler);
- } else {
- // {$smarty.block.parent}
- res = SMARTY_INTERNAL_COMPILE_BLOCK::compileParentBlock($this->compiler);
- }
-}
-
-
- // end of block tag {/....}
-smartytag(res)::= CLOSETAG(t). {
- $tag = trim(substr(t, $this->lex->ldel_length, -$this->lex->rdel_length), ' /');
- if ($tag == 'strip') {
- $this->strip = false;
- res = null;
- } else {
- res = $this->compiler->compileTag($tag.'close',array());
- }
- }
-tag(res) ::= LDELSLASH ID(i). {
- res = $this->compiler->compileTag(i.'close',array());
-}
-
-tag(res) ::= LDELSLASH ID(i) modifierlist(l). {
- res = $this->compiler->compileTag(i.'close',array(),array('modifier_list'=>l));
-}
-
- // end of block object tag {/....}
-tag(res) ::= LDELSLASH ID(i) PTR ID(m). {
- res = $this->compiler->compileTag(i.'close',array(),array('object_method'=>m));
-}
-
-tag(res) ::= LDELSLASH ID(i) PTR ID(m) modifierlist(l). {
- res = $this->compiler->compileTag(i.'close',array(),array('object_method'=>m, 'modifier_list'=>l));
-}
-
-//
-//Attributes of Smarty tags
-//
- // list of attributes
-attributes(res) ::= attributes(a1) attribute(a2). {
- res = a1;
- res[] = a2;
-}
-
- // single attribute
-attributes(res) ::= attribute(a). {
- res = array(a);
-}
-
- // no attributes
-attributes(res) ::= . {
- res = array();
-}
-
- // attribute
-attribute(res) ::= SPACE ID(v) EQUAL ID(id). {
- if (defined(id)) {
- if ($this->security) {
- $this->security->isTrustedConstant(id, $this->compiler);
- }
- res = array(v=>id);
- } else {
- res = array(v=>'\''.id.'\'');
- }
-}
-
-attribute(res) ::= ATTR(v) expr(e). {
- res = array(trim(v," =\n\r\t")=>e);
-}
-
-attribute(res) ::= ATTR(v) value(e). {
- res = array(trim(v," =\n\r\t")=>e);
-}
-
-attribute(res) ::= SPACE ID(v). {
- res = '\''.v.'\'';
-}
-
-attribute(res) ::= SPACE expr(e). {
- res = e;
-}
-
-attribute(res) ::= SPACE value(v). {
- res = v;
-}
-
-attribute(res) ::= SPACE INTEGER(i) EQUAL expr(e). {
- res = array(i=>e);
-}
-
-
-
-//
-// statement
-//
-statements(res) ::= statement(s). {
- res = array(s);
-}
-
-statements(res) ::= statements(s1) COMMA statement(s). {
- s1[]=s;
- res = s1;
-}
-
-statement(res) ::= DOLLARID(i) EQUAL INTEGER(e). {
- res = array('var' => '\''.substr(i,1).'\'', 'value'=>e);
-}
-statement(res) ::= DOLLARID(i) EQUAL expr(e). {
- res = array('var' => '\''.substr(i,1).'\'', 'value'=>e);
-}
-
-statement(res) ::= varindexed(vi) EQUAL expr(e). {
- res = array('var' => vi, 'value'=>e);
-}
-
-statement(res) ::= OPENP statement(st) CLOSEP. {
- res = st;
-}
-
-
-//
-// expressions
-//
-
- // single value
-expr(res) ::= value(v). {
- res = v;
-}
-
- // ternary
-expr(res) ::= ternary(v). {
- res = v;
-}
-
- // resources/streams
-expr(res) ::= DOLLARID(i) COLON ID(i2). {
- res = '$_smarty_tpl->getStreamVariable(\''.substr(i,1).'://' . i2 . '\')';
-}
-
- // arithmetic expression
-expr(res) ::= expr(e) MATH(m) value(v). {
- res = e . trim(m) . v;
-}
-
-expr(res) ::= expr(e) UNIMATH(m) value(v). {
- res = e . trim(m) . v;
-}
-
- // array
-expr(res) ::= array(a). {
- res = a;
-}
-
- // modifier
-expr(res) ::= expr(e) modifierlist(l). {
- res = $this->compiler->compileTag('private_modifier',array(),array('value'=>e,'modifierlist'=>l));
-}
-
-// if expression
- // simple expression
-expr(res) ::= expr(e1) lop(c) expr(e2). {
- res = (isset(c['pre']) ? c['pre'] : '') . e1.c['op'].e2 . (isset(c['pre']) ? ')' : '');
-}
-expr(res) ::= expr(e1) scond(c). {
- res = c . e1 . ')';
-}
-
-expr(res) ::= expr(e1) ISIN array(a). {
- res = 'in_array('.e1.','.a.')';
-}
-
-expr(res) ::= expr(e1) ISIN value(v). {
- res = 'in_array('.e1.',(array)'.v.')';
-}
-
-expr(res) ::= variable(v1) INSTANCEOF(i) ns1(v2). {
- res = v1.i.v2;
-}
-
-
-//
-// ternary
-//
-ternary(res) ::= OPENP expr(v) CLOSEP QMARK DOLLARID(e1) COLON expr(e2). {
- res = v.' ? '. $this->compiler->compileVariable('\''.substr(e1,1).'\'') . ' : '.e2;
-}
-
-ternary(res) ::= OPENP expr(v) CLOSEP QMARK expr(e1) COLON expr(e2). {
- res = v.' ? '.e1.' : '.e2;
-}
-
- // value
-value(res) ::= variable(v). {
- res = v;
-}
-
- // +/- value
-value(res) ::= UNIMATH(m) value(v). {
- res = m.v;
-}
-
- // logical negation
-value(res) ::= NOT value(v). {
- res = '!'.v;
-}
-
-value(res) ::= TYPECAST(t) value(v). {
- res = t.v;
-}
-
-value(res) ::= variable(v) INCDEC(o). {
- res = v.o;
-}
-
- // numeric
-value(res) ::= HEX(n). {
- res = n;
-}
-
-value(res) ::= INTEGER(n). {
- res = n;
-}
-
-value(res) ::= INTEGER(n1) DOT INTEGER(n2). {
- res = n1.'.'.n2;
-}
-
-value(res) ::= INTEGER(n1) DOT. {
- res = n1.'.';
-}
-
-value(res) ::= DOT INTEGER(n1). {
- res = '.'.n1;
-}
-
- // ID, true, false, null
-value(res) ::= ID(id). {
- if (defined(id)) {
- if ($this->security) {
- $this->security->isTrustedConstant(id, $this->compiler);
- }
- res = id;
- } else {
- res = '\''.id.'\'';
- }
-}
-
- // function call
-value(res) ::= function(f). {
- res = f;
-}
-
- // expression
-value(res) ::= OPENP expr(e) CLOSEP. {
- res = "(". e .")";
-}
-
- // singele quoted string
-value(res) ::= SINGLEQUOTESTRING(t). {
- res = t;
-}
-
- // double quoted string
-value(res) ::= doublequoted_with_quotes(s). {
- res = s;
-}
-
-
-value(res) ::= varindexed(vi) DOUBLECOLON static_class_access(r). {
- self::$prefix_number++;
- if (vi['var'] == '\'smarty\'') {
- $this->compiler->prefix_code[] = '<?php $_tmp'.self::$prefix_number.' = '. $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']).';?>';
- } else {
- $this->compiler->prefix_code[] = '<?php $_tmp'.self::$prefix_number.' = '. $this->compiler->compileVariable(vi['var']).vi['smarty_internal_index'].';?>';
- }
- res = '$_tmp'.self::$prefix_number.'::'.r[0].r[1];
-}
-
- // Smarty tag
-value(res) ::= smartytag(st). {
- self::$prefix_number++;
- $tmp = $this->compiler->appendCode('<?php ob_start();?>', st);
- $this->compiler->prefix_code[] = $this->compiler->appendCode($tmp, '<?php $_tmp'.self::$prefix_number.'=ob_get_clean();?>');
- res = '$_tmp'.self::$prefix_number;
-}
-
-value(res) ::= value(v) modifierlist(l). {
- res = $this->compiler->compileTag('private_modifier',array(),array('value'=>v,'modifierlist'=>l));
-}
- // name space constant
-value(res) ::= NAMESPACE(c). {
- res = c;
-}
-
-
- // static class access
-value(res) ::= ns1(c)DOUBLECOLON static_class_access(s). {
- if (!in_array(strtolower(c), array('self', 'parent')) && (!$this->security || $this->security->isTrustedStaticClassAccess(c, s, $this->compiler))) {
- if (isset($this->smarty->registered_classes[c])) {
- res = $this->smarty->registered_classes[c].'::'.s[0].s[1];
- } else {
- res = c.'::'.s[0].s[1];
- }
- } else {
- $this->compiler->trigger_template_error ("static class '".c."' is undefined or not allowed by security setting");
- }
-}
-//
-// namespace stuff
-//
-
-ns1(res) ::= ID(i). {
- res = i;
-}
-
-ns1(res) ::= NAMESPACE(i). {
- res = i;
-}
-
-//ns1(res) ::= variable(v). {
-// res = v;
-//}
-
-
-
-
-//
-// variables
-//
- // Smarty variable (optional array)
-variable(res) ::= DOLLARID(i). {
- res = $this->compiler->compileVariable('\''.substr(i,1).'\'');
-}
-variable(res) ::= varindexed(vi). {
- if (vi['var'] == '\'smarty\'') {
- $smarty_var = $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']);
- res = $smarty_var;
- } else {
- // used for array reset,next,prev,end,current
- $this->last_variable = vi['var'];
- $this->last_index = vi['smarty_internal_index'];
- res = $this->compiler->compileVariable(vi['var']).vi['smarty_internal_index'];
- }
-}
-
- // variable with property
-variable(res) ::= varvar(v) AT ID(p). {
- res = '$_smarty_tpl->tpl_vars['. v .']->'.p;
-}
-
- // object
-variable(res) ::= object(o). {
- res = o;
-}
-
- // config variable
-variable(res) ::= HATCH ID(i) HATCH. {
- res = '$_smarty_tpl->getConfigVariable( \''. i .'\')';
-}
-
-variable(res) ::= HATCH ID(i) HATCH arrayindex(a). {
- res = '(is_array($tmp = $_smarty_tpl->getConfigVariable( \''. i .'\')) ? $tmp'.a.' :null)';
-}
-
-variable(res) ::= HATCH variable(v) HATCH. {
- res = '$_smarty_tpl->getConfigVariable( '. v .')';
-}
-
-variable(res) ::= HATCH variable(v) HATCH arrayindex(a). {
- res = '(is_array($tmp = $_smarty_tpl->getConfigVariable( '. v .')) ? $tmp'.a.' : null)';
-}
-
-varindexed(res) ::= DOLLARID(i) arrayindex(a). {
- res = array('var'=>'\''.substr(i,1).'\'', 'smarty_internal_index'=>a);
-}
-varindexed(res) ::= varvar(v) arrayindex(a). {
- res = array('var'=>v, 'smarty_internal_index'=>a);
-}
-
-//
-// array index
-//
- // multiple array index
-arrayindex(res) ::= arrayindex(a1) indexdef(a2). {
- res = a1.a2;
-}
-
- // no array index
-arrayindex ::= . {
- return;
-}
-
-// single index definition
- // Smarty2 style index
-indexdef(res) ::= DOT DOLLARID(i). {
- res = '['.$this->compiler->compileVariable('\''.substr(i,1).'\'').']';
-}
-indexdef(res) ::= DOT varvar(v). {
- res = '['.$this->compiler->compileVariable(v).']';
-}
-
-indexdef(res) ::= DOT varvar(v) AT ID(p). {
- res = '['.$this->compiler->compileVariable(v).'->'.p.']';
-}
-
-indexdef(res) ::= DOT ID(i). {
- if (defined(i)) {
- if ($this->security) {
- $this->security->isTrustedConstant(i, $this->compiler);
- }
- res = '['. i .']';
- } else {
- res = "['". i ."']";
- }
-}
-
-indexdef(res) ::= DOT INTEGER(n). {
- res = '['. n .']';
-}
-
-indexdef(res) ::= DOT LDEL expr(e) RDEL. {
- res = '['. e .']';
-}
-
- // section tag index
-indexdef(res) ::= OPENB ID(i)CLOSEB. {
- res = '['.$this->compiler->compileTag('private_special_variable',array(),'[\'section\'][\''.i.'\'][\'index\']').']';
-}
-
-indexdef(res) ::= OPENB ID(i) DOT ID(i2) CLOSEB. {
- res = '['.$this->compiler->compileTag('private_special_variable',array(),'[\'section\'][\''.i.'\'][\''.i2.'\']').']';
-}
-indexdef(res) ::= OPENB SINGLEQUOTESTRING(s) CLOSEB. {
- res = '['.s.']';
-}
-indexdef(res) ::= OPENB INTEGER(n) CLOSEB. {
- res = '['.n.']';
-}
-indexdef(res) ::= OPENB DOLLARID(i) CLOSEB. {
- res = '['.$this->compiler->compileVariable('\''.substr(i,1).'\'').']';;
-}
-indexdef(res) ::= OPENB variable(v) CLOSEB. {
- res = '['.v.']';
-}
-indexdef(res) ::= OPENB value(v) CLOSEB. {
- res = '['.v.']';
-}
-
- // PHP style index
-indexdef(res) ::= OPENB expr(e) CLOSEB. {
- res = '['. e .']';
-}
-
- // for assign append array
-indexdef(res) ::= OPENB CLOSEB. {
- res = '[]';
-}
-
-
-//
-// variable variable names
-//
-
- // singel identifier element
-varvar(res) ::= DOLLARID(i). {
- res = '\''.substr(i,1).'\'';
-}
- // single $
-varvar(res) ::= DOLLAR. {
- res = "''";
-}
-
- // sequence of identifier elements
-varvar(res) ::= varvar(v1) varvarele(v2). {
- res = v1.'.'.v2;
-}
-
- // fix sections of element
-varvarele(res) ::= ID(s). {
- res = '\''.s.'\'';
-}
-
- // variable sections of element
-varvarele(res) ::= LDEL expr(e) RDEL. {
- res = '('.e.')';
-}
-
-//
-// objects
-//
-object(res) ::= varindexed(vi) objectchain(oc). {
- if (vi['var'] == '\'smarty\'') {
- res = $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']).oc;
- } else {
- res = $this->compiler->compileVariable(vi['var']).vi['smarty_internal_index'].oc;
- }
-}
-
- // single element
-objectchain(res) ::= objectelement(oe). {
- res = oe;
-}
-
- // chain of elements
-objectchain(res) ::= objectchain(oc) objectelement(oe). {
- res = oc.oe;
-}
-
- // variable
-objectelement(res)::= PTR ID(i) arrayindex(a). {
- if ($this->security && substr(i,0,1) == '_') {
- $this->compiler->trigger_template_error (self::Err1);
- }
- res = '->'.i.a;
-}
-
-objectelement(res)::= PTR varvar(v) arrayindex(a). {
- if ($this->security) {
- $this->compiler->trigger_template_error (self::Err2);
- }
- res = '->{'.$this->compiler->compileVariable(v).a.'}';
-}
-
-objectelement(res)::= PTR LDEL expr(e) RDEL arrayindex(a). {
- if ($this->security) {
- $this->compiler->trigger_template_error (self::Err2);
- }
- res = '->{'.e.a.'}';
-}
-
-objectelement(res)::= PTR ID(ii) LDEL expr(e) RDEL arrayindex(a). {
- if ($this->security) {
- $this->compiler->trigger_template_error (self::Err2);
- }
- res = '->{\''.ii.'\'.'.e.a.'}';
-}
-
- // method
-objectelement(res)::= PTR method(f). {
- res = '->'.f;
-}
-
-
-//
-// function
-//
-function(res) ::= ns1(f) OPENP params(p) CLOSEP. {
- if (!$this->security || $this->security->isTrustedPhpFunction(f, $this->compiler)) {
- if (strcasecmp(f,'isset') === 0 || strcasecmp(f,'empty') === 0 || strcasecmp(f,'array') === 0 || is_callable(f)) {
- $func_name = strtolower(f);
- if ($func_name == 'isset') {
- if (count(p) == 0) {
- $this->compiler->trigger_template_error ('Illegal number of paramer in "isset()"');
- }
- $par = implode(',',p);
- if (strncasecmp($par,'$_smarty_tpl->getConfigVariable',strlen('$_smarty_tpl->getConfigVariable')) === 0) {
- self::$prefix_number++;
- $this->compiler->prefix_code[] = '<?php $_tmp'.self::$prefix_number.'='.str_replace(')',', false)',$par).';?>';
- $isset_par = '$_tmp'.self::$prefix_number;
- } else {
- $isset_par=str_replace("')->value","',null,true,false)->value",$par);
- }
- res = f . "(". $isset_par .")";
- } elseif (in_array($func_name,array('empty','reset','current','end','prev','next'))){
- if (count(p) != 1) {
- $this->compiler->trigger_template_error ('Illegal number of paramer in "empty()"');
- }
- if ($func_name == 'empty') {
- res = $func_name.'('.str_replace("')->value","',null,true,false)->value",p[0]).')';
- } else {
- res = $func_name.'('.p[0].')';
- }
- } else {
- res = f . "(". implode(',',p) .")";
- }
- } else {
- $this->compiler->trigger_template_error ("unknown function \"" . f . "\"");
- }
- }
-}
-
-
-//
-// method
-//
-method(res) ::= ID(f) OPENP params(p) CLOSEP. {
- if ($this->security && substr(f,0,1) == '_') {
- $this->compiler->trigger_template_error (self::Err1);
- }
- res = f . "(". implode(',',p) .")";
-}
-
-method(res) ::= DOLLARID(f) OPENP params(p) CLOSEP. {
- if ($this->security) {
- $this->compiler->trigger_template_error (self::Err2);
- }
- self::$prefix_number++;
- $this->compiler->prefix_code[] = '<?php $_tmp'.self::$prefix_number.'='.$this->compiler->compileVariable('\''.substr(f,1).'\'').';?>';
- res = '$_tmp'.self::$prefix_number.'('. implode(',',p) .')';
-}
-
-// function/method parameter
- // multiple parameters
-params(res) ::= params(p) COMMA expr(e). {
- res = array_merge(p,array(e));
-}
-
- // single parameter
-params(res) ::= expr(e). {
- res = array(e);
-}
-
- // kein parameter
-params(res) ::= . {
- res = array();
-}
-
-//
-// modifier
-//
-modifierlist(res) ::= modifierlist(l) modifier(m) modparameters(p). {
- res = array_merge(l,array(array_merge(m,p)));
-}
-
-modifierlist(res) ::= modifier(m) modparameters(p). {
- res = array(array_merge(m,p));
-}
-
-modifier(res) ::= VERT AT ID(m). {
- res = array(m);
-}
-
-modifier(res) ::= VERT ID(m). {
- res = array(m);
-}
-
-//
-// modifier parameter
-//
- // multiple parameter
-modparameters(res) ::= modparameters(mps) modparameter(mp). {
- res = array_merge(mps,mp);
-}
-
- // no parameter
-modparameters(res) ::= . {
- res = array();
-}
-
- // parameter expression
-modparameter(res) ::= COLON value(mp). {
- res = array(mp);
-}
-
-modparameter(res) ::= COLON array(mp). {
- res = array(mp);
-}
-
- // static class methode call
-static_class_access(res) ::= method(m). {
- res = array(m, '', 'method');
-}
-
- // static class methode call with object chainig
-static_class_access(res) ::= method(m) objectchain(oc). {
- res = array(m, oc, 'method');
-}
-
- // static class constant
-static_class_access(res) ::= ID(v). {
- res = array(v, '');
-}
-
- // static class variables
-static_class_access(res) ::= DOLLARID(v) arrayindex(a). {
- res = array(v, a, 'property');
-}
-
- // static class variables with object chain
-static_class_access(res) ::= DOLLARID(v) arrayindex(a) objectchain(oc). {
- res = array(v, a.oc, 'property');
-}
-
-
-// if conditions and operators
-lop(res) ::= LOGOP(o). {
- res['op'] = ' '. trim(o) . ' ';
-}
-
-lop(res) ::= TLOGOP(o). {
- static $lops = array(
- 'eq' => array('op' => ' == ', 'pre' => null),
- 'ne' => array('op' => ' != ', 'pre' => null),
- 'neq' => array('op' => ' != ', 'pre' => null),
- 'gt' => array('op' => ' > ', 'pre' => null),
- 'ge' => array('op' => ' >= ', 'pre' => null),
- 'gte' => array('op' => ' >= ', 'pre' => null),
- 'lt' => array('op' => ' < ', 'pre' => null),
- 'le' => array('op' => ' <= ', 'pre' => null),
- 'lte' => array('op' => ' <= ', 'pre' => null),
- 'mod' => array('op' => ' % ', 'pre' => null),
- 'and' => array('op' => ' && ', 'pre' => null),
- 'or' => array('op' => ' || ', 'pre' => null),
- 'xor' => array('op' => ' xor ', 'pre' => null),
- 'isdivby' => array('op' => ' % ', 'pre' => '!('),
- 'isnotdivby' => array('op' => ' % ', 'pre' => '('),
- 'isevenby' => array('op' => ' / ', 'pre' => '!(1 & '),
- 'isnotevenby' => array('op' => ' / ', 'pre' => '(1 & '),
- 'isoddby' => array('op' => ' / ', 'pre' => '(1 & '),
- 'isnotoddby' => array('op' => ' / ', 'pre' => '!(1 & '),
- );
- $op = strtolower(preg_replace('/\s*/', '', o));
- res = $lops[$op];
-}
-
-scond(res) ::= SINGLECOND(o). {
- static $scond = array (
- 'iseven' => '!(1 & ',
- 'isnoteven' => '(1 & ',
- 'isodd' => '(1 & ',
- 'isnotodd' => '!(1 & ',
- );
- $op = strtolower(str_replace(' ', '', o));
- res = $scond[$op];
-}
-
-//
-// ARRAY element assignment
-//
-array(res) ::= OPENB arrayelements(a) CLOSEB. {
- res = 'array('.a.')';
-}
-
-arrayelements(res) ::= arrayelement(a). {
- res = a;
-}
-
-arrayelements(res) ::= arrayelements(a1) COMMA arrayelement(a). {
- res = a1.','.a;
-}
-
-arrayelements ::= . {
- return;
-}
-
-arrayelement(res) ::= value(e1) APTR expr(e2). {
- res = e1.'=>'.e2;
-}
-
-arrayelement(res) ::= ID(i) APTR expr(e2). {
- res = '\''.i.'\'=>'.e2;
-}
-
-arrayelement(res) ::= expr(e). {
- res = e;
-}
-
-
-//
-// double qouted strings
-//
-doublequoted_with_quotes(res) ::= QUOTE QUOTE. {
- res = "''";
-}
-
-doublequoted_with_quotes(res) ::= QUOTE doublequoted(s) QUOTE. {
- res = s->to_smarty_php();
-}
-
-
-doublequoted(res) ::= doublequoted(o1) doublequotedcontent(o2). {
- o1->append_subtree(o2);
- res = o1;
-}
-
-doublequoted(res) ::= doublequotedcontent(o). {
- res = new Smarty_Internal_ParseTree_Dq($this, o);
-}
-
-doublequotedcontent(res) ::= BACKTICK variable(v) BACKTICK. {
- res = new Smarty_Internal_ParseTree_Code($this, '(string)'.v);
-}
-
-doublequotedcontent(res) ::= BACKTICK expr(e) BACKTICK. {
- res = new Smarty_Internal_ParseTree_Code($this, '(string)'.e);
-}
-
-doublequotedcontent(res) ::= DOLLARID(i). {
- res = new Smarty_Internal_ParseTree_Code($this, '(string)$_smarty_tpl->tpl_vars[\''. substr(i,1) .'\']->value');
-}
-
-doublequotedcontent(res) ::= LDEL variable(v) RDEL. {
- res = new Smarty_Internal_ParseTree_Code($this, '(string)'.v);
-}
-
-doublequotedcontent(res) ::= LDEL expr(e) RDEL. {
- res = new Smarty_Internal_ParseTree_Code($this, '(string)('.e.')');
-}
-
-doublequotedcontent(res) ::= smartytag(st). {
- res = new Smarty_Internal_ParseTree_Tag($this, st);
-}
-
-doublequotedcontent(res) ::= TEXT(o). {
- res = new Smarty_Internal_ParseTree_DqContent($this, o);
-}
-