Update ams smarty
parent
90225d0011
commit
f8cb53bfd8
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
|
||||||
|
Starting with Smarty 3.1.21 Composer has been configured to load the packages from github.
|
||||||
|
|
||||||
|
*******************************************************************************
|
||||||
|
* *
|
||||||
|
* NOTE: Because of this change you must clear your local composer cache with *
|
||||||
|
* the "composer clearcache" command *
|
||||||
|
* *
|
||||||
|
*******************************************************************************
|
||||||
|
|
||||||
|
To get the latest stable version use
|
||||||
|
"require": {
|
||||||
|
"smarty/smarty": "~3.1"
|
||||||
|
}
|
||||||
|
in your composer.json file.
|
||||||
|
|
||||||
|
To get the trunk version use
|
||||||
|
"require": {
|
||||||
|
"smarty/smarty": "~3.1@dev"
|
||||||
|
}
|
||||||
|
|
||||||
|
The "smarty/smarty" package will start at libs/.... subfolder.
|
||||||
|
|
||||||
|
To retrieve the development and documentation folders add
|
||||||
|
"require-dev": {
|
||||||
|
"smarty/smarty-dev": "~3.1@dev"
|
||||||
|
}
|
||||||
|
|
||||||
|
If you are using (include) the composer generated autoloader.php which is located
|
||||||
|
in the /vendor folder it is no longer needed to require the Smarty.class.php file.
|
@ -0,0 +1,91 @@
|
|||||||
|
3.1.3"
|
||||||
|
New tags for inheritance parent and chilD
|
||||||
|
{parent} == {$smarty.block.parent}
|
||||||
|
{child} == {$smarty.block.child}
|
||||||
|
Both tags support the assign attribute like
|
||||||
|
{child assign=foo}
|
||||||
|
|
||||||
|
3.1.31
|
||||||
|
New tags for inheritance parent and child
|
||||||
|
{block_parent} == {$smarty.block.parent}
|
||||||
|
{block_child} == {$smarty.block.child}
|
||||||
|
|
||||||
|
Since 3.1.28 you can mix inheritance by extends resource with the {extends} tag.
|
||||||
|
A template called by extends resource can extend a subtemplate or chain buy the {extends} tag.
|
||||||
|
Since 3.1.31 this feature can be turned off by setting the new Smarty property Smarty::$extends_recursion to false.
|
||||||
|
|
||||||
|
3.1.28
|
||||||
|
Starting with version 3.1.28 template inheritance is no longer a compile time process.
|
||||||
|
All {block} tag parent/child relations are resolved at run time.
|
||||||
|
This does resolve all known existing restrictions (see below).
|
||||||
|
|
||||||
|
The $smarty::$inheritance_merge_compiled_includes property has been removed.
|
||||||
|
Any access to it is ignored.
|
||||||
|
|
||||||
|
New features:
|
||||||
|
|
||||||
|
Any code outside root {block} tags in child templates is now executed but any output will be ignored.
|
||||||
|
|
||||||
|
{extends 'foo.tpl'}
|
||||||
|
{$bar = 'on'} // assigns variable $bar seen in parent templates
|
||||||
|
{block 'buh'}{/block}
|
||||||
|
|
||||||
|
{extends 'foo.tpl'}
|
||||||
|
{$bar} // the output of variable bar is ignored
|
||||||
|
{block 'buh'}{/block}
|
||||||
|
|
||||||
|
{block} tags can be dynamically en/disabled by conditions.
|
||||||
|
|
||||||
|
{block 'root'}
|
||||||
|
{if $foo}
|
||||||
|
{block 'v1'}
|
||||||
|
....
|
||||||
|
{/block}
|
||||||
|
{else}
|
||||||
|
{block 'v1'}
|
||||||
|
....
|
||||||
|
{/block}
|
||||||
|
{/if}
|
||||||
|
{/block}
|
||||||
|
|
||||||
|
{block} tags can have variable names.
|
||||||
|
|
||||||
|
{block $foo}
|
||||||
|
....
|
||||||
|
{/block}
|
||||||
|
|
||||||
|
Starting with 3.1.28 you can mix inheritance by extends resource with the {extends} tag.
|
||||||
|
A template called by extends resource can extend a subtemplate or chain buy the {extends} tag.
|
||||||
|
|
||||||
|
NOTE There is a BC break. If you used the extends resource {extends} tags have been ignored.
|
||||||
|
|
||||||
|
THE FOLLOWING RESTRICTIONS ARE NO LONGER EXISTING:
|
||||||
|
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. Separate 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.
|
||||||
|
|
@ -0,0 +1,179 @@
|
|||||||
|
Smarty: the PHP compiling template engine
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 3.0 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU Lesser General Public License below for more details.
|
||||||
|
|
||||||
|
|
||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
|
||||||
|
This version of the GNU Lesser General Public License incorporates
|
||||||
|
the terms and conditions of version 3 of the GNU General Public
|
||||||
|
License, supplemented by the additional permissions listed below.
|
||||||
|
|
||||||
|
0. Additional Definitions.
|
||||||
|
|
||||||
|
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||||
|
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||||
|
General Public License.
|
||||||
|
|
||||||
|
"The Library" refers to a covered work governed by this License,
|
||||||
|
other than an Application or a Combined Work as defined below.
|
||||||
|
|
||||||
|
An "Application" is any work that makes use of an interface provided
|
||||||
|
by the Library, but which is not otherwise based on the Library.
|
||||||
|
Defining a subclass of a class defined by the Library is deemed a mode
|
||||||
|
of using an interface provided by the Library.
|
||||||
|
|
||||||
|
A "Combined Work" is a work produced by combining or linking an
|
||||||
|
Application with the Library. The particular version of the Library
|
||||||
|
with which the Combined Work was made is also called the "Linked
|
||||||
|
Version".
|
||||||
|
|
||||||
|
The "Minimal Corresponding Source" for a Combined Work means the
|
||||||
|
Corresponding Source for the Combined Work, excluding any source code
|
||||||
|
for portions of the Combined Work that, considered in isolation, are
|
||||||
|
based on the Application, and not on the Linked Version.
|
||||||
|
|
||||||
|
The "Corresponding Application Code" for a Combined Work means the
|
||||||
|
object code and/or source code for the Application, including any data
|
||||||
|
and utility programs needed for reproducing the Combined Work from the
|
||||||
|
Application, but excluding the System Libraries of the Combined Work.
|
||||||
|
|
||||||
|
1. Exception to Section 3 of the GNU GPL.
|
||||||
|
|
||||||
|
You may convey a covered work under sections 3 and 4 of this License
|
||||||
|
without being bound by section 3 of the GNU GPL.
|
||||||
|
|
||||||
|
2. Conveying Modified Versions.
|
||||||
|
|
||||||
|
If you modify a copy of the Library, and, in your modifications, a
|
||||||
|
facility refers to a function or data to be supplied by an Application
|
||||||
|
that uses the facility (other than as an argument passed when the
|
||||||
|
facility is invoked), then you may convey a copy of the modified
|
||||||
|
version:
|
||||||
|
|
||||||
|
a) under this License, provided that you make a good faith effort to
|
||||||
|
ensure that, in the event an Application does not supply the
|
||||||
|
function or data, the facility still operates, and performs
|
||||||
|
whatever part of its purpose remains meaningful, or
|
||||||
|
|
||||||
|
b) under the GNU GPL, with none of the additional permissions of
|
||||||
|
this License applicable to that copy.
|
||||||
|
|
||||||
|
3. Object Code Incorporating Material from Library Header Files.
|
||||||
|
|
||||||
|
The object code form of an Application may incorporate material from
|
||||||
|
a header file that is part of the Library. You may convey such object
|
||||||
|
code under terms of your choice, provided that, if the incorporated
|
||||||
|
material is not limited to numerical parameters, data structure
|
||||||
|
layouts and accessors, or small macros, inline functions and templates
|
||||||
|
(ten or fewer lines in length), you do both of the following:
|
||||||
|
|
||||||
|
a) Give prominent notice with each copy of the object code that the
|
||||||
|
Library is used in it and that the Library and its use are
|
||||||
|
covered by this License.
|
||||||
|
|
||||||
|
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||||
|
document.
|
||||||
|
|
||||||
|
4. Combined Works.
|
||||||
|
|
||||||
|
You may convey a Combined Work under terms of your choice that,
|
||||||
|
taken together, effectively do not restrict modification of the
|
||||||
|
portions of the Library contained in the Combined Work and reverse
|
||||||
|
engineering for debugging such modifications, if you also do each of
|
||||||
|
the following:
|
||||||
|
|
||||||
|
a) Give prominent notice with each copy of the Combined Work that
|
||||||
|
the Library is used in it and that the Library and its use are
|
||||||
|
covered by this License.
|
||||||
|
|
||||||
|
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||||
|
document.
|
||||||
|
|
||||||
|
c) For a Combined Work that displays copyright notices during
|
||||||
|
execution, include the copyright notice for the Library among
|
||||||
|
these notices, as well as a reference directing the user to the
|
||||||
|
copies of the GNU GPL and this license document.
|
||||||
|
|
||||||
|
d) Do one of the following:
|
||||||
|
|
||||||
|
0) Convey the Minimal Corresponding Source under the terms of this
|
||||||
|
License, and the Corresponding Application Code in a form
|
||||||
|
suitable for, and under terms that permit, the user to
|
||||||
|
recombine or relink the Application with a modified version of
|
||||||
|
the Linked Version to produce a modified Combined Work, in the
|
||||||
|
manner specified by section 6 of the GNU GPL for conveying
|
||||||
|
Corresponding Source.
|
||||||
|
|
||||||
|
1) Use a suitable shared library mechanism for linking with the
|
||||||
|
Library. A suitable mechanism is one that (a) uses at run time
|
||||||
|
a copy of the Library already present on the user's computer
|
||||||
|
system, and (b) will operate properly with a modified version
|
||||||
|
of the Library that is interface-compatible with the Linked
|
||||||
|
Version.
|
||||||
|
|
||||||
|
e) Provide Installation Information, but only if you would otherwise
|
||||||
|
be required to provide such information under section 6 of the
|
||||||
|
GNU GPL, and only to the extent that such information is
|
||||||
|
necessary to install and execute a modified version of the
|
||||||
|
Combined Work produced by recombining or relinking the
|
||||||
|
Application with a modified version of the Linked Version. (If
|
||||||
|
you use option 4d0, the Installation Information must accompany
|
||||||
|
the Minimal Corresponding Source and Corresponding Application
|
||||||
|
Code. If you use option 4d1, you must provide the Installation
|
||||||
|
Information in the manner specified by section 6 of the GNU GPL
|
||||||
|
for conveying Corresponding Source.)
|
||||||
|
|
||||||
|
5. Combined Libraries.
|
||||||
|
|
||||||
|
You may place library facilities that are a work based on the
|
||||||
|
Library side by side in a single library together with other library
|
||||||
|
facilities that are not Applications and are not covered by this
|
||||||
|
License, and convey such a combined library under terms of your
|
||||||
|
choice, if you do both of the following:
|
||||||
|
|
||||||
|
a) Accompany the combined library with a copy of the same work based
|
||||||
|
on the Library, uncombined with any other library facilities,
|
||||||
|
conveyed under the terms of this License.
|
||||||
|
|
||||||
|
b) Give prominent notice with the combined library that part of it
|
||||||
|
is a work based on the Library, and explaining where to find the
|
||||||
|
accompanying uncombined form of the same work.
|
||||||
|
|
||||||
|
6. Revised Versions of the GNU Lesser General Public License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the GNU Lesser General Public License from time to time. Such new
|
||||||
|
versions will be similar in spirit to the present version, but may
|
||||||
|
differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Library as you received it specifies that a certain numbered version
|
||||||
|
of the GNU Lesser General Public License "or any later version"
|
||||||
|
applies to it, you have the option of following the terms and
|
||||||
|
conditions either of that published version or of any later version
|
||||||
|
published by the Free Software Foundation. If the Library as you
|
||||||
|
received it does not specify a version number of the GNU Lesser
|
||||||
|
General Public License, you may choose any version of the GNU Lesser
|
||||||
|
General Public License ever published by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Library as you received it specifies that a proxy can decide
|
||||||
|
whether future versions of the GNU Lesser General Public License shall
|
||||||
|
apply, that proxy's public statement of acceptance of any version is
|
||||||
|
permanent authorization for you to choose that version for the
|
||||||
|
Library.
|
@ -0,0 +1,291 @@
|
|||||||
|
|
||||||
|
|
||||||
|
This file contains a brief description of new features which have been added to Smarty 3.1
|
||||||
|
|
||||||
|
Smarty 3.1.33-dev
|
||||||
|
Variable capture name in Smarty special variable
|
||||||
|
================================================
|
||||||
|
{$smarty.capture.$foo} can now be used to access the content of a named
|
||||||
|
capture block
|
||||||
|
|
||||||
|
Smarty 3.1.32
|
||||||
|
New tags for inheritance parent and child
|
||||||
|
=========================================
|
||||||
|
{parent} == {$smarty.block.parent}
|
||||||
|
{child} == {$smarty.block.child}
|
||||||
|
Both tags support the assign attribute like
|
||||||
|
{child assign=foo}
|
||||||
|
|
||||||
|
Deprecate functions Smarty::muteExpectedErrors() and Smarty::unmuteExpectedErrors()
|
||||||
|
===================================================================================
|
||||||
|
These functions to start a special error handler are no longer needed as Smarty does
|
||||||
|
no longer use error suppression like @filemtime().
|
||||||
|
For backward compatibility the functions still can be called.
|
||||||
|
|
||||||
|
Using literals containing Smarty's left and right delimiter
|
||||||
|
===========================================================
|
||||||
|
New Methods
|
||||||
|
$smarty->setLiterals(array $literals)
|
||||||
|
$smarty->addLiterals(array $literals)
|
||||||
|
to define literals containing Smarty delimiter. This can avoid the need for extreme usage
|
||||||
|
of {literal} {/literal} tags.
|
||||||
|
A) Treat '{{' and '}}' as literal
|
||||||
|
If Smarty::$auto_literal is enabled
|
||||||
|
{{ foo }}
|
||||||
|
will be treated now as literal. (This does apply for any number of delimiter repeatations).
|
||||||
|
However {{foo}} is not an literal but will be interpreted as a recursive Smarty tag.
|
||||||
|
If you use
|
||||||
|
$smarty->setLiterals(array('{{','}}'));
|
||||||
|
{{foo}} is now a literal as well.
|
||||||
|
NOTE: In the last example nested Smarty tags starting with '{{' or ending with '}}' will not
|
||||||
|
work any longer, but this should be very very raw occouring restriction.
|
||||||
|
B) Example 2
|
||||||
|
Assume your delimiter are '<-' , '->' and '<--' , '-->' shall be literals
|
||||||
|
$smarty->setLiterals(array('<--','-->'));
|
||||||
|
|
||||||
|
|
||||||
|
The capture buffers can now be accessed as array
|
||||||
|
================================================
|
||||||
|
{capture name='foo'}
|
||||||
|
bah
|
||||||
|
{\capture}
|
||||||
|
{capture name='buh'}
|
||||||
|
blar
|
||||||
|
{\capture}
|
||||||
|
{foreach $smarty.capture as $name => $buffer}
|
||||||
|
....
|
||||||
|
{/foreach}
|
||||||
|
|
||||||
|
Smarty 3.1.31
|
||||||
|
New tags for inheritance parent and child
|
||||||
|
=========================================
|
||||||
|
{block_parent} == {$smarty.block.parent}
|
||||||
|
{block_child} == {$smarty.block.child}
|
||||||
|
|
||||||
|
Smarty 3.1.30
|
||||||
|
|
||||||
|
Loop optimization {foreach} and {section}
|
||||||
|
=========================================
|
||||||
|
Smarty does optimize the {foreach} and {section} loops by removing code for not needed loop
|
||||||
|
properties.
|
||||||
|
The compiler collects needed properties by scanning the current template for $item@property,
|
||||||
|
$smarty.foreach.name.property and $smarty.section.name.property.
|
||||||
|
The compiler does not know if additional properties will be needed outside the current template scope.
|
||||||
|
Additional properties can be generated by adding them with the property attribute.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
index.tpl
|
||||||
|
{foreach $from as $item properties=[iteration, index]}
|
||||||
|
{include 'sub.tpl'}
|
||||||
|
{$item.total}
|
||||||
|
{/foreach}
|
||||||
|
|
||||||
|
sub.tpl
|
||||||
|
{$item.index} {$item.iteration} {$item.total}
|
||||||
|
|
||||||
|
In above example code for the 'total' property is automatically generated as $item.total is used in
|
||||||
|
index.tpl. Code for 'iteration' and 'index' must be added with properties=[iteration, index].
|
||||||
|
|
||||||
|
New tag {make_nocache}
|
||||||
|
======================
|
||||||
|
Syntax: {make_nocache $foo}
|
||||||
|
|
||||||
|
This tag makes a variable which does exists normally only while rendering the compiled template
|
||||||
|
available in the cached template for use in not cached expressions.
|
||||||
|
|
||||||
|
Expample:
|
||||||
|
{foreach from=$list item=item}
|
||||||
|
<li>{$item.name} {make_nocache $item}{if $current==$item.id} ACTIVE{/if}</li>
|
||||||
|
{/foreach}
|
||||||
|
|
||||||
|
The {foreach} loop is rendered while processing the compiled template, but $current is a nocache
|
||||||
|
variable. Normally the {if $current==$item.id} would fail as the $item variable is unknown in the cached template. {make_nocache $item} does make the current $item value known in thee cached template.
|
||||||
|
|
||||||
|
{make_nocache} is ignored when caching is disabled or the variable does exists as nocache variable.
|
||||||
|
|
||||||
|
NOTE: if the variable value does contain objects these must have the __set_state method implemented.
|
||||||
|
|
||||||
|
|
||||||
|
Scope Attributes
|
||||||
|
================
|
||||||
|
The scope handling has been updated to cover all cases of variable assignments in templates.
|
||||||
|
|
||||||
|
The tags {assign}, {append} direct assignments like {$foo = ...}, {$foo[...]= ...} support
|
||||||
|
the following optional scope attributes:
|
||||||
|
scope='parent' - the variable will be assigned in the current template and if the template
|
||||||
|
was included by {include} the calling template
|
||||||
|
scope='tpl_root' - the variable will be assigned in the outermost root template called by $smarty->display()
|
||||||
|
or $smarty->fetch() and is bubbled up all {include} sub-templates to the current template.
|
||||||
|
scope='smarty' - the variable will be assigned in the Smarty object and is bubbled up all {include} sub-templates
|
||||||
|
to the current template.
|
||||||
|
scope='global' - the variable will be assigned as Smarty object global variable and is bubbled up all {include}
|
||||||
|
sub-templates to the current template.
|
||||||
|
scope='root' - the variable will be assigned if a data object was used for variable definitions in the data
|
||||||
|
object or in the Smarty object otherwise and is bubbled up all {include} sub-templates to the
|
||||||
|
current template.
|
||||||
|
scope='local' - this scope has only a meaning if the tag is called within a template {function}.
|
||||||
|
The variable will be assigned in the local scope of the template function and the
|
||||||
|
template which did call the template function.
|
||||||
|
|
||||||
|
|
||||||
|
The {config_load} tag supports all of the above except the global scope.
|
||||||
|
|
||||||
|
The scope attribute can be used also with the {include} tag.
|
||||||
|
Supported scope are parent, tpl_root, smarty, global and root.
|
||||||
|
A scope used together with the {include} tag will cause that with some exceptions any variable
|
||||||
|
assignment within that sub-template will update/assign the variable in other scopes according
|
||||||
|
to the above rules. It does include also variables assigned by plugins, tags supporting the assign=foo attribute and direct assignments in {if} and {while} like {if $foo=$bar}.
|
||||||
|
Excluded are the key and value variables of {foreach}, {for} loop variables , variables passed by attributes
|
||||||
|
in {include} and direct increments/decrements like {$foo++}, {$foo--}
|
||||||
|
|
||||||
|
Note: The scopes should be used only to the extend really need. If a variable value assigned in an included
|
||||||
|
sub-template should be returned to the calling sub-template just use {$foo='bar' scope='parent'}.
|
||||||
|
Use scopes only with variables for which it's realy needed. Avoid general scope settings with the
|
||||||
|
{include} tag as it can have a performance impact.
|
||||||
|
|
||||||
|
The {assign}, {append}, {config_load} and {$foo...=...} tags have a new option flag 'noscope'.Thi
|
||||||
|
Example: {$foo='bar' noscope} This will assign $foo only in the current template and any scope settings
|
||||||
|
at {include} is ignored.
|
||||||
|
|
||||||
|
|
||||||
|
Caching
|
||||||
|
=======
|
||||||
|
Caching does now observe the template_dir setting and will create separate cache files if required
|
||||||
|
|
||||||
|
Compiled Templates
|
||||||
|
==================
|
||||||
|
The template_dir setting is now encoded in the uid of the file name.
|
||||||
|
The content of the compiled template may depend on the template_dir search order
|
||||||
|
{include .... inline} is used or $smarty->merge_compiled_includes is enabled
|
||||||
|
|
||||||
|
APC
|
||||||
|
===
|
||||||
|
If APC is enabled force an apc_compile_file() when compiled or cached template was updated
|
||||||
|
|
||||||
|
Smarty 3.1.28
|
||||||
|
|
||||||
|
OPCACHE
|
||||||
|
=======
|
||||||
|
Smarty does now invalidate automatically updated and cleared compiled or cached template files in OPCACHE.
|
||||||
|
Correct operation is no longer dependent on OPCACHE configuration settings.
|
||||||
|
|
||||||
|
Template inheritance
|
||||||
|
====================
|
||||||
|
Template inheritance is now processed in run time.
|
||||||
|
See the INHERITANCE_RELEASE_NOTES
|
||||||
|
|
||||||
|
Modifier regex_replace
|
||||||
|
======================
|
||||||
|
An optional limit parameter was added
|
||||||
|
|
||||||
|
fetch() and display()
|
||||||
|
=====================
|
||||||
|
The fetch() and display() methods of the template object accept now optionally the same parameter
|
||||||
|
as the corresponding Smarty methods to get the content of another template.
|
||||||
|
Example:
|
||||||
|
$template->display(); Does display template of template object
|
||||||
|
$template->display('foo.tpl'); Does display template 'foo.bar'
|
||||||
|
|
||||||
|
File: resource
|
||||||
|
==============
|
||||||
|
Multiple template_dir entries can now be selected by a comma separated list of indices.
|
||||||
|
The template_dir array is searched in the order of the indices. (Could be used to change the default search order)
|
||||||
|
Example:
|
||||||
|
$smarty->display('[1],[0]foo.bar');
|
||||||
|
|
||||||
|
Filter support
|
||||||
|
==============
|
||||||
|
Optional filter names
|
||||||
|
An optional filter name was added to $smarty->registerFilter(). It can be used to unregister a filter by name.
|
||||||
|
- $smarty->registerFilter('output', $callback, 'name');
|
||||||
|
$smarty->unregister('output', 'name');
|
||||||
|
|
||||||
|
Closures
|
||||||
|
$smarty->registerFilter() does now accept closures.
|
||||||
|
- $smarty->registerFilter('pre', function($source) {return $source;});
|
||||||
|
If no optional filter name was specified it gets the default name 'closure'.
|
||||||
|
If you register multiple closures register each with a unique filter name.
|
||||||
|
- $smarty->registerFilter('pre', function($source) {return $source;}, 'closure_1');
|
||||||
|
- $smarty->registerFilter('pre', function($source) {return $source;}, 'closure_2');
|
||||||
|
|
||||||
|
|
||||||
|
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 debug window.
|
||||||
|
|
@ -0,0 +1,78 @@
|
|||||||
|
# Smarty 3 template engine
|
||||||
|
[smarty.net](https://www.smarty.net/)
|
||||||
|
|
||||||
|
[![Build Status](https://travis-ci.org/smarty-php/smarty.svg?branch=master)](https://travis-ci.org/smarty-php/smarty)
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
For documentation see
|
||||||
|
[www.smarty.net/docs/en/](https://www.smarty.net/docs/en/)
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
Smarty can be run with PHP 5.2 to PHP 7.4.
|
||||||
|
|
||||||
|
## Distribution repository
|
||||||
|
|
||||||
|
> Smarty 3.1.28 introduces run time template inheritance
|
||||||
|
|
||||||
|
> Read the NEW_FEATURES and INHERITANCE_RELEASE_NOTES 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:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"require": {
|
||||||
|
"smarty/smarty": "~3.1"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
in your composer.json file.
|
||||||
|
|
||||||
|
To get the trunk version use:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"require": {
|
||||||
|
"smarty/smarty": "~3.1@dev"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
For a specific version use something like:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"require": {
|
||||||
|
"smarty/smarty": "3.1.19"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
PHPUnit test can be installed by corresponding composer entries like:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"require": {
|
||||||
|
"smarty/smarty-phpunit": "3.1.19"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Similar applies for the lexer/parser generator.
|
||||||
|
|
||||||
|
```json
|
||||||
|
"require": {
|
||||||
|
"smarty/smarty-lexer": "3.1.19"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Or you could use:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"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.30.
|
@ -0,0 +1,110 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty Autoloader
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Autoloader
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @author Uwe Tews
|
||||||
|
* Usage:
|
||||||
|
* require_once '...path/Autoloader.php';
|
||||||
|
* Smarty_Autoloader::register();
|
||||||
|
* or
|
||||||
|
* include '...path/bootstrap.php';
|
||||||
|
*
|
||||||
|
* $smarty = new Smarty();
|
||||||
|
*/
|
||||||
|
class Smarty_Autoloader
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Filepath to Smarty root
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public static $SMARTY_DIR = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filepath to Smarty internal plugins
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public static $SMARTY_SYSPLUGINS_DIR = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array with Smarty core classes and their filename
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $rootClasses = array('smarty' => 'Smarty.class.php', 'smartybc' => 'SmartyBC.class.php',);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers Smarty_Autoloader backward compatible to older installations.
|
||||||
|
*
|
||||||
|
* @param bool $prepend Whether to prepend the autoloader or not.
|
||||||
|
*/
|
||||||
|
public static function registerBC($prepend = false)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* register the class autoloader
|
||||||
|
*/
|
||||||
|
if (!defined('SMARTY_SPL_AUTOLOAD')) {
|
||||||
|
define('SMARTY_SPL_AUTOLOAD', 0);
|
||||||
|
}
|
||||||
|
if (SMARTY_SPL_AUTOLOAD
|
||||||
|
&& set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
|
||||||
|
) {
|
||||||
|
$registeredAutoLoadFunctions = spl_autoload_functions();
|
||||||
|
if (!isset($registeredAutoLoadFunctions[ 'spl_autoload' ])) {
|
||||||
|
spl_autoload_register();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self::register($prepend);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers Smarty_Autoloader as an SPL autoloader.
|
||||||
|
*
|
||||||
|
* @param bool $prepend Whether to prepend the autoloader or not.
|
||||||
|
*/
|
||||||
|
public static function register($prepend = false)
|
||||||
|
{
|
||||||
|
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . DIRECTORY_SEPARATOR;
|
||||||
|
self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR :
|
||||||
|
self::$SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR;
|
||||||
|
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
||||||
|
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
|
||||||
|
} else {
|
||||||
|
spl_autoload_register(array(__CLASS__, 'autoload'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles auto loading of classes.
|
||||||
|
*
|
||||||
|
* @param string $class A class name.
|
||||||
|
*/
|
||||||
|
public static function autoload($class)
|
||||||
|
{
|
||||||
|
if ($class[ 0 ] !== 'S' || strpos($class, 'Smarty') !== 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$_class = strtolower($class);
|
||||||
|
if (isset(self::$rootClasses[ $_class ])) {
|
||||||
|
$file = self::$SMARTY_DIR . self::$rootClasses[ $_class ];
|
||||||
|
if (is_file($file)) {
|
||||||
|
include $file;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php';
|
||||||
|
if (is_file($file)) {
|
||||||
|
include $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Smarty package.
|
||||||
|
*
|
||||||
|
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Load and register Smarty Autoloader
|
||||||
|
*/
|
||||||
|
if (!class_exists('Smarty_Autoloader')) {
|
||||||
|
include dirname(__FILE__) . '/Autoloader.php';
|
||||||
|
}
|
||||||
|
Smarty_Autoloader::register(true);
|
@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty plugin
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsModifier
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Smarty wordwrap modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: mb_wordwrap
|
||||||
|
* Purpose: Wrap a string to a given number of characters
|
||||||
|
*
|
||||||
|
* @link http://php.net/manual/en/function.wordwrap.php for similarity
|
||||||
|
*
|
||||||
|
* @param string $str the string to wrap
|
||||||
|
* @param int $width the width of the output
|
||||||
|
* @param string $break the character used to break the line
|
||||||
|
* @param boolean $cut ignored parameter, just for the sake of
|
||||||
|
*
|
||||||
|
* @return string wrapped string
|
||||||
|
* @author Rodney Rehm
|
||||||
|
*/
|
||||||
|
function smarty_modifier_mb_wordwrap($str, $width = 75, $break = "\n", $cut = false)
|
||||||
|
{
|
||||||
|
// break words into tokens using white space as a delimiter
|
||||||
|
$tokens = preg_split('!(\s)!S' . Smarty::$_UTF8_MODIFIER, $str, -1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE);
|
||||||
|
$length = 0;
|
||||||
|
$t = '';
|
||||||
|
$_previous = false;
|
||||||
|
$_space = false;
|
||||||
|
foreach ($tokens as $_token) {
|
||||||
|
$token_length = mb_strlen($_token, Smarty::$_CHARSET);
|
||||||
|
$_tokens = array($_token);
|
||||||
|
if ($token_length > $width) {
|
||||||
|
if ($cut) {
|
||||||
|
$_tokens = preg_split(
|
||||||
|
'!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER,
|
||||||
|
$_token,
|
||||||
|
-1,
|
||||||
|
PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($_tokens as $token) {
|
||||||
|
$_space = !!preg_match('!^\s$!S' . Smarty::$_UTF8_MODIFIER, $token);
|
||||||
|
$token_length = mb_strlen($token, Smarty::$_CHARSET);
|
||||||
|
$length += $token_length;
|
||||||
|
if ($length > $width) {
|
||||||
|
// remove space before inserted break
|
||||||
|
if ($_previous) {
|
||||||
|
$t = mb_substr($t, 0, -1, Smarty::$_CHARSET);
|
||||||
|
}
|
||||||
|
if (!$_space) {
|
||||||
|
// add the break before the token
|
||||||
|
if (!empty($t)) {
|
||||||
|
$t .= $break;
|
||||||
|
}
|
||||||
|
$length = $token_length;
|
||||||
|
}
|
||||||
|
} elseif ($token === "\n") {
|
||||||
|
// hard break must reset counters
|
||||||
|
$length = 0;
|
||||||
|
}
|
||||||
|
$_previous = $_space;
|
||||||
|
// add the token
|
||||||
|
$t .= $token;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $t;
|
||||||
|
}
|
@ -1,83 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty shared plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsShared
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!function_exists('smarty_mb_wordwrap')) {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrap a string to a given number of characters
|
|
||||||
*
|
|
||||||
* @link http://php.net/manual/en/function.wordwrap.php for similarity
|
|
||||||
*
|
|
||||||
* @param string $str the string to wrap
|
|
||||||
* @param int $width the width of the output
|
|
||||||
* @param string $break the character used to break the line
|
|
||||||
* @param boolean $cut ignored parameter, just for the sake of
|
|
||||||
*
|
|
||||||
* @return string wrapped string
|
|
||||||
* @author Rodney Rehm
|
|
||||||
*/
|
|
||||||
function smarty_mb_wordwrap($str, $width = 75, $break = "\n", $cut = false)
|
|
||||||
{
|
|
||||||
// break words into tokens using white space as a delimiter
|
|
||||||
$tokens = preg_split('!(\s)!S' . Smarty::$_UTF8_MODIFIER, $str, - 1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE);
|
|
||||||
$length = 0;
|
|
||||||
$t = '';
|
|
||||||
$_previous = false;
|
|
||||||
|
|
||||||
foreach ($tokens as $_token) {
|
|
||||||
$token_length = mb_strlen($_token, Smarty::$_CHARSET);
|
|
||||||
$_tokens = array($_token);
|
|
||||||
if ($token_length > $width) {
|
|
||||||
// remove last space
|
|
||||||
$t = mb_substr($t, 0, - 1, Smarty::$_CHARSET);
|
|
||||||
$_previous = false;
|
|
||||||
$length = 0;
|
|
||||||
|
|
||||||
if ($cut) {
|
|
||||||
$_tokens = preg_split('!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER, $_token, - 1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE);
|
|
||||||
// broken words go on a new line
|
|
||||||
$t .= $break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($_tokens as $token) {
|
|
||||||
$_space = !!preg_match('!^\s$!S' . Smarty::$_UTF8_MODIFIER, $token);
|
|
||||||
$token_length = mb_strlen($token, Smarty::$_CHARSET);
|
|
||||||
$length += $token_length;
|
|
||||||
|
|
||||||
if ($length > $width) {
|
|
||||||
// remove space before inserted break
|
|
||||||
if ($_previous && $token_length < $width) {
|
|
||||||
$t = mb_substr($t, 0, - 1, Smarty::$_CHARSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
// add the break before the token
|
|
||||||
$t .= $break;
|
|
||||||
$length = $token_length;
|
|
||||||
|
|
||||||
// skip space after inserting a break
|
|
||||||
if ($_space) {
|
|
||||||
$length = 0;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} elseif ($token == "\n") {
|
|
||||||
// hard break must reset counters
|
|
||||||
$_previous = 0;
|
|
||||||
$length = 0;
|
|
||||||
} else {
|
|
||||||
// remember if we had a space or not
|
|
||||||
$_previous = $_space;
|
|
||||||
}
|
|
||||||
// add the token
|
|
||||||
$t .= $token;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $t;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,94 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty Internal Plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage TemplateResources
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty Resource Data Object
|
|
||||||
* Meta Data Container for Config Files
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage TemplateResources
|
|
||||||
* @author Rodney Rehm
|
|
||||||
* @property string $content
|
|
||||||
* @property int $timestamp
|
|
||||||
* @property bool $exists
|
|
||||||
*/
|
|
||||||
class Smarty_Config_Source extends Smarty_Template_Source
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* create Config Object container
|
|
||||||
*
|
|
||||||
* @param Smarty_Resource $handler Resource Handler this source object communicates with
|
|
||||||
* @param Smarty $smarty Smarty instance this source object belongs to
|
|
||||||
* @param string $resource full config_resource
|
|
||||||
* @param string $type type of resource
|
|
||||||
* @param string $name resource name
|
|
||||||
* @param string $unique_resource unqiue resource name
|
|
||||||
*/
|
|
||||||
public function __construct(Smarty_Resource $handler, Smarty $smarty, $resource, $type, $name, $unique_resource)
|
|
||||||
{
|
|
||||||
$this->handler = $handler; // Note: prone to circular references
|
|
||||||
|
|
||||||
// Note: these may be ->config_compiler_class etc in the future
|
|
||||||
//$this->config_compiler_class = $handler->config_compiler_class;
|
|
||||||
//$this->config_lexer_class = $handler->config_lexer_class;
|
|
||||||
//$this->config_parser_class = $handler->config_parser_class;
|
|
||||||
|
|
||||||
$this->smarty = $smarty;
|
|
||||||
$this->resource = $resource;
|
|
||||||
$this->type = $type;
|
|
||||||
$this->name = $name;
|
|
||||||
$this->unique_resource = $unique_resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <<magic>> Generic setter.
|
|
||||||
*
|
|
||||||
* @param string $property_name valid: content, timestamp, exists
|
|
||||||
* @param mixed $value newly assigned value (not check for correct type)
|
|
||||||
*
|
|
||||||
* @throws SmartyException when the given property name is not valid
|
|
||||||
*/
|
|
||||||
public function __set($property_name, $value)
|
|
||||||
{
|
|
||||||
switch ($property_name) {
|
|
||||||
case 'content':
|
|
||||||
case 'timestamp':
|
|
||||||
case 'exists':
|
|
||||||
$this->$property_name = $value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new SmartyException("invalid config property '$property_name'.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <<magic>> Generic getter.
|
|
||||||
*
|
|
||||||
* @param string $property_name valid: content, timestamp, exists
|
|
||||||
*
|
|
||||||
* @return mixed|void
|
|
||||||
* @throws SmartyException when the given property name is not valid
|
|
||||||
*/
|
|
||||||
public function __get($property_name)
|
|
||||||
{
|
|
||||||
switch ($property_name) {
|
|
||||||
case 'timestamp':
|
|
||||||
case 'exists':
|
|
||||||
$this->handler->populateTimestamp($this);
|
|
||||||
|
|
||||||
return $this->$property_name;
|
|
||||||
|
|
||||||
case 'content':
|
|
||||||
return $this->content = $this->handler->getContent($this);
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new SmartyException("config property '$property_name' does not exist.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty Plugin Data
|
||||||
|
* This file contains the data object
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage Template
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* class for the Smarty data object
|
||||||
|
* The Smarty data object will hold Smarty variables in the current scope
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage Template
|
||||||
|
*/
|
||||||
|
class Smarty_Data extends Smarty_Internal_Data
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Counter
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public static $count = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data block name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $dataObjectName = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty object
|
||||||
|
*
|
||||||
|
* @var Smarty
|
||||||
|
*/
|
||||||
|
public $smarty = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create Smarty data object
|
||||||
|
*
|
||||||
|
* @param Smarty|array $_parent parent template
|
||||||
|
* @param Smarty|Smarty_Internal_Template $smarty global smarty instance
|
||||||
|
* @param string $name optional data block name
|
||||||
|
*
|
||||||
|
* @throws SmartyException
|
||||||
|
*/
|
||||||
|
public function __construct($_parent = null, $smarty = null, $name = null)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
self::$count++;
|
||||||
|
$this->dataObjectName = 'Data_object ' . (isset($name) ? "'{$name}'" : self::$count);
|
||||||
|
$this->smarty = $smarty;
|
||||||
|
if (is_object($_parent)) {
|
||||||
|
// when object set up back pointer
|
||||||
|
$this->parent = $_parent;
|
||||||
|
} elseif (is_array($_parent)) {
|
||||||
|
// set up variable values
|
||||||
|
foreach ($_parent as $_key => $_val) {
|
||||||
|
$this->tpl_vars[ $_key ] = new Smarty_Variable($_val);
|
||||||
|
}
|
||||||
|
} elseif ($_parent !== null) {
|
||||||
|
throw new SmartyException('Wrong type for template variables');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty {block} tag class
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsInternal
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Block
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Block name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $name = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide attribute
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $hide = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Append attribute
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $append = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* prepend attribute
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $prepend = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Block calls $smarty.block.child
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $callsChild = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inheritance child block
|
||||||
|
*
|
||||||
|
* @var Smarty_Internal_Block|null
|
||||||
|
*/
|
||||||
|
public $child = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inheritance calling parent block
|
||||||
|
*
|
||||||
|
* @var Smarty_Internal_Block|null
|
||||||
|
*/
|
||||||
|
public $parent = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inheritance Template index
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $tplIndex = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty_Internal_Block constructor.
|
||||||
|
* - if outer level {block} of child template ($state === 1) save it as child root block
|
||||||
|
* - otherwise process inheritance and render
|
||||||
|
*
|
||||||
|
* @param string $name block name
|
||||||
|
* @param int|null $tplIndex index of outer level {block} if nested
|
||||||
|
*/
|
||||||
|
public function __construct($name, $tplIndex)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
$this->tplIndex = $tplIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compiled block code overloaded by {block} class
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_Template $tpl
|
||||||
|
*/
|
||||||
|
public function callBlock(Smarty_Internal_Template $tpl)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of Smarty.
|
||||||
|
*
|
||||||
|
* (c) 2015 Uwe Tews
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Internal Plugin Compile Block Child Class
|
||||||
|
*
|
||||||
|
* @author Uwe Tews <uwe.tews@googlemail.com>
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Compile_Block_Child extends Smarty_Internal_Compile_Child
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Tag name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $tag = 'block_child';
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of Smarty.
|
||||||
|
*
|
||||||
|
* (c) 2015 Uwe Tews
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Internal Plugin Compile Block Parent Class
|
||||||
|
*
|
||||||
|
* @author Uwe Tews <uwe.tews@googlemail.com>
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Compile_Block_Parent extends Smarty_Internal_Compile_Child
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Tag name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $tag = 'block_parent';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Block type
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $blockType = 'Parent';
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of Smarty.
|
||||||
|
*
|
||||||
|
* (c) 2015 Uwe Tews
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Internal Plugin Compile Child Class
|
||||||
|
*
|
||||||
|
* @author Uwe Tews <uwe.tews@googlemail.com>
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Compile_Child extends Smarty_Internal_CompileBase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Attribute definition: Overwrites base class.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @see Smarty_Internal_CompileBase
|
||||||
|
*/
|
||||||
|
public $optional_attributes = array('assign');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tag name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $tag = 'child';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Block type
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $blockType = 'Child';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compiles code for the {child} tag
|
||||||
|
*
|
||||||
|
* @param array $args array with attributes from parser
|
||||||
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
|
* @param array $parameter array with compilation parameter
|
||||||
|
*
|
||||||
|
* @return string compiled code
|
||||||
|
* @throws \SmartyCompilerException
|
||||||
|
*/
|
||||||
|
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||||
|
{
|
||||||
|
// check and get attributes
|
||||||
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
$tag = isset($parameter[ 0 ]) ? "'{$parameter[0]}'" : "'{{$this->tag}}'";
|
||||||
|
if (!isset($compiler->_cache[ 'blockNesting' ])) {
|
||||||
|
$compiler->trigger_template_error(
|
||||||
|
"{$tag} used outside {block} tags ",
|
||||||
|
$compiler->parser->lex->taglineno
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$compiler->has_code = true;
|
||||||
|
$compiler->suppressNocacheProcessing = true;
|
||||||
|
if ($this->blockType === 'Child') {
|
||||||
|
$compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ][ 'callsChild' ] = 'true';
|
||||||
|
}
|
||||||
|
$_assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : null;
|
||||||
|
$output = "<?php \n";
|
||||||
|
if (isset($_assign)) {
|
||||||
|
$output .= "ob_start();\n";
|
||||||
|
}
|
||||||
|
$output .= '$_smarty_tpl->inheritance->call' . $this->blockType . '($_smarty_tpl, $this' .
|
||||||
|
($this->blockType === 'Child' ? '' : ", {$tag}") . ");\n";
|
||||||
|
if (isset($_assign)) {
|
||||||
|
$output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n";
|
||||||
|
}
|
||||||
|
$output .= "?>\n";
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty Internal Plugin Compile Make_Nocache
|
||||||
|
* Compiles the {make_nocache} tag
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage Compiler
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Internal Plugin Compile Make_Nocache Class
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage Compiler
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Compile_Make_Nocache extends Smarty_Internal_CompileBase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Attribute definition: Overwrites base class.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @see Smarty_Internal_CompileBase
|
||||||
|
*/
|
||||||
|
public $option_flags = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of names of required attribute required by tag
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $required_attributes = array('var');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shorttag attribute order defined by its names
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $shorttag_order = array('var');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compiles code for the {make_nocache} tag
|
||||||
|
*
|
||||||
|
* @param array $args array with attributes from parser
|
||||||
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
|
*
|
||||||
|
* @return string compiled code
|
||||||
|
*/
|
||||||
|
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
|
{
|
||||||
|
// check and get attributes
|
||||||
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
if ($compiler->template->caching) {
|
||||||
|
$output = "<?php \$_smarty_tpl->smarty->ext->_make_nocache->save(\$_smarty_tpl, {$_attr[ 'var' ]});\n?>\n";
|
||||||
|
$compiler->template->compiled->has_nocache_code = true;
|
||||||
|
$compiler->suppressNocacheProcessing = true;
|
||||||
|
return $output;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of Smarty.
|
||||||
|
*
|
||||||
|
* (c) 2015 Uwe Tews
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Internal Plugin Compile Parent Class
|
||||||
|
*
|
||||||
|
* @author Uwe Tews <uwe.tews@googlemail.com>
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Compile_Parent extends Smarty_Internal_Compile_Child
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Tag name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $tag = 'parent';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Block type
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $blockType = 'Parent';
|
||||||
|
}
|
@ -0,0 +1,228 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty Internal Plugin Compile ForeachSection
|
||||||
|
* Shared methods for {foreach} {section} tags
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage Compiler
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Internal Plugin Compile ForeachSection Class
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage Compiler
|
||||||
|
*/
|
||||||
|
class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_CompileBase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Name of this tag
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $tagName = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valid properties of $smarty.xxx variable
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $nameProperties = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {section} tag has no item properties
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $itemProperties = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {section} tag has always name attribute
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $isNamed = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $matchResults = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preg search pattern
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $propertyPreg = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offsets in preg match result
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $resultOffsets = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start offset
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $startOffset = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scan sources for used tag attributes
|
||||||
|
*
|
||||||
|
* @param array $attributes
|
||||||
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
|
*
|
||||||
|
* @throws \SmartyException
|
||||||
|
*/
|
||||||
|
public function scanForProperties($attributes, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
|
{
|
||||||
|
$this->propertyPreg = '~(';
|
||||||
|
$this->startOffset = 1;
|
||||||
|
$this->resultOffsets = array();
|
||||||
|
$this->matchResults = array('named' => array(), 'item' => array());
|
||||||
|
if (isset($attributes[ 'name' ])) {
|
||||||
|
$this->buildPropertyPreg(true, $attributes);
|
||||||
|
}
|
||||||
|
if (isset($this->itemProperties)) {
|
||||||
|
if ($this->isNamed) {
|
||||||
|
$this->propertyPreg .= '|';
|
||||||
|
}
|
||||||
|
$this->buildPropertyPreg(false, $attributes);
|
||||||
|
}
|
||||||
|
$this->propertyPreg .= ')\W~i';
|
||||||
|
// Template source
|
||||||
|
$this->matchTemplateSource($compiler);
|
||||||
|
// Parent template source
|
||||||
|
$this->matchParentTemplateSource($compiler);
|
||||||
|
// {block} source
|
||||||
|
$this->matchBlockSource($compiler);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build property preg string
|
||||||
|
*
|
||||||
|
* @param bool $named
|
||||||
|
* @param array $attributes
|
||||||
|
*/
|
||||||
|
public function buildPropertyPreg($named, $attributes)
|
||||||
|
{
|
||||||
|
if ($named) {
|
||||||
|
$this->resultOffsets[ 'named' ] = $this->startOffset = $this->startOffset + 3;
|
||||||
|
$this->propertyPreg .= "(([\$]smarty[.]{$this->tagName}[.]" .
|
||||||
|
($this->tagName === 'section' ? "|[\[]\s*" : '') .
|
||||||
|
"){$attributes['name']}[.](";
|
||||||
|
$properties = $this->nameProperties;
|
||||||
|
} else {
|
||||||
|
$this->resultOffsets[ 'item' ] = $this->startOffset = $this->startOffset + 2;
|
||||||
|
$this->propertyPreg .= "([\$]{$attributes['item']}[@](";
|
||||||
|
$properties = $this->itemProperties;
|
||||||
|
}
|
||||||
|
$propName = reset($properties);
|
||||||
|
while ($propName) {
|
||||||
|
$this->propertyPreg .= "{$propName}";
|
||||||
|
$propName = next($properties);
|
||||||
|
if ($propName) {
|
||||||
|
$this->propertyPreg .= '|';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->propertyPreg .= '))';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find matches in source string
|
||||||
|
*
|
||||||
|
* @param string $source
|
||||||
|
*/
|
||||||
|
public function matchProperty($source)
|
||||||
|
{
|
||||||
|
preg_match_all($this->propertyPreg, $source, $match);
|
||||||
|
foreach ($this->resultOffsets as $key => $offset) {
|
||||||
|
foreach ($match[ $offset ] as $m) {
|
||||||
|
if (!empty($m)) {
|
||||||
|
$this->matchResults[ $key ][ strtolower($m) ] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find matches in template source
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
|
*/
|
||||||
|
public function matchTemplateSource(Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
|
{
|
||||||
|
$this->matchProperty($compiler->parser->lex->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find matches in all parent template source
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
|
*
|
||||||
|
* @throws \SmartyException
|
||||||
|
*/
|
||||||
|
public function matchParentTemplateSource(Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
|
{
|
||||||
|
// search parent compiler template source
|
||||||
|
$nextCompiler = $compiler;
|
||||||
|
while ($nextCompiler !== $nextCompiler->parent_compiler) {
|
||||||
|
$nextCompiler = $nextCompiler->parent_compiler;
|
||||||
|
if ($compiler !== $nextCompiler) {
|
||||||
|
// get template source
|
||||||
|
$_content = $nextCompiler->template->source->getContent();
|
||||||
|
if ($_content !== '') {
|
||||||
|
// run pre filter if required
|
||||||
|
if ((isset($nextCompiler->smarty->autoload_filters[ 'pre' ]) ||
|
||||||
|
isset($nextCompiler->smarty->registered_filters[ 'pre' ]))
|
||||||
|
) {
|
||||||
|
$_content = $nextCompiler->smarty->ext->_filterHandler->runFilter(
|
||||||
|
'pre',
|
||||||
|
$_content,
|
||||||
|
$nextCompiler->template
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$this->matchProperty($_content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find matches in {block} tag source
|
||||||
|
*
|
||||||
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
|
*/
|
||||||
|
public function matchBlockSource(Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compiles code for the {$smarty.foreach.xxx} or {$smarty.section.xxx}tag
|
||||||
|
*
|
||||||
|
* @param array $args array with attributes from parser
|
||||||
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
|
* @param array $parameter array with compilation parameter
|
||||||
|
*
|
||||||
|
* @return string compiled code
|
||||||
|
* @throws \SmartyCompilerException
|
||||||
|
*/
|
||||||
|
public function compileSpecialVariable($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||||
|
{
|
||||||
|
$tag = strtolower(trim($parameter[ 0 ], '"\''));
|
||||||
|
$name = isset($parameter[ 1 ]) ? $compiler->getId($parameter[ 1 ]) : false;
|
||||||
|
if (!$name) {
|
||||||
|
$compiler->trigger_template_error("missing or illegal \$smarty.{$tag} name attribute", null, true);
|
||||||
|
}
|
||||||
|
$property = isset($parameter[ 2 ]) ? strtolower($compiler->getId($parameter[ 2 ])) : false;
|
||||||
|
if (!$property || !in_array($property, $this->nameProperties)) {
|
||||||
|
$compiler->trigger_template_error("missing or illegal \$smarty.{$tag} property attribute", null, true);
|
||||||
|
}
|
||||||
|
$tagVar = "'__smarty_{$tag}_{$name}'";
|
||||||
|
return "(isset(\$_smarty_tpl->tpl_vars[{$tagVar}]->value['{$property}']) ? \$_smarty_tpl->tpl_vars[{$tagVar}]->value['{$property}'] : null)";
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue