remove more unneeded smarty files

This commit is contained in:
Mario Vavti 2015-12-06 20:25:42 +01:00
parent ef09a29854
commit f2d7083183
23 changed files with 0 additions and 4430 deletions

View file

@ -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.

View file

@ -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.
.

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -1,5 +0,0 @@
title = Welcome to Smarty!
cutoff_size = 40
[setup]
bold = true

View file

@ -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');

View file

@ -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');
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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}`";
}
}

View file

@ -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);
}
}

View file

@ -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;
}
}

View file

@ -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);
}
}

View file

@ -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;
}
}
}

View file

@ -1,2 +0,0 @@
</BODY>
</HTML>

View file

@ -1,5 +0,0 @@
<HTML>
<HEAD>
<TITLE>{$title} - {$Name}</TITLE>
</HEAD>
<BODY bgcolor="#ffffff">

View file

@ -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"}

View file

@ -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;
}
*/
}

View file

@ -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;
}

View file

@ -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;
}
*/
}

File diff suppressed because it is too large Load diff