Version Description
Download this release
Release Info
Developer | supsystic.com |
Plugin | Photo Gallery by Supsystic |
Version | 1.15.11 |
Comparing to | |
See all releases |
Code changes from version 1.15.9 to 1.15.11
- app/SupsysticGallery.php +12 -12
- app/langs/default.po +1 -1
- app/langs/sgg-ca.po +2 -2
- app/langs/sgg-es_ES.po +2 -2
- app/langs/sgg-fr_FR.po +2 -2
- app/langs/sgg-it_IT.po +2 -2
- app/langs/sgg-zh_CN.po +1 -1
- app/templates/grid-gallery.twig +1 -1
- index.php +22 -2
- readme.txt +8 -1
- src/GridGallery/Ajax/Handler.php +11 -11
- src/GridGallery/Ajax/Module.php +1 -1
- src/GridGallery/Core/BaseController.php +6 -6
- src/GridGallery/Core/BaseModel.php +5 -5
- src/GridGallery/Core/Module.php +14 -13
- src/GridGallery/Developer/Controller.php +3 -3
- src/GridGallery/Developer/Model.php +1 -1
- src/GridGallery/Developer/Module.php +1 -1
- src/GridGallery/Galleries/Controller.php +116 -116
- src/GridGallery/Galleries/Model/Galleries.php +12 -12
- src/GridGallery/Galleries/Model/Resources.php +6 -6
- src/GridGallery/Galleries/Model/plugins/Mobile_Detect.php +2 -1
- src/GridGallery/Galleries/Module.php +10 -10
- src/GridGallery/Galleries/views/settings.twig +1 -1
- src/GridGallery/Galleries/views/sort.twig +6 -8
- src/GridGallery/Galleries/views/view.twig +19 -19
- src/GridGallery/Insta/Controller.php +10 -10
- src/GridGallery/Insta/Module.php +1 -1
- src/GridGallery/Optimization/Controller.php +19 -19
- src/GridGallery/Optimization/Model/Cdn.php +1 -1
- src/GridGallery/Optimization/Model/ImageOptimize.php +1 -1
- src/GridGallery/Overview/Controller.php +18 -15
- src/GridGallery/Overview/Module.php +1 -1
- src/GridGallery/Photos/Controller.php +40 -40
- src/GridGallery/Photos/Model/Folders.php +1 -1
- src/GridGallery/Photos/Model/Photos.php +2 -2
- src/GridGallery/Photos/Model/Settings.php +1 -1
- src/GridGallery/Photos/Module.php +3 -3
- src/GridGallery/Promo/Controller.php +3 -3
- src/GridGallery/Promo/Model/Promo.php +1 -1
- src/GridGallery/Settings/Controller.php +4 -4
- src/GridGallery/Settings/Model/Settings.php +1 -1
- src/GridGallery/Settings/Module.php +1 -1
- src/GridGallery/Stats/Module.php +1 -1
- src/GridGallery/Ui/Module.php +1 -1
- vendor/Rsc/Autoloader.php +7 -6
- vendor/Rsc/Cache.php +6 -6
- vendor/Rsc/Cache/Dummy.php +1 -1
- vendor/Rsc/Cache/Filesystem.php +1 -1
- vendor/Rsc/Cache/Interface.php +1 -1
- vendor/Rsc/ClassLoader.php +8 -8
- vendor/Rsc/Common/Collection.php +16 -7
- vendor/Rsc/Config.php +11 -11
- vendor/Rsc/Config/ListenerInterface.php +1 -1
- vendor/Rsc/Config/Loader.php +4 -4
- vendor/Rsc/Dispatcher.php +8 -8
- vendor/Rsc/Environment.php +53 -43
- vendor/Rsc/Environment/Aware.php +4 -4
- vendor/Rsc/Environment/AwareInterface.php +3 -3
- vendor/Rsc/Exception/ConfigLoaderException.php +1 -1
- vendor/Rsc/Exception/EnvironmentRuntimeException.php +1 -1
- vendor/Rsc/Exception/LangException.php +1 -1
- vendor/Rsc/Feedback/Mailer.php +6 -6
- vendor/Rsc/Feedback/SupportMailer.php +9 -9
- vendor/Rsc/Form/Filter/Custom.php +1 -1
- vendor/Rsc/Form/Filter/Interface.php +1 -1
- vendor/Rsc/Form/Filter/XssClear.php +1 -1
- vendor/Rsc/Form/Rule/Interface.php +1 -1
- vendor/Rsc/Form/Rule/Numeric.php +2 -2
- vendor/Rsc/Form/Rule/Regex.php +3 -3
- vendor/Rsc/Form/Rule/Required.php +3 -3
- vendor/Rsc/Form/Validator.php +27 -27
- vendor/Rsc/Form/Validator/EmptyRequestException.php +1 -1
- vendor/Rsc/Form/Validator/InvalidMethodException.php +1 -1
- vendor/Rsc/Form/Validator/UnexpectedRuleException.php +1 -1
- vendor/Rsc/Html.php +1 -1
- vendor/Rsc/Http/Parameters.php +2 -2
- vendor/Rsc/Http/Request.php +12 -12
- vendor/Rsc/Http/Response.php +3 -3
- vendor/Rsc/Http/ServerParameters.php +1 -1
- vendor/Rsc/Installer.php +4 -4
- vendor/Rsc/Installer/Parser.php +2 -2
- vendor/Rsc/Installer/PhpParser.php +1 -1
- vendor/Rsc/Lang.php +11 -11
- vendor/Rsc/Logger.php +3 -3
- vendor/Rsc/Logger/AwareInterface.php +3 -3
- vendor/Rsc/Logger/Exception/InvalidPathException.php +2 -2
- vendor/Rsc/Logger/Interface.php +1 -1
- vendor/Rsc/Menu/Item.php +9 -9
- vendor/Rsc/Menu/Page.php +16 -16
- vendor/Rsc/Mvc/Controller.php +14 -14
- vendor/Rsc/Mvc/Model.php +1 -1
- vendor/Rsc/Mvc/Module.php +13 -13
- vendor/Rsc/Profiler.php +1 -1
- vendor/Rsc/Resolver.php +20 -20
- vendor/Twig/Autoloader.php +5 -5
- vendor/Twig/BaseNodeVisitor.php +12 -12
- vendor/Twig/Cache/Filesystem.php +1 -1
- vendor/Twig/Cache/Null.php +1 -1
- vendor/Twig/CacheInterface.php +1 -1
- vendor/Twig/Compiler.php +11 -11
- vendor/Twig/CompilerInterface.php +2 -2
- vendor/Twig/ContainerRuntimeLoader.php +1 -1
- vendor/Twig/Environment.php +158 -158
- vendor/Twig/Error.php +12 -12
- vendor/Twig/Error/Loader.php +3 -3
- vendor/Twig/Error/Runtime.php +1 -1
- vendor/Twig/Error/Syntax.php +1 -1
- vendor/Twig/ExistsLoaderInterface.php +1 -1
- vendor/Twig/ExpressionParser.php +140 -140
- vendor/Twig/Extension.php +4 -4
- vendor/Twig/Extension/Core.php +230 -230
- vendor/Twig/Extension/Debug.php +4 -4
- vendor/Twig/Extension/Escaper.php +8 -8
- vendor/Twig/Extension/GlobalsInterface.php +2 -2
- vendor/Twig/Extension/InitRuntimeInterface.php +2 -2
- vendor/Twig/Extension/Optimizer.php +2 -2
- vendor/Twig/Extension/Profiler.php +5 -5
- vendor/Twig/Extension/Sandbox.php +5 -5
- vendor/Twig/Extension/Staging.php +4 -4
- vendor/Twig/Extension/StringLoader.php +5 -5
- vendor/Twig/ExtensionInterface.php +9 -9
- vendor/Twig/FactoryRuntimeLoader.php +1 -1
- vendor/Twig/FileExtensionEscapingStrategy.php +1 -1
- vendor/Twig/Filter.php +4 -4
- vendor/Twig/Filter/Function.php +3 -3
- vendor/Twig/Filter/Method.php +4 -4
- vendor/Twig/Filter/Node.php +3 -3
- vendor/Twig/FilterCallableInterface.php +2 -2
- vendor/Twig/FilterInterface.php +3 -3
- vendor/Twig/Function.php +4 -4
- vendor/Twig/Function/Function.php +3 -3
- vendor/Twig/Function/Method.php +4 -4
- vendor/Twig/Function/Node.php +3 -3
- vendor/Twig/FunctionCallableInterface.php +2 -2
- vendor/Twig/FunctionInterface.php +3 -3
- vendor/Twig/Lexer.php +48 -48
- vendor/Twig/LexerInterface.php +4 -4
- vendor/Twig/Loader/Array.php +7 -7
- vendor/Twig/Loader/Chain.php +21 -21
- vendor/Twig/Loader/Filesystem.php +17 -17
- vendor/Twig/Loader/String.php +4 -4
- vendor/Twig/LoaderInterface.php +5 -5
- vendor/Twig/Markup.php +2 -2
- vendor/Twig/Node.php +18 -16
- vendor/Twig/Node/AutoEscape.php +3 -3
- vendor/Twig/Node/Block.php +3 -3
- vendor/Twig/Node/BlockReference.php +2 -2
- vendor/Twig/Node/Body.php +1 -1
- vendor/Twig/Node/CheckSecurity.php +8 -8
- vendor/Twig/Node/Do.php +3 -3
- vendor/Twig/Node/Embed.php +4 -4
- vendor/Twig/Node/Expression.php +1 -1
- vendor/Twig/Node/Expression/Array.php +6 -6
- vendor/Twig/Node/Expression/AssignName.php +2 -2
- vendor/Twig/Node/Expression/Binary.php +4 -4
- vendor/Twig/Node/Expression/Binary/Add.php +2 -2
- vendor/Twig/Node/Expression/Binary/And.php +2 -2
- vendor/Twig/Node/Expression/Binary/BitwiseAnd.php +2 -2
- vendor/Twig/Node/Expression/Binary/BitwiseOr.php +2 -2
- vendor/Twig/Node/Expression/Binary/BitwiseXor.php +2 -2
- vendor/Twig/Node/Expression/Binary/Concat.php +2 -2
- vendor/Twig/Node/Expression/Binary/Div.php +2 -2
- vendor/Twig/Node/Expression/Binary/EndsWith.php +3 -3
- vendor/Twig/Node/Expression/Binary/Equal.php +2 -2
- vendor/Twig/Node/Expression/Binary/FloorDiv.php +3 -3
- vendor/Twig/Node/Expression/Binary/Greater.php +2 -2
- vendor/Twig/Node/Expression/Binary/GreaterEqual.php +2 -2
- vendor/Twig/Node/Expression/Binary/In.php +4 -4
- vendor/Twig/Node/Expression/Binary/Less.php +2 -2
- vendor/Twig/Node/Expression/Binary/LessEqual.php +2 -2
- vendor/Twig/Node/Expression/Binary/Matches.php +3 -3
- vendor/Twig/Node/Expression/Binary/Mod.php +2 -2
- vendor/Twig/Node/Expression/Binary/Mul.php +2 -2
- vendor/Twig/Node/Expression/Binary/NotEqual.php +2 -2
- vendor/Twig/Node/Expression/Binary/NotIn.php +4 -4
- vendor/Twig/Node/Expression/Binary/Or.php +2 -2
- vendor/Twig/Node/Expression/Binary/Power.php +3 -3
- vendor/Twig/Node/Expression/Binary/Range.php +3 -3
- vendor/Twig/Node/Expression/Binary/StartsWith.php +3 -3
- vendor/Twig/Node/Expression/Binary/Sub.php +2 -2
- vendor/Twig/Node/Expression/BlockReference.php +7 -7
- vendor/Twig/Node/Expression/Call.php +13 -13
- vendor/Twig/Node/Expression/Conditional.php +3 -3
- vendor/Twig/Node/Expression/Constant.php +2 -2
- vendor/Twig/Node/Expression/ExtensionReference.php +3 -3
- vendor/Twig/Node/Expression/Filter.php +5 -5
- vendor/Twig/Node/Expression/Filter/Default.php +8 -8
- vendor/Twig/Node/Expression/Function.php +6 -6
- vendor/Twig/Node/Expression/GetAttr.php +7 -7
- vendor/Twig/Node/Expression/MethodCall.php +4 -4
- vendor/Twig/Node/Expression/Name.php +2 -2
- vendor/Twig/Node/Expression/NullCoalesce.php +7 -7
- vendor/Twig/Node/Expression/Parent.php +2 -2
- vendor/Twig/Node/Expression/TempName.php +2 -2
- vendor/Twig/Node/Expression/Test.php +5 -5
- vendor/Twig/Node/Expression/Test/Constant.php +2 -2
- vendor/Twig/Node/Expression/Test/Defined.php +12 -12
- vendor/Twig/Node/Expression/Test/Divisibleby.php +2 -2
- vendor/Twig/Node/Expression/Test/Even.php +2 -2
- vendor/Twig/Node/Expression/Test/Null.php +2 -2
- vendor/Twig/Node/Expression/Test/Odd.php +2 -2
- vendor/Twig/Node/Expression/Test/Sameas.php +2 -2
- vendor/Twig/Node/Expression/Unary.php +4 -4
- vendor/Twig/Node/Expression/Unary/Neg.php +2 -2
- vendor/Twig/Node/Expression/Unary/Not.php +2 -2
- vendor/Twig/Node/Expression/Unary/Pos.php +2 -2
- vendor/Twig/Node/Flush.php +2 -2
- vendor/Twig/Node/For.php +6 -6
- vendor/Twig/Node/ForLoop.php +2 -2
- vendor/Twig/Node/If.php +3 -3
- vendor/Twig/Node/Import.php +4 -4
- vendor/Twig/Node/Include.php +6 -6
- vendor/Twig/Node/Macro.php +5 -5
- vendor/Twig/Node/Module.php +38 -38
- vendor/Twig/Node/Print.php +3 -3
- vendor/Twig/Node/Sandbox.php +4 -4
- vendor/Twig/Node/SandboxedPrint.php +7 -7
- vendor/Twig/Node/Set.php +8 -8
- vendor/Twig/Node/SetTemp.php +2 -2
- vendor/Twig/Node/Spaceless.php +3 -3
- vendor/Twig/Node/Text.php +2 -2
- vendor/Twig/Node/With.php +4 -4
- vendor/Twig/NodeCaptureInterface.php +1 -1
- vendor/Twig/NodeInterface.php +2 -2
- vendor/Twig/NodeOutputInterface.php +1 -1
- vendor/Twig/NodeTraverser.php +9 -9
- vendor/Twig/NodeVisitor/Escaper.php +24 -24
- vendor/Twig/NodeVisitor/Optimizer.php +37 -37
- vendor/Twig/NodeVisitor/SafeAnalysis.php +13 -13
- vendor/Twig/NodeVisitor/Sandbox.php +11 -11
- vendor/Twig/NodeVisitorInterface.php +6 -6
- vendor/Twig/Parser.php +43 -43
- vendor/Twig/ParserInterface.php +4 -4
- vendor/Twig/Profiler/Dumper/Blackfire.php +4 -4
- vendor/Twig/Profiler/Dumper/Html.php +5 -5
- vendor/Twig/Profiler/Dumper/Text.php +6 -6
- vendor/Twig/Profiler/Node/EnterProfile.php +3 -3
- vendor/Twig/Profiler/Node/LeaveProfile.php +2 -2
- vendor/Twig/Profiler/NodeVisitor/Profiler.php +14 -14
- vendor/Twig/Profiler/Profile.php +2 -2
- vendor/Twig/RuntimeLoaderInterface.php +1 -1
- vendor/Twig/Sandbox/SecurityError.php +1 -1
- vendor/Twig/Sandbox/SecurityNotAllowedFilterError.php +1 -1
- vendor/Twig/Sandbox/SecurityNotAllowedFunctionError.php +1 -1
- vendor/Twig/Sandbox/SecurityNotAllowedMethodError.php +1 -1
- vendor/Twig/Sandbox/SecurityNotAllowedPropertyError.php +1 -1
- vendor/Twig/Sandbox/SecurityNotAllowedTagError.php +1 -1
- vendor/Twig/Sandbox/SecurityPolicy.php +7 -7
- vendor/Twig/Sandbox/SecurityPolicyInterface.php +1 -1
- vendor/Twig/SimpleFilter.php +3 -3
- vendor/Twig/SimpleFunction.php +3 -3
- vendor/Twig/SimpleTest.php +2 -2
- vendor/Twig/Source.php +1 -1
- vendor/Twig/SourceContextLoaderInterface.php +3 -3
- vendor/Twig/Template.php +40 -40
- vendor/Twig/TemplateInterface.php +2 -2
- vendor/Twig/TemplateWrapper.php +4 -4
- vendor/Twig/Test.php +2 -2
- vendor/Twig/Test/Function.php +2 -2
- vendor/Twig/Test/IntegrationTestCase.php +11 -11
- vendor/Twig/Test/Method.php +3 -3
- vendor/Twig/Test/Node.php +2 -2
- vendor/Twig/Test/NodeTestCase.php +7 -7
- vendor/Twig/TestCallableInterface.php +1 -1
- vendor/Twig/TestInterface.php +1 -1
- vendor/Twig/Token.php +2 -2
- vendor/Twig/TokenParser.php +3 -3
- vendor/Twig/TokenParser/AutoEscape.php +12 -12
- vendor/Twig/TokenParser/Block.php +13 -13
- vendor/Twig/TokenParser/Do.php +4 -4
- vendor/Twig/TokenParser/Embed.php +13 -13
- vendor/Twig/TokenParser/Extends.php +5 -5
- vendor/Twig/TokenParser/Filter.php +8 -8
- vendor/Twig/TokenParser/Flush.php +4 -4
- vendor/Twig/TokenParser/For.php +22 -22
- vendor/Twig/TokenParser/From.php +8 -8
- vendor/Twig/TokenParser/If.php +10 -10
- vendor/Twig/TokenParser/Import.php +5 -5
- vendor/Twig/TokenParser/Include.php +8 -8
- vendor/Twig/TokenParser/Macro.php +9 -9
- vendor/Twig/TokenParser/Sandbox.php +10 -10
- vendor/Twig/TokenParser/Set.php +10 -10
- vendor/Twig/TokenParser/Spaceless.php +6 -6
- vendor/Twig/TokenParser/Use.php +10 -10
- vendor/Twig/TokenParser/With.php +8 -8
- vendor/Twig/TokenParserBroker.php +14 -14
- vendor/Twig/TokenParserBrokerInterface.php +6 -6
- vendor/Twig/TokenParserInterface.php +5 -5
- vendor/Twig/TokenStream.php +18 -18
- vendor/Twig/Util/DeprecationCollector.php +5 -5
- vendor/Twig/Util/TemplateDirIterator.php +1 -1
app/SupsysticGallery.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
class SupsysticGallery
|
8 |
{
|
9 |
/**
|
10 |
-
* @var
|
11 |
*/
|
12 |
private $environment;
|
13 |
|
@@ -21,16 +21,16 @@ class SupsysticGallery
|
|
21 |
*/
|
22 |
public function __construct($version)
|
23 |
{
|
24 |
-
if (!class_exists('
|
25 |
require dirname(dirname(__FILE__)) . '/vendor/Rsc/Autoloader.php';
|
26 |
-
|
27 |
}
|
28 |
add_action('init', array($this, '_loadPluginsTextdomain'));
|
29 |
add_action('init', array($this, 'addShortcodeButton'));
|
30 |
|
31 |
/* Create new plugin $environment */
|
32 |
$pluginPath = dirname(dirname(__FILE__));
|
33 |
-
$environment = new
|
34 |
|
35 |
/* Configure */
|
36 |
$environment->configure(
|
@@ -159,22 +159,22 @@ class SupsysticGallery
|
|
159 |
$this->initFilesystem();
|
160 |
|
161 |
/* Initialize cache null-adapter by default */
|
162 |
-
$cacheAdapter = new
|
163 |
|
164 |
/* Initialize the log system first. */
|
165 |
if (null !== $logDir = $config->get('plugin_log', null)) {
|
166 |
if (is_dir($logDir) && is_writable($logDir)) {
|
167 |
-
$logger = new
|
168 |
$this->environment->setLogger($logger);
|
169 |
}
|
170 |
}
|
171 |
|
172 |
/* If it's a production environment and cache directory is OK */
|
173 |
-
if ($config->isEnvironment(
|
174 |
&& null !== $cacheDir = $config->get('plugin_cache', null)
|
175 |
) {
|
176 |
if (is_dir($cacheDir) && is_writable($cacheDir)) {
|
177 |
-
$cacheAdapter = new
|
178 |
} else {
|
179 |
if ($logger) {
|
180 |
$logger->error(
|
@@ -236,15 +236,15 @@ class SupsysticGallery
|
|
236 |
|
237 |
/**
|
238 |
* Get plugin enviroment develop or production
|
239 |
-
* @return
|
240 |
*/
|
241 |
protected function getPluginEnvironment()
|
242 |
{
|
243 |
-
$environment =
|
244 |
|
245 |
if (defined('WP_DEBUG') && WP_DEBUG) {
|
246 |
if (defined('SUPSYSTIC_GRID_GALLERY_DEBUG') && SUPSYSTIC_GRID_GALLERY_DEBUG) {
|
247 |
-
$environment =
|
248 |
}
|
249 |
}
|
250 |
|
@@ -253,7 +253,7 @@ class SupsysticGallery
|
|
253 |
|
254 |
/**
|
255 |
* get gallery Environment for other supsystic plugins
|
256 |
-
* @return
|
257 |
*/
|
258 |
public function getEnvironment() {
|
259 |
return $this->environment;
|
7 |
class SupsysticGallery
|
8 |
{
|
9 |
/**
|
10 |
+
* @var RscSgg_Environment
|
11 |
*/
|
12 |
private $environment;
|
13 |
|
21 |
*/
|
22 |
public function __construct($version)
|
23 |
{
|
24 |
+
if (!class_exists('RscSgg_Autoloader', false)) {
|
25 |
require dirname(dirname(__FILE__)) . '/vendor/Rsc/Autoloader.php';
|
26 |
+
RscSgg_Autoloader::register();
|
27 |
}
|
28 |
add_action('init', array($this, '_loadPluginsTextdomain'));
|
29 |
add_action('init', array($this, 'addShortcodeButton'));
|
30 |
|
31 |
/* Create new plugin $environment */
|
32 |
$pluginPath = dirname(dirname(__FILE__));
|
33 |
+
$environment = new RscSgg_Environment('sgg', $version, $pluginPath);
|
34 |
|
35 |
/* Configure */
|
36 |
$environment->configure(
|
159 |
$this->initFilesystem();
|
160 |
|
161 |
/* Initialize cache null-adapter by default */
|
162 |
+
$cacheAdapter = new RscSgg_Cache_Dummy();
|
163 |
|
164 |
/* Initialize the log system first. */
|
165 |
if (null !== $logDir = $config->get('plugin_log', null)) {
|
166 |
if (is_dir($logDir) && is_writable($logDir)) {
|
167 |
+
$logger = new RscSgg_Logger($logDir);
|
168 |
$this->environment->setLogger($logger);
|
169 |
}
|
170 |
}
|
171 |
|
172 |
/* If it's a production environment and cache directory is OK */
|
173 |
+
if ($config->isEnvironment(RscSgg_Environment::ENV_PRODUCTION)
|
174 |
&& null !== $cacheDir = $config->get('plugin_cache', null)
|
175 |
) {
|
176 |
if (is_dir($cacheDir) && is_writable($cacheDir)) {
|
177 |
+
$cacheAdapter = new RscSgg_Cache_Filesystem($cacheDir);
|
178 |
} else {
|
179 |
if ($logger) {
|
180 |
$logger->error(
|
236 |
|
237 |
/**
|
238 |
* Get plugin enviroment develop or production
|
239 |
+
* @return RscSgg_Environment ENV_PRODUCTION or ENV_DEVELOPMENT
|
240 |
*/
|
241 |
protected function getPluginEnvironment()
|
242 |
{
|
243 |
+
$environment = RscSgg_Environment::ENV_PRODUCTION;
|
244 |
|
245 |
if (defined('WP_DEBUG') && WP_DEBUG) {
|
246 |
if (defined('SUPSYSTIC_GRID_GALLERY_DEBUG') && SUPSYSTIC_GRID_GALLERY_DEBUG) {
|
247 |
+
$environment = RscSgg_Environment::ENV_DEVELOPMENT;
|
248 |
}
|
249 |
}
|
250 |
|
253 |
|
254 |
/**
|
255 |
* get gallery Environment for other supsystic plugins
|
256 |
+
* @return RscSgg_Environment
|
257 |
*/
|
258 |
public function getEnvironment() {
|
259 |
return $this->environment;
|
app/langs/default.po
CHANGED
@@ -1955,7 +1955,7 @@ msgid ""
|
|
1955 |
" );\n"
|
1956 |
" }\n"
|
1957 |
"\n"
|
1958 |
-
" public function chooseAction(
|
1959 |
" {\n"
|
1960 |
" $resourceId = $request->post->get('resources"
|
1961 |
msgstr ""
|
1955 |
" );\n"
|
1956 |
" }\n"
|
1957 |
"\n"
|
1958 |
+
" public function chooseAction(RscSgg_Http_Request $request)\n"
|
1959 |
" {\n"
|
1960 |
" $resourceId = $request->post->get('resources"
|
1961 |
msgstr ""
|
app/langs/sgg-ca.po
CHANGED
@@ -2244,7 +2244,7 @@ msgid ""
|
|
2244 |
"\t\t);\n"
|
2245 |
" }\n"
|
2246 |
"\n"
|
2247 |
-
" public function chooseAction(
|
2248 |
" {\n"
|
2249 |
" $resourceId = $request->post->get('resources"
|
2250 |
msgstr ""
|
@@ -2259,7 +2259,7 @@ msgstr ""
|
|
2259 |
"\t\t);\n"
|
2260 |
" }\n"
|
2261 |
"\n"
|
2262 |
-
" public function chooseAction(
|
2263 |
" {\n"
|
2264 |
" $resourceId = $request->post->get(‘resources"
|
2265 |
|
2244 |
"\t\t);\n"
|
2245 |
" }\n"
|
2246 |
"\n"
|
2247 |
+
" public function chooseAction(RscSgg_Http_Request $request)\n"
|
2248 |
" {\n"
|
2249 |
" $resourceId = $request->post->get('resources"
|
2250 |
msgstr ""
|
2259 |
"\t\t);\n"
|
2260 |
" }\n"
|
2261 |
"\n"
|
2262 |
+
" public function chooseAction(RscSgg_Http_Request $request)\n"
|
2263 |
" {\n"
|
2264 |
" $resourceId = $request->post->get(‘resources"
|
2265 |
|
app/langs/sgg-es_ES.po
CHANGED
@@ -2260,7 +2260,7 @@ msgid ""
|
|
2260 |
"\t\t);\n"
|
2261 |
" }\n"
|
2262 |
"\n"
|
2263 |
-
" public function chooseAction(
|
2264 |
" {\n"
|
2265 |
" $resourceId = $request->post->get('resources"
|
2266 |
msgstr ""
|
@@ -2268,7 +2268,7 @@ msgstr ""
|
|
2268 |
"' = > (int) $Gallery-> ID, ' RedirectURL ' = > $this-> getEnvironment ()-> "
|
2269 |
"GENERATEURL (' Galleries ', ' View ', array (' gallery_id ' = > $Gallery-> "
|
2270 |
"ID))));\n"
|
2271 |
-
" } Public Function Chooseaction (
|
2272 |
"= $request-> post-> get (' recursos"
|
2273 |
|
2274 |
msgid "The title can't be empty"
|
2260 |
"\t\t);\n"
|
2261 |
" }\n"
|
2262 |
"\n"
|
2263 |
+
" public function chooseAction(RscSgg_Http_Request $request)\n"
|
2264 |
" {\n"
|
2265 |
" $resourceId = $request->post->get('resources"
|
2266 |
msgstr ""
|
2268 |
"' = > (int) $Gallery-> ID, ' RedirectURL ' = > $this-> getEnvironment ()-> "
|
2269 |
"GENERATEURL (' Galleries ', ' View ', array (' gallery_id ' = > $Gallery-> "
|
2270 |
"ID))));\n"
|
2271 |
+
" } Public Function Chooseaction (RscSgg_http_request $request) {$ResourceID "
|
2272 |
"= $request-> post-> get (' recursos"
|
2273 |
|
2274 |
msgid "The title can't be empty"
|
app/langs/sgg-fr_FR.po
CHANGED
@@ -2248,7 +2248,7 @@ msgid ""
|
|
2248 |
"\t\t);\n"
|
2249 |
" }\n"
|
2250 |
"\n"
|
2251 |
-
" public function chooseAction(
|
2252 |
" {\n"
|
2253 |
" $resourceId = $request->post->get('resources"
|
2254 |
msgstr ""
|
@@ -2263,7 +2263,7 @@ msgstr ""
|
|
2263 |
"\t\t);\n"
|
2264 |
" }\n"
|
2265 |
"\n"
|
2266 |
-
" public function chooseAction(
|
2267 |
" {\n"
|
2268 |
" $resourceId = $request->post->get('resources"
|
2269 |
|
2248 |
"\t\t);\n"
|
2249 |
" }\n"
|
2250 |
"\n"
|
2251 |
+
" public function chooseAction(RscSgg_Http_Request $request)\n"
|
2252 |
" {\n"
|
2253 |
" $resourceId = $request->post->get('resources"
|
2254 |
msgstr ""
|
2263 |
"\t\t);\n"
|
2264 |
" }\n"
|
2265 |
"\n"
|
2266 |
+
" public function chooseAction(RscSgg_Http_Request $request)\n"
|
2267 |
" {\n"
|
2268 |
" $resourceId = $request->post->get('resources"
|
2269 |
|
app/langs/sgg-it_IT.po
CHANGED
@@ -2252,7 +2252,7 @@ msgid ""
|
|
2252 |
"\t\t);\n"
|
2253 |
" }\n"
|
2254 |
"\n"
|
2255 |
-
" public function chooseAction(
|
2256 |
" {\n"
|
2257 |
" $resourceId = $request->post->get('resources"
|
2258 |
msgstr ""
|
@@ -2267,7 +2267,7 @@ msgstr ""
|
|
2267 |
"\t\t);\n"
|
2268 |
" }\n"
|
2269 |
"\n"
|
2270 |
-
" public function chooseAction(
|
2271 |
" {\n"
|
2272 |
" $resourceId = $request->post->get('resources"
|
2273 |
|
2252 |
"\t\t);\n"
|
2253 |
" }\n"
|
2254 |
"\n"
|
2255 |
+
" public function chooseAction(RscSgg_Http_Request $request)\n"
|
2256 |
" {\n"
|
2257 |
" $resourceId = $request->post->get('resources"
|
2258 |
msgstr ""
|
2267 |
"\t\t);\n"
|
2268 |
" }\n"
|
2269 |
"\n"
|
2270 |
+
" public function chooseAction(RscSgg_Http_Request $request)\n"
|
2271 |
" {\n"
|
2272 |
" $resourceId = $request->post->get('resources"
|
2273 |
|
app/langs/sgg-zh_CN.po
CHANGED
@@ -2155,7 +2155,7 @@ msgid ""
|
|
2155 |
"\t\t);\n"
|
2156 |
" }\n"
|
2157 |
"\n"
|
2158 |
-
" public function chooseAction(
|
2159 |
" {\n"
|
2160 |
" $resourceId = $request->post->get('resources"
|
2161 |
msgstr ""
|
2155 |
"\t\t);\n"
|
2156 |
" }\n"
|
2157 |
"\n"
|
2158 |
+
" public function chooseAction(RscSgg_Http_Request $request)\n"
|
2159 |
" {\n"
|
2160 |
" $resourceId = $request->post->get('resources"
|
2161 |
msgstr ""
|
app/templates/grid-gallery.twig
CHANGED
@@ -105,7 +105,7 @@
|
|
105 |
<div class="supsystic-footer-wrapper">
|
106 |
<div class="supsystic-footer-add-review">Add your <a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/gallery-by-supsystic?filter=5#postform">★★★★★</a> on wordpress.org</div>
|
107 |
<a href="https://supsystic.com/" target="_blank"><img src="{{SGG_PLUGIN_URL}}/src/GridGallery/Overview/assets/img/supsystic-logo-small.png"></a>
|
108 |
-
<div class="supsystic-footer-plugin-version">Photo Gallery by Supsystic Version: {{SGG_PLUGIN_VERSION}}</div>
|
109 |
</div>
|
110 |
</section>
|
111 |
</div>
|
105 |
<div class="supsystic-footer-wrapper">
|
106 |
<div class="supsystic-footer-add-review">Add your <a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/gallery-by-supsystic?filter=5#postform">★★★★★</a> on wordpress.org</div>
|
107 |
<a href="https://supsystic.com/" target="_blank"><img src="{{SGG_PLUGIN_URL}}/src/GridGallery/Overview/assets/img/supsystic-logo-small.png"></a>
|
108 |
+
<div class="supsystic-footer-plugin-version">Photo Gallery by Supsystic Version: {{' '}} {{SGG_PLUGIN_VERSION}}</div>
|
109 |
</div>
|
110 |
</section>
|
111 |
</div>
|
index.php
CHANGED
@@ -3,17 +3,37 @@
|
|
3 |
/**
|
4 |
* Plugin Name: Photo Gallery by Supsystic
|
5 |
* Description: Easy to use Gallery by Supsystic with professional gallery templates. Show off your best design, photography and creative work
|
6 |
-
* Version: 1.15.
|
7 |
* Author: supsystic.com
|
8 |
* Author URI: https://supsystic.com
|
9 |
* Text Domain: grid-gallery
|
10 |
**/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
require_once dirname(__FILE__) . '/app/SupsysticGallery.php';
|
13 |
|
14 |
if (!defined('SGG_PLUGIN_URL')) {
|
15 |
define('SGG_PLUGIN_URL', plugin_dir_url( __FILE__ ));
|
16 |
}
|
17 |
|
18 |
-
$supsysticGallery = new SupsysticGallery('1.15.
|
19 |
$supsysticGallery->run();
|
3 |
/**
|
4 |
* Plugin Name: Photo Gallery by Supsystic
|
5 |
* Description: Easy to use Gallery by Supsystic with professional gallery templates. Show off your best design, photography and creative work
|
6 |
+
* Version: 1.15.11
|
7 |
* Author: supsystic.com
|
8 |
* Author URI: https://supsystic.com
|
9 |
* Text Domain: grid-gallery
|
10 |
**/
|
11 |
|
12 |
+
//Fix RSC Class rename for PRO plugin
|
13 |
+
function sggChangeProVersionNotice(){
|
14 |
+
global $pagenow;
|
15 |
+
if ( $pagenow == 'admin.php' || $pagenow == 'plugins.php' ) {
|
16 |
+
echo '<div class="notice notice-warning is-dismissible"><p><b>WARNING!</b> You using <b>OLD Photo Gallery by Supsystic PRO</b> version! For continued use and before activating the PRO plugin - please <b>UPDATE PRO VERSION</b>. Thank you. <br><b>You can download new compatible PRO version direct from this <a href="https://supsystic.com/pro/supsystic-gallery-pro.zip">LINK</a></b>.</p></div>';
|
17 |
+
}
|
18 |
+
}
|
19 |
+
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
20 |
+
$proPluginPath = dirname(__FILE__);
|
21 |
+
$proPluginPath = str_replace('gallery-supsystic', 'supsystic-gallery-pro', $proPluginPath);
|
22 |
+
$proPluginPath = str_replace('gallery-by-supsystic', 'supsystic-gallery-pro', $proPluginPath);
|
23 |
+
$proPluginPath = $proPluginPath . '/index.php';
|
24 |
+
if (file_exists($proPluginPath)) {
|
25 |
+
$pluginData = get_file_data($proPluginPath, array('Version' => 'Version'), false);
|
26 |
+
if (!empty($pluginData['Version']) && version_compare($pluginData['Version'], '2.9.7', '<')) {
|
27 |
+
add_action('admin_notices', 'sggChangeProVersionNotice');
|
28 |
+
deactivate_plugins('supsystic-gallery-pro/index.php');
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
require_once dirname(__FILE__) . '/app/SupsysticGallery.php';
|
33 |
|
34 |
if (!defined('SGG_PLUGIN_URL')) {
|
35 |
define('SGG_PLUGIN_URL', plugin_dir_url( __FILE__ ));
|
36 |
}
|
37 |
|
38 |
+
$supsysticGallery = new SupsysticGallery('1.15.11');
|
39 |
$supsysticGallery->run();
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: supsystic.com
|
|
3 |
Donate link: https://supsystic.com/plugins/gallery
|
4 |
Tags: gallery, wordpress gallery plugin, photo gallery, grid gallery, image gallery, video gallery, responsive gallery, polaroid gallery
|
5 |
Tested up to: 6.0
|
6 |
-
Stable tag: 1.15.
|
7 |
|
8 |
Photo Gallery with template editor to build amazing media gallery. Responsive mobile gallery with grid, masonry, carousel, polaroid and more gallery
|
9 |
|
@@ -176,6 +176,13 @@ Add watermark on each image in your gallery and you protect your photos from the
|
|
176 |
14. Photo gallery plugin admin area. Captions and Icons tab. Create impressive gallery with icons and fantastic caption effect.
|
177 |
|
178 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
= Gallery 1.15.9 / 06.07.2022 =
|
180 |
* Fixes for interface overview
|
181 |
|
3 |
Donate link: https://supsystic.com/plugins/gallery
|
4 |
Tags: gallery, wordpress gallery plugin, photo gallery, grid gallery, image gallery, video gallery, responsive gallery, polaroid gallery
|
5 |
Tested up to: 6.0
|
6 |
+
Stable tag: 1.15.11
|
7 |
|
8 |
Photo Gallery with template editor to build amazing media gallery. Responsive mobile gallery with grid, masonry, carousel, polaroid and more gallery
|
9 |
|
176 |
14. Photo gallery plugin admin area. Captions and Icons tab. Create impressive gallery with icons and fantastic caption effect.
|
177 |
|
178 |
== Changelog ==
|
179 |
+
= Gallery 1.15.11 / 30.08.2022 =
|
180 |
+
* required PRO min 2.9.7
|
181 |
+
|
182 |
+
= Gallery 1.15.10 / 30.08.2022 =
|
183 |
+
* Add support WP 6.0
|
184 |
+
* Add support PHP 8.1
|
185 |
+
|
186 |
= Gallery 1.15.9 / 06.07.2022 =
|
187 |
* Fixes for interface overview
|
188 |
|
src/GridGallery/Ajax/Handler.php
CHANGED
@@ -11,14 +11,14 @@ class GridGallery_Ajax_Handler
|
|
11 |
{
|
12 |
|
13 |
/**
|
14 |
-
* @var
|
15 |
*/
|
16 |
protected $environment;
|
17 |
|
18 |
/**
|
19 |
-
* @param
|
20 |
*/
|
21 |
-
public function __construct(
|
22 |
{
|
23 |
$this->environment = $environment;
|
24 |
}
|
@@ -28,7 +28,7 @@ class GridGallery_Ajax_Handler
|
|
28 |
*/
|
29 |
public function handle()
|
30 |
{
|
31 |
-
$request =
|
32 |
|
33 |
if ($this->isPostRequest($request)) {
|
34 |
return $this->handleRequest($request->post);
|
@@ -38,12 +38,12 @@ class GridGallery_Ajax_Handler
|
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
-
* @param
|
42 |
* @return bool
|
43 |
*/
|
44 |
-
public function handleRequest(
|
45 |
{
|
46 |
-
/** @var
|
47 |
if (!$method->has('route')) {
|
48 |
return false;
|
49 |
}
|
@@ -87,19 +87,19 @@ class GridGallery_Ajax_Handler
|
|
87 |
|
88 |
/**
|
89 |
*
|
90 |
-
* @param
|
91 |
* @return bool
|
92 |
*/
|
93 |
-
public function isPostRequest(
|
94 |
{
|
95 |
return ($request->post->has('route'));
|
96 |
}
|
97 |
|
98 |
/**
|
99 |
-
* @param
|
100 |
* @return bool
|
101 |
*/
|
102 |
-
public function isGetRequest(
|
103 |
{
|
104 |
return ($request->query->has('route'));
|
105 |
}
|
11 |
{
|
12 |
|
13 |
/**
|
14 |
+
* @var RscSgg_Environment
|
15 |
*/
|
16 |
protected $environment;
|
17 |
|
18 |
/**
|
19 |
+
* @param RscSgg_Environment $environment
|
20 |
*/
|
21 |
+
public function __construct(RscSgg_Environment $environment)
|
22 |
{
|
23 |
$this->environment = $environment;
|
24 |
}
|
28 |
*/
|
29 |
public function handle()
|
30 |
{
|
31 |
+
$request = RscSgg_Http_Request::create();
|
32 |
|
33 |
if ($this->isPostRequest($request)) {
|
34 |
return $this->handleRequest($request->post);
|
38 |
}
|
39 |
|
40 |
/**
|
41 |
+
* @param RscSgg_Http_Parameters $method
|
42 |
* @return bool
|
43 |
*/
|
44 |
+
public function handleRequest(RscSgg_Http_Parameters $method)
|
45 |
{
|
46 |
+
/** @var RscSgg_Mvc_Module $module */
|
47 |
if (!$method->has('route')) {
|
48 |
return false;
|
49 |
}
|
87 |
|
88 |
/**
|
89 |
*
|
90 |
+
* @param RscSgg_Http_Request $request
|
91 |
* @return bool
|
92 |
*/
|
93 |
+
public function isPostRequest(RscSgg_Http_Request $request)
|
94 |
{
|
95 |
return ($request->post->has('route'));
|
96 |
}
|
97 |
|
98 |
/**
|
99 |
+
* @param RscSgg_Http_Request $request
|
100 |
* @return bool
|
101 |
*/
|
102 |
+
public function isGetRequest(RscSgg_Http_Request $request)
|
103 |
{
|
104 |
return ($request->query->has('route'));
|
105 |
}
|
src/GridGallery/Ajax/Module.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* @package GridGallery\Ajax
|
8 |
* @author Artur Kovalevsky
|
9 |
*/
|
10 |
-
class GridGallery_Ajax_Module extends
|
11 |
{
|
12 |
|
13 |
/**
|
7 |
* @package GridGallery\Ajax
|
8 |
* @author Artur Kovalevsky
|
9 |
*/
|
10 |
+
class GridGallery_Ajax_Module extends RscSgg_Mvc_Module
|
11 |
{
|
12 |
|
13 |
/**
|
src/GridGallery/Core/BaseController.php
CHANGED
@@ -7,13 +7,13 @@
|
|
7 |
* @package GridGallery\Core
|
8 |
* @author Artur Kovalevsky
|
9 |
*/
|
10 |
-
class GridGallery_Core_BaseController extends
|
11 |
{
|
12 |
|
13 |
/**
|
14 |
* Constructor
|
15 |
*/
|
16 |
-
public function __construct(
|
17 |
{
|
18 |
parent::__construct($environment, $request);
|
19 |
if ($environment->isPluginPage() && !$environment->isModule('license')
|
@@ -90,7 +90,7 @@ class GridGallery_Core_BaseController extends Rsc_Mvc_Controller
|
|
90 |
*/
|
91 |
public function isProduction()
|
92 |
{
|
93 |
-
return $this->getEnvironment()->getConfig()->isEnvironment(
|
94 |
}
|
95 |
|
96 |
/**
|
@@ -99,7 +99,7 @@ class GridGallery_Core_BaseController extends Rsc_Mvc_Controller
|
|
99 |
* instance if module of the specified controller.
|
100 |
*
|
101 |
* @param string|object $module The name of the module or an instance of the controller
|
102 |
-
* @return
|
103 |
*/
|
104 |
public function getModule($module)
|
105 |
{
|
@@ -116,7 +116,7 @@ class GridGallery_Core_BaseController extends Rsc_Mvc_Controller
|
|
116 |
* Creates the new instance of the model and returns it
|
117 |
*
|
118 |
* @param string $modelName
|
119 |
-
* @return
|
120 |
* @throws RuntimeException
|
121 |
*/
|
122 |
public function getModel($modelName)
|
@@ -150,7 +150,7 @@ class GridGallery_Core_BaseController extends Rsc_Mvc_Controller
|
|
150 |
$model->setDebugEnabled(true);
|
151 |
}
|
152 |
|
153 |
-
if ($model instanceof
|
154 |
if ($logger = $this->getEnvironment()->getLogger()) {
|
155 |
$model->setLogger($logger);
|
156 |
}
|
7 |
* @package GridGallery\Core
|
8 |
* @author Artur Kovalevsky
|
9 |
*/
|
10 |
+
class GridGallery_Core_BaseController extends RscSgg_Mvc_Controller
|
11 |
{
|
12 |
|
13 |
/**
|
14 |
* Constructor
|
15 |
*/
|
16 |
+
public function __construct(RscSgg_Environment $environment, RscSgg_Http_Request $request)
|
17 |
{
|
18 |
parent::__construct($environment, $request);
|
19 |
if ($environment->isPluginPage() && !$environment->isModule('license')
|
90 |
*/
|
91 |
public function isProduction()
|
92 |
{
|
93 |
+
return $this->getEnvironment()->getConfig()->isEnvironment(RscSgg_Environment::ENV_PRODUCTION);
|
94 |
}
|
95 |
|
96 |
/**
|
99 |
* instance if module of the specified controller.
|
100 |
*
|
101 |
* @param string|object $module The name of the module or an instance of the controller
|
102 |
+
* @return RscSgg_Mvc_Module|null
|
103 |
*/
|
104 |
public function getModule($module)
|
105 |
{
|
116 |
* Creates the new instance of the model and returns it
|
117 |
*
|
118 |
* @param string $modelName
|
119 |
+
* @return RscSgg_Mvc_Model|GridGallery_Core_BaseModel
|
120 |
* @throws RuntimeException
|
121 |
*/
|
122 |
public function getModel($modelName)
|
150 |
$model->setDebugEnabled(true);
|
151 |
}
|
152 |
|
153 |
+
if ($model instanceof RscSgg_Logger_AwareInterface) {
|
154 |
if ($logger = $this->getEnvironment()->getLogger()) {
|
155 |
$model->setLogger($logger);
|
156 |
}
|
src/GridGallery/Core/BaseModel.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class GridGallery_Core_BaseModel extends
|
5 |
{
|
6 |
|
7 |
/**
|
@@ -20,12 +20,12 @@ class GridGallery_Core_BaseModel extends Rsc_Mvc_Model implements Rsc_Logger_Awa
|
|
20 |
protected $insertId;
|
21 |
|
22 |
/**
|
23 |
-
* @var
|
24 |
*/
|
25 |
protected $logger;
|
26 |
|
27 |
/**
|
28 |
-
* @var
|
29 |
*/
|
30 |
protected $environment;
|
31 |
|
@@ -79,10 +79,10 @@ class GridGallery_Core_BaseModel extends Rsc_Mvc_Model implements Rsc_Logger_Awa
|
|
79 |
/**
|
80 |
* Sets a logger instance on the object
|
81 |
*
|
82 |
-
* @param
|
83 |
* @return null
|
84 |
*/
|
85 |
-
public function setLogger(
|
86 |
{
|
87 |
$this->logger = $logger;
|
88 |
}
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class GridGallery_Core_BaseModel extends RscSgg_Mvc_Model implements RscSgg_Logger_AwareInterface
|
5 |
{
|
6 |
|
7 |
/**
|
20 |
protected $insertId;
|
21 |
|
22 |
/**
|
23 |
+
* @var RscSgg_Logger_Interface
|
24 |
*/
|
25 |
protected $logger;
|
26 |
|
27 |
/**
|
28 |
+
* @var RscSgg_Environment
|
29 |
*/
|
30 |
protected $environment;
|
31 |
|
79 |
/**
|
80 |
* Sets a logger instance on the object
|
81 |
*
|
82 |
+
* @param RscSgg_Logger_Interface $logger
|
83 |
* @return null
|
84 |
*/
|
85 |
+
public function setLogger(RscSgg_Logger_Interface $logger)
|
86 |
{
|
87 |
$this->logger = $logger;
|
88 |
}
|
src/GridGallery/Core/Module.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* @package GridGallery\Core
|
8 |
* @author Artur Kovalevsky
|
9 |
*/
|
10 |
-
class GridGallery_Core_Module extends
|
11 |
{
|
12 |
/**
|
13 |
* {@inheritdoc}
|
@@ -86,22 +86,22 @@ class GridGallery_Core_Module extends Rsc_Mvc_Module
|
|
86 |
{
|
87 |
$twig = $this->getTwig();
|
88 |
$twig->addFunction(
|
89 |
-
new
|
90 |
'plugin_directory_url', array($this, 'getPluginDirectoryUrl')
|
91 |
)
|
92 |
);
|
93 |
$twig->addFunction(
|
94 |
-
new
|
95 |
'build_pro_url', array($this, 'buildProUrl')
|
96 |
)
|
97 |
);
|
98 |
$twig->addFunction(
|
99 |
-
new
|
100 |
'translate', array($this, 'translate')
|
101 |
)
|
102 |
);
|
103 |
$twig->addFunction(
|
104 |
-
new
|
105 |
'getProUrl', array($this, 'getProUrl')
|
106 |
)
|
107 |
);
|
@@ -116,14 +116,6 @@ class GridGallery_Core_Module extends Rsc_Mvc_Module
|
|
116 |
$twig->addGlobal('_wpnonce', wp_create_nonce('supsystic-gallery'));
|
117 |
|
118 |
$show = true;
|
119 |
-
$acSubscribe = get_option('sgg_ac_subscribe', false);
|
120 |
-
if (!empty($acSubscribe)) {
|
121 |
-
$show = false;
|
122 |
-
}
|
123 |
-
$acDisabled = get_option('sgg_ac_disabled', false);
|
124 |
-
if (!empty($acDisabled)) {
|
125 |
-
$show = false;
|
126 |
-
}
|
127 |
$acRemind = get_option('sgg_ac_remind', false);
|
128 |
if (!empty($acRemind)) {
|
129 |
$currentDate = date('Y-m-d h:i:s');
|
@@ -133,6 +125,15 @@ class GridGallery_Core_Module extends Rsc_Mvc_Module
|
|
133 |
$show = false;
|
134 |
}
|
135 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
$twig->addGlobal('SGG_AC_SHOW', $show);
|
137 |
// delete_option('sgg_ac_remind');
|
138 |
// delete_option('sgg_ac_disabled');
|
7 |
* @package GridGallery\Core
|
8 |
* @author Artur Kovalevsky
|
9 |
*/
|
10 |
+
class GridGallery_Core_Module extends RscSgg_Mvc_Module
|
11 |
{
|
12 |
/**
|
13 |
* {@inheritdoc}
|
86 |
{
|
87 |
$twig = $this->getTwig();
|
88 |
$twig->addFunction(
|
89 |
+
new Twig_SupTwgSgg_SimpleFunction(
|
90 |
'plugin_directory_url', array($this, 'getPluginDirectoryUrl')
|
91 |
)
|
92 |
);
|
93 |
$twig->addFunction(
|
94 |
+
new Twig_SupTwgSgg_SimpleFunction(
|
95 |
'build_pro_url', array($this, 'buildProUrl')
|
96 |
)
|
97 |
);
|
98 |
$twig->addFunction(
|
99 |
+
new Twig_SupTwgSgg_SimpleFunction(
|
100 |
'translate', array($this, 'translate')
|
101 |
)
|
102 |
);
|
103 |
$twig->addFunction(
|
104 |
+
new Twig_SupTwgSgg_SimpleFunction(
|
105 |
'getProUrl', array($this, 'getProUrl')
|
106 |
)
|
107 |
);
|
116 |
$twig->addGlobal('_wpnonce', wp_create_nonce('supsystic-gallery'));
|
117 |
|
118 |
$show = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
$acRemind = get_option('sgg_ac_remind', false);
|
120 |
if (!empty($acRemind)) {
|
121 |
$currentDate = date('Y-m-d h:i:s');
|
125 |
$show = false;
|
126 |
}
|
127 |
}
|
128 |
+
$acSubscribe = get_option('sgg_ac_subscribe', false);
|
129 |
+
if (!empty($acSubscribe)) {
|
130 |
+
$show = false;
|
131 |
+
}
|
132 |
+
$acDisabled = get_option('sgg_ac_disabled', false);
|
133 |
+
if (!empty($acDisabled)) {
|
134 |
+
$show = false;
|
135 |
+
}
|
136 |
+
|
137 |
$twig->addGlobal('SGG_AC_SHOW', $show);
|
138 |
// delete_option('sgg_ac_remind');
|
139 |
// delete_option('sgg_ac_disabled');
|
src/GridGallery/Developer/Controller.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* @package GridGallery\Developer
|
8 |
* @author Artur Kovalevsky
|
9 |
*/
|
10 |
-
class GridGallery_Developer_Controller extends
|
11 |
{
|
12 |
public function requireNonces() {
|
13 |
return array(
|
@@ -17,7 +17,7 @@ class GridGallery_Developer_Controller extends Rsc_Mvc_Controller
|
|
17 |
|
18 |
/**
|
19 |
* Index Action
|
20 |
-
* @return
|
21 |
*/
|
22 |
public function indexAction()
|
23 |
{
|
@@ -33,7 +33,7 @@ class GridGallery_Developer_Controller extends Rsc_Mvc_Controller
|
|
33 |
/**
|
34 |
* Log Action
|
35 |
*/
|
36 |
-
public function logAction(
|
37 |
{
|
38 |
if (!$date = $request->query->get('date')) {
|
39 |
$date = date('Y-m-d');
|
7 |
* @package GridGallery\Developer
|
8 |
* @author Artur Kovalevsky
|
9 |
*/
|
10 |
+
class GridGallery_Developer_Controller extends RscSgg_Mvc_Controller
|
11 |
{
|
12 |
public function requireNonces() {
|
13 |
return array(
|
17 |
|
18 |
/**
|
19 |
* Index Action
|
20 |
+
* @return RscSgg_Http_Response
|
21 |
*/
|
22 |
public function indexAction()
|
23 |
{
|
33 |
/**
|
34 |
* Log Action
|
35 |
*/
|
36 |
+
public function logAction(RscSgg_Http_Request $request)
|
37 |
{
|
38 |
if (!$date = $request->query->get('date')) {
|
39 |
$date = date('Y-m-d');
|
src/GridGallery/Developer/Model.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* @package GridGallery\Developer
|
7 |
* @author Artur Kovalevsky
|
8 |
*/
|
9 |
-
class GridGallery_Developer_Model extends
|
10 |
{
|
11 |
|
12 |
/**
|
6 |
* @package GridGallery\Developer
|
7 |
* @author Artur Kovalevsky
|
8 |
*/
|
9 |
+
class GridGallery_Developer_Model extends RscSgg_Mvc_Model
|
10 |
{
|
11 |
|
12 |
/**
|
src/GridGallery/Developer/Module.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* @package GridGallery\Developer
|
8 |
* @author Artur Kovalevsky
|
9 |
*/
|
10 |
-
class GridGallery_Developer_Module extends
|
11 |
{
|
12 |
|
13 |
/**
|
7 |
* @package GridGallery\Developer
|
8 |
* @author Artur Kovalevsky
|
9 |
*/
|
10 |
+
class GridGallery_Developer_Module extends RscSgg_Mvc_Module
|
11 |
{
|
12 |
|
13 |
/**
|
src/GridGallery/Galleries/Controller.php
CHANGED
@@ -63,10 +63,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
63 |
/**
|
64 |
* Index Action
|
65 |
* Shows the list of the galleries
|
66 |
-
* @param
|
67 |
-
* @return
|
68 |
*/
|
69 |
-
public function indexAction(
|
70 |
{
|
71 |
$stats = $this->getEnvironment()->getModule('stats');
|
72 |
$stats->save('Galleries.tab');
|
@@ -86,7 +86,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
86 |
|
87 |
$twig = $this->getEnvironment()->getTwig();
|
88 |
$twig->addFunction(
|
89 |
-
new
|
90 |
'get_image_src',
|
91 |
'wp_get_attachment_image_src'
|
92 |
)
|
@@ -106,7 +106,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
106 |
/**
|
107 |
* Preview Action
|
108 |
*/
|
109 |
-
public function previewAction(
|
110 |
{
|
111 |
$this->saveEvent('galleries.preview');
|
112 |
$galleryId = $request->query->get('gallery_id');
|
@@ -251,10 +251,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
251 |
* View Action
|
252 |
* Renders single gallery page
|
253 |
*
|
254 |
-
* @param
|
255 |
-
* @return
|
256 |
*/
|
257 |
-
public function viewAction(
|
258 |
|
259 |
$params = $this->getViewActionParams($request);
|
260 |
|
@@ -268,10 +268,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
268 |
* SortMode Action
|
269 |
* Renders single gallery page
|
270 |
*
|
271 |
-
* @param
|
272 |
-
* @return
|
273 |
*/
|
274 |
-
public function sortAction(
|
275 |
|
276 |
$params = $this->getSortActionParams($request);
|
277 |
|
@@ -285,7 +285,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
285 |
* List Action
|
286 |
* Returns the AJAX response with galleries list
|
287 |
*
|
288 |
-
* @return
|
289 |
*/
|
290 |
public function listAction()
|
291 |
{
|
@@ -301,10 +301,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
301 |
* Create Action
|
302 |
* Creates the new gallery from the POST request
|
303 |
*
|
304 |
-
* @param
|
305 |
-
* @return
|
306 |
*/
|
307 |
-
public function createAction(
|
308 |
{
|
309 |
$galleries = $this->getModel('galleries');
|
310 |
$language = $this->getEnvironment()->getLang();
|
@@ -359,7 +359,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
359 |
);
|
360 |
}
|
361 |
|
362 |
-
public function sideloadSaveAction(
|
363 |
$selectedImages = $request->post->get('urls');
|
364 |
$photos = $this->getModel('photos');
|
365 |
$attachID = array();
|
@@ -371,7 +371,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
371 |
$attachID[] = $photos->getInsertId();
|
372 |
|
373 |
}
|
374 |
-
return $this->response(
|
375 |
array('msh' => 'Loaded', 'ids' => $attachID));
|
376 |
}
|
377 |
|
@@ -379,10 +379,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
379 |
* Attach Action
|
380 |
* Attaches resources to the specified gallery
|
381 |
*
|
382 |
-
* @param
|
383 |
-
* @return
|
384 |
*/
|
385 |
-
public function attachAction(
|
386 |
{
|
387 |
$logger = $this->getEnvironment()->getLogger();
|
388 |
$lang = $this->getEnvironment()->getLang();
|
@@ -449,7 +449,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
449 |
);
|
450 |
}
|
451 |
|
452 |
-
public function chooseAction(
|
453 |
{
|
454 |
$resourceId = $request->post->get('resources');
|
455 |
$galleryId = $request->post->get('gallery_id');
|
@@ -465,7 +465,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
465 |
|
466 |
update_option('previewImageId', $photo->attachment_id);
|
467 |
|
468 |
-
return $this->response(
|
469 |
array('url' => $this->generateUrl('galleries', 'settings', array('gallery_id' => $galleryId)),
|
470 |
'message' => 'Preview image successfully changed'
|
471 |
)
|
@@ -473,17 +473,17 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
473 |
}
|
474 |
|
475 |
//Uncomment to allow getting tooltips url
|
476 |
-
/*public function getTooltipsUrlAction(
|
477 |
$url = $this->getEnvironment()->getConfig()->get('plugin_url');
|
478 |
|
479 |
-
return $this->response(
|
480 |
array('url' => $url,
|
481 |
'message' => 'Preview image successfully changed'
|
482 |
)
|
483 |
);
|
484 |
}*/
|
485 |
|
486 |
-
public function showPresetsAction(
|
487 |
return $this->response('@galleries/gallery_preset.twig',
|
488 |
array('url' => $this->generateUrl('galleries'))
|
489 |
);
|
@@ -493,10 +493,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
493 |
* Rename Action
|
494 |
* Renames the specified gallery
|
495 |
*
|
496 |
-
* @param
|
497 |
-
* @return
|
498 |
*/
|
499 |
-
public function renameAction(
|
500 |
{
|
501 |
$lang = $this->getEnvironment()->getLang();
|
502 |
$logger = $this->getEnvironment()->getLogger();
|
@@ -540,10 +540,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
540 |
* Delete Action
|
541 |
* Deletes the gallery
|
542 |
*
|
543 |
-
* @param
|
544 |
-
* @return
|
545 |
*/
|
546 |
-
public function deleteAction(
|
547 |
{
|
548 |
|
549 |
$env = $this->getEnvironment();
|
@@ -598,10 +598,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
598 |
* Delete Group Action
|
599 |
* Deletes the gallery list
|
600 |
*
|
601 |
-
* @param
|
602 |
-
* @return
|
603 |
*/
|
604 |
-
public function deleteGroupAction(
|
605 |
{
|
606 |
$env = $this->getEnvironment();
|
607 |
$logger = $env->getLogger();
|
@@ -636,10 +636,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
636 |
/**
|
637 |
* Deletes the resources from the specified gallery.
|
638 |
*
|
639 |
-
* @param
|
640 |
-
* @return
|
641 |
*/
|
642 |
-
public function deleteResourceAction(
|
643 |
{
|
644 |
$resources = $this->getModel('resources');
|
645 |
|
@@ -660,10 +660,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
660 |
/**
|
661 |
* Shows the page with photos to attach them to the gallery.
|
662 |
*
|
663 |
-
* @param
|
664 |
-
* @return
|
665 |
*/
|
666 |
-
public function addImagesAction(
|
667 |
{
|
668 |
if (null === $galleryId = $request->query->get('gallery_id')) {
|
669 |
// 404 - gallery not found
|
@@ -689,10 +689,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
689 |
* Settings Action.
|
690 |
* Manage gallery settings
|
691 |
*
|
692 |
-
* @param
|
693 |
-
* @return
|
694 |
*/
|
695 |
-
public function settingsAction(
|
696 |
{
|
697 |
$galleryId = $request->query->get('gallery_id');
|
698 |
|
@@ -708,7 +708,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
708 |
|
709 |
$twig = $this->getEnvironment()->getTwig();
|
710 |
$twig->addFunction(
|
711 |
-
new
|
712 |
'get_image_src',
|
713 |
'wp_get_attachment_image_src'
|
714 |
)
|
@@ -803,10 +803,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
803 |
* Save Settings Action
|
804 |
* Saves the specified gallery's settings
|
805 |
*
|
806 |
-
* @param
|
807 |
-
* @return
|
808 |
*/
|
809 |
-
public function saveSettingsAction(
|
810 |
{
|
811 |
/** @var GridGallery_Galleries_Model_Settings $settings */
|
812 |
$galleryId = $request->query->get('gallery_id');
|
@@ -875,10 +875,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
875 |
/**
|
876 |
* Save custom categories preset
|
877 |
*
|
878 |
-
* @param
|
879 |
-
* @return
|
880 |
*/
|
881 |
-
public function saveCatsPresetAction(
|
882 |
if(isset($request->post['route']['options'])) {
|
883 |
$data = $request->post['route']['options'];
|
884 |
|
@@ -900,7 +900,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
900 |
update_option('customCatsPresets', $presets);
|
901 |
|
902 |
return $this->response(
|
903 |
-
|
904 |
array(
|
905 |
'success' => 'ok',
|
906 |
)
|
@@ -908,7 +908,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
908 |
}
|
909 |
|
910 |
return $this->response(
|
911 |
-
|
912 |
array(
|
913 |
'success' => 'error',
|
914 |
)
|
@@ -919,10 +919,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
919 |
*
|
920 |
* Get categories custom presets
|
921 |
*
|
922 |
-
* @param
|
923 |
-
* @return
|
924 |
*/
|
925 |
-
public function getCustomCatsPresetsAction(
|
926 |
$presets = get_option('customCatsPresets');
|
927 |
$names = array();
|
928 |
|
@@ -933,7 +933,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
933 |
}
|
934 |
|
935 |
return $this->response(
|
936 |
-
|
937 |
array(
|
938 |
'names' => $names
|
939 |
)
|
@@ -943,10 +943,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
943 |
/**
|
944 |
* Save pages custom preset
|
945 |
*
|
946 |
-
* @param
|
947 |
-
* @return
|
948 |
*/
|
949 |
-
public function savePagesPresetAction(
|
950 |
if(isset($request->post['route']['options'])) {
|
951 |
$data = $request->post['route']['options'];
|
952 |
if(get_option('customPagesPresets')) {
|
@@ -967,7 +967,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
967 |
update_option('customPagesPresets', $presets);
|
968 |
|
969 |
return $this->response(
|
970 |
-
|
971 |
array(
|
972 |
'success' => 'ok',
|
973 |
)
|
@@ -975,7 +975,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
975 |
}
|
976 |
|
977 |
return $this->response(
|
978 |
-
|
979 |
array(
|
980 |
'success' => 'error',
|
981 |
)
|
@@ -986,10 +986,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
986 |
*
|
987 |
* Get pages custom presets
|
988 |
*
|
989 |
-
* @param
|
990 |
-
* @return
|
991 |
*/
|
992 |
-
public function getCustomPagesPresetsAction(
|
993 |
$presets = get_option('customPagesPresets');
|
994 |
$names = array();
|
995 |
|
@@ -1000,7 +1000,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1000 |
}
|
1001 |
|
1002 |
return $this->response(
|
1003 |
-
|
1004 |
array(
|
1005 |
'names' => $names
|
1006 |
)
|
@@ -1010,10 +1010,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1010 |
/**
|
1011 |
* Save Preset Action
|
1012 |
* Saves the settings preset to the database.
|
1013 |
-
* @param
|
1014 |
-
* @return
|
1015 |
*/
|
1016 |
-
public function savePresetAction(
|
1017 |
{
|
1018 |
$preset = $this->getModel('preset');
|
1019 |
$settingsId = $request->post->get('settings_id');
|
@@ -1023,7 +1023,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1023 |
|
1024 |
if (empty($settingsId) || empty($presetTitle)) {
|
1025 |
return $this->response(
|
1026 |
-
|
1027 |
$this->getErrorResponseData(
|
1028 |
$lang->translate('Not enough data.')
|
1029 |
)
|
@@ -1032,7 +1032,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1032 |
|
1033 |
if ($preset->set($settingsId, $presetTitle)) {
|
1034 |
return $this->response(
|
1035 |
-
|
1036 |
$this->getSuccessResponseData(
|
1037 |
$lang->translate('Preset successfully saved.')
|
1038 |
)
|
@@ -1040,7 +1040,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1040 |
}
|
1041 |
|
1042 |
return $this->response(
|
1043 |
-
|
1044 |
$this->getErrorResponseData(
|
1045 |
$lang->translate(
|
1046 |
sprintf(
|
@@ -1055,10 +1055,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1055 |
/**
|
1056 |
* Remove Preset Action
|
1057 |
* Removes the settings preset by the preset id.
|
1058 |
-
* @param
|
1059 |
-
* @return
|
1060 |
*/
|
1061 |
-
public function removePresetAction(
|
1062 |
{
|
1063 |
$preset = $this->getModel('preset');
|
1064 |
$presetId = $request->post->get('preset_id');
|
@@ -1067,7 +1067,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1067 |
|
1068 |
if (null === $presetId || empty($presetId)) {
|
1069 |
return $this->response(
|
1070 |
-
|
1071 |
$this->getErrorResponseData(
|
1072 |
$lang->translate('The preset ID is not specified.')
|
1073 |
)
|
@@ -1076,7 +1076,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1076 |
|
1077 |
if ($preset->remove($presetId)) {
|
1078 |
return $this->response(
|
1079 |
-
|
1080 |
$this->getSuccessResponseData(
|
1081 |
$lang->translate('Preset successfully removed.')
|
1082 |
)
|
@@ -1084,7 +1084,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1084 |
}
|
1085 |
|
1086 |
return $this->response(
|
1087 |
-
|
1088 |
$this->getErrorResponseData(
|
1089 |
$lang->translate(
|
1090 |
sprintf(
|
@@ -1099,7 +1099,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1099 |
public function getPresetListAction()
|
1100 |
{
|
1101 |
return $this->response(
|
1102 |
-
|
1103 |
array(
|
1104 |
'error' => false,
|
1105 |
'presets' => $this->getModel('preset')->getAll(),
|
@@ -1107,7 +1107,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1107 |
);
|
1108 |
}
|
1109 |
|
1110 |
-
public function applyPresetAction(
|
1111 |
{
|
1112 |
$galleryId = $request->post->get('gallery_id');
|
1113 |
$presetId = $request->post->get('preset_id');
|
@@ -1121,7 +1121,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1121 |
|
1122 |
if (!$preset) {
|
1123 |
return $this->response(
|
1124 |
-
|
1125 |
$this->getErrorResponseData(
|
1126 |
$lang->translate('Failed to find the preset.')
|
1127 |
)
|
@@ -1131,14 +1131,14 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1131 |
$settings->save($galleryId, $preset->settings->data);
|
1132 |
|
1133 |
return $this->response(
|
1134 |
-
|
1135 |
$this->getSuccessResponseData(
|
1136 |
$lang->translate('Preset successfully applied to the gallery.')
|
1137 |
)
|
1138 |
);
|
1139 |
}
|
1140 |
|
1141 |
-
public function getCatsPresetOptionsAction(
|
1142 |
{
|
1143 |
if(isset($request->post['route']['selectedPreset'])) {
|
1144 |
$selectedPreset = $request->post['route']['selectedPreset'];
|
@@ -1148,7 +1148,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1148 |
if($indx) {
|
1149 |
$presetOptions = $dbPresetOpt[$indx-1]['categories'];
|
1150 |
return $this->response(
|
1151 |
-
|
1152 |
array(
|
1153 |
'dialogType' => 'customized',
|
1154 |
'presetName' => $selectedPreset,
|
@@ -1159,14 +1159,14 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1159 |
}
|
1160 |
|
1161 |
return $this->response(
|
1162 |
-
|
1163 |
array(
|
1164 |
'dialogType' => 'standart'
|
1165 |
)
|
1166 |
);
|
1167 |
}
|
1168 |
|
1169 |
-
public function getPagesPresetOptionsAction(
|
1170 |
{
|
1171 |
if(isset($request->post['route']['selectedPreset'])) {
|
1172 |
$selectedPreset = $request->post['route']['selectedPreset'];
|
@@ -1176,7 +1176,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1176 |
if($indx) {
|
1177 |
$presetOptions = $dbPresetOpt[$indx-1]['pagination'];
|
1178 |
return $this->response(
|
1179 |
-
|
1180 |
array(
|
1181 |
'dialogType' => 'customized',
|
1182 |
'presetName' => $selectedPreset,
|
@@ -1187,14 +1187,14 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1187 |
}
|
1188 |
|
1189 |
return $this->response(
|
1190 |
-
|
1191 |
array(
|
1192 |
'dialogType' => 'standart'
|
1193 |
)
|
1194 |
);
|
1195 |
}
|
1196 |
|
1197 |
-
public function checkReviewNoticeAction(
|
1198 |
$showNotice = get_option('showGalleryRevNotice');
|
1199 |
$show = false;
|
1200 |
|
@@ -1214,12 +1214,12 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1214 |
}
|
1215 |
|
1216 |
return $this->response(
|
1217 |
-
|
1218 |
array('show' => $show)
|
1219 |
);
|
1220 |
}
|
1221 |
|
1222 |
-
public function checkNoticeButtonAction(
|
1223 |
$code = 'is_shown';
|
1224 |
$showNotice = get_option('showGalleryRevNotice');
|
1225 |
|
@@ -1232,7 +1232,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1232 |
$this->sendUsageStat($code);
|
1233 |
update_option('showGalleryRevNotice', $showNotice);
|
1234 |
|
1235 |
-
return $this->response(
|
1236 |
}
|
1237 |
|
1238 |
public function sendUsageStat($state) {
|
@@ -1267,11 +1267,11 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1267 |
return str_replace('@url', $url . '/app/assets/img', $element);
|
1268 |
}
|
1269 |
|
1270 |
-
public function ajaxGetImagesAction(
|
1271 |
{
|
1272 |
if (null === $galleryId = $request->post->get('gallery_id')) {
|
1273 |
return $this->response(
|
1274 |
-
|
1275 |
$this->getErrorResponseData(
|
1276 |
'Gallery identifier is not specified.'
|
1277 |
)
|
@@ -1283,7 +1283,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1283 |
|
1284 |
if (null === $gallery = $galleries->getById((int)$galleryId)) {
|
1285 |
return $this->response(
|
1286 |
-
|
1287 |
$this->getErrorResponseData('The gallery does not exists.')
|
1288 |
);
|
1289 |
}
|
@@ -1291,7 +1291,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1291 |
$gallery->settings = $this->getModel('settings')->get($galleryId)->data;
|
1292 |
|
1293 |
return $this->response(
|
1294 |
-
|
1295 |
$this->getSuccessResponseData(
|
1296 |
null,
|
1297 |
array(
|
@@ -1302,11 +1302,11 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1302 |
);
|
1303 |
}
|
1304 |
|
1305 |
-
public function ajaxResizeImageAction(
|
1306 |
{
|
1307 |
if (!function_exists('wp_get_image_editor')) {
|
1308 |
return $this->response(
|
1309 |
-
|
1310 |
$this->getErrorResponseData(
|
1311 |
'Current WordPress revision has not Image Editor.'
|
1312 |
)
|
@@ -1319,7 +1319,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1319 |
|
1320 |
if (!$attachmentId) {
|
1321 |
return $this->response(
|
1322 |
-
|
1323 |
$this->getErrorResponseData(
|
1324 |
'The attachment id is not specified.'
|
1325 |
)
|
@@ -1331,7 +1331,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1331 |
|
1332 |
if (!is_file($file = $upload['basedir'] . '/' . $meta['file'])) {
|
1333 |
return $this->response(
|
1334 |
-
|
1335 |
$this->getErrorResponseData(
|
1336 |
sprintf('File not found: %s', $file)
|
1337 |
)
|
@@ -1340,7 +1340,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1340 |
|
1341 |
if (!$width || !$height) {
|
1342 |
return $this->response(
|
1343 |
-
|
1344 |
$this->getErrorResponseData('Width or Height is not specified.')
|
1345 |
);
|
1346 |
}
|
@@ -1349,7 +1349,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1349 |
|
1350 |
if (is_wp_error($editor)) {
|
1351 |
return $this->response(
|
1352 |
-
|
1353 |
$this->getErrorResponseData(
|
1354 |
sprintf('Unable to load the image: %s', $file)
|
1355 |
)
|
@@ -1358,7 +1358,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1358 |
|
1359 |
if (is_wp_error($error = $editor->resize((int)$width, (int)$height, true))) {
|
1360 |
return $this->response(
|
1361 |
-
|
1362 |
$this->getErrorResponseData(
|
1363 |
sprintf(
|
1364 |
'Unable to resize the image: %s.',
|
@@ -1374,7 +1374,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1374 |
$image = $editor->save();
|
1375 |
|
1376 |
return $this->response(
|
1377 |
-
|
1378 |
$this->getSuccessResponseData(
|
1379 |
sprintf('Attachment %s resized successfully.', $attachmentId),
|
1380 |
array(
|
@@ -1387,10 +1387,10 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1387 |
/**
|
1388 |
* Save sort images by (Size, Name, Add date, Create Date)
|
1389 |
*
|
1390 |
-
* @param
|
1391 |
* @return string msg Response answer
|
1392 |
*/
|
1393 |
-
public function saveSortByAction(
|
1394 |
{
|
1395 |
$galleryId = $request->post->get('gallery_id');
|
1396 |
|
@@ -1425,25 +1425,25 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1425 |
$this->getModule('galleries')->cleanCache($galleryId);
|
1426 |
|
1427 |
return $this->response(
|
1428 |
-
|
1429 |
$this->getSuccessResponseData(
|
1430 |
"Save sorted"
|
1431 |
)
|
1432 |
);
|
1433 |
}
|
1434 |
|
1435 |
-
public function getGalleriesListAction(
|
1436 |
{
|
1437 |
$galleries = $this->getModel('galleries');
|
1438 |
|
1439 |
return $this->response(
|
1440 |
-
|
1441 |
'list' => $galleries->getList(),
|
1442 |
)
|
1443 |
);
|
1444 |
}
|
1445 |
|
1446 |
-
public function importSettingsAction(
|
1447 |
{
|
1448 |
$settingsModel = $this->getModel('settings');
|
1449 |
$from = $request->post->get('from');
|
@@ -1452,7 +1452,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1452 |
$settingsModel->save($to, $settings->data);
|
1453 |
$this->getModule('galleries')->cleanCache($to, true);
|
1454 |
return $this->response(
|
1455 |
-
|
1456 |
'success' => true,
|
1457 |
)
|
1458 |
);
|
@@ -1475,7 +1475,7 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1475 |
);
|
1476 |
}
|
1477 |
|
1478 |
-
public function cloneAction(
|
1479 |
$route = $request->post->get("route");
|
1480 |
$oldGalleryId = null;
|
1481 |
$result = array(
|
@@ -1490,15 +1490,15 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1490 |
$result = $galleryModel->cloneGallery($oldGalleryId, $cloneType, $this->getCloneParams());
|
1491 |
}
|
1492 |
}
|
1493 |
-
return $this->response(
|
1494 |
}
|
1495 |
|
1496 |
-
public function createDefaultGallerySettingsAction(
|
1497 |
$galleryId = $request->post->get("id");
|
1498 |
update_option('defaultgallerysettings', $galleryId);
|
1499 |
|
1500 |
return $this->response(
|
1501 |
-
|
1502 |
'success' => true,
|
1503 |
'message' => 'success',
|
1504 |
)
|
@@ -1506,12 +1506,12 @@ class GridGallery_Galleries_Controller extends GridGallery_Core_BaseController
|
|
1506 |
|
1507 |
}
|
1508 |
|
1509 |
-
public function removeDefaultGallerySettingsAction(
|
1510 |
$galleryId = $request->post->get("id");
|
1511 |
delete_option('defaultgallerysettings', $galleryId);
|
1512 |
|
1513 |
return $this->response(
|
1514 |
-
|
1515 |
'success' => true,
|
1516 |
'message' => 'success',
|
1517 |
)
|
63 |
/**
|
64 |
* Index Action
|
65 |
* Shows the list of the galleries
|
66 |
+
* @param RscSgg_Http_Request $request
|
67 |
+
* @return RscSgg_Http_Response
|
68 |
*/
|
69 |
+
public function indexAction(RscSgg_Http_Request $request)
|
70 |
{
|
71 |
$stats = $this->getEnvironment()->getModule('stats');
|
72 |
$stats->save('Galleries.tab');
|
86 |
|
87 |
$twig = $this->getEnvironment()->getTwig();
|
88 |
$twig->addFunction(
|
89 |
+
new Twig_SupTwgSgg_SimpleFunction(
|
90 |
'get_image_src',
|
91 |
'wp_get_attachment_image_src'
|
92 |
)
|
106 |
/**
|
107 |
* Preview Action
|
108 |
*/
|
109 |
+
public function previewAction(RscSgg_Http_Request $request)
|
110 |
{
|
111 |
$this->saveEvent('galleries.preview');
|
112 |
$galleryId = $request->query->get('gallery_id');
|
251 |
* View Action
|
252 |
* Renders single gallery page
|
253 |
*
|
254 |
+
* @param RscSgg_Http_Request $request
|
255 |
+
* @return RscSgg_Http_Response
|
256 |
*/
|
257 |
+
public function viewAction(RscSgg_Http_Request $request) {
|
258 |
|
259 |
$params = $this->getViewActionParams($request);
|
260 |
|
268 |
* SortMode Action
|
269 |
* Renders single gallery page
|
270 |
*
|
271 |
+
* @param RscSgg_Http_Request $request
|
272 |
+
* @return RscSgg_Http_Response
|
273 |
*/
|
274 |
+
public function sortAction(RscSgg_Http_Request $request) {
|
275 |
|
276 |
$params = $this->getSortActionParams($request);
|
277 |
|
285 |
* List Action
|
286 |
* Returns the AJAX response with galleries list
|
287 |
*
|
288 |
+
* @return RscSgg_Http_Response
|
289 |
*/
|
290 |
public function listAction()
|
291 |
{
|
301 |
* Create Action
|
302 |
* Creates the new gallery from the POST request
|
303 |
*
|
304 |
+
* @param RscSgg_Http_Request $request
|
305 |
+
* @return RscSgg_Http_Response
|
306 |
*/
|
307 |
+
public function createAction(RscSgg_Http_Request $request)
|
308 |
{
|
309 |
$galleries = $this->getModel('galleries');
|
310 |
$language = $this->getEnvironment()->getLang();
|
359 |
);
|
360 |
}
|
361 |
|
362 |
+
public function sideloadSaveAction(RscSgg_Http_Request $request){
|
363 |
$selectedImages = $request->post->get('urls');
|
364 |
$photos = $this->getModel('photos');
|
365 |
$attachID = array();
|
371 |
$attachID[] = $photos->getInsertId();
|
372 |
|
373 |
}
|
374 |
+
return $this->response(RscSgg_Http_Response::AJAX,
|
375 |
array('msh' => 'Loaded', 'ids' => $attachID));
|
376 |
}
|
377 |
|
379 |
* Attach Action
|
380 |
* Attaches resources to the specified gallery
|
381 |
*
|
382 |
+
* @param RscSgg_Http_Request $request
|
383 |
+
* @return RscSgg_Http_Response
|
384 |
*/
|
385 |
+
public function attachAction(RscSgg_Http_Request $request)
|
386 |
{
|
387 |
$logger = $this->getEnvironment()->getLogger();
|
388 |
$lang = $this->getEnvironment()->getLang();
|
449 |
);
|
450 |
}
|
451 |
|
452 |
+
public function chooseAction(RscSgg_Http_Request $request)
|
453 |
{
|
454 |
$resourceId = $request->post->get('resources');
|
455 |
$galleryId = $request->post->get('gallery_id');
|
465 |
|
466 |
update_option('previewImageId', $photo->attachment_id);
|
467 |
|
468 |
+
return $this->response(RscSgg_Http_Response::AJAX,
|
469 |
array('url' => $this->generateUrl('galleries', 'settings', array('gallery_id' => $galleryId)),
|
470 |
'message' => 'Preview image successfully changed'
|
471 |
)
|
473 |
}
|
474 |
|
475 |
//Uncomment to allow getting tooltips url
|
476 |
+
/*public function getTooltipsUrlAction(RscSgg_Http_Request $request) {
|
477 |
$url = $this->getEnvironment()->getConfig()->get('plugin_url');
|
478 |
|
479 |
+
return $this->response(RscSgg_Http_Response::AJAX,
|
480 |
array('url' => $url,
|
481 |
'message' => 'Preview image successfully changed'
|
482 |
)
|
483 |
);
|
484 |
}*/
|
485 |
|
486 |
+
public function showPresetsAction(RscSgg_Http_Request $request) {
|
487 |
return $this->response('@galleries/gallery_preset.twig',
|
488 |
array('url' => $this->generateUrl('galleries'))
|
489 |
);
|
493 |
* Rename Action
|
494 |
* Renames the specified gallery
|
495 |
*
|
496 |
+
* @param RscSgg_Http_Request $request
|
497 |
+
* @return RscSgg_Http_Response
|
498 |
*/
|
499 |
+
public function renameAction(RscSgg_Http_Request $request)
|
500 |
{
|
501 |
$lang = $this->getEnvironment()->getLang();
|
502 |
$logger = $this->getEnvironment()->getLogger();
|
540 |
* Delete Action
|
541 |
* Deletes the gallery
|
542 |
*
|
543 |
+
* @param RscSgg_Http_Request $request An instance of the HTTP request
|
544 |
+
* @return RscSgg_Http_Response
|
545 |
*/
|
546 |
+
public function deleteAction(RscSgg_Http_Request $request)
|
547 |
{
|
548 |
|
549 |
$env = $this->getEnvironment();
|
598 |
* Delete Group Action
|
599 |
* Deletes the gallery list
|
600 |
*
|
601 |
+
* @param RscSgg_Http_Request $request An instance of the HTTP request
|
602 |
+
* @return RscSgg_Http_Response
|
603 |
*/
|
604 |
+
public function deleteGroupAction(RscSgg_Http_Request $request)
|
605 |
{
|
606 |
$env = $this->getEnvironment();
|
607 |
$logger = $env->getLogger();
|
636 |
/**
|
637 |
* Deletes the resources from the specified gallery.
|
638 |
*
|
639 |
+
* @param RscSgg_Http_Request $request
|
640 |
+
* @return RscSgg_Http_Response
|
641 |
*/
|
642 |
+
public function deleteResourceAction(RscSgg_Http_Request $request)
|
643 |
{
|
644 |
$resources = $this->getModel('resources');
|
645 |
|
660 |
/**
|
661 |
* Shows the page with photos to attach them to the gallery.
|
662 |
*
|
663 |
+
* @param RscSgg_Http_Request $request
|
664 |
+
* @return RscSgg_Http_Response
|
665 |
*/
|
666 |
+
public function addImagesAction(RscSgg_Http_Request $request)
|
667 |
{
|
668 |
if (null === $galleryId = $request->query->get('gallery_id')) {
|
669 |
// 404 - gallery not found
|
689 |
* Settings Action.
|
690 |
* Manage gallery settings
|
691 |
*
|
692 |
+
* @param RscSgg_Http_Request $request
|
693 |
+
* @return RscSgg_Http_Response
|
694 |
*/
|
695 |
+
public function settingsAction(RscSgg_Http_Request $request)
|
696 |
{
|
697 |
$galleryId = $request->query->get('gallery_id');
|
698 |
|
708 |
|
709 |
$twig = $this->getEnvironment()->getTwig();
|
710 |
$twig->addFunction(
|
711 |
+
new Twig_SupTwgSgg_SimpleFunction(
|
712 |
'get_image_src',
|
713 |
'wp_get_attachment_image_src'
|
714 |
)
|
803 |
* Save Settings Action
|
804 |
* Saves the specified gallery's settings
|
805 |
*
|
806 |
+
* @param RscSgg_Http_Request $request
|
807 |
+
* @return RscSgg_Http_Response
|
808 |
*/
|
809 |
+
public function saveSettingsAction(RscSgg_Http_Request $request)
|
810 |
{
|
811 |
/** @var GridGallery_Galleries_Model_Settings $settings */
|
812 |
$galleryId = $request->query->get('gallery_id');
|
875 |
/**
|
876 |
* Save custom categories preset
|
877 |
*
|
878 |
+
* @param RscSgg_Http_Request $request
|
879 |
+
* @return RscSgg_Http_Response
|
880 |
*/
|
881 |
+
public function saveCatsPresetAction(RscSgg_Http_Request $request) {
|
882 |
if(isset($request->post['route']['options'])) {
|
883 |
$data = $request->post['route']['options'];
|
884 |
|
900 |
update_option('customCatsPresets', $presets);
|
901 |
|
902 |
return $this->response(
|
903 |
+
RscSgg_Http_Response::AJAX,
|
904 |
array(
|
905 |
'success' => 'ok',
|
906 |
)
|
908 |
}
|
909 |
|
910 |
return $this->response(
|
911 |
+
RscSgg_Http_Response::AJAX,
|
912 |
array(
|
913 |
'success' => 'error',
|
914 |
)
|
919 |
*
|
920 |
* Get categories custom presets
|
921 |
*
|
922 |
+
* @param RscSgg_Http_Request $request
|
923 |
+
* @return RscSgg_Http_Response
|
924 |
*/
|
925 |
+
public function getCustomCatsPresetsAction(RscSgg_Http_Request $request) {
|
926 |
$presets = get_option('customCatsPresets');
|
927 |
$names = array();
|
928 |
|
933 |
}
|
934 |
|
935 |
return $this->response(
|
936 |
+
RscSgg_Http_Response::AJAX,
|
937 |
array(
|
938 |
'names' => $names
|
939 |
)
|
943 |
/**
|
944 |
* Save pages custom preset
|
945 |
*
|
946 |
+
* @param RscSgg_Http_Request $request
|
947 |
+
* @return RscSgg_Http_Response
|
948 |
*/
|
949 |
+
public function savePagesPresetAction(RscSgg_Http_Request $request) {
|
950 |
if(isset($request->post['route']['options'])) {
|
951 |
$data = $request->post['route']['options'];
|
952 |
if(get_option('customPagesPresets')) {
|
967 |
update_option('customPagesPresets', $presets);
|
968 |
|
969 |
return $this->response(
|
970 |
+
RscSgg_Http_Response::AJAX,
|
971 |
array(
|
972 |
'success' => 'ok',
|
973 |
)
|
975 |
}
|
976 |
|
977 |
return $this->response(
|
978 |
+
RscSgg_Http_Response::AJAX,
|
979 |
array(
|
980 |
'success' => 'error',
|
981 |
)
|
986 |
*
|
987 |
* Get pages custom presets
|
988 |
*
|
989 |
+
* @param RscSgg_Http_Request $request
|
990 |
+
* @return RscSgg_Http_Response
|
991 |
*/
|
992 |
+
public function getCustomPagesPresetsAction(RscSgg_Http_Request $request) {
|
993 |
$presets = get_option('customPagesPresets');
|
994 |
$names = array();
|
995 |
|
1000 |
}
|
1001 |
|
1002 |
return $this->response(
|
1003 |
+
RscSgg_Http_Response::AJAX,
|
1004 |
array(
|
1005 |
'names' => $names
|
1006 |
)
|
1010 |
/**
|
1011 |
* Save Preset Action
|
1012 |
* Saves the settings preset to the database.
|
1013 |
+
* @param RscSgg_Http_Request $request HTTP request.
|
1014 |
+
* @return RscSgg_Http_Response
|
1015 |
*/
|
1016 |
+
public function savePresetAction(RscSgg_Http_Request $request)
|
1017 |
{
|
1018 |
$preset = $this->getModel('preset');
|
1019 |
$settingsId = $request->post->get('settings_id');
|
1023 |
|
1024 |
if (empty($settingsId) || empty($presetTitle)) {
|
1025 |
return $this->response(
|
1026 |
+
RscSgg_Http_Response::AJAX,
|
1027 |
$this->getErrorResponseData(
|
1028 |
$lang->translate('Not enough data.')
|
1029 |
)
|
1032 |
|
1033 |
if ($preset->set($settingsId, $presetTitle)) {
|
1034 |
return $this->response(
|
1035 |
+
RscSgg_Http_Response::AJAX,
|
1036 |
$this->getSuccessResponseData(
|
1037 |
$lang->translate('Preset successfully saved.')
|
1038 |
)
|
1040 |
}
|
1041 |
|
1042 |
return $this->response(
|
1043 |
+
RscSgg_Http_Response::AJAX,
|
1044 |
$this->getErrorResponseData(
|
1045 |
$lang->translate(
|
1046 |
sprintf(
|
1055 |
/**
|
1056 |
* Remove Preset Action
|
1057 |
* Removes the settings preset by the preset id.
|
1058 |
+
* @param RscSgg_Http_Request $request
|
1059 |
+
* @return RscSgg_Http_Response
|
1060 |
*/
|
1061 |
+
public function removePresetAction(RscSgg_Http_Request $request)
|
1062 |
{
|
1063 |
$preset = $this->getModel('preset');
|
1064 |
$presetId = $request->post->get('preset_id');
|
1067 |
|
1068 |
if (null === $presetId || empty($presetId)) {
|
1069 |
return $this->response(
|
1070 |
+
RscSgg_Http_Response::AJAX,
|
1071 |
$this->getErrorResponseData(
|
1072 |
$lang->translate('The preset ID is not specified.')
|
1073 |
)
|
1076 |
|
1077 |
if ($preset->remove($presetId)) {
|
1078 |
return $this->response(
|
1079 |
+
RscSgg_Http_Response::AJAX,
|
1080 |
$this->getSuccessResponseData(
|
1081 |
$lang->translate('Preset successfully removed.')
|
1082 |
)
|
1084 |
}
|
1085 |
|
1086 |
return $this->response(
|
1087 |
+
RscSgg_Http_Response::AJAX,
|
1088 |
$this->getErrorResponseData(
|
1089 |
$lang->translate(
|
1090 |
sprintf(
|
1099 |
public function getPresetListAction()
|
1100 |
{
|
1101 |
return $this->response(
|
1102 |
+
RscSgg_Http_Response::AJAX,
|
1103 |
array(
|
1104 |
'error' => false,
|
1105 |
'presets' => $this->getModel('preset')->getAll(),
|
1107 |
);
|
1108 |
}
|
1109 |
|
1110 |
+
public function applyPresetAction(RscSgg_Http_Request $request)
|
1111 |
{
|
1112 |
$galleryId = $request->post->get('gallery_id');
|
1113 |
$presetId = $request->post->get('preset_id');
|
1121 |
|
1122 |
if (!$preset) {
|
1123 |
return $this->response(
|
1124 |
+
RscSgg_Http_Response::AJAX,
|
1125 |
$this->getErrorResponseData(
|
1126 |
$lang->translate('Failed to find the preset.')
|
1127 |
)
|
1131 |
$settings->save($galleryId, $preset->settings->data);
|
1132 |
|
1133 |
return $this->response(
|
1134 |
+
RscSgg_Http_Response::AJAX,
|
1135 |
$this->getSuccessResponseData(
|
1136 |
$lang->translate('Preset successfully applied to the gallery.')
|
1137 |
)
|
1138 |
);
|
1139 |
}
|
1140 |
|
1141 |
+
public function getCatsPresetOptionsAction(RscSgg_Http_Request $request)
|
1142 |
{
|
1143 |
if(isset($request->post['route']['selectedPreset'])) {
|
1144 |
$selectedPreset = $request->post['route']['selectedPreset'];
|
1148 |
if($indx) {
|
1149 |
$presetOptions = $dbPresetOpt[$indx-1]['categories'];
|
1150 |
return $this->response(
|
1151 |
+
RscSgg_Http_Response::AJAX,
|
1152 |
array(
|
1153 |
'dialogType' => 'customized',
|
1154 |
'presetName' => $selectedPreset,
|
1159 |
}
|
1160 |
|
1161 |
return $this->response(
|
1162 |
+
RscSgg_Http_Response::AJAX,
|
1163 |
array(
|
1164 |
'dialogType' => 'standart'
|
1165 |
)
|
1166 |
);
|
1167 |
}
|
1168 |
|
1169 |
+
public function getPagesPresetOptionsAction(RscSgg_Http_Request $request)
|
1170 |
{
|
1171 |
if(isset($request->post['route']['selectedPreset'])) {
|
1172 |
$selectedPreset = $request->post['route']['selectedPreset'];
|
1176 |
if($indx) {
|
1177 |
$presetOptions = $dbPresetOpt[$indx-1]['pagination'];
|
1178 |
return $this->response(
|
1179 |
+
RscSgg_Http_Response::AJAX,
|
1180 |
array(
|
1181 |
'dialogType' => 'customized',
|
1182 |
'presetName' => $selectedPreset,
|
1187 |
}
|
1188 |
|
1189 |
return $this->response(
|
1190 |
+
RscSgg_Http_Response::AJAX,
|
1191 |
array(
|
1192 |
'dialogType' => 'standart'
|
1193 |
)
|
1194 |
);
|
1195 |
}
|
1196 |
|
1197 |
+
public function checkReviewNoticeAction(RscSgg_Http_Request $request) {
|
1198 |
$showNotice = get_option('showGalleryRevNotice');
|
1199 |
$show = false;
|
1200 |
|
1214 |
}
|
1215 |
|
1216 |
return $this->response(
|
1217 |
+
RscSgg_Http_Response::AJAX,
|
1218 |
array('show' => $show)
|
1219 |
);
|
1220 |
}
|
1221 |
|
1222 |
+
public function checkNoticeButtonAction(RscSgg_Http_Request $request) {
|
1223 |
$code = 'is_shown';
|
1224 |
$showNotice = get_option('showGalleryRevNotice');
|
1225 |
|
1232 |
$this->sendUsageStat($code);
|
1233 |
update_option('showGalleryRevNotice', $showNotice);
|
1234 |
|
1235 |
+
return $this->response(RscSgg_Http_Response::AJAX);
|
1236 |
}
|
1237 |
|
1238 |
public function sendUsageStat($state) {
|
1267 |
return str_replace('@url', $url . '/app/assets/img', $element);
|
1268 |
}
|
1269 |
|
1270 |
+
public function ajaxGetImagesAction(RscSgg_Http_Request $request)
|
1271 |
{
|
1272 |
if (null === $galleryId = $request->post->get('gallery_id')) {
|
1273 |
return $this->response(
|
1274 |
+
RscSgg_Http_Response::AJAX,
|
1275 |
$this->getErrorResponseData(
|
1276 |
'Gallery identifier is not specified.'
|
1277 |
)
|
1283 |
|
1284 |
if (null === $gallery = $galleries->getById((int)$galleryId)) {
|
1285 |
return $this->response(
|
1286 |
+
RscSgg_Http_Response::AJAX,
|
1287 |
$this->getErrorResponseData('The gallery does not exists.')
|
1288 |
);
|
1289 |
}
|
1291 |
$gallery->settings = $this->getModel('settings')->get($galleryId)->data;
|
1292 |
|
1293 |
return $this->response(
|
1294 |
+
RscSgg_Http_Response::AJAX,
|
1295 |
$this->getSuccessResponseData(
|
1296 |
null,
|
1297 |
array(
|
1302 |
);
|
1303 |
}
|
1304 |
|
1305 |
+
public function ajaxResizeImageAction(RscSgg_Http_Request $request)
|
1306 |
{
|
1307 |
if (!function_exists('wp_get_image_editor')) {
|
1308 |
return $this->response(
|
1309 |
+
RscSgg_Http_Response::AJAX,
|
1310 |
$this->getErrorResponseData(
|
1311 |
'Current WordPress revision has not Image Editor.'
|
1312 |
)
|
1319 |
|
1320 |
if (!$attachmentId) {
|
1321 |
return $this->response(
|
1322 |
+
RscSgg_Http_Response::AJAX,
|
1323 |
$this->getErrorResponseData(
|
1324 |
'The attachment id is not specified.'
|
1325 |
)
|
1331 |
|
1332 |
if (!is_file($file = $upload['basedir'] . '/' . $meta['file'])) {
|
1333 |
return $this->response(
|
1334 |
+
RscSgg_Http_Response::AJAX,
|
1335 |
$this->getErrorResponseData(
|
1336 |
sprintf('File not found: %s', $file)
|
1337 |
)
|
1340 |
|
1341 |
if (!$width || !$height) {
|
1342 |
return $this->response(
|
1343 |
+
RscSgg_Http_Response::AJAX,
|
1344 |
$this->getErrorResponseData('Width or Height is not specified.')
|
1345 |
);
|
1346 |
}
|
1349 |
|
1350 |
if (is_wp_error($editor)) {
|
1351 |
return $this->response(
|
1352 |
+
RscSgg_Http_Response::AJAX,
|
1353 |
$this->getErrorResponseData(
|
1354 |
sprintf('Unable to load the image: %s', $file)
|
1355 |
)
|
1358 |
|
1359 |
if (is_wp_error($error = $editor->resize((int)$width, (int)$height, true))) {
|
1360 |
return $this->response(
|
1361 |
+
RscSgg_Http_Response::AJAX,
|
1362 |
$this->getErrorResponseData(
|
1363 |
sprintf(
|
1364 |
'Unable to resize the image: %s.',
|
1374 |
$image = $editor->save();
|
1375 |
|
1376 |
return $this->response(
|
1377 |
+
RscSgg_Http_Response::AJAX,
|
1378 |
$this->getSuccessResponseData(
|
1379 |
sprintf('Attachment %s resized successfully.', $attachmentId),
|
1380 |
array(
|
1387 |
/**
|
1388 |
* Save sort images by (Size, Name, Add date, Create Date)
|
1389 |
*
|
1390 |
+
* @param RscSgg_Http_Request $request query post param
|
1391 |
* @return string msg Response answer
|
1392 |
*/
|
1393 |
+
public function saveSortByAction(RscSgg_Http_Request $request)
|
1394 |
{
|
1395 |
$galleryId = $request->post->get('gallery_id');
|
1396 |
|
1425 |
$this->getModule('galleries')->cleanCache($galleryId);
|
1426 |
|
1427 |
return $this->response(
|
1428 |
+
RscSgg_Http_Response::AJAX,
|
1429 |
$this->getSuccessResponseData(
|
1430 |
"Save sorted"
|
1431 |
)
|
1432 |
);
|
1433 |
}
|
1434 |
|
1435 |
+
public function getGalleriesListAction(RscSgg_Http_Request $request)
|
1436 |
{
|
1437 |
$galleries = $this->getModel('galleries');
|
1438 |
|
1439 |
return $this->response(
|
1440 |
+
RscSgg_Http_Response::AJAX, array(
|
1441 |
'list' => $galleries->getList(),
|
1442 |
)
|
1443 |
);
|
1444 |
}
|
1445 |
|
1446 |
+
public function importSettingsAction(RscSgg_Http_Request $request)
|
1447 |
{
|
1448 |
$settingsModel = $this->getModel('settings');
|
1449 |
$from = $request->post->get('from');
|
1452 |
$settingsModel->save($to, $settings->data);
|
1453 |
$this->getModule('galleries')->cleanCache($to, true);
|
1454 |
return $this->response(
|
1455 |
+
RscSgg_Http_Response::AJAX, array(
|
1456 |
'success' => true,
|
1457 |
)
|
1458 |
);
|
1475 |
);
|
1476 |
}
|
1477 |
|
1478 |
+
public function cloneAction(RscSgg_Http_Request $request) {
|
1479 |
$route = $request->post->get("route");
|
1480 |
$oldGalleryId = null;
|
1481 |
$result = array(
|
1490 |
$result = $galleryModel->cloneGallery($oldGalleryId, $cloneType, $this->getCloneParams());
|
1491 |
}
|
1492 |
}
|
1493 |
+
return $this->response(RscSgg_Http_Response::AJAX, $result);
|
1494 |
}
|
1495 |
|
1496 |
+
public function createDefaultGallerySettingsAction(RscSgg_Http_Request $request){
|
1497 |
$galleryId = $request->post->get("id");
|
1498 |
update_option('defaultgallerysettings', $galleryId);
|
1499 |
|
1500 |
return $this->response(
|
1501 |
+
RscSgg_Http_Response::AJAX, array(
|
1502 |
'success' => true,
|
1503 |
'message' => 'success',
|
1504 |
)
|
1506 |
|
1507 |
}
|
1508 |
|
1509 |
+
public function removeDefaultGallerySettingsAction(RscSgg_Http_Request $request){
|
1510 |
$galleryId = $request->post->get("id");
|
1511 |
delete_option('defaultgallerysettings', $galleryId);
|
1512 |
|
1513 |
return $this->response(
|
1514 |
+
RscSgg_Http_Response::AJAX, array(
|
1515 |
'success' => true,
|
1516 |
'message' => 'success',
|
1517 |
)
|
src/GridGallery/Galleries/Model/Galleries.php
CHANGED
@@ -820,12 +820,12 @@ class GridGallery_Galleries_Model_Galleries extends GridGallery_Core_BaseModel
|
|
820 |
|
821 |
/**
|
822 |
* Creates the new gallery from the HTTP request
|
823 |
-
* @param
|
824 |
-
* @param
|
825 |
-
* @param
|
826 |
* @return bool TRUE on success, FALSE otherwise
|
827 |
*/
|
828 |
-
public function createFromRequest(
|
829 |
{
|
830 |
$title = $request->post->get('title');
|
831 |
$unnamed = (!$title || strlen($title) == 0);
|
@@ -891,12 +891,12 @@ class GridGallery_Galleries_Model_Galleries extends GridGallery_Core_BaseModel
|
|
891 |
/**
|
892 |
* Renames the gallery from the HTTP request
|
893 |
*
|
894 |
-
* @param
|
895 |
-
* @param
|
896 |
* @throws RuntimeException When rename query return FALSE
|
897 |
* @throws InvalidArgumentException If at least one argument is invalid
|
898 |
*/
|
899 |
-
public function renameFromRequest(
|
900 |
{
|
901 |
$galleryId = $request->post->get('gallery_id');
|
902 |
$title = $request->post->get('title');
|
@@ -919,13 +919,13 @@ class GridGallery_Galleries_Model_Galleries extends GridGallery_Core_BaseModel
|
|
919 |
/**
|
920 |
* Deletes gallery from the database from the HTTP request
|
921 |
*
|
922 |
-
* @param
|
923 |
-
* @param
|
924 |
* @param string $hooksPrefix The prefix for the plugin hooks
|
925 |
* @throws RuntimeException
|
926 |
* @throws UnexpectedValueException
|
927 |
*/
|
928 |
-
public function deleteFromRequest(
|
929 |
{
|
930 |
$galleryId = $request->query->get('gallery_id');
|
931 |
|
@@ -1081,10 +1081,10 @@ class GridGallery_Galleries_Model_Galleries extends GridGallery_Core_BaseModel
|
|
1081 |
/**
|
1082 |
* Sets a logger instance on the object
|
1083 |
*
|
1084 |
-
* @param
|
1085 |
* @return null
|
1086 |
*/
|
1087 |
-
public function setLogger(
|
1088 |
{
|
1089 |
$this->logger = $logger;
|
1090 |
}
|
820 |
|
821 |
/**
|
822 |
* Creates the new gallery from the HTTP request
|
823 |
+
* @param RscSgg_Http_Request $request The HTTP request
|
824 |
+
* @param RscSgg_Lang $lang The instance of the language class
|
825 |
+
* @param RscSgg_Config $config
|
826 |
* @return bool TRUE on success, FALSE otherwise
|
827 |
*/
|
828 |
+
public function createFromRequest(RscSgg_Http_Request $request, RscSgg_Lang $lang, RscSgg_Config $config)
|
829 |
{
|
830 |
$title = $request->post->get('title');
|
831 |
$unnamed = (!$title || strlen($title) == 0);
|
891 |
/**
|
892 |
* Renames the gallery from the HTTP request
|
893 |
*
|
894 |
+
* @param RscSgg_Http_Request $request An instance of the HTTP request
|
895 |
+
* @param RscSgg_Lang $lang An instance of the translation class
|
896 |
* @throws RuntimeException When rename query return FALSE
|
897 |
* @throws InvalidArgumentException If at least one argument is invalid
|
898 |
*/
|
899 |
+
public function renameFromRequest(RscSgg_Http_Request $request, RscSgg_Lang $lang)
|
900 |
{
|
901 |
$galleryId = $request->post->get('gallery_id');
|
902 |
$title = $request->post->get('title');
|
919 |
/**
|
920 |
* Deletes gallery from the database from the HTTP request
|
921 |
*
|
922 |
+
* @param RscSgg_Http_Request $request An instance of the HTTP request
|
923 |
+
* @param RscSgg_Lang $lang An instance of the translation class
|
924 |
* @param string $hooksPrefix The prefix for the plugin hooks
|
925 |
* @throws RuntimeException
|
926 |
* @throws UnexpectedValueException
|
927 |
*/
|
928 |
+
public function deleteFromRequest(RscSgg_Http_Request $request, RscSgg_Lang $lang, $hooksPrefix = null)
|
929 |
{
|
930 |
$galleryId = $request->query->get('gallery_id');
|
931 |
|
1081 |
/**
|
1082 |
* Sets a logger instance on the object
|
1083 |
*
|
1084 |
+
* @param RscSgg_Logger_Interface $logger
|
1085 |
* @return null
|
1086 |
*/
|
1087 |
+
public function setLogger(RscSgg_Logger_Interface $logger)
|
1088 |
{
|
1089 |
$this->logger = $logger;
|
1090 |
}
|
src/GridGallery/Galleries/Model/Resources.php
CHANGED
@@ -150,13 +150,13 @@ class GridGallery_Galleries_Model_Resources extends GridGallery_Core_BaseModel
|
|
150 |
/**
|
151 |
* Attaches resources to the gallery from the HTTP request
|
152 |
*
|
153 |
-
* @param
|
154 |
-
* @param
|
155 |
*
|
156 |
* @return mixed
|
157 |
* @throws GridGallery_Galleries_Exception_AttachException If not enough input data
|
158 |
*/
|
159 |
-
public function attachFromRequest(
|
160 |
{
|
161 |
if (!$resources = $request->post->get('resources')) {
|
162 |
|
@@ -213,7 +213,7 @@ class GridGallery_Galleries_Model_Resources extends GridGallery_Core_BaseModel
|
|
213 |
return $galleryId;
|
214 |
}
|
215 |
|
216 |
-
public function deleteFromRequest(
|
217 |
{
|
218 |
$galleryId = $request->post->get('gallery_id');
|
219 |
$resources = $request->post->get('ids');
|
@@ -363,10 +363,10 @@ class GridGallery_Galleries_Model_Resources extends GridGallery_Core_BaseModel
|
|
363 |
/**
|
364 |
* Sets a logger instance on the object
|
365 |
*
|
366 |
-
* @param
|
367 |
* @return null
|
368 |
*/
|
369 |
-
public function setLogger(
|
370 |
{
|
371 |
$this->logger = $logger;
|
372 |
}
|
150 |
/**
|
151 |
* Attaches resources to the gallery from the HTTP request
|
152 |
*
|
153 |
+
* @param RscSgg_Http_Request $request The HTTP request
|
154 |
+
* @param RscSgg_Lang $lang The instance of the language class
|
155 |
*
|
156 |
* @return mixed
|
157 |
* @throws GridGallery_Galleries_Exception_AttachException If not enough input data
|
158 |
*/
|
159 |
+
public function attachFromRequest(RscSgg_Http_Request $request, RscSgg_Lang $lang)
|
160 |
{
|
161 |
if (!$resources = $request->post->get('resources')) {
|
162 |
|
213 |
return $galleryId;
|
214 |
}
|
215 |
|
216 |
+
public function deleteFromRequest(RscSgg_Http_Request $request)
|
217 |
{
|
218 |
$galleryId = $request->post->get('gallery_id');
|
219 |
$resources = $request->post->get('ids');
|
363 |
/**
|
364 |
* Sets a logger instance on the object
|
365 |
*
|
366 |
+
* @param RscSgg_Logger_Interface $logger
|
367 |
* @return null
|
368 |
*/
|
369 |
+
public function setLogger(RscSgg_Logger_Interface $logger)
|
370 |
{
|
371 |
$this->logger = $logger;
|
372 |
}
|
src/GridGallery/Galleries/Model/plugins/Mobile_Detect.php
CHANGED
@@ -1127,7 +1127,8 @@ class Mobile_Detect
|
|
1127 |
*/
|
1128 |
public function match($regex, $userAgent = null)
|
1129 |
{
|
1130 |
-
$
|
|
|
1131 |
// If positive match is found, store the results for debug.
|
1132 |
if ($match) {
|
1133 |
$this->matchingRegex = $regex;
|
1127 |
*/
|
1128 |
public function match($regex, $userAgent = null)
|
1129 |
{
|
1130 |
+
$preg = (false === empty($userAgent) ? $userAgent : $this->userAgent);
|
1131 |
+
$match = (bool) preg_match(sprintf('#%s#is', $regex), (string)$preg, $matches);
|
1132 |
// If positive match is found, store the results for debug.
|
1133 |
if ($match) {
|
1134 |
$this->matchingRegex = $regex;
|
src/GridGallery/Galleries/Module.php
CHANGED
@@ -36,28 +36,28 @@ class GridGallery_Galleries_Module extends GridGallery_Core_Module
|
|
36 |
add_image_size('gg_gallery_thumbnail', 450, 250, true);
|
37 |
|
38 |
// !!!!!! use {} for preg_* functions as start and end of the expresion.
|
39 |
-
$pregReplaceFilter = new
|
40 |
'preg_replace',
|
41 |
array($this, 'pregReplace')
|
42 |
);
|
43 |
|
44 |
-
$httpFilter = new
|
45 |
'force_http',
|
46 |
array($this, 'forceHttpUrl')
|
47 |
);
|
48 |
-
$htmlspecialchars_decode = new
|
49 |
'htmlspecialchars_decode',
|
50 |
'htmlspecialchars_decode'
|
51 |
);
|
52 |
|
53 |
-
$function = new
|
54 |
-
$ceilFunction = new
|
55 |
$all_categories_func =
|
56 |
-
new
|
57 |
'all_categories',
|
58 |
'get_categories'
|
59 |
);
|
60 |
-
$hexToRgbaFunction = new
|
61 |
|
62 |
$twig = $this->getEnvironment()->getTwig();
|
63 |
$twig->enableAutoReload();
|
@@ -70,7 +70,7 @@ class GridGallery_Galleries_Module extends GridGallery_Core_Module
|
|
70 |
$twig->addFunction($hexToRgbaFunction);
|
71 |
|
72 |
// To avoid conflict with other plugins which have older twig version.
|
73 |
-
$twig->addFilter(new
|
74 |
|
75 |
|
76 |
// Widget
|
@@ -731,7 +731,7 @@ class GridGallery_Galleries_Module extends GridGallery_Core_Module
|
|
731 |
$this->getEnvironment()
|
732 |
->getTwig()
|
733 |
->addFunction(
|
734 |
-
new
|
735 |
$attachment,
|
736 |
'getAttachment'
|
737 |
)
|
@@ -740,7 +740,7 @@ class GridGallery_Galleries_Module extends GridGallery_Core_Module
|
|
740 |
$this->getEnvironment()
|
741 |
->getTwig()
|
742 |
->addFunction(
|
743 |
-
new
|
744 |
$attachment,
|
745 |
'setAttachmentSettings',
|
746 |
)
|
36 |
add_image_size('gg_gallery_thumbnail', 450, 250, true);
|
37 |
|
38 |
// !!!!!! use {} for preg_* functions as start and end of the expresion.
|
39 |
+
$pregReplaceFilter = new Twig_SupTwgSgg_SimpleFilter(
|
40 |
'preg_replace',
|
41 |
array($this, 'pregReplace')
|
42 |
);
|
43 |
|
44 |
+
$httpFilter = new Twig_SupTwgSgg_SimpleFilter(
|
45 |
'force_http',
|
46 |
array($this, 'forceHttpUrl')
|
47 |
);
|
48 |
+
$htmlspecialchars_decode = new Twig_SupTwgSgg_SimpleFilter(
|
49 |
'htmlspecialchars_decode',
|
50 |
'htmlspecialchars_decode'
|
51 |
);
|
52 |
|
53 |
+
$function = new Twig_SupTwgSgg_SimpleFunction('translate', array($this->getController(), 'translate'));
|
54 |
+
$ceilFunction = new Twig_SupTwgSgg_SimpleFunction('ceil','ceil');
|
55 |
$all_categories_func =
|
56 |
+
new Twig_SupTwgSgg_SimpleFunction(
|
57 |
'all_categories',
|
58 |
'get_categories'
|
59 |
);
|
60 |
+
$hexToRgbaFunction = new Twig_SupTwgSgg_SimpleFunction('hex_to_rgba', 'GridGallery_Galleries_Module::hexToRgbaStr');
|
61 |
|
62 |
$twig = $this->getEnvironment()->getTwig();
|
63 |
$twig->enableAutoReload();
|
70 |
$twig->addFunction($hexToRgbaFunction);
|
71 |
|
72 |
// To avoid conflict with other plugins which have older twig version.
|
73 |
+
$twig->addFilter(new Twig_SupTwgSgg_SimpleFilter('round', 'round'));
|
74 |
|
75 |
|
76 |
// Widget
|
731 |
$this->getEnvironment()
|
732 |
->getTwig()
|
733 |
->addFunction(
|
734 |
+
new Twig_SupTwgSgg_SimpleFunction('get_attachment', array(
|
735 |
$attachment,
|
736 |
'getAttachment'
|
737 |
)
|
740 |
$this->getEnvironment()
|
741 |
->getTwig()
|
742 |
->addFunction(
|
743 |
+
new Twig_SupTwgSgg_SimpleFunction('set_attachment_settings', array(
|
744 |
$attachment,
|
745 |
'setAttachmentSettings',
|
746 |
)
|
src/GridGallery/Galleries/views/settings.twig
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
|
17 |
{% block header %}
|
18 |
{#{{ dump(settings) }}#}
|
19 |
-
<nav id="supsystic-breadcrumbs" class="supsystic-breadcrumbs" style="float: left;
|
20 |
{#
|
21 |
<ul class="supsystic-bar-controls">
|
22 |
<li>
|
16 |
|
17 |
{% block header %}
|
18 |
{#{{ dump(settings) }}#}
|
19 |
+
<nav id="supsystic-breadcrumbs" class="supsystic-breadcrumbs" style="float: left;">
|
20 |
{#
|
21 |
<ul class="supsystic-bar-controls">
|
22 |
<li>
|
src/GridGallery/Galleries/views/sort.twig
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
{% extends 'grid-gallery.twig' %}
|
2 |
|
3 |
{% block header %}
|
4 |
-
<nav id="supsystic-breadcrumbs" class="supsystic-breadcrumbs" style="float: left;
|
5 |
{#<a href="{{ environment.generateUrl('galleries') }}">{{ translate('Gallery by Supsystic') }}</a>#}
|
6 |
{#<i class="fa fa-angle-right"></i>#}
|
7 |
<a href="{{ environment.generateUrl('galleries') }}">{{ translate('Galleries') }}</a>
|
@@ -67,8 +67,8 @@
|
|
67 |
<li>
|
68 |
<div class="gg-wraper-option-links" style="padding-left: 20px">
|
69 |
{{ translate('Preview size: ') }}
|
70 |
-
<a href="#gg-big" class="gg-option-links" data-size-image data-width="200">{{ translate('Big') }}</a> /
|
71 |
-
<a href="#gg-medium" class="gg-option-links active" data-size-image data-width="150">{{ translate('Medium') }}</a> /
|
72 |
<a href="#gg-small" class="gg-option-links" data-size-image data-width="80">{{ translate('Small') }}</a>
|
73 |
</div>
|
74 |
</li>
|
@@ -87,7 +87,7 @@
|
|
87 |
</ul>
|
88 |
</div>
|
89 |
|
90 |
-
<div class="gg-settings-block">
|
91 |
<ul class="supsystic-bar-controls">
|
92 |
<li title="{{ translate('Sort By: ') }}">
|
93 |
{{ translate('Sort By: ') }}
|
@@ -147,7 +147,7 @@
|
|
147 |
<i class="fa fa-arrows-v ggImgVerticalMove" style="padding:4px" aria-hidden="true"></i>
|
148 |
<a href="#gg-rename" class="gg-rename-category">{{ category }}</a>: <label data-count>0</label> {{ translate('media') }}
|
149 |
</div>
|
150 |
-
<ul class="sg-photos gg-sort-entities gg-category-container" data-category="{{ category }}"></ul>
|
151 |
</div>
|
152 |
{% endfor %}
|
153 |
<div class="gg-category">
|
@@ -155,7 +155,7 @@
|
|
155 |
<i class="fa fa-arrows-v ggImgVerticalMove" style="padding:4px" aria-hidden="true"></i>
|
156 |
<label class>{{ translate('No category') }}:</label> <label data-count>0</label> {{ translate('media') }}
|
157 |
</div>
|
158 |
-
<ul class="sg-photos gg-sort-entities gg-category-container" data-category=""></ul>
|
159 |
</div>
|
160 |
</div>
|
161 |
{% endif %}
|
@@ -179,5 +179,3 @@
|
|
179 |
<img class="supsystic-lazy gg-image-thumbnail" data-original="{{ src }}" alt="{{ image.attachment.title }}" width="150" height="150"/>
|
180 |
</li>
|
181 |
{% endmacro %}
|
182 |
-
|
183 |
-
|
1 |
{% extends 'grid-gallery.twig' %}
|
2 |
|
3 |
{% block header %}
|
4 |
+
<nav id="supsystic-breadcrumbs" class="supsystic-breadcrumbs" style="float: left;">
|
5 |
{#<a href="{{ environment.generateUrl('galleries') }}">{{ translate('Gallery by Supsystic') }}</a>#}
|
6 |
{#<i class="fa fa-angle-right"></i>#}
|
7 |
<a href="{{ environment.generateUrl('galleries') }}">{{ translate('Galleries') }}</a>
|
67 |
<li>
|
68 |
<div class="gg-wraper-option-links" style="padding-left: 20px">
|
69 |
{{ translate('Preview size: ') }}
|
70 |
+
<a href="#gg-big" class="gg-option-links" data-size-image data-width="200">{{ translate('Big') }}</a> /
|
71 |
+
<a href="#gg-medium" class="gg-option-links active" data-size-image data-width="150">{{ translate('Medium') }}</a> /
|
72 |
<a href="#gg-small" class="gg-option-links" data-size-image data-width="80">{{ translate('Small') }}</a>
|
73 |
</div>
|
74 |
</li>
|
87 |
</ul>
|
88 |
</div>
|
89 |
|
90 |
+
<div class="gg-settings-block">
|
91 |
<ul class="supsystic-bar-controls">
|
92 |
<li title="{{ translate('Sort By: ') }}">
|
93 |
{{ translate('Sort By: ') }}
|
147 |
<i class="fa fa-arrows-v ggImgVerticalMove" style="padding:4px" aria-hidden="true"></i>
|
148 |
<a href="#gg-rename" class="gg-rename-category">{{ category }}</a>: <label data-count>0</label> {{ translate('media') }}
|
149 |
</div>
|
150 |
+
<ul class="sg-photos gg-sort-entities gg-category-container" data-category="{{ category }}"></ul>
|
151 |
</div>
|
152 |
{% endfor %}
|
153 |
<div class="gg-category">
|
155 |
<i class="fa fa-arrows-v ggImgVerticalMove" style="padding:4px" aria-hidden="true"></i>
|
156 |
<label class>{{ translate('No category') }}:</label> <label data-count>0</label> {{ translate('media') }}
|
157 |
</div>
|
158 |
+
<ul class="sg-photos gg-sort-entities gg-category-container" data-category=""></ul>
|
159 |
</div>
|
160 |
</div>
|
161 |
{% endif %}
|
179 |
<img class="supsystic-lazy gg-image-thumbnail" data-original="{{ src }}" alt="{{ image.attachment.title }}" width="150" height="150"/>
|
180 |
</li>
|
181 |
{% endmacro %}
|
|
|
|
src/GridGallery/Galleries/views/view.twig
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
{% extends 'grid-gallery.twig' %}
|
2 |
|
3 |
{% block header %}
|
4 |
-
<nav id="supsystic-breadcrumbs" class="supsystic-breadcrumbs" style="float: left; padding: 20px
|
5 |
{#<a href="{{ environment.generateUrl('galleries') }}">{{ translate('Gallery by Supsystic') }}</a>#}
|
6 |
{#<i class="fa fa-angle-right"></i>#}
|
7 |
<a href="{{ environment.generateUrl('galleries') }}">{{ translate('Galleries') }}</a>
|
@@ -88,7 +88,7 @@
|
|
88 |
</li>
|
89 |
<li class="gg-checked-container gg-checked-add-category ggSettingsDisplNone">
|
90 |
<select id="gg-categories-list" style="height: 34px;">
|
91 |
-
{% if(gallery.tags|length > 0) %}
|
92 |
{% for value, title in gallery.tags %}
|
93 |
<option value="{{ title }}">{{ title }}</option>
|
94 |
{% endfor %}
|
@@ -97,7 +97,7 @@
|
|
97 |
</li>
|
98 |
<li class="gg-checked-container gg-checked-del-category ggSettingsDisplNone">
|
99 |
<select id="gg-categories-del" style="height: 34px;">
|
100 |
-
{% if(gallery.tags|length > 0) %}
|
101 |
{% for value, title in gallery.tags %}
|
102 |
<option value="{{ title }}">{{ title }}</option>
|
103 |
{% endfor %}
|
@@ -149,7 +149,7 @@
|
|
149 |
</li>
|
150 |
<li class="separator">|</li>
|
151 |
</ul>
|
152 |
-
|
153 |
<ul class="supsystic-bar-controls">
|
154 |
<li title="{{ translate('Sort By: ') }}">
|
155 |
{{ translate('Sort By: ') }}
|
@@ -207,7 +207,7 @@
|
|
207 |
{% import '@ui/type.twig' as view %}
|
208 |
{% set entity = { images: gallery.photos } %}
|
209 |
{% set sliderSettings = settings %}
|
210 |
-
|
211 |
{% if viewType == 'block' %}
|
212 |
{{ view.block_view(entity) }}
|
213 |
{% endif %}
|
@@ -226,7 +226,7 @@
|
|
226 |
<button class="button remove">{{ translate('Remove selected') }}</button>
|
227 |
</div>
|
228 |
<div class="linked-attachments-list">
|
229 |
-
|
230 |
</div>
|
231 |
<div class="loading-container">
|
232 |
<i class="fa fa-spinner fa-spin fa-2x"></i>
|
@@ -410,21 +410,21 @@
|
|
410 |
{% endblock %}
|
411 |
</div>
|
412 |
<style>
|
413 |
-
.hi-icon {
|
414 |
-
color: {{ settings.icons.color }} !important;
|
415 |
-
background: {{ settings.icons.background }} !important;
|
416 |
}
|
417 |
-
.hi-icon:hover {
|
418 |
-
color: {{ settings.icons.hover_color }} !important;
|
419 |
-
background: {{ settings.icons.background_hover }} !important;
|
420 |
}
|
421 |
-
.hi-icon {
|
422 |
-
width: {{ settings.icons.size * 2 }}px !important;
|
423 |
-
height: {{ settings.icons.size * 2 }}px !important;
|
424 |
}
|
425 |
-
.hi-icon:before {
|
426 |
-
font-size: {{ settings.icons.size|default(16) }}px !important;
|
427 |
-
line-height: {{ settings.icons.size * 2 }}px !important;
|
428 |
}
|
429 |
</style>
|
430 |
{% block settingsOtherPro %}
|
@@ -498,4 +498,4 @@
|
|
498 |
</div>
|
499 |
{% endif %}
|
500 |
|
501 |
-
{% endblock %}
|
1 |
{% extends 'grid-gallery.twig' %}
|
2 |
|
3 |
{% block header %}
|
4 |
+
<nav id="supsystic-breadcrumbs" class="supsystic-breadcrumbs" style="float: left; padding: 20px;">
|
5 |
{#<a href="{{ environment.generateUrl('galleries') }}">{{ translate('Gallery by Supsystic') }}</a>#}
|
6 |
{#<i class="fa fa-angle-right"></i>#}
|
7 |
<a href="{{ environment.generateUrl('galleries') }}">{{ translate('Galleries') }}</a>
|
88 |
</li>
|
89 |
<li class="gg-checked-container gg-checked-add-category ggSettingsDisplNone">
|
90 |
<select id="gg-categories-list" style="height: 34px;">
|
91 |
+
{% if(gallery.tags|length > 0) %}
|
92 |
{% for value, title in gallery.tags %}
|
93 |
<option value="{{ title }}">{{ title }}</option>
|
94 |
{% endfor %}
|
97 |
</li>
|
98 |
<li class="gg-checked-container gg-checked-del-category ggSettingsDisplNone">
|
99 |
<select id="gg-categories-del" style="height: 34px;">
|
100 |
+
{% if(gallery.tags|length > 0) %}
|
101 |
{% for value, title in gallery.tags %}
|
102 |
<option value="{{ title }}">{{ title }}</option>
|
103 |
{% endfor %}
|
149 |
</li>
|
150 |
<li class="separator">|</li>
|
151 |
</ul>
|
152 |
+
|
153 |
<ul class="supsystic-bar-controls">
|
154 |
<li title="{{ translate('Sort By: ') }}">
|
155 |
{{ translate('Sort By: ') }}
|
207 |
{% import '@ui/type.twig' as view %}
|
208 |
{% set entity = { images: gallery.photos } %}
|
209 |
{% set sliderSettings = settings %}
|
210 |
+
|
211 |
{% if viewType == 'block' %}
|
212 |
{{ view.block_view(entity) }}
|
213 |
{% endif %}
|
226 |
<button class="button remove">{{ translate('Remove selected') }}</button>
|
227 |
</div>
|
228 |
<div class="linked-attachments-list">
|
229 |
+
|
230 |
</div>
|
231 |
<div class="loading-container">
|
232 |
<i class="fa fa-spinner fa-spin fa-2x"></i>
|
410 |
{% endblock %}
|
411 |
</div>
|
412 |
<style>
|
413 |
+
.hi-icon {
|
414 |
+
color: {{ settings.icons.color }} !important;
|
415 |
+
background: {{ settings.icons.background }} !important;
|
416 |
}
|
417 |
+
.hi-icon:hover {
|
418 |
+
color: {{ settings.icons.hover_color }} !important;
|
419 |
+
background: {{ settings.icons.background_hover }} !important;
|
420 |
}
|
421 |
+
.hi-icon {
|
422 |
+
width: {{ settings.icons.size * 2 }}px !important;
|
423 |
+
height: {{ settings.icons.size * 2 }}px !important;
|
424 |
}
|
425 |
+
.hi-icon:before {
|
426 |
+
font-size: {{ settings.icons.size|default(16) }}px !important;
|
427 |
+
line-height: {{ settings.icons.size * 2 }}px !important;
|
428 |
}
|
429 |
</style>
|
430 |
{% block settingsOtherPro %}
|
498 |
</div>
|
499 |
{% endif %}
|
500 |
|
501 |
+
{% endblock %}
|
src/GridGallery/Insta/Controller.php
CHANGED
@@ -15,7 +15,7 @@ class GridGallery_Insta_Controller extends GridGallery_Core_BaseController
|
|
15 |
* If user is not authorized yet, then we ask for authorization.
|
16 |
* Otherwise we show page about current user.
|
17 |
*
|
18 |
-
* @return
|
19 |
*/
|
20 |
|
21 |
protected function getModelAliases()
|
@@ -26,7 +26,7 @@ class GridGallery_Insta_Controller extends GridGallery_Core_BaseController
|
|
26 |
);
|
27 |
}
|
28 |
|
29 |
-
public function indexAction(
|
30 |
{
|
31 |
$galleryId = $request->query->get('id');
|
32 |
$galleries = $this->getModel('galleries');
|
@@ -50,9 +50,9 @@ class GridGallery_Insta_Controller extends GridGallery_Core_BaseController
|
|
50 |
/**
|
51 |
* Asks user to authorize with Instagram.
|
52 |
*
|
53 |
-
* @return
|
54 |
*/
|
55 |
-
public function authorizationAction(
|
56 |
{
|
57 |
$galleryId = $request->query->get('id');
|
58 |
$galleries = $this->getModel('galleries');
|
@@ -71,7 +71,7 @@ class GridGallery_Insta_Controller extends GridGallery_Core_BaseController
|
|
71 |
}
|
72 |
}
|
73 |
|
74 |
-
public function completeAction(
|
75 |
{
|
76 |
$code = $request->query->get('code');
|
77 |
$galleryId = $request->query->get('id');
|
@@ -108,7 +108,7 @@ class GridGallery_Insta_Controller extends GridGallery_Core_BaseController
|
|
108 |
return $this->redirect($this->generateUrl('insta', 'index', array('id' => $galleryId)));
|
109 |
}
|
110 |
|
111 |
-
public function refreshAction(
|
112 |
{
|
113 |
$savedThumbs = get_option('insta_thumbnails');
|
114 |
$client = $this->getClient();
|
@@ -120,14 +120,14 @@ class GridGallery_Insta_Controller extends GridGallery_Core_BaseController
|
|
120 |
}
|
121 |
}
|
122 |
update_option('insta_thumbnails', $thumbs);
|
123 |
-
return $this->response(
|
124 |
}
|
125 |
|
126 |
-
public function listAction(
|
127 |
{
|
128 |
|
129 |
return $this->response(
|
130 |
-
|
131 |
array(
|
132 |
'galleries' => $this->getModel('galleries')->getList(),
|
133 |
)
|
@@ -135,7 +135,7 @@ class GridGallery_Insta_Controller extends GridGallery_Core_BaseController
|
|
135 |
|
136 |
}
|
137 |
|
138 |
-
public function logoutAction(
|
139 |
{
|
140 |
$galleryId = $request->query->get('id');
|
141 |
|
15 |
* If user is not authorized yet, then we ask for authorization.
|
16 |
* Otherwise we show page about current user.
|
17 |
*
|
18 |
+
* @return RscSgg_Http_Response
|
19 |
*/
|
20 |
|
21 |
protected function getModelAliases()
|
26 |
);
|
27 |
}
|
28 |
|
29 |
+
public function indexAction(RscSgg_Http_Request $request)
|
30 |
{
|
31 |
$galleryId = $request->query->get('id');
|
32 |
$galleries = $this->getModel('galleries');
|
50 |
/**
|
51 |
* Asks user to authorize with Instagram.
|
52 |
*
|
53 |
+
* @return RscSgg_Http_Response
|
54 |
*/
|
55 |
+
public function authorizationAction(RscSgg_Http_Request $request)
|
56 |
{
|
57 |
$galleryId = $request->query->get('id');
|
58 |
$galleries = $this->getModel('galleries');
|
71 |
}
|
72 |
}
|
73 |
|
74 |
+
public function completeAction(RscSgg_Http_Request $request)
|
75 |
{
|
76 |
$code = $request->query->get('code');
|
77 |
$galleryId = $request->query->get('id');
|
108 |
return $this->redirect($this->generateUrl('insta', 'index', array('id' => $galleryId)));
|
109 |
}
|
110 |
|
111 |
+
public function refreshAction(RscSgg_Http_Request $request)
|
112 |
{
|
113 |
$savedThumbs = get_option('insta_thumbnails');
|
114 |
$client = $this->getClient();
|
120 |
}
|
121 |
}
|
122 |
update_option('insta_thumbnails', $thumbs);
|
123 |
+
return $this->response(RscSgg_Http_Response::AJAX, array('images' => $images));
|
124 |
}
|
125 |
|
126 |
+
public function listAction(RscSgg_Http_Request $request)
|
127 |
{
|
128 |
|
129 |
return $this->response(
|
130 |
+
RscSgg_Http_Response::AJAX,
|
131 |
array(
|
132 |
'galleries' => $this->getModel('galleries')->getList(),
|
133 |
)
|
135 |
|
136 |
}
|
137 |
|
138 |
+
public function logoutAction(RscSgg_Http_Request $request)
|
139 |
{
|
140 |
$galleryId = $request->query->get('id');
|
141 |
|
src/GridGallery/Insta/Module.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class GridGallery_Insta_Module extends
|
5 |
{
|
6 |
|
7 |
protected $client;
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class GridGallery_Insta_Module extends RscSgg_Mvc_Module
|
5 |
{
|
6 |
|
7 |
protected $client;
|
src/GridGallery/Optimization/Controller.php
CHANGED
@@ -27,7 +27,7 @@ class GridGallery_Optimization_Controller extends GridGallery_Core_BaseControlle
|
|
27 |
);
|
28 |
}
|
29 |
|
30 |
-
public function indexAction(
|
31 |
|
32 |
$imageOptimizeModel = $this->getModel('imageOptimize');
|
33 |
$requirements = $imageOptimizeModel->checkRequirements();
|
@@ -79,7 +79,7 @@ class GridGallery_Optimization_Controller extends GridGallery_Core_BaseControlle
|
|
79 |
}
|
80 |
}
|
81 |
|
82 |
-
public function saveSettingsAction(
|
83 |
|
84 |
$message = $this->translate('Error occurred');
|
85 |
$isSuccess = false;
|
@@ -98,13 +98,13 @@ class GridGallery_Optimization_Controller extends GridGallery_Core_BaseControlle
|
|
98 |
}
|
99 |
}
|
100 |
}
|
101 |
-
return $this->response(
|
102 |
'success' => $isSuccess,
|
103 |
'message' => $message,
|
104 |
));
|
105 |
}
|
106 |
|
107 |
-
public function saveCdnSettingsAction(
|
108 |
|
109 |
$message = $this->translate('Error occurred');
|
110 |
$isSuccess = false;
|
@@ -132,13 +132,13 @@ class GridGallery_Optimization_Controller extends GridGallery_Core_BaseControlle
|
|
132 |
}
|
133 |
}
|
134 |
}
|
135 |
-
return $this->response(
|
136 |
'success' => $isSuccess,
|
137 |
'message' => $message,
|
138 |
));
|
139 |
}
|
140 |
|
141 |
-
public function getPhotoListAction(
|
142 |
$message = $this->translate('Error occurred');
|
143 |
$isSuccess = false;
|
144 |
|
@@ -214,7 +214,7 @@ class GridGallery_Optimization_Controller extends GridGallery_Core_BaseControlle
|
|
214 |
}
|
215 |
}
|
216 |
|
217 |
-
return $this->response(
|
218 |
'success' => $isSuccess,
|
219 |
'message' => $message,
|
220 |
'photos' => $photos,
|
@@ -222,7 +222,7 @@ class GridGallery_Optimization_Controller extends GridGallery_Core_BaseControlle
|
|
222 |
));
|
223 |
}
|
224 |
|
225 |
-
public function getCdnPhotoListAction(
|
226 |
$message = $this->translate('Error occurred');
|
227 |
$isSuccess = false;
|
228 |
|
@@ -241,7 +241,7 @@ class GridGallery_Optimization_Controller extends GridGallery_Core_BaseControlle
|
|
241 |
}
|
242 |
}
|
243 |
|
244 |
-
return $this->response(
|
245 |
'success' => $isSuccess,
|
246 |
'message' => $message,
|
247 |
'photos' => $photos,
|
@@ -303,7 +303,7 @@ class GridGallery_Optimization_Controller extends GridGallery_Core_BaseControlle
|
|
303 |
return true;
|
304 |
}
|
305 |
|
306 |
-
public function optimizeOneImageAction(
|
307 |
|
308 |
$message = $this->translate('Error occurred');
|
309 |
$isSuccess = false;
|
@@ -380,7 +380,7 @@ class GridGallery_Optimization_Controller extends GridGallery_Core_BaseControlle
|
|
380 |
}
|
381 |
}
|
382 |
|
383 |
-
return $this->response(
|
384 |
'success' => $isSuccess,
|
385 |
'message' => $message,
|
386 |
'serviceError' => $serviceError,
|
@@ -388,7 +388,7 @@ class GridGallery_Optimization_Controller extends GridGallery_Core_BaseControlle
|
|
388 |
));
|
389 |
}
|
390 |
|
391 |
-
public function transferOneImageAction(
|
392 |
$message = $this->translate('Error occurred');
|
393 |
$isSuccess = false;
|
394 |
$serviceError = false;
|
@@ -439,14 +439,14 @@ class GridGallery_Optimization_Controller extends GridGallery_Core_BaseControlle
|
|
439 |
$message = $this->translate('Error! Incorrect params!');
|
440 |
}
|
441 |
|
442 |
-
return $this->response(
|
443 |
'success' => $isSuccess,
|
444 |
'message' => $message,
|
445 |
'serviceError' => $serviceError,
|
446 |
));
|
447 |
}
|
448 |
|
449 |
-
public function saveOptimizeInfoToDbAction(
|
450 |
$message = $this->translate('Error occurred');
|
451 |
$isSuccess = false;
|
452 |
$route = $request->post->get("route");
|
@@ -483,13 +483,13 @@ class GridGallery_Optimization_Controller extends GridGallery_Core_BaseControlle
|
|
483 |
}
|
484 |
}
|
485 |
|
486 |
-
return $this->response(
|
487 |
'success' => $isSuccess,
|
488 |
'message' => $message,
|
489 |
));
|
490 |
}
|
491 |
|
492 |
-
public function saveCdnInfoToDbAction(
|
493 |
$route = $request->post->get("route");
|
494 |
$addedGall = array();
|
495 |
|
@@ -513,12 +513,12 @@ class GridGallery_Optimization_Controller extends GridGallery_Core_BaseControlle
|
|
513 |
}
|
514 |
}
|
515 |
|
516 |
-
return $this->response(
|
517 |
'galleries' => $addedGall,
|
518 |
));
|
519 |
}
|
520 |
|
521 |
-
public function rollbackRestoredImgAction(
|
522 |
$message = $this->translate('Error occurred');
|
523 |
$isSuccess = false;
|
524 |
$data = isset($request->post['route']['data']) ? $request->post['route']['data'] : null;
|
@@ -534,7 +534,7 @@ class GridGallery_Optimization_Controller extends GridGallery_Core_BaseControlle
|
|
534 |
$optimizeModel->restorePreviousFiles($galleryId, $resources, $photoModel, $currGallerySettings, $imgOptimize);
|
535 |
}
|
536 |
|
537 |
-
return $this->response(
|
538 |
'success' => $isSuccess,
|
539 |
'message' => $message,
|
540 |
));
|
27 |
);
|
28 |
}
|
29 |
|
30 |
+
public function indexAction(RscSgg_Http_Request $request) {
|
31 |
|
32 |
$imageOptimizeModel = $this->getModel('imageOptimize');
|
33 |
$requirements = $imageOptimizeModel->checkRequirements();
|
79 |
}
|
80 |
}
|
81 |
|
82 |
+
public function saveSettingsAction(RscSgg_Http_Request $request) {
|
83 |
|
84 |
$message = $this->translate('Error occurred');
|
85 |
$isSuccess = false;
|
98 |
}
|
99 |
}
|
100 |
}
|
101 |
+
return $this->response(RscSgg_Http_Response::AJAX, array(
|
102 |
'success' => $isSuccess,
|
103 |
'message' => $message,
|
104 |
));
|
105 |
}
|
106 |
|
107 |
+
public function saveCdnSettingsAction(RscSgg_Http_Request $request) {
|
108 |
|
109 |
$message = $this->translate('Error occurred');
|
110 |
$isSuccess = false;
|
132 |
}
|
133 |
}
|
134 |
}
|
135 |
+
return $this->response(RscSgg_Http_Response::AJAX, array(
|
136 |
'success' => $isSuccess,
|
137 |
'message' => $message,
|
138 |
));
|
139 |
}
|
140 |
|
141 |
+
public function getPhotoListAction(RscSgg_Http_Request $request) {
|
142 |
$message = $this->translate('Error occurred');
|
143 |
$isSuccess = false;
|
144 |
|
214 |
}
|
215 |
}
|
216 |
|
217 |
+
return $this->response(RscSgg_Http_Response::AJAX, array(
|
218 |
'success' => $isSuccess,
|
219 |
'message' => $message,
|
220 |
'photos' => $photos,
|
222 |
));
|
223 |
}
|
224 |
|
225 |
+
public function getCdnPhotoListAction(RscSgg_Http_Request $request) {
|
226 |
$message = $this->translate('Error occurred');
|
227 |
$isSuccess = false;
|
228 |
|
241 |
}
|
242 |
}
|
243 |
|
244 |
+
return $this->response(RscSgg_Http_Response::AJAX, array(
|
245 |
'success' => $isSuccess,
|
246 |
'message' => $message,
|
247 |
'photos' => $photos,
|
303 |
return true;
|
304 |
}
|
305 |
|
306 |
+
public function optimizeOneImageAction(RscSgg_Http_Request $request) {
|
307 |
|
308 |
$message = $this->translate('Error occurred');
|
309 |
$isSuccess = false;
|
380 |
}
|
381 |
}
|
382 |
|
383 |
+
return $this->response(RscSgg_Http_Response::AJAX, array(
|
384 |
'success' => $isSuccess,
|
385 |
'message' => $message,
|
386 |
'serviceError' => $serviceError,
|
388 |
));
|
389 |
}
|
390 |
|
391 |
+
public function transferOneImageAction(RscSgg_Http_Request $request) {
|
392 |
$message = $this->translate('Error occurred');
|
393 |
$isSuccess = false;
|
394 |
$serviceError = false;
|
439 |
$message = $this->translate('Error! Incorrect params!');
|
440 |
}
|
441 |
|
442 |
+
return $this->response(RscSgg_Http_Response::AJAX, array(
|
443 |
'success' => $isSuccess,
|
444 |
'message' => $message,
|
445 |
'serviceError' => $serviceError,
|
446 |
));
|
447 |
}
|
448 |
|
449 |
+
public function saveOptimizeInfoToDbAction(RscSgg_Http_Request $request) {
|
450 |
$message = $this->translate('Error occurred');
|
451 |
$isSuccess = false;
|
452 |
$route = $request->post->get("route");
|
483 |
}
|
484 |
}
|
485 |
|
486 |
+
return $this->response(RscSgg_Http_Response::AJAX, array(
|
487 |
'success' => $isSuccess,
|
488 |
'message' => $message,
|
489 |
));
|
490 |
}
|
491 |
|
492 |
+
public function saveCdnInfoToDbAction(RscSgg_Http_Request $request) {
|
493 |
$route = $request->post->get("route");
|
494 |
$addedGall = array();
|
495 |
|
513 |
}
|
514 |
}
|
515 |
|
516 |
+
return $this->response(RscSgg_Http_Response::AJAX, array(
|
517 |
'galleries' => $addedGall,
|
518 |
));
|
519 |
}
|
520 |
|
521 |
+
public function rollbackRestoredImgAction(RscSgg_Http_Request $request) {
|
522 |
$message = $this->translate('Error occurred');
|
523 |
$isSuccess = false;
|
524 |
$data = isset($request->post['route']['data']) ? $request->post['route']['data'] : null;
|
534 |
$optimizeModel->restorePreviousFiles($galleryId, $resources, $photoModel, $currGallerySettings, $imgOptimize);
|
535 |
}
|
536 |
|
537 |
+
return $this->response(RscSgg_Http_Response::AJAX, array(
|
538 |
'success' => $isSuccess,
|
539 |
'message' => $message,
|
540 |
));
|
src/GridGallery/Optimization/Model/Cdn.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
class GridGallery_Optimization_Model_Cdn extends
|
3 |
|
4 |
protected $table;
|
5 |
|
1 |
<?php
|
2 |
+
class GridGallery_Optimization_Model_Cdn extends RscSgg_Mvc_Model {
|
3 |
|
4 |
protected $table;
|
5 |
|
src/GridGallery/Optimization/Model/ImageOptimize.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
class GridGallery_Optimization_Model_ImageOptimize extends
|
3 |
|
4 |
protected $table;
|
5 |
|
1 |
<?php
|
2 |
+
class GridGallery_Optimization_Model_ImageOptimize extends RscSgg_Mvc_Model {
|
3 |
|
4 |
protected $table;
|
5 |
|
src/GridGallery/Overview/Controller.php
CHANGED
@@ -14,9 +14,9 @@ class GridGallery_Overview_Controller extends GridGallery_Core_BaseController
|
|
14 |
);
|
15 |
}
|
16 |
/**
|
17 |
-
* @param
|
18 |
*/
|
19 |
-
public function indexAction(
|
20 |
{
|
21 |
$serverSettings = $this->getServerSettings();
|
22 |
$config = $this->getEnvironment()->getConfig();
|
@@ -37,9 +37,9 @@ class GridGallery_Overview_Controller extends GridGallery_Core_BaseController
|
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
-
* @param
|
41 |
*/
|
42 |
-
public function sendMailAction(
|
43 |
{
|
44 |
$mail = $request->post['route']['data'];
|
45 |
|
@@ -75,19 +75,22 @@ class GridGallery_Overview_Controller extends GridGallery_Core_BaseController
|
|
75 |
);
|
76 |
}
|
77 |
|
78 |
-
return $this->response(
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
-
* @param
|
83 |
*/
|
84 |
-
public function sendSubscribeMailAction(
|
85 |
{
|
|
|
|
|
86 |
$config = $this->getEnvironment()->getConfig();
|
87 |
$mail = $request->post['route']['data'];
|
88 |
$isPro = !empty($config->get('is_pro')) ? true : false;
|
89 |
$data = array(
|
90 |
'body' => array(
|
|
|
91 |
'user_name' => $mail['username'],
|
92 |
'user_email' => $mail['email'],
|
93 |
'site_url' => get_bloginfo('wpurl'),
|
@@ -97,7 +100,7 @@ class GridGallery_Overview_Controller extends GridGallery_Core_BaseController
|
|
97 |
),
|
98 |
);
|
99 |
$response = wp_remote_post(
|
100 |
-
$
|
101 |
$data
|
102 |
);
|
103 |
if (is_wp_error($response)) {
|
@@ -112,27 +115,27 @@ class GridGallery_Overview_Controller extends GridGallery_Core_BaseController
|
|
112 |
);
|
113 |
update_option('sgg_ac_subscribe', true);
|
114 |
}
|
115 |
-
return $this->response(
|
116 |
}
|
117 |
|
118 |
/**
|
119 |
-
* @param
|
120 |
*/
|
121 |
-
public function sendSubscribeRemindAction(
|
122 |
{
|
123 |
update_option('sgg_ac_remind', date("Y-m-d h:i:s", time() + 86400));
|
124 |
$response = array ('success' => true);
|
125 |
-
return $this->response(
|
126 |
}
|
127 |
|
128 |
/**
|
129 |
-
* @param
|
130 |
*/
|
131 |
-
public function sendSubscribeDisableAction(
|
132 |
{
|
133 |
update_option('sgg_ac_disabled', true);
|
134 |
$response = array ('success' => true);
|
135 |
-
return $this->response(
|
136 |
}
|
137 |
|
138 |
/**
|
14 |
);
|
15 |
}
|
16 |
/**
|
17 |
+
* @param RscSgg_Http_Request $request
|
18 |
*/
|
19 |
+
public function indexAction(RscSgg_Http_Request $request)
|
20 |
{
|
21 |
$serverSettings = $this->getServerSettings();
|
22 |
$config = $this->getEnvironment()->getConfig();
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
+
* @param RscSgg_Http_Request $request
|
41 |
*/
|
42 |
+
public function sendMailAction(RscSgg_Http_Request $request)
|
43 |
{
|
44 |
$mail = $request->post['route']['data'];
|
45 |
|
75 |
);
|
76 |
}
|
77 |
|
78 |
+
return $this->response(RscSgg_Http_Response::AJAX, $response);
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
+
* @param RscSgg_Http_Request $request
|
83 |
*/
|
84 |
+
public function sendSubscribeMailAction(RscSgg_Http_Request $request)
|
85 |
{
|
86 |
+
$apiUrl = 'https://supsystic.com/wp-admin/admin-ajax.php';
|
87 |
+
$reqUrl = $apiUrl . '?action=ac_get_plugin_installed';
|
88 |
$config = $this->getEnvironment()->getConfig();
|
89 |
$mail = $request->post['route']['data'];
|
90 |
$isPro = !empty($config->get('is_pro')) ? true : false;
|
91 |
$data = array(
|
92 |
'body' => array(
|
93 |
+
'key' => 'kJ#f3(FjkF9fasd124t5t589u9d4389r3r3R#2asdas3(#R03r#(r#t-4t5t589u9d4389r3r3R#$%lfdj',
|
94 |
'user_name' => $mail['username'],
|
95 |
'user_email' => $mail['email'],
|
96 |
'site_url' => get_bloginfo('wpurl'),
|
100 |
),
|
101 |
);
|
102 |
$response = wp_remote_post(
|
103 |
+
$reqUrl,
|
104 |
$data
|
105 |
);
|
106 |
if (is_wp_error($response)) {
|
115 |
);
|
116 |
update_option('sgg_ac_subscribe', true);
|
117 |
}
|
118 |
+
return $this->response(RscSgg_Http_Response::AJAX, $response);
|
119 |
}
|
120 |
|
121 |
/**
|
122 |
+
* @param RscSgg_Http_Request $request
|
123 |
*/
|
124 |
+
public function sendSubscribeRemindAction(RscSgg_Http_Request $request)
|
125 |
{
|
126 |
update_option('sgg_ac_remind', date("Y-m-d h:i:s", time() + 86400));
|
127 |
$response = array ('success' => true);
|
128 |
+
return $this->response(RscSgg_Http_Response::AJAX, $response);
|
129 |
}
|
130 |
|
131 |
/**
|
132 |
+
* @param RscSgg_Http_Request $request
|
133 |
*/
|
134 |
+
public function sendSubscribeDisableAction(RscSgg_Http_Request $request)
|
135 |
{
|
136 |
update_option('sgg_ac_disabled', true);
|
137 |
$response = array ('success' => true);
|
138 |
+
return $this->response(RscSgg_Http_Response::AJAX, $response);
|
139 |
}
|
140 |
|
141 |
/**
|
src/GridGallery/Overview/Module.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class GridGallery_Overview_Module extends
|
5 |
{
|
6 |
|
7 |
/**
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class GridGallery_Overview_Module extends RscSgg_Mvc_Module
|
5 |
{
|
6 |
|
7 |
/**
|
src/GridGallery/Photos/Controller.php
CHANGED
@@ -38,7 +38,7 @@ class GridGallery_Photos_Controller extends GridGallery_Core_BaseController
|
|
38 |
* Index Action
|
39 |
* Shows the list of the all photos
|
40 |
*/
|
41 |
-
public function indexAction(
|
42 |
{
|
43 |
$stats = $this->getEnvironment()->getModule('stats');
|
44 |
$stats->save('Images.tab');
|
@@ -75,10 +75,10 @@ class GridGallery_Photos_Controller extends GridGallery_Core_BaseController
|
|
75 |
* View Action
|
76 |
* Shows the photos in the selected album
|
77 |
*
|
78 |
-
* @param
|
79 |
-
* @return
|
80 |
*/
|
81 |
-
public function viewAction(
|
82 |
{
|
83 |
if (!$request->query->has('folder_id')) {
|
84 |
$this->redirect(
|
@@ -132,17 +132,17 @@ class GridGallery_Photos_Controller extends GridGallery_Core_BaseController
|
|
132 |
* Add Action
|
133 |
* Adds new photos to the database
|
134 |
*
|
135 |
-
* @param
|
136 |
-
* @return
|
137 |
*/
|
138 |
-
public function addAction(
|
139 |
{
|
140 |
$env = $this->getEnvironment();
|
141 |
|
142 |
$photos = $this->getModel('photos');
|
143 |
|
144 |
if ($env->getConfig()->isEnvironment(
|
145 |
-
|
146 |
)
|
147 |
) {
|
148 |
$photos->setDebugEnabled(true);
|
@@ -199,17 +199,17 @@ class GridGallery_Photos_Controller extends GridGallery_Core_BaseController
|
|
199 |
);
|
200 |
do_action('sgg_add_new_image_to_gallery', $imageParams);
|
201 |
|
202 |
-
return $this->response(
|
203 |
}
|
204 |
|
205 |
/**
|
206 |
* Add Folder Action
|
207 |
* Adds the new folder
|
208 |
*
|
209 |
-
* @param
|
210 |
-
* @return
|
211 |
*/
|
212 |
-
public function addFolderAction(
|
213 |
{
|
214 |
$env = $this->getEnvironment();
|
215 |
$folders = new GridGallery_Photos_Model_Folders();
|
@@ -218,7 +218,7 @@ class GridGallery_Photos_Controller extends GridGallery_Core_BaseController
|
|
218 |
$stats->save('folders.add');
|
219 |
|
220 |
if ($env->getConfig()->isEnvironment(
|
221 |
-
|
222 |
)
|
223 |
) {
|
224 |
$folders->setDebugEnabled(true);
|
@@ -255,15 +255,15 @@ class GridGallery_Photos_Controller extends GridGallery_Core_BaseController
|
|
255 |
* Delete Action
|
256 |
* Deletes the specified folders and photos
|
257 |
*
|
258 |
-
* @param
|
259 |
-
* @return
|
260 |
*/
|
261 |
-
public function deleteAction(
|
262 |
{
|
263 |
$env = $this->getEnvironment();
|
264 |
$data = $request->post->get('data');
|
265 |
$debug = $env->getConfig()->isEnvironment(
|
266 |
-
|
267 |
);
|
268 |
$photos = new GridGallery_Photos_Model_Photos($debug);
|
269 |
$folders = new GridGallery_Photos_Model_Folders($debug);
|
@@ -299,7 +299,7 @@ class GridGallery_Photos_Controller extends GridGallery_Core_BaseController
|
|
299 |
);
|
300 |
}
|
301 |
|
302 |
-
public function checkPhotoUsageAction(
|
303 |
{
|
304 |
$photoId = $request->post->get('photo_id');
|
305 |
|
@@ -314,12 +314,12 @@ class GridGallery_Photos_Controller extends GridGallery_Core_BaseController
|
|
314 |
$galleries = $resources->getGalleriesWithPhoto($photo->id);
|
315 |
}
|
316 |
|
317 |
-
return $this->response(
|
318 |
'count' => count($galleries),
|
319 |
));
|
320 |
}
|
321 |
|
322 |
-
public function rotatePhotoAction(
|
323 |
{
|
324 |
$env = $this->getEnvironment();
|
325 |
$ids = $request->post->get('ids');
|
@@ -337,23 +337,23 @@ class GridGallery_Photos_Controller extends GridGallery_Core_BaseController
|
|
337 |
}
|
338 |
}
|
339 |
$this->getModule('galleries')->cleanCache($request->post->get('gallery_id'));
|
340 |
-
return $this->response(
|
341 |
}
|
342 |
|
343 |
/**
|
344 |
* Move Action
|
345 |
* Moves photos to the folders
|
346 |
*
|
347 |
-
* @param
|
348 |
-
* @return
|
349 |
*/
|
350 |
-
public function moveAction(
|
351 |
{
|
352 |
$photos = new GridGallery_Photos_Model_Photos();
|
353 |
$error = true;
|
354 |
|
355 |
if ($this->getEnvironment()->getConfig()->isEnvironment(
|
356 |
-
|
357 |
)
|
358 |
) {
|
359 |
$photos->setDebugEnabled(true);
|
@@ -378,10 +378,10 @@ class GridGallery_Photos_Controller extends GridGallery_Core_BaseController
|
|
378 |
* Render Action
|
379 |
* Renders the photos from the folder
|
380 |
*
|
381 |
-
* @param
|
382 |
-
* @return
|
383 |
*/
|
384 |
-
public function renderAction(
|
385 |
{
|
386 |
$photos = $request->post->get('photos');
|
387 |
|
@@ -416,10 +416,10 @@ class GridGallery_Photos_Controller extends GridGallery_Core_BaseController
|
|
416 |
* Update Title Action
|
417 |
* Updates the title of the folder
|
418 |
*
|
419 |
-
* @param
|
420 |
-
* @return
|
421 |
*/
|
422 |
-
public function updateTitleAction(
|
423 |
{
|
424 |
$env = $this->getEnvironment();
|
425 |
$folders = new GridGallery_Photos_Model_Folders();
|
@@ -471,7 +471,7 @@ class GridGallery_Photos_Controller extends GridGallery_Core_BaseController
|
|
471 |
}
|
472 |
|
473 |
return $this->response(
|
474 |
-
|
475 |
array(
|
476 |
'isEmpty' => $isEmpty,
|
477 |
)
|
@@ -482,10 +482,10 @@ class GridGallery_Photos_Controller extends GridGallery_Core_BaseController
|
|
482 |
* Before update attachemnt
|
483 |
* if attachment was updated then replace it and after save all information
|
484 |
* to new attachment
|
485 |
-
* @param
|
486 |
*/
|
487 |
// old pro version compatibility - remove this method in future
|
488 |
-
protected function beforeUpdateAttachment(
|
489 |
/** @var GridGallery_Photos_Model_Photos $photos */
|
490 |
$photos = $this->getModel('photos');
|
491 |
|
@@ -502,7 +502,7 @@ class GridGallery_Photos_Controller extends GridGallery_Core_BaseController
|
|
502 |
}
|
503 |
}
|
504 |
|
505 |
-
public function updateAttachmentAction(
|
506 |
|
507 |
/** @var GridGallery_Photos_Model_Photos $photos */
|
508 |
$photos = $this->getModel('photos');
|
@@ -548,15 +548,15 @@ class GridGallery_Photos_Controller extends GridGallery_Core_BaseController
|
|
548 |
|
549 |
$this->getModule('galleries')->cleanCache($request->post->get('gallery_id'));
|
550 |
|
551 |
-
return $this->response(
|
552 |
}
|
553 |
|
554 |
/**
|
555 |
* Updates the position of the photo.
|
556 |
-
* @param
|
557 |
-
* @return
|
558 |
*/
|
559 |
-
public function updatePositionAction(
|
560 |
{
|
561 |
$response = $this->getErrorResponseData(
|
562 |
$this->translate('Failed to update position.')
|
@@ -570,6 +570,6 @@ class GridGallery_Photos_Controller extends GridGallery_Core_BaseController
|
|
570 |
}
|
571 |
$this->getModule('galleries')->cleanCache($data['scope_id']);
|
572 |
|
573 |
-
return $this->response(
|
574 |
}
|
575 |
}
|
38 |
* Index Action
|
39 |
* Shows the list of the all photos
|
40 |
*/
|
41 |
+
public function indexAction(RscSgg_Http_Request $request)
|
42 |
{
|
43 |
$stats = $this->getEnvironment()->getModule('stats');
|
44 |
$stats->save('Images.tab');
|
75 |
* View Action
|
76 |
* Shows the photos in the selected album
|
77 |
*
|
78 |
+
* @param RscSgg_Http_Request $request
|
79 |
+
* @return RscSgg_Http_Response
|
80 |
*/
|
81 |
+
public function viewAction(RscSgg_Http_Request $request)
|
82 |
{
|
83 |
if (!$request->query->has('folder_id')) {
|
84 |
$this->redirect(
|
132 |
* Add Action
|
133 |
* Adds new photos to the database
|
134 |
*
|
135 |
+
* @param RscSgg_Http_Request $request
|
136 |
+
* @return RscSgg_Http_Response
|
137 |
*/
|
138 |
+
public function addAction(RscSgg_Http_Request $request)
|
139 |
{
|
140 |
$env = $this->getEnvironment();
|
141 |
|
142 |
$photos = $this->getModel('photos');
|
143 |
|
144 |
if ($env->getConfig()->isEnvironment(
|
145 |
+
RscSgg_Environment::ENV_DEVELOPMENT
|
146 |
)
|
147 |
) {
|
148 |
$photos->setDebugEnabled(true);
|
199 |
);
|
200 |
do_action('sgg_add_new_image_to_gallery', $imageParams);
|
201 |
|
202 |
+
return $this->response(RscSgg_Http_Response::AJAX, $response);
|
203 |
}
|
204 |
|
205 |
/**
|
206 |
* Add Folder Action
|
207 |
* Adds the new folder
|
208 |
*
|
209 |
+
* @param RscSgg_Http_Request $request
|
210 |
+
* @return RscSgg_Http_Response
|
211 |
*/
|
212 |
+
public function addFolderAction(RscSgg_Http_Request $request)
|
213 |
{
|
214 |
$env = $this->getEnvironment();
|
215 |
$folders = new GridGallery_Photos_Model_Folders();
|
218 |
$stats->save('folders.add');
|
219 |
|
220 |
if ($env->getConfig()->isEnvironment(
|
221 |
+
RscSgg_Environment::ENV_DEVELOPMENT
|
222 |
)
|
223 |
) {
|
224 |
$folders->setDebugEnabled(true);
|
255 |
* Delete Action
|
256 |
* Deletes the specified folders and photos
|
257 |
*
|
258 |
+
* @param RscSgg_Http_Request $request
|
259 |
+
* @return RscSgg_Http_Response
|
260 |
*/
|
261 |
+
public function deleteAction(RscSgg_Http_Request $request)
|
262 |
{
|
263 |
$env = $this->getEnvironment();
|
264 |
$data = $request->post->get('data');
|
265 |
$debug = $env->getConfig()->isEnvironment(
|
266 |
+
RscSgg_Environment::ENV_DEVELOPMENT
|
267 |
);
|
268 |
$photos = new GridGallery_Photos_Model_Photos($debug);
|
269 |
$folders = new GridGallery_Photos_Model_Folders($debug);
|
299 |
);
|
300 |
}
|
301 |
|
302 |
+
public function checkPhotoUsageAction(RscSgg_Http_Request $request)
|
303 |
{
|
304 |
$photoId = $request->post->get('photo_id');
|
305 |
|
314 |
$galleries = $resources->getGalleriesWithPhoto($photo->id);
|
315 |
}
|
316 |
|
317 |
+
return $this->response(RscSgg_Http_Response::AJAX, array(
|
318 |
'count' => count($galleries),
|
319 |
));
|
320 |
}
|
321 |
|
322 |
+
public function rotatePhotoAction(RscSgg_Http_Request $request)
|
323 |
{
|
324 |
$env = $this->getEnvironment();
|
325 |
$ids = $request->post->get('ids');
|
337 |
}
|
338 |
}
|
339 |
$this->getModule('galleries')->cleanCache($request->post->get('gallery_id'));
|
340 |
+
return $this->response(RscSgg_Http_Response::AJAX, array('message' => sprintf($env->translate('There are %d photos successfully rotated'), $rotated)));
|
341 |
}
|
342 |
|
343 |
/**
|
344 |
* Move Action
|
345 |
* Moves photos to the folders
|
346 |
*
|
347 |
+
* @param RscSgg_Http_Request $request
|
348 |
+
* @return RscSgg_Http_Response
|
349 |
*/
|
350 |
+
public function moveAction(RscSgg_Http_Request $request)
|
351 |
{
|
352 |
$photos = new GridGallery_Photos_Model_Photos();
|
353 |
$error = true;
|
354 |
|
355 |
if ($this->getEnvironment()->getConfig()->isEnvironment(
|
356 |
+
RscSgg_Environment::ENV_DEVELOPMENT
|
357 |
)
|
358 |
) {
|
359 |
$photos->setDebugEnabled(true);
|
378 |
* Render Action
|
379 |
* Renders the photos from the folder
|
380 |
*
|
381 |
+
* @param RscSgg_Http_Request $request
|
382 |
+
* @return RscSgg_Http_Response
|
383 |
*/
|
384 |
+
public function renderAction(RscSgg_Http_Request $request)
|
385 |
{
|
386 |
$photos = $request->post->get('photos');
|
387 |
|
416 |
* Update Title Action
|
417 |
* Updates the title of the folder
|
418 |
*
|
419 |
+
* @param RscSgg_Http_Request $request
|
420 |
+
* @return RscSgg_Http_Response
|
421 |
*/
|
422 |
+
public function updateTitleAction(RscSgg_Http_Request $request)
|
423 |
{
|
424 |
$env = $this->getEnvironment();
|
425 |
$folders = new GridGallery_Photos_Model_Folders();
|
471 |
}
|
472 |
|
473 |
return $this->response(
|
474 |
+
RscSgg_Http_Response::AJAX,
|
475 |
array(
|
476 |
'isEmpty' => $isEmpty,
|
477 |
)
|
482 |
* Before update attachemnt
|
483 |
* if attachment was updated then replace it and after save all information
|
484 |
* to new attachment
|
485 |
+
* @param RscSgg_Http_Request $request
|
486 |
*/
|
487 |
// old pro version compatibility - remove this method in future
|
488 |
+
protected function beforeUpdateAttachment(RscSgg_Http_Request $request){
|
489 |
/** @var GridGallery_Photos_Model_Photos $photos */
|
490 |
$photos = $this->getModel('photos');
|
491 |
|
502 |
}
|
503 |
}
|
504 |
|
505 |
+
public function updateAttachmentAction(RscSgg_Http_Request $request) {
|
506 |
|
507 |
/** @var GridGallery_Photos_Model_Photos $photos */
|
508 |
$photos = $this->getModel('photos');
|
548 |
|
549 |
$this->getModule('galleries')->cleanCache($request->post->get('gallery_id'));
|
550 |
|
551 |
+
return $this->response(RscSgg_Http_Response::AJAX);
|
552 |
}
|
553 |
|
554 |
/**
|
555 |
* Updates the position of the photo.
|
556 |
+
* @param RscSgg_Http_Request $request
|
557 |
+
* @return RscSgg_Http_Response
|
558 |
*/
|
559 |
+
public function updatePositionAction(RscSgg_Http_Request $request)
|
560 |
{
|
561 |
$response = $this->getErrorResponseData(
|
562 |
$this->translate('Failed to update position.')
|
570 |
}
|
571 |
$this->getModule('galleries')->cleanCache($data['scope_id']);
|
572 |
|
573 |
+
return $this->response(RscSgg_Http_Response::AJAX, $response);
|
574 |
}
|
575 |
}
|
src/GridGallery/Photos/Model/Folders.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* @package GridGallery\Photos\Model
|
8 |
* @author Artur Kovalevsky
|
9 |
*/
|
10 |
-
class GridGallery_Photos_Model_Folders extends
|
11 |
{
|
12 |
/**
|
13 |
* @var string
|
7 |
* @package GridGallery\Photos\Model
|
8 |
* @author Artur Kovalevsky
|
9 |
*/
|
10 |
+
class GridGallery_Photos_Model_Folders extends RscSgg_Mvc_Model
|
11 |
{
|
12 |
/**
|
13 |
* @var string
|
src/GridGallery/Photos/Model/Photos.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* @package GridGallery\Photos\Model
|
7 |
* @author Artur Kovalevsky
|
8 |
*/
|
9 |
-
class GridGallery_Photos_Model_Photos extends
|
10 |
{
|
11 |
|
12 |
/**
|
@@ -556,7 +556,7 @@ class GridGallery_Photos_Model_Photos extends Rsc_Mvc_Model
|
|
556 |
$usedTimes = $this->getUsedTimes($photo);
|
557 |
$photo->is_used = (($usedTimes > 0) ? true : false);
|
558 |
$photo->used_times = $usedTimes;
|
559 |
-
$photo->gg_wp_upload_date = date($this->ggWpDateFormat, strtotime($photo->timestamp));
|
560 |
}
|
561 |
|
562 |
$photo->attachment = wp_prepare_attachment_for_js($photo->attachment_id);
|
6 |
* @package GridGallery\Photos\Model
|
7 |
* @author Artur Kovalevsky
|
8 |
*/
|
9 |
+
class GridGallery_Photos_Model_Photos extends RscSgg_Mvc_Model
|
10 |
{
|
11 |
|
12 |
/**
|
556 |
$usedTimes = $this->getUsedTimes($photo);
|
557 |
$photo->is_used = (($usedTimes > 0) ? true : false);
|
558 |
$photo->used_times = $usedTimes;
|
559 |
+
$photo->gg_wp_upload_date = date((string)$this->ggWpDateFormat, strtotime($photo->timestamp));
|
560 |
}
|
561 |
|
562 |
$photo->attachment = wp_prepare_attachment_for_js($photo->attachment_id);
|
src/GridGallery/Photos/Model/Settings.php
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
* @package GridGallery\Photos\Model
|
9 |
* @author Artur Kovalevsky
|
10 |
*/
|
11 |
-
class GridGallery_Photos_Model_Settings extends
|
12 |
{
|
13 |
|
14 |
/**
|
8 |
* @package GridGallery\Photos\Model
|
9 |
* @author Artur Kovalevsky
|
10 |
*/
|
11 |
+
class GridGallery_Photos_Model_Settings extends RscSgg_Mvc_Model
|
12 |
{
|
13 |
|
14 |
/**
|
src/GridGallery/Photos/Module.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* @package GridGallery\Photos
|
8 |
* @author Artur Kovalevsky
|
9 |
*/
|
10 |
-
class GridGallery_Photos_Module extends
|
11 |
{
|
12 |
|
13 |
/**
|
@@ -25,7 +25,7 @@ class GridGallery_Photos_Module extends Rsc_Mvc_Module
|
|
25 |
|
26 |
add_action('delete_attachment', array(
|
27 |
new GridGallery_Photos_Model_Photos(
|
28 |
-
$config->isEnvironment(
|
29 |
), 'deleteByAttachmentId'
|
30 |
));
|
31 |
|
@@ -33,7 +33,7 @@ class GridGallery_Photos_Module extends Rsc_Mvc_Module
|
|
33 |
'grid_gallery_delete_folder',
|
34 |
array(
|
35 |
new GridGallery_Photos_Model_Photos($config->isEnvironment(
|
36 |
-
|
37 |
)),
|
38 |
'deleteByFolderId'
|
39 |
)
|
7 |
* @package GridGallery\Photos
|
8 |
* @author Artur Kovalevsky
|
9 |
*/
|
10 |
+
class GridGallery_Photos_Module extends RscSgg_Mvc_Module
|
11 |
{
|
12 |
|
13 |
/**
|
25 |
|
26 |
add_action('delete_attachment', array(
|
27 |
new GridGallery_Photos_Model_Photos(
|
28 |
+
$config->isEnvironment(RscSgg_Environment::ENV_DEVELOPMENT)
|
29 |
), 'deleteByAttachmentId'
|
30 |
));
|
31 |
|
33 |
'grid_gallery_delete_folder',
|
34 |
array(
|
35 |
new GridGallery_Photos_Model_Photos($config->isEnvironment(
|
36 |
+
RscSgg_Environment::ENV_DEVELOPMENT
|
37 |
)),
|
38 |
'deleteByFolderId'
|
39 |
)
|
src/GridGallery/Promo/Controller.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*/
|
5 |
class GridGallery_Promo_Controller extends GridGallery_Core_BaseController
|
6 |
{
|
7 |
-
public function welcomeAction(
|
8 |
{
|
9 |
$model = $this->getModel('promo');
|
10 |
$model->bigStatAdd('Welcome Show');
|
@@ -24,12 +24,12 @@ class GridGallery_Promo_Controller extends GridGallery_Core_BaseController
|
|
24 |
update_user_meta(get_current_user_id(), 'sgg-tutorial_was_showed', false);
|
25 |
return $this->redirect($this->generateUrl('overview'));
|
26 |
}
|
27 |
-
public function saveDeactivateDataAction(
|
28 |
$lang = $this->getEnvironment()->getLang();
|
29 |
$model = $this->getModel('promo');
|
30 |
$model->saveDeactivateData($request->post);
|
31 |
return $this->response(
|
32 |
-
|
33 |
$this->getSuccessResponseData(
|
34 |
$lang->translate('Hope you will come back!')
|
35 |
)
|
4 |
*/
|
5 |
class GridGallery_Promo_Controller extends GridGallery_Core_BaseController
|
6 |
{
|
7 |
+
public function welcomeAction(RscSgg_Http_Request $request)
|
8 |
{
|
9 |
$model = $this->getModel('promo');
|
10 |
$model->bigStatAdd('Welcome Show');
|
24 |
update_user_meta(get_current_user_id(), 'sgg-tutorial_was_showed', false);
|
25 |
return $this->redirect($this->generateUrl('overview'));
|
26 |
}
|
27 |
+
public function saveDeactivateDataAction(RscSgg_Http_Request $request) {
|
28 |
$lang = $this->getEnvironment()->getLang();
|
29 |
$model = $this->getModel('promo');
|
30 |
$model->saveDeactivateData($request->post);
|
31 |
return $this->response(
|
32 |
+
RscSgg_Http_Response::AJAX,
|
33 |
$this->getSuccessResponseData(
|
34 |
$lang->translate('Hope you will come back!')
|
35 |
)
|
src/GridGallery/Promo/Model/Promo.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
class GridGallery_Promo_Model_Promo extends
|
3 |
private $_bigCli = null;
|
4 |
public function saveDeactivateData( $d ) {
|
5 |
$deactivateParams = array();
|
1 |
<?php
|
2 |
+
class GridGallery_Promo_Model_Promo extends RscSgg_Mvc_Model {
|
3 |
private $_bigCli = null;
|
4 |
public function saveDeactivateData( $d ) {
|
5 |
$deactivateParams = array();
|
src/GridGallery/Settings/Controller.php
CHANGED
@@ -24,10 +24,10 @@ class GridGallery_Settings_Controller extends GridGallery_Core_BaseController
|
|
24 |
* Index Action
|
25 |
* Shows the settings page
|
26 |
*
|
27 |
-
* @param
|
28 |
-
* @return
|
29 |
*/
|
30 |
-
public function indexAction(
|
31 |
{
|
32 |
$module = $this->getModule('settings');
|
33 |
$module->loadAssets();
|
@@ -49,7 +49,7 @@ class GridGallery_Settings_Controller extends GridGallery_Core_BaseController
|
|
49 |
);
|
50 |
}
|
51 |
|
52 |
-
public function saveSettingsAction(
|
53 |
$optionsName = $this->getConfig()->get('db_prefix') . 'settings';
|
54 |
$currentSettings = get_option($optionsName);
|
55 |
$settings = $request->post->get('settings', array());
|
24 |
* Index Action
|
25 |
* Shows the settings page
|
26 |
*
|
27 |
+
* @param RscSgg_Http_Request $request
|
28 |
+
* @return RscSgg_Http_Response
|
29 |
*/
|
30 |
+
public function indexAction(RscSgg_Http_Request $request)
|
31 |
{
|
32 |
$module = $this->getModule('settings');
|
33 |
$module->loadAssets();
|
49 |
);
|
50 |
}
|
51 |
|
52 |
+
public function saveSettingsAction(RscSgg_Http_Request $request) {
|
53 |
$optionsName = $this->getConfig()->get('db_prefix') . 'settings';
|
54 |
$currentSettings = get_option($optionsName);
|
55 |
$settings = $request->post->get('settings', array());
|
src/GridGallery/Settings/Model/Settings.php
CHANGED
@@ -26,7 +26,7 @@ class GridGallery_Settings_Model_Settings extends GridGallery_Core_BaseModel
|
|
26 |
return $this;
|
27 |
}
|
28 |
|
29 |
-
public function save(
|
30 |
{
|
31 |
foreach ($request->post as $field => $value) {
|
32 |
$this->registry->set($field, $value);
|
26 |
return $this;
|
27 |
}
|
28 |
|
29 |
+
public function save(RscSgg_Http_Request $request)
|
30 |
{
|
31 |
foreach ($request->post as $field => $value) {
|
32 |
$this->registry->set($field, $value);
|
src/GridGallery/Settings/Module.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* @package GridGallery\Settings
|
8 |
* @author Artur Kovalevsky
|
9 |
*/
|
10 |
-
class GridGallery_Settings_Module extends
|
11 |
{
|
12 |
|
13 |
/**
|
7 |
* @package GridGallery\Settings
|
8 |
* @author Artur Kovalevsky
|
9 |
*/
|
10 |
+
class GridGallery_Settings_Module extends RscSgg_Mvc_Module
|
11 |
{
|
12 |
|
13 |
/**
|
src/GridGallery/Stats/Module.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class GridGallery_Stats_Module extends
|
4 |
{
|
5 |
|
6 |
/**
|
1 |
<?php
|
2 |
|
3 |
+
class GridGallery_Stats_Module extends RscSgg_Mvc_Module
|
4 |
{
|
5 |
|
6 |
/**
|
src/GridGallery/Ui/Module.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* @package GridGallery\Ui
|
8 |
* @author Artur Kovalevsky
|
9 |
*/
|
10 |
-
class GridGallery_Ui_Module extends
|
11 |
{
|
12 |
/**
|
13 |
* @var array
|
7 |
* @package GridGallery\Ui
|
8 |
* @author Artur Kovalevsky
|
9 |
*/
|
10 |
+
class GridGallery_Ui_Module extends RscSgg_Mvc_Module
|
11 |
{
|
12 |
/**
|
13 |
* @var array
|
vendor/Rsc/Autoloader.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
-
* Register
|
9 |
*/
|
10 |
public static function register()
|
11 |
{
|
@@ -18,13 +18,14 @@ class Rsc_Autoloader
|
|
18 |
*/
|
19 |
public static function load($classname)
|
20 |
{
|
21 |
-
if (substr($classname, 0,
|
22 |
return;
|
23 |
}
|
24 |
-
|
25 |
-
|
|
|
26 |
require $file;
|
27 |
}
|
28 |
}
|
29 |
|
30 |
-
}
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Autoloader
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
+
* Register RscSgg_Autoloader in the SPL autoloader stack
|
9 |
*/
|
10 |
public static function register()
|
11 |
{
|
18 |
*/
|
19 |
public static function load($classname)
|
20 |
{
|
21 |
+
if (substr($classname, 0, 6) !== 'RscSgg') {
|
22 |
return;
|
23 |
}
|
24 |
+
$classname = str_replace('RscSgg', '', $classname);
|
25 |
+
$file = dirname(__FILE__) . '/' . str_replace(array('_', '\0'), array('/', ''), $classname) . '.php';
|
26 |
+
if (is_file($file)) {
|
27 |
require $file;
|
28 |
}
|
29 |
}
|
30 |
|
31 |
+
}
|
vendor/Rsc/Cache.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
-
* @var
|
9 |
*/
|
10 |
protected $adapter;
|
11 |
|
@@ -21,9 +21,9 @@ class Rsc_Cache
|
|
21 |
|
22 |
/**
|
23 |
* Constructor
|
24 |
-
* @param
|
25 |
*/
|
26 |
-
public function __construct(
|
27 |
{
|
28 |
$this->adapter = $adapter;
|
29 |
}
|
@@ -71,7 +71,7 @@ class Rsc_Cache
|
|
71 |
/**
|
72 |
* Sets the prefix for keys
|
73 |
* @param string $prefix
|
74 |
-
* @return
|
75 |
*/
|
76 |
public function setPrefix($prefix)
|
77 |
{
|
@@ -91,7 +91,7 @@ class Rsc_Cache
|
|
91 |
/**
|
92 |
* Sets the time to life for cached data
|
93 |
* @param int $ttl
|
94 |
-
* @return
|
95 |
*/
|
96 |
public function setTtl($ttl)
|
97 |
{
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Cache
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
+
* @var RscSgg_Cache_Interface
|
9 |
*/
|
10 |
protected $adapter;
|
11 |
|
21 |
|
22 |
/**
|
23 |
* Constructor
|
24 |
+
* @param RscSgg_Cache_Interface $adapter The caching adapter
|
25 |
*/
|
26 |
+
public function __construct(RscSgg_Cache_Interface $adapter)
|
27 |
{
|
28 |
$this->adapter = $adapter;
|
29 |
}
|
71 |
/**
|
72 |
* Sets the prefix for keys
|
73 |
* @param string $prefix
|
74 |
+
* @return RscSgg_Cache
|
75 |
*/
|
76 |
public function setPrefix($prefix)
|
77 |
{
|
91 |
/**
|
92 |
* Sets the time to life for cached data
|
93 |
* @param int $ttl
|
94 |
+
* @return RscSgg_Cache
|
95 |
*/
|
96 |
public function setTtl($ttl)
|
97 |
{
|
vendor/Rsc/Cache/Dummy.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Cache_Dummy implements RscSgg_Cache_Interface
|
5 |
{
|
6 |
|
7 |
/**
|
vendor/Rsc/Cache/Filesystem.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Cache_Filesystem implements RscSgg_Cache_Interface
|
5 |
{
|
6 |
|
7 |
/**
|
vendor/Rsc/Cache/Interface.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
interface
|
5 |
{
|
6 |
/**
|
7 |
* Caches data
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
interface RscSgg_Cache_Interface
|
5 |
{
|
6 |
/**
|
7 |
* Caches data
|
vendor/Rsc/ClassLoader.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
@@ -22,7 +22,7 @@ class Rsc_ClassLoader
|
|
22 |
* Add vendor prefix to the autoload stack
|
23 |
* @param string $prefix Vendor prefix
|
24 |
* @param string|array $path Classes path
|
25 |
-
* @return
|
26 |
*/
|
27 |
public function add($prefix, $path)
|
28 |
{
|
@@ -38,7 +38,7 @@ class Rsc_ClassLoader
|
|
38 |
/**
|
39 |
* Remove prefixes from the autoload stack
|
40 |
* @param string|array $prefix Vendor prefixes to remove
|
41 |
-
* @return
|
42 |
*/
|
43 |
public function remove($prefix)
|
44 |
{
|
@@ -56,7 +56,7 @@ class Rsc_ClassLoader
|
|
56 |
/**
|
57 |
* Add an array of prefixes to the autoload stack
|
58 |
* @param array $prefixes An array of prefixes
|
59 |
-
* @return
|
60 |
*/
|
61 |
public function addPrefixes(array $prefixes)
|
62 |
{
|
@@ -70,7 +70,7 @@ class Rsc_ClassLoader
|
|
70 |
/**
|
71 |
* Set an array of the vendor prefixes
|
72 |
* @param array $prefixes An array of prefixes
|
73 |
-
* @return
|
74 |
*/
|
75 |
public function setPrefixes(array $prefixes)
|
76 |
{
|
@@ -135,7 +135,7 @@ class Rsc_ClassLoader
|
|
135 |
}
|
136 |
|
137 |
if (stripos($class,'Twig_') !== false) {
|
138 |
-
$className = str_replace('
|
139 |
$classDelimeters = explode('_', $className);
|
140 |
|
141 |
$newName = '';
|
@@ -143,10 +143,10 @@ class Rsc_ClassLoader
|
|
143 |
$newName .= DIRECTORY_SEPARATOR . $classDelimeters[$i];
|
144 |
}
|
145 |
$path .= 'Twig' . $newName . '.php';
|
146 |
-
if ($class == '
|
147 |
$path = DIRECTORY_SEPARATOR.'SupsysticSlider'.DIRECTORY_SEPARATOR.'Slider'.DIRECTORY_SEPARATOR.'Twig'.DIRECTORY_SEPARATOR.'Attachment.php';
|
148 |
}
|
149 |
-
if ($class == '
|
150 |
$path = DIRECTORY_SEPARATOR.'SupsysticSliderPro'.DIRECTORY_SEPARATOR.'Slider'.DIRECTORY_SEPARATOR.'Twig'.DIRECTORY_SEPARATOR.'Video.php';
|
151 |
}
|
152 |
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_ClassLoader
|
5 |
{
|
6 |
|
7 |
/**
|
22 |
* Add vendor prefix to the autoload stack
|
23 |
* @param string $prefix Vendor prefix
|
24 |
* @param string|array $path Classes path
|
25 |
+
* @return RscSgg_ClassLoader
|
26 |
*/
|
27 |
public function add($prefix, $path)
|
28 |
{
|
38 |
/**
|
39 |
* Remove prefixes from the autoload stack
|
40 |
* @param string|array $prefix Vendor prefixes to remove
|
41 |
+
* @return RscSgg_ClassLoader
|
42 |
*/
|
43 |
public function remove($prefix)
|
44 |
{
|
56 |
/**
|
57 |
* Add an array of prefixes to the autoload stack
|
58 |
* @param array $prefixes An array of prefixes
|
59 |
+
* @return RscSgg_ClassLoader
|
60 |
*/
|
61 |
public function addPrefixes(array $prefixes)
|
62 |
{
|
70 |
/**
|
71 |
* Set an array of the vendor prefixes
|
72 |
* @param array $prefixes An array of prefixes
|
73 |
+
* @return RscSgg_ClassLoader
|
74 |
*/
|
75 |
public function setPrefixes(array $prefixes)
|
76 |
{
|
135 |
}
|
136 |
|
137 |
if (stripos($class,'Twig_') !== false) {
|
138 |
+
$className = str_replace('Twig_SupTwgSgg_', '', $name);
|
139 |
$classDelimeters = explode('_', $className);
|
140 |
|
141 |
$newName = '';
|
143 |
$newName .= DIRECTORY_SEPARATOR . $classDelimeters[$i];
|
144 |
}
|
145 |
$path .= 'Twig' . $newName . '.php';
|
146 |
+
if ($class == 'SupsysticSlider_Slider_Twig_SupTwgSgg_Attachment') {
|
147 |
$path = DIRECTORY_SEPARATOR.'SupsysticSlider'.DIRECTORY_SEPARATOR.'Slider'.DIRECTORY_SEPARATOR.'Twig'.DIRECTORY_SEPARATOR.'Attachment.php';
|
148 |
}
|
149 |
+
if ($class == 'SupsysticSliderPro_Slider_Twig_SupTwgSgg_Video') {
|
150 |
$path = DIRECTORY_SEPARATOR.'SupsysticSliderPro'.DIRECTORY_SEPARATOR.'Slider'.DIRECTORY_SEPARATOR.'Twig'.DIRECTORY_SEPARATOR.'Video.php';
|
151 |
}
|
152 |
|
vendor/Rsc/Common/Collection.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/** @var array */
|
@@ -16,6 +16,9 @@ class Rsc_Common_Collection implements Countable, IteratorAggregate, Serializabl
|
|
16 |
$this->collection = $collection;
|
17 |
}
|
18 |
|
|
|
|
|
|
|
19 |
/**
|
20 |
* Return data for the key
|
21 |
* @param string $key
|
@@ -105,7 +108,7 @@ class Rsc_Common_Collection implements Countable, IteratorAggregate, Serializabl
|
|
105 |
* Adds a new item to the collection
|
106 |
* @param string $key Key to add
|
107 |
* @param mixed $value Value of the element
|
108 |
-
* @return
|
109 |
*/
|
110 |
public function add($key, $value)
|
111 |
{
|
@@ -120,7 +123,7 @@ class Rsc_Common_Collection implements Countable, IteratorAggregate, Serializabl
|
|
120 |
* Change the value of an existing key
|
121 |
* @param string $key The key to be edited
|
122 |
* @param mixed $value The new value
|
123 |
-
* @return
|
124 |
*/
|
125 |
public function set($key, $value)
|
126 |
{
|
@@ -168,7 +171,7 @@ class Rsc_Common_Collection implements Countable, IteratorAggregate, Serializabl
|
|
168 |
/**
|
169 |
* Change the current collection to the specified
|
170 |
* @param array $collection Array elements of the new collection
|
171 |
-
* @return
|
172 |
*/
|
173 |
public function replace(array $collection)
|
174 |
{
|
@@ -180,7 +183,7 @@ class Rsc_Common_Collection implements Countable, IteratorAggregate, Serializabl
|
|
180 |
/**
|
181 |
* Merge the specified array with the current collection
|
182 |
* @param array $collection Array elements
|
183 |
-
* @return
|
184 |
*/
|
185 |
public function merge(array $collection)
|
186 |
{
|
@@ -192,7 +195,7 @@ class Rsc_Common_Collection implements Countable, IteratorAggregate, Serializabl
|
|
192 |
/**
|
193 |
* Applies the callback to the elements of the collection
|
194 |
* @param callable $callback Callback function to run for each element in the collection
|
195 |
-
* @return
|
196 |
*/
|
197 |
public function map(Callable $callback)
|
198 |
{
|
@@ -235,6 +238,7 @@ class Rsc_Common_Collection implements Countable, IteratorAggregate, Serializabl
|
|
235 |
* @return Traversable An instance of an object implementing <b>Iterator</b> or
|
236 |
* <b>Traversable</b>
|
237 |
*/
|
|
|
238 |
public function getIterator()
|
239 |
{
|
240 |
return new ArrayIterator($this->collection);
|
@@ -274,6 +278,7 @@ class Rsc_Common_Collection implements Countable, IteratorAggregate, Serializabl
|
|
274 |
* <p>
|
275 |
* The return value is cast to an integer.
|
276 |
*/
|
|
|
277 |
public function count()
|
278 |
{
|
279 |
return count($this->collection);
|
@@ -291,6 +296,7 @@ class Rsc_Common_Collection implements Countable, IteratorAggregate, Serializabl
|
|
291 |
* <p>
|
292 |
* The return value will be casted to boolean if non-boolean was returned.
|
293 |
*/
|
|
|
294 |
public function offsetExists($offset)
|
295 |
{
|
296 |
return $this->has($offset);
|
@@ -305,6 +311,7 @@ class Rsc_Common_Collection implements Countable, IteratorAggregate, Serializabl
|
|
305 |
* </p>
|
306 |
* @return mixed Can return all value types.
|
307 |
*/
|
|
|
308 |
public function offsetGet($offset)
|
309 |
{
|
310 |
return $this->get($offset, null);
|
@@ -322,6 +329,7 @@ class Rsc_Common_Collection implements Countable, IteratorAggregate, Serializabl
|
|
322 |
* </p>
|
323 |
* @return void
|
324 |
*/
|
|
|
325 |
public function offsetSet($offset, $value)
|
326 |
{
|
327 |
if (is_null($offset)) {
|
@@ -340,8 +348,9 @@ class Rsc_Common_Collection implements Countable, IteratorAggregate, Serializabl
|
|
340 |
* </p>
|
341 |
* @return void
|
342 |
*/
|
|
|
343 |
public function offsetUnset($offset)
|
344 |
{
|
345 |
$this->delete($offset);
|
346 |
}
|
347 |
-
}
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Common_Collection implements Countable, IteratorAggregate, Serializable, ArrayAccess
|
5 |
{
|
6 |
|
7 |
/** @var array */
|
16 |
$this->collection = $collection;
|
17 |
}
|
18 |
|
19 |
+
public function __serialize(): array {}
|
20 |
+
public function __unserialize(array $data): void {}
|
21 |
+
|
22 |
/**
|
23 |
* Return data for the key
|
24 |
* @param string $key
|
108 |
* Adds a new item to the collection
|
109 |
* @param string $key Key to add
|
110 |
* @param mixed $value Value of the element
|
111 |
+
* @return RscSgg_Common_Collection
|
112 |
*/
|
113 |
public function add($key, $value)
|
114 |
{
|
123 |
* Change the value of an existing key
|
124 |
* @param string $key The key to be edited
|
125 |
* @param mixed $value The new value
|
126 |
+
* @return RscSgg_Common_Collection
|
127 |
*/
|
128 |
public function set($key, $value)
|
129 |
{
|
171 |
/**
|
172 |
* Change the current collection to the specified
|
173 |
* @param array $collection Array elements of the new collection
|
174 |
+
* @return RscSgg_Common_Collection
|
175 |
*/
|
176 |
public function replace(array $collection)
|
177 |
{
|
183 |
/**
|
184 |
* Merge the specified array with the current collection
|
185 |
* @param array $collection Array elements
|
186 |
+
* @return RscSgg_Common_Collection
|
187 |
*/
|
188 |
public function merge(array $collection)
|
189 |
{
|
195 |
/**
|
196 |
* Applies the callback to the elements of the collection
|
197 |
* @param callable $callback Callback function to run for each element in the collection
|
198 |
+
* @return RscSgg_Common_Collection
|
199 |
*/
|
200 |
public function map(Callable $callback)
|
201 |
{
|
238 |
* @return Traversable An instance of an object implementing <b>Iterator</b> or
|
239 |
* <b>Traversable</b>
|
240 |
*/
|
241 |
+
#[\ReturnTypeWillChange]
|
242 |
public function getIterator()
|
243 |
{
|
244 |
return new ArrayIterator($this->collection);
|
278 |
* <p>
|
279 |
* The return value is cast to an integer.
|
280 |
*/
|
281 |
+
#[\ReturnTypeWillChange]
|
282 |
public function count()
|
283 |
{
|
284 |
return count($this->collection);
|
296 |
* <p>
|
297 |
* The return value will be casted to boolean if non-boolean was returned.
|
298 |
*/
|
299 |
+
#[\ReturnTypeWillChange]
|
300 |
public function offsetExists($offset)
|
301 |
{
|
302 |
return $this->has($offset);
|
311 |
* </p>
|
312 |
* @return mixed Can return all value types.
|
313 |
*/
|
314 |
+
#[\ReturnTypeWillChange]
|
315 |
public function offsetGet($offset)
|
316 |
{
|
317 |
return $this->get($offset, null);
|
329 |
* </p>
|
330 |
* @return void
|
331 |
*/
|
332 |
+
#[\ReturnTypeWillChange]
|
333 |
public function offsetSet($offset, $value)
|
334 |
{
|
335 |
if (is_null($offset)) {
|
348 |
* </p>
|
349 |
* @return void
|
350 |
*/
|
351 |
+
#[\ReturnTypeWillChange]
|
352 |
public function offsetUnset($offset)
|
353 |
{
|
354 |
$this->delete($offset);
|
355 |
}
|
356 |
+
}
|
vendor/Rsc/Config.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
-
* @var
|
9 |
*/
|
10 |
protected $loader;
|
11 |
|
12 |
/**
|
13 |
-
* @var
|
14 |
*/
|
15 |
protected $listener;
|
16 |
|
@@ -22,7 +22,7 @@ class Rsc_Config extends Rsc_Common_Collection
|
|
22 |
{
|
23 |
parent::__construct($config);
|
24 |
|
25 |
-
$this->loader = new
|
26 |
}
|
27 |
|
28 |
/**
|
@@ -55,8 +55,8 @@ class Rsc_Config extends Rsc_Common_Collection
|
|
55 |
try {
|
56 |
$this->merge($this->loader->load($filename));
|
57 |
return true;
|
58 |
-
} catch(
|
59 |
-
if ($this->isEnvironment(
|
60 |
wp_die ($e->getMessage());
|
61 |
}
|
62 |
|
@@ -66,7 +66,7 @@ class Rsc_Config extends Rsc_Common_Collection
|
|
66 |
|
67 |
/**
|
68 |
* Returns the instance of the config loader
|
69 |
-
* @return
|
70 |
*/
|
71 |
public function getLoader()
|
72 |
{
|
@@ -76,10 +76,10 @@ class Rsc_Config extends Rsc_Common_Collection
|
|
76 |
/**
|
77 |
* Adds the listener
|
78 |
* @param string $name The unique name of the listener
|
79 |
-
* @param
|
80 |
-
* @return
|
81 |
*/
|
82 |
-
public function addListener($name,
|
83 |
{
|
84 |
$this->listener[$name] = $listener;
|
85 |
return $this;
|
@@ -156,6 +156,6 @@ class Rsc_Config extends Rsc_Common_Collection
|
|
156 |
{
|
157 |
$loader = $this->getLoader();
|
158 |
|
159 |
-
$loader->add($defaultPath,
|
160 |
}
|
161 |
}
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Config extends RscSgg_Common_Collection
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
+
* @var RscSgg_Config_Loader
|
9 |
*/
|
10 |
protected $loader;
|
11 |
|
12 |
/**
|
13 |
+
* @var RscSgg_Config_ListenerInterface[]
|
14 |
*/
|
15 |
protected $listener;
|
16 |
|
22 |
{
|
23 |
parent::__construct($config);
|
24 |
|
25 |
+
$this->loader = new RscSgg_Config_Loader();
|
26 |
}
|
27 |
|
28 |
/**
|
55 |
try {
|
56 |
$this->merge($this->loader->load($filename));
|
57 |
return true;
|
58 |
+
} catch(RscSgg_Exception_ConfigLoaderException $e) {
|
59 |
+
if ($this->isEnvironment(RscSgg_Environment::ENV_DEVELOPMENT)) {
|
60 |
wp_die ($e->getMessage());
|
61 |
}
|
62 |
|
66 |
|
67 |
/**
|
68 |
* Returns the instance of the config loader
|
69 |
+
* @return RscSgg_Config_Loader
|
70 |
*/
|
71 |
public function getLoader()
|
72 |
{
|
76 |
/**
|
77 |
* Adds the listener
|
78 |
* @param string $name The unique name of the listener
|
79 |
+
* @param RscSgg_Config_ListenerInterface $listener
|
80 |
+
* @return RscSgg_Config
|
81 |
*/
|
82 |
+
public function addListener($name, RscSgg_Config_ListenerInterface $listener)
|
83 |
{
|
84 |
$this->listener[$name] = $listener;
|
85 |
return $this;
|
156 |
{
|
157 |
$loader = $this->getLoader();
|
158 |
|
159 |
+
$loader->add($defaultPath, RscSgg_Config_Loader::DEFAULT_NAMESPACE);
|
160 |
}
|
161 |
}
|
vendor/Rsc/Config/ListenerInterface.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
interface
|
5 |
{
|
6 |
|
7 |
public function onAdd($key, $value);
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
interface RscSgg_Config_ListenerInterface
|
5 |
{
|
6 |
|
7 |
public function onAdd($key, $value);
|
vendor/Rsc/Config/Loader.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
const DEFAULT_NAMESPACE = 'app';
|
@@ -15,7 +15,7 @@ class Rsc_Config_Loader
|
|
15 |
* Adds
|
16 |
* @param string $path
|
17 |
* @param string $namespace
|
18 |
-
* @return
|
19 |
*/
|
20 |
public function add($path, $namespace = self::DEFAULT_NAMESPACE)
|
21 |
{
|
@@ -53,7 +53,7 @@ class Rsc_Config_Loader
|
|
53 |
/**
|
54 |
* @param string $file The full path to the file
|
55 |
* @return array
|
56 |
-
* @throws
|
57 |
*/
|
58 |
public function load($file)
|
59 |
{
|
@@ -65,7 +65,7 @@ class Rsc_Config_Loader
|
|
65 |
try {
|
66 |
return $this->loadFromNamespace($file);
|
67 |
} catch (Exception $e) {
|
68 |
-
throw new
|
69 |
'Unable to load config %s: %s',
|
70 |
$file,
|
71 |
$e->getMessage()
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Config_Loader
|
5 |
{
|
6 |
|
7 |
const DEFAULT_NAMESPACE = 'app';
|
15 |
* Adds
|
16 |
* @param string $path
|
17 |
* @param string $namespace
|
18 |
+
* @return RscSgg_Config_Loader
|
19 |
*/
|
20 |
public function add($path, $namespace = self::DEFAULT_NAMESPACE)
|
21 |
{
|
53 |
/**
|
54 |
* @param string $file The full path to the file
|
55 |
* @return array
|
56 |
+
* @throws RscSgg_Exception_ConfigLoaderException
|
57 |
*/
|
58 |
public function load($file)
|
59 |
{
|
65 |
try {
|
66 |
return $this->loadFromNamespace($file);
|
67 |
} catch (Exception $e) {
|
68 |
+
throw new RscSgg_Exception_ConfigLoaderException(sprintf(
|
69 |
'Unable to load config %s: %s',
|
70 |
$file,
|
71 |
$e->getMessage()
|
vendor/Rsc/Dispatcher.php
CHANGED
@@ -4,19 +4,19 @@
|
|
4 |
* In-plugin event dispatcher.
|
5 |
* Dispatchers plugin-specific events.
|
6 |
*/
|
7 |
-
class
|
8 |
{
|
9 |
|
10 |
/**
|
11 |
-
* @var
|
12 |
*/
|
13 |
protected $environment;
|
14 |
|
15 |
/**
|
16 |
* Constructor.
|
17 |
-
* @param
|
18 |
*/
|
19 |
-
public function __construct(
|
20 |
{
|
21 |
$this->environment = $environment;
|
22 |
}
|
@@ -31,13 +31,13 @@ class Rsc_Dispatcher
|
|
31 |
* @param int $priority Used to specify the order in which the functions associated with a particular action are executed.
|
32 |
* @param int $args The number of arguments the hooked function accepts.
|
33 |
* @throws InvalidArgumentException
|
34 |
-
* @return
|
35 |
*/
|
36 |
public function on($action, $function, $priority = 10, $args = 1)
|
37 |
{
|
38 |
if (!is_callable($function)) {
|
39 |
throw new InvalidArgumentException(sprintf(
|
40 |
-
'Argument 2 passed to
|
41 |
gettype($function)
|
42 |
));
|
43 |
}
|
@@ -97,14 +97,14 @@ class Rsc_Dispatcher
|
|
97 |
* @param type $function
|
98 |
* @param type $priority
|
99 |
* @param type $args
|
100 |
-
* @return \
|
101 |
* @throws InvalidArgumentException
|
102 |
*/
|
103 |
public function filter($action, $function, $priority = 10, $args = 1)
|
104 |
{
|
105 |
if (!is_callable($function)) {
|
106 |
throw new InvalidArgumentException(sprintf(
|
107 |
-
'Argument 2 passed to
|
108 |
gettype($function)
|
109 |
));
|
110 |
}
|
4 |
* In-plugin event dispatcher.
|
5 |
* Dispatchers plugin-specific events.
|
6 |
*/
|
7 |
+
class RscSgg_Dispatcher
|
8 |
{
|
9 |
|
10 |
/**
|
11 |
+
* @var RscSgg_Environment;
|
12 |
*/
|
13 |
protected $environment;
|
14 |
|
15 |
/**
|
16 |
* Constructor.
|
17 |
+
* @param RscSgg_Environment $environment Plugin environment.
|
18 |
*/
|
19 |
+
public function __construct(RscSgg_Environment $environment)
|
20 |
{
|
21 |
$this->environment = $environment;
|
22 |
}
|
31 |
* @param int $priority Used to specify the order in which the functions associated with a particular action are executed.
|
32 |
* @param int $args The number of arguments the hooked function accepts.
|
33 |
* @throws InvalidArgumentException
|
34 |
+
* @return RscSgg_Dispatcher
|
35 |
*/
|
36 |
public function on($action, $function, $priority = 10, $args = 1)
|
37 |
{
|
38 |
if (!is_callable($function)) {
|
39 |
throw new InvalidArgumentException(sprintf(
|
40 |
+
'Argument 2 passed to RscSgg_Dispatcher::on() must be a callable, %s given.',
|
41 |
gettype($function)
|
42 |
));
|
43 |
}
|
97 |
* @param type $function
|
98 |
* @param type $priority
|
99 |
* @param type $args
|
100 |
+
* @return \RscSgg_Dispatcher
|
101 |
* @throws InvalidArgumentException
|
102 |
*/
|
103 |
public function filter($action, $function, $priority = 10, $args = 1)
|
104 |
{
|
105 |
if (!is_callable($function)) {
|
106 |
throw new InvalidArgumentException(sprintf(
|
107 |
+
'Argument 2 passed to RscSgg_Dispatcher::filter() must be a callable, %s given.',
|
108 |
gettype($function)
|
109 |
));
|
110 |
}
|
vendor/Rsc/Environment.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
const ENV_DEVELOPMENT = 'development';
|
@@ -27,42 +27,42 @@ class Rsc_Environment
|
|
27 |
protected $pluginPath;
|
28 |
|
29 |
/**
|
30 |
-
* @var
|
31 |
*/
|
32 |
protected $config;
|
33 |
|
34 |
/**
|
35 |
-
* @var
|
36 |
*/
|
37 |
protected $cache;
|
38 |
|
39 |
/**
|
40 |
-
* @var
|
41 |
*/
|
42 |
protected $loader;
|
43 |
|
44 |
/**
|
45 |
-
* @var
|
46 |
*/
|
47 |
protected $lang;
|
48 |
|
49 |
/**
|
50 |
-
* @var
|
51 |
*/
|
52 |
protected $menu;
|
53 |
|
54 |
/**
|
55 |
-
* @var
|
56 |
*/
|
57 |
protected $resolver;
|
58 |
|
59 |
/**
|
60 |
-
* @var
|
61 |
*/
|
62 |
protected $twig;
|
63 |
|
64 |
/**
|
65 |
-
* @var
|
66 |
*/
|
67 |
protected $logger;
|
68 |
|
@@ -72,7 +72,7 @@ class Rsc_Environment
|
|
72 |
protected $profilerEnabled;
|
73 |
|
74 |
/**
|
75 |
-
* @var
|
76 |
*/
|
77 |
protected $dispatcher;
|
78 |
|
@@ -92,13 +92,13 @@ class Rsc_Environment
|
|
92 |
$this->pluginPath = $path;
|
93 |
|
94 |
/* Class loader */
|
95 |
-
$this->loader = new
|
96 |
|
97 |
/* Modules resolver */
|
98 |
-
$this->resolver = new
|
99 |
|
100 |
/* Config */
|
101 |
-
$this->config = new
|
102 |
$this->config->setDefaultPath(untrailingslashit($path) . '/app/configs');
|
103 |
try {
|
104 |
$this->config->load('@app/global.php');
|
@@ -109,7 +109,7 @@ class Rsc_Environment
|
|
109 |
$this->config->add('plugin_path', $path);
|
110 |
|
111 |
/* Dispatcher */
|
112 |
-
$this->dispatcher = new
|
113 |
|
114 |
add_action('init', array($this, 'wpInitCallback'));
|
115 |
}
|
@@ -125,7 +125,7 @@ class Rsc_Environment
|
|
125 |
/**
|
126 |
* Configure plugin environment
|
127 |
* @param array $parameters An associative array with the parameters
|
128 |
-
* @return
|
129 |
*/
|
130 |
public function configure(array $parameters)
|
131 |
{
|
@@ -167,8 +167,8 @@ class Rsc_Environment
|
|
167 |
try {
|
168 |
$templatesPath = $this->getPluginPath() . '/app/templates';
|
169 |
|
170 |
-
$this->twig = new
|
171 |
-
new
|
172 |
array(
|
173 |
'cache' => $this->config->get('plugin_cache_twig', false),
|
174 |
'debug' => false,
|
@@ -177,9 +177,9 @@ class Rsc_Environment
|
|
177 |
);
|
178 |
|
179 |
// if ($this->isDev()) {
|
180 |
-
// $this->twig->addExtension(new
|
181 |
// }
|
182 |
-
} catch (
|
183 |
wp_die(
|
184 |
sprintf('Invalid plugin path specified: "%s"', $e->getMessage())
|
185 |
);
|
@@ -189,7 +189,7 @@ class Rsc_Environment
|
|
189 |
|
190 |
/** @TODO THROW TRY CATCH */
|
191 |
if ($this->config->has('plugin_menu')) {
|
192 |
-
$this->menu = new
|
193 |
|
194 |
foreach ($parameters = $this->config->get('plugin_menu') as $key => $value) {
|
195 |
if (method_exists($this->menu, $method = sprintf('set%s', str_replace('_', '', $key)))) {
|
@@ -206,7 +206,7 @@ class Rsc_Environment
|
|
206 |
}
|
207 |
|
208 |
$this->twig->addGlobal('environment', $this);
|
209 |
-
$this->twig->addGlobal('request', new
|
210 |
|
211 |
$this->resolver = apply_filters(
|
212 |
sprintf('%s_before_resolver_register', $this->pluginName),
|
@@ -253,7 +253,7 @@ class Rsc_Environment
|
|
253 |
|
254 |
/**
|
255 |
* Returns an instance of the Twig
|
256 |
-
* @return
|
257 |
*/
|
258 |
public function getTwig()
|
259 |
{
|
@@ -262,7 +262,7 @@ class Rsc_Environment
|
|
262 |
|
263 |
/**
|
264 |
* Returns an instance of the language class
|
265 |
-
* @return
|
266 |
*/
|
267 |
public function getLang()
|
268 |
{
|
@@ -281,7 +281,7 @@ class Rsc_Environment
|
|
281 |
$this->config->add('lang_path', $path);
|
282 |
}
|
283 |
|
284 |
-
$this->lang = new
|
285 |
}
|
286 |
|
287 |
return $this->lang;
|
@@ -289,7 +289,7 @@ class Rsc_Environment
|
|
289 |
|
290 |
/**
|
291 |
* Returns plugin environment configurations
|
292 |
-
* @return
|
293 |
*/
|
294 |
public function getConfig()
|
295 |
{
|
@@ -298,7 +298,7 @@ class Rsc_Environment
|
|
298 |
|
299 |
/**
|
300 |
* Returns an instance of the caching class
|
301 |
-
* @return
|
302 |
*/
|
303 |
public function getCache()
|
304 |
{
|
@@ -307,7 +307,7 @@ class Rsc_Environment
|
|
307 |
|
308 |
/**
|
309 |
* Returns ClassLoader
|
310 |
-
* @return
|
311 |
*/
|
312 |
public function getLoader()
|
313 |
{
|
@@ -316,7 +316,7 @@ class Rsc_Environment
|
|
316 |
|
317 |
/**
|
318 |
* Returns an instance of the current menu page
|
319 |
-
* @return \
|
320 |
*/
|
321 |
public function getMenu()
|
322 |
{
|
@@ -325,7 +325,7 @@ class Rsc_Environment
|
|
325 |
|
326 |
/**
|
327 |
* Returns an instance of the modules resolver
|
328 |
-
* @return
|
329 |
*/
|
330 |
public function getResolver()
|
331 |
{
|
@@ -333,17 +333,17 @@ class Rsc_Environment
|
|
333 |
}
|
334 |
|
335 |
/**
|
336 |
-
* @param \
|
337 |
-
* @return
|
338 |
*/
|
339 |
-
public function setLogger(
|
340 |
{
|
341 |
$this->logger = $logger;
|
342 |
return $this;
|
343 |
}
|
344 |
|
345 |
/**
|
346 |
-
* @return \
|
347 |
*/
|
348 |
public function getLogger()
|
349 |
{
|
@@ -392,7 +392,7 @@ class Rsc_Environment
|
|
392 |
/**
|
393 |
* Returns an instance of the specified module
|
394 |
* @param string $module The name of the module
|
395 |
-
* @return
|
396 |
*/
|
397 |
public function getModule($module)
|
398 |
{
|
@@ -411,19 +411,19 @@ class Rsc_Environment
|
|
411 |
|
412 |
/**
|
413 |
* Set an instance of the caching class
|
414 |
-
* @param
|
415 |
-
* @return
|
416 |
*/
|
417 |
-
public function setCacheAdapter(
|
418 |
{
|
419 |
-
$this->cache = new
|
420 |
return $this;
|
421 |
}
|
422 |
|
423 |
/**
|
424 |
* Set profiler state
|
425 |
* @param boolean $profilerEnabled
|
426 |
-
* @return
|
427 |
*/
|
428 |
public function setProfilerEnabled($profilerEnabled)
|
429 |
{
|
@@ -478,7 +478,7 @@ class Rsc_Environment
|
|
478 |
*/
|
479 |
public function isPluginPage()
|
480 |
{
|
481 |
-
$request = new
|
482 |
$menuSlug = $this->menu->getMenuSlug();
|
483 |
|
484 |
if ($menuSlug === null) {
|
@@ -497,7 +497,7 @@ class Rsc_Environment
|
|
497 |
*/
|
498 |
public function isModule($module, $action = null)
|
499 |
{
|
500 |
-
$request = new
|
501 |
$default = $this->config->get('default_module');
|
502 |
|
503 |
if (!$this->isPluginPage()) {
|
@@ -521,7 +521,7 @@ class Rsc_Environment
|
|
521 |
*/
|
522 |
public function isAction($action)
|
523 |
{
|
524 |
-
$request = new
|
525 |
|
526 |
if (!$this->isPluginPage()) {
|
527 |
return false;
|
@@ -543,7 +543,7 @@ class Rsc_Environment
|
|
543 |
/**
|
544 |
* Returns event dispatcher
|
545 |
*
|
546 |
-
* @return \
|
547 |
*/
|
548 |
public function getDispatcher()
|
549 |
{
|
@@ -570,6 +570,16 @@ class Rsc_Environment
|
|
570 |
return $this->isWPInit;
|
571 |
}
|
572 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
/**
|
574 |
* Sets the plugin path.
|
575 |
*
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Environment
|
5 |
{
|
6 |
|
7 |
const ENV_DEVELOPMENT = 'development';
|
27 |
protected $pluginPath;
|
28 |
|
29 |
/**
|
30 |
+
* @var RscSgg_Config
|
31 |
*/
|
32 |
protected $config;
|
33 |
|
34 |
/**
|
35 |
+
* @var RscSgg_Cache
|
36 |
*/
|
37 |
protected $cache;
|
38 |
|
39 |
/**
|
40 |
+
* @var RscSgg_ClassLoader
|
41 |
*/
|
42 |
protected $loader;
|
43 |
|
44 |
/**
|
45 |
+
* @var RscSgg_Lang
|
46 |
*/
|
47 |
protected $lang;
|
48 |
|
49 |
/**
|
50 |
+
* @var RscSgg_Menu_Page
|
51 |
*/
|
52 |
protected $menu;
|
53 |
|
54 |
/**
|
55 |
+
* @var RscSgg_Resolver
|
56 |
*/
|
57 |
protected $resolver;
|
58 |
|
59 |
/**
|
60 |
+
* @var Twig_SupTwgSgg_Environment
|
61 |
*/
|
62 |
protected $twig;
|
63 |
|
64 |
/**
|
65 |
+
* @var RscSgg_Logger_Interface
|
66 |
*/
|
67 |
protected $logger;
|
68 |
|
72 |
protected $profilerEnabled;
|
73 |
|
74 |
/**
|
75 |
+
* @var RscSgg_Dispatcher
|
76 |
*/
|
77 |
protected $dispatcher;
|
78 |
|
92 |
$this->pluginPath = $path;
|
93 |
|
94 |
/* Class loader */
|
95 |
+
$this->loader = new RscSgg_ClassLoader();
|
96 |
|
97 |
/* Modules resolver */
|
98 |
+
$this->resolver = new RscSgg_Resolver($this);
|
99 |
|
100 |
/* Config */
|
101 |
+
$this->config = new RscSgg_Config($this->defaults);
|
102 |
$this->config->setDefaultPath(untrailingslashit($path) . '/app/configs');
|
103 |
try {
|
104 |
$this->config->load('@app/global.php');
|
109 |
$this->config->add('plugin_path', $path);
|
110 |
|
111 |
/* Dispatcher */
|
112 |
+
$this->dispatcher = new RscSgg_Dispatcher($this);
|
113 |
|
114 |
add_action('init', array($this, 'wpInitCallback'));
|
115 |
}
|
125 |
/**
|
126 |
* Configure plugin environment
|
127 |
* @param array $parameters An associative array with the parameters
|
128 |
+
* @return RscSgg_Environment
|
129 |
*/
|
130 |
public function configure(array $parameters)
|
131 |
{
|
167 |
try {
|
168 |
$templatesPath = $this->getPluginPath() . '/app/templates';
|
169 |
|
170 |
+
$this->twig = new Twig_SupTwgSgg_Environment(
|
171 |
+
new Twig_SupTwgSgg_Loader_Filesystem($templatesPath),
|
172 |
array(
|
173 |
'cache' => $this->config->get('plugin_cache_twig', false),
|
174 |
'debug' => false,
|
177 |
);
|
178 |
|
179 |
// if ($this->isDev()) {
|
180 |
+
// $this->twig->addExtension(new Twig_SupTwgSgg_Extension_Debug());
|
181 |
// }
|
182 |
+
} catch (Twig_SupTwgSgg_Error_Loader $e) {
|
183 |
wp_die(
|
184 |
sprintf('Invalid plugin path specified: "%s"', $e->getMessage())
|
185 |
);
|
189 |
|
190 |
/** @TODO THROW TRY CATCH */
|
191 |
if ($this->config->has('plugin_menu')) {
|
192 |
+
$this->menu = new RscSgg_Menu_Page($this->resolver);
|
193 |
|
194 |
foreach ($parameters = $this->config->get('plugin_menu') as $key => $value) {
|
195 |
if (method_exists($this->menu, $method = sprintf('set%s', str_replace('_', '', $key)))) {
|
206 |
}
|
207 |
|
208 |
$this->twig->addGlobal('environment', $this);
|
209 |
+
$this->twig->addGlobal('request', new RscSgg_Http_Request());
|
210 |
|
211 |
$this->resolver = apply_filters(
|
212 |
sprintf('%s_before_resolver_register', $this->pluginName),
|
253 |
|
254 |
/**
|
255 |
* Returns an instance of the Twig
|
256 |
+
* @return Twig_SupTwgSgg_Environment
|
257 |
*/
|
258 |
public function getTwig()
|
259 |
{
|
262 |
|
263 |
/**
|
264 |
* Returns an instance of the language class
|
265 |
+
* @return RscSgg_Lang
|
266 |
*/
|
267 |
public function getLang()
|
268 |
{
|
281 |
$this->config->add('lang_path', $path);
|
282 |
}
|
283 |
|
284 |
+
$this->lang = new RscSgg_Lang($domain, $path);
|
285 |
}
|
286 |
|
287 |
return $this->lang;
|
289 |
|
290 |
/**
|
291 |
* Returns plugin environment configurations
|
292 |
+
* @return RscSgg_Config
|
293 |
*/
|
294 |
public function getConfig()
|
295 |
{
|
298 |
|
299 |
/**
|
300 |
* Returns an instance of the caching class
|
301 |
+
* @return RscSgg_Cache
|
302 |
*/
|
303 |
public function getCache()
|
304 |
{
|
307 |
|
308 |
/**
|
309 |
* Returns ClassLoader
|
310 |
+
* @return RscSgg_ClassLoader
|
311 |
*/
|
312 |
public function getLoader()
|
313 |
{
|
316 |
|
317 |
/**
|
318 |
* Returns an instance of the current menu page
|
319 |
+
* @return \RscSgg_Menu_Page
|
320 |
*/
|
321 |
public function getMenu()
|
322 |
{
|
325 |
|
326 |
/**
|
327 |
* Returns an instance of the modules resolver
|
328 |
+
* @return RscSgg_Resolver
|
329 |
*/
|
330 |
public function getResolver()
|
331 |
{
|
333 |
}
|
334 |
|
335 |
/**
|
336 |
+
* @param \RscSgg_Logger_Interface $logger
|
337 |
+
* @return RscSgg_Environment
|
338 |
*/
|
339 |
+
public function setLogger(RscSgg_Logger_Interface $logger)
|
340 |
{
|
341 |
$this->logger = $logger;
|
342 |
return $this;
|
343 |
}
|
344 |
|
345 |
/**
|
346 |
+
* @return \RscSgg_Logger_Interface
|
347 |
*/
|
348 |
public function getLogger()
|
349 |
{
|
392 |
/**
|
393 |
* Returns an instance of the specified module
|
394 |
* @param string $module The name of the module
|
395 |
+
* @return RscSgg_Mvc_Module|null
|
396 |
*/
|
397 |
public function getModule($module)
|
398 |
{
|
411 |
|
412 |
/**
|
413 |
* Set an instance of the caching class
|
414 |
+
* @param RscSgg_Cache_Interface $adapter
|
415 |
+
* @return RscSgg_Environment
|
416 |
*/
|
417 |
+
public function setCacheAdapter(RscSgg_Cache_Interface $adapter)
|
418 |
{
|
419 |
+
$this->cache = new RscSgg_Cache($adapter);
|
420 |
return $this;
|
421 |
}
|
422 |
|
423 |
/**
|
424 |
* Set profiler state
|
425 |
* @param boolean $profilerEnabled
|
426 |
+
* @return RscSgg_Environment
|
427 |
*/
|
428 |
public function setProfilerEnabled($profilerEnabled)
|
429 |
{
|
478 |
*/
|
479 |
public function isPluginPage()
|
480 |
{
|
481 |
+
$request = new RscSgg_Http_Request();
|
482 |
$menuSlug = $this->menu->getMenuSlug();
|
483 |
|
484 |
if ($menuSlug === null) {
|
497 |
*/
|
498 |
public function isModule($module, $action = null)
|
499 |
{
|
500 |
+
$request = new RscSgg_Http_Request();
|
501 |
$default = $this->config->get('default_module');
|
502 |
|
503 |
if (!$this->isPluginPage()) {
|
521 |
*/
|
522 |
public function isAction($action)
|
523 |
{
|
524 |
+
$request = new RscSgg_Http_Request();
|
525 |
|
526 |
if (!$this->isPluginPage()) {
|
527 |
return false;
|
543 |
/**
|
544 |
* Returns event dispatcher
|
545 |
*
|
546 |
+
* @return \RscSgg_Dispatcher
|
547 |
*/
|
548 |
public function getDispatcher()
|
549 |
{
|
570 |
return $this->isWPInit;
|
571 |
}
|
572 |
|
573 |
+
public function getNonceFrontend()
|
574 |
+
{
|
575 |
+
return wp_create_nonce('sgg_nonce_frontend');
|
576 |
+
}
|
577 |
+
|
578 |
+
public function getNonce()
|
579 |
+
{
|
580 |
+
return wp_create_nonce('sgg_nonce');
|
581 |
+
}
|
582 |
+
|
583 |
/**
|
584 |
* Sets the plugin path.
|
585 |
*
|
vendor/Rsc/Environment/Aware.php
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
-
* @var
|
9 |
*/
|
10 |
protected $environment;
|
11 |
|
12 |
/**
|
13 |
* Sets the environment.
|
14 |
*
|
15 |
-
* @param
|
16 |
*/
|
17 |
-
public function setEnvironment(
|
18 |
{
|
19 |
$this->environment = $environment;
|
20 |
}
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Environment_Aware implements RscSgg_Environment_AwareInterface
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
+
* @var RscSgg_Environment
|
9 |
*/
|
10 |
protected $environment;
|
11 |
|
12 |
/**
|
13 |
* Sets the environment.
|
14 |
*
|
15 |
+
* @param RscSgg_Environment $environment
|
16 |
*/
|
17 |
+
public function setEnvironment(RscSgg_Environment $environment)
|
18 |
{
|
19 |
$this->environment = $environment;
|
20 |
}
|
vendor/Rsc/Environment/AwareInterface.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
interface
|
4 |
{
|
5 |
|
6 |
/**
|
7 |
* Sets the environment.
|
8 |
-
* @param
|
9 |
*/
|
10 |
-
public function setEnvironment(
|
11 |
}
|
1 |
<?php
|
2 |
|
3 |
+
interface RscSgg_Environment_AwareInterface
|
4 |
{
|
5 |
|
6 |
/**
|
7 |
* Sets the environment.
|
8 |
+
* @param RscSgg_Environment $environment
|
9 |
*/
|
10 |
+
public function setEnvironment(RscSgg_Environment $environment);
|
11 |
}
|
vendor/Rsc/Exception/ConfigLoaderException.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
}
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Exception_ConfigLoaderException extends RuntimeException
|
5 |
{
|
6 |
|
7 |
}
|
vendor/Rsc/Exception/EnvironmentRuntimeException.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
}
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Exception_EnvironmentRuntimeException extends RuntimeException
|
5 |
{
|
6 |
|
7 |
}
|
vendor/Rsc/Exception/LangException.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
}
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Exception_LangException extends InvalidArgumentException
|
5 |
{
|
6 |
|
7 |
}
|
vendor/Rsc/Feedback/Mailer.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
/**
|
7 |
* @var array
|
@@ -66,7 +66,7 @@ class Rsc_Feedback_Mailer
|
|
66 |
*
|
67 |
* @param array $headers
|
68 |
* @throws InvalidArgumentException If the headers is not an array or not a string
|
69 |
-
* @return
|
70 |
*/
|
71 |
public function setHeaders(array $headers)
|
72 |
{
|
@@ -94,7 +94,7 @@ class Rsc_Feedback_Mailer
|
|
94 |
* Sets the attachments
|
95 |
*
|
96 |
* @param array $attachments
|
97 |
-
* @return
|
98 |
* @throws InvalidArgumentException If the attachments is not an array or not a string
|
99 |
*/
|
100 |
public function setAttachments(array $attachments)
|
@@ -129,7 +129,7 @@ class Rsc_Feedback_Mailer
|
|
129 |
* @param array $emails
|
130 |
* @throws LogicException
|
131 |
* @throws InvalidArgumentException
|
132 |
-
* @return
|
133 |
*/
|
134 |
public function setEmails(array $emails)
|
135 |
{
|
@@ -187,7 +187,7 @@ class Rsc_Feedback_Mailer
|
|
187 |
* Sets the message
|
188 |
*
|
189 |
* @param string $message
|
190 |
-
* @return
|
191 |
*/
|
192 |
public function setMessage($message)
|
193 |
{
|
@@ -209,7 +209,7 @@ class Rsc_Feedback_Mailer
|
|
209 |
* Sets the subject
|
210 |
*
|
211 |
* @param string $subject
|
212 |
-
* @return
|
213 |
*/
|
214 |
public function setSubject($subject)
|
215 |
{
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Feedback_Mailer
|
5 |
{
|
6 |
/**
|
7 |
* @var array
|
66 |
*
|
67 |
* @param array $headers
|
68 |
* @throws InvalidArgumentException If the headers is not an array or not a string
|
69 |
+
* @return RscSgg_Feedback_Mailer
|
70 |
*/
|
71 |
public function setHeaders(array $headers)
|
72 |
{
|
94 |
* Sets the attachments
|
95 |
*
|
96 |
* @param array $attachments
|
97 |
+
* @return RscSgg_Feedback_Mailer
|
98 |
* @throws InvalidArgumentException If the attachments is not an array or not a string
|
99 |
*/
|
100 |
public function setAttachments(array $attachments)
|
129 |
* @param array $emails
|
130 |
* @throws LogicException
|
131 |
* @throws InvalidArgumentException
|
132 |
+
* @return RscSgg_Feedback_Mailer
|
133 |
*/
|
134 |
public function setEmails(array $emails)
|
135 |
{
|
187 |
* Sets the message
|
188 |
*
|
189 |
* @param string $message
|
190 |
+
* @return RscSgg_Feedback_Mailer
|
191 |
*/
|
192 |
public function setMessage($message)
|
193 |
{
|
209 |
* Sets the subject
|
210 |
*
|
211 |
* @param string $subject
|
212 |
+
* @return RscSgg_Feedback_Mailer
|
213 |
*/
|
214 |
public function setSubject($subject)
|
215 |
{
|
vendor/Rsc/Feedback/SupportMailer.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* Class
|
5 |
* @package Rsc\Feedback
|
6 |
*/
|
7 |
-
class
|
8 |
{
|
9 |
/**
|
10 |
-
* @var
|
11 |
*/
|
12 |
private $mailer;
|
13 |
|
@@ -19,14 +19,14 @@ class Rsc_Feedback_SupportMailer
|
|
19 |
/**
|
20 |
* Constructor
|
21 |
*
|
22 |
-
* @param
|
23 |
* @param string $subject
|
24 |
* @param string $message
|
25 |
* @param array $parameters
|
26 |
*/
|
27 |
-
public function __construct(
|
28 |
{
|
29 |
-
$this->mailer = (is_null($mailer) ? new
|
30 |
|
31 |
$this->mailer->setSubject($subject);
|
32 |
$this->mailer->setMessage($message);
|
@@ -38,7 +38,7 @@ class Rsc_Feedback_SupportMailer
|
|
38 |
* Sets the message
|
39 |
*
|
40 |
* @param string $message
|
41 |
-
* @return
|
42 |
*/
|
43 |
public function setMessage($message)
|
44 |
{
|
@@ -51,7 +51,7 @@ class Rsc_Feedback_SupportMailer
|
|
51 |
* Sets the subject
|
52 |
*
|
53 |
* @param string $subject
|
54 |
-
* @return
|
55 |
*/
|
56 |
public function setSubject($subject)
|
57 |
{
|
@@ -64,7 +64,7 @@ class Rsc_Feedback_SupportMailer
|
|
64 |
* Sets the parameters
|
65 |
*
|
66 |
* @param array $parameters
|
67 |
-
* @return
|
68 |
*/
|
69 |
public function setParameters(array $parameters)
|
70 |
{
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* Class RscSgg_Feedback_SupportMailer
|
5 |
* @package Rsc\Feedback
|
6 |
*/
|
7 |
+
class RscSgg_Feedback_SupportMailer
|
8 |
{
|
9 |
/**
|
10 |
+
* @var RscSgg_Feedback_Mailer
|
11 |
*/
|
12 |
private $mailer;
|
13 |
|
19 |
/**
|
20 |
* Constructor
|
21 |
*
|
22 |
+
* @param RscSgg_Feedback_Mailer $mailer
|
23 |
* @param string $subject
|
24 |
* @param string $message
|
25 |
* @param array $parameters
|
26 |
*/
|
27 |
+
public function __construct(RscSgg_Feedback_Mailer $mailer = null, $subject = '', $message = '', array $parameters = array())
|
28 |
{
|
29 |
+
$this->mailer = (is_null($mailer) ? new RscSgg_Feedback_Mailer() : $mailer);
|
30 |
|
31 |
$this->mailer->setSubject($subject);
|
32 |
$this->mailer->setMessage($message);
|
38 |
* Sets the message
|
39 |
*
|
40 |
* @param string $message
|
41 |
+
* @return RscSgg_Feedback_SupportMailer
|
42 |
*/
|
43 |
public function setMessage($message)
|
44 |
{
|
51 |
* Sets the subject
|
52 |
*
|
53 |
* @param string $subject
|
54 |
+
* @return RscSgg_Feedback_SupportMailer
|
55 |
*/
|
56 |
public function setSubject($subject)
|
57 |
{
|
64 |
* Sets the parameters
|
65 |
*
|
66 |
* @param array $parameters
|
67 |
+
* @return RscSgg_Feedback_SupportMailer
|
68 |
*/
|
69 |
public function setParameters(array $parameters)
|
70 |
{
|
vendor/Rsc/Form/Filter/Custom.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
public $function;
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Form_Filter_Custom implements RscSgg_Form_Filter_Interface
|
5 |
{
|
6 |
|
7 |
public $function;
|
vendor/Rsc/Form/Filter/Interface.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
interface
|
5 |
{
|
6 |
/**
|
7 |
* Filters data
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
interface RscSgg_Form_Filter_Interface
|
5 |
{
|
6 |
/**
|
7 |
* Filters data
|
vendor/Rsc/Form/Filter/XssClear.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
/**
|
7 |
* Filters data
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Form_Filter_XssClear implements RscSgg_Form_Filter_Interface
|
5 |
{
|
6 |
/**
|
7 |
* Filters data
|
vendor/Rsc/Form/Rule/Interface.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
interface
|
5 |
{
|
6 |
/**
|
7 |
* Constructor
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
interface RscSgg_Form_Rule_Interface
|
5 |
{
|
6 |
/**
|
7 |
* Constructor
|
vendor/Rsc/Form/Rule/Numeric.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
@@ -66,7 +66,7 @@ class Rsc_Form_Rule_Numeric implements Rsc_Form_Rule_Interface
|
|
66 |
* Creates the new instance
|
67 |
* @param string $label Field label
|
68 |
* @param null $parameters Rule parameters
|
69 |
-
* @return
|
70 |
*/
|
71 |
public static function create($label, $parameters)
|
72 |
{
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Form_Rule_Numeric implements RscSgg_Form_Rule_Interface
|
5 |
{
|
6 |
|
7 |
/**
|
66 |
* Creates the new instance
|
67 |
* @param string $label Field label
|
68 |
* @param null $parameters Rule parameters
|
69 |
+
* @return RscSgg_Form_Rule_Numeric
|
70 |
*/
|
71 |
public static function create($label, $parameters)
|
72 |
{
|
vendor/Rsc/Form/Rule/Regex.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
@@ -62,7 +62,7 @@ class Rsc_Form_Rule_Regex implements Rsc_Form_Rule_Interface
|
|
62 |
/**
|
63 |
* Sets the error message
|
64 |
* @param string $message Error message
|
65 |
-
* @return
|
66 |
*/
|
67 |
public function setMessage($message)
|
68 |
{
|
@@ -75,7 +75,7 @@ class Rsc_Form_Rule_Regex implements Rsc_Form_Rule_Interface
|
|
75 |
* Creates the new instance
|
76 |
* @param string $label Field label
|
77 |
* @param string $parameters Rule parameters
|
78 |
-
* @return
|
79 |
*/
|
80 |
public static function create($label, $parameters)
|
81 |
{
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Form_Rule_Regex implements RscSgg_Form_Rule_Interface
|
5 |
{
|
6 |
|
7 |
/**
|
62 |
/**
|
63 |
* Sets the error message
|
64 |
* @param string $message Error message
|
65 |
+
* @return RscSgg_Form_Rule_Regex
|
66 |
*/
|
67 |
public function setMessage($message)
|
68 |
{
|
75 |
* Creates the new instance
|
76 |
* @param string $label Field label
|
77 |
* @param string $parameters Rule parameters
|
78 |
+
* @return RscSgg_Form_Rule_Regex
|
79 |
*/
|
80 |
public static function create($label, $parameters)
|
81 |
{
|
vendor/Rsc/Form/Rule/Required.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
@@ -73,11 +73,11 @@ class Rsc_Form_Rule_Required implements Rsc_Form_Rule_Interface
|
|
73 |
/**
|
74 |
* Creates the new instance of the rule for chaining
|
75 |
* <code>
|
76 |
-
*
|
77 |
* </code>
|
78 |
* @param string $label Field label
|
79 |
* @param null $parameters An array of parameters
|
80 |
-
* @return
|
81 |
*/
|
82 |
public static function create($label, $parameters = null)
|
83 |
{
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Form_Rule_Required implements RscSgg_Form_Rule_Interface
|
5 |
{
|
6 |
|
7 |
/**
|
73 |
/**
|
74 |
* Creates the new instance of the rule for chaining
|
75 |
* <code>
|
76 |
+
* RscSgg_Form_Rule_Required::create('Control label', $params)->setMessage('The field %s is required');
|
77 |
* </code>
|
78 |
* @param string $label Field label
|
79 |
* @param null $parameters An array of parameters
|
80 |
+
* @return RscSgg_Form_Rule_Required
|
81 |
*/
|
82 |
public static function create($label, $parameters = null)
|
83 |
{
|
vendor/Rsc/Form/Validator.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
const METHOD_POST = 'post';
|
8 |
const METHOD_GET = 'query';
|
9 |
|
10 |
/**
|
11 |
-
* @var
|
12 |
*/
|
13 |
protected $request;
|
14 |
|
@@ -18,12 +18,12 @@ class Rsc_Form_Validator
|
|
18 |
protected $method;
|
19 |
|
20 |
/**
|
21 |
-
* @var
|
22 |
*/
|
23 |
protected $rules;
|
24 |
|
25 |
/**
|
26 |
-
* @var
|
27 |
*/
|
28 |
protected $filters;
|
29 |
|
@@ -34,14 +34,14 @@ class Rsc_Form_Validator
|
|
34 |
|
35 |
/**
|
36 |
* Constructor
|
37 |
-
* @param
|
38 |
* @param string|null $method
|
39 |
-
* @param
|
40 |
-
* @param
|
41 |
*/
|
42 |
-
public function __construct(
|
43 |
{
|
44 |
-
$this->request = ($request === null ?
|
45 |
$this->method = ($method === null ? self::METHOD_POST : $this->prepareMethod($method));
|
46 |
$this->rules = $rules;
|
47 |
$this->filters = $filters;
|
@@ -50,15 +50,15 @@ class Rsc_Form_Validator
|
|
50 |
/**
|
51 |
* Is valid HTTP request?
|
52 |
* @return bool
|
53 |
-
* @throws
|
54 |
*/
|
55 |
public function isValid()
|
56 |
{
|
57 |
if (!$this->request) {
|
58 |
-
throw new
|
59 |
}
|
60 |
|
61 |
-
/** @var
|
62 |
$method = $this->request->{$this->method};
|
63 |
|
64 |
if ($method->isEmpty()) {
|
@@ -77,10 +77,10 @@ class Rsc_Form_Validator
|
|
77 |
|
78 |
/**
|
79 |
* Set current HTTP request for validation
|
80 |
-
* @param
|
81 |
-
* @return
|
82 |
*/
|
83 |
-
public function setRequest(
|
84 |
{
|
85 |
$this->request = $request;
|
86 |
return $this;
|
@@ -88,7 +88,7 @@ class Rsc_Form_Validator
|
|
88 |
|
89 |
/**
|
90 |
* Returns object of current HTTP request
|
91 |
-
* @return
|
92 |
*/
|
93 |
public function getRequest()
|
94 |
{
|
@@ -98,15 +98,15 @@ class Rsc_Form_Validator
|
|
98 |
/**
|
99 |
* Set HTTP method to validate
|
100 |
* @param string $method HTTP method to validate (POST or GET)
|
101 |
-
* @throws
|
102 |
-
* @return
|
103 |
*/
|
104 |
public function setMethod($method)
|
105 |
{
|
106 |
$method = $this->prepareMethod($method);
|
107 |
|
108 |
if (!in_array($method, array(self::METHOD_GET, self::METHOD_POST))) {
|
109 |
-
throw new
|
110 |
}
|
111 |
|
112 |
return $this;
|
@@ -124,7 +124,7 @@ class Rsc_Form_Validator
|
|
124 |
/**
|
125 |
* Set fields filters
|
126 |
* @param array $filters
|
127 |
-
* @return
|
128 |
*/
|
129 |
public function setFilters(array $filters)
|
130 |
{
|
@@ -145,7 +145,7 @@ class Rsc_Form_Validator
|
|
145 |
/**
|
146 |
* Set validation rules
|
147 |
* @param array $rules
|
148 |
-
* @return
|
149 |
*/
|
150 |
public function setRules(array $rules)
|
151 |
{
|
@@ -198,15 +198,15 @@ class Rsc_Form_Validator
|
|
198 |
|
199 |
/**
|
200 |
* Applies the specified filters
|
201 |
-
* @param
|
202 |
*/
|
203 |
-
protected function applyFilters(
|
204 |
{
|
205 |
if (empty($this->filters)) {
|
206 |
return;
|
207 |
}
|
208 |
|
209 |
-
/** @var
|
210 |
foreach ($this->filters as $field => $filters) {
|
211 |
|
212 |
if (!is_array($this->filters[$field])) {
|
@@ -225,15 +225,15 @@ class Rsc_Form_Validator
|
|
225 |
|
226 |
/**
|
227 |
* Do validation
|
228 |
-
* @param
|
229 |
*/
|
230 |
-
protected function doValidation(
|
231 |
{
|
232 |
if (empty($this->rules)) {
|
233 |
return;
|
234 |
}
|
235 |
|
236 |
-
/** @var
|
237 |
foreach ($this->rules as $field => $rules) {
|
238 |
|
239 |
if (!is_array($this->rules[$field])) {
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Form_Validator
|
5 |
{
|
6 |
|
7 |
const METHOD_POST = 'post';
|
8 |
const METHOD_GET = 'query';
|
9 |
|
10 |
/**
|
11 |
+
* @var RscSgg_Http_Request
|
12 |
*/
|
13 |
protected $request;
|
14 |
|
18 |
protected $method;
|
19 |
|
20 |
/**
|
21 |
+
* @var RscSgg_Common_Collection
|
22 |
*/
|
23 |
protected $rules;
|
24 |
|
25 |
/**
|
26 |
+
* @var RscSgg_Common_Collection
|
27 |
*/
|
28 |
protected $filters;
|
29 |
|
34 |
|
35 |
/**
|
36 |
* Constructor
|
37 |
+
* @param RscSgg_Http_Request $request
|
38 |
* @param string|null $method
|
39 |
+
* @param RscSgg_Common_Collection|array $rules
|
40 |
+
* @param RscSgg_Common_Collection|array $filters
|
41 |
*/
|
42 |
+
public function __construct(RscSgg_Http_Request $request = null, $method = null, array $rules = array(), array $filters = array())
|
43 |
{
|
44 |
+
$this->request = ($request === null ? RscSgg_Http_Request::create() : $request);
|
45 |
$this->method = ($method === null ? self::METHOD_POST : $this->prepareMethod($method));
|
46 |
$this->rules = $rules;
|
47 |
$this->filters = $filters;
|
50 |
/**
|
51 |
* Is valid HTTP request?
|
52 |
* @return bool
|
53 |
+
* @throws RscSgg_Form_Validator_EmptyRequestException If HTTP request is not specified
|
54 |
*/
|
55 |
public function isValid()
|
56 |
{
|
57 |
if (!$this->request) {
|
58 |
+
throw new RscSgg_Form_Validator_EmptyRequestException('You must submit the request via ' . __CLASS__ . '::setRequest() method');
|
59 |
}
|
60 |
|
61 |
+
/** @var RscSgg_Http_Parameters $method */
|
62 |
$method = $this->request->{$this->method};
|
63 |
|
64 |
if ($method->isEmpty()) {
|
77 |
|
78 |
/**
|
79 |
* Set current HTTP request for validation
|
80 |
+
* @param RscSgg_Http_Request $request
|
81 |
+
* @return RscSgg_Form_Validator
|
82 |
*/
|
83 |
+
public function setRequest(RscSgg_Http_Request $request)
|
84 |
{
|
85 |
$this->request = $request;
|
86 |
return $this;
|
88 |
|
89 |
/**
|
90 |
* Returns object of current HTTP request
|
91 |
+
* @return RscSgg_Http_Request
|
92 |
*/
|
93 |
public function getRequest()
|
94 |
{
|
98 |
/**
|
99 |
* Set HTTP method to validate
|
100 |
* @param string $method HTTP method to validate (POST or GET)
|
101 |
+
* @throws RscSgg_Form_Validator_InvalidMethodException If specified method is wrong
|
102 |
+
* @return RscSgg_Form_Validator
|
103 |
*/
|
104 |
public function setMethod($method)
|
105 |
{
|
106 |
$method = $this->prepareMethod($method);
|
107 |
|
108 |
if (!in_array($method, array(self::METHOD_GET, self::METHOD_POST))) {
|
109 |
+
throw new RscSgg_Form_Validator_InvalidMethodException('Invalid method. Type of the method can only be POST or GET (QUERY)');
|
110 |
}
|
111 |
|
112 |
return $this;
|
124 |
/**
|
125 |
* Set fields filters
|
126 |
* @param array $filters
|
127 |
+
* @return RscSgg_Form_Validator
|
128 |
*/
|
129 |
public function setFilters(array $filters)
|
130 |
{
|
145 |
/**
|
146 |
* Set validation rules
|
147 |
* @param array $rules
|
148 |
+
* @return RscSgg_Form_Validator
|
149 |
*/
|
150 |
public function setRules(array $rules)
|
151 |
{
|
198 |
|
199 |
/**
|
200 |
* Applies the specified filters
|
201 |
+
* @param RscSgg_Http_Parameters $method
|
202 |
*/
|
203 |
+
protected function applyFilters(RscSgg_Http_Parameters $method)
|
204 |
{
|
205 |
if (empty($this->filters)) {
|
206 |
return;
|
207 |
}
|
208 |
|
209 |
+
/** @var RscSgg_Form_Filter_Interface $filter */
|
210 |
foreach ($this->filters as $field => $filters) {
|
211 |
|
212 |
if (!is_array($this->filters[$field])) {
|
225 |
|
226 |
/**
|
227 |
* Do validation
|
228 |
+
* @param RscSgg_Http_Parameters $method
|
229 |
*/
|
230 |
+
protected function doValidation(RscSgg_Http_Parameters $method)
|
231 |
{
|
232 |
if (empty($this->rules)) {
|
233 |
return;
|
234 |
}
|
235 |
|
236 |
+
/** @var RscSgg_Form_Rule_Interface $rule */
|
237 |
foreach ($this->rules as $field => $rules) {
|
238 |
|
239 |
if (!is_array($this->rules[$field])) {
|
vendor/Rsc/Form/Validator/EmptyRequestException.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
}
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Form_Validator_EmptyRequestException extends RuntimeException
|
5 |
{
|
6 |
|
7 |
}
|
vendor/Rsc/Form/Validator/InvalidMethodException.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
}
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Form_Validator_InvalidMethodException extends InvalidArgumentException
|
5 |
{
|
6 |
|
7 |
}
|
vendor/Rsc/Form/Validator/UnexpectedRuleException.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
}
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Form_Validator_UnexpectedRuleException extends InvalidArgumentException
|
5 |
{
|
6 |
|
7 |
}
|
vendor/Rsc/Html.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
class
|
3 |
static public function nameToClassId($name, $params = array()) {
|
4 |
if(!empty($params) && isset($params['attrs']) && strpos($params['attrs'], 'id="') !== false) {
|
5 |
preg_match('/id="(.+)"/ui', $params['attrs'], $idMatches);
|
1 |
<?php
|
2 |
+
class RscSgg_Html {
|
3 |
static public function nameToClassId($name, $params = array()) {
|
4 |
if(!empty($params) && isset($params['attrs']) && strpos($params['attrs'], 'id="') !== false) {
|
5 |
preg_match('/id="(.+)"/ui', $params['attrs'], $idMatches);
|
vendor/Rsc/Http/Parameters.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
public function get_esc_html($key, $default = null)
|
7 |
{
|
@@ -10,4 +10,4 @@ class Rsc_Http_Parameters extends Rsc_Common_Collection
|
|
10 |
|
11 |
return $default;
|
12 |
}
|
13 |
-
}
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Http_Parameters extends RscSgg_Common_Collection
|
5 |
{
|
6 |
public function get_esc_html($key, $default = null)
|
7 |
{
|
10 |
|
11 |
return $default;
|
12 |
}
|
13 |
+
}
|
vendor/Rsc/Http/Request.php
CHANGED
@@ -1,30 +1,30 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
/**
|
7 |
-
* @var
|
8 |
*/
|
9 |
public $post;
|
10 |
|
11 |
/**
|
12 |
-
* @var
|
13 |
*/
|
14 |
public $query;
|
15 |
|
16 |
/**
|
17 |
-
* @var
|
18 |
*/
|
19 |
public $files;
|
20 |
|
21 |
/**
|
22 |
-
* @var
|
23 |
*/
|
24 |
public $server;
|
25 |
|
26 |
/**
|
27 |
-
* @var
|
28 |
*/
|
29 |
public $headers;
|
30 |
|
@@ -40,16 +40,16 @@ class Rsc_Http_Request
|
|
40 |
if(!is_array($postTempVar)) {
|
41 |
$postTempVar = array();
|
42 |
}
|
43 |
-
$this->post = new
|
44 |
-
$this->query = new
|
45 |
-
$this->files = new
|
46 |
-
$this->server = new
|
47 |
-
$this->headers = new
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
* Returns new request from the global variables
|
52 |
-
* @return
|
53 |
*/
|
54 |
public static function create()
|
55 |
{
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Http_Request
|
5 |
{
|
6 |
/**
|
7 |
+
* @var RscSgg_Http_Parameters
|
8 |
*/
|
9 |
public $post;
|
10 |
|
11 |
/**
|
12 |
+
* @var RscSgg_Http_Parameters
|
13 |
*/
|
14 |
public $query;
|
15 |
|
16 |
/**
|
17 |
+
* @var RscSgg_Http_Parameters
|
18 |
*/
|
19 |
public $files;
|
20 |
|
21 |
/**
|
22 |
+
* @var RscSgg_Http_ServerParameters
|
23 |
*/
|
24 |
public $server;
|
25 |
|
26 |
/**
|
27 |
+
* @var RscSgg_Http_Parameters
|
28 |
*/
|
29 |
public $headers;
|
30 |
|
40 |
if(!is_array($postTempVar)) {
|
41 |
$postTempVar = array();
|
42 |
}
|
43 |
+
$this->post = new RscSgg_Http_Parameters($postTempVar);
|
44 |
+
$this->query = new RscSgg_Http_Parameters($_GET);
|
45 |
+
$this->files = new RscSgg_Http_Parameters($_FILES);
|
46 |
+
$this->server = new RscSgg_Http_ServerParameters($_SERVER);
|
47 |
+
$this->headers = new RscSgg_Http_Parameters($this->server->getHeaders());
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
* Returns new request from the global variables
|
52 |
+
* @return RscSgg_Http_Request
|
53 |
*/
|
54 |
public static function create()
|
55 |
{
|
vendor/Rsc/Http/Response.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
const AJAX = 'ajax';
|
@@ -13,7 +13,7 @@ class Rsc_Http_Response
|
|
13 |
|
14 |
/**
|
15 |
* Creates the new response for chaining methods
|
16 |
-
* @return
|
17 |
*/
|
18 |
public static function create()
|
19 |
{
|
@@ -23,7 +23,7 @@ class Rsc_Http_Response
|
|
23 |
/**
|
24 |
* Sets the content of the response
|
25 |
* @param string $content
|
26 |
-
* @return
|
27 |
*/
|
28 |
public function setContent($content)
|
29 |
{
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Http_Response
|
5 |
{
|
6 |
|
7 |
const AJAX = 'ajax';
|
13 |
|
14 |
/**
|
15 |
* Creates the new response for chaining methods
|
16 |
+
* @return RscSgg_Http_Response
|
17 |
*/
|
18 |
public static function create()
|
19 |
{
|
23 |
/**
|
24 |
* Sets the content of the response
|
25 |
* @param string $content
|
26 |
+
* @return RscSgg_Http_Response
|
27 |
*/
|
28 |
public function setContent($content)
|
29 |
{
|
vendor/Rsc/Http/ServerParameters.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Http_ServerParameters extends RscSgg_Http_Parameters
|
5 |
{
|
6 |
|
7 |
/**
|
vendor/Rsc/Installer.php
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
/**
|
7 |
-
* @var
|
8 |
*/
|
9 |
private $parser;
|
10 |
|
11 |
/**
|
12 |
-
* @param
|
13 |
*/
|
14 |
-
public function __construct(
|
15 |
{
|
16 |
$this->parser = $parser;
|
17 |
}
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Installer
|
5 |
{
|
6 |
/**
|
7 |
+
* @var RscSgg_Installer_Parser
|
8 |
*/
|
9 |
private $parser;
|
10 |
|
11 |
/**
|
12 |
+
* @param RscSgg_Installer_Parser $parser
|
13 |
*/
|
14 |
+
public function __construct(RscSgg_Installer_Parser $parser)
|
15 |
{
|
16 |
$this->parser = $parser;
|
17 |
}
|
vendor/Rsc/Installer/Parser.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* Class
|
5 |
* Abstract parser
|
6 |
*/
|
7 |
-
abstract class
|
8 |
{
|
9 |
/**
|
10 |
* @var string
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* Class RscSgg_Installer_Parser
|
5 |
* Abstract parser
|
6 |
*/
|
7 |
+
abstract class RscSgg_Installer_Parser
|
8 |
{
|
9 |
/**
|
10 |
* @var string
|
vendor/Rsc/Installer/PhpParser.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
/**
|
7 |
* Checks whether the required resource is supported by selected parser
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Installer_PhpParser extends RscSgg_Installer_Parser
|
5 |
{
|
6 |
/**
|
7 |
* Checks whether the required resource is supported by selected parser
|
vendor/Rsc/Lang.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
@@ -20,7 +20,7 @@ class Rsc_Lang
|
|
20 |
protected $files;
|
21 |
|
22 |
/**
|
23 |
-
* @var
|
24 |
*/
|
25 |
protected $cache;
|
26 |
|
@@ -28,9 +28,9 @@ class Rsc_Lang
|
|
28 |
* Constructor
|
29 |
* @param null|string $domain Text domain
|
30 |
* @param null|string $path Path to the *.mo files
|
31 |
-
* @param
|
32 |
*/
|
33 |
-
public function __construct($domain = null, $path = null,
|
34 |
{
|
35 |
$this->domain = $domain;
|
36 |
$this->path = $path;
|
@@ -39,10 +39,10 @@ class Rsc_Lang
|
|
39 |
|
40 |
/**
|
41 |
* Set caching class
|
42 |
-
* @param \
|
43 |
-
* @return
|
44 |
*/
|
45 |
-
public function setCache(
|
46 |
{
|
47 |
$this->cache = $cache;
|
48 |
return $this;
|
@@ -50,7 +50,7 @@ class Rsc_Lang
|
|
50 |
|
51 |
/**
|
52 |
* Load text domain
|
53 |
-
* @throws
|
54 |
*/
|
55 |
public function loadTextDomain()
|
56 |
{
|
@@ -77,7 +77,7 @@ class Rsc_Lang
|
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
-
* Alias for
|
81 |
* @param string $msgid Message ID
|
82 |
* @return string|void
|
83 |
*/
|
@@ -139,7 +139,7 @@ class Rsc_Lang
|
|
139 |
/**
|
140 |
* Set text domain
|
141 |
* @param string $domain
|
142 |
-
* @return
|
143 |
*/
|
144 |
public function setDomain($domain)
|
145 |
{
|
@@ -159,7 +159,7 @@ class Rsc_Lang
|
|
159 |
/**
|
160 |
* Set domain path
|
161 |
* @param string $path
|
162 |
-
* @return
|
163 |
*/
|
164 |
public function setPath($path)
|
165 |
{
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Lang
|
5 |
{
|
6 |
|
7 |
/**
|
20 |
protected $files;
|
21 |
|
22 |
/**
|
23 |
+
* @var RscSgg_Cache_Interface
|
24 |
*/
|
25 |
protected $cache;
|
26 |
|
28 |
* Constructor
|
29 |
* @param null|string $domain Text domain
|
30 |
* @param null|string $path Path to the *.mo files
|
31 |
+
* @param RscSgg_Cache $cache Caching class
|
32 |
*/
|
33 |
+
public function __construct($domain = null, $path = null, RscSgg_Cache $cache = null)
|
34 |
{
|
35 |
$this->domain = $domain;
|
36 |
$this->path = $path;
|
39 |
|
40 |
/**
|
41 |
* Set caching class
|
42 |
+
* @param \RscSgg_Cache_Interface $cache
|
43 |
+
* @return RscSgg_Lang
|
44 |
*/
|
45 |
+
public function setCache(RscSgg_Cache_Interface $cache)
|
46 |
{
|
47 |
$this->cache = $cache;
|
48 |
return $this;
|
50 |
|
51 |
/**
|
52 |
* Load text domain
|
53 |
+
* @throws RscSgg_Exception_LangException If path or domain is not specified
|
54 |
*/
|
55 |
public function loadTextDomain()
|
56 |
{
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
+
* Alias for RscSgg_Lang::translate()
|
81 |
* @param string $msgid Message ID
|
82 |
* @return string|void
|
83 |
*/
|
139 |
/**
|
140 |
* Set text domain
|
141 |
* @param string $domain
|
142 |
+
* @return RscSgg_Lang
|
143 |
*/
|
144 |
public function setDomain($domain)
|
145 |
{
|
159 |
/**
|
160 |
* Set domain path
|
161 |
* @param string $path
|
162 |
+
* @return RscSgg_Lang
|
163 |
*/
|
164 |
public function setPath($path)
|
165 |
{
|
vendor/Rsc/Logger.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
@@ -23,7 +23,7 @@ class Rsc_Logger implements Rsc_Logger_Interface
|
|
23 |
* Sets the path to the log files.
|
24 |
*
|
25 |
* @param string $path Path to the log files
|
26 |
-
* @return
|
27 |
*/
|
28 |
public function setPath($path)
|
29 |
{
|
@@ -154,7 +154,7 @@ class Rsc_Logger implements Rsc_Logger_Interface
|
|
154 |
* @param mixed $level
|
155 |
* @param string $message
|
156 |
* @param array $context
|
157 |
-
* @throws
|
158 |
* @return null
|
159 |
*/
|
160 |
public function log($level, $message, array $context = array())
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Logger implements RscSgg_Logger_Interface
|
5 |
{
|
6 |
|
7 |
/**
|
23 |
* Sets the path to the log files.
|
24 |
*
|
25 |
* @param string $path Path to the log files
|
26 |
+
* @return RscSgg_Logger
|
27 |
*/
|
28 |
public function setPath($path)
|
29 |
{
|
154 |
* @param mixed $level
|
155 |
* @param string $message
|
156 |
* @param array $context
|
157 |
+
* @throws RscSgg_Logger_Exception_InvalidPathException If path is does not exists or does not writable
|
158 |
* @return null
|
159 |
*/
|
160 |
public function log($level, $message, array $context = array())
|
vendor/Rsc/Logger/AwareInterface.php
CHANGED
@@ -3,13 +3,13 @@
|
|
3 |
/**
|
4 |
* Describes a logger-aware instance
|
5 |
*/
|
6 |
-
interface
|
7 |
{
|
8 |
/**
|
9 |
* Sets a logger instance on the object
|
10 |
*
|
11 |
-
* @param
|
12 |
* @return null
|
13 |
*/
|
14 |
-
public function setLogger(
|
15 |
}
|
3 |
/**
|
4 |
* Describes a logger-aware instance
|
5 |
*/
|
6 |
+
interface RscSgg_Logger_AwareInterface
|
7 |
{
|
8 |
/**
|
9 |
* Sets a logger instance on the object
|
10 |
*
|
11 |
+
* @param RscSgg_Logger_Interface $logger
|
12 |
* @return null
|
13 |
*/
|
14 |
+
public function setLogger(RscSgg_Logger_Interface $logger);
|
15 |
}
|
vendor/Rsc/Logger/Exception/InvalidPathException.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* Class
|
5 |
*/
|
6 |
-
class
|
7 |
{
|
8 |
|
9 |
}
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* Class RscSgg_Logger_Exception_InvalidPathException
|
5 |
*/
|
6 |
+
class RscSgg_Logger_Exception_InvalidPathException extends RuntimeException
|
7 |
{
|
8 |
|
9 |
}
|
vendor/Rsc/Logger/Interface.php
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
|
16 |
* for the full interface specification.
|
17 |
*/
|
18 |
-
interface
|
19 |
{
|
20 |
/**
|
21 |
* System is unusable.
|
15 |
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
|
16 |
* for the full interface specification.
|
17 |
*/
|
18 |
+
interface RscSgg_Logger_Interface
|
19 |
{
|
20 |
/**
|
21 |
* System is unusable.
|
vendor/Rsc/Menu/Item.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
@@ -30,7 +30,7 @@ class Rsc_Menu_Item
|
|
30 |
protected $menuSlug;
|
31 |
|
32 |
/**
|
33 |
-
* @var
|
34 |
*/
|
35 |
protected $resolver;
|
36 |
|
@@ -47,9 +47,9 @@ class Rsc_Menu_Item
|
|
47 |
/**
|
48 |
* Constructor
|
49 |
* @param string $parentSlug
|
50 |
-
* @param
|
51 |
*/
|
52 |
-
public function __construct($parentSlug,
|
53 |
{
|
54 |
$this->parentSlug = $parentSlug;
|
55 |
$this->resolver = $resolver;
|
@@ -58,7 +58,7 @@ class Rsc_Menu_Item
|
|
58 |
/**
|
59 |
* Set the capability
|
60 |
* @param string $capability The capability required for this menu to be displayed to the user
|
61 |
-
* @return
|
62 |
*/
|
63 |
public function setCapability($capability)
|
64 |
{
|
@@ -78,7 +78,7 @@ class Rsc_Menu_Item
|
|
78 |
/**
|
79 |
* Set the menu slug
|
80 |
* @param string $menuSlug The slug name to refer to this menu by
|
81 |
-
* @return
|
82 |
*/
|
83 |
public function setMenuSlug($menuSlug)
|
84 |
{
|
@@ -98,7 +98,7 @@ class Rsc_Menu_Item
|
|
98 |
/**
|
99 |
* Set the menu title
|
100 |
* @param string $menuTitle The text to be used for the menu
|
101 |
-
* @return
|
102 |
*/
|
103 |
public function setMenuTitle($menuTitle)
|
104 |
{
|
@@ -118,7 +118,7 @@ class Rsc_Menu_Item
|
|
118 |
/**
|
119 |
* Set the page title
|
120 |
* @param string $pageTitle The text to be displayed in the title tags of the page when the menu is selected
|
121 |
-
* @return
|
122 |
*/
|
123 |
public function setPageTitle($pageTitle)
|
124 |
{
|
@@ -138,7 +138,7 @@ class Rsc_Menu_Item
|
|
138 |
/**
|
139 |
* Sets the module name
|
140 |
* @param string $moduleName
|
141 |
-
* @return
|
142 |
*/
|
143 |
public function setModuleName($moduleName)
|
144 |
{
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Menu_Item
|
5 |
{
|
6 |
|
7 |
/**
|
30 |
protected $menuSlug;
|
31 |
|
32 |
/**
|
33 |
+
* @var RscSgg_Resolver
|
34 |
*/
|
35 |
protected $resolver;
|
36 |
|
47 |
/**
|
48 |
* Constructor
|
49 |
* @param string $parentSlug
|
50 |
+
* @param RscSgg_Resolver $resolver
|
51 |
*/
|
52 |
+
public function __construct($parentSlug, RscSgg_Resolver $resolver)
|
53 |
{
|
54 |
$this->parentSlug = $parentSlug;
|
55 |
$this->resolver = $resolver;
|
58 |
/**
|
59 |
* Set the capability
|
60 |
* @param string $capability The capability required for this menu to be displayed to the user
|
61 |
+
* @return RscSgg_Menu_Item
|
62 |
*/
|
63 |
public function setCapability($capability)
|
64 |
{
|
78 |
/**
|
79 |
* Set the menu slug
|
80 |
* @param string $menuSlug The slug name to refer to this menu by
|
81 |
+
* @return RscSgg_Menu_Item
|
82 |
*/
|
83 |
public function setMenuSlug($menuSlug)
|
84 |
{
|
98 |
/**
|
99 |
* Set the menu title
|
100 |
* @param string $menuTitle The text to be used for the menu
|
101 |
+
* @return RscSgg_Menu_Item
|
102 |
*/
|
103 |
public function setMenuTitle($menuTitle)
|
104 |
{
|
118 |
/**
|
119 |
* Set the page title
|
120 |
* @param string $pageTitle The text to be displayed in the title tags of the page when the menu is selected
|
121 |
+
* @return RscSgg_Menu_Item
|
122 |
*/
|
123 |
public function setPageTitle($pageTitle)
|
124 |
{
|
138 |
/**
|
139 |
* Sets the module name
|
140 |
* @param string $moduleName
|
141 |
+
* @return RscSgg_Menu_Item
|
142 |
*/
|
143 |
public function setModuleName($moduleName)
|
144 |
{
|
vendor/Rsc/Menu/Page.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
-
* @var
|
9 |
*/
|
10 |
protected $resolver;
|
11 |
|
@@ -44,7 +44,7 @@ class Rsc_Menu_Page
|
|
44 |
*/
|
45 |
protected $submenu;
|
46 |
|
47 |
-
public function __construct(
|
48 |
{
|
49 |
$this->resolver = $resolver;
|
50 |
}
|
@@ -52,7 +52,7 @@ class Rsc_Menu_Page
|
|
52 |
/**
|
53 |
* Set the capability
|
54 |
* @param string $capability The capability required for this menu to be displayed to the user
|
55 |
-
* @return
|
56 |
*/
|
57 |
public function setCapability($capability)
|
58 |
{
|
@@ -72,7 +72,7 @@ class Rsc_Menu_Page
|
|
72 |
/**
|
73 |
* Set the icon url
|
74 |
* @param string $iconUrl The icon for this menu
|
75 |
-
* @return
|
76 |
*/
|
77 |
public function setIconUrl($iconUrl)
|
78 |
{
|
@@ -92,7 +92,7 @@ class Rsc_Menu_Page
|
|
92 |
/**
|
93 |
* Set the slug name
|
94 |
* @param string $menuSlug The slug name to refer to this menu by
|
95 |
-
* @return
|
96 |
*/
|
97 |
public function setMenuSlug($menuSlug)
|
98 |
{
|
@@ -112,7 +112,7 @@ class Rsc_Menu_Page
|
|
112 |
/**
|
113 |
* Set the menu title
|
114 |
* @param string $menuTitle The on-screen name text for the menu
|
115 |
-
* @return
|
116 |
*/
|
117 |
public function setMenuTitle($menuTitle)
|
118 |
{
|
@@ -132,7 +132,7 @@ class Rsc_Menu_Page
|
|
132 |
/**
|
133 |
* Set the page title
|
134 |
* @param string $pageTitle The text to be displayed in the title tags of the page when the menu is selected
|
135 |
-
* @return
|
136 |
*/
|
137 |
public function setPageTitle($pageTitle)
|
138 |
{
|
@@ -152,7 +152,7 @@ class Rsc_Menu_Page
|
|
152 |
/**
|
153 |
* Set the position
|
154 |
* @param int|string $position The position in the menu order this menu should appear
|
155 |
-
* @return
|
156 |
*/
|
157 |
public function setPosition($position)
|
158 |
{
|
@@ -172,19 +172,19 @@ class Rsc_Menu_Page
|
|
172 |
|
173 |
/**
|
174 |
* Create an instance of the submenu item class
|
175 |
-
* @return
|
176 |
*/
|
177 |
public function createSubmenuItem()
|
178 |
{
|
179 |
-
return new
|
180 |
}
|
181 |
|
182 |
/**
|
183 |
* @param string $handle The handle of the item
|
184 |
-
* @param
|
185 |
-
* @return
|
186 |
*/
|
187 |
-
public function addSubmenuItem($handle,
|
188 |
{
|
189 |
$this->submenu[$handle] = $submenu;
|
190 |
return $this;
|
@@ -208,7 +208,7 @@ class Rsc_Menu_Page
|
|
208 |
/**
|
209 |
* Returns an instance of the submenu item
|
210 |
* @param string $handle The handle of the submenu item
|
211 |
-
* @return null|
|
212 |
*/
|
213 |
public function getSubmenuItem($handle)
|
214 |
{
|
@@ -227,7 +227,7 @@ class Rsc_Menu_Page
|
|
227 |
add_action('admin_menu', array($this, 'addMenuPage'));
|
228 |
if(is_array($this->submenu) && count($this->submenu) > 0) {
|
229 |
usort($this->submenu, array($this, 'sortSubMenuItemsClb'));
|
230 |
-
/** @var
|
231 |
foreach ($this->submenu as $submenu) {
|
232 |
add_action('admin_menu', array($submenu, 'register'));
|
233 |
}
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Menu_Page
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
+
* @var RscSgg_Resolver
|
9 |
*/
|
10 |
protected $resolver;
|
11 |
|
44 |
*/
|
45 |
protected $submenu;
|
46 |
|
47 |
+
public function __construct(RscSgg_Resolver $resolver)
|
48 |
{
|
49 |
$this->resolver = $resolver;
|
50 |
}
|
52 |
/**
|
53 |
* Set the capability
|
54 |
* @param string $capability The capability required for this menu to be displayed to the user
|
55 |
+
* @return RscSgg_Menu_Page
|
56 |
*/
|
57 |
public function setCapability($capability)
|
58 |
{
|
72 |
/**
|
73 |
* Set the icon url
|
74 |
* @param string $iconUrl The icon for this menu
|
75 |
+
* @return RscSgg_Menu_Page
|
76 |
*/
|
77 |
public function setIconUrl($iconUrl)
|
78 |
{
|
92 |
/**
|
93 |
* Set the slug name
|
94 |
* @param string $menuSlug The slug name to refer to this menu by
|
95 |
+
* @return RscSgg_Menu_Page
|
96 |
*/
|
97 |
public function setMenuSlug($menuSlug)
|
98 |
{
|
112 |
/**
|
113 |
* Set the menu title
|
114 |
* @param string $menuTitle The on-screen name text for the menu
|
115 |
+
* @return RscSgg_Menu_Page
|
116 |
*/
|
117 |
public function setMenuTitle($menuTitle)
|
118 |
{
|
132 |
/**
|
133 |
* Set the page title
|
134 |
* @param string $pageTitle The text to be displayed in the title tags of the page when the menu is selected
|
135 |
+
* @return RscSgg_Menu_Page
|
136 |
*/
|
137 |
public function setPageTitle($pageTitle)
|
138 |
{
|
152 |
/**
|
153 |
* Set the position
|
154 |
* @param int|string $position The position in the menu order this menu should appear
|
155 |
+
* @return RscSgg_Menu_Page
|
156 |
*/
|
157 |
public function setPosition($position)
|
158 |
{
|
172 |
|
173 |
/**
|
174 |
* Create an instance of the submenu item class
|
175 |
+
* @return RscSgg_Menu_Item
|
176 |
*/
|
177 |
public function createSubmenuItem()
|
178 |
{
|
179 |
+
return new RscSgg_Menu_Item($this->menuSlug, $this->resolver);
|
180 |
}
|
181 |
|
182 |
/**
|
183 |
* @param string $handle The handle of the item
|
184 |
+
* @param RscSgg_Menu_Item $submenu An instance of the submenu item class
|
185 |
+
* @return RscSgg_Menu_Page
|
186 |
*/
|
187 |
+
public function addSubmenuItem($handle, RscSgg_Menu_Item $submenu)
|
188 |
{
|
189 |
$this->submenu[$handle] = $submenu;
|
190 |
return $this;
|
208 |
/**
|
209 |
* Returns an instance of the submenu item
|
210 |
* @param string $handle The handle of the submenu item
|
211 |
+
* @return null|RscSgg_Menu_Item
|
212 |
*/
|
213 |
public function getSubmenuItem($handle)
|
214 |
{
|
227 |
add_action('admin_menu', array($this, 'addMenuPage'));
|
228 |
if(is_array($this->submenu) && count($this->submenu) > 0) {
|
229 |
usort($this->submenu, array($this, 'sortSubMenuItemsClb'));
|
230 |
+
/** @var RscSgg_Menu_Item $submenu */
|
231 |
foreach ($this->submenu as $submenu) {
|
232 |
add_action('admin_menu', array($submenu, 'register'));
|
233 |
}
|
vendor/Rsc/Mvc/Controller.php
CHANGED
@@ -1,27 +1,27 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
-
* @var
|
9 |
*/
|
10 |
private $environment;
|
11 |
|
12 |
/**
|
13 |
-
* @var
|
14 |
*/
|
15 |
private $request;
|
16 |
|
17 |
/**
|
18 |
* Constructor
|
19 |
-
* @param
|
20 |
-
* @param
|
21 |
*/
|
22 |
public function __construct(
|
23 |
-
|
24 |
-
|
25 |
) {
|
26 |
$this->environment = $environment;
|
27 |
$this->request = $request;
|
@@ -52,11 +52,11 @@ class Rsc_Mvc_Controller
|
|
52 |
* Creates new response
|
53 |
* @param string $template The name of the template
|
54 |
* @param array $data An associative array of the data
|
55 |
-
* @return
|
56 |
*/
|
57 |
public function response($template, array $data = array())
|
58 |
{
|
59 |
-
if ($template !=
|
60 |
try {
|
61 |
$twig = $this->environment->getTwig();
|
62 |
$content = $twig->render($template, $data);
|
@@ -67,7 +67,7 @@ class Rsc_Mvc_Controller
|
|
67 |
wp_send_json($data);
|
68 |
}
|
69 |
|
70 |
-
return
|
71 |
}
|
72 |
|
73 |
/**
|
@@ -88,7 +88,7 @@ class Rsc_Mvc_Controller
|
|
88 |
/**
|
89 |
* Makes redirects to the specified URL
|
90 |
* @param string $url
|
91 |
-
* @return \
|
92 |
*/
|
93 |
public function redirect($url)
|
94 |
{
|
@@ -99,12 +99,12 @@ class Rsc_Mvc_Controller
|
|
99 |
|
100 |
$content = "<script type=\"text/javascript\">document.location.href = '$url'</script>";
|
101 |
|
102 |
-
return
|
103 |
}
|
104 |
|
105 |
/**
|
106 |
* Returns an instance of the environment
|
107 |
-
* @return \
|
108 |
*/
|
109 |
public function getEnvironment()
|
110 |
{
|
@@ -113,7 +113,7 @@ class Rsc_Mvc_Controller
|
|
113 |
|
114 |
/**
|
115 |
* Returns an instance of the current request
|
116 |
-
* @return \
|
117 |
*/
|
118 |
public function getRequest()
|
119 |
{
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Mvc_Controller
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
+
* @var RscSgg_Environment
|
9 |
*/
|
10 |
private $environment;
|
11 |
|
12 |
/**
|
13 |
+
* @var RscSgg_Http_Request
|
14 |
*/
|
15 |
private $request;
|
16 |
|
17 |
/**
|
18 |
* Constructor
|
19 |
+
* @param RscSgg_Environment $environment
|
20 |
+
* @param RscSgg_Http_Request $request
|
21 |
*/
|
22 |
public function __construct(
|
23 |
+
RscSgg_Environment $environment,
|
24 |
+
RscSgg_Http_Request $request
|
25 |
) {
|
26 |
$this->environment = $environment;
|
27 |
$this->request = $request;
|
52 |
* Creates new response
|
53 |
* @param string $template The name of the template
|
54 |
* @param array $data An associative array of the data
|
55 |
+
* @return RscSgg_Http_Response
|
56 |
*/
|
57 |
public function response($template, array $data = array())
|
58 |
{
|
59 |
+
if ($template != RscSgg_Http_Response::AJAX) {
|
60 |
try {
|
61 |
$twig = $this->environment->getTwig();
|
62 |
$content = $twig->render($template, $data);
|
67 |
wp_send_json($data);
|
68 |
}
|
69 |
|
70 |
+
return RscSgg_Http_Response::create()->setContent($content);
|
71 |
}
|
72 |
|
73 |
/**
|
88 |
/**
|
89 |
* Makes redirects to the specified URL
|
90 |
* @param string $url
|
91 |
+
* @return \RscSgg_Http_Response
|
92 |
*/
|
93 |
public function redirect($url)
|
94 |
{
|
99 |
|
100 |
$content = "<script type=\"text/javascript\">document.location.href = '$url'</script>";
|
101 |
|
102 |
+
return RscSgg_Http_Response::create()->setContent($content);
|
103 |
}
|
104 |
|
105 |
/**
|
106 |
* Returns an instance of the environment
|
107 |
+
* @return \RscSgg_Environment
|
108 |
*/
|
109 |
public function getEnvironment()
|
110 |
{
|
113 |
|
114 |
/**
|
115 |
* Returns an instance of the current request
|
116 |
+
* @return \RscSgg_Http_Request
|
117 |
*/
|
118 |
public function getRequest()
|
119 |
{
|
vendor/Rsc/Mvc/Model.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Mvc_Model
|
5 |
{
|
6 |
|
7 |
/**
|
vendor/Rsc/Mvc/Module.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
-
* @var
|
9 |
*/
|
10 |
private $environment;
|
11 |
|
@@ -20,12 +20,12 @@ class Rsc_Mvc_Module
|
|
20 |
private $namespace;
|
21 |
|
22 |
/**
|
23 |
-
* @var
|
24 |
*/
|
25 |
private $request;
|
26 |
|
27 |
/**
|
28 |
-
* @var
|
29 |
*/
|
30 |
private $controller;
|
31 |
|
@@ -36,11 +36,11 @@ class Rsc_Mvc_Module
|
|
36 |
|
37 |
/**
|
38 |
* Constructor.
|
39 |
-
* @param
|
40 |
* @param string $location Full path to the directory where is module
|
41 |
* @param string $namespace Module prefix
|
42 |
*/
|
43 |
-
public function __construct(
|
44 |
{
|
45 |
$this->environment = $environment;
|
46 |
$this->location = $location;
|
@@ -66,7 +66,7 @@ class Rsc_Mvc_Module
|
|
66 |
|
67 |
/**
|
68 |
* Returns an instance of the current environment
|
69 |
-
* @return
|
70 |
*/
|
71 |
public function getEnvironment()
|
72 |
{
|
@@ -116,7 +116,7 @@ class Rsc_Mvc_Module
|
|
116 |
|
117 |
/**
|
118 |
* Returns an instance of controller
|
119 |
-
* @return null|
|
120 |
*/
|
121 |
public function getController()
|
122 |
{
|
@@ -129,7 +129,7 @@ class Rsc_Mvc_Module
|
|
129 |
|
130 |
/**
|
131 |
* Returns the HTTP request to the module
|
132 |
-
* @return
|
133 |
*/
|
134 |
public function getRequest()
|
135 |
{
|
@@ -138,10 +138,10 @@ class Rsc_Mvc_Module
|
|
138 |
|
139 |
/**
|
140 |
* Set HTTP request to the module
|
141 |
-
* @param
|
142 |
-
* @return
|
143 |
*/
|
144 |
-
public function setRequest(
|
145 |
{
|
146 |
$this->request = $request;
|
147 |
return $this;
|
@@ -167,7 +167,7 @@ class Rsc_Mvc_Module
|
|
167 |
|
168 |
$twig = $this->environment->getTwig();
|
169 |
|
170 |
-
return
|
171 |
'controller' => $this->getModuleName(),
|
172 |
'action' => $action,
|
173 |
)));
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Mvc_Module
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
+
* @var RscSgg_Environment
|
9 |
*/
|
10 |
private $environment;
|
11 |
|
20 |
private $namespace;
|
21 |
|
22 |
/**
|
23 |
+
* @var RscSgg_Http_Request
|
24 |
*/
|
25 |
private $request;
|
26 |
|
27 |
/**
|
28 |
+
* @var RscSgg_Mvc_Controller
|
29 |
*/
|
30 |
private $controller;
|
31 |
|
36 |
|
37 |
/**
|
38 |
* Constructor.
|
39 |
+
* @param RscSgg_Environment $environment An instance of the current environment
|
40 |
* @param string $location Full path to the directory where is module
|
41 |
* @param string $namespace Module prefix
|
42 |
*/
|
43 |
+
public function __construct(RscSgg_Environment $environment, $location, $namespace)
|
44 |
{
|
45 |
$this->environment = $environment;
|
46 |
$this->location = $location;
|
66 |
|
67 |
/**
|
68 |
* Returns an instance of the current environment
|
69 |
+
* @return RscSgg_Environment
|
70 |
*/
|
71 |
public function getEnvironment()
|
72 |
{
|
116 |
|
117 |
/**
|
118 |
* Returns an instance of controller
|
119 |
+
* @return null|RscSgg_Mvc_Controller
|
120 |
*/
|
121 |
public function getController()
|
122 |
{
|
129 |
|
130 |
/**
|
131 |
* Returns the HTTP request to the module
|
132 |
+
* @return RscSgg_Http_Request
|
133 |
*/
|
134 |
public function getRequest()
|
135 |
{
|
138 |
|
139 |
/**
|
140 |
* Set HTTP request to the module
|
141 |
+
* @param RscSgg_Http_Request $request HTTP request
|
142 |
+
* @return RscSgg_Mvc_Module
|
143 |
*/
|
144 |
+
public function setRequest(RscSgg_Http_Request $request)
|
145 |
{
|
146 |
$this->request = $request;
|
147 |
return $this;
|
167 |
|
168 |
$twig = $this->environment->getTwig();
|
169 |
|
170 |
+
return RscSgg_Http_Response::create()->setContent($twig->render('404.twig', array(
|
171 |
'controller' => $this->getModuleName(),
|
172 |
'action' => $action,
|
173 |
)));
|
vendor/Rsc/Profiler.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Profiler
|
5 |
{
|
6 |
|
7 |
|
vendor/Rsc/Resolver.php
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
-
* @var
|
9 |
*/
|
10 |
private $environment;
|
11 |
|
12 |
/**
|
13 |
-
* @var
|
14 |
*/
|
15 |
protected $modules;
|
16 |
|
17 |
/**
|
18 |
-
* @var
|
19 |
*/
|
20 |
protected $request;
|
21 |
|
@@ -31,19 +31,19 @@ class Rsc_Resolver
|
|
31 |
|
32 |
/**
|
33 |
* Constructor
|
34 |
-
* @param
|
35 |
*/
|
36 |
-
public function __construct(
|
37 |
{
|
38 |
$this->environment = $environment;
|
39 |
-
$this->modules = new
|
40 |
-
$this->request = new
|
41 |
$this->routes = array();
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
* Returns an instance of environment
|
46 |
-
* @return
|
47 |
*/
|
48 |
public function getEnvironment()
|
49 |
{
|
@@ -52,7 +52,7 @@ class Rsc_Resolver
|
|
52 |
|
53 |
/**
|
54 |
* Returns the collection of the found modules
|
55 |
-
* @return
|
56 |
*/
|
57 |
public function getModules()
|
58 |
{
|
@@ -62,7 +62,7 @@ class Rsc_Resolver
|
|
62 |
public function setModules($modules)
|
63 |
{
|
64 |
if (is_array($modules)) {
|
65 |
-
$modules = new
|
66 |
}
|
67 |
|
68 |
$this->modules = $modules;
|
@@ -81,7 +81,7 @@ class Rsc_Resolver
|
|
81 |
{
|
82 |
$modules = $this->getModulesList();
|
83 |
|
84 |
-
/** @var
|
85 |
foreach ($modules as $name => $module) {
|
86 |
$module->onInstall();
|
87 |
}
|
@@ -97,7 +97,7 @@ class Rsc_Resolver
|
|
97 |
|
98 |
$modules = $this->getModulesList();
|
99 |
|
100 |
-
/** @var
|
101 |
foreach ($modules as $name => $instance) {
|
102 |
/* Set http request to the module */
|
103 |
$instance->setRequest($this->request)->onInit();
|
@@ -114,7 +114,7 @@ class Rsc_Resolver
|
|
114 |
|
115 |
/* We add module's location to the template & config loaders */
|
116 |
|
117 |
-
/** @var
|
118 |
try {
|
119 |
$loader = $this->environment->getTwig()->getLoader();
|
120 |
$loader->addPath($instance->getLocation() . '/views', strtolower($name));
|
@@ -130,7 +130,7 @@ class Rsc_Resolver
|
|
130 |
|
131 |
$loader->addPath($location . '/views', strtolower($name) . '_pro');
|
132 |
}
|
133 |
-
} catch (
|
134 |
|
135 |
$configLoader = $config->getLoader();
|
136 |
$configLoader->add($instance->getLocation() . '/configs', strtolower($name));
|
@@ -195,7 +195,7 @@ class Rsc_Resolver
|
|
195 |
|
196 |
try {
|
197 |
$twig->addPath($location . '/views', $name . '_pro');
|
198 |
-
} catch (
|
199 |
// Do nothing. Path does not exists.
|
200 |
}
|
201 |
|
@@ -217,7 +217,7 @@ class Rsc_Resolver
|
|
217 |
if (in_array($query->get('page'), array_keys($this->routes))) {
|
218 |
$name = $this->routes[$query->get('page')];
|
219 |
} else {
|
220 |
-
/** @var
|
221 |
$name = $query->get('module', $this->environment->getConfig()->get('default_module'));
|
222 |
}
|
223 |
|
@@ -225,10 +225,10 @@ class Rsc_Resolver
|
|
225 |
wp_die ('The module that you requested is not found');
|
226 |
}
|
227 |
|
228 |
-
/** @var
|
229 |
$response = $module = $this->modules->get(strtolower($name))->setRequest($this->request)->handle();
|
230 |
|
231 |
-
if (!is_object($response) || !$response instanceof
|
232 |
wp_die ('The controller must return the response');
|
233 |
}
|
234 |
|
@@ -281,7 +281,7 @@ class Rsc_Resolver
|
|
281 |
}
|
282 |
}
|
283 |
|
284 |
-
$this->modulesList = new
|
285 |
}
|
286 |
|
287 |
return $this->modulesList;
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSgg_Resolver
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
+
* @var RscSgg_Environment
|
9 |
*/
|
10 |
private $environment;
|
11 |
|
12 |
/**
|
13 |
+
* @var RscSgg_Common_Collection
|
14 |
*/
|
15 |
protected $modules;
|
16 |
|
17 |
/**
|
18 |
+
* @var RscSgg_Http_Request
|
19 |
*/
|
20 |
protected $request;
|
21 |
|
31 |
|
32 |
/**
|
33 |
* Constructor
|
34 |
+
* @param RscSgg_Environment $environment An instance of current environment
|
35 |
*/
|
36 |
+
public function __construct(RscSgg_Environment $environment)
|
37 |
{
|
38 |
$this->environment = $environment;
|
39 |
+
$this->modules = new RscSgg_Common_Collection();
|
40 |
+
$this->request = new RscSgg_Http_Request();
|
41 |
$this->routes = array();
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
* Returns an instance of environment
|
46 |
+
* @return RscSgg_Environment
|
47 |
*/
|
48 |
public function getEnvironment()
|
49 |
{
|
52 |
|
53 |
/**
|
54 |
* Returns the collection of the found modules
|
55 |
+
* @return RscSgg_Common_Collection
|
56 |
*/
|
57 |
public function getModules()
|
58 |
{
|
62 |
public function setModules($modules)
|
63 |
{
|
64 |
if (is_array($modules)) {
|
65 |
+
$modules = new RscSgg_Common_Collection($modules);
|
66 |
}
|
67 |
|
68 |
$this->modules = $modules;
|
81 |
{
|
82 |
$modules = $this->getModulesList();
|
83 |
|
84 |
+
/** @var RscSgg_Mvc_Module $module */
|
85 |
foreach ($modules as $name => $module) {
|
86 |
$module->onInstall();
|
87 |
}
|
97 |
|
98 |
$modules = $this->getModulesList();
|
99 |
|
100 |
+
/** @var RscSgg_Mvc_Module $instance */
|
101 |
foreach ($modules as $name => $instance) {
|
102 |
/* Set http request to the module */
|
103 |
$instance->setRequest($this->request)->onInit();
|
114 |
|
115 |
/* We add module's location to the template & config loaders */
|
116 |
|
117 |
+
/** @var Twig_SupTwgSgg_Loader_Filesystem $loader */
|
118 |
try {
|
119 |
$loader = $this->environment->getTwig()->getLoader();
|
120 |
$loader->addPath($instance->getLocation() . '/views', strtolower($name));
|
130 |
|
131 |
$loader->addPath($location . '/views', strtolower($name) . '_pro');
|
132 |
}
|
133 |
+
} catch (Twig_SupTwgSgg_Error_Loader $e) { }
|
134 |
|
135 |
$configLoader = $config->getLoader();
|
136 |
$configLoader->add($instance->getLocation() . '/configs', strtolower($name));
|
195 |
|
196 |
try {
|
197 |
$twig->addPath($location . '/views', $name . '_pro');
|
198 |
+
} catch (Twig_SupTwgSgg_Error_Loader $e) {
|
199 |
// Do nothing. Path does not exists.
|
200 |
}
|
201 |
|
217 |
if (in_array($query->get('page'), array_keys($this->routes))) {
|
218 |
$name = $this->routes[$query->get('page')];
|
219 |
} else {
|
220 |
+
/** @var RscSgg_Mvc_Module $module */
|
221 |
$name = $query->get('module', $this->environment->getConfig()->get('default_module'));
|
222 |
}
|
223 |
|
225 |
wp_die ('The module that you requested is not found');
|
226 |
}
|
227 |
|
228 |
+
/** @var RscSgg_Http_Response $response */
|
229 |
$response = $module = $this->modules->get(strtolower($name))->setRequest($this->request)->handle();
|
230 |
|
231 |
+
if (!is_object($response) || !$response instanceof RscSgg_Http_Response) {
|
232 |
wp_die ('The controller must return the response');
|
233 |
}
|
234 |
|
281 |
}
|
282 |
}
|
283 |
|
284 |
+
$this->modulesList = new RscSgg_Common_Collection($modulesList);
|
285 |
}
|
286 |
|
287 |
return $this->modulesList;
|
vendor/Twig/Autoloader.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
|
14 |
/**
|
15 |
* Autoloads Twig classes.
|
@@ -18,16 +18,16 @@
|
|
18 |
*
|
19 |
* @deprecated since 1.21 and will be removed in 2.0. Use Composer instead. 2.0.
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
/**
|
24 |
-
* Registers
|
25 |
*
|
26 |
* @param bool $prepend whether to prepend the autoloader or not
|
27 |
*/
|
28 |
public static function register($prepend = false)
|
29 |
{
|
30 |
-
|
31 |
|
32 |
if (PHP_VERSION_ID < 50300) {
|
33 |
spl_autoload_register(array(__CLASS__, 'autoload'));
|
@@ -43,7 +43,7 @@ class Twig_SupTwg_Autoloader
|
|
43 |
*/
|
44 |
public static function autoload($class)
|
45 |
{
|
46 |
-
if (0 !== strpos($class, '
|
47 |
return;
|
48 |
}
|
49 |
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
+
//@trigger_error('The Twig_SupTwgSgg_Autoloader class is deprecated since version 1.21 and will be removed in 2.0. Use Composer instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Autoloads Twig classes.
|
18 |
*
|
19 |
* @deprecated since 1.21 and will be removed in 2.0. Use Composer instead. 2.0.
|
20 |
*/
|
21 |
+
class Twig_SupTwgSgg_Autoloader
|
22 |
{
|
23 |
/**
|
24 |
+
* Registers Twig_SupTwgSgg_Autoloader as an SPL autoloader.
|
25 |
*
|
26 |
* @param bool $prepend whether to prepend the autoloader or not
|
27 |
*/
|
28 |
public static function register($prepend = false)
|
29 |
{
|
30 |
+
//@trigger_error('Using Twig_SupTwgSgg_Autoloader is deprecated since version 1.21. Use Composer instead.', E_USER_DEPRECATED);
|
31 |
|
32 |
if (PHP_VERSION_ID < 50300) {
|
33 |
spl_autoload_register(array(__CLASS__, 'autoload'));
|
43 |
*/
|
44 |
public static function autoload($class)
|
45 |
{
|
46 |
+
if (0 !== strpos($class, 'Twig_SupTwgSgg')) {
|
47 |
return;
|
48 |
}
|
49 |
|
vendor/Twig/BaseNodeVisitor.php
CHANGED
@@ -10,25 +10,25 @@
|
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
abstract class
|
18 |
{
|
19 |
-
final public function enterNode(
|
20 |
{
|
21 |
-
if (!$node instanceof
|
22 |
-
throw new LogicException('
|
23 |
}
|
24 |
|
25 |
return $this->doEnterNode($node, $env);
|
26 |
}
|
27 |
|
28 |
-
final public function leaveNode(
|
29 |
{
|
30 |
-
if (!$node instanceof
|
31 |
-
throw new LogicException('
|
32 |
}
|
33 |
|
34 |
return $this->doLeaveNode($node, $env);
|
@@ -37,14 +37,14 @@ abstract class Twig_SupTwg_BaseNodeVisitor implements Twig_SupTwg_NodeVisitorInt
|
|
37 |
/**
|
38 |
* Called before child nodes are visited.
|
39 |
*
|
40 |
-
* @return
|
41 |
*/
|
42 |
-
abstract protected function doEnterNode(
|
43 |
|
44 |
/**
|
45 |
* Called after child nodes are visited.
|
46 |
*
|
47 |
-
* @return
|
48 |
*/
|
49 |
-
abstract protected function doLeaveNode(
|
50 |
}
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
+
* Twig_SupTwgSgg_BaseNodeVisitor can be used to make node visitors compatible with Twig 1.x and 2.x.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
abstract class Twig_SupTwgSgg_BaseNodeVisitor implements Twig_SupTwgSgg_NodeVisitorInterface
|
18 |
{
|
19 |
+
final public function enterNode(Twig_SupTwgSgg_NodeInterface $node, Twig_SupTwgSgg_Environment $env)
|
20 |
{
|
21 |
+
if (!$node instanceof Twig_SupTwgSgg_Node) {
|
22 |
+
throw new LogicException('Twig_SupTwgSgg_BaseNodeVisitor only supports Twig_SupTwgSgg_Node instances.');
|
23 |
}
|
24 |
|
25 |
return $this->doEnterNode($node, $env);
|
26 |
}
|
27 |
|
28 |
+
final public function leaveNode(Twig_SupTwgSgg_NodeInterface $node, Twig_SupTwgSgg_Environment $env)
|
29 |
{
|
30 |
+
if (!$node instanceof Twig_SupTwgSgg_Node) {
|
31 |
+
throw new LogicException('Twig_SupTwgSgg_BaseNodeVisitor only supports Twig_SupTwgSgg_Node instances.');
|
32 |
}
|
33 |
|
34 |
return $this->doLeaveNode($node, $env);
|
37 |
/**
|
38 |
* Called before child nodes are visited.
|
39 |
*
|
40 |
+
* @return Twig_SupTwgSgg_Node The modified node
|
41 |
*/
|
42 |
+
abstract protected function doEnterNode(Twig_SupTwgSgg_Node $node, Twig_SupTwgSgg_Environment $env);
|
43 |
|
44 |
/**
|
45 |
* Called after child nodes are visited.
|
46 |
*
|
47 |
+
* @return Twig_SupTwgSgg_Node|false The modified node or false if the node must be removed
|
48 |
*/
|
49 |
+
abstract protected function doLeaveNode(Twig_SupTwgSgg_Node $node, Twig_SupTwgSgg_Environment $env);
|
50 |
}
|
vendor/Twig/Cache/Filesystem.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @author Andrew Tch <andrew@noop.lv>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
const FORCE_BYTECODE_INVALIDATION = 1;
|
20 |
|
14 |
*
|
15 |
* @author Andrew Tch <andrew@noop.lv>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Cache_Filesystem implements Twig_SupTwgSgg_CacheInterface
|
18 |
{
|
19 |
const FORCE_BYTECODE_INVALIDATION = 1;
|
20 |
|
vendor/Twig/Cache/Null.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
-
class
|
20 |
{
|
21 |
public function generateKey($name, $className)
|
22 |
{
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class Twig_SupTwgSgg_Cache_Null implements Twig_SupTwgSgg_CacheInterface
|
20 |
{
|
21 |
public function generateKey($name, $className)
|
22 |
{
|
vendor/Twig/CacheInterface.php
CHANGED
@@ -18,7 +18,7 @@
|
|
18 |
*
|
19 |
* @author Andrew Tch <andrew@noop.lv>
|
20 |
*/
|
21 |
-
interface
|
22 |
{
|
23 |
/**
|
24 |
* Generates a cache key for the given template class name.
|
18 |
*
|
19 |
* @author Andrew Tch <andrew@noop.lv>
|
20 |
*/
|
21 |
+
interface Twig_SupTwgSgg_CacheInterface
|
22 |
{
|
23 |
/**
|
24 |
* Generates a cache key for the given template class name.
|
vendor/Twig/Compiler.php
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
-
class
|
19 |
{
|
20 |
protected $lastLine;
|
21 |
protected $source;
|
@@ -26,7 +26,7 @@ class Twig_SupTwg_Compiler implements Twig_SupTwg_CompilerInterface
|
|
26 |
protected $sourceLine;
|
27 |
protected $filename;
|
28 |
|
29 |
-
public function __construct(
|
30 |
{
|
31 |
$this->env = $env;
|
32 |
}
|
@@ -36,7 +36,7 @@ class Twig_SupTwg_Compiler implements Twig_SupTwg_CompilerInterface
|
|
36 |
*/
|
37 |
public function getFilename()
|
38 |
{
|
39 |
-
|
40 |
|
41 |
return $this->filename;
|
42 |
}
|
@@ -44,7 +44,7 @@ class Twig_SupTwg_Compiler implements Twig_SupTwg_CompilerInterface
|
|
44 |
/**
|
45 |
* Returns the environment instance related to this compiler.
|
46 |
*
|
47 |
-
* @return
|
48 |
*/
|
49 |
public function getEnvironment()
|
50 |
{
|
@@ -64,12 +64,12 @@ class Twig_SupTwg_Compiler implements Twig_SupTwg_CompilerInterface
|
|
64 |
/**
|
65 |
* Compiles a node.
|
66 |
*
|
67 |
-
* @param
|
68 |
* @param int $indentation The current indentation
|
69 |
*
|
70 |
* @return $this
|
71 |
*/
|
72 |
-
public function compile(
|
73 |
{
|
74 |
$this->lastLine = null;
|
75 |
$this->source = '';
|
@@ -79,7 +79,7 @@ class Twig_SupTwg_Compiler implements Twig_SupTwg_CompilerInterface
|
|
79 |
$this->sourceLine = 1;
|
80 |
$this->indentation = $indentation;
|
81 |
|
82 |
-
if ($node instanceof
|
83 |
// to be removed in 2.0
|
84 |
$this->filename = $node->getTemplateName();
|
85 |
}
|
@@ -89,7 +89,7 @@ class Twig_SupTwg_Compiler implements Twig_SupTwg_CompilerInterface
|
|
89 |
return $this;
|
90 |
}
|
91 |
|
92 |
-
public function subcompile(
|
93 |
{
|
94 |
if (false === $raw) {
|
95 |
$this->source .= str_repeat(' ', $this->indentation * 4);
|
@@ -138,7 +138,7 @@ class Twig_SupTwg_Compiler implements Twig_SupTwg_CompilerInterface
|
|
138 |
*/
|
139 |
public function addIndentation()
|
140 |
{
|
141 |
-
|
142 |
|
143 |
$this->source .= str_repeat(' ', $this->indentation * 4);
|
144 |
|
@@ -207,7 +207,7 @@ class Twig_SupTwg_Compiler implements Twig_SupTwg_CompilerInterface
|
|
207 |
*
|
208 |
* @return $this
|
209 |
*/
|
210 |
-
public function addDebugInfo(
|
211 |
{
|
212 |
if ($node->getTemplateLine() != $this->lastLine) {
|
213 |
$this->write(sprintf("// line %d\n", $node->getTemplateLine()));
|
@@ -216,7 +216,7 @@ class Twig_SupTwg_Compiler implements Twig_SupTwg_CompilerInterface
|
|
216 |
// mb_substr_count() replaces substr_count()
|
217 |
// but they have different signatures!
|
218 |
if (((int) ini_get('mbstring.func_overload')) & 2) {
|
219 |
-
|
220 |
|
221 |
// this is much slower than the "right" version
|
222 |
$this->sourceLine += mb_substr_count(mb_substr($this->source, $this->sourceOffset), "\n");
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_SupTwgSgg_Compiler implements Twig_SupTwgSgg_CompilerInterface
|
19 |
{
|
20 |
protected $lastLine;
|
21 |
protected $source;
|
26 |
protected $sourceLine;
|
27 |
protected $filename;
|
28 |
|
29 |
+
public function __construct(Twig_SupTwgSgg_Environment $env)
|
30 |
{
|
31 |
$this->env = $env;
|
32 |
}
|
36 |
*/
|
37 |
public function getFilename()
|
38 |
{
|
39 |
+
//@trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED);
|
40 |
|
41 |
return $this->filename;
|
42 |
}
|
44 |
/**
|
45 |
* Returns the environment instance related to this compiler.
|
46 |
*
|
47 |
+
* @return Twig_SupTwgSgg_Environment
|
48 |
*/
|
49 |
public function getEnvironment()
|
50 |
{
|
64 |
/**
|
65 |
* Compiles a node.
|
66 |
*
|
67 |
+
* @param Twig_SupTwgSgg_NodeInterface $node The node to compile
|
68 |
* @param int $indentation The current indentation
|
69 |
*
|
70 |
* @return $this
|
71 |
*/
|
72 |
+
public function compile(Twig_SupTwgSgg_NodeInterface $node, $indentation = 0)
|
73 |
{
|
74 |
$this->lastLine = null;
|
75 |
$this->source = '';
|
79 |
$this->sourceLine = 1;
|
80 |
$this->indentation = $indentation;
|
81 |
|
82 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Module) {
|
83 |
// to be removed in 2.0
|
84 |
$this->filename = $node->getTemplateName();
|
85 |
}
|
89 |
return $this;
|
90 |
}
|
91 |
|
92 |
+
public function subcompile(Twig_SupTwgSgg_NodeInterface $node, $raw = true)
|
93 |
{
|
94 |
if (false === $raw) {
|
95 |
$this->source .= str_repeat(' ', $this->indentation * 4);
|
138 |
*/
|
139 |
public function addIndentation()
|
140 |
{
|
141 |
+
//@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use write(\'\') instead.', E_USER_DEPRECATED);
|
142 |
|
143 |
$this->source .= str_repeat(' ', $this->indentation * 4);
|
144 |
|
207 |
*
|
208 |
* @return $this
|
209 |
*/
|
210 |
+
public function addDebugInfo(Twig_SupTwgSgg_NodeInterface $node)
|
211 |
{
|
212 |
if ($node->getTemplateLine() != $this->lastLine) {
|
213 |
$this->write(sprintf("// line %d\n", $node->getTemplateLine()));
|
216 |
// mb_substr_count() replaces substr_count()
|
217 |
// but they have different signatures!
|
218 |
if (((int) ini_get('mbstring.func_overload')) & 2) {
|
219 |
+
//@trigger_error('Support for having "mbstring.func_overload" different from 0 is deprecated version 1.29 and will be removed in 2.0.', E_USER_DEPRECATED);
|
220 |
|
221 |
// this is much slower than the "right" version
|
222 |
$this->sourceLine += mb_substr_count(mb_substr($this->source, $this->sourceOffset), "\n");
|
vendor/Twig/CompilerInterface.php
CHANGED
@@ -16,14 +16,14 @@
|
|
16 |
*
|
17 |
* @deprecated since 1.12 (to be removed in 3.0)
|
18 |
*/
|
19 |
-
interface
|
20 |
{
|
21 |
/**
|
22 |
* Compiles a node.
|
23 |
*
|
24 |
* @return $this
|
25 |
*/
|
26 |
-
public function compile(
|
27 |
|
28 |
/**
|
29 |
* Gets the current PHP code after compilation.
|
16 |
*
|
17 |
* @deprecated since 1.12 (to be removed in 3.0)
|
18 |
*/
|
19 |
+
interface Twig_SupTwgSgg_CompilerInterface
|
20 |
{
|
21 |
/**
|
22 |
* Compiles a node.
|
23 |
*
|
24 |
* @return $this
|
25 |
*/
|
26 |
+
public function compile(Twig_SupTwgSgg_NodeInterface $node);
|
27 |
|
28 |
/**
|
29 |
* Gets the current PHP code after compilation.
|
vendor/Twig/ContainerRuntimeLoader.php
CHANGED
@@ -19,7 +19,7 @@ use Psr\Container\ContainerInterface;
|
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
* @author Robin Chalas <robin.chalas@gmail.com>
|
21 |
*/
|
22 |
-
class
|
23 |
{
|
24 |
private $container;
|
25 |
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
* @author Robin Chalas <robin.chalas@gmail.com>
|
21 |
*/
|
22 |
+
class Twig_SupTwgSgg_ContainerRuntimeLoader implements Twig_SupTwgSgg_RuntimeLoaderInterface
|
23 |
{
|
24 |
private $container;
|
25 |
|
vendor/Twig/Environment.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
const VERSION = '1.33.2';
|
20 |
const VERSION_ID = 13302;
|
@@ -70,10 +70,10 @@ class Twig_SupTwg_Environment
|
|
70 |
* * charset: The charset used by the templates (default to UTF-8).
|
71 |
*
|
72 |
* * base_template_class: The base template class to use for generated
|
73 |
-
* templates (default to
|
74 |
*
|
75 |
* * cache: An absolute path where to store the compiled templates,
|
76 |
-
* a
|
77 |
* or false to disable compilation cache (default).
|
78 |
*
|
79 |
* * auto_reload: Whether to reload the template if the original source changed.
|
@@ -94,21 +94,21 @@ class Twig_SupTwg_Environment
|
|
94 |
* (default to -1 which means that all optimizations are enabled;
|
95 |
* set it to 0 to disable).
|
96 |
*
|
97 |
-
* @param
|
98 |
* @param array $options An array of options
|
99 |
*/
|
100 |
-
public function __construct(
|
101 |
{
|
102 |
if (null !== $loader) {
|
103 |
$this->setLoader($loader);
|
104 |
} else {
|
105 |
-
|
106 |
}
|
107 |
|
108 |
$options = array_merge(array(
|
109 |
'debug' => false,
|
110 |
'charset' => 'UTF-8',
|
111 |
-
'base_template_class' => '
|
112 |
'strict_variables' => false,
|
113 |
'autoescape' => 'html',
|
114 |
'cache' => false,
|
@@ -123,23 +123,23 @@ class Twig_SupTwg_Environment
|
|
123 |
$this->strictVariables = (bool) $options['strict_variables'];
|
124 |
$this->setCache($options['cache']);
|
125 |
|
126 |
-
$this->addExtension(new
|
127 |
-
$this->addExtension(new
|
128 |
-
$this->addExtension(new
|
129 |
-
$this->staging = new
|
130 |
|
131 |
// For BC
|
132 |
if (is_string($this->originalCache)) {
|
133 |
$r = new ReflectionMethod($this, 'writeCacheFile');
|
134 |
if ($r->getDeclaringClass()->getName() !== __CLASS__) {
|
135 |
-
|
136 |
|
137 |
$this->bcWriteCacheFile = true;
|
138 |
}
|
139 |
|
140 |
$r = new ReflectionMethod($this, 'getCacheFilename');
|
141 |
if ($r->getDeclaringClass()->getName() !== __CLASS__) {
|
142 |
-
|
143 |
|
144 |
$this->bcGetCacheFilename = true;
|
145 |
}
|
@@ -254,7 +254,7 @@ class Twig_SupTwg_Environment
|
|
254 |
*
|
255 |
* @param bool $original Whether to return the original cache option or the real cache instance
|
256 |
*
|
257 |
-
* @return
|
258 |
* an absolute path to the compiled templates,
|
259 |
* or false to disable cache
|
260 |
*/
|
@@ -266,7 +266,7 @@ class Twig_SupTwg_Environment
|
|
266 |
/**
|
267 |
* Sets the current cache implementation.
|
268 |
*
|
269 |
-
* @param
|
270 |
* an absolute path to the compiled templates,
|
271 |
* or false to disable cache
|
272 |
*/
|
@@ -274,18 +274,18 @@ class Twig_SupTwg_Environment
|
|
274 |
{
|
275 |
if (is_string($cache)) {
|
276 |
$this->originalCache = $cache;
|
277 |
-
$this->cache = new
|
278 |
} elseif (false === $cache) {
|
279 |
$this->originalCache = $cache;
|
280 |
-
$this->cache = new
|
281 |
} elseif (null === $cache) {
|
282 |
-
|
283 |
$this->originalCache = false;
|
284 |
-
$this->cache = new
|
285 |
-
} elseif ($cache instanceof
|
286 |
$this->originalCache = $this->cache = $cache;
|
287 |
} else {
|
288 |
-
throw new LogicException(sprintf('Cache can only be a string, false, or a
|
289 |
}
|
290 |
}
|
291 |
|
@@ -300,7 +300,7 @@ class Twig_SupTwg_Environment
|
|
300 |
*/
|
301 |
public function getCacheFilename($name)
|
302 |
{
|
303 |
-
|
304 |
|
305 |
$key = $this->cache->generateKey($name, $this->getTemplateClass($name));
|
306 |
|
@@ -340,7 +340,7 @@ class Twig_SupTwg_Environment
|
|
340 |
*/
|
341 |
public function getTemplateClassPrefix()
|
342 |
{
|
343 |
-
|
344 |
|
345 |
return $this->templateClassPrefix;
|
346 |
}
|
@@ -353,9 +353,9 @@ class Twig_SupTwg_Environment
|
|
353 |
*
|
354 |
* @return string The rendered template
|
355 |
*
|
356 |
-
* @throws
|
357 |
-
* @throws
|
358 |
-
* @throws
|
359 |
*/
|
360 |
public function render($name, array $context = array())
|
361 |
{
|
@@ -368,9 +368,9 @@ class Twig_SupTwg_Environment
|
|
368 |
* @param string $name The template name
|
369 |
* @param array $context An array of parameters to pass to the template
|
370 |
*
|
371 |
-
* @throws
|
372 |
-
* @throws
|
373 |
-
* @throws
|
374 |
*/
|
375 |
public function display($name, array $context = array())
|
376 |
{
|
@@ -380,21 +380,21 @@ class Twig_SupTwg_Environment
|
|
380 |
/**
|
381 |
* Loads a template.
|
382 |
*
|
383 |
-
* @param string|
|
384 |
*
|
385 |
-
* @return
|
386 |
*/
|
387 |
public function load($name)
|
388 |
{
|
389 |
-
if ($name instanceof
|
390 |
return $name;
|
391 |
}
|
392 |
|
393 |
-
if ($name instanceof
|
394 |
-
return new
|
395 |
}
|
396 |
|
397 |
-
return new
|
398 |
}
|
399 |
|
400 |
/**
|
@@ -406,11 +406,11 @@ class Twig_SupTwg_Environment
|
|
406 |
* @param string $name The template name
|
407 |
* @param int $index The index if it is an embedded template
|
408 |
*
|
409 |
-
* @return
|
410 |
*
|
411 |
-
* @throws
|
412 |
-
* @throws
|
413 |
-
* @throws
|
414 |
*
|
415 |
* @internal
|
416 |
*/
|
@@ -438,8 +438,8 @@ class Twig_SupTwg_Environment
|
|
438 |
|
439 |
if (!class_exists($cls, false)) {
|
440 |
$loader = $this->getLoader();
|
441 |
-
if (!$loader instanceof
|
442 |
-
$source = new
|
443 |
} else {
|
444 |
$source = $loader->getSourceContext($name);
|
445 |
}
|
@@ -464,7 +464,7 @@ class Twig_SupTwg_Environment
|
|
464 |
}
|
465 |
|
466 |
if (!class_exists($cls, false)) {
|
467 |
-
throw new
|
468 |
}
|
469 |
}
|
470 |
|
@@ -482,17 +482,17 @@ class Twig_SupTwg_Environment
|
|
482 |
*
|
483 |
* @param string $template The template name
|
484 |
*
|
485 |
-
* @return
|
486 |
*
|
487 |
-
* @throws
|
488 |
-
* @throws
|
489 |
*/
|
490 |
public function createTemplate($template)
|
491 |
{
|
492 |
$name = sprintf('__string_template__%s', hash('sha256', uniqid(mt_rand(), true), false));
|
493 |
|
494 |
-
$loader = new
|
495 |
-
new
|
496 |
$current = $this->getLoader(),
|
497 |
));
|
498 |
|
@@ -542,15 +542,15 @@ class Twig_SupTwg_Environment
|
|
542 |
/**
|
543 |
* Tries to load a template consecutively from an array.
|
544 |
*
|
545 |
-
* Similar to loadTemplate() but it also accepts
|
546 |
* of templates where each is tried to be loaded.
|
547 |
*
|
548 |
-
* @param string|
|
549 |
*
|
550 |
-
* @return
|
551 |
*
|
552 |
-
* @throws
|
553 |
-
* @throws
|
554 |
*/
|
555 |
public function resolveTemplate($names)
|
556 |
{
|
@@ -559,13 +559,13 @@ class Twig_SupTwg_Environment
|
|
559 |
}
|
560 |
|
561 |
foreach ($names as $name) {
|
562 |
-
if ($name instanceof
|
563 |
return $name;
|
564 |
}
|
565 |
|
566 |
try {
|
567 |
return $this->loadTemplate($name);
|
568 |
-
} catch (
|
569 |
}
|
570 |
}
|
571 |
|
@@ -573,7 +573,7 @@ class Twig_SupTwg_Environment
|
|
573 |
throw $e;
|
574 |
}
|
575 |
|
576 |
-
throw new
|
577 |
}
|
578 |
|
579 |
/**
|
@@ -583,7 +583,7 @@ class Twig_SupTwg_Environment
|
|
583 |
*/
|
584 |
public function clearTemplateCache()
|
585 |
{
|
586 |
-
|
587 |
|
588 |
$this->loadedTemplates = array();
|
589 |
}
|
@@ -595,7 +595,7 @@ class Twig_SupTwg_Environment
|
|
595 |
*/
|
596 |
public function clearCacheFiles()
|
597 |
{
|
598 |
-
|
599 |
|
600 |
if (is_string($this->originalCache)) {
|
601 |
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->originalCache), RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
|
@@ -609,22 +609,22 @@ class Twig_SupTwg_Environment
|
|
609 |
/**
|
610 |
* Gets the Lexer instance.
|
611 |
*
|
612 |
-
* @return
|
613 |
*
|
614 |
* @deprecated since 1.25 (to be removed in 2.0)
|
615 |
*/
|
616 |
public function getLexer()
|
617 |
{
|
618 |
-
|
619 |
|
620 |
if (null === $this->lexer) {
|
621 |
-
$this->lexer = new
|
622 |
}
|
623 |
|
624 |
return $this->lexer;
|
625 |
}
|
626 |
|
627 |
-
public function setLexer(
|
628 |
{
|
629 |
$this->lexer = $lexer;
|
630 |
}
|
@@ -632,22 +632,22 @@ class Twig_SupTwg_Environment
|
|
632 |
/**
|
633 |
* Tokenizes a source code.
|
634 |
*
|
635 |
-
* @param string|
|
636 |
* @param string $name The template name (deprecated)
|
637 |
*
|
638 |
-
* @return
|
639 |
*
|
640 |
-
* @throws
|
641 |
*/
|
642 |
public function tokenize($source, $name = null)
|
643 |
{
|
644 |
-
if (!$source instanceof
|
645 |
-
|
646 |
-
$source = new
|
647 |
}
|
648 |
|
649 |
if (null === $this->lexer) {
|
650 |
-
$this->lexer = new
|
651 |
}
|
652 |
|
653 |
return $this->lexer->tokenize($source);
|
@@ -656,22 +656,22 @@ class Twig_SupTwg_Environment
|
|
656 |
/**
|
657 |
* Gets the Parser instance.
|
658 |
*
|
659 |
-
* @return
|
660 |
*
|
661 |
* @deprecated since 1.25 (to be removed in 2.0)
|
662 |
*/
|
663 |
public function getParser()
|
664 |
{
|
665 |
-
|
666 |
|
667 |
if (null === $this->parser) {
|
668 |
-
$this->parser = new
|
669 |
}
|
670 |
|
671 |
return $this->parser;
|
672 |
}
|
673 |
|
674 |
-
public function setParser(
|
675 |
{
|
676 |
$this->parser = $parser;
|
677 |
}
|
@@ -679,14 +679,14 @@ class Twig_SupTwg_Environment
|
|
679 |
/**
|
680 |
* Converts a token stream to a node tree.
|
681 |
*
|
682 |
-
* @return
|
683 |
*
|
684 |
-
* @throws
|
685 |
*/
|
686 |
-
public function parse(
|
687 |
{
|
688 |
if (null === $this->parser) {
|
689 |
-
$this->parser = new
|
690 |
}
|
691 |
|
692 |
return $this->parser->parse($stream);
|
@@ -695,22 +695,22 @@ class Twig_SupTwg_Environment
|
|
695 |
/**
|
696 |
* Gets the Compiler instance.
|
697 |
*
|
698 |
-
* @return
|
699 |
*
|
700 |
* @deprecated since 1.25 (to be removed in 2.0)
|
701 |
*/
|
702 |
public function getCompiler()
|
703 |
{
|
704 |
-
|
705 |
|
706 |
if (null === $this->compiler) {
|
707 |
-
$this->compiler = new
|
708 |
}
|
709 |
|
710 |
return $this->compiler;
|
711 |
}
|
712 |
|
713 |
-
public function setCompiler(
|
714 |
{
|
715 |
$this->compiler = $compiler;
|
716 |
}
|
@@ -720,10 +720,10 @@ class Twig_SupTwg_Environment
|
|
720 |
*
|
721 |
* @return string The compiled PHP source code
|
722 |
*/
|
723 |
-
public function compile(
|
724 |
{
|
725 |
if (null === $this->compiler) {
|
726 |
-
$this->compiler = new
|
727 |
}
|
728 |
|
729 |
return $this->compiler->compile($node)->getSource();
|
@@ -732,34 +732,34 @@ class Twig_SupTwg_Environment
|
|
732 |
/**
|
733 |
* Compiles a template source code.
|
734 |
*
|
735 |
-
* @param string|
|
736 |
* @param string $name The template name (deprecated)
|
737 |
*
|
738 |
* @return string The compiled PHP source code
|
739 |
*
|
740 |
-
* @throws
|
741 |
*/
|
742 |
public function compileSource($source, $name = null)
|
743 |
{
|
744 |
-
if (!$source instanceof
|
745 |
-
|
746 |
-
$source = new
|
747 |
}
|
748 |
|
749 |
try {
|
750 |
return $this->compile($this->parse($this->tokenize($source)));
|
751 |
-
} catch (
|
752 |
$e->setSourceContext($source);
|
753 |
throw $e;
|
754 |
} catch (Exception $e) {
|
755 |
-
throw new
|
756 |
}
|
757 |
}
|
758 |
|
759 |
-
public function setLoader(
|
760 |
{
|
761 |
-
if (!$loader instanceof
|
762 |
-
|
763 |
}
|
764 |
|
765 |
$this->loader = $loader;
|
@@ -768,7 +768,7 @@ class Twig_SupTwg_Environment
|
|
768 |
/**
|
769 |
* Gets the Loader instance.
|
770 |
*
|
771 |
-
* @return
|
772 |
*/
|
773 |
public function getLoader()
|
774 |
{
|
@@ -809,11 +809,11 @@ class Twig_SupTwg_Environment
|
|
809 |
$this->runtimeInitialized = true;
|
810 |
|
811 |
foreach ($this->getExtensions() as $name => $extension) {
|
812 |
-
if (!$extension instanceof
|
813 |
$m = new ReflectionMethod($extension, 'initRuntime');
|
814 |
|
815 |
-
if ('
|
816 |
-
|
817 |
}
|
818 |
}
|
819 |
|
@@ -833,7 +833,7 @@ class Twig_SupTwg_Environment
|
|
833 |
$class = ltrim($class, '\\');
|
834 |
if (isset($this->extensions[$class])) {
|
835 |
if ($class !== get_class($this->extensions[$class])) {
|
836 |
-
|
837 |
}
|
838 |
|
839 |
return true;
|
@@ -845,7 +845,7 @@ class Twig_SupTwg_Environment
|
|
845 |
/**
|
846 |
* Adds a runtime loader.
|
847 |
*/
|
848 |
-
public function addRuntimeLoader(
|
849 |
{
|
850 |
$this->runtimeLoaders[] = $loader;
|
851 |
}
|
@@ -855,7 +855,7 @@ class Twig_SupTwg_Environment
|
|
855 |
*
|
856 |
* @param string $class The extension class name
|
857 |
*
|
858 |
-
* @return
|
859 |
*/
|
860 |
public function getExtension($class)
|
861 |
{
|
@@ -863,14 +863,14 @@ class Twig_SupTwg_Environment
|
|
863 |
|
864 |
if (isset($this->extensions[$class])) {
|
865 |
if ($class !== get_class($this->extensions[$class])) {
|
866 |
-
|
867 |
}
|
868 |
|
869 |
return $this->extensions[$class];
|
870 |
}
|
871 |
|
872 |
if (!isset($this->extensionsByClass[$class])) {
|
873 |
-
throw new
|
874 |
}
|
875 |
|
876 |
return $this->extensionsByClass[$class];
|
@@ -883,7 +883,7 @@ class Twig_SupTwg_Environment
|
|
883 |
*
|
884 |
* @return object The runtime implementation
|
885 |
*
|
886 |
-
* @throws
|
887 |
*/
|
888 |
public function getRuntime($class)
|
889 |
{
|
@@ -897,10 +897,10 @@ class Twig_SupTwg_Environment
|
|
897 |
}
|
898 |
}
|
899 |
|
900 |
-
throw new
|
901 |
}
|
902 |
|
903 |
-
public function addExtension(
|
904 |
{
|
905 |
if ($this->extensionInitialized) {
|
906 |
throw new LogicException(sprintf('Unable to register extension "%s" as extensions have already been initialized.', $extension->getName()));
|
@@ -910,7 +910,7 @@ class Twig_SupTwg_Environment
|
|
910 |
if ($class !== $extension->getName()) {
|
911 |
if (isset($this->extensions[$extension->getName()])) {
|
912 |
unset($this->extensions[$extension->getName()], $this->extensionsByClass[$class]);
|
913 |
-
|
914 |
}
|
915 |
}
|
916 |
|
@@ -931,7 +931,7 @@ class Twig_SupTwg_Environment
|
|
931 |
*/
|
932 |
public function removeExtension($name)
|
933 |
{
|
934 |
-
|
935 |
|
936 |
if ($this->extensionInitialized) {
|
937 |
throw new LogicException(sprintf('Unable to remove extension "%s" as extensions have already been initialized.', $name));
|
@@ -940,7 +940,7 @@ class Twig_SupTwg_Environment
|
|
940 |
$class = ltrim($name, '\\');
|
941 |
if (isset($this->extensions[$class])) {
|
942 |
if ($class !== get_class($this->extensions[$class])) {
|
943 |
-
|
944 |
}
|
945 |
|
946 |
unset($this->extensions[$class]);
|
@@ -965,14 +965,14 @@ class Twig_SupTwg_Environment
|
|
965 |
/**
|
966 |
* Returns all registered extensions.
|
967 |
*
|
968 |
-
* @return
|
969 |
*/
|
970 |
public function getExtensions()
|
971 |
{
|
972 |
return $this->extensions;
|
973 |
}
|
974 |
|
975 |
-
public function addTokenParser(
|
976 |
{
|
977 |
if ($this->extensionInitialized) {
|
978 |
throw new LogicException('Unable to add a token parser as extensions have already been initialized.');
|
@@ -984,7 +984,7 @@ class Twig_SupTwg_Environment
|
|
984 |
/**
|
985 |
* Gets the registered Token Parsers.
|
986 |
*
|
987 |
-
* @return
|
988 |
*
|
989 |
* @internal
|
990 |
*/
|
@@ -1000,9 +1000,9 @@ class Twig_SupTwg_Environment
|
|
1000 |
/**
|
1001 |
* Gets registered tags.
|
1002 |
*
|
1003 |
-
* Be warned that this method cannot return tags defined by
|
1004 |
*
|
1005 |
-
* @return
|
1006 |
*
|
1007 |
* @internal
|
1008 |
*/
|
@@ -1010,7 +1010,7 @@ class Twig_SupTwg_Environment
|
|
1010 |
{
|
1011 |
$tags = array();
|
1012 |
foreach ($this->getTokenParsers()->getParsers() as $parser) {
|
1013 |
-
if ($parser instanceof
|
1014 |
$tags[$parser->getTag()] = $parser;
|
1015 |
}
|
1016 |
}
|
@@ -1018,7 +1018,7 @@ class Twig_SupTwg_Environment
|
|
1018 |
return $tags;
|
1019 |
}
|
1020 |
|
1021 |
-
public function addNodeVisitor(
|
1022 |
{
|
1023 |
if ($this->extensionInitialized) {
|
1024 |
throw new LogicException('Unable to add a node visitor as extensions have already been initialized.');
|
@@ -1030,7 +1030,7 @@ class Twig_SupTwg_Environment
|
|
1030 |
/**
|
1031 |
* Gets the registered Node Visitors.
|
1032 |
*
|
1033 |
-
* @return
|
1034 |
*
|
1035 |
* @internal
|
1036 |
*/
|
@@ -1046,20 +1046,20 @@ class Twig_SupTwg_Environment
|
|
1046 |
/**
|
1047 |
* Registers a Filter.
|
1048 |
*
|
1049 |
-
* @param string|
|
1050 |
-
* @param
|
1051 |
*/
|
1052 |
public function addFilter($name, $filter = null)
|
1053 |
{
|
1054 |
-
if (!$name instanceof
|
1055 |
-
throw new LogicException('A filter must be an instance of
|
1056 |
}
|
1057 |
|
1058 |
-
if ($name instanceof
|
1059 |
$filter = $name;
|
1060 |
$name = $filter->getName();
|
1061 |
} else {
|
1062 |
-
|
1063 |
}
|
1064 |
|
1065 |
if ($this->extensionInitialized) {
|
@@ -1077,7 +1077,7 @@ class Twig_SupTwg_Environment
|
|
1077 |
*
|
1078 |
* @param string $name The filter name
|
1079 |
*
|
1080 |
-
* @return
|
1081 |
*
|
1082 |
* @internal
|
1083 |
*/
|
@@ -1123,7 +1123,7 @@ class Twig_SupTwg_Environment
|
|
1123 |
*
|
1124 |
* Be warned that this method cannot return filters defined with registerUndefinedFilterCallback.
|
1125 |
*
|
1126 |
-
* @return
|
1127 |
*
|
1128 |
* @see registerUndefinedFilterCallback
|
1129 |
*
|
@@ -1141,20 +1141,20 @@ class Twig_SupTwg_Environment
|
|
1141 |
/**
|
1142 |
* Registers a Test.
|
1143 |
*
|
1144 |
-
* @param string|
|
1145 |
-
* @param
|
1146 |
*/
|
1147 |
public function addTest($name, $test = null)
|
1148 |
{
|
1149 |
-
if (!$name instanceof
|
1150 |
-
throw new LogicException('A test must be an instance of
|
1151 |
}
|
1152 |
|
1153 |
-
if ($name instanceof
|
1154 |
$test = $name;
|
1155 |
$name = $test->getName();
|
1156 |
} else {
|
1157 |
-
|
1158 |
}
|
1159 |
|
1160 |
if ($this->extensionInitialized) {
|
@@ -1167,7 +1167,7 @@ class Twig_SupTwg_Environment
|
|
1167 |
/**
|
1168 |
* Gets the registered Tests.
|
1169 |
*
|
1170 |
-
* @return
|
1171 |
*
|
1172 |
* @internal
|
1173 |
*/
|
@@ -1185,7 +1185,7 @@ class Twig_SupTwg_Environment
|
|
1185 |
*
|
1186 |
* @param string $name The test name
|
1187 |
*
|
1188 |
-
* @return
|
1189 |
*
|
1190 |
* @internal
|
1191 |
*/
|
@@ -1205,20 +1205,20 @@ class Twig_SupTwg_Environment
|
|
1205 |
/**
|
1206 |
* Registers a Function.
|
1207 |
*
|
1208 |
-
* @param string|
|
1209 |
-
* @param
|
1210 |
*/
|
1211 |
public function addFunction($name, $function = null)
|
1212 |
{
|
1213 |
-
if (!$name instanceof
|
1214 |
-
throw new LogicException('A function must be an instance of
|
1215 |
}
|
1216 |
|
1217 |
-
if ($name instanceof
|
1218 |
$function = $name;
|
1219 |
$name = $function->getName();
|
1220 |
} else {
|
1221 |
-
|
1222 |
}
|
1223 |
|
1224 |
if ($this->extensionInitialized) {
|
@@ -1236,7 +1236,7 @@ class Twig_SupTwg_Environment
|
|
1236 |
*
|
1237 |
* @param string $name function name
|
1238 |
*
|
1239 |
-
* @return
|
1240 |
*
|
1241 |
* @internal
|
1242 |
*/
|
@@ -1282,7 +1282,7 @@ class Twig_SupTwg_Environment
|
|
1282 |
*
|
1283 |
* Be warned that this method cannot return functions defined with registerUndefinedFunctionCallback.
|
1284 |
*
|
1285 |
-
* @return
|
1286 |
*
|
1287 |
* @see registerUndefinedFunctionCallback
|
1288 |
*
|
@@ -1315,7 +1315,7 @@ class Twig_SupTwg_Environment
|
|
1315 |
|
1316 |
if (!array_key_exists($name, $this->globals)) {
|
1317 |
// The deprecation notice must be turned into the following exception in Twig 2.0
|
1318 |
-
|
1319 |
//throw new LogicException(sprintf('Unable to add global "%s" as the runtime or the extensions have already been initialized.', $name));
|
1320 |
}
|
1321 |
}
|
@@ -1405,9 +1405,9 @@ class Twig_SupTwg_Environment
|
|
1405 |
*/
|
1406 |
public function computeAlternatives($name, $items)
|
1407 |
{
|
1408 |
-
|
1409 |
|
1410 |
-
return
|
1411 |
}
|
1412 |
|
1413 |
/**
|
@@ -1417,11 +1417,11 @@ class Twig_SupTwg_Environment
|
|
1417 |
{
|
1418 |
$globals = array();
|
1419 |
foreach ($this->extensions as $name => $extension) {
|
1420 |
-
if (!$extension instanceof
|
1421 |
$m = new ReflectionMethod($extension, 'getGlobals');
|
1422 |
|
1423 |
-
if ('
|
1424 |
-
|
1425 |
}
|
1426 |
}
|
1427 |
|
@@ -1447,7 +1447,7 @@ class Twig_SupTwg_Environment
|
|
1447 |
return;
|
1448 |
}
|
1449 |
|
1450 |
-
$this->parsers = new
|
1451 |
$this->filters = array();
|
1452 |
$this->functions = array();
|
1453 |
$this->tests = array();
|
@@ -1466,14 +1466,14 @@ class Twig_SupTwg_Environment
|
|
1466 |
/**
|
1467 |
* @internal
|
1468 |
*/
|
1469 |
-
protected function initExtension(
|
1470 |
{
|
1471 |
// filters
|
1472 |
foreach ($extension->getFilters() as $name => $filter) {
|
1473 |
-
if ($filter instanceof
|
1474 |
$name = $filter->getName();
|
1475 |
} else {
|
1476 |
-
|
1477 |
}
|
1478 |
|
1479 |
$this->filters[$name] = $filter;
|
@@ -1481,10 +1481,10 @@ class Twig_SupTwg_Environment
|
|
1481 |
|
1482 |
// functions
|
1483 |
foreach ($extension->getFunctions() as $name => $function) {
|
1484 |
-
if ($function instanceof
|
1485 |
$name = $function->getName();
|
1486 |
} else {
|
1487 |
-
|
1488 |
}
|
1489 |
|
1490 |
$this->functions[$name] = $function;
|
@@ -1492,10 +1492,10 @@ class Twig_SupTwg_Environment
|
|
1492 |
|
1493 |
// tests
|
1494 |
foreach ($extension->getTests() as $name => $test) {
|
1495 |
-
if ($test instanceof
|
1496 |
$name = $test->getName();
|
1497 |
} else {
|
1498 |
-
|
1499 |
}
|
1500 |
|
1501 |
$this->tests[$name] = $test;
|
@@ -1503,14 +1503,14 @@ class Twig_SupTwg_Environment
|
|
1503 |
|
1504 |
// token parsers
|
1505 |
foreach ($extension->getTokenParsers() as $parser) {
|
1506 |
-
if ($parser instanceof
|
1507 |
$this->parsers->addTokenParser($parser);
|
1508 |
-
} elseif ($parser instanceof
|
1509 |
-
|
1510 |
|
1511 |
$this->parsers->addTokenParserBroker($parser);
|
1512 |
} else {
|
1513 |
-
throw new LogicException('getTokenParsers() must return an array of
|
1514 |
}
|
1515 |
}
|
1516 |
|
@@ -1547,7 +1547,7 @@ class Twig_SupTwg_Environment
|
|
1547 |
$hashParts = array_merge(
|
1548 |
array_keys($this->extensions),
|
1549 |
array(
|
1550 |
-
(int) function_exists('
|
1551 |
PHP_MAJOR_VERSION,
|
1552 |
PHP_MINOR_VERSION,
|
1553 |
self::VERSION,
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Environment
|
18 |
{
|
19 |
const VERSION = '1.33.2';
|
20 |
const VERSION_ID = 13302;
|
70 |
* * charset: The charset used by the templates (default to UTF-8).
|
71 |
*
|
72 |
* * base_template_class: The base template class to use for generated
|
73 |
+
* templates (default to Twig_SupTwgSgg_Template).
|
74 |
*
|
75 |
* * cache: An absolute path where to store the compiled templates,
|
76 |
+
* a Twig_SupTwgSgg_Cache_Interface implementation,
|
77 |
* or false to disable compilation cache (default).
|
78 |
*
|
79 |
* * auto_reload: Whether to reload the template if the original source changed.
|
94 |
* (default to -1 which means that all optimizations are enabled;
|
95 |
* set it to 0 to disable).
|
96 |
*
|
97 |
+
* @param Twig_SupTwgSgg_LoaderInterface $loader
|
98 |
* @param array $options An array of options
|
99 |
*/
|
100 |
+
public function __construct(Twig_SupTwgSgg_LoaderInterface $loader = null, $options = array())
|
101 |
{
|
102 |
if (null !== $loader) {
|
103 |
$this->setLoader($loader);
|
104 |
} else {
|
105 |
+
//@trigger_error('Not passing a Twig_SupTwgSgg_LoaderInterface as the first constructor argument of Twig_SupTwgSgg_Environment is deprecated since version 1.21.', E_USER_DEPRECATED);
|
106 |
}
|
107 |
|
108 |
$options = array_merge(array(
|
109 |
'debug' => false,
|
110 |
'charset' => 'UTF-8',
|
111 |
+
'base_template_class' => 'Twig_SupTwgSgg_Template',
|
112 |
'strict_variables' => false,
|
113 |
'autoescape' => 'html',
|
114 |
'cache' => false,
|
123 |
$this->strictVariables = (bool) $options['strict_variables'];
|
124 |
$this->setCache($options['cache']);
|
125 |
|
126 |
+
$this->addExtension(new Twig_SupTwgSgg_Extension_Core());
|
127 |
+
$this->addExtension(new Twig_SupTwgSgg_Extension_Escaper($options['autoescape']));
|
128 |
+
$this->addExtension(new Twig_SupTwgSgg_Extension_Optimizer($options['optimizations']));
|
129 |
+
$this->staging = new Twig_SupTwgSgg_Extension_Staging();
|
130 |
|
131 |
// For BC
|
132 |
if (is_string($this->originalCache)) {
|
133 |
$r = new ReflectionMethod($this, 'writeCacheFile');
|
134 |
if ($r->getDeclaringClass()->getName() !== __CLASS__) {
|
135 |
+
//@trigger_error('The Twig_SupTwgSgg_Environment::writeCacheFile method is deprecated since version 1.22 and will be removed in Twig 2.0.', E_USER_DEPRECATED);
|
136 |
|
137 |
$this->bcWriteCacheFile = true;
|
138 |
}
|
139 |
|
140 |
$r = new ReflectionMethod($this, 'getCacheFilename');
|
141 |
if ($r->getDeclaringClass()->getName() !== __CLASS__) {
|
142 |
+
//@trigger_error('The Twig_SupTwgSgg_Environment::getCacheFilename method is deprecated since version 1.22 and will be removed in Twig 2.0.', E_USER_DEPRECATED);
|
143 |
|
144 |
$this->bcGetCacheFilename = true;
|
145 |
}
|
254 |
*
|
255 |
* @param bool $original Whether to return the original cache option or the real cache instance
|
256 |
*
|
257 |
+
* @return Twig_SupTwgSgg_CacheInterface|string|false A Twig_SupTwgSgg_CacheInterface implementation,
|
258 |
* an absolute path to the compiled templates,
|
259 |
* or false to disable cache
|
260 |
*/
|
266 |
/**
|
267 |
* Sets the current cache implementation.
|
268 |
*
|
269 |
+
* @param Twig_SupTwgSgg_CacheInterface|string|false $cache A Twig_SupTwgSgg_CacheInterface implementation,
|
270 |
* an absolute path to the compiled templates,
|
271 |
* or false to disable cache
|
272 |
*/
|
274 |
{
|
275 |
if (is_string($cache)) {
|
276 |
$this->originalCache = $cache;
|
277 |
+
$this->cache = new Twig_SupTwgSgg_Cache_Filesystem($cache);
|
278 |
} elseif (false === $cache) {
|
279 |
$this->originalCache = $cache;
|
280 |
+
$this->cache = new Twig_SupTwgSgg_Cache_Null();
|
281 |
} elseif (null === $cache) {
|
282 |
+
//@trigger_error('Using "null" as the cache strategy is deprecated since version 1.23 and will be removed in Twig 2.0.', E_USER_DEPRECATED);
|
283 |
$this->originalCache = false;
|
284 |
+
$this->cache = new Twig_SupTwgSgg_Cache_Null();
|
285 |
+
} elseif ($cache instanceof Twig_SupTwgSgg_CacheInterface) {
|
286 |
$this->originalCache = $this->cache = $cache;
|
287 |
} else {
|
288 |
+
throw new LogicException(sprintf('Cache can only be a string, false, or a Twig_SupTwgSgg_CacheInterface implementation.'));
|
289 |
}
|
290 |
}
|
291 |
|
300 |
*/
|
301 |
public function getCacheFilename($name)
|
302 |
{
|
303 |
+
//@trigger_error(sprintf('The %s method is deprecated since version 1.22 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
|
304 |
|
305 |
$key = $this->cache->generateKey($name, $this->getTemplateClass($name));
|
306 |
|
340 |
*/
|
341 |
public function getTemplateClassPrefix()
|
342 |
{
|
343 |
+
//@trigger_error(sprintf('The %s method is deprecated since version 1.22 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
|
344 |
|
345 |
return $this->templateClassPrefix;
|
346 |
}
|
353 |
*
|
354 |
* @return string The rendered template
|
355 |
*
|
356 |
+
* @throws Twig_SupTwgSgg_Error_Loader When the template cannot be found
|
357 |
+
* @throws Twig_SupTwgSgg_Error_Syntax When an error occurred during compilation
|
358 |
+
* @throws Twig_SupTwgSgg_Error_Runtime When an error occurred during rendering
|
359 |
*/
|
360 |
public function render($name, array $context = array())
|
361 |
{
|
368 |
* @param string $name The template name
|
369 |
* @param array $context An array of parameters to pass to the template
|
370 |
*
|
371 |
+
* @throws Twig_SupTwgSgg_Error_Loader When the template cannot be found
|
372 |
+
* @throws Twig_SupTwgSgg_Error_Syntax When an error occurred during compilation
|
373 |
+
* @throws Twig_SupTwgSgg_Error_Runtime When an error occurred during rendering
|
374 |
*/
|
375 |
public function display($name, array $context = array())
|
376 |
{
|
380 |
/**
|
381 |
* Loads a template.
|
382 |
*
|
383 |
+
* @param string|Twig_SupTwgSgg_TemplateWrapper|Twig_SupTwgSgg_Template $name The template name
|
384 |
*
|
385 |
+
* @return Twig_SupTwgSgg_TemplateWrapper
|
386 |
*/
|
387 |
public function load($name)
|
388 |
{
|
389 |
+
if ($name instanceof Twig_SupTwgSgg_TemplateWrapper) {
|
390 |
return $name;
|
391 |
}
|
392 |
|
393 |
+
if ($name instanceof Twig_SupTwgSgg_Template) {
|
394 |
+
return new Twig_SupTwgSgg_TemplateWrapper($this, $name);
|
395 |
}
|
396 |
|
397 |
+
return new Twig_SupTwgSgg_TemplateWrapper($this, $this->loadTemplate($name));
|
398 |
}
|
399 |
|
400 |
/**
|
406 |
* @param string $name The template name
|
407 |
* @param int $index The index if it is an embedded template
|
408 |
*
|
409 |
+
* @return Twig_SupTwgSgg_TemplateInterface A template instance representing the given template name
|
410 |
*
|
411 |
+
* @throws Twig_SupTwgSgg_Error_Loader When the template cannot be found
|
412 |
+
* @throws Twig_SupTwgSgg_Error_Runtime When a previously generated cache is corrupted
|
413 |
+
* @throws Twig_SupTwgSgg_Error_Syntax When an error occurred during compilation
|
414 |
*
|
415 |
* @internal
|
416 |
*/
|
438 |
|
439 |
if (!class_exists($cls, false)) {
|
440 |
$loader = $this->getLoader();
|
441 |
+
if (!$loader instanceof Twig_SupTwgSgg_SourceContextLoaderInterface) {
|
442 |
+
$source = new Twig_SupTwgSgg_Source($loader->getSource($name), $name);
|
443 |
} else {
|
444 |
$source = $loader->getSourceContext($name);
|
445 |
}
|
464 |
}
|
465 |
|
466 |
if (!class_exists($cls, false)) {
|
467 |
+
throw new Twig_SupTwgSgg_Error_Runtime(sprintf('Failed to load Twig template "%s", index "%s": cache is corrupted.', $name, $index), -1, $source);
|
468 |
}
|
469 |
}
|
470 |
|
482 |
*
|
483 |
* @param string $template The template name
|
484 |
*
|
485 |
+
* @return Twig_SupTwgSgg_Template A template instance representing the given template name
|
486 |
*
|
487 |
+
* @throws Twig_SupTwgSgg_Error_Loader When the template cannot be found
|
488 |
+
* @throws Twig_SupTwgSgg_Error_Syntax When an error occurred during compilation
|
489 |
*/
|
490 |
public function createTemplate($template)
|
491 |
{
|
492 |
$name = sprintf('__string_template__%s', hash('sha256', uniqid(mt_rand(), true), false));
|
493 |
|
494 |
+
$loader = new Twig_SupTwgSgg_Loader_Chain(array(
|
495 |
+
new Twig_SupTwgSgg_Loader_Array(array($name => $template)),
|
496 |
$current = $this->getLoader(),
|
497 |
));
|
498 |
|
542 |
/**
|
543 |
* Tries to load a template consecutively from an array.
|
544 |
*
|
545 |
+
* Similar to loadTemplate() but it also accepts Twig_SupTwgSgg_TemplateInterface instances and an array
|
546 |
* of templates where each is tried to be loaded.
|
547 |
*
|
548 |
+
* @param string|Twig_SupTwgSgg_Template|array $names A template or an array of templates to try consecutively
|
549 |
*
|
550 |
+
* @return Twig_SupTwgSgg_Template
|
551 |
*
|
552 |
+
* @throws Twig_SupTwgSgg_Error_Loader When none of the templates can be found
|
553 |
+
* @throws Twig_SupTwgSgg_Error_Syntax When an error occurred during compilation
|
554 |
*/
|
555 |
public function resolveTemplate($names)
|
556 |
{
|
559 |
}
|
560 |
|
561 |
foreach ($names as $name) {
|
562 |
+
if ($name instanceof Twig_SupTwgSgg_Template) {
|
563 |
return $name;
|
564 |
}
|
565 |
|
566 |
try {
|
567 |
return $this->loadTemplate($name);
|
568 |
+
} catch (Twig_SupTwgSgg_Error_Loader $e) {
|
569 |
}
|
570 |
}
|
571 |
|
573 |
throw $e;
|
574 |
}
|
575 |
|
576 |
+
throw new Twig_SupTwgSgg_Error_Loader(sprintf('Unable to find one of the following templates: "%s".', implode('", "', $names)));
|
577 |
}
|
578 |
|
579 |
/**
|
583 |
*/
|
584 |
public function clearTemplateCache()
|
585 |
{
|
586 |
+
//@trigger_error(sprintf('The %s method is deprecated since version 1.18.3 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
|
587 |
|
588 |
$this->loadedTemplates = array();
|
589 |
}
|
595 |
*/
|
596 |
public function clearCacheFiles()
|
597 |
{
|
598 |
+
//@trigger_error(sprintf('The %s method is deprecated since version 1.22 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
|
599 |
|
600 |
if (is_string($this->originalCache)) {
|
601 |
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->originalCache), RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
|
609 |
/**
|
610 |
* Gets the Lexer instance.
|
611 |
*
|
612 |
+
* @return Twig_SupTwgSgg_LexerInterface
|
613 |
*
|
614 |
* @deprecated since 1.25 (to be removed in 2.0)
|
615 |
*/
|
616 |
public function getLexer()
|
617 |
{
|
618 |
+
//@trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED);
|
619 |
|
620 |
if (null === $this->lexer) {
|
621 |
+
$this->lexer = new Twig_SupTwgSgg_Lexer($this);
|
622 |
}
|
623 |
|
624 |
return $this->lexer;
|
625 |
}
|
626 |
|
627 |
+
public function setLexer(Twig_SupTwgSgg_LexerInterface $lexer)
|
628 |
{
|
629 |
$this->lexer = $lexer;
|
630 |
}
|
632 |
/**
|
633 |
* Tokenizes a source code.
|
634 |
*
|
635 |
+
* @param string|Twig_SupTwgSgg_Source $source The template source code
|
636 |
* @param string $name The template name (deprecated)
|
637 |
*
|
638 |
+
* @return Twig_SupTwgSgg_TokenStream
|
639 |
*
|
640 |
+
* @throws Twig_SupTwgSgg_Error_Syntax When the code is syntactically wrong
|
641 |
*/
|
642 |
public function tokenize($source, $name = null)
|
643 |
{
|
644 |
+
if (!$source instanceof Twig_SupTwgSgg_Source) {
|
645 |
+
//@trigger_error(sprintf('Passing a string as the $source argument of %s() is deprecated since version 1.27. Pass a Twig_SupTwgSgg_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
646 |
+
$source = new Twig_SupTwgSgg_Source($source, $name);
|
647 |
}
|
648 |
|
649 |
if (null === $this->lexer) {
|
650 |
+
$this->lexer = new Twig_SupTwgSgg_Lexer($this);
|
651 |
}
|
652 |
|
653 |
return $this->lexer->tokenize($source);
|
656 |
/**
|
657 |
* Gets the Parser instance.
|
658 |
*
|
659 |
+
* @return Twig_SupTwgSgg_ParserInterface
|
660 |
*
|
661 |
* @deprecated since 1.25 (to be removed in 2.0)
|
662 |
*/
|
663 |
public function getParser()
|
664 |
{
|
665 |
+
//@trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED);
|
666 |
|
667 |
if (null === $this->parser) {
|
668 |
+
$this->parser = new Twig_SupTwgSgg_Parser($this);
|
669 |
}
|
670 |
|
671 |
return $this->parser;
|
672 |
}
|
673 |
|
674 |
+
public function setParser(Twig_SupTwgSgg_ParserInterface $parser)
|
675 |
{
|
676 |
$this->parser = $parser;
|
677 |
}
|
679 |
/**
|
680 |
* Converts a token stream to a node tree.
|
681 |
*
|
682 |
+
* @return Twig_SupTwgSgg_Node_Module
|
683 |
*
|
684 |
+
* @throws Twig_SupTwgSgg_Error_Syntax When the token stream is syntactically or semantically wrong
|
685 |
*/
|
686 |
+
public function parse(Twig_SupTwgSgg_TokenStream $stream)
|
687 |
{
|
688 |
if (null === $this->parser) {
|
689 |
+
$this->parser = new Twig_SupTwgSgg_Parser($this);
|
690 |
}
|
691 |
|
692 |
return $this->parser->parse($stream);
|
695 |
/**
|
696 |
* Gets the Compiler instance.
|
697 |
*
|
698 |
+
* @return Twig_SupTwgSgg_CompilerInterface
|
699 |
*
|
700 |
* @deprecated since 1.25 (to be removed in 2.0)
|
701 |
*/
|
702 |
public function getCompiler()
|
703 |
{
|
704 |
+
//@trigger_error(sprintf('The %s() method is deprecated since version 1.25 and will be removed in 2.0.', __FUNCTION__), E_USER_DEPRECATED);
|
705 |
|
706 |
if (null === $this->compiler) {
|
707 |
+
$this->compiler = new Twig_SupTwgSgg_Compiler($this);
|
708 |
}
|
709 |
|
710 |
return $this->compiler;
|
711 |
}
|
712 |
|
713 |
+
public function setCompiler(Twig_SupTwgSgg_CompilerInterface $compiler)
|
714 |
{
|
715 |
$this->compiler = $compiler;
|
716 |
}
|
720 |
*
|
721 |
* @return string The compiled PHP source code
|
722 |
*/
|
723 |
+
public function compile(Twig_SupTwgSgg_NodeInterface $node)
|
724 |
{
|
725 |
if (null === $this->compiler) {
|
726 |
+
$this->compiler = new Twig_SupTwgSgg_Compiler($this);
|
727 |
}
|
728 |
|
729 |
return $this->compiler->compile($node)->getSource();
|
732 |
/**
|
733 |
* Compiles a template source code.
|
734 |
*
|
735 |
+
* @param string|Twig_SupTwgSgg_Source $source The template source code
|
736 |
* @param string $name The template name (deprecated)
|
737 |
*
|
738 |
* @return string The compiled PHP source code
|
739 |
*
|
740 |
+
* @throws Twig_SupTwgSgg_Error_Syntax When there was an error during tokenizing, parsing or compiling
|
741 |
*/
|
742 |
public function compileSource($source, $name = null)
|
743 |
{
|
744 |
+
if (!$source instanceof Twig_SupTwgSgg_Source) {
|
745 |
+
//@trigger_error(sprintf('Passing a string as the $source argument of %s() is deprecated since version 1.27. Pass a Twig_SupTwgSgg_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
746 |
+
$source = new Twig_SupTwgSgg_Source($source, $name);
|
747 |
}
|
748 |
|
749 |
try {
|
750 |
return $this->compile($this->parse($this->tokenize($source)));
|
751 |
+
} catch (Twig_SupTwgSgg_Error $e) {
|
752 |
$e->setSourceContext($source);
|
753 |
throw $e;
|
754 |
} catch (Exception $e) {
|
755 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('An exception has been thrown during the compilation of a template ("%s").', $e->getMessage()), -1, $source, $e);
|
756 |
}
|
757 |
}
|
758 |
|
759 |
+
public function setLoader(Twig_SupTwgSgg_LoaderInterface $loader)
|
760 |
{
|
761 |
+
if (!$loader instanceof Twig_SupTwgSgg_SourceContextLoaderInterface && 0 !== strpos(get_class($loader), 'Mock_Twig_SupTwgSgg_LoaderInterface')) {
|
762 |
+
//@trigger_error(sprintf('Twig loader "%s" should implement Twig_SupTwgSgg_SourceContextLoaderInterface since version 1.27.', get_class($loader)), E_USER_DEPRECATED);
|
763 |
}
|
764 |
|
765 |
$this->loader = $loader;
|
768 |
/**
|
769 |
* Gets the Loader instance.
|
770 |
*
|
771 |
+
* @return Twig_SupTwgSgg_LoaderInterface
|
772 |
*/
|
773 |
public function getLoader()
|
774 |
{
|
809 |
$this->runtimeInitialized = true;
|
810 |
|
811 |
foreach ($this->getExtensions() as $name => $extension) {
|
812 |
+
if (!$extension instanceof Twig_SupTwgSgg_Extension_InitRuntimeInterface) {
|
813 |
$m = new ReflectionMethod($extension, 'initRuntime');
|
814 |
|
815 |
+
if ('Twig_SupTwgSgg_Extension' !== $m->getDeclaringClass()->getName()) {
|
816 |
+
//@trigger_error(sprintf('Defining the initRuntime() method in the "%s" extension is deprecated since version 1.23. Use the `needs_environment` option to get the Twig_SupTwgSgg_Environment instance in filters, functions, or tests; or explicitly implement Twig_SupTwgSgg_Extension_InitRuntimeInterface if needed (not recommended).', $name), E_USER_DEPRECATED);
|
817 |
}
|
818 |
}
|
819 |
|
833 |
$class = ltrim($class, '\\');
|
834 |
if (isset($this->extensions[$class])) {
|
835 |
if ($class !== get_class($this->extensions[$class])) {
|
836 |
+
//@trigger_error(sprintf('Referencing the "%s" extension by its name (defined by getName()) is deprecated since 1.26 and will be removed in Twig 2.0. Use the Fully Qualified Extension Class Name instead.', $class), E_USER_DEPRECATED);
|
837 |
}
|
838 |
|
839 |
return true;
|
845 |
/**
|
846 |
* Adds a runtime loader.
|
847 |
*/
|
848 |
+
public function addRuntimeLoader(Twig_SupTwgSgg_RuntimeLoaderInterface $loader)
|
849 |
{
|
850 |
$this->runtimeLoaders[] = $loader;
|
851 |
}
|
855 |
*
|
856 |
* @param string $class The extension class name
|
857 |
*
|
858 |
+
* @return Twig_SupTwgSgg_ExtensionInterface
|
859 |
*/
|
860 |
public function getExtension($class)
|
861 |
{
|
863 |
|
864 |
if (isset($this->extensions[$class])) {
|
865 |
if ($class !== get_class($this->extensions[$class])) {
|
866 |
+
//@trigger_error(sprintf('Referencing the "%s" extension by its name (defined by getName()) is deprecated since 1.26 and will be removed in Twig 2.0. Use the Fully Qualified Extension Class Name instead.', $class), E_USER_DEPRECATED);
|
867 |
}
|
868 |
|
869 |
return $this->extensions[$class];
|
870 |
}
|
871 |
|
872 |
if (!isset($this->extensionsByClass[$class])) {
|
873 |
+
throw new Twig_SupTwgSgg_Error_Runtime(sprintf('The "%s" extension is not enabled.', $class));
|
874 |
}
|
875 |
|
876 |
return $this->extensionsByClass[$class];
|
883 |
*
|
884 |
* @return object The runtime implementation
|
885 |
*
|
886 |
+
* @throws Twig_SupTwgSgg_Error_Runtime When the template cannot be found
|
887 |
*/
|
888 |
public function getRuntime($class)
|
889 |
{
|
897 |
}
|
898 |
}
|
899 |
|
900 |
+
throw new Twig_SupTwgSgg_Error_Runtime(sprintf('Unable to load the "%s" runtime.', $class));
|
901 |
}
|
902 |
|
903 |
+
public function addExtension(Twig_SupTwgSgg_ExtensionInterface $extension)
|
904 |
{
|
905 |
if ($this->extensionInitialized) {
|
906 |
throw new LogicException(sprintf('Unable to register extension "%s" as extensions have already been initialized.', $extension->getName()));
|
910 |
if ($class !== $extension->getName()) {
|
911 |
if (isset($this->extensions[$extension->getName()])) {
|
912 |
unset($this->extensions[$extension->getName()], $this->extensionsByClass[$class]);
|
913 |
+
//@trigger_error(sprintf('The possibility to register the same extension twice ("%s") is deprecated since version 1.23 and will be removed in Twig 2.0. Use proper PHP inheritance instead.', $extension->getName()), E_USER_DEPRECATED);
|
914 |
}
|
915 |
}
|
916 |
|
931 |
*/
|
932 |
public function removeExtension($name)
|
933 |
{
|
934 |
+
//@trigger_error(sprintf('The %s method is deprecated since version 1.12 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
|
935 |
|
936 |
if ($this->extensionInitialized) {
|
937 |
throw new LogicException(sprintf('Unable to remove extension "%s" as extensions have already been initialized.', $name));
|
940 |
$class = ltrim($name, '\\');
|
941 |
if (isset($this->extensions[$class])) {
|
942 |
if ($class !== get_class($this->extensions[$class])) {
|
943 |
+
//@trigger_error(sprintf('Referencing the "%s" extension by its name (defined by getName()) is deprecated since 1.26 and will be removed in Twig 2.0. Use the Fully Qualified Extension Class Name instead.', $class), E_USER_DEPRECATED);
|
944 |
}
|
945 |
|
946 |
unset($this->extensions[$class]);
|
965 |
/**
|
966 |
* Returns all registered extensions.
|
967 |
*
|
968 |
+
* @return Twig_SupTwgSgg_ExtensionInterface[] An array of extensions (keys are for internal usage only and should not be relied on)
|
969 |
*/
|
970 |
public function getExtensions()
|
971 |
{
|
972 |
return $this->extensions;
|
973 |
}
|
974 |
|
975 |
+
public function addTokenParser(Twig_SupTwgSgg_TokenParserInterface $parser)
|
976 |
{
|
977 |
if ($this->extensionInitialized) {
|
978 |
throw new LogicException('Unable to add a token parser as extensions have already been initialized.');
|
984 |
/**
|
985 |
* Gets the registered Token Parsers.
|
986 |
*
|
987 |
+
* @return Twig_SupTwgSgg_TokenParserBrokerInterface
|
988 |
*
|
989 |
* @internal
|
990 |
*/
|
1000 |
/**
|
1001 |
* Gets registered tags.
|
1002 |
*
|
1003 |
+
* Be warned that this method cannot return tags defined by Twig_SupTwgSgg_TokenParserBrokerInterface classes.
|
1004 |
*
|
1005 |
+
* @return Twig_SupTwgSgg_TokenParserInterface[]
|
1006 |
*
|
1007 |
* @internal
|
1008 |
*/
|
1010 |
{
|
1011 |
$tags = array();
|
1012 |
foreach ($this->getTokenParsers()->getParsers() as $parser) {
|
1013 |
+
if ($parser instanceof Twig_SupTwgSgg_TokenParserInterface) {
|
1014 |
$tags[$parser->getTag()] = $parser;
|
1015 |
}
|
1016 |
}
|
1018 |
return $tags;
|
1019 |
}
|
1020 |
|
1021 |
+
public function addNodeVisitor(Twig_SupTwgSgg_NodeVisitorInterface $visitor)
|
1022 |
{
|
1023 |
if ($this->extensionInitialized) {
|
1024 |
throw new LogicException('Unable to add a node visitor as extensions have already been initialized.');
|
1030 |
/**
|
1031 |
* Gets the registered Node Visitors.
|
1032 |
*
|
1033 |
+
* @return Twig_SupTwgSgg_NodeVisitorInterface[]
|
1034 |
*
|
1035 |
* @internal
|
1036 |
*/
|
1046 |
/**
|
1047 |
* Registers a Filter.
|
1048 |
*
|
1049 |
+
* @param string|Twig_SupTwgSgg_SimpleFilter $name The filter name or a Twig_SupTwgSgg_SimpleFilter instance
|
1050 |
+
* @param Twig_SupTwgSgg_FilterInterface|Twig_SupTwgSgg_SimpleFilter $filter
|
1051 |
*/
|
1052 |
public function addFilter($name, $filter = null)
|
1053 |
{
|
1054 |
+
if (!$name instanceof Twig_SupTwgSgg_SimpleFilter && !($filter instanceof Twig_SupTwgSgg_SimpleFilter || $filter instanceof Twig_SupTwgSgg_FilterInterface)) {
|
1055 |
+
throw new LogicException('A filter must be an instance of Twig_SupTwgSgg_FilterInterface or Twig_SupTwgSgg_SimpleFilter.');
|
1056 |
}
|
1057 |
|
1058 |
+
if ($name instanceof Twig_SupTwgSgg_SimpleFilter) {
|
1059 |
$filter = $name;
|
1060 |
$name = $filter->getName();
|
1061 |
} else {
|
1062 |
+
//@trigger_error(sprintf('Passing a name as a first argument to the %s method is deprecated since version 1.21. Pass an instance of "Twig_SupTwgSgg_SimpleFilter" instead when defining filter "%s".', __METHOD__, $name), E_USER_DEPRECATED);
|
1063 |
}
|
1064 |
|
1065 |
if ($this->extensionInitialized) {
|
1077 |
*
|
1078 |
* @param string $name The filter name
|
1079 |
*
|
1080 |
+
* @return Twig_SupTwgSgg_Filter|false A Twig_SupTwgSgg_Filter instance or false if the filter does not exist
|
1081 |
*
|
1082 |
* @internal
|
1083 |
*/
|
1123 |
*
|
1124 |
* Be warned that this method cannot return filters defined with registerUndefinedFilterCallback.
|
1125 |
*
|
1126 |
+
* @return Twig_SupTwgSgg_FilterInterface[]
|
1127 |
*
|
1128 |
* @see registerUndefinedFilterCallback
|
1129 |
*
|
1141 |
/**
|
1142 |
* Registers a Test.
|
1143 |
*
|
1144 |
+
* @param string|Twig_SupTwgSgg_SimpleTest $name The test name or a Twig_SupTwgSgg_SimpleTest instance
|
1145 |
+
* @param Twig_SupTwgSgg_TestInterface|Twig_SupTwgSgg_SimpleTest $test A Twig_SupTwgSgg_TestInterface instance or a Twig_SupTwgSgg_SimpleTest instance
|
1146 |
*/
|
1147 |
public function addTest($name, $test = null)
|
1148 |
{
|
1149 |
+
if (!$name instanceof Twig_SupTwgSgg_SimpleTest && !($test instanceof Twig_SupTwgSgg_SimpleTest || $test instanceof Twig_SupTwgSgg_TestInterface)) {
|
1150 |
+
throw new LogicException('A test must be an instance of Twig_SupTwgSgg_TestInterface or Twig_SupTwgSgg_SimpleTest.');
|
1151 |
}
|
1152 |
|
1153 |
+
if ($name instanceof Twig_SupTwgSgg_SimpleTest) {
|
1154 |
$test = $name;
|
1155 |
$name = $test->getName();
|
1156 |
} else {
|
1157 |
+
//@trigger_error(sprintf('Passing a name as a first argument to the %s method is deprecated since version 1.21. Pass an instance of "Twig_SupTwgSgg_SimpleTest" instead when defining test "%s".', __METHOD__, $name), E_USER_DEPRECATED);
|
1158 |
}
|
1159 |
|
1160 |
if ($this->extensionInitialized) {
|
1167 |
/**
|
1168 |
* Gets the registered Tests.
|
1169 |
*
|
1170 |
+
* @return Twig_SupTwgSgg_TestInterface[]
|
1171 |
*
|
1172 |
* @internal
|
1173 |
*/
|
1185 |
*
|
1186 |
* @param string $name The test name
|
1187 |
*
|
1188 |
+
* @return Twig_SupTwgSgg_Test|false A Twig_SupTwgSgg_Test instance or false if the test does not exist
|
1189 |
*
|
1190 |
* @internal
|
1191 |
*/
|
1205 |
/**
|
1206 |
* Registers a Function.
|
1207 |
*
|
1208 |
+
* @param string|Twig_SupTwgSgg_SimpleFunction $name The function name or a Twig_SupTwgSgg_SimpleFunction instance
|
1209 |
+
* @param Twig_SupTwgSgg_FunctionInterface|Twig_SupTwgSgg_SimpleFunction $function
|
1210 |
*/
|
1211 |
public function addFunction($name, $function = null)
|
1212 |
{
|
1213 |
+
if (!$name instanceof Twig_SupTwgSgg_SimpleFunction && !($function instanceof Twig_SupTwgSgg_SimpleFunction || $function instanceof Twig_SupTwgSgg_FunctionInterface)) {
|
1214 |
+
throw new LogicException('A function must be an instance of Twig_SupTwgSgg_FunctionInterface or Twig_SupTwgSgg_SimpleFunction.');
|
1215 |
}
|
1216 |
|
1217 |
+
if ($name instanceof Twig_SupTwgSgg_SimpleFunction) {
|
1218 |
$function = $name;
|
1219 |
$name = $function->getName();
|
1220 |
} else {
|
1221 |
+
//@trigger_error(sprintf('Passing a name as a first argument to the %s method is deprecated since version 1.21. Pass an instance of "Twig_SupTwgSgg_SimpleFunction" instead when defining function "%s".', __METHOD__, $name), E_USER_DEPRECATED);
|
1222 |
}
|
1223 |
|
1224 |
if ($this->extensionInitialized) {
|
1236 |
*
|
1237 |
* @param string $name function name
|
1238 |
*
|
1239 |
+
* @return Twig_SupTwgSgg_Function|false A Twig_SupTwgSgg_Function instance or false if the function does not exist
|
1240 |
*
|
1241 |
* @internal
|
1242 |
*/
|
1282 |
*
|
1283 |
* Be warned that this method cannot return functions defined with registerUndefinedFunctionCallback.
|
1284 |
*
|
1285 |
+
* @return Twig_SupTwgSgg_FunctionInterface[]
|
1286 |
*
|
1287 |
* @see registerUndefinedFunctionCallback
|
1288 |
*
|
1315 |
|
1316 |
if (!array_key_exists($name, $this->globals)) {
|
1317 |
// The deprecation notice must be turned into the following exception in Twig 2.0
|
1318 |
+
//@trigger_error(sprintf('Registering global variable "%s" at runtime or when the extensions have already been initialized is deprecated since version 1.21.', $name), E_USER_DEPRECATED);
|
1319 |
//throw new LogicException(sprintf('Unable to add global "%s" as the runtime or the extensions have already been initialized.', $name));
|
1320 |
}
|
1321 |
}
|
1405 |
*/
|
1406 |
public function computeAlternatives($name, $items)
|
1407 |
{
|
1408 |
+
//@trigger_error(sprintf('The %s method is deprecated since version 1.23 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
|
1409 |
|
1410 |
+
return Twig_SupTwgSgg_Error_Syntax::computeAlternatives($name, $items);
|
1411 |
}
|
1412 |
|
1413 |
/**
|
1417 |
{
|
1418 |
$globals = array();
|
1419 |
foreach ($this->extensions as $name => $extension) {
|
1420 |
+
if (!$extension instanceof Twig_SupTwgSgg_Extension_GlobalsInterface) {
|
1421 |
$m = new ReflectionMethod($extension, 'getGlobals');
|
1422 |
|
1423 |
+
if ('Twig_SupTwgSgg_Extension' !== $m->getDeclaringClass()->getName()) {
|
1424 |
+
//@trigger_error(sprintf('Defining the getGlobals() method in the "%s" extension without explicitly implementing Twig_SupTwgSgg_Extension_GlobalsInterface is deprecated since version 1.23.', $name), E_USER_DEPRECATED);
|
1425 |
}
|
1426 |
}
|
1427 |
|
1447 |
return;
|
1448 |
}
|
1449 |
|
1450 |
+
$this->parsers = new Twig_SupTwgSgg_TokenParserBroker(array(), array(), false);
|
1451 |
$this->filters = array();
|
1452 |
$this->functions = array();
|
1453 |
$this->tests = array();
|
1466 |
/**
|
1467 |
* @internal
|
1468 |
*/
|
1469 |
+
protected function initExtension(Twig_SupTwgSgg_ExtensionInterface $extension)
|
1470 |
{
|
1471 |
// filters
|
1472 |
foreach ($extension->getFilters() as $name => $filter) {
|
1473 |
+
if ($filter instanceof Twig_SupTwgSgg_SimpleFilter) {
|
1474 |
$name = $filter->getName();
|
1475 |
} else {
|
1476 |
+
//@trigger_error(sprintf('Using an instance of "%s" for filter "%s" is deprecated since version 1.21. Use Twig_SupTwgSgg_SimpleFilter instead.', get_class($filter), $name), E_USER_DEPRECATED);
|
1477 |
}
|
1478 |
|
1479 |
$this->filters[$name] = $filter;
|
1481 |
|
1482 |
// functions
|
1483 |
foreach ($extension->getFunctions() as $name => $function) {
|
1484 |
+
if ($function instanceof Twig_SupTwgSgg_SimpleFunction) {
|
1485 |
$name = $function->getName();
|
1486 |
} else {
|
1487 |
+
//@trigger_error(sprintf('Using an instance of "%s" for function "%s" is deprecated since version 1.21. Use Twig_SupTwgSgg_SimpleFunction instead.', get_class($function), $name), E_USER_DEPRECATED);
|
1488 |
}
|
1489 |
|
1490 |
$this->functions[$name] = $function;
|
1492 |
|
1493 |
// tests
|
1494 |
foreach ($extension->getTests() as $name => $test) {
|
1495 |
+
if ($test instanceof Twig_SupTwgSgg_SimpleTest) {
|
1496 |
$name = $test->getName();
|
1497 |
} else {
|
1498 |
+
//@trigger_error(sprintf('Using an instance of "%s" for test "%s" is deprecated since version 1.21. Use Twig_SupTwgSgg_SimpleTest instead.', get_class($test), $name), E_USER_DEPRECATED);
|
1499 |
}
|
1500 |
|
1501 |
$this->tests[$name] = $test;
|
1503 |
|
1504 |
// token parsers
|
1505 |
foreach ($extension->getTokenParsers() as $parser) {
|
1506 |
+
if ($parser instanceof Twig_SupTwgSgg_TokenParserInterface) {
|
1507 |
$this->parsers->addTokenParser($parser);
|
1508 |
+
} elseif ($parser instanceof Twig_SupTwgSgg_TokenParserBrokerInterface) {
|
1509 |
+
//@trigger_error('Registering a Twig_SupTwgSgg_TokenParserBrokerInterface instance is deprecated since version 1.21.', E_USER_DEPRECATED);
|
1510 |
|
1511 |
$this->parsers->addTokenParserBroker($parser);
|
1512 |
} else {
|
1513 |
+
throw new LogicException('getTokenParsers() must return an array of Twig_SupTwgSgg_TokenParserInterface or Twig_SupTwgSgg_TokenParserBrokerInterface instances.');
|
1514 |
}
|
1515 |
}
|
1516 |
|
1547 |
$hashParts = array_merge(
|
1548 |
array_keys($this->extensions),
|
1549 |
array(
|
1550 |
+
(int) function_exists('Twig_SupTwgSgg_template_get_attributes'),
|
1551 |
PHP_MAJOR_VERSION,
|
1552 |
PHP_MINOR_VERSION,
|
1553 |
self::VERSION,
|
vendor/Twig/Error.php
CHANGED
@@ -31,7 +31,7 @@
|
|
31 |
*
|
32 |
* @author Fabien Potencier <fabien@symfony.com>
|
33 |
*/
|
34 |
-
class
|
35 |
{
|
36 |
protected $lineno;
|
37 |
// to be renamed to name in 2.0
|
@@ -56,14 +56,14 @@ class Twig_SupTwg_Error extends Exception
|
|
56 |
*
|
57 |
* @param string $message The error message
|
58 |
* @param int $lineno The template line where the error occurred
|
59 |
-
* @param
|
60 |
* @param Exception $previous The previous exception
|
61 |
*/
|
62 |
public function __construct($message, $lineno = -1, $source = null, Exception $previous = null)
|
63 |
{
|
64 |
if (null === $source) {
|
65 |
$name = null;
|
66 |
-
} elseif (!$source instanceof
|
67 |
// for compat with the Twig C ext., passing the template name as string is accepted
|
68 |
$name = $source;
|
69 |
} else {
|
@@ -109,7 +109,7 @@ class Twig_SupTwg_Error extends Exception
|
|
109 |
*/
|
110 |
public function getTemplateFile()
|
111 |
{
|
112 |
-
|
113 |
|
114 |
return $this->filename;
|
115 |
}
|
@@ -123,7 +123,7 @@ class Twig_SupTwg_Error extends Exception
|
|
123 |
*/
|
124 |
public function setTemplateFile($name)
|
125 |
{
|
126 |
-
|
127 |
|
128 |
$this->filename = $name;
|
129 |
|
@@ -139,7 +139,7 @@ class Twig_SupTwg_Error extends Exception
|
|
139 |
*/
|
140 |
public function getTemplateName()
|
141 |
{
|
142 |
-
|
143 |
|
144 |
return $this->filename;
|
145 |
}
|
@@ -153,7 +153,7 @@ class Twig_SupTwg_Error extends Exception
|
|
153 |
*/
|
154 |
public function setTemplateName($name)
|
155 |
{
|
156 |
-
|
157 |
|
158 |
$this->filename = $name;
|
159 |
$this->sourceCode = $this->sourcePath = null;
|
@@ -186,17 +186,17 @@ class Twig_SupTwg_Error extends Exception
|
|
186 |
/**
|
187 |
* Gets the source context of the Twig template where the error occurred.
|
188 |
*
|
189 |
-
* @return
|
190 |
*/
|
191 |
public function getSourceContext()
|
192 |
{
|
193 |
-
return $this->filename ? new
|
194 |
}
|
195 |
|
196 |
/**
|
197 |
* Sets the source context of the Twig template where the error occurred.
|
198 |
*/
|
199 |
-
public function setSourceContext(
|
200 |
{
|
201 |
if (null === $source) {
|
202 |
$this->sourceCode = $this->filename = $this->sourcePath = null;
|
@@ -231,7 +231,7 @@ class Twig_SupTwg_Error extends Exception
|
|
231 |
return $this->previous;
|
232 |
}
|
233 |
|
234 |
-
throw new BadMethodCallException(sprintf('Method "
|
235 |
}
|
236 |
|
237 |
public function appendMessage($rawMessage)
|
@@ -303,7 +303,7 @@ class Twig_SupTwg_Error extends Exception
|
|
303 |
}
|
304 |
|
305 |
foreach ($backtrace as $trace) {
|
306 |
-
if (isset($trace['object']) && $trace['object'] instanceof
|
307 |
$currentClass = get_class($trace['object']);
|
308 |
$isEmbedContainer = 0 === strpos($templateClass, $currentClass);
|
309 |
if (null === $this->filename || ($this->filename == $trace['object']->getTemplateName() && !$isEmbedContainer)) {
|
31 |
*
|
32 |
* @author Fabien Potencier <fabien@symfony.com>
|
33 |
*/
|
34 |
+
class Twig_SupTwgSgg_Error extends Exception
|
35 |
{
|
36 |
protected $lineno;
|
37 |
// to be renamed to name in 2.0
|
56 |
*
|
57 |
* @param string $message The error message
|
58 |
* @param int $lineno The template line where the error occurred
|
59 |
+
* @param Twig_SupTwgSgg_Source|string|null $source The source context where the error occurred
|
60 |
* @param Exception $previous The previous exception
|
61 |
*/
|
62 |
public function __construct($message, $lineno = -1, $source = null, Exception $previous = null)
|
63 |
{
|
64 |
if (null === $source) {
|
65 |
$name = null;
|
66 |
+
} elseif (!$source instanceof Twig_SupTwgSgg_Source) {
|
67 |
// for compat with the Twig C ext., passing the template name as string is accepted
|
68 |
$name = $source;
|
69 |
} else {
|
109 |
*/
|
110 |
public function getTemplateFile()
|
111 |
{
|
112 |
+
//@trigger_error(sprintf('The "%s" method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', __METHOD__), E_USER_DEPRECATED);
|
113 |
|
114 |
return $this->filename;
|
115 |
}
|
123 |
*/
|
124 |
public function setTemplateFile($name)
|
125 |
{
|
126 |
+
//@trigger_error(sprintf('The "%s" method is deprecated since version 1.27 and will be removed in 2.0. Use setSourceContext() instead.', __METHOD__), E_USER_DEPRECATED);
|
127 |
|
128 |
$this->filename = $name;
|
129 |
|
139 |
*/
|
140 |
public function getTemplateName()
|
141 |
{
|
142 |
+
//@trigger_error(sprintf('The "%s" method is deprecated since version 1.29 and will be removed in 2.0. Use getSourceContext() instead.', __METHOD__), E_USER_DEPRECATED);
|
143 |
|
144 |
return $this->filename;
|
145 |
}
|
153 |
*/
|
154 |
public function setTemplateName($name)
|
155 |
{
|
156 |
+
//@trigger_error(sprintf('The "%s" method is deprecated since version 1.29 and will be removed in 2.0. Use setSourceContext() instead.', __METHOD__), E_USER_DEPRECATED);
|
157 |
|
158 |
$this->filename = $name;
|
159 |
$this->sourceCode = $this->sourcePath = null;
|
186 |
/**
|
187 |
* Gets the source context of the Twig template where the error occurred.
|
188 |
*
|
189 |
+
* @return Twig_SupTwgSgg_Source|null
|
190 |
*/
|
191 |
public function getSourceContext()
|
192 |
{
|
193 |
+
return $this->filename ? new Twig_SupTwgSgg_Source($this->sourceCode, $this->filename, $this->sourcePath) : null;
|
194 |
}
|
195 |
|
196 |
/**
|
197 |
* Sets the source context of the Twig template where the error occurred.
|
198 |
*/
|
199 |
+
public function setSourceContext(Twig_SupTwgSgg_Source $source = null)
|
200 |
{
|
201 |
if (null === $source) {
|
202 |
$this->sourceCode = $this->filename = $this->sourcePath = null;
|
231 |
return $this->previous;
|
232 |
}
|
233 |
|
234 |
+
throw new BadMethodCallException(sprintf('Method "Twig_SupTwgSgg_Error::%s()" does not exist.', $method));
|
235 |
}
|
236 |
|
237 |
public function appendMessage($rawMessage)
|
303 |
}
|
304 |
|
305 |
foreach ($backtrace as $trace) {
|
306 |
+
if (isset($trace['object']) && $trace['object'] instanceof Twig_SupTwgSgg_Template && 'Twig_SupTwgSgg_Template' !== get_class($trace['object'])) {
|
307 |
$currentClass = get_class($trace['object']);
|
308 |
$isEmbedContainer = 0 === strpos($templateClass, $currentClass);
|
309 |
if (null === $this->filename || ($this->filename == $trace['object']->getTemplateName() && !$isEmbedContainer)) {
|
vendor/Twig/Error/Loader.php
CHANGED
@@ -16,13 +16,13 @@
|
|
16 |
* if a template cannot be loaded, there is nothing to guess.
|
17 |
* However, when a template is loaded from another one, then, we need
|
18 |
* to find the current context and this is automatically done by
|
19 |
-
*
|
20 |
*
|
21 |
-
* This strategy makes
|
22 |
*
|
23 |
* @author Fabien Potencier <fabien@symfony.com>
|
24 |
*/
|
25 |
-
class
|
26 |
{
|
27 |
public function __construct($message, $lineno = -1, $source = null, Exception $previous = null)
|
28 |
{
|
16 |
* if a template cannot be loaded, there is nothing to guess.
|
17 |
* However, when a template is loaded from another one, then, we need
|
18 |
* to find the current context and this is automatically done by
|
19 |
+
* Twig_SupTwgSgg_Template::displayWithErrorHandling().
|
20 |
*
|
21 |
+
* This strategy makes Twig_SupTwgSgg_Environment::resolveTemplate() much faster.
|
22 |
*
|
23 |
* @author Fabien Potencier <fabien@symfony.com>
|
24 |
*/
|
25 |
+
class Twig_SupTwgSgg_Error_Loader extends Twig_SupTwgSgg_Error
|
26 |
{
|
27 |
public function __construct($message, $lineno = -1, $source = null, Exception $previous = null)
|
28 |
{
|
vendor/Twig/Error/Runtime.php
CHANGED
@@ -15,6 +15,6 @@
|
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
-
class
|
19 |
{
|
20 |
}
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_SupTwgSgg_Error_Runtime extends Twig_SupTwgSgg_Error
|
19 |
{
|
20 |
}
|
vendor/Twig/Error/Syntax.php
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
-
class
|
19 |
{
|
20 |
/**
|
21 |
* Tweaks the error message to include suggestions.
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_SupTwgSgg_Error_Syntax extends Twig_SupTwgSgg_Error
|
19 |
{
|
20 |
/**
|
21 |
* Tweaks the error message to include suggestions.
|
vendor/Twig/ExistsLoaderInterface.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
*
|
17 |
* @deprecated since 1.12 (to be removed in 3.0)
|
18 |
*/
|
19 |
-
interface
|
20 |
{
|
21 |
/**
|
22 |
* Check if we have the source code of a template, given its name.
|
16 |
*
|
17 |
* @deprecated since 1.12 (to be removed in 3.0)
|
18 |
*/
|
19 |
+
interface Twig_SupTwgSgg_ExistsLoaderInterface
|
20 |
{
|
21 |
/**
|
22 |
* Check if we have the source code of a template, given its name.
|
vendor/Twig/ExpressionParser.php
CHANGED
@@ -22,7 +22,7 @@
|
|
22 |
*
|
23 |
* @internal
|
24 |
*/
|
25 |
-
class
|
26 |
{
|
27 |
const OPERATOR_LEFT = 1;
|
28 |
const OPERATOR_RIGHT = 2;
|
@@ -33,16 +33,16 @@ class Twig_SupTwg_ExpressionParser
|
|
33 |
|
34 |
private $env;
|
35 |
|
36 |
-
public function __construct(
|
37 |
{
|
38 |
$this->parser = $parser;
|
39 |
|
40 |
-
if ($env instanceof
|
41 |
$this->env = $env;
|
42 |
$this->unaryOperators = $env->getUnaryOperators();
|
43 |
$this->binaryOperators = $env->getBinaryOperators();
|
44 |
} else {
|
45 |
-
|
46 |
|
47 |
$this->env = $parser->getEnvironment();
|
48 |
$this->unaryOperators = func_get_arg(1);
|
@@ -91,10 +91,10 @@ class Twig_SupTwg_ExpressionParser
|
|
91 |
$class = $operator['class'];
|
92 |
|
93 |
return $this->parsePostfixExpression(new $class($expr, $token->getLine()));
|
94 |
-
} elseif ($token->test(
|
95 |
$this->parser->getStream()->next();
|
96 |
$expr = $this->parseExpression();
|
97 |
-
$this->parser->getStream()->expect(
|
98 |
|
99 |
return $this->parsePostfixExpression($expr);
|
100 |
}
|
@@ -104,92 +104,92 @@ class Twig_SupTwg_ExpressionParser
|
|
104 |
|
105 |
protected function parseConditionalExpression($expr)
|
106 |
{
|
107 |
-
while ($this->parser->getStream()->nextIf(
|
108 |
-
if (!$this->parser->getStream()->nextIf(
|
109 |
$expr2 = $this->parseExpression();
|
110 |
-
if ($this->parser->getStream()->nextIf(
|
111 |
$expr3 = $this->parseExpression();
|
112 |
} else {
|
113 |
-
$expr3 = new
|
114 |
}
|
115 |
} else {
|
116 |
$expr2 = $expr;
|
117 |
$expr3 = $this->parseExpression();
|
118 |
}
|
119 |
|
120 |
-
$expr = new
|
121 |
}
|
122 |
|
123 |
return $expr;
|
124 |
}
|
125 |
|
126 |
-
protected function isUnary(
|
127 |
{
|
128 |
-
return $token->test(
|
129 |
}
|
130 |
|
131 |
-
protected function isBinary(
|
132 |
{
|
133 |
-
return $token->test(
|
134 |
}
|
135 |
|
136 |
public function parsePrimaryExpression()
|
137 |
{
|
138 |
$token = $this->parser->getCurrentToken();
|
139 |
switch ($token->getType()) {
|
140 |
-
case
|
141 |
$this->parser->getStream()->next();
|
142 |
switch ($token->getValue()) {
|
143 |
case 'true':
|
144 |
case 'TRUE':
|
145 |
-
$node = new
|
146 |
break;
|
147 |
|
148 |
case 'false':
|
149 |
case 'FALSE':
|
150 |
-
$node = new
|
151 |
break;
|
152 |
|
153 |
case 'none':
|
154 |
case 'NONE':
|
155 |
case 'null':
|
156 |
case 'NULL':
|
157 |
-
$node = new
|
158 |
break;
|
159 |
|
160 |
default:
|
161 |
if ('(' === $this->parser->getCurrentToken()->getValue()) {
|
162 |
$node = $this->getFunctionNode($token->getValue(), $token->getLine());
|
163 |
} else {
|
164 |
-
$node = new
|
165 |
}
|
166 |
}
|
167 |
break;
|
168 |
|
169 |
-
case
|
170 |
$this->parser->getStream()->next();
|
171 |
-
$node = new
|
172 |
break;
|
173 |
|
174 |
-
case
|
175 |
-
case
|
176 |
$node = $this->parseStringExpression();
|
177 |
break;
|
178 |
|
179 |
-
case
|
180 |
-
if (preg_match(
|
181 |
// in this context, string operators are variable names
|
182 |
$this->parser->getStream()->next();
|
183 |
-
$node = new
|
184 |
break;
|
185 |
} elseif (isset($this->unaryOperators[$token->getValue()])) {
|
186 |
$class = $this->unaryOperators[$token->getValue()]['class'];
|
187 |
|
188 |
$ref = new ReflectionClass($class);
|
189 |
-
$negClass = '
|
190 |
-
$posClass = '
|
191 |
if (!(in_array($ref->getName(), array($negClass, $posClass)) || $ref->isSubclassOf($negClass) || $ref->isSubclassOf($posClass))) {
|
192 |
-
throw new
|
193 |
}
|
194 |
|
195 |
$this->parser->getStream()->next();
|
@@ -200,12 +200,12 @@ class Twig_SupTwg_ExpressionParser
|
|
200 |
}
|
201 |
|
202 |
default:
|
203 |
-
if ($token->test(
|
204 |
$node = $this->parseArrayExpression();
|
205 |
-
} elseif ($token->test(
|
206 |
$node = $this->parseHashExpression();
|
207 |
} else {
|
208 |
-
throw new
|
209 |
}
|
210 |
}
|
211 |
|
@@ -220,12 +220,12 @@ class Twig_SupTwg_ExpressionParser
|
|
220 |
// a string cannot be followed by another string in a single expression
|
221 |
$nextCanBeString = true;
|
222 |
while (true) {
|
223 |
-
if ($nextCanBeString && $token = $stream->nextIf(
|
224 |
-
$nodes[] = new
|
225 |
$nextCanBeString = false;
|
226 |
-
} elseif ($stream->nextIf(
|
227 |
$nodes[] = $this->parseExpression();
|
228 |
-
$stream->expect(
|
229 |
$nextCanBeString = true;
|
230 |
} else {
|
231 |
break;
|
@@ -234,7 +234,7 @@ class Twig_SupTwg_ExpressionParser
|
|
234 |
|
235 |
$expr = array_shift($nodes);
|
236 |
foreach ($nodes as $node) {
|
237 |
-
$expr = new
|
238 |
}
|
239 |
|
240 |
return $expr;
|
@@ -243,16 +243,16 @@ class Twig_SupTwg_ExpressionParser
|
|
243 |
public function parseArrayExpression()
|
244 |
{
|
245 |
$stream = $this->parser->getStream();
|
246 |
-
$stream->expect(
|
247 |
|
248 |
-
$node = new
|
249 |
$first = true;
|
250 |
-
while (!$stream->test(
|
251 |
if (!$first) {
|
252 |
-
$stream->expect(
|
253 |
|
254 |
// trailing ,?
|
255 |
-
if ($stream->test(
|
256 |
break;
|
257 |
}
|
258 |
}
|
@@ -260,7 +260,7 @@ class Twig_SupTwg_ExpressionParser
|
|
260 |
|
261 |
$node->addElement($this->parseExpression());
|
262 |
}
|
263 |
-
$stream->expect(
|
264 |
|
265 |
return $node;
|
266 |
}
|
@@ -268,16 +268,16 @@ class Twig_SupTwg_ExpressionParser
|
|
268 |
public function parseHashExpression()
|
269 |
{
|
270 |
$stream = $this->parser->getStream();
|
271 |
-
$stream->expect(
|
272 |
|
273 |
-
$node = new
|
274 |
$first = true;
|
275 |
-
while (!$stream->test(
|
276 |
if (!$first) {
|
277 |
-
$stream->expect(
|
278 |
|
279 |
// trailing ,?
|
280 |
-
if ($stream->test(
|
281 |
break;
|
282 |
}
|
283 |
}
|
@@ -289,22 +289,22 @@ class Twig_SupTwg_ExpressionParser
|
|
289 |
// * a string -- 'a'
|
290 |
// * a name, which is equivalent to a string -- a
|
291 |
// * an expression, which must be enclosed in parentheses -- (1 + 2)
|
292 |
-
if (($token = $stream->nextIf(
|
293 |
-
$key = new
|
294 |
-
} elseif ($stream->test(
|
295 |
$key = $this->parseExpression();
|
296 |
} else {
|
297 |
$current = $stream->getCurrent();
|
298 |
|
299 |
-
throw new
|
300 |
}
|
301 |
|
302 |
-
$stream->expect(
|
303 |
$value = $this->parseExpression();
|
304 |
|
305 |
$node->addElement($value, $key);
|
306 |
}
|
307 |
-
$stream->expect(
|
308 |
|
309 |
return $node;
|
310 |
}
|
@@ -313,7 +313,7 @@ class Twig_SupTwg_ExpressionParser
|
|
313 |
{
|
314 |
while (true) {
|
315 |
$token = $this->parser->getCurrentToken();
|
316 |
-
if ($token->getType() ==
|
317 |
if ('.' == $token->getValue() || '[' == $token->getValue()) {
|
318 |
$node = $this->parseSubscriptExpression($node);
|
319 |
} elseif ('|' == $token->getValue()) {
|
@@ -335,36 +335,36 @@ class Twig_SupTwg_ExpressionParser
|
|
335 |
case 'parent':
|
336 |
$this->parseArguments();
|
337 |
if (!count($this->parser->getBlockStack())) {
|
338 |
-
throw new
|
339 |
}
|
340 |
|
341 |
if (!$this->parser->getParent() && !$this->parser->hasTraits()) {
|
342 |
-
throw new
|
343 |
}
|
344 |
|
345 |
-
return new
|
346 |
case 'block':
|
347 |
$args = $this->parseArguments();
|
348 |
if (count($args) < 1) {
|
349 |
-
throw new
|
350 |
}
|
351 |
|
352 |
-
return new
|
353 |
case 'attribute':
|
354 |
$args = $this->parseArguments();
|
355 |
if (count($args) < 2) {
|
356 |
-
throw new
|
357 |
}
|
358 |
|
359 |
-
return new
|
360 |
default:
|
361 |
if (null !== $alias = $this->parser->getImportedSymbol('function', $name)) {
|
362 |
-
$arguments = new
|
363 |
foreach ($this->parseArguments() as $n) {
|
364 |
$arguments->addElement($n);
|
365 |
}
|
366 |
|
367 |
-
$node = new
|
368 |
$node->setAttribute('safe', true);
|
369 |
|
370 |
return $node;
|
@@ -382,81 +382,81 @@ class Twig_SupTwg_ExpressionParser
|
|
382 |
$stream = $this->parser->getStream();
|
383 |
$token = $stream->next();
|
384 |
$lineno = $token->getLine();
|
385 |
-
$arguments = new
|
386 |
-
$type =
|
387 |
if ($token->getValue() == '.') {
|
388 |
$token = $stream->next();
|
389 |
if (
|
390 |
-
$token->getType() ==
|
391 |
||
|
392 |
-
$token->getType() ==
|
393 |
||
|
394 |
-
($token->getType() ==
|
395 |
) {
|
396 |
-
$arg = new
|
397 |
|
398 |
-
if ($stream->test(
|
399 |
-
$type =
|
400 |
foreach ($this->parseArguments() as $n) {
|
401 |
$arguments->addElement($n);
|
402 |
}
|
403 |
}
|
404 |
} else {
|
405 |
-
throw new
|
406 |
}
|
407 |
|
408 |
-
if ($node instanceof
|
409 |
-
if (!$arg instanceof
|
410 |
-
throw new
|
411 |
}
|
412 |
|
413 |
$name = $arg->getAttribute('value');
|
414 |
|
415 |
if ($this->parser->isReservedMacroName($name)) {
|
416 |
-
throw new
|
417 |
}
|
418 |
|
419 |
-
$node = new
|
420 |
$node->setAttribute('safe', true);
|
421 |
|
422 |
return $node;
|
423 |
}
|
424 |
} else {
|
425 |
-
$type =
|
426 |
|
427 |
// slice?
|
428 |
$slice = false;
|
429 |
-
if ($stream->test(
|
430 |
$slice = true;
|
431 |
-
$arg = new
|
432 |
} else {
|
433 |
$arg = $this->parseExpression();
|
434 |
}
|
435 |
|
436 |
-
if ($stream->nextIf(
|
437 |
$slice = true;
|
438 |
}
|
439 |
|
440 |
if ($slice) {
|
441 |
-
if ($stream->test(
|
442 |
-
$length = new
|
443 |
} else {
|
444 |
$length = $this->parseExpression();
|
445 |
}
|
446 |
|
447 |
$class = $this->getFilterNodeClass('slice', $token->getLine());
|
448 |
-
$arguments = new
|
449 |
-
$filter = new $class($node, new
|
450 |
|
451 |
-
$stream->expect(
|
452 |
|
453 |
return $filter;
|
454 |
}
|
455 |
|
456 |
-
$stream->expect(
|
457 |
}
|
458 |
|
459 |
-
return new
|
460 |
}
|
461 |
|
462 |
public function parseFilterExpression($node)
|
@@ -469,11 +469,11 @@ class Twig_SupTwg_ExpressionParser
|
|
469 |
public function parseFilterExpressionRaw($node, $tag = null)
|
470 |
{
|
471 |
while (true) {
|
472 |
-
$token = $this->parser->getStream()->expect(
|
473 |
|
474 |
-
$name = new
|
475 |
-
if (!$this->parser->getStream()->test(
|
476 |
-
$arguments = new
|
477 |
} else {
|
478 |
$arguments = $this->parseArguments(true);
|
479 |
}
|
@@ -482,7 +482,7 @@ class Twig_SupTwg_ExpressionParser
|
|
482 |
|
483 |
$node = new $class($node, $name, $arguments, $token->getLine(), $tag);
|
484 |
|
485 |
-
if (!$this->parser->getStream()->test(
|
486 |
break;
|
487 |
}
|
488 |
|
@@ -498,32 +498,32 @@ class Twig_SupTwg_ExpressionParser
|
|
498 |
* @param bool $namedArguments Whether to allow named arguments or not
|
499 |
* @param bool $definition Whether we are parsing arguments for a function definition
|
500 |
*
|
501 |
-
* @return
|
502 |
*
|
503 |
-
* @throws
|
504 |
*/
|
505 |
public function parseArguments($namedArguments = false, $definition = false)
|
506 |
{
|
507 |
$args = array();
|
508 |
$stream = $this->parser->getStream();
|
509 |
|
510 |
-
$stream->expect(
|
511 |
-
while (!$stream->test(
|
512 |
if (!empty($args)) {
|
513 |
-
$stream->expect(
|
514 |
}
|
515 |
|
516 |
if ($definition) {
|
517 |
-
$token = $stream->expect(
|
518 |
-
$value = new
|
519 |
} else {
|
520 |
$value = $this->parseExpression();
|
521 |
}
|
522 |
|
523 |
$name = null;
|
524 |
-
if ($namedArguments && $token = $stream->nextIf(
|
525 |
-
if (!$value instanceof
|
526 |
-
throw new
|
527 |
}
|
528 |
$name = $value->getAttribute('name');
|
529 |
|
@@ -531,7 +531,7 @@ class Twig_SupTwg_ExpressionParser
|
|
531 |
$value = $this->parsePrimaryExpression();
|
532 |
|
533 |
if (!$this->checkConstantExpression($value)) {
|
534 |
-
throw new
|
535 |
}
|
536 |
} else {
|
537 |
$value = $this->parseExpression();
|
@@ -541,7 +541,7 @@ class Twig_SupTwg_ExpressionParser
|
|
541 |
if ($definition) {
|
542 |
if (null === $name) {
|
543 |
$name = $value->getAttribute('name');
|
544 |
-
$value = new
|
545 |
}
|
546 |
$args[$name] = $value;
|
547 |
} else {
|
@@ -552,9 +552,9 @@ class Twig_SupTwg_ExpressionParser
|
|
552 |
}
|
553 |
}
|
554 |
}
|
555 |
-
$stream->expect(
|
556 |
|
557 |
-
return new
|
558 |
}
|
559 |
|
560 |
public function parseAssignmentExpression()
|
@@ -562,19 +562,19 @@ class Twig_SupTwg_ExpressionParser
|
|
562 |
$stream = $this->parser->getStream();
|
563 |
$targets = array();
|
564 |
while (true) {
|
565 |
-
$token = $stream->expect(
|
566 |
$value = $token->getValue();
|
567 |
if (in_array(strtolower($value), array('true', 'false', 'none', 'null'))) {
|
568 |
-
throw new
|
569 |
}
|
570 |
-
$targets[] = new
|
571 |
|
572 |
-
if (!$stream->nextIf(
|
573 |
break;
|
574 |
}
|
575 |
}
|
576 |
|
577 |
-
return new
|
578 |
}
|
579 |
|
580 |
public function parseMultitargetExpression()
|
@@ -582,27 +582,27 @@ class Twig_SupTwg_ExpressionParser
|
|
582 |
$targets = array();
|
583 |
while (true) {
|
584 |
$targets[] = $this->parseExpression();
|
585 |
-
if (!$this->parser->getStream()->nextIf(
|
586 |
break;
|
587 |
}
|
588 |
}
|
589 |
|
590 |
-
return new
|
591 |
}
|
592 |
|
593 |
-
private function parseNotTestExpression(
|
594 |
{
|
595 |
-
return new
|
596 |
}
|
597 |
|
598 |
-
private function parseTestExpression(
|
599 |
{
|
600 |
$stream = $this->parser->getStream();
|
601 |
list($name, $test) = $this->getTest($node->getTemplateLine());
|
602 |
|
603 |
$class = $this->getTestNodeClass($test);
|
604 |
$arguments = null;
|
605 |
-
if ($stream->test(
|
606 |
$arguments = $this->parser->getExpressionParser()->parseArguments(true);
|
607 |
}
|
608 |
|
@@ -612,13 +612,13 @@ class Twig_SupTwg_ExpressionParser
|
|
612 |
private function getTest($line)
|
613 |
{
|
614 |
$stream = $this->parser->getStream();
|
615 |
-
$name = $stream->expect(
|
616 |
|
617 |
if ($test = $this->env->getTest($name)) {
|
618 |
return array($name, $test);
|
619 |
}
|
620 |
|
621 |
-
if ($stream->test(
|
622 |
// try 2-words tests
|
623 |
$name = $name.' '.$this->parser->getCurrentToken()->getValue();
|
624 |
|
@@ -629,7 +629,7 @@ class Twig_SupTwg_ExpressionParser
|
|
629 |
}
|
630 |
}
|
631 |
|
632 |
-
$e = new
|
633 |
$e->addSuggestions($name, array_keys($this->env->getTests()));
|
634 |
|
635 |
throw $e;
|
@@ -637,7 +637,7 @@ class Twig_SupTwg_ExpressionParser
|
|
637 |
|
638 |
private function getTestNodeClass($test)
|
639 |
{
|
640 |
-
if ($test instanceof
|
641 |
$stream = $this->parser->getStream();
|
642 |
$message = sprintf('Twig Test "%s" is deprecated', $test->getName());
|
643 |
if (!is_bool($test->getDeprecatedVersion())) {
|
@@ -649,26 +649,26 @@ class Twig_SupTwg_ExpressionParser
|
|
649 |
$src = $stream->getSourceContext();
|
650 |
$message .= sprintf(' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $stream->getCurrent()->getLine());
|
651 |
|
652 |
-
|
653 |
}
|
654 |
|
655 |
-
if ($test instanceof
|
656 |
return $test->getNodeClass();
|
657 |
}
|
658 |
|
659 |
-
return $test instanceof
|
660 |
}
|
661 |
|
662 |
protected function getFunctionNodeClass($name, $line)
|
663 |
{
|
664 |
if (false === $function = $this->env->getFunction($name)) {
|
665 |
-
$e = new
|
666 |
$e->addSuggestions($name, array_keys($this->env->getFunctions()));
|
667 |
|
668 |
throw $e;
|
669 |
}
|
670 |
|
671 |
-
if ($function instanceof
|
672 |
$message = sprintf('Twig Function "%s" is deprecated', $function->getName());
|
673 |
if (!is_bool($function->getDeprecatedVersion())) {
|
674 |
$message .= sprintf(' since version %s', $function->getDeprecatedVersion());
|
@@ -679,26 +679,26 @@ class Twig_SupTwg_ExpressionParser
|
|
679 |
$src = $this->parser->getStream()->getSourceContext();
|
680 |
$message .= sprintf(' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $line);
|
681 |
|
682 |
-
|
683 |
}
|
684 |
|
685 |
-
if ($function instanceof
|
686 |
return $function->getNodeClass();
|
687 |
}
|
688 |
|
689 |
-
return $function instanceof
|
690 |
}
|
691 |
|
692 |
protected function getFilterNodeClass($name, $line)
|
693 |
{
|
694 |
if (false === $filter = $this->env->getFilter($name)) {
|
695 |
-
$e = new
|
696 |
$e->addSuggestions($name, array_keys($this->env->getFilters()));
|
697 |
|
698 |
throw $e;
|
699 |
}
|
700 |
|
701 |
-
if ($filter instanceof
|
702 |
$message = sprintf('Twig Filter "%s" is deprecated', $filter->getName());
|
703 |
if (!is_bool($filter->getDeprecatedVersion())) {
|
704 |
$message .= sprintf(' since version %s', $filter->getDeprecatedVersion());
|
@@ -709,21 +709,21 @@ class Twig_SupTwg_ExpressionParser
|
|
709 |
$src = $this->parser->getStream()->getSourceContext();
|
710 |
$message .= sprintf(' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $line);
|
711 |
|
712 |
-
|
713 |
}
|
714 |
|
715 |
-
if ($filter instanceof
|
716 |
return $filter->getNodeClass();
|
717 |
}
|
718 |
|
719 |
-
return $filter instanceof
|
720 |
}
|
721 |
|
722 |
// checks that the node only contains "constant" elements
|
723 |
-
protected function checkConstantExpression(
|
724 |
{
|
725 |
-
if (!($node instanceof
|
726 |
-
|| $node instanceof
|
727 |
)) {
|
728 |
return false;
|
729 |
}
|
22 |
*
|
23 |
* @internal
|
24 |
*/
|
25 |
+
class Twig_SupTwgSgg_ExpressionParser
|
26 |
{
|
27 |
const OPERATOR_LEFT = 1;
|
28 |
const OPERATOR_RIGHT = 2;
|
33 |
|
34 |
private $env;
|
35 |
|
36 |
+
public function __construct(Twig_SupTwgSgg_Parser $parser, $env = null)
|
37 |
{
|
38 |
$this->parser = $parser;
|
39 |
|
40 |
+
if ($env instanceof Twig_SupTwgSgg_Environment) {
|
41 |
$this->env = $env;
|
42 |
$this->unaryOperators = $env->getUnaryOperators();
|
43 |
$this->binaryOperators = $env->getBinaryOperators();
|
44 |
} else {
|
45 |
+
//@trigger_error('Passing the operators as constructor arguments to '.__METHOD__.' is deprecated since version 1.27. Pass the environment instead.', E_USER_DEPRECATED);
|
46 |
|
47 |
$this->env = $parser->getEnvironment();
|
48 |
$this->unaryOperators = func_get_arg(1);
|
91 |
$class = $operator['class'];
|
92 |
|
93 |
return $this->parsePostfixExpression(new $class($expr, $token->getLine()));
|
94 |
+
} elseif ($token->test(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, '(')) {
|
95 |
$this->parser->getStream()->next();
|
96 |
$expr = $this->parseExpression();
|
97 |
+
$this->parser->getStream()->expect(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ')', 'An opened parenthesis is not properly closed');
|
98 |
|
99 |
return $this->parsePostfixExpression($expr);
|
100 |
}
|
104 |
|
105 |
protected function parseConditionalExpression($expr)
|
106 |
{
|
107 |
+
while ($this->parser->getStream()->nextIf(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, '?')) {
|
108 |
+
if (!$this->parser->getStream()->nextIf(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ':')) {
|
109 |
$expr2 = $this->parseExpression();
|
110 |
+
if ($this->parser->getStream()->nextIf(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ':')) {
|
111 |
$expr3 = $this->parseExpression();
|
112 |
} else {
|
113 |
+
$expr3 = new Twig_SupTwgSgg_Node_Expression_Constant('', $this->parser->getCurrentToken()->getLine());
|
114 |
}
|
115 |
} else {
|
116 |
$expr2 = $expr;
|
117 |
$expr3 = $this->parseExpression();
|
118 |
}
|
119 |
|
120 |
+
$expr = new Twig_SupTwgSgg_Node_Expression_Conditional($expr, $expr2, $expr3, $this->parser->getCurrentToken()->getLine());
|
121 |
}
|
122 |
|
123 |
return $expr;
|
124 |
}
|
125 |
|
126 |
+
protected function isUnary(Twig_SupTwgSgg_Token $token)
|
127 |
{
|
128 |
+
return $token->test(Twig_SupTwgSgg_Token::OPERATOR_TYPE) && isset($this->unaryOperators[$token->getValue()]);
|
129 |
}
|
130 |
|
131 |
+
protected function isBinary(Twig_SupTwgSgg_Token $token)
|
132 |
{
|
133 |
+
return $token->test(Twig_SupTwgSgg_Token::OPERATOR_TYPE) && isset($this->binaryOperators[$token->getValue()]);
|
134 |
}
|
135 |
|
136 |
public function parsePrimaryExpression()
|
137 |
{
|
138 |
$token = $this->parser->getCurrentToken();
|
139 |
switch ($token->getType()) {
|
140 |
+
case Twig_SupTwgSgg_Token::NAME_TYPE:
|
141 |
$this->parser->getStream()->next();
|
142 |
switch ($token->getValue()) {
|
143 |
case 'true':
|
144 |
case 'TRUE':
|
145 |
+
$node = new Twig_SupTwgSgg_Node_Expression_Constant(true, $token->getLine());
|
146 |
break;
|
147 |
|
148 |
case 'false':
|
149 |
case 'FALSE':
|
150 |
+
$node = new Twig_SupTwgSgg_Node_Expression_Constant(false, $token->getLine());
|
151 |
break;
|
152 |
|
153 |
case 'none':
|
154 |
case 'NONE':
|
155 |
case 'null':
|
156 |
case 'NULL':
|
157 |
+
$node = new Twig_SupTwgSgg_Node_Expression_Constant(null, $token->getLine());
|
158 |
break;
|
159 |
|
160 |
default:
|
161 |
if ('(' === $this->parser->getCurrentToken()->getValue()) {
|
162 |
$node = $this->getFunctionNode($token->getValue(), $token->getLine());
|
163 |
} else {
|
164 |
+
$node = new Twig_SupTwgSgg_Node_Expression_Name($token->getValue(), $token->getLine());
|
165 |
}
|
166 |
}
|
167 |
break;
|
168 |
|
169 |
+
case Twig_SupTwgSgg_Token::NUMBER_TYPE:
|
170 |
$this->parser->getStream()->next();
|
171 |
+
$node = new Twig_SupTwgSgg_Node_Expression_Constant($token->getValue(), $token->getLine());
|
172 |
break;
|
173 |
|
174 |
+
case Twig_SupTwgSgg_Token::STRING_TYPE:
|
175 |
+
case Twig_SupTwgSgg_Token::INTERPOLATION_START_TYPE:
|
176 |
$node = $this->parseStringExpression();
|
177 |
break;
|
178 |
|
179 |
+
case Twig_SupTwgSgg_Token::OPERATOR_TYPE:
|
180 |
+
if (preg_match(Twig_SupTwgSgg_Lexer::REGEX_NAME, $token->getValue(), $matches) && $matches[0] == $token->getValue()) {
|
181 |
// in this context, string operators are variable names
|
182 |
$this->parser->getStream()->next();
|
183 |
+
$node = new Twig_SupTwgSgg_Node_Expression_Name($token->getValue(), $token->getLine());
|
184 |
break;
|
185 |
} elseif (isset($this->unaryOperators[$token->getValue()])) {
|
186 |
$class = $this->unaryOperators[$token->getValue()]['class'];
|
187 |
|
188 |
$ref = new ReflectionClass($class);
|
189 |
+
$negClass = 'Twig_SupTwgSgg_Node_Expression_Unary_Neg';
|
190 |
+
$posClass = 'Twig_SupTwgSgg_Node_Expression_Unary_Pos';
|
191 |
if (!(in_array($ref->getName(), array($negClass, $posClass)) || $ref->isSubclassOf($negClass) || $ref->isSubclassOf($posClass))) {
|
192 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('Unexpected unary operator "%s".', $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext());
|
193 |
}
|
194 |
|
195 |
$this->parser->getStream()->next();
|
200 |
}
|
201 |
|
202 |
default:
|
203 |
+
if ($token->test(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, '[')) {
|
204 |
$node = $this->parseArrayExpression();
|
205 |
+
} elseif ($token->test(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, '{')) {
|
206 |
$node = $this->parseHashExpression();
|
207 |
} else {
|
208 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('Unexpected token "%s" of value "%s".', Twig_SupTwgSgg_Token::typeToEnglish($token->getType()), $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext());
|
209 |
}
|
210 |
}
|
211 |
|
220 |
// a string cannot be followed by another string in a single expression
|
221 |
$nextCanBeString = true;
|
222 |
while (true) {
|
223 |
+
if ($nextCanBeString && $token = $stream->nextIf(Twig_SupTwgSgg_Token::STRING_TYPE)) {
|
224 |
+
$nodes[] = new Twig_SupTwgSgg_Node_Expression_Constant($token->getValue(), $token->getLine());
|
225 |
$nextCanBeString = false;
|
226 |
+
} elseif ($stream->nextIf(Twig_SupTwgSgg_Token::INTERPOLATION_START_TYPE)) {
|
227 |
$nodes[] = $this->parseExpression();
|
228 |
+
$stream->expect(Twig_SupTwgSgg_Token::INTERPOLATION_END_TYPE);
|
229 |
$nextCanBeString = true;
|
230 |
} else {
|
231 |
break;
|
234 |
|
235 |
$expr = array_shift($nodes);
|
236 |
foreach ($nodes as $node) {
|
237 |
+
$expr = new Twig_SupTwgSgg_Node_Expression_Binary_Concat($expr, $node, $node->getTemplateLine());
|
238 |
}
|
239 |
|
240 |
return $expr;
|
243 |
public function parseArrayExpression()
|
244 |
{
|
245 |
$stream = $this->parser->getStream();
|
246 |
+
$stream->expect(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, '[', 'An array element was expected');
|
247 |
|
248 |
+
$node = new Twig_SupTwgSgg_Node_Expression_Array(array(), $stream->getCurrent()->getLine());
|
249 |
$first = true;
|
250 |
+
while (!$stream->test(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ']')) {
|
251 |
if (!$first) {
|
252 |
+
$stream->expect(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ',', 'An array element must be followed by a comma');
|
253 |
|
254 |
// trailing ,?
|
255 |
+
if ($stream->test(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ']')) {
|
256 |
break;
|
257 |
}
|
258 |
}
|
260 |
|
261 |
$node->addElement($this->parseExpression());
|
262 |
}
|
263 |
+
$stream->expect(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ']', 'An opened array is not properly closed');
|
264 |
|
265 |
return $node;
|
266 |
}
|
268 |
public function parseHashExpression()
|
269 |
{
|
270 |
$stream = $this->parser->getStream();
|
271 |
+
$stream->expect(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, '{', 'A hash element was expected');
|
272 |
|
273 |
+
$node = new Twig_SupTwgSgg_Node_Expression_Array(array(), $stream->getCurrent()->getLine());
|
274 |
$first = true;
|
275 |
+
while (!$stream->test(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, '}')) {
|
276 |
if (!$first) {
|
277 |
+
$stream->expect(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ',', 'A hash value must be followed by a comma');
|
278 |
|
279 |
// trailing ,?
|
280 |
+
if ($stream->test(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, '}')) {
|
281 |
break;
|
282 |
}
|
283 |
}
|
289 |
// * a string -- 'a'
|
290 |
// * a name, which is equivalent to a string -- a
|
291 |
// * an expression, which must be enclosed in parentheses -- (1 + 2)
|
292 |
+
if (($token = $stream->nextIf(Twig_SupTwgSgg_Token::STRING_TYPE)) || ($token = $stream->nextIf(Twig_SupTwgSgg_Token::NAME_TYPE)) || $token = $stream->nextIf(Twig_SupTwgSgg_Token::NUMBER_TYPE)) {
|
293 |
+
$key = new Twig_SupTwgSgg_Node_Expression_Constant($token->getValue(), $token->getLine());
|
294 |
+
} elseif ($stream->test(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, '(')) {
|
295 |
$key = $this->parseExpression();
|
296 |
} else {
|
297 |
$current = $stream->getCurrent();
|
298 |
|
299 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token "%s" of value "%s".', Twig_SupTwgSgg_Token::typeToEnglish($current->getType()), $current->getValue()), $current->getLine(), $stream->getSourceContext());
|
300 |
}
|
301 |
|
302 |
+
$stream->expect(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ':', 'A hash key must be followed by a colon (:)');
|
303 |
$value = $this->parseExpression();
|
304 |
|
305 |
$node->addElement($value, $key);
|
306 |
}
|
307 |
+
$stream->expect(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, '}', 'An opened hash is not properly closed');
|
308 |
|
309 |
return $node;
|
310 |
}
|
313 |
{
|
314 |
while (true) {
|
315 |
$token = $this->parser->getCurrentToken();
|
316 |
+
if ($token->getType() == Twig_SupTwgSgg_Token::PUNCTUATION_TYPE) {
|
317 |
if ('.' == $token->getValue() || '[' == $token->getValue()) {
|
318 |
$node = $this->parseSubscriptExpression($node);
|
319 |
} elseif ('|' == $token->getValue()) {
|
335 |
case 'parent':
|
336 |
$this->parseArguments();
|
337 |
if (!count($this->parser->getBlockStack())) {
|
338 |
+
throw new Twig_SupTwgSgg_Error_Syntax('Calling "parent" outside a block is forbidden.', $line, $this->parser->getStream()->getSourceContext());
|
339 |
}
|
340 |
|
341 |
if (!$this->parser->getParent() && !$this->parser->hasTraits()) {
|
342 |
+
throw new Twig_SupTwgSgg_Error_Syntax('Calling "parent" on a template that does not extend nor "use" another template is forbidden.', $line, $this->parser->getStream()->getSourceContext());
|
343 |
}
|
344 |
|
345 |
+
return new Twig_SupTwgSgg_Node_Expression_Parent($this->parser->peekBlockStack(), $line);
|
346 |
case 'block':
|
347 |
$args = $this->parseArguments();
|
348 |
if (count($args) < 1) {
|
349 |
+
throw new Twig_SupTwgSgg_Error_Syntax('The "block" function takes one argument (the block name).', $line, $this->parser->getStream()->getSourceContext());
|
350 |
}
|
351 |
|
352 |
+
return new Twig_SupTwgSgg_Node_Expression_BlockReference($args->getNode(0), count($args) > 1 ? $args->getNode(1) : null, $line);
|
353 |
case 'attribute':
|
354 |
$args = $this->parseArguments();
|
355 |
if (count($args) < 2) {
|
356 |
+
throw new Twig_SupTwgSgg_Error_Syntax('The "attribute" function takes at least two arguments (the variable and the attributes).', $line, $this->parser->getStream()->getSourceContext());
|
357 |
}
|
358 |
|
359 |
+
return new Twig_SupTwgSgg_Node_Expression_GetAttr($args->getNode(0), $args->getNode(1), count($args) > 2 ? $args->getNode(2) : null, Twig_SupTwgSgg_Template::ANY_CALL, $line);
|
360 |
default:
|
361 |
if (null !== $alias = $this->parser->getImportedSymbol('function', $name)) {
|
362 |
+
$arguments = new Twig_SupTwgSgg_Node_Expression_Array(array(), $line);
|
363 |
foreach ($this->parseArguments() as $n) {
|
364 |
$arguments->addElement($n);
|
365 |
}
|
366 |
|
367 |
+
$node = new Twig_SupTwgSgg_Node_Expression_MethodCall($alias['node'], $alias['name'], $arguments, $line);
|
368 |
$node->setAttribute('safe', true);
|
369 |
|
370 |
return $node;
|
382 |
$stream = $this->parser->getStream();
|
383 |
$token = $stream->next();
|
384 |
$lineno = $token->getLine();
|
385 |
+
$arguments = new Twig_SupTwgSgg_Node_Expression_Array(array(), $lineno);
|
386 |
+
$type = Twig_SupTwgSgg_Template::ANY_CALL;
|
387 |
if ($token->getValue() == '.') {
|
388 |
$token = $stream->next();
|
389 |
if (
|
390 |
+
$token->getType() == Twig_SupTwgSgg_Token::NAME_TYPE
|
391 |
||
|
392 |
+
$token->getType() == Twig_SupTwgSgg_Token::NUMBER_TYPE
|
393 |
||
|
394 |
+
($token->getType() == Twig_SupTwgSgg_Token::OPERATOR_TYPE && preg_match(Twig_SupTwgSgg_Lexer::REGEX_NAME, $token->getValue()))
|
395 |
) {
|
396 |
+
$arg = new Twig_SupTwgSgg_Node_Expression_Constant($token->getValue(), $lineno);
|
397 |
|
398 |
+
if ($stream->test(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, '(')) {
|
399 |
+
$type = Twig_SupTwgSgg_Template::METHOD_CALL;
|
400 |
foreach ($this->parseArguments() as $n) {
|
401 |
$arguments->addElement($n);
|
402 |
}
|
403 |
}
|
404 |
} else {
|
405 |
+
throw new Twig_SupTwgSgg_Error_Syntax('Expected name or number.', $lineno, $stream->getSourceContext());
|
406 |
}
|
407 |
|
408 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Expression_Name && null !== $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) {
|
409 |
+
if (!$arg instanceof Twig_SupTwgSgg_Node_Expression_Constant) {
|
410 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('Dynamic macro names are not supported (called on "%s").', $node->getAttribute('name')), $token->getLine(), $stream->getSourceContext());
|
411 |
}
|
412 |
|
413 |
$name = $arg->getAttribute('value');
|
414 |
|
415 |
if ($this->parser->isReservedMacroName($name)) {
|
416 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('"%s" cannot be called as macro as it is a reserved keyword.', $name), $token->getLine(), $stream->getSourceContext());
|
417 |
}
|
418 |
|
419 |
+
$node = new Twig_SupTwgSgg_Node_Expression_MethodCall($node, 'get'.$name, $arguments, $lineno);
|
420 |
$node->setAttribute('safe', true);
|
421 |
|
422 |
return $node;
|
423 |
}
|
424 |
} else {
|
425 |
+
$type = Twig_SupTwgSgg_Template::ARRAY_CALL;
|
426 |
|
427 |
// slice?
|
428 |
$slice = false;
|
429 |
+
if ($stream->test(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ':')) {
|
430 |
$slice = true;
|
431 |
+
$arg = new Twig_SupTwgSgg_Node_Expression_Constant(0, $token->getLine());
|
432 |
} else {
|
433 |
$arg = $this->parseExpression();
|
434 |
}
|
435 |
|
436 |
+
if ($stream->nextIf(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ':')) {
|
437 |
$slice = true;
|
438 |
}
|
439 |
|
440 |
if ($slice) {
|
441 |
+
if ($stream->test(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ']')) {
|
442 |
+
$length = new Twig_SupTwgSgg_Node_Expression_Constant(null, $token->getLine());
|
443 |
} else {
|
444 |
$length = $this->parseExpression();
|
445 |
}
|
446 |
|
447 |
$class = $this->getFilterNodeClass('slice', $token->getLine());
|
448 |
+
$arguments = new Twig_SupTwgSgg_Node(array($arg, $length));
|
449 |
+
$filter = new $class($node, new Twig_SupTwgSgg_Node_Expression_Constant('slice', $token->getLine()), $arguments, $token->getLine());
|
450 |
|
451 |
+
$stream->expect(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ']');
|
452 |
|
453 |
return $filter;
|
454 |
}
|
455 |
|
456 |
+
$stream->expect(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ']');
|
457 |
}
|
458 |
|
459 |
+
return new Twig_SupTwgSgg_Node_Expression_GetAttr($node, $arg, $arguments, $type, $lineno);
|
460 |
}
|
461 |
|
462 |
public function parseFilterExpression($node)
|
469 |
public function parseFilterExpressionRaw($node, $tag = null)
|
470 |
{
|
471 |
while (true) {
|
472 |
+
$token = $this->parser->getStream()->expect(Twig_SupTwgSgg_Token::NAME_TYPE);
|
473 |
|
474 |
+
$name = new Twig_SupTwgSgg_Node_Expression_Constant($token->getValue(), $token->getLine());
|
475 |
+
if (!$this->parser->getStream()->test(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, '(')) {
|
476 |
+
$arguments = new Twig_SupTwgSgg_Node();
|
477 |
} else {
|
478 |
$arguments = $this->parseArguments(true);
|
479 |
}
|
482 |
|
483 |
$node = new $class($node, $name, $arguments, $token->getLine(), $tag);
|
484 |
|
485 |
+
if (!$this->parser->getStream()->test(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, '|')) {
|
486 |
break;
|
487 |
}
|
488 |
|
498 |
* @param bool $namedArguments Whether to allow named arguments or not
|
499 |
* @param bool $definition Whether we are parsing arguments for a function definition
|
500 |
*
|
501 |
+
* @return Twig_SupTwgSgg_Node
|
502 |
*
|
503 |
+
* @throws Twig_SupTwgSgg_Error_Syntax
|
504 |
*/
|
505 |
public function parseArguments($namedArguments = false, $definition = false)
|
506 |
{
|
507 |
$args = array();
|
508 |
$stream = $this->parser->getStream();
|
509 |
|
510 |
+
$stream->expect(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, '(', 'A list of arguments must begin with an opening parenthesis');
|
511 |
+
while (!$stream->test(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ')')) {
|
512 |
if (!empty($args)) {
|
513 |
+
$stream->expect(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ',', 'Arguments must be separated by a comma');
|
514 |
}
|
515 |
|
516 |
if ($definition) {
|
517 |
+
$token = $stream->expect(Twig_SupTwgSgg_Token::NAME_TYPE, null, 'An argument must be a name');
|
518 |
+
$value = new Twig_SupTwgSgg_Node_Expression_Name($token->getValue(), $this->parser->getCurrentToken()->getLine());
|
519 |
} else {
|
520 |
$value = $this->parseExpression();
|
521 |
}
|
522 |
|
523 |
$name = null;
|
524 |
+
if ($namedArguments && $token = $stream->nextIf(Twig_SupTwgSgg_Token::OPERATOR_TYPE, '=')) {
|
525 |
+
if (!$value instanceof Twig_SupTwgSgg_Node_Expression_Name) {
|
526 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('A parameter name must be a string, "%s" given.', get_class($value)), $token->getLine(), $stream->getSourceContext());
|
527 |
}
|
528 |
$name = $value->getAttribute('name');
|
529 |
|
531 |
$value = $this->parsePrimaryExpression();
|
532 |
|
533 |
if (!$this->checkConstantExpression($value)) {
|
534 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('A default value for an argument must be a constant (a boolean, a string, a number, or an array).'), $token->getLine(), $stream->getSourceContext());
|
535 |
}
|
536 |
} else {
|
537 |
$value = $this->parseExpression();
|
541 |
if ($definition) {
|
542 |
if (null === $name) {
|
543 |
$name = $value->getAttribute('name');
|
544 |
+
$value = new Twig_SupTwgSgg_Node_Expression_Constant(null, $this->parser->getCurrentToken()->getLine());
|
545 |
}
|
546 |
$args[$name] = $value;
|
547 |
} else {
|
552 |
}
|
553 |
}
|
554 |
}
|
555 |
+
$stream->expect(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ')', 'A list of arguments must be closed by a parenthesis');
|
556 |
|
557 |
+
return new Twig_SupTwgSgg_Node($args);
|
558 |
}
|
559 |
|
560 |
public function parseAssignmentExpression()
|
562 |
$stream = $this->parser->getStream();
|
563 |
$targets = array();
|
564 |
while (true) {
|
565 |
+
$token = $stream->expect(Twig_SupTwgSgg_Token::NAME_TYPE, null, 'Only variables can be assigned to');
|
566 |
$value = $token->getValue();
|
567 |
if (in_array(strtolower($value), array('true', 'false', 'none', 'null'))) {
|
568 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('You cannot assign a value to "%s".', $value), $token->getLine(), $stream->getSourceContext());
|
569 |
}
|
570 |
+
$targets[] = new Twig_SupTwgSgg_Node_Expression_AssignName($value, $token->getLine());
|
571 |
|
572 |
+
if (!$stream->nextIf(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ',')) {
|
573 |
break;
|
574 |
}
|
575 |
}
|
576 |
|
577 |
+
return new Twig_SupTwgSgg_Node($targets);
|
578 |
}
|
579 |
|
580 |
public function parseMultitargetExpression()
|
582 |
$targets = array();
|
583 |
while (true) {
|
584 |
$targets[] = $this->parseExpression();
|
585 |
+
if (!$this->parser->getStream()->nextIf(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ',')) {
|
586 |
break;
|
587 |
}
|
588 |
}
|
589 |
|
590 |
+
return new Twig_SupTwgSgg_Node($targets);
|
591 |
}
|
592 |
|
593 |
+
private function parseNotTestExpression(Twig_SupTwgSgg_NodeInterface $node)
|
594 |
{
|
595 |
+
return new Twig_SupTwgSgg_Node_Expression_Unary_Not($this->parseTestExpression($node), $this->parser->getCurrentToken()->getLine());
|
596 |
}
|
597 |
|
598 |
+
private function parseTestExpression(Twig_SupTwgSgg_NodeInterface $node)
|
599 |
{
|
600 |
$stream = $this->parser->getStream();
|
601 |
list($name, $test) = $this->getTest($node->getTemplateLine());
|
602 |
|
603 |
$class = $this->getTestNodeClass($test);
|
604 |
$arguments = null;
|
605 |
+
if ($stream->test(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, '(')) {
|
606 |
$arguments = $this->parser->getExpressionParser()->parseArguments(true);
|
607 |
}
|
608 |
|
612 |
private function getTest($line)
|
613 |
{
|
614 |
$stream = $this->parser->getStream();
|
615 |
+
$name = $stream->expect(Twig_SupTwgSgg_Token::NAME_TYPE)->getValue();
|
616 |
|
617 |
if ($test = $this->env->getTest($name)) {
|
618 |
return array($name, $test);
|
619 |
}
|
620 |
|
621 |
+
if ($stream->test(Twig_SupTwgSgg_Token::NAME_TYPE)) {
|
622 |
// try 2-words tests
|
623 |
$name = $name.' '.$this->parser->getCurrentToken()->getValue();
|
624 |
|
629 |
}
|
630 |
}
|
631 |
|
632 |
+
$e = new Twig_SupTwgSgg_Error_Syntax(sprintf('Unknown "%s" test.', $name), $line, $stream->getSourceContext());
|
633 |
$e->addSuggestions($name, array_keys($this->env->getTests()));
|
634 |
|
635 |
throw $e;
|
637 |
|
638 |
private function getTestNodeClass($test)
|
639 |
{
|
640 |
+
if ($test instanceof Twig_SupTwgSgg_SimpleTest && $test->isDeprecated()) {
|
641 |
$stream = $this->parser->getStream();
|
642 |
$message = sprintf('Twig Test "%s" is deprecated', $test->getName());
|
643 |
if (!is_bool($test->getDeprecatedVersion())) {
|
649 |
$src = $stream->getSourceContext();
|
650 |
$message .= sprintf(' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $stream->getCurrent()->getLine());
|
651 |
|
652 |
+
//@trigger_error($message, E_USER_DEPRECATED);
|
653 |
}
|
654 |
|
655 |
+
if ($test instanceof Twig_SupTwgSgg_SimpleTest) {
|
656 |
return $test->getNodeClass();
|
657 |
}
|
658 |
|
659 |
+
return $test instanceof Twig_SupTwgSgg_Test_Node ? $test->getClass() : 'Twig_SupTwgSgg_Node_Expression_Test';
|
660 |
}
|
661 |
|
662 |
protected function getFunctionNodeClass($name, $line)
|
663 |
{
|
664 |
if (false === $function = $this->env->getFunction($name)) {
|
665 |
+
$e = new Twig_SupTwgSgg_Error_Syntax(sprintf('Unknown "%s" function.', $name), $line, $this->parser->getStream()->getSourceContext());
|
666 |
$e->addSuggestions($name, array_keys($this->env->getFunctions()));
|
667 |
|
668 |
throw $e;
|
669 |
}
|
670 |
|
671 |
+
if ($function instanceof Twig_SupTwgSgg_SimpleFunction && $function->isDeprecated()) {
|
672 |
$message = sprintf('Twig Function "%s" is deprecated', $function->getName());
|
673 |
if (!is_bool($function->getDeprecatedVersion())) {
|
674 |
$message .= sprintf(' since version %s', $function->getDeprecatedVersion());
|
679 |
$src = $this->parser->getStream()->getSourceContext();
|
680 |
$message .= sprintf(' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $line);
|
681 |
|
682 |
+
//@trigger_error($message, E_USER_DEPRECATED);
|
683 |
}
|
684 |
|
685 |
+
if ($function instanceof Twig_SupTwgSgg_SimpleFunction) {
|
686 |
return $function->getNodeClass();
|
687 |
}
|
688 |
|
689 |
+
return $function instanceof Twig_SupTwgSgg_Function_Node ? $function->getClass() : 'Twig_SupTwgSgg_Node_Expression_Function';
|
690 |
}
|
691 |
|
692 |
protected function getFilterNodeClass($name, $line)
|
693 |
{
|
694 |
if (false === $filter = $this->env->getFilter($name)) {
|
695 |
+
$e = new Twig_SupTwgSgg_Error_Syntax(sprintf('Unknown "%s" filter.', $name), $line, $this->parser->getStream()->getSourceContext());
|
696 |
$e->addSuggestions($name, array_keys($this->env->getFilters()));
|
697 |
|
698 |
throw $e;
|
699 |
}
|
700 |
|
701 |
+
if ($filter instanceof Twig_SupTwgSgg_SimpleFilter && $filter->isDeprecated()) {
|
702 |
$message = sprintf('Twig Filter "%s" is deprecated', $filter->getName());
|
703 |
if (!is_bool($filter->getDeprecatedVersion())) {
|
704 |
$message .= sprintf(' since version %s', $filter->getDeprecatedVersion());
|
709 |
$src = $this->parser->getStream()->getSourceContext();
|
710 |
$message .= sprintf(' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $line);
|
711 |
|
712 |
+
//@trigger_error($message, E_USER_DEPRECATED);
|
713 |
}
|
714 |
|
715 |
+
if ($filter instanceof Twig_SupTwgSgg_SimpleFilter) {
|
716 |
return $filter->getNodeClass();
|
717 |
}
|
718 |
|
719 |
+
return $filter instanceof Twig_SupTwgSgg_Filter_Node ? $filter->getClass() : 'Twig_SupTwgSgg_Node_Expression_Filter';
|
720 |
}
|
721 |
|
722 |
// checks that the node only contains "constant" elements
|
723 |
+
protected function checkConstantExpression(Twig_SupTwgSgg_NodeInterface $node)
|
724 |
{
|
725 |
+
if (!($node instanceof Twig_SupTwgSgg_Node_Expression_Constant || $node instanceof Twig_SupTwgSgg_Node_Expression_Array
|
726 |
+
|| $node instanceof Twig_SupTwgSgg_Node_Expression_Unary_Neg || $node instanceof Twig_SupTwgSgg_Node_Expression_Unary_Pos
|
727 |
)) {
|
728 |
return false;
|
729 |
}
|
vendor/Twig/Extension.php
CHANGED
@@ -8,12 +8,12 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
abstract class
|
12 |
{
|
13 |
/**
|
14 |
-
* @deprecated since 1.23 (to be removed in 2.0), implement
|
15 |
*/
|
16 |
-
public function initRuntime(
|
17 |
{
|
18 |
}
|
19 |
|
@@ -48,7 +48,7 @@ abstract class Twig_SupTwg_Extension implements Twig_SupTwg_ExtensionInterface
|
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
-
* @deprecated since 1.23 (to be removed in 2.0), implement
|
52 |
*/
|
53 |
public function getGlobals()
|
54 |
{
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
abstract class Twig_SupTwgSgg_Extension implements Twig_SupTwgSgg_ExtensionInterface
|
12 |
{
|
13 |
/**
|
14 |
+
* @deprecated since 1.23 (to be removed in 2.0), implement Twig_SupTwgSgg_Extension_InitRuntimeInterface instead
|
15 |
*/
|
16 |
+
public function initRuntime(Twig_SupTwgSgg_Environment $environment)
|
17 |
{
|
18 |
}
|
19 |
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
+
* @deprecated since 1.23 (to be removed in 2.0), implement Twig_SupTwgSgg_Extension_GlobalsInterface instead
|
52 |
*/
|
53 |
public function getGlobals()
|
54 |
{
|
vendor/Twig/Extension/Core.php
CHANGED
@@ -17,7 +17,7 @@ if (!defined('ENT_SUBSTITUTE')) {
|
|
17 |
/**
|
18 |
* @final
|
19 |
*/
|
20 |
-
class
|
21 |
{
|
22 |
protected $dateFormats = array('F j, Y H:i', '%d days');
|
23 |
protected $numberFormat = array(0, '.', ',');
|
@@ -121,22 +121,22 @@ class Twig_SupTwg_Extension_Core extends Twig_SupTwg_Extension
|
|
121 |
public function getTokenParsers()
|
122 |
{
|
123 |
return array(
|
124 |
-
new
|
125 |
-
new
|
126 |
-
new
|
127 |
-
new
|
128 |
-
new
|
129 |
-
new
|
130 |
-
new
|
131 |
-
new
|
132 |
-
new
|
133 |
-
new
|
134 |
-
new
|
135 |
-
new
|
136 |
-
new
|
137 |
-
new
|
138 |
-
new
|
139 |
-
new
|
140 |
);
|
141 |
}
|
142 |
|
@@ -144,54 +144,54 @@ class Twig_SupTwg_Extension_Core extends Twig_SupTwg_Extension
|
|
144 |
{
|
145 |
$filters = array(
|
146 |
// formatting filters
|
147 |
-
new
|
148 |
-
new
|
149 |
-
new
|
150 |
-
new
|
151 |
-
new
|
152 |
-
new
|
153 |
-
new
|
154 |
|
155 |
// encoding
|
156 |
-
new
|
157 |
-
new
|
158 |
-
new
|
159 |
|
160 |
// string filters
|
161 |
-
new
|
162 |
-
new
|
163 |
-
new
|
164 |
-
new
|
165 |
-
new
|
166 |
-
new
|
167 |
-
new
|
168 |
|
169 |
// array helpers
|
170 |
-
new
|
171 |
-
new
|
172 |
-
new
|
173 |
-
new
|
174 |
-
new
|
175 |
|
176 |
// string/array filters
|
177 |
-
new
|
178 |
-
new
|
179 |
-
new
|
180 |
-
new
|
181 |
-
new
|
182 |
|
183 |
// iteration and runtime
|
184 |
-
new
|
185 |
-
new
|
186 |
|
187 |
// escaping
|
188 |
-
new
|
189 |
-
new
|
190 |
);
|
191 |
|
192 |
if (function_exists('mb_get_info')) {
|
193 |
-
$filters[] = new
|
194 |
-
$filters[] = new
|
195 |
}
|
196 |
|
197 |
return $filters;
|
@@ -200,33 +200,33 @@ class Twig_SupTwg_Extension_Core extends Twig_SupTwg_Extension
|
|
200 |
public function getFunctions()
|
201 |
{
|
202 |
return array(
|
203 |
-
new
|
204 |
-
new
|
205 |
-
new
|
206 |
-
new
|
207 |
-
new
|
208 |
-
new
|
209 |
-
new
|
210 |
-
new
|
211 |
-
new
|
212 |
);
|
213 |
}
|
214 |
|
215 |
public function getTests()
|
216 |
{
|
217 |
return array(
|
218 |
-
new
|
219 |
-
new
|
220 |
-
new
|
221 |
-
new
|
222 |
-
new
|
223 |
-
new
|
224 |
-
new
|
225 |
-
new
|
226 |
-
new
|
227 |
-
new
|
228 |
-
new
|
229 |
-
new
|
230 |
);
|
231 |
}
|
232 |
|
@@ -234,39 +234,39 @@ class Twig_SupTwg_Extension_Core extends Twig_SupTwg_Extension
|
|
234 |
{
|
235 |
return array(
|
236 |
array(
|
237 |
-
'not' => array('precedence' => 50, 'class' => '
|
238 |
-
'-' => array('precedence' => 500, 'class' => '
|
239 |
-
'+' => array('precedence' => 500, 'class' => '
|
240 |
),
|
241 |
array(
|
242 |
-
'or' => array('precedence' => 10, 'class' => '
|
243 |
-
'and' => array('precedence' => 15, 'class' => '
|
244 |
-
'b-or' => array('precedence' => 16, 'class' => '
|
245 |
-
'b-xor' => array('precedence' => 17, 'class' => '
|
246 |
-
'b-and' => array('precedence' => 18, 'class' => '
|
247 |
-
'==' => array('precedence' => 20, 'class' => '
|
248 |
-
'!=' => array('precedence' => 20, 'class' => '
|
249 |
-
'<' => array('precedence' => 20, 'class' => '
|
250 |
-
'>' => array('precedence' => 20, 'class' => '
|
251 |
-
'>=' => array('precedence' => 20, 'class' => '
|
252 |
-
'<=' => array('precedence' => 20, 'class' => '
|
253 |
-
'not in' => array('precedence' => 20, 'class' => '
|
254 |
-
'in' => array('precedence' => 20, 'class' => '
|
255 |
-
'matches' => array('precedence' => 20, 'class' => '
|
256 |
-
'starts with' => array('precedence' => 20, 'class' => '
|
257 |
-
'ends with' => array('precedence' => 20, 'class' => '
|
258 |
-
'..' => array('precedence' => 25, 'class' => '
|
259 |
-
'+' => array('precedence' => 30, 'class' => '
|
260 |
-
'-' => array('precedence' => 30, 'class' => '
|
261 |
-
'~' => array('precedence' => 40, 'class' => '
|
262 |
-
'*' => array('precedence' => 60, 'class' => '
|
263 |
-
'/' => array('precedence' => 60, 'class' => '
|
264 |
-
'//' => array('precedence' => 60, 'class' => '
|
265 |
-
'%' => array('precedence' => 60, 'class' => '
|
266 |
-
'is' => array('precedence' => 100, 'associativity' =>
|
267 |
-
'is not' => array('precedence' => 100, 'associativity' =>
|
268 |
-
'**' => array('precedence' => 200, 'class' => '
|
269 |
-
'??' => array('precedence' => 300, 'class' => '
|
270 |
),
|
271 |
);
|
272 |
}
|
@@ -285,7 +285,7 @@ class Twig_SupTwg_Extension_Core extends Twig_SupTwg_Extension
|
|
285 |
*
|
286 |
* @return string The next value in the cycle
|
287 |
*/
|
288 |
-
function
|
289 |
{
|
290 |
if (!is_array($values) && !$values instanceof ArrayAccess) {
|
291 |
return $values;
|
@@ -300,14 +300,14 @@ function Twig_SupTwg_cycle($values, $position)
|
|
300 |
* - a random character from a string
|
301 |
* - a random integer between 0 and the integer parameter.
|
302 |
*
|
303 |
-
* @param
|
304 |
* @param Traversable|array|int|float|string $values The values to pick a random item from
|
305 |
*
|
306 |
-
* @throws
|
307 |
*
|
308 |
* @return mixed A random value from the given sequence
|
309 |
*/
|
310 |
-
function
|
311 |
{
|
312 |
if (null === $values) {
|
313 |
return mt_rand();
|
@@ -325,7 +325,7 @@ function Twig_SupTwg_random(Twig_SupTwg_Environment $env, $values = null)
|
|
325 |
}
|
326 |
if (null !== $charset = $env->getCharset()) {
|
327 |
if ('UTF-8' !== $charset) {
|
328 |
-
$values =
|
329 |
}
|
330 |
|
331 |
// unicode version of str_split()
|
@@ -334,7 +334,7 @@ function Twig_SupTwg_random(Twig_SupTwg_Environment $env, $values = null)
|
|
334 |
|
335 |
if ('UTF-8' !== $charset) {
|
336 |
foreach ($values as $i => $value) {
|
337 |
-
$values[$i] =
|
338 |
}
|
339 |
}
|
340 |
} else {
|
@@ -347,7 +347,7 @@ function Twig_SupTwg_random(Twig_SupTwg_Environment $env, $values = null)
|
|
347 |
}
|
348 |
|
349 |
if (0 === count($values)) {
|
350 |
-
throw new
|
351 |
}
|
352 |
|
353 |
return $values[array_rand($values, 1)];
|
@@ -360,17 +360,17 @@ function Twig_SupTwg_random(Twig_SupTwg_Environment $env, $values = null)
|
|
360 |
* {{ post.published_at|date("m/d/Y") }}
|
361 |
* </pre>
|
362 |
*
|
363 |
-
* @param
|
364 |
* @param DateTime|DateTimeInterface|DateInterval|string $date A date
|
365 |
* @param string|null $format The target format, null to use the default
|
366 |
* @param DateTimeZone|string|null|false $timezone The target timezone, null to use the default, false to leave unchanged
|
367 |
*
|
368 |
* @return string The formatted date
|
369 |
*/
|
370 |
-
function
|
371 |
{
|
372 |
if (null === $format) {
|
373 |
-
$formats = $env->getExtension('
|
374 |
$format = $date instanceof DateInterval ? $formats[1] : $formats[0];
|
375 |
}
|
376 |
|
@@ -378,7 +378,7 @@ function Twig_SupTwg_date_format_filter(Twig_SupTwg_Environment $env, $date, $fo
|
|
378 |
return $date->format($format);
|
379 |
}
|
380 |
|
381 |
-
return
|
382 |
}
|
383 |
|
384 |
/**
|
@@ -388,15 +388,15 @@ function Twig_SupTwg_date_format_filter(Twig_SupTwg_Environment $env, $date, $fo
|
|
388 |
* {{ post.published_at|date_modify("-1day")|date("m/d/Y") }}
|
389 |
* </pre>
|
390 |
*
|
391 |
-
* @param
|
392 |
* @param DateTime|string $date A date
|
393 |
* @param string $modifier A modifier string
|
394 |
*
|
395 |
* @return DateTime A new date object
|
396 |
*/
|
397 |
-
function
|
398 |
{
|
399 |
-
$date =
|
400 |
$resultDate = $date->modify($modifier);
|
401 |
|
402 |
// This is a hack to ensure PHP 5.2 support and support for DateTimeImmutable
|
@@ -414,18 +414,18 @@ function Twig_SupTwg_date_modify_filter(Twig_SupTwg_Environment $env, $date, $mo
|
|
414 |
* {% endif %}
|
415 |
* </pre>
|
416 |
*
|
417 |
-
* @param
|
418 |
* @param DateTime|DateTimeInterface|string|null $date A date
|
419 |
* @param DateTimeZone|string|null|false $timezone The target timezone, null to use the default, false to leave unchanged
|
420 |
*
|
421 |
* @return DateTime A DateTime instance
|
422 |
*/
|
423 |
-
function
|
424 |
{
|
425 |
// determine the timezone
|
426 |
if (false !== $timezone) {
|
427 |
if (null === $timezone) {
|
428 |
-
$timezone = $env->getExtension('
|
429 |
} elseif (!$timezone instanceof DateTimeZone) {
|
430 |
$timezone = new DateTimeZone($timezone);
|
431 |
}
|
@@ -446,14 +446,14 @@ function Twig_SupTwg_date_converter(Twig_SupTwg_Environment $env, $date = null,
|
|
446 |
}
|
447 |
|
448 |
if (null === $date || 'now' === $date) {
|
449 |
-
return new DateTime($date, false !== $timezone ? $timezone : $env->getExtension('
|
450 |
}
|
451 |
|
452 |
$asString = (string) $date;
|
453 |
if (ctype_digit($asString) || (!empty($asString) && '-' === $asString[0] && ctype_digit(substr($asString, 1)))) {
|
454 |
$date = new DateTime('@'.$date);
|
455 |
} else {
|
456 |
-
$date = new DateTime($date, $env->getExtension('
|
457 |
}
|
458 |
|
459 |
if (false !== $timezone) {
|
@@ -472,16 +472,16 @@ function Twig_SupTwg_date_converter(Twig_SupTwg_Environment $env, $date = null,
|
|
472 |
*
|
473 |
* @return string
|
474 |
*/
|
475 |
-
function
|
476 |
{
|
477 |
if ($from instanceof Traversable) {
|
478 |
$from = iterator_to_array($from);
|
479 |
} elseif (is_string($from) && is_string($to)) {
|
480 |
-
|
481 |
|
482 |
return strtr($str, $from, $to);
|
483 |
} elseif (!is_array($from)) {
|
484 |
-
throw new
|
485 |
}
|
486 |
|
487 |
return strtr($str, $from);
|
@@ -496,14 +496,14 @@ function Twig_SupTwg_replace_filter($str, $from, $to = null)
|
|
496 |
*
|
497 |
* @return int|float The rounded number
|
498 |
*/
|
499 |
-
function
|
500 |
{
|
501 |
if ('common' == $method) {
|
502 |
return round($value, $precision);
|
503 |
}
|
504 |
|
505 |
if ('ceil' != $method && 'floor' != $method) {
|
506 |
-
throw new
|
507 |
}
|
508 |
|
509 |
return $method($value * pow(10, $precision)) / pow(10, $precision);
|
@@ -516,7 +516,7 @@ function Twig_SupTwg_round($value, $precision = 0, $method = 'common')
|
|
516 |
* be used. Supplying any of the parameters will override the defaults set in the
|
517 |
* environment object.
|
518 |
*
|
519 |
-
* @param
|
520 |
* @param mixed $number A float/int/string of the number to format
|
521 |
* @param int $decimal the number of decimal points to display
|
522 |
* @param string $decimalPoint the character(s) to use for the decimal point
|
@@ -524,9 +524,9 @@ function Twig_SupTwg_round($value, $precision = 0, $method = 'common')
|
|
524 |
*
|
525 |
* @return string The formatted number
|
526 |
*/
|
527 |
-
function
|
528 |
{
|
529 |
-
$defaults = $env->getExtension('
|
530 |
if (null === $decimal) {
|
531 |
$decimal = $defaults[0];
|
532 |
}
|
@@ -549,7 +549,7 @@ function Twig_SupTwg_number_format_filter(Twig_SupTwg_Environment $env, $number,
|
|
549 |
*
|
550 |
* @return string The URL encoded value
|
551 |
*/
|
552 |
-
function
|
553 |
{
|
554 |
if (is_array($url)) {
|
555 |
if (defined('PHP_QUERY_RFC3986')) {
|
@@ -571,12 +571,12 @@ if (PHP_VERSION_ID < 50300) {
|
|
571 |
*
|
572 |
* @return mixed The JSON encoded value
|
573 |
*/
|
574 |
-
function
|
575 |
{
|
576 |
-
if ($value instanceof
|
577 |
$value = (string) $value;
|
578 |
} elseif (is_array($value)) {
|
579 |
-
array_walk_recursive($value, '
|
580 |
}
|
581 |
|
582 |
return json_encode($value);
|
@@ -590,21 +590,21 @@ if (PHP_VERSION_ID < 50300) {
|
|
590 |
*
|
591 |
* @return mixed The JSON encoded value
|
592 |
*/
|
593 |
-
function
|
594 |
{
|
595 |
-
if ($value instanceof
|
596 |
$value = (string) $value;
|
597 |
} elseif (is_array($value)) {
|
598 |
-
array_walk_recursive($value, '
|
599 |
}
|
600 |
|
601 |
return json_encode($value, $options);
|
602 |
}
|
603 |
}
|
604 |
|
605 |
-
function
|
606 |
{
|
607 |
-
if ($value instanceof
|
608 |
$value = (string) $value;
|
609 |
}
|
610 |
}
|
@@ -625,18 +625,18 @@ function _Twig_SupTwg_markup2string(&$value)
|
|
625 |
*
|
626 |
* @return array The merged array
|
627 |
*/
|
628 |
-
function
|
629 |
{
|
630 |
if ($arr1 instanceof Traversable) {
|
631 |
$arr1 = iterator_to_array($arr1);
|
632 |
} elseif (!is_array($arr1)) {
|
633 |
-
throw new
|
634 |
}
|
635 |
|
636 |
if ($arr2 instanceof Traversable) {
|
637 |
$arr2 = iterator_to_array($arr2);
|
638 |
} elseif (!is_array($arr2)) {
|
639 |
-
throw new
|
640 |
}
|
641 |
|
642 |
return array_merge($arr1, $arr2);
|
@@ -645,7 +645,7 @@ function Twig_SupTwg_array_merge($arr1, $arr2)
|
|
645 |
/**
|
646 |
* Slices a variable.
|
647 |
*
|
648 |
-
* @param
|
649 |
* @param mixed $item A variable
|
650 |
* @param int $start Start of the slice
|
651 |
* @param int $length Size of the slice
|
@@ -653,7 +653,7 @@ function Twig_SupTwg_array_merge($arr1, $arr2)
|
|
653 |
*
|
654 |
* @return mixed The sliced variable
|
655 |
*/
|
656 |
-
function
|
657 |
{
|
658 |
if ($item instanceof Traversable) {
|
659 |
while ($item instanceof IteratorAggregate) {
|
@@ -687,14 +687,14 @@ function Twig_SupTwg_slice(Twig_SupTwg_Environment $env, $item, $start, $length
|
|
687 |
/**
|
688 |
* Returns the first element of the item.
|
689 |
*
|
690 |
-
* @param
|
691 |
* @param mixed $item A variable
|
692 |
*
|
693 |
* @return mixed The first element of the item
|
694 |
*/
|
695 |
-
function
|
696 |
{
|
697 |
-
$elements =
|
698 |
|
699 |
return is_string($elements) ? $elements : current($elements);
|
700 |
}
|
@@ -702,14 +702,14 @@ function Twig_SupTwg_first(Twig_SupTwg_Environment $env, $item)
|
|
702 |
/**
|
703 |
* Returns the last element of the item.
|
704 |
*
|
705 |
-
* @param
|
706 |
* @param mixed $item A variable
|
707 |
*
|
708 |
* @return mixed The last element of the item
|
709 |
*/
|
710 |
-
function
|
711 |
{
|
712 |
-
$elements =
|
713 |
|
714 |
return is_string($elements) ? $elements : current($elements);
|
715 |
}
|
@@ -732,7 +732,7 @@ function Twig_SupTwg_last(Twig_SupTwg_Environment $env, $item)
|
|
732 |
*
|
733 |
* @return string The concatenated string
|
734 |
*/
|
735 |
-
function
|
736 |
{
|
737 |
if ($value instanceof Traversable) {
|
738 |
$value = iterator_to_array($value, false);
|
@@ -758,14 +758,14 @@ function Twig_SupTwg_join_filter($value, $glue = '')
|
|
758 |
* {# returns [aa, bb, cc] #}
|
759 |
* </pre>
|
760 |
*
|
761 |
-
* @param
|
762 |
* @param string $value A string
|
763 |
* @param string $delimiter The delimiter
|
764 |
* @param int $limit The limit
|
765 |
*
|
766 |
* @return array The split string as an array
|
767 |
*/
|
768 |
-
function
|
769 |
{
|
770 |
if (!empty($delimiter)) {
|
771 |
return null === $limit ? explode($delimiter, $value) : explode($delimiter, $value, $limit);
|
@@ -798,9 +798,9 @@ function Twig_SupTwg_split_filter(Twig_SupTwg_Environment $env, $value, $delimit
|
|
798 |
/**
|
799 |
* @internal
|
800 |
*/
|
801 |
-
function
|
802 |
{
|
803 |
-
if (
|
804 |
return $default;
|
805 |
}
|
806 |
|
@@ -822,7 +822,7 @@ function _Twig_SupTwg_default_filter($value, $default = '')
|
|
822 |
*
|
823 |
* @return array The keys
|
824 |
*/
|
825 |
-
function
|
826 |
{
|
827 |
if ($array instanceof Traversable) {
|
828 |
while ($array instanceof IteratorAggregate) {
|
@@ -858,13 +858,13 @@ function Twig_SupTwg_get_array_keys_filter($array)
|
|
858 |
/**
|
859 |
* Reverses a variable.
|
860 |
*
|
861 |
-
* @param
|
862 |
* @param array|Traversable|string $item An array, a Traversable instance, or a string
|
863 |
* @param bool $preserveKeys Whether to preserve key or not
|
864 |
*
|
865 |
* @return mixed The reversed input
|
866 |
*/
|
867 |
-
function
|
868 |
{
|
869 |
if ($item instanceof Traversable) {
|
870 |
return array_reverse(iterator_to_array($item), $preserveKeys);
|
@@ -878,7 +878,7 @@ function Twig_SupTwg_reverse_filter(Twig_SupTwg_Environment $env, $item, $preser
|
|
878 |
$string = (string) $item;
|
879 |
|
880 |
if ('UTF-8' !== $charset) {
|
881 |
-
$item =
|
882 |
}
|
883 |
|
884 |
preg_match_all('/./us', $item, $matches);
|
@@ -886,7 +886,7 @@ function Twig_SupTwg_reverse_filter(Twig_SupTwg_Environment $env, $item, $preser
|
|
886 |
$string = implode('', array_reverse($matches[0]));
|
887 |
|
888 |
if ('UTF-8' !== $charset) {
|
889 |
-
$string =
|
890 |
}
|
891 |
|
892 |
return $string;
|
@@ -902,12 +902,12 @@ function Twig_SupTwg_reverse_filter(Twig_SupTwg_Environment $env, $item, $preser
|
|
902 |
*
|
903 |
* @return array
|
904 |
*/
|
905 |
-
function
|
906 |
{
|
907 |
if ($array instanceof Traversable) {
|
908 |
$array = iterator_to_array($array);
|
909 |
} elseif (!is_array($array)) {
|
910 |
-
throw new
|
911 |
}
|
912 |
|
913 |
asort($array);
|
@@ -918,7 +918,7 @@ function Twig_SupTwg_sort_filter($array)
|
|
918 |
/**
|
919 |
* @internal
|
920 |
*/
|
921 |
-
function
|
922 |
{
|
923 |
if (is_array($compare)) {
|
924 |
return in_array($value, $compare, is_object($value) || is_resource($value));
|
@@ -950,9 +950,9 @@ function Twig_SupTwg_in_filter($value, $compare)
|
|
950 |
*
|
951 |
* @return string
|
952 |
*
|
953 |
-
* @throws
|
954 |
*/
|
955 |
-
function
|
956 |
{
|
957 |
if (null === $characterMask) {
|
958 |
$characterMask = " \t\n\r\0\x0B";
|
@@ -960,20 +960,20 @@ function Twig_SupTwg_trim_filter($string, $characterMask = null, $side = 'both')
|
|
960 |
|
961 |
switch ($side) {
|
962 |
case 'both':
|
963 |
-
return trim($string, $characterMask);
|
964 |
case 'left':
|
965 |
-
return ltrim($string, $characterMask);
|
966 |
case 'right':
|
967 |
-
return rtrim($string, $characterMask);
|
968 |
default:
|
969 |
-
throw new
|
970 |
}
|
971 |
}
|
972 |
|
973 |
/**
|
974 |
* Escapes a string.
|
975 |
*
|
976 |
-
* @param
|
977 |
* @param mixed $string The value to be escaped
|
978 |
* @param string $strategy The escaping strategy
|
979 |
* @param string $charset The charset
|
@@ -981,9 +981,9 @@ function Twig_SupTwg_trim_filter($string, $characterMask = null, $side = 'both')
|
|
981 |
*
|
982 |
* @return string
|
983 |
*/
|
984 |
-
function
|
985 |
{
|
986 |
-
if ($autoescape && $string instanceof
|
987 |
return $string;
|
988 |
}
|
989 |
|
@@ -1042,60 +1042,60 @@ function Twig_SupTwg_escape_filter(Twig_SupTwg_Environment $env, $string, $strat
|
|
1042 |
return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
|
1043 |
}
|
1044 |
|
1045 |
-
$string =
|
1046 |
$string = htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
1047 |
|
1048 |
-
return
|
1049 |
|
1050 |
case 'js':
|
1051 |
// escape all non-alphanumeric characters
|
1052 |
// into their \xHH or \uHHHH representations
|
1053 |
if ('UTF-8' !== $charset) {
|
1054 |
-
$string =
|
1055 |
}
|
1056 |
|
1057 |
if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
|
1058 |
-
throw new
|
1059 |
}
|
1060 |
|
1061 |
-
$string = preg_replace_callback('#[^a-zA-Z0-9,\._]#Su', '
|
1062 |
|
1063 |
if ('UTF-8' !== $charset) {
|
1064 |
-
$string =
|
1065 |
}
|
1066 |
|
1067 |
return $string;
|
1068 |
|
1069 |
case 'css':
|
1070 |
if ('UTF-8' !== $charset) {
|
1071 |
-
$string =
|
1072 |
}
|
1073 |
|
1074 |
if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
|
1075 |
-
throw new
|
1076 |
}
|
1077 |
|
1078 |
-
$string = preg_replace_callback('#[^a-zA-Z0-9]#Su', '
|
1079 |
|
1080 |
if ('UTF-8' !== $charset) {
|
1081 |
-
$string =
|
1082 |
}
|
1083 |
|
1084 |
return $string;
|
1085 |
|
1086 |
case 'html_attr':
|
1087 |
if ('UTF-8' !== $charset) {
|
1088 |
-
$string =
|
1089 |
}
|
1090 |
|
1091 |
if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
|
1092 |
-
throw new
|
1093 |
}
|
1094 |
|
1095 |
-
$string = preg_replace_callback('#[^a-zA-Z0-9,\.\-_]#Su', '
|
1096 |
|
1097 |
if ('UTF-8' !== $charset) {
|
1098 |
-
$string =
|
1099 |
}
|
1100 |
|
1101 |
return $string;
|
@@ -1111,7 +1111,7 @@ function Twig_SupTwg_escape_filter(Twig_SupTwg_Environment $env, $string, $strat
|
|
1111 |
static $escapers;
|
1112 |
|
1113 |
if (null === $escapers) {
|
1114 |
-
$escapers = $env->getExtension('
|
1115 |
}
|
1116 |
|
1117 |
if (isset($escapers[$strategy])) {
|
@@ -1120,17 +1120,17 @@ function Twig_SupTwg_escape_filter(Twig_SupTwg_Environment $env, $string, $strat
|
|
1120 |
|
1121 |
$validStrategies = implode(', ', array_merge(array('html', 'js', 'url', 'css', 'html_attr'), array_keys($escapers)));
|
1122 |
|
1123 |
-
throw new
|
1124 |
}
|
1125 |
}
|
1126 |
|
1127 |
/**
|
1128 |
* @internal
|
1129 |
*/
|
1130 |
-
function
|
1131 |
{
|
1132 |
foreach ($filterArgs as $arg) {
|
1133 |
-
if ($arg instanceof
|
1134 |
return array($arg->getAttribute('value'));
|
1135 |
}
|
1136 |
|
@@ -1141,23 +1141,23 @@ function Twig_SupTwg_escape_filter_is_safe(Twig_SupTwg_Node $filterArgs)
|
|
1141 |
}
|
1142 |
|
1143 |
if (function_exists('mb_convert_encoding')) {
|
1144 |
-
function
|
1145 |
{
|
1146 |
return mb_convert_encoding($string, $to, $from);
|
1147 |
}
|
1148 |
} elseif (function_exists('iconv')) {
|
1149 |
-
function
|
1150 |
{
|
1151 |
return iconv($from, $to, $string);
|
1152 |
}
|
1153 |
} else {
|
1154 |
-
function
|
1155 |
{
|
1156 |
-
throw new
|
1157 |
}
|
1158 |
}
|
1159 |
|
1160 |
-
function
|
1161 |
{
|
1162 |
$char = $matches[0];
|
1163 |
|
@@ -1167,7 +1167,7 @@ function _Twig_SupTwg_escape_js_callback($matches)
|
|
1167 |
}
|
1168 |
|
1169 |
// \uHHHH
|
1170 |
-
$char =
|
1171 |
$char = strtoupper(bin2hex($char));
|
1172 |
|
1173 |
if (4 >= strlen($char)) {
|
@@ -1177,7 +1177,7 @@ function _Twig_SupTwg_escape_js_callback($matches)
|
|
1177 |
return sprintf('\u%04s\u%04s', substr($char, 0, -4), substr($char, -4));
|
1178 |
}
|
1179 |
|
1180 |
-
function
|
1181 |
{
|
1182 |
$char = $matches[0];
|
1183 |
|
@@ -1192,7 +1192,7 @@ function _Twig_SupTwg_escape_css_callback($matches)
|
|
1192 |
}
|
1193 |
|
1194 |
// \uHHHH
|
1195 |
-
$char =
|
1196 |
|
1197 |
return '\\'.ltrim(strtoupper(bin2hex($char)), '0').' ';
|
1198 |
}
|
@@ -1203,7 +1203,7 @@ function _Twig_SupTwg_escape_css_callback($matches)
|
|
1203 |
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
1204 |
* @license http://framework.zend.com/license/new-bsd New BSD License
|
1205 |
*/
|
1206 |
-
function
|
1207 |
{
|
1208 |
/*
|
1209 |
* While HTML supports far more named entities, the lowest common denominator
|
@@ -1236,7 +1236,7 @@ function _Twig_SupTwg_escape_html_attr_callback($matches)
|
|
1236 |
if (strlen($chr) == 1) {
|
1237 |
$hex = strtoupper(substr('00'.bin2hex($chr), -2));
|
1238 |
} else {
|
1239 |
-
$chr =
|
1240 |
$hex = strtoupper(substr('0000'.bin2hex($chr), -4));
|
1241 |
}
|
1242 |
|
@@ -1257,12 +1257,12 @@ if (function_exists('mb_get_info')) {
|
|
1257 |
/**
|
1258 |
* Returns the length of a variable.
|
1259 |
*
|
1260 |
-
* @param
|
1261 |
* @param mixed $thing A variable
|
1262 |
*
|
1263 |
* @return int The length of the value
|
1264 |
*/
|
1265 |
-
function
|
1266 |
{
|
1267 |
if (is_scalar($thing)) {
|
1268 |
return mb_strlen($thing, $env->getCharset());
|
@@ -1284,12 +1284,12 @@ if (function_exists('mb_get_info')) {
|
|
1284 |
/**
|
1285 |
* Converts a string to uppercase.
|
1286 |
*
|
1287 |
-
* @param
|
1288 |
* @param string $string A string
|
1289 |
*
|
1290 |
* @return string The uppercased string
|
1291 |
*/
|
1292 |
-
function
|
1293 |
{
|
1294 |
if (null !== $charset = $env->getCharset()) {
|
1295 |
return mb_strtoupper($string, $charset);
|
@@ -1301,12 +1301,12 @@ if (function_exists('mb_get_info')) {
|
|
1301 |
/**
|
1302 |
* Converts a string to lowercase.
|
1303 |
*
|
1304 |
-
* @param
|
1305 |
* @param string $string A string
|
1306 |
*
|
1307 |
* @return string The lowercased string
|
1308 |
*/
|
1309 |
-
function
|
1310 |
{
|
1311 |
if (null !== $charset = $env->getCharset()) {
|
1312 |
return mb_strtolower($string, $charset);
|
@@ -1318,12 +1318,12 @@ if (function_exists('mb_get_info')) {
|
|
1318 |
/**
|
1319 |
* Returns a titlecased string.
|
1320 |
*
|
1321 |
-
* @param
|
1322 |
* @param string $string A string
|
1323 |
*
|
1324 |
* @return string The titlecased string
|
1325 |
*/
|
1326 |
-
function
|
1327 |
{
|
1328 |
if (null !== $charset = $env->getCharset()) {
|
1329 |
return mb_convert_case($string, MB_CASE_TITLE, $charset);
|
@@ -1335,12 +1335,12 @@ if (function_exists('mb_get_info')) {
|
|
1335 |
/**
|
1336 |
* Returns a capitalized string.
|
1337 |
*
|
1338 |
-
* @param
|
1339 |
* @param string $string A string
|
1340 |
*
|
1341 |
* @return string The capitalized string
|
1342 |
*/
|
1343 |
-
function
|
1344 |
{
|
1345 |
if (null !== $charset = $env->getCharset()) {
|
1346 |
return mb_strtoupper(mb_substr($string, 0, 1, $charset), $charset).mb_strtolower(mb_substr($string, 1, mb_strlen($string, $charset), $charset), $charset);
|
@@ -1354,12 +1354,12 @@ else {
|
|
1354 |
/**
|
1355 |
* Returns the length of a variable.
|
1356 |
*
|
1357 |
-
* @param
|
1358 |
* @param mixed $thing A variable
|
1359 |
*
|
1360 |
* @return int The length of the value
|
1361 |
*/
|
1362 |
-
function
|
1363 |
{
|
1364 |
if (is_scalar($thing)) {
|
1365 |
return strlen($thing);
|
@@ -1375,12 +1375,12 @@ else {
|
|
1375 |
/**
|
1376 |
* Returns a titlecased string.
|
1377 |
*
|
1378 |
-
* @param
|
1379 |
* @param string $string A string
|
1380 |
*
|
1381 |
* @return string The titlecased string
|
1382 |
*/
|
1383 |
-
function
|
1384 |
{
|
1385 |
return ucwords(strtolower($string));
|
1386 |
}
|
@@ -1388,12 +1388,12 @@ else {
|
|
1388 |
/**
|
1389 |
* Returns a capitalized string.
|
1390 |
*
|
1391 |
-
* @param
|
1392 |
* @param string $string A string
|
1393 |
*
|
1394 |
* @return string The capitalized string
|
1395 |
*/
|
1396 |
-
function
|
1397 |
{
|
1398 |
return ucfirst(strtolower($string));
|
1399 |
}
|
@@ -1402,7 +1402,7 @@ else {
|
|
1402 |
/**
|
1403 |
* @internal
|
1404 |
*/
|
1405 |
-
function
|
1406 |
{
|
1407 |
if ($seq instanceof Traversable || is_array($seq)) {
|
1408 |
return $seq;
|
@@ -1425,7 +1425,7 @@ function Twig_SupTwg_ensure_traversable($seq)
|
|
1425 |
*
|
1426 |
* @return bool true if the value is empty, false otherwise
|
1427 |
*/
|
1428 |
-
function
|
1429 |
{
|
1430 |
if ($value instanceof Countable) {
|
1431 |
return 0 == count($value);
|
@@ -1452,7 +1452,7 @@ function Twig_SupTwg_test_empty($value)
|
|
1452 |
*
|
1453 |
* @return bool true if the value is traversable
|
1454 |
*/
|
1455 |
-
function
|
1456 |
{
|
1457 |
return $value instanceof Traversable || is_array($value);
|
1458 |
}
|
@@ -1460,7 +1460,7 @@ function Twig_SupTwg_test_iterable($value)
|
|
1460 |
/**
|
1461 |
* Renders a template.
|
1462 |
*
|
1463 |
-
* @param
|
1464 |
* @param array $context
|
1465 |
* @param string|array $template The template to render or an array of templates to try consecutively
|
1466 |
* @param array $variables The variables to pass to the template
|
@@ -1470,7 +1470,7 @@ function Twig_SupTwg_test_iterable($value)
|
|
1470 |
*
|
1471 |
* @return string The rendered template
|
1472 |
*/
|
1473 |
-
function
|
1474 |
{
|
1475 |
$alreadySandboxed = false;
|
1476 |
$sandbox = null;
|
@@ -1478,8 +1478,8 @@ function Twig_SupTwg_include(Twig_SupTwg_Environment $env, $context, $template,
|
|
1478 |
$variables = array_merge($context, $variables);
|
1479 |
}
|
1480 |
|
1481 |
-
if ($isSandboxed = $sandboxed && $env->hasExtension('
|
1482 |
-
$sandbox = $env->getExtension('
|
1483 |
if (!$alreadySandboxed = $sandbox->isSandboxed()) {
|
1484 |
$sandbox->enableSandbox();
|
1485 |
}
|
@@ -1488,7 +1488,7 @@ function Twig_SupTwg_include(Twig_SupTwg_Environment $env, $context, $template,
|
|
1488 |
$result = null;
|
1489 |
try {
|
1490 |
$result = $env->resolveTemplate($template)->render($variables);
|
1491 |
-
} catch (
|
1492 |
if (!$ignoreMissing) {
|
1493 |
if ($isSandboxed && !$alreadySandboxed) {
|
1494 |
$sandbox->disableSandbox();
|
@@ -1520,22 +1520,22 @@ function Twig_SupTwg_include(Twig_SupTwg_Environment $env, $context, $template,
|
|
1520 |
/**
|
1521 |
* Returns a template content without rendering it.
|
1522 |
*
|
1523 |
-
* @param
|
1524 |
* @param string $name The template name
|
1525 |
* @param bool $ignoreMissing Whether to ignore missing templates or not
|
1526 |
*
|
1527 |
* @return string The template source
|
1528 |
*/
|
1529 |
-
function
|
1530 |
{
|
1531 |
$loader = $env->getLoader();
|
1532 |
try {
|
1533 |
-
if (!$loader instanceof
|
1534 |
return $loader->getSource($name);
|
1535 |
} else {
|
1536 |
return $loader->getSourceContext($name)->getCode();
|
1537 |
}
|
1538 |
-
} catch (
|
1539 |
if (!$ignoreMissing) {
|
1540 |
throw $e;
|
1541 |
}
|
@@ -1550,7 +1550,7 @@ function Twig_SupTwg_source(Twig_SupTwg_Environment $env, $name, $ignoreMissing
|
|
1550 |
*
|
1551 |
* @return string
|
1552 |
*/
|
1553 |
-
function
|
1554 |
{
|
1555 |
if (null !== $object) {
|
1556 |
$constant = get_class($object).'::'.$constant;
|
@@ -1567,7 +1567,7 @@ function Twig_SupTwg_constant($constant, $object = null)
|
|
1567 |
*
|
1568 |
* @return bool
|
1569 |
*/
|
1570 |
-
function
|
1571 |
{
|
1572 |
if (null !== $object) {
|
1573 |
$constant = get_class($object).'::'.$constant;
|
@@ -1585,7 +1585,7 @@ function Twig_SupTwg_constant_is_defined($constant, $object = null)
|
|
1585 |
*
|
1586 |
* @return array
|
1587 |
*/
|
1588 |
-
function
|
1589 |
{
|
1590 |
if ($items instanceof Traversable) {
|
1591 |
$items = iterator_to_array($items, false);
|
17 |
/**
|
18 |
* @final
|
19 |
*/
|
20 |
+
class Twig_SupTwgSgg_Extension_Core extends Twig_SupTwgSgg_Extension
|
21 |
{
|
22 |
protected $dateFormats = array('F j, Y H:i', '%d days');
|
23 |
protected $numberFormat = array(0, '.', ',');
|
121 |
public function getTokenParsers()
|
122 |
{
|
123 |
return array(
|
124 |
+
new Twig_SupTwgSgg_TokenParser_For(),
|
125 |
+
new Twig_SupTwgSgg_TokenParser_If(),
|
126 |
+
new Twig_SupTwgSgg_TokenParser_Extends(),
|
127 |
+
new Twig_SupTwgSgg_TokenParser_Include(),
|
128 |
+
new Twig_SupTwgSgg_TokenParser_Block(),
|
129 |
+
new Twig_SupTwgSgg_TokenParser_Use(),
|
130 |
+
new Twig_SupTwgSgg_TokenParser_Filter(),
|
131 |
+
new Twig_SupTwgSgg_TokenParser_Macro(),
|
132 |
+
new Twig_SupTwgSgg_TokenParser_Import(),
|
133 |
+
new Twig_SupTwgSgg_TokenParser_From(),
|
134 |
+
new Twig_SupTwgSgg_TokenParser_Set(),
|
135 |
+
new Twig_SupTwgSgg_TokenParser_Spaceless(),
|
136 |
+
new Twig_SupTwgSgg_TokenParser_Flush(),
|
137 |
+
new Twig_SupTwgSgg_TokenParser_Do(),
|
138 |
+
new Twig_SupTwgSgg_TokenParser_Embed(),
|
139 |
+
new Twig_SupTwgSgg_TokenParser_With(),
|
140 |
);
|
141 |
}
|
142 |
|
144 |
{
|
145 |
$filters = array(
|
146 |
// formatting filters
|
147 |
+
new Twig_SupTwgSgg_SimpleFilter('date', 'Twig_SupTwgSgg_date_format_filter', array('needs_environment' => true)),
|
148 |
+
new Twig_SupTwgSgg_SimpleFilter('date_modify', 'Twig_SupTwgSgg_date_modify_filter', array('needs_environment' => true)),
|
149 |
+
new Twig_SupTwgSgg_SimpleFilter('format', 'sprintf'),
|
150 |
+
new Twig_SupTwgSgg_SimpleFilter('replace', 'Twig_SupTwgSgg_replace_filter'),
|
151 |
+
new Twig_SupTwgSgg_SimpleFilter('number_format', 'Twig_SupTwgSgg_number_format_filter', array('needs_environment' => true)),
|
152 |
+
new Twig_SupTwgSgg_SimpleFilter('abs', 'abs'),
|
153 |
+
new Twig_SupTwgSgg_SimpleFilter('round', 'Twig_SupTwgSgg_round'),
|
154 |
|
155 |
// encoding
|
156 |
+
new Twig_SupTwgSgg_SimpleFilter('url_encode', 'Twig_SupTwgSgg_urlencode_filter'),
|
157 |
+
new Twig_SupTwgSgg_SimpleFilter('json_encode', 'Twig_SupTwgSgg_jsonencode_filter'),
|
158 |
+
new Twig_SupTwgSgg_SimpleFilter('convert_encoding', 'Twig_SupTwgSgg_convert_encoding'),
|
159 |
|
160 |
// string filters
|
161 |
+
new Twig_SupTwgSgg_SimpleFilter('title', 'Twig_SupTwgSgg_title_string_filter', array('needs_environment' => true)),
|
162 |
+
new Twig_SupTwgSgg_SimpleFilter('capitalize', 'Twig_SupTwgSgg_capitalize_string_filter', array('needs_environment' => true)),
|
163 |
+
new Twig_SupTwgSgg_SimpleFilter('upper', 'strtoupper'),
|
164 |
+
new Twig_SupTwgSgg_SimpleFilter('lower', 'strtolower'),
|
165 |
+
new Twig_SupTwgSgg_SimpleFilter('striptags', 'strip_tags'),
|
166 |
+
new Twig_SupTwgSgg_SimpleFilter('trim', 'Twig_SupTwgSgg_trim_filter'),
|
167 |
+
new Twig_SupTwgSgg_SimpleFilter('nl2br', 'nl2br', array('pre_escape' => 'html', 'is_safe' => array('html'))),
|
168 |
|
169 |
// array helpers
|
170 |
+
new Twig_SupTwgSgg_SimpleFilter('join', 'Twig_SupTwgSgg_join_filter'),
|
171 |
+
new Twig_SupTwgSgg_SimpleFilter('split', 'Twig_SupTwgSgg_split_filter', array('needs_environment' => true)),
|
172 |
+
new Twig_SupTwgSgg_SimpleFilter('sort', 'Twig_SupTwgSgg_sort_filter'),
|
173 |
+
new Twig_SupTwgSgg_SimpleFilter('merge', 'Twig_SupTwgSgg_array_merge'),
|
174 |
+
new Twig_SupTwgSgg_SimpleFilter('batch', 'Twig_SupTwgSgg_array_batch'),
|
175 |
|
176 |
// string/array filters
|
177 |
+
new Twig_SupTwgSgg_SimpleFilter('reverse', 'Twig_SupTwgSgg_reverse_filter', array('needs_environment' => true)),
|
178 |
+
new Twig_SupTwgSgg_SimpleFilter('length', 'Twig_SupTwgSgg_length_filter', array('needs_environment' => true)),
|
179 |
+
new Twig_SupTwgSgg_SimpleFilter('slice', 'Twig_SupTwgSgg_slice', array('needs_environment' => true)),
|
180 |
+
new Twig_SupTwgSgg_SimpleFilter('first', 'Twig_SupTwgSgg_first', array('needs_environment' => true)),
|
181 |
+
new Twig_SupTwgSgg_SimpleFilter('last', 'Twig_SupTwgSgg_last', array('needs_environment' => true)),
|
182 |
|
183 |
// iteration and runtime
|
184 |
+
new Twig_SupTwgSgg_SimpleFilter('default', '_Twig_SupTwgSgg_default_filter', array('node_class' => 'Twig_SupTwgSgg_Node_Expression_Filter_Default')),
|
185 |
+
new Twig_SupTwgSgg_SimpleFilter('keys', 'Twig_SupTwgSgg_get_array_keys_filter'),
|
186 |
|
187 |
// escaping
|
188 |
+
new Twig_SupTwgSgg_SimpleFilter('escape', 'Twig_SupTwgSgg_escape_filter', array('needs_environment' => true, 'is_safe_callback' => 'Twig_SupTwgSgg_escape_filter_is_safe')),
|
189 |
+
new Twig_SupTwgSgg_SimpleFilter('e', 'Twig_SupTwgSgg_escape_filter', array('needs_environment' => true, 'is_safe_callback' => 'Twig_SupTwgSgg_escape_filter_is_safe')),
|
190 |
);
|
191 |
|
192 |
if (function_exists('mb_get_info')) {
|
193 |
+
$filters[] = new Twig_SupTwgSgg_SimpleFilter('upper', 'Twig_SupTwgSgg_upper_filter', array('needs_environment' => true));
|
194 |
+
$filters[] = new Twig_SupTwgSgg_SimpleFilter('lower', 'Twig_SupTwgSgg_lower_filter', array('needs_environment' => true));
|
195 |
}
|
196 |
|
197 |
return $filters;
|
200 |
public function getFunctions()
|
201 |
{
|
202 |
return array(
|
203 |
+
new Twig_SupTwgSgg_SimpleFunction('max', 'max'),
|
204 |
+
new Twig_SupTwgSgg_SimpleFunction('min', 'min'),
|
205 |
+
new Twig_SupTwgSgg_SimpleFunction('range', 'range'),
|
206 |
+
new Twig_SupTwgSgg_SimpleFunction('constant', 'Twig_SupTwgSgg_constant'),
|
207 |
+
new Twig_SupTwgSgg_SimpleFunction('cycle', 'Twig_SupTwgSgg_cycle'),
|
208 |
+
new Twig_SupTwgSgg_SimpleFunction('random', 'Twig_SupTwgSgg_random', array('needs_environment' => true)),
|
209 |
+
new Twig_SupTwgSgg_SimpleFunction('date', 'Twig_SupTwgSgg_date_converter', array('needs_environment' => true)),
|
210 |
+
new Twig_SupTwgSgg_SimpleFunction('include', 'Twig_SupTwgSgg_include', array('needs_environment' => true, 'needs_context' => true, 'is_safe' => array('all'))),
|
211 |
+
new Twig_SupTwgSgg_SimpleFunction('source', 'Twig_SupTwgSgg_source', array('needs_environment' => true, 'is_safe' => array('all'))),
|
212 |
);
|
213 |
}
|
214 |
|
215 |
public function getTests()
|
216 |
{
|
217 |
return array(
|
218 |
+
new Twig_SupTwgSgg_SimpleTest('even', null, array('node_class' => 'Twig_SupTwgSgg_Node_Expression_Test_Even')),
|
219 |
+
new Twig_SupTwgSgg_SimpleTest('odd', null, array('node_class' => 'Twig_SupTwgSgg_Node_Expression_Test_Odd')),
|
220 |
+
new Twig_SupTwgSgg_SimpleTest('defined', null, array('node_class' => 'Twig_SupTwgSgg_Node_Expression_Test_Defined')),
|
221 |
+
new Twig_SupTwgSgg_SimpleTest('sameas', null, array('node_class' => 'Twig_SupTwgSgg_Node_Expression_Test_Sameas', 'deprecated' => '1.21', 'alternative' => 'same as')),
|
222 |
+
new Twig_SupTwgSgg_SimpleTest('same as', null, array('node_class' => 'Twig_SupTwgSgg_Node_Expression_Test_Sameas')),
|
223 |
+
new Twig_SupTwgSgg_SimpleTest('none', null, array('node_class' => 'Twig_SupTwgSgg_Node_Expression_Test_Null')),
|
224 |
+
new Twig_SupTwgSgg_SimpleTest('null', null, array('node_class' => 'Twig_SupTwgSgg_Node_Expression_Test_Null')),
|
225 |
+
new Twig_SupTwgSgg_SimpleTest('divisibleby', null, array('node_class' => 'Twig_SupTwgSgg_Node_Expression_Test_Divisibleby', 'deprecated' => '1.21', 'alternative' => 'divisible by')),
|
226 |
+
new Twig_SupTwgSgg_SimpleTest('divisible by', null, array('node_class' => 'Twig_SupTwgSgg_Node_Expression_Test_Divisibleby')),
|
227 |
+
new Twig_SupTwgSgg_SimpleTest('constant', null, array('node_class' => 'Twig_SupTwgSgg_Node_Expression_Test_Constant')),
|
228 |
+
new Twig_SupTwgSgg_SimpleTest('empty', 'Twig_SupTwgSgg_test_empty'),
|
229 |
+
new Twig_SupTwgSgg_SimpleTest('iterable', 'Twig_SupTwgSgg_test_iterable'),
|
230 |
);
|
231 |
}
|
232 |
|
234 |
{
|
235 |
return array(
|
236 |
array(
|
237 |
+
'not' => array('precedence' => 50, 'class' => 'Twig_SupTwgSgg_Node_Expression_Unary_Not'),
|
238 |
+
'-' => array('precedence' => 500, 'class' => 'Twig_SupTwgSgg_Node_Expression_Unary_Neg'),
|
239 |
+
'+' => array('precedence' => 500, 'class' => 'Twig_SupTwgSgg_Node_Expression_Unary_Pos'),
|
240 |
),
|
241 |
array(
|
242 |
+
'or' => array('precedence' => 10, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_Or', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
243 |
+
'and' => array('precedence' => 15, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_And', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
244 |
+
'b-or' => array('precedence' => 16, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_BitwiseOr', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
245 |
+
'b-xor' => array('precedence' => 17, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_BitwiseXor', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
246 |
+
'b-and' => array('precedence' => 18, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_BitwiseAnd', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
247 |
+
'==' => array('precedence' => 20, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_Equal', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
248 |
+
'!=' => array('precedence' => 20, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_NotEqual', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
249 |
+
'<' => array('precedence' => 20, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_Less', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
250 |
+
'>' => array('precedence' => 20, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_Greater', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
251 |
+
'>=' => array('precedence' => 20, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_GreaterEqual', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
252 |
+
'<=' => array('precedence' => 20, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_LessEqual', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
253 |
+
'not in' => array('precedence' => 20, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_NotIn', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
254 |
+
'in' => array('precedence' => 20, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_In', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
255 |
+
'matches' => array('precedence' => 20, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_Matches', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
256 |
+
'starts with' => array('precedence' => 20, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_StartsWith', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
257 |
+
'ends with' => array('precedence' => 20, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_EndsWith', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
258 |
+
'..' => array('precedence' => 25, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_Range', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
259 |
+
'+' => array('precedence' => 30, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_Add', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
260 |
+
'-' => array('precedence' => 30, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_Sub', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
261 |
+
'~' => array('precedence' => 40, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_Concat', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
262 |
+
'*' => array('precedence' => 60, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_Mul', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
263 |
+
'/' => array('precedence' => 60, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_Div', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
264 |
+
'//' => array('precedence' => 60, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_FloorDiv', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
265 |
+
'%' => array('precedence' => 60, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_Mod', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
266 |
+
'is' => array('precedence' => 100, 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
267 |
+
'is not' => array('precedence' => 100, 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_LEFT),
|
268 |
+
'**' => array('precedence' => 200, 'class' => 'Twig_SupTwgSgg_Node_Expression_Binary_Power', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_RIGHT),
|
269 |
+
'??' => array('precedence' => 300, 'class' => 'Twig_SupTwgSgg_Node_Expression_NullCoalesce', 'associativity' => Twig_SupTwgSgg_ExpressionParser::OPERATOR_RIGHT),
|
270 |
),
|
271 |
);
|
272 |
}
|
285 |
*
|
286 |
* @return string The next value in the cycle
|
287 |
*/
|
288 |
+
function Twig_SupTwgSgg_cycle($values, $position)
|
289 |
{
|
290 |
if (!is_array($values) && !$values instanceof ArrayAccess) {
|
291 |
return $values;
|
300 |
* - a random character from a string
|
301 |
* - a random integer between 0 and the integer parameter.
|
302 |
*
|
303 |
+
* @param Twig_SupTwgSgg_Environment $env
|
304 |
* @param Traversable|array|int|float|string $values The values to pick a random item from
|
305 |
*
|
306 |
+
* @throws Twig_SupTwgSgg_Error_Runtime when $values is an empty array (does not apply to an empty string which is returned as is)
|
307 |
*
|
308 |
* @return mixed A random value from the given sequence
|
309 |
*/
|
310 |
+
function Twig_SupTwgSgg_random(Twig_SupTwgSgg_Environment $env, $values = null)
|
311 |
{
|
312 |
if (null === $values) {
|
313 |
return mt_rand();
|
325 |
}
|
326 |
if (null !== $charset = $env->getCharset()) {
|
327 |
if ('UTF-8' !== $charset) {
|
328 |
+
$values = Twig_SupTwgSgg_convert_encoding($values, 'UTF-8', $charset);
|
329 |
}
|
330 |
|
331 |
// unicode version of str_split()
|
334 |
|
335 |
if ('UTF-8' !== $charset) {
|
336 |
foreach ($values as $i => $value) {
|
337 |
+
$values[$i] = Twig_SupTwgSgg_convert_encoding($value, $charset, 'UTF-8');
|
338 |
}
|
339 |
}
|
340 |
} else {
|
347 |
}
|
348 |
|
349 |
if (0 === count($values)) {
|
350 |
+
throw new Twig_SupTwgSgg_Error_Runtime('The random function cannot pick from an empty array.');
|
351 |
}
|
352 |
|
353 |
return $values[array_rand($values, 1)];
|
360 |
* {{ post.published_at|date("m/d/Y") }}
|
361 |
* </pre>
|
362 |
*
|
363 |
+
* @param Twig_SupTwgSgg_Environment $env
|
364 |
* @param DateTime|DateTimeInterface|DateInterval|string $date A date
|
365 |
* @param string|null $format The target format, null to use the default
|
366 |
* @param DateTimeZone|string|null|false $timezone The target timezone, null to use the default, false to leave unchanged
|
367 |
*
|
368 |
* @return string The formatted date
|
369 |
*/
|
370 |
+
function Twig_SupTwgSgg_date_format_filter(Twig_SupTwgSgg_Environment $env, $date, $format = null, $timezone = null)
|
371 |
{
|
372 |
if (null === $format) {
|
373 |
+
$formats = $env->getExtension('Twig_SupTwgSgg_Extension_Core')->getDateFormat();
|
374 |
$format = $date instanceof DateInterval ? $formats[1] : $formats[0];
|
375 |
}
|
376 |
|
378 |
return $date->format($format);
|
379 |
}
|
380 |
|
381 |
+
return Twig_SupTwgSgg_date_converter($env, $date, $timezone)->format($format);
|
382 |
}
|
383 |
|
384 |
/**
|
388 |
* {{ post.published_at|date_modify("-1day")|date("m/d/Y") }}
|
389 |
* </pre>
|
390 |
*
|
391 |
+
* @param Twig_SupTwgSgg_Environment $env
|
392 |
* @param DateTime|string $date A date
|
393 |
* @param string $modifier A modifier string
|
394 |
*
|
395 |
* @return DateTime A new date object
|
396 |
*/
|
397 |
+
function Twig_SupTwgSgg_date_modify_filter(Twig_SupTwgSgg_Environment $env, $date, $modifier)
|
398 |
{
|
399 |
+
$date = Twig_SupTwgSgg_date_converter($env, $date, false);
|
400 |
$resultDate = $date->modify($modifier);
|
401 |
|
402 |
// This is a hack to ensure PHP 5.2 support and support for DateTimeImmutable
|
414 |
* {% endif %}
|
415 |
* </pre>
|
416 |
*
|
417 |
+
* @param Twig_SupTwgSgg_Environment $env
|
418 |
* @param DateTime|DateTimeInterface|string|null $date A date
|
419 |
* @param DateTimeZone|string|null|false $timezone The target timezone, null to use the default, false to leave unchanged
|
420 |
*
|
421 |
* @return DateTime A DateTime instance
|
422 |
*/
|
423 |
+
function Twig_SupTwgSgg_date_converter(Twig_SupTwgSgg_Environment $env, $date = null, $timezone = null)
|
424 |
{
|
425 |
// determine the timezone
|
426 |
if (false !== $timezone) {
|
427 |
if (null === $timezone) {
|
428 |
+
$timezone = $env->getExtension('Twig_SupTwgSgg_Extension_Core')->getTimezone();
|
429 |
} elseif (!$timezone instanceof DateTimeZone) {
|
430 |
$timezone = new DateTimeZone($timezone);
|
431 |
}
|
446 |
}
|
447 |
|
448 |
if (null === $date || 'now' === $date) {
|
449 |
+
return new DateTime($date, false !== $timezone ? $timezone : $env->getExtension('Twig_SupTwgSgg_Extension_Core')->getTimezone());
|
450 |
}
|
451 |
|
452 |
$asString = (string) $date;
|
453 |
if (ctype_digit($asString) || (!empty($asString) && '-' === $asString[0] && ctype_digit(substr($asString, 1)))) {
|
454 |
$date = new DateTime('@'.$date);
|
455 |
} else {
|
456 |
+
$date = new DateTime($date, $env->getExtension('Twig_SupTwgSgg_Extension_Core')->getTimezone());
|
457 |
}
|
458 |
|
459 |
if (false !== $timezone) {
|
472 |
*
|
473 |
* @return string
|
474 |
*/
|
475 |
+
function Twig_SupTwgSgg_replace_filter($str, $from, $to = null)
|
476 |
{
|
477 |
if ($from instanceof Traversable) {
|
478 |
$from = iterator_to_array($from);
|
479 |
} elseif (is_string($from) && is_string($to)) {
|
480 |
+
//@trigger_error('Using "replace" with character by character replacement is deprecated since version 1.22 and will be removed in Twig 2.0', E_USER_DEPRECATED);
|
481 |
|
482 |
return strtr($str, $from, $to);
|
483 |
} elseif (!is_array($from)) {
|
484 |
+
throw new Twig_SupTwgSgg_Error_Runtime(sprintf('The "replace" filter expects an array or "Traversable" as replace values, got "%s".', is_object($from) ? get_class($from) : gettype($from)));
|
485 |
}
|
486 |
|
487 |
return strtr($str, $from);
|
496 |
*
|
497 |
* @return int|float The rounded number
|
498 |
*/
|
499 |
+
function Twig_SupTwgSgg_round($value, $precision = 0, $method = 'common')
|
500 |
{
|
501 |
if ('common' == $method) {
|
502 |
return round($value, $precision);
|
503 |
}
|
504 |
|
505 |
if ('ceil' != $method && 'floor' != $method) {
|
506 |
+
throw new Twig_SupTwgSgg_Error_Runtime('The round filter only supports the "common", "ceil", and "floor" methods.');
|
507 |
}
|
508 |
|
509 |
return $method($value * pow(10, $precision)) / pow(10, $precision);
|
516 |
* be used. Supplying any of the parameters will override the defaults set in the
|
517 |
* environment object.
|
518 |
*
|
519 |
+
* @param Twig_SupTwgSgg_Environment $env
|
520 |
* @param mixed $number A float/int/string of the number to format
|
521 |
* @param int $decimal the number of decimal points to display
|
522 |
* @param string $decimalPoint the character(s) to use for the decimal point
|
524 |
*
|
525 |
* @return string The formatted number
|
526 |
*/
|
527 |
+
function Twig_SupTwgSgg_number_format_filter(Twig_SupTwgSgg_Environment $env, $number, $decimal = null, $decimalPoint = null, $thousandSep = null)
|
528 |
{
|
529 |
+
$defaults = $env->getExtension('Twig_SupTwgSgg_Extension_Core')->getNumberFormat();
|
530 |
if (null === $decimal) {
|
531 |
$decimal = $defaults[0];
|
532 |
}
|
549 |
*
|
550 |
* @return string The URL encoded value
|
551 |
*/
|
552 |
+
function Twig_SupTwgSgg_urlencode_filter($url)
|
553 |
{
|
554 |
if (is_array($url)) {
|
555 |
if (defined('PHP_QUERY_RFC3986')) {
|
571 |
*
|
572 |
* @return mixed The JSON encoded value
|
573 |
*/
|
574 |
+
function Twig_SupTwgSgg_jsonencode_filter($value, $options = 0)
|
575 |
{
|
576 |
+
if ($value instanceof Twig_SupTwgSgg_Markup) {
|
577 |
$value = (string) $value;
|
578 |
} elseif (is_array($value)) {
|
579 |
+
array_walk_recursive($value, '_Twig_SupTwgSgg_markup2string');
|
580 |
}
|
581 |
|
582 |
return json_encode($value);
|
590 |
*
|
591 |
* @return mixed The JSON encoded value
|
592 |
*/
|
593 |
+
function Twig_SupTwgSgg_jsonencode_filter($value, $options = 0)
|
594 |
{
|
595 |
+
if ($value instanceof Twig_SupTwgSgg_Markup) {
|
596 |
$value = (string) $value;
|
597 |
} elseif (is_array($value)) {
|
598 |
+
array_walk_recursive($value, '_Twig_SupTwgSgg_markup2string');
|
599 |
}
|
600 |
|
601 |
return json_encode($value, $options);
|
602 |
}
|
603 |
}
|
604 |
|
605 |
+
function _Twig_SupTwgSgg_markup2string(&$value)
|
606 |
{
|
607 |
+
if ($value instanceof Twig_SupTwgSgg_Markup) {
|
608 |
$value = (string) $value;
|
609 |
}
|
610 |
}
|
625 |
*
|
626 |
* @return array The merged array
|
627 |
*/
|
628 |
+
function Twig_SupTwgSgg_array_merge($arr1, $arr2)
|
629 |
{
|
630 |
if ($arr1 instanceof Traversable) {
|
631 |
$arr1 = iterator_to_array($arr1);
|
632 |
} elseif (!is_array($arr1)) {
|
633 |
+
throw new Twig_SupTwgSgg_Error_Runtime(sprintf('The merge filter only works with arrays or "Traversable", got "%s" as first argument.', gettype($arr1)));
|
634 |
}
|
635 |
|
636 |
if ($arr2 instanceof Traversable) {
|
637 |
$arr2 = iterator_to_array($arr2);
|
638 |
} elseif (!is_array($arr2)) {
|
639 |
+
throw new Twig_SupTwgSgg_Error_Runtime(sprintf('The merge filter only works with arrays or "Traversable", got "%s" as second argument.', gettype($arr2)));
|
640 |
}
|
641 |
|
642 |
return array_merge($arr1, $arr2);
|
645 |
/**
|
646 |
* Slices a variable.
|
647 |
*
|
648 |
+
* @param Twig_SupTwgSgg_Environment $env
|
649 |
* @param mixed $item A variable
|
650 |
* @param int $start Start of the slice
|
651 |
* @param int $length Size of the slice
|
653 |
*
|
654 |
* @return mixed The sliced variable
|
655 |
*/
|
656 |
+
function Twig_SupTwgSgg_slice(Twig_SupTwgSgg_Environment $env, $item, $start, $length = null, $preserveKeys = false)
|
657 |
{
|
658 |
if ($item instanceof Traversable) {
|
659 |
while ($item instanceof IteratorAggregate) {
|
687 |
/**
|
688 |
* Returns the first element of the item.
|
689 |
*
|
690 |
+
* @param Twig_SupTwgSgg_Environment $env
|
691 |
* @param mixed $item A variable
|
692 |
*
|
693 |
* @return mixed The first element of the item
|
694 |
*/
|
695 |
+
function Twig_SupTwgSgg_first(Twig_SupTwgSgg_Environment $env, $item)
|
696 |
{
|
697 |
+
$elements = Twig_SupTwgSgg_slice($env, $item, 0, 1, false);
|
698 |
|
699 |
return is_string($elements) ? $elements : current($elements);
|
700 |
}
|
702 |
/**
|
703 |
* Returns the last element of the item.
|
704 |
*
|
705 |
+
* @param Twig_SupTwgSgg_Environment $env
|
706 |
* @param mixed $item A variable
|
707 |
*
|
708 |
* @return mixed The last element of the item
|
709 |
*/
|
710 |
+
function Twig_SupTwgSgg_last(Twig_SupTwgSgg_Environment $env, $item)
|
711 |
{
|
712 |
+
$elements = Twig_SupTwgSgg_slice($env, $item, -1, 1, false);
|
713 |
|
714 |
return is_string($elements) ? $elements : current($elements);
|
715 |
}
|
732 |
*
|
733 |
* @return string The concatenated string
|
734 |
*/
|
735 |
+
function Twig_SupTwgSgg_join_filter($value, $glue = '')
|
736 |
{
|
737 |
if ($value instanceof Traversable) {
|
738 |
$value = iterator_to_array($value, false);
|
758 |
* {# returns [aa, bb, cc] #}
|
759 |
* </pre>
|
760 |
*
|
761 |
+
* @param Twig_SupTwgSgg_Environment $env
|
762 |
* @param string $value A string
|
763 |
* @param string $delimiter The delimiter
|
764 |
* @param int $limit The limit
|
765 |
*
|
766 |
* @return array The split string as an array
|
767 |
*/
|
768 |
+
function Twig_SupTwgSgg_split_filter(Twig_SupTwgSgg_Environment $env, $value, $delimiter, $limit = null)
|
769 |
{
|
770 |
if (!empty($delimiter)) {
|
771 |
return null === $limit ? explode($delimiter, $value) : explode($delimiter, $value, $limit);
|
798 |
/**
|
799 |
* @internal
|
800 |
*/
|
801 |
+
function _Twig_SupTwgSgg_default_filter($value, $default = '')
|
802 |
{
|
803 |
+
if (Twig_SupTwgSgg_test_empty($value)) {
|
804 |
return $default;
|
805 |
}
|
806 |
|
822 |
*
|
823 |
* @return array The keys
|
824 |
*/
|
825 |
+
function Twig_SupTwgSgg_get_array_keys_filter($array)
|
826 |
{
|
827 |
if ($array instanceof Traversable) {
|
828 |
while ($array instanceof IteratorAggregate) {
|
858 |
/**
|
859 |
* Reverses a variable.
|
860 |
*
|
861 |
+
* @param Twig_SupTwgSgg_Environment $env
|
862 |
* @param array|Traversable|string $item An array, a Traversable instance, or a string
|
863 |
* @param bool $preserveKeys Whether to preserve key or not
|
864 |
*
|
865 |
* @return mixed The reversed input
|
866 |
*/
|
867 |
+
function Twig_SupTwgSgg_reverse_filter(Twig_SupTwgSgg_Environment $env, $item, $preserveKeys = false)
|
868 |
{
|
869 |
if ($item instanceof Traversable) {
|
870 |
return array_reverse(iterator_to_array($item), $preserveKeys);
|
878 |
$string = (string) $item;
|
879 |
|
880 |
if ('UTF-8' !== $charset) {
|
881 |
+
$item = Twig_SupTwgSgg_convert_encoding($string, 'UTF-8', $charset);
|
882 |
}
|
883 |
|
884 |
preg_match_all('/./us', $item, $matches);
|
886 |
$string = implode('', array_reverse($matches[0]));
|
887 |
|
888 |
if ('UTF-8' !== $charset) {
|
889 |
+
$string = Twig_SupTwgSgg_convert_encoding($string, $charset, 'UTF-8');
|
890 |
}
|
891 |
|
892 |
return $string;
|
902 |
*
|
903 |
* @return array
|
904 |
*/
|
905 |
+
function Twig_SupTwgSgg_sort_filter($array)
|
906 |
{
|
907 |
if ($array instanceof Traversable) {
|
908 |
$array = iterator_to_array($array);
|
909 |
} elseif (!is_array($array)) {
|
910 |
+
throw new Twig_SupTwgSgg_Error_Runtime(sprintf('The sort filter only works with arrays or "Traversable", got "%s".', gettype($array)));
|
911 |
}
|
912 |
|
913 |
asort($array);
|
918 |
/**
|
919 |
* @internal
|
920 |
*/
|
921 |
+
function Twig_SupTwgSgg_in_filter($value, $compare)
|
922 |
{
|
923 |
if (is_array($compare)) {
|
924 |
return in_array($value, $compare, is_object($value) || is_resource($value));
|
950 |
*
|
951 |
* @return string
|
952 |
*
|
953 |
+
* @throws Twig_SupTwgSgg_Error_Runtime When an invalid trimming side is used (not a string or not 'left', 'right', or 'both')
|
954 |
*/
|
955 |
+
function Twig_SupTwgSgg_trim_filter($string, $characterMask = null, $side = 'both')
|
956 |
{
|
957 |
if (null === $characterMask) {
|
958 |
$characterMask = " \t\n\r\0\x0B";
|
960 |
|
961 |
switch ($side) {
|
962 |
case 'both':
|
963 |
+
return trim((string)$string, (string)$characterMask);
|
964 |
case 'left':
|
965 |
+
return ltrim((string)$string, (string)$characterMask);
|
966 |
case 'right':
|
967 |
+
return rtrim((string)$string, (string)$characterMask);
|
968 |
default:
|
969 |
+
throw new Twig_SupTwgSgg_Error_Runtime('Trimming side must be "left", "right" or "both".');
|
970 |
}
|
971 |
}
|
972 |
|
973 |
/**
|
974 |
* Escapes a string.
|
975 |
*
|
976 |
+
* @param Twig_SupTwgSgg_Environment $env
|
977 |
* @param mixed $string The value to be escaped
|
978 |
* @param string $strategy The escaping strategy
|
979 |
* @param string $charset The charset
|
981 |
*
|
982 |
* @return string
|
983 |
*/
|
984 |
+
function Twig_SupTwgSgg_escape_filter(Twig_SupTwgSgg_Environment $env, $string, $strategy = 'html', $charset = null, $autoescape = false)
|
985 |
{
|
986 |
+
if ($autoescape && $string instanceof Twig_SupTwgSgg_Markup) {
|
987 |
return $string;
|
988 |
}
|
989 |
|
1042 |
return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
|
1043 |
}
|
1044 |
|
1045 |
+
$string = Twig_SupTwgSgg_convert_encoding($string, 'UTF-8', $charset);
|
1046 |
$string = htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
1047 |
|
1048 |
+
return Twig_SupTwgSgg_convert_encoding($string, $charset, 'UTF-8');
|
1049 |
|
1050 |
case 'js':
|
1051 |
// escape all non-alphanumeric characters
|
1052 |
// into their \xHH or \uHHHH representations
|
1053 |
if ('UTF-8' !== $charset) {
|
1054 |
+
$string = Twig_SupTwgSgg_convert_encoding($string, 'UTF-8', $charset);
|
1055 |
}
|
1056 |
|
1057 |
if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
|
1058 |
+
throw new Twig_SupTwgSgg_Error_Runtime('The string to escape is not a valid UTF-8 string.');
|
1059 |
}
|
1060 |
|
1061 |
+
$string = preg_replace_callback('#[^a-zA-Z0-9,\._]#Su', '_Twig_SupTwgSgg_escape_js_callback', $string);
|
1062 |
|
1063 |
if ('UTF-8' !== $charset) {
|
1064 |
+
$string = Twig_SupTwgSgg_convert_encoding($string, $charset, 'UTF-8');
|
1065 |
}
|
1066 |
|
1067 |
return $string;
|
1068 |
|
1069 |
case 'css':
|
1070 |
if ('UTF-8' !== $charset) {
|
1071 |
+
$string = Twig_SupTwgSgg_convert_encoding($string, 'UTF-8', $charset);
|
1072 |
}
|
1073 |
|
1074 |
if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
|
1075 |
+
throw new Twig_SupTwgSgg_Error_Runtime('The string to escape is not a valid UTF-8 string.');
|
1076 |
}
|
1077 |
|
1078 |
+
$string = preg_replace_callback('#[^a-zA-Z0-9]#Su', '_Twig_SupTwgSgg_escape_css_callback', $string);
|
1079 |
|
1080 |
if ('UTF-8' !== $charset) {
|
1081 |
+
$string = Twig_SupTwgSgg_convert_encoding($string, $charset, 'UTF-8');
|
1082 |
}
|
1083 |
|
1084 |
return $string;
|
1085 |
|
1086 |
case 'html_attr':
|
1087 |
if ('UTF-8' !== $charset) {
|
1088 |
+
$string = Twig_SupTwgSgg_convert_encoding($string, 'UTF-8', $charset);
|
1089 |
}
|
1090 |
|
1091 |
if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
|
1092 |
+
throw new Twig_SupTwgSgg_Error_Runtime('The string to escape is not a valid UTF-8 string.');
|
1093 |
}
|
1094 |
|
1095 |
+
$string = preg_replace_callback('#[^a-zA-Z0-9,\.\-_]#Su', '_Twig_SupTwgSgg_escape_html_attr_callback', $string);
|
1096 |
|
1097 |
if ('UTF-8' !== $charset) {
|
1098 |
+
$string = Twig_SupTwgSgg_convert_encoding($string, $charset, 'UTF-8');
|
1099 |
}
|
1100 |
|
1101 |
return $string;
|
1111 |
static $escapers;
|
1112 |
|
1113 |
if (null === $escapers) {
|
1114 |
+
$escapers = $env->getExtension('Twig_SupTwgSgg_Extension_Core')->getEscapers();
|
1115 |
}
|
1116 |
|
1117 |
if (isset($escapers[$strategy])) {
|
1120 |
|
1121 |
$validStrategies = implode(', ', array_merge(array('html', 'js', 'url', 'css', 'html_attr'), array_keys($escapers)));
|
1122 |
|
1123 |
+
throw new Twig_SupTwgSgg_Error_Runtime(sprintf('Invalid escaping strategy "%s" (valid ones: %s).', $strategy, $validStrategies));
|
1124 |
}
|
1125 |
}
|
1126 |
|
1127 |
/**
|
1128 |
* @internal
|
1129 |
*/
|
1130 |
+
function Twig_SupTwgSgg_escape_filter_is_safe(Twig_SupTwgSgg_Node $filterArgs)
|
1131 |
{
|
1132 |
foreach ($filterArgs as $arg) {
|
1133 |
+
if ($arg instanceof Twig_SupTwgSgg_Node_Expression_Constant) {
|
1134 |
return array($arg->getAttribute('value'));
|
1135 |
}
|
1136 |
|
1141 |
}
|
1142 |
|
1143 |
if (function_exists('mb_convert_encoding')) {
|
1144 |
+
function Twig_SupTwgSgg_convert_encoding($string, $to, $from)
|
1145 |
{
|
1146 |
return mb_convert_encoding($string, $to, $from);
|
1147 |
}
|
1148 |
} elseif (function_exists('iconv')) {
|
1149 |
+
function Twig_SupTwgSgg_convert_encoding($string, $to, $from)
|
1150 |
{
|
1151 |
return iconv($from, $to, $string);
|
1152 |
}
|
1153 |
} else {
|
1154 |
+
function Twig_SupTwgSgg_convert_encoding($string, $to, $from)
|
1155 |
{
|
1156 |
+
throw new Twig_SupTwgSgg_Error_Runtime('No suitable convert encoding function (use UTF-8 as your encoding or install the iconv or mbstring extension).');
|
1157 |
}
|
1158 |
}
|
1159 |
|
1160 |
+
function _Twig_SupTwgSgg_escape_js_callback($matches)
|
1161 |
{
|
1162 |
$char = $matches[0];
|
1163 |
|
1167 |
}
|
1168 |
|
1169 |
// \uHHHH
|
1170 |
+
$char = Twig_SupTwgSgg_convert_encoding($char, 'UTF-16BE', 'UTF-8');
|
1171 |
$char = strtoupper(bin2hex($char));
|
1172 |
|
1173 |
if (4 >= strlen($char)) {
|
1177 |
return sprintf('\u%04s\u%04s', substr($char, 0, -4), substr($char, -4));
|
1178 |
}
|
1179 |
|
1180 |
+
function _Twig_SupTwgSgg_escape_css_callback($matches)
|
1181 |
{
|
1182 |
$char = $matches[0];
|
1183 |
|
1192 |
}
|
1193 |
|
1194 |
// \uHHHH
|
1195 |
+
$char = Twig_SupTwgSgg_convert_encoding($char, 'UTF-16BE', 'UTF-8');
|
1196 |
|
1197 |
return '\\'.ltrim(strtoupper(bin2hex($char)), '0').' ';
|
1198 |
}
|
1203 |
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
|
1204 |
* @license http://framework.zend.com/license/new-bsd New BSD License
|
1205 |
*/
|
1206 |
+
function _Twig_SupTwgSgg_escape_html_attr_callback($matches)
|
1207 |
{
|
1208 |
/*
|
1209 |
* While HTML supports far more named entities, the lowest common denominator
|
1236 |
if (strlen($chr) == 1) {
|
1237 |
$hex = strtoupper(substr('00'.bin2hex($chr), -2));
|
1238 |
} else {
|
1239 |
+
$chr = Twig_SupTwgSgg_convert_encoding($chr, 'UTF-16BE', 'UTF-8');
|
1240 |
$hex = strtoupper(substr('0000'.bin2hex($chr), -4));
|
1241 |
}
|
1242 |
|
1257 |
/**
|
1258 |
* Returns the length of a variable.
|
1259 |
*
|
1260 |
+
* @param Twig_SupTwgSgg_Environment $env
|
1261 |
* @param mixed $thing A variable
|
1262 |
*
|
1263 |
* @return int The length of the value
|
1264 |
*/
|
1265 |
+
function Twig_SupTwgSgg_length_filter(Twig_SupTwgSgg_Environment $env, $thing)
|
1266 |
{
|
1267 |
if (is_scalar($thing)) {
|
1268 |
return mb_strlen($thing, $env->getCharset());
|
1284 |
/**
|
1285 |
* Converts a string to uppercase.
|
1286 |
*
|
1287 |
+
* @param Twig_SupTwgSgg_Environment $env
|
1288 |
* @param string $string A string
|
1289 |
*
|
1290 |
* @return string The uppercased string
|
1291 |
*/
|
1292 |
+
function Twig_SupTwgSgg_upper_filter(Twig_SupTwgSgg_Environment $env, $string)
|
1293 |
{
|
1294 |
if (null !== $charset = $env->getCharset()) {
|
1295 |
return mb_strtoupper($string, $charset);
|
1301 |
/**
|
1302 |
* Converts a string to lowercase.
|
1303 |
*
|
1304 |
+
* @param Twig_SupTwgSgg_Environment $env
|
1305 |
* @param string $string A string
|
1306 |
*
|
1307 |
* @return string The lowercased string
|
1308 |
*/
|
1309 |
+
function Twig_SupTwgSgg_lower_filter(Twig_SupTwgSgg_Environment $env, $string)
|
1310 |
{
|
1311 |
if (null !== $charset = $env->getCharset()) {
|
1312 |
return mb_strtolower($string, $charset);
|
1318 |
/**
|
1319 |
* Returns a titlecased string.
|
1320 |
*
|
1321 |
+
* @param Twig_SupTwgSgg_Environment $env
|
1322 |
* @param string $string A string
|
1323 |
*
|
1324 |
* @return string The titlecased string
|
1325 |
*/
|
1326 |
+
function Twig_SupTwgSgg_title_string_filter(Twig_SupTwgSgg_Environment $env, $string)
|
1327 |
{
|
1328 |
if (null !== $charset = $env->getCharset()) {
|
1329 |
return mb_convert_case($string, MB_CASE_TITLE, $charset);
|
1335 |
/**
|
1336 |
* Returns a capitalized string.
|
1337 |
*
|
1338 |
+
* @param Twig_SupTwgSgg_Environment $env
|
1339 |
* @param string $string A string
|
1340 |
*
|
1341 |
* @return string The capitalized string
|
1342 |
*/
|
1343 |
+
function Twig_SupTwgSgg_capitalize_string_filter(Twig_SupTwgSgg_Environment $env, $string)
|
1344 |
{
|
1345 |
if (null !== $charset = $env->getCharset()) {
|
1346 |
return mb_strtoupper(mb_substr($string, 0, 1, $charset), $charset).mb_strtolower(mb_substr($string, 1, mb_strlen($string, $charset), $charset), $charset);
|
1354 |
/**
|
1355 |
* Returns the length of a variable.
|
1356 |
*
|
1357 |
+
* @param Twig_SupTwgSgg_Environment $env
|
1358 |
* @param mixed $thing A variable
|
1359 |
*
|
1360 |
* @return int The length of the value
|
1361 |
*/
|
1362 |
+
function Twig_SupTwgSgg_length_filter(Twig_SupTwgSgg_Environment $env, $thing)
|
1363 |
{
|
1364 |
if (is_scalar($thing)) {
|
1365 |
return strlen($thing);
|
1375 |
/**
|
1376 |
* Returns a titlecased string.
|
1377 |
*
|
1378 |
+
* @param Twig_SupTwgSgg_Environment $env
|
1379 |
* @param string $string A string
|
1380 |
*
|
1381 |
* @return string The titlecased string
|
1382 |
*/
|
1383 |
+
function Twig_SupTwgSgg_title_string_filter(Twig_SupTwgSgg_Environment $env, $string)
|
1384 |
{
|
1385 |
return ucwords(strtolower($string));
|
1386 |
}
|
1388 |
/**
|
1389 |
* Returns a capitalized string.
|
1390 |
*
|
1391 |
+
* @param Twig_SupTwgSgg_Environment $env
|
1392 |
* @param string $string A string
|
1393 |
*
|
1394 |
* @return string The capitalized string
|
1395 |
*/
|
1396 |
+
function Twig_SupTwgSgg_capitalize_string_filter(Twig_SupTwgSgg_Environment $env, $string)
|
1397 |
{
|
1398 |
return ucfirst(strtolower($string));
|
1399 |
}
|
1402 |
/**
|
1403 |
* @internal
|
1404 |
*/
|
1405 |
+
function Twig_SupTwgSgg_ensure_traversable($seq)
|
1406 |
{
|
1407 |
if ($seq instanceof Traversable || is_array($seq)) {
|
1408 |
return $seq;
|
1425 |
*
|
1426 |
* @return bool true if the value is empty, false otherwise
|
1427 |
*/
|
1428 |
+
function Twig_SupTwgSgg_test_empty($value)
|
1429 |
{
|
1430 |
if ($value instanceof Countable) {
|
1431 |
return 0 == count($value);
|
1452 |
*
|
1453 |
* @return bool true if the value is traversable
|
1454 |
*/
|
1455 |
+
function Twig_SupTwgSgg_test_iterable($value)
|
1456 |
{
|
1457 |
return $value instanceof Traversable || is_array($value);
|
1458 |
}
|
1460 |
/**
|
1461 |
* Renders a template.
|
1462 |
*
|
1463 |
+
* @param Twig_SupTwgSgg_Environment $env
|
1464 |
* @param array $context
|
1465 |
* @param string|array $template The template to render or an array of templates to try consecutively
|
1466 |
* @param array $variables The variables to pass to the template
|
1470 |
*
|
1471 |
* @return string The rendered template
|
1472 |
*/
|
1473 |
+
function Twig_SupTwgSgg_include(Twig_SupTwgSgg_Environment $env, $context, $template, $variables = array(), $withContext = true, $ignoreMissing = false, $sandboxed = false)
|
1474 |
{
|
1475 |
$alreadySandboxed = false;
|
1476 |
$sandbox = null;
|
1478 |
$variables = array_merge($context, $variables);
|
1479 |
}
|
1480 |
|
1481 |
+
if ($isSandboxed = $sandboxed && $env->hasExtension('Twig_SupTwgSgg_Extension_Sandbox')) {
|
1482 |
+
$sandbox = $env->getExtension('Twig_SupTwgSgg_Extension_Sandbox');
|
1483 |
if (!$alreadySandboxed = $sandbox->isSandboxed()) {
|
1484 |
$sandbox->enableSandbox();
|
1485 |
}
|
1488 |
$result = null;
|
1489 |
try {
|
1490 |
$result = $env->resolveTemplate($template)->render($variables);
|
1491 |
+
} catch (Twig_SupTwgSgg_Error_Loader $e) {
|
1492 |
if (!$ignoreMissing) {
|
1493 |
if ($isSandboxed && !$alreadySandboxed) {
|
1494 |
$sandbox->disableSandbox();
|
1520 |
/**
|
1521 |
* Returns a template content without rendering it.
|
1522 |
*
|
1523 |
+
* @param Twig_SupTwgSgg_Environment $env
|
1524 |
* @param string $name The template name
|
1525 |
* @param bool $ignoreMissing Whether to ignore missing templates or not
|
1526 |
*
|
1527 |
* @return string The template source
|
1528 |
*/
|
1529 |
+
function Twig_SupTwgSgg_source(Twig_SupTwgSgg_Environment $env, $name, $ignoreMissing = false)
|
1530 |
{
|
1531 |
$loader = $env->getLoader();
|
1532 |
try {
|
1533 |
+
if (!$loader instanceof Twig_SupTwgSgg_SourceContextLoaderInterface) {
|
1534 |
return $loader->getSource($name);
|
1535 |
} else {
|
1536 |
return $loader->getSourceContext($name)->getCode();
|
1537 |
}
|
1538 |
+
} catch (Twig_SupTwgSgg_Error_Loader $e) {
|
1539 |
if (!$ignoreMissing) {
|
1540 |
throw $e;
|
1541 |
}
|
1550 |
*
|
1551 |
* @return string
|
1552 |
*/
|
1553 |
+
function Twig_SupTwgSgg_constant($constant, $object = null)
|
1554 |
{
|
1555 |
if (null !== $object) {
|
1556 |
$constant = get_class($object).'::'.$constant;
|
1567 |
*
|
1568 |
* @return bool
|
1569 |
*/
|
1570 |
+
function Twig_SupTwgSgg_constant_is_defined($constant, $object = null)
|
1571 |
{
|
1572 |
if (null !== $object) {
|
1573 |
$constant = get_class($object).'::'.$constant;
|
1585 |
*
|
1586 |
* @return array
|
1587 |
*/
|
1588 |
+
function Twig_SupTwgSgg_array_batch($items, $size, $fill = null)
|
1589 |
{
|
1590 |
if ($items instanceof Traversable) {
|
1591 |
$items = iterator_to_array($items, false);
|
vendor/Twig/Extension/Debug.php
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
/**
|
13 |
* @final
|
14 |
*/
|
15 |
-
class
|
16 |
{
|
17 |
public function getFunctions()
|
18 |
{
|
@@ -27,7 +27,7 @@ class Twig_SupTwg_Extension_Debug extends Twig_SupTwg_Extension
|
|
27 |
;
|
28 |
|
29 |
return array(
|
30 |
-
new
|
31 |
);
|
32 |
}
|
33 |
|
@@ -37,7 +37,7 @@ class Twig_SupTwg_Extension_Debug extends Twig_SupTwg_Extension
|
|
37 |
}
|
38 |
}
|
39 |
|
40 |
-
function
|
41 |
{
|
42 |
if (!$env->isDebug()) {
|
43 |
return;
|
@@ -49,7 +49,7 @@ function Twig_SupTwg_var_dump(Twig_SupTwg_Environment $env, $context)
|
|
49 |
if (2 === $count) {
|
50 |
$vars = array();
|
51 |
foreach ($context as $key => $value) {
|
52 |
-
if (!$value instanceof
|
53 |
$vars[$key] = $value;
|
54 |
}
|
55 |
}
|
12 |
/**
|
13 |
* @final
|
14 |
*/
|
15 |
+
class Twig_SupTwgSgg_Extension_Debug extends Twig_SupTwgSgg_Extension
|
16 |
{
|
17 |
public function getFunctions()
|
18 |
{
|
27 |
;
|
28 |
|
29 |
return array(
|
30 |
+
new Twig_SupTwgSgg_SimpleFunction('dump', 'Twig_SupTwgSgg_var_dump', array('is_safe' => $isDumpOutputHtmlSafe ? array('html') : array(), 'needs_context' => true, 'needs_environment' => true)),
|
31 |
);
|
32 |
}
|
33 |
|
37 |
}
|
38 |
}
|
39 |
|
40 |
+
function Twig_SupTwgSgg_var_dump(Twig_SupTwgSgg_Environment $env, $context)
|
41 |
{
|
42 |
if (!$env->isDebug()) {
|
43 |
return;
|
49 |
if (2 === $count) {
|
50 |
$vars = array();
|
51 |
foreach ($context as $key => $value) {
|
52 |
+
if (!$value instanceof Twig_SupTwgSgg_Template) {
|
53 |
$vars[$key] = $value;
|
54 |
}
|
55 |
}
|
vendor/Twig/Extension/Escaper.php
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
/**
|
13 |
* @final
|
14 |
*/
|
15 |
-
class
|
16 |
{
|
17 |
protected $defaultStrategy;
|
18 |
|
@@ -28,18 +28,18 @@ class Twig_SupTwg_Extension_Escaper extends Twig_SupTwg_Extension
|
|
28 |
|
29 |
public function getTokenParsers()
|
30 |
{
|
31 |
-
return array(new
|
32 |
}
|
33 |
|
34 |
public function getNodeVisitors()
|
35 |
{
|
36 |
-
return array(new
|
37 |
}
|
38 |
|
39 |
public function getFilters()
|
40 |
{
|
41 |
return array(
|
42 |
-
new
|
43 |
);
|
44 |
}
|
45 |
|
@@ -55,19 +55,19 @@ class Twig_SupTwg_Extension_Escaper extends Twig_SupTwg_Extension
|
|
55 |
{
|
56 |
// for BC
|
57 |
if (true === $defaultStrategy) {
|
58 |
-
|
59 |
|
60 |
$defaultStrategy = 'html';
|
61 |
}
|
62 |
|
63 |
if ('filename' === $defaultStrategy) {
|
64 |
-
|
65 |
|
66 |
$defaultStrategy = 'name';
|
67 |
}
|
68 |
|
69 |
if ('name' === $defaultStrategy) {
|
70 |
-
$defaultStrategy = array('
|
71 |
}
|
72 |
|
73 |
$this->defaultStrategy = $defaultStrategy;
|
@@ -104,7 +104,7 @@ class Twig_SupTwg_Extension_Escaper extends Twig_SupTwg_Extension
|
|
104 |
*
|
105 |
* @return string
|
106 |
*/
|
107 |
-
function
|
108 |
{
|
109 |
return $string;
|
110 |
}
|
12 |
/**
|
13 |
* @final
|
14 |
*/
|
15 |
+
class Twig_SupTwgSgg_Extension_Escaper extends Twig_SupTwgSgg_Extension
|
16 |
{
|
17 |
protected $defaultStrategy;
|
18 |
|
28 |
|
29 |
public function getTokenParsers()
|
30 |
{
|
31 |
+
return array(new Twig_SupTwgSgg_TokenParser_AutoEscape());
|
32 |
}
|
33 |
|
34 |
public function getNodeVisitors()
|
35 |
{
|
36 |
+
return array(new Twig_SupTwgSgg_NodeVisitor_Escaper());
|
37 |
}
|
38 |
|
39 |
public function getFilters()
|
40 |
{
|
41 |
return array(
|
42 |
+
new Twig_SupTwgSgg_SimpleFilter('raw', 'Twig_SupTwgSgg_raw_filter', array('is_safe' => array('all'))),
|
43 |
);
|
44 |
}
|
45 |
|
55 |
{
|
56 |
// for BC
|
57 |
if (true === $defaultStrategy) {
|
58 |
+
//@trigger_error('Using "true" as the default strategy is deprecated since version 1.21. Use "html" instead.', E_USER_DEPRECATED);
|
59 |
|
60 |
$defaultStrategy = 'html';
|
61 |
}
|
62 |
|
63 |
if ('filename' === $defaultStrategy) {
|
64 |
+
//@trigger_error('Using "filename" as the default strategy is deprecated since version 1.27. Use "name" instead.', E_USER_DEPRECATED);
|
65 |
|
66 |
$defaultStrategy = 'name';
|
67 |
}
|
68 |
|
69 |
if ('name' === $defaultStrategy) {
|
70 |
+
$defaultStrategy = array('Twig_SupTwgSgg_FileExtensionEscapingStrategy', 'guess');
|
71 |
}
|
72 |
|
73 |
$this->defaultStrategy = $defaultStrategy;
|
104 |
*
|
105 |
* @return string
|
106 |
*/
|
107 |
+
function Twig_SupTwgSgg_raw_filter($string)
|
108 |
{
|
109 |
return $string;
|
110 |
}
|
vendor/Twig/Extension/GlobalsInterface.php
CHANGED
@@ -10,13 +10,13 @@
|
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
-
* Enables usage of the deprecated
|
14 |
*
|
15 |
* Explicitly implement this interface if you really need to implement the
|
16 |
* deprecated getGlobals() method in your extensions.
|
17 |
*
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*/
|
20 |
-
interface
|
21 |
{
|
22 |
}
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
+
* Enables usage of the deprecated Twig_SupTwgSgg_Extension::getGlobals() method.
|
14 |
*
|
15 |
* Explicitly implement this interface if you really need to implement the
|
16 |
* deprecated getGlobals() method in your extensions.
|
17 |
*
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*/
|
20 |
+
interface Twig_SupTwgSgg_Extension_GlobalsInterface
|
21 |
{
|
22 |
}
|
vendor/Twig/Extension/InitRuntimeInterface.php
CHANGED
@@ -10,13 +10,13 @@
|
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
-
* Enables usage of the deprecated
|
14 |
*
|
15 |
* Explicitly implement this interface if you really need to implement the
|
16 |
* deprecated initRuntime() method in your extensions.
|
17 |
*
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*/
|
20 |
-
interface
|
21 |
{
|
22 |
}
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
+
* Enables usage of the deprecated Twig_SupTwgSgg_Extension::initRuntime() method.
|
14 |
*
|
15 |
* Explicitly implement this interface if you really need to implement the
|
16 |
* deprecated initRuntime() method in your extensions.
|
17 |
*
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*/
|
20 |
+
interface Twig_SupTwgSgg_Extension_InitRuntimeInterface
|
21 |
{
|
22 |
}
|
vendor/Twig/Extension/Optimizer.php
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
/**
|
13 |
* @final
|
14 |
*/
|
15 |
-
class
|
16 |
{
|
17 |
protected $optimizers;
|
18 |
|
@@ -23,7 +23,7 @@ class Twig_SupTwg_Extension_Optimizer extends Twig_SupTwg_Extension
|
|
23 |
|
24 |
public function getNodeVisitors()
|
25 |
{
|
26 |
-
return array(new
|
27 |
}
|
28 |
|
29 |
public function getName()
|
12 |
/**
|
13 |
* @final
|
14 |
*/
|
15 |
+
class Twig_SupTwgSgg_Extension_Optimizer extends Twig_SupTwgSgg_Extension
|
16 |
{
|
17 |
protected $optimizers;
|
18 |
|
23 |
|
24 |
public function getNodeVisitors()
|
25 |
{
|
26 |
+
return array(new Twig_SupTwgSgg_NodeVisitor_Optimizer($this->optimizers));
|
27 |
}
|
28 |
|
29 |
public function getName()
|
vendor/Twig/Extension/Profiler.php
CHANGED
@@ -9,22 +9,22 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
class
|
13 |
{
|
14 |
private $actives = array();
|
15 |
|
16 |
-
public function __construct(
|
17 |
{
|
18 |
$this->actives[] = $profile;
|
19 |
}
|
20 |
|
21 |
-
public function enter(
|
22 |
{
|
23 |
$this->actives[0]->addProfile($profile);
|
24 |
array_unshift($this->actives, $profile);
|
25 |
}
|
26 |
|
27 |
-
public function leave(
|
28 |
{
|
29 |
$profile->leave();
|
30 |
array_shift($this->actives);
|
@@ -36,7 +36,7 @@ class Twig_SupTwg_Extension_Profiler extends Twig_SupTwg_Extension
|
|
36 |
|
37 |
public function getNodeVisitors()
|
38 |
{
|
39 |
-
return array(new
|
40 |
}
|
41 |
|
42 |
public function getName()
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
+
class Twig_SupTwgSgg_Extension_Profiler extends Twig_SupTwgSgg_Extension
|
13 |
{
|
14 |
private $actives = array();
|
15 |
|
16 |
+
public function __construct(Twig_SupTwgSgg_Profiler_Profile $profile)
|
17 |
{
|
18 |
$this->actives[] = $profile;
|
19 |
}
|
20 |
|
21 |
+
public function enter(Twig_SupTwgSgg_Profiler_Profile $profile)
|
22 |
{
|
23 |
$this->actives[0]->addProfile($profile);
|
24 |
array_unshift($this->actives, $profile);
|
25 |
}
|
26 |
|
27 |
+
public function leave(Twig_SupTwgSgg_Profiler_Profile $profile)
|
28 |
{
|
29 |
$profile->leave();
|
30 |
array_shift($this->actives);
|
36 |
|
37 |
public function getNodeVisitors()
|
38 |
{
|
39 |
+
return array(new Twig_SupTwgSgg_Profiler_NodeVisitor_Profiler(get_class($this)));
|
40 |
}
|
41 |
|
42 |
public function getName()
|
vendor/Twig/Extension/Sandbox.php
CHANGED
@@ -12,13 +12,13 @@
|
|
12 |
/**
|
13 |
* @final
|
14 |
*/
|
15 |
-
class
|
16 |
{
|
17 |
protected $sandboxedGlobally;
|
18 |
protected $sandboxed;
|
19 |
protected $policy;
|
20 |
|
21 |
-
public function __construct(
|
22 |
{
|
23 |
$this->policy = $policy;
|
24 |
$this->sandboxedGlobally = $sandboxed;
|
@@ -26,12 +26,12 @@ class Twig_SupTwg_Extension_Sandbox extends Twig_SupTwg_Extension
|
|
26 |
|
27 |
public function getTokenParsers()
|
28 |
{
|
29 |
-
return array(new
|
30 |
}
|
31 |
|
32 |
public function getNodeVisitors()
|
33 |
{
|
34 |
-
return array(new
|
35 |
}
|
36 |
|
37 |
public function enableSandbox()
|
@@ -54,7 +54,7 @@ class Twig_SupTwg_Extension_Sandbox extends Twig_SupTwg_Extension
|
|
54 |
return $this->sandboxedGlobally;
|
55 |
}
|
56 |
|
57 |
-
public function setSecurityPolicy(
|
58 |
{
|
59 |
$this->policy = $policy;
|
60 |
}
|
12 |
/**
|
13 |
* @final
|
14 |
*/
|
15 |
+
class Twig_SupTwgSgg_Extension_Sandbox extends Twig_SupTwgSgg_Extension
|
16 |
{
|
17 |
protected $sandboxedGlobally;
|
18 |
protected $sandboxed;
|
19 |
protected $policy;
|
20 |
|
21 |
+
public function __construct(Twig_SupTwgSgg_Sandbox_SecurityPolicyInterface $policy, $sandboxed = false)
|
22 |
{
|
23 |
$this->policy = $policy;
|
24 |
$this->sandboxedGlobally = $sandboxed;
|
26 |
|
27 |
public function getTokenParsers()
|
28 |
{
|
29 |
+
return array(new Twig_SupTwgSgg_TokenParser_Sandbox());
|
30 |
}
|
31 |
|
32 |
public function getNodeVisitors()
|
33 |
{
|
34 |
+
return array(new Twig_SupTwgSgg_NodeVisitor_Sandbox());
|
35 |
}
|
36 |
|
37 |
public function enableSandbox()
|
54 |
return $this->sandboxedGlobally;
|
55 |
}
|
56 |
|
57 |
+
public function setSecurityPolicy(Twig_SupTwgSgg_Sandbox_SecurityPolicyInterface $policy)
|
58 |
{
|
59 |
$this->policy = $policy;
|
60 |
}
|
vendor/Twig/Extension/Staging.php
CHANGED
@@ -12,13 +12,13 @@
|
|
12 |
/**
|
13 |
* Internal class.
|
14 |
*
|
15 |
-
* This class is used by
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*
|
19 |
* @internal
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
protected $functions = array();
|
24 |
protected $filters = array();
|
@@ -53,7 +53,7 @@ class Twig_SupTwg_Extension_Staging extends Twig_SupTwg_Extension
|
|
53 |
return $this->filters;
|
54 |
}
|
55 |
|
56 |
-
public function addNodeVisitor(
|
57 |
{
|
58 |
$this->visitors[] = $visitor;
|
59 |
}
|
@@ -63,7 +63,7 @@ class Twig_SupTwg_Extension_Staging extends Twig_SupTwg_Extension
|
|
63 |
return $this->visitors;
|
64 |
}
|
65 |
|
66 |
-
public function addTokenParser(
|
67 |
{
|
68 |
if (isset($this->tokenParsers[$parser->getTag()])) {
|
69 |
}
|
12 |
/**
|
13 |
* Internal class.
|
14 |
*
|
15 |
+
* This class is used by Twig_SupTwgSgg_Environment as a staging area and must not be used directly.
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*
|
19 |
* @internal
|
20 |
*/
|
21 |
+
class Twig_SupTwgSgg_Extension_Staging extends Twig_SupTwgSgg_Extension
|
22 |
{
|
23 |
protected $functions = array();
|
24 |
protected $filters = array();
|
53 |
return $this->filters;
|
54 |
}
|
55 |
|
56 |
+
public function addNodeVisitor(Twig_SupTwgSgg_NodeVisitorInterface $visitor)
|
57 |
{
|
58 |
$this->visitors[] = $visitor;
|
59 |
}
|
63 |
return $this->visitors;
|
64 |
}
|
65 |
|
66 |
+
public function addTokenParser(Twig_SupTwgSgg_TokenParserInterface $parser)
|
67 |
{
|
68 |
if (isset($this->tokenParsers[$parser->getTag()])) {
|
69 |
}
|
vendor/Twig/Extension/StringLoader.php
CHANGED
@@ -12,12 +12,12 @@
|
|
12 |
/**
|
13 |
* @final
|
14 |
*/
|
15 |
-
class
|
16 |
{
|
17 |
public function getFunctions()
|
18 |
{
|
19 |
return array(
|
20 |
-
new
|
21 |
);
|
22 |
}
|
23 |
|
@@ -34,12 +34,12 @@ class Twig_SupTwg_Extension_StringLoader extends Twig_SupTwg_Extension
|
|
34 |
* {{ include(template_from_string("Hello {{ name }}")) }}
|
35 |
* </pre>
|
36 |
*
|
37 |
-
* @param
|
38 |
* @param string $template A template as a string or object implementing __toString()
|
39 |
*
|
40 |
-
* @return
|
41 |
*/
|
42 |
-
function
|
43 |
{
|
44 |
return $env->createTemplate((string) $template);
|
45 |
}
|
12 |
/**
|
13 |
* @final
|
14 |
*/
|
15 |
+
class Twig_SupTwgSgg_Extension_StringLoader extends Twig_SupTwgSgg_Extension
|
16 |
{
|
17 |
public function getFunctions()
|
18 |
{
|
19 |
return array(
|
20 |
+
new Twig_SupTwgSgg_SimpleFunction('template_from_string', 'Twig_SupTwgSgg_template_from_string', array('needs_environment' => true)),
|
21 |
);
|
22 |
}
|
23 |
|
34 |
* {{ include(template_from_string("Hello {{ name }}")) }}
|
35 |
* </pre>
|
36 |
*
|
37 |
+
* @param Twig_SupTwgSgg_Environment $env A Twig_SupTwgSgg_Environment instance
|
38 |
* @param string $template A template as a string or object implementing __toString()
|
39 |
*
|
40 |
+
* @return Twig_SupTwgSgg_Template
|
41 |
*/
|
42 |
+
function Twig_SupTwgSgg_template_from_string(Twig_SupTwgSgg_Environment $env, $template)
|
43 |
{
|
44 |
return $env->createTemplate((string) $template);
|
45 |
}
|
vendor/Twig/ExtensionInterface.php
CHANGED
@@ -14,49 +14,49 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
interface
|
18 |
{
|
19 |
/**
|
20 |
* Initializes the runtime environment.
|
21 |
*
|
22 |
* This is where you can load some file that contains filter functions for instance.
|
23 |
*
|
24 |
-
* @deprecated since 1.23 (to be removed in 2.0), implement
|
25 |
*/
|
26 |
-
public function initRuntime(
|
27 |
|
28 |
/**
|
29 |
* Returns the token parser instances to add to the existing list.
|
30 |
*
|
31 |
-
* @return
|
32 |
*/
|
33 |
public function getTokenParsers();
|
34 |
|
35 |
/**
|
36 |
* Returns the node visitor instances to add to the existing list.
|
37 |
*
|
38 |
-
* @return
|
39 |
*/
|
40 |
public function getNodeVisitors();
|
41 |
|
42 |
/**
|
43 |
* Returns a list of filters to add to the existing list.
|
44 |
*
|
45 |
-
* @return
|
46 |
*/
|
47 |
public function getFilters();
|
48 |
|
49 |
/**
|
50 |
* Returns a list of tests to add to the existing list.
|
51 |
*
|
52 |
-
* @return
|
53 |
*/
|
54 |
public function getTests();
|
55 |
|
56 |
/**
|
57 |
* Returns a list of functions to add to the existing list.
|
58 |
*
|
59 |
-
* @return
|
60 |
*/
|
61 |
public function getFunctions();
|
62 |
|
@@ -72,7 +72,7 @@ interface Twig_SupTwg_ExtensionInterface
|
|
72 |
*
|
73 |
* @return array An array of global variables
|
74 |
*
|
75 |
-
* @deprecated since 1.23 (to be removed in 2.0), implement
|
76 |
*/
|
77 |
public function getGlobals();
|
78 |
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
interface Twig_SupTwgSgg_ExtensionInterface
|
18 |
{
|
19 |
/**
|
20 |
* Initializes the runtime environment.
|
21 |
*
|
22 |
* This is where you can load some file that contains filter functions for instance.
|
23 |
*
|
24 |
+
* @deprecated since 1.23 (to be removed in 2.0), implement Twig_SupTwgSgg_Extension_InitRuntimeInterface instead
|
25 |
*/
|
26 |
+
public function initRuntime(Twig_SupTwgSgg_Environment $environment);
|
27 |
|
28 |
/**
|
29 |
* Returns the token parser instances to add to the existing list.
|
30 |
*
|
31 |
+
* @return Twig_SupTwgSgg_TokenParserInterface[]
|
32 |
*/
|
33 |
public function getTokenParsers();
|
34 |
|
35 |
/**
|
36 |
* Returns the node visitor instances to add to the existing list.
|
37 |
*
|
38 |
+
* @return Twig_SupTwgSgg_NodeVisitorInterface[]
|
39 |
*/
|
40 |
public function getNodeVisitors();
|
41 |
|
42 |
/**
|
43 |
* Returns a list of filters to add to the existing list.
|
44 |
*
|
45 |
+
* @return Twig_SupTwgSgg_SimpleFilter[]
|
46 |
*/
|
47 |
public function getFilters();
|
48 |
|
49 |
/**
|
50 |
* Returns a list of tests to add to the existing list.
|
51 |
*
|
52 |
+
* @return Twig_SupTwgSgg_SimpleTest[]
|
53 |
*/
|
54 |
public function getTests();
|
55 |
|
56 |
/**
|
57 |
* Returns a list of functions to add to the existing list.
|
58 |
*
|
59 |
+
* @return Twig_SupTwgSgg_SimpleFunction[]
|
60 |
*/
|
61 |
public function getFunctions();
|
62 |
|
72 |
*
|
73 |
* @return array An array of global variables
|
74 |
*
|
75 |
+
* @deprecated since 1.23 (to be removed in 2.0), implement Twig_SupTwgSgg_Extension_GlobalsInterface instead
|
76 |
*/
|
77 |
public function getGlobals();
|
78 |
|
vendor/Twig/FactoryRuntimeLoader.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @author Robin Chalas <robin.chalas@gmail.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
private $map;
|
20 |
|
14 |
*
|
15 |
* @author Robin Chalas <robin.chalas@gmail.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_FactoryRuntimeLoader implements Twig_SupTwgSgg_RuntimeLoaderInterface
|
18 |
{
|
19 |
private $map;
|
20 |
|
vendor/Twig/FileExtensionEscapingStrategy.php
CHANGED
@@ -20,7 +20,7 @@
|
|
20 |
*
|
21 |
* @author Fabien Potencier <fabien@symfony.com>
|
22 |
*/
|
23 |
-
class
|
24 |
{
|
25 |
/**
|
26 |
* Guesses the best autoescaping strategy based on the file name.
|
20 |
*
|
21 |
* @author Fabien Potencier <fabien@symfony.com>
|
22 |
*/
|
23 |
+
class Twig_SupTwgSgg_FileExtensionEscapingStrategy
|
24 |
{
|
25 |
/**
|
26 |
* Guesses the best autoescaping strategy based on the file name.
|
vendor/Twig/Filter.php
CHANGED
@@ -9,18 +9,18 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
|
14 |
/**
|
15 |
* Represents a template filter.
|
16 |
*
|
17 |
-
* Use
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*
|
21 |
* @deprecated since 1.12 (to be removed in 2.0)
|
22 |
*/
|
23 |
-
abstract class
|
24 |
{
|
25 |
protected $options;
|
26 |
protected $arguments = array();
|
@@ -56,7 +56,7 @@ abstract class Twig_SupTwg_Filter implements Twig_SupTwg_FilterInterface, Twig_S
|
|
56 |
return $this->options['needs_context'];
|
57 |
}
|
58 |
|
59 |
-
public function getSafe(
|
60 |
{
|
61 |
if (isset($this->options['is_safe'])) {
|
62 |
return $this->options['is_safe'];
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
+
//@trigger_error('The Twig_SupTwgSgg_Filter class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSgg_SimpleFilter instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Represents a template filter.
|
16 |
*
|
17 |
+
* Use Twig_SupTwgSgg_SimpleFilter instead.
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*
|
21 |
* @deprecated since 1.12 (to be removed in 2.0)
|
22 |
*/
|
23 |
+
abstract class Twig_SupTwgSgg_Filter implements Twig_SupTwgSgg_FilterInterface, Twig_SupTwgSgg_FilterCallableInterface
|
24 |
{
|
25 |
protected $options;
|
26 |
protected $arguments = array();
|
56 |
return $this->options['needs_context'];
|
57 |
}
|
58 |
|
59 |
+
public function getSafe(Twig_SupTwgSgg_Node $filterArgs)
|
60 |
{
|
61 |
if (isset($this->options['is_safe'])) {
|
62 |
return $this->options['is_safe'];
|
vendor/Twig/Filter/Function.php
CHANGED
@@ -9,18 +9,18 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
|
14 |
/**
|
15 |
* Represents a function template filter.
|
16 |
*
|
17 |
-
* Use
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*
|
21 |
* @deprecated since 1.12 (to be removed in 2.0)
|
22 |
*/
|
23 |
-
class
|
24 |
{
|
25 |
protected $function;
|
26 |
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
+
//@trigger_error('The Twig_SupTwgSgg_Filter_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSgg_SimpleFilter instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Represents a function template filter.
|
16 |
*
|
17 |
+
* Use Twig_SupTwgSgg_SimpleFilter instead.
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*
|
21 |
* @deprecated since 1.12 (to be removed in 2.0)
|
22 |
*/
|
23 |
+
class Twig_SupTwgSgg_Filter_Function extends Twig_SupTwgSgg_Filter
|
24 |
{
|
25 |
protected $function;
|
26 |
|
vendor/Twig/Filter/Method.php
CHANGED
@@ -9,23 +9,23 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
|
14 |
/**
|
15 |
* Represents a method template filter.
|
16 |
*
|
17 |
-
* Use
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*
|
21 |
* @deprecated since 1.12 (to be removed in 2.0)
|
22 |
*/
|
23 |
-
class
|
24 |
{
|
25 |
protected $extension;
|
26 |
protected $method;
|
27 |
|
28 |
-
public function __construct(
|
29 |
{
|
30 |
$options['callable'] = array($extension, $method);
|
31 |
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
+
//@trigger_error('The Twig_SupTwgSgg_Filter_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSgg_SimpleFilter instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Represents a method template filter.
|
16 |
*
|
17 |
+
* Use Twig_SupTwgSgg_SimpleFilter instead.
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*
|
21 |
* @deprecated since 1.12 (to be removed in 2.0)
|
22 |
*/
|
23 |
+
class Twig_SupTwgSgg_Filter_Method extends Twig_SupTwgSgg_Filter
|
24 |
{
|
25 |
protected $extension;
|
26 |
protected $method;
|
27 |
|
28 |
+
public function __construct(Twig_SupTwgSgg_ExtensionInterface $extension, $method, array $options = array())
|
29 |
{
|
30 |
$options['callable'] = array($extension, $method);
|
31 |
|
vendor/Twig/Filter/Node.php
CHANGED
@@ -9,18 +9,18 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
|
14 |
/**
|
15 |
* Represents a template filter as a node.
|
16 |
*
|
17 |
-
* Use
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*
|
21 |
* @deprecated since 1.12 (to be removed in 2.0)
|
22 |
*/
|
23 |
-
class
|
24 |
{
|
25 |
protected $class;
|
26 |
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
+
//@trigger_error('The Twig_SupTwgSgg_Filter_Node class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSgg_SimpleFilter instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Represents a template filter as a node.
|
16 |
*
|
17 |
+
* Use Twig_SupTwgSgg_SimpleFilter instead.
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*
|
21 |
* @deprecated since 1.12 (to be removed in 2.0)
|
22 |
*/
|
23 |
+
class Twig_SupTwgSgg_Filter_Node extends Twig_SupTwgSgg_Filter
|
24 |
{
|
25 |
protected $class;
|
26 |
|
vendor/Twig/FilterCallableInterface.php
CHANGED
@@ -12,13 +12,13 @@
|
|
12 |
/**
|
13 |
* Represents a callable template filter.
|
14 |
*
|
15 |
-
* Use
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*
|
19 |
* @deprecated since 1.12 (to be removed in 2.0)
|
20 |
*/
|
21 |
-
interface
|
22 |
{
|
23 |
public function getCallable();
|
24 |
}
|
12 |
/**
|
13 |
* Represents a callable template filter.
|
14 |
*
|
15 |
+
* Use Twig_SupTwgSgg_SimpleFilter instead.
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*
|
19 |
* @deprecated since 1.12 (to be removed in 2.0)
|
20 |
*/
|
21 |
+
interface Twig_SupTwgSgg_FilterCallableInterface
|
22 |
{
|
23 |
public function getCallable();
|
24 |
}
|
vendor/Twig/FilterInterface.php
CHANGED
@@ -12,13 +12,13 @@
|
|
12 |
/**
|
13 |
* Represents a template filter.
|
14 |
*
|
15 |
-
* Use
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*
|
19 |
* @deprecated since 1.12 (to be removed in 2.0)
|
20 |
*/
|
21 |
-
interface
|
22 |
{
|
23 |
/**
|
24 |
* Compiles a filter.
|
@@ -31,7 +31,7 @@ interface Twig_SupTwg_FilterInterface
|
|
31 |
|
32 |
public function needsContext();
|
33 |
|
34 |
-
public function getSafe(
|
35 |
|
36 |
public function getPreservesSafety();
|
37 |
|
12 |
/**
|
13 |
* Represents a template filter.
|
14 |
*
|
15 |
+
* Use Twig_SupTwgSgg_SimpleFilter instead.
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*
|
19 |
* @deprecated since 1.12 (to be removed in 2.0)
|
20 |
*/
|
21 |
+
interface Twig_SupTwgSgg_FilterInterface
|
22 |
{
|
23 |
/**
|
24 |
* Compiles a filter.
|
31 |
|
32 |
public function needsContext();
|
33 |
|
34 |
+
public function getSafe(Twig_SupTwgSgg_Node $filterArgs);
|
35 |
|
36 |
public function getPreservesSafety();
|
37 |
|
vendor/Twig/Function.php
CHANGED
@@ -9,18 +9,18 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
|
14 |
/**
|
15 |
* Represents a template function.
|
16 |
*
|
17 |
-
* Use
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*
|
21 |
* @deprecated since 1.12 (to be removed in 2.0)
|
22 |
*/
|
23 |
-
abstract class
|
24 |
{
|
25 |
protected $options;
|
26 |
protected $arguments = array();
|
@@ -54,7 +54,7 @@ abstract class Twig_SupTwg_Function implements Twig_SupTwg_FunctionInterface, Tw
|
|
54 |
return $this->options['needs_context'];
|
55 |
}
|
56 |
|
57 |
-
public function getSafe(
|
58 |
{
|
59 |
if (isset($this->options['is_safe'])) {
|
60 |
return $this->options['is_safe'];
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
+
//@trigger_error('The Twig_SupTwgSgg_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSgg_SimpleFunction instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Represents a template function.
|
16 |
*
|
17 |
+
* Use Twig_SupTwgSgg_SimpleFunction instead.
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*
|
21 |
* @deprecated since 1.12 (to be removed in 2.0)
|
22 |
*/
|
23 |
+
abstract class Twig_SupTwgSgg_Function implements Twig_SupTwgSgg_FunctionInterface, Twig_SupTwgSgg_FunctionCallableInterface
|
24 |
{
|
25 |
protected $options;
|
26 |
protected $arguments = array();
|
54 |
return $this->options['needs_context'];
|
55 |
}
|
56 |
|
57 |
+
public function getSafe(Twig_SupTwgSgg_Node $functionArgs)
|
58 |
{
|
59 |
if (isset($this->options['is_safe'])) {
|
60 |
return $this->options['is_safe'];
|
vendor/Twig/Function/Function.php
CHANGED
@@ -10,18 +10,18 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
|
14 |
|
15 |
/**
|
16 |
* Represents a function template function.
|
17 |
*
|
18 |
-
* Use
|
19 |
*
|
20 |
* @author Arnaud Le Blanc <arnaud.lb@gmail.com>
|
21 |
*
|
22 |
* @deprecated since 1.12 (to be removed in 2.0)
|
23 |
*/
|
24 |
-
class
|
25 |
{
|
26 |
protected $function;
|
27 |
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
+
//@trigger_error('The Twig_SupTwgSgg_Function_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSgg_SimpleFunction instead.', E_USER_DEPRECATED);
|
14 |
|
15 |
/**
|
16 |
* Represents a function template function.
|
17 |
*
|
18 |
+
* Use Twig_SupTwgSgg_SimpleFunction instead.
|
19 |
*
|
20 |
* @author Arnaud Le Blanc <arnaud.lb@gmail.com>
|
21 |
*
|
22 |
* @deprecated since 1.12 (to be removed in 2.0)
|
23 |
*/
|
24 |
+
class Twig_SupTwgSgg_Function_Function extends Twig_SupTwgSgg_Function
|
25 |
{
|
26 |
protected $function;
|
27 |
|
vendor/Twig/Function/Method.php
CHANGED
@@ -10,23 +10,23 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
|
14 |
|
15 |
/**
|
16 |
* Represents a method template function.
|
17 |
*
|
18 |
-
* Use
|
19 |
*
|
20 |
* @author Arnaud Le Blanc <arnaud.lb@gmail.com>
|
21 |
*
|
22 |
* @deprecated since 1.12 (to be removed in 2.0)
|
23 |
*/
|
24 |
-
class
|
25 |
{
|
26 |
protected $extension;
|
27 |
protected $method;
|
28 |
|
29 |
-
public function __construct(
|
30 |
{
|
31 |
$options['callable'] = array($extension, $method);
|
32 |
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
+
//@trigger_error('The Twig_SupTwgSgg_Function_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSgg_SimpleFunction instead.', E_USER_DEPRECATED);
|
14 |
|
15 |
/**
|
16 |
* Represents a method template function.
|
17 |
*
|
18 |
+
* Use Twig_SupTwgSgg_SimpleFunction instead.
|
19 |
*
|
20 |
* @author Arnaud Le Blanc <arnaud.lb@gmail.com>
|
21 |
*
|
22 |
* @deprecated since 1.12 (to be removed in 2.0)
|
23 |
*/
|
24 |
+
class Twig_SupTwgSgg_Function_Method extends Twig_SupTwgSgg_Function
|
25 |
{
|
26 |
protected $extension;
|
27 |
protected $method;
|
28 |
|
29 |
+
public function __construct(Twig_SupTwgSgg_ExtensionInterface $extension, $method, array $options = array())
|
30 |
{
|
31 |
$options['callable'] = array($extension, $method);
|
32 |
|
vendor/Twig/Function/Node.php
CHANGED
@@ -9,18 +9,18 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
|
14 |
/**
|
15 |
* Represents a template function as a node.
|
16 |
*
|
17 |
-
* Use
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*
|
21 |
* @deprecated since 1.12 (to be removed in 2.0)
|
22 |
*/
|
23 |
-
class
|
24 |
{
|
25 |
protected $class;
|
26 |
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
+
//@trigger_error('The Twig_SupTwgSgg_Function_Node class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSgg_SimpleFunction instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Represents a template function as a node.
|
16 |
*
|
17 |
+
* Use Twig_SupTwgSgg_SimpleFunction instead.
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*
|
21 |
* @deprecated since 1.12 (to be removed in 2.0)
|
22 |
*/
|
23 |
+
class Twig_SupTwgSgg_Function_Node extends Twig_SupTwgSgg_Function
|
24 |
{
|
25 |
protected $class;
|
26 |
|
vendor/Twig/FunctionCallableInterface.php
CHANGED
@@ -12,13 +12,13 @@
|
|
12 |
/**
|
13 |
* Represents a callable template function.
|
14 |
*
|
15 |
-
* Use
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*
|
19 |
* @deprecated since 1.12 (to be removed in 2.0)
|
20 |
*/
|
21 |
-
interface
|
22 |
{
|
23 |
public function getCallable();
|
24 |
}
|
12 |
/**
|
13 |
* Represents a callable template function.
|
14 |
*
|
15 |
+
* Use Twig_SupTwgSgg_SimpleFunction instead.
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*
|
19 |
* @deprecated since 1.12 (to be removed in 2.0)
|
20 |
*/
|
21 |
+
interface Twig_SupTwgSgg_FunctionCallableInterface
|
22 |
{
|
23 |
public function getCallable();
|
24 |
}
|
vendor/Twig/FunctionInterface.php
CHANGED
@@ -13,13 +13,13 @@
|
|
13 |
/**
|
14 |
* Represents a template function.
|
15 |
*
|
16 |
-
* Use
|
17 |
*
|
18 |
* @author Arnaud Le Blanc <arnaud.lb@gmail.com>
|
19 |
*
|
20 |
* @deprecated since 1.12 (to be removed in 2.0)
|
21 |
*/
|
22 |
-
interface
|
23 |
{
|
24 |
/**
|
25 |
* Compiles a function.
|
@@ -32,7 +32,7 @@ interface Twig_SupTwg_FunctionInterface
|
|
32 |
|
33 |
public function needsContext();
|
34 |
|
35 |
-
public function getSafe(
|
36 |
|
37 |
public function setArguments($arguments);
|
38 |
|
13 |
/**
|
14 |
* Represents a template function.
|
15 |
*
|
16 |
+
* Use Twig_SupTwgSgg_SimpleFunction instead.
|
17 |
*
|
18 |
* @author Arnaud Le Blanc <arnaud.lb@gmail.com>
|
19 |
*
|
20 |
* @deprecated since 1.12 (to be removed in 2.0)
|
21 |
*/
|
22 |
+
interface Twig_SupTwgSgg_FunctionInterface
|
23 |
{
|
24 |
/**
|
25 |
* Compiles a function.
|
32 |
|
33 |
public function needsContext();
|
34 |
|
35 |
+
public function getSafe(Twig_SupTwgSgg_Node $filterArgs);
|
36 |
|
37 |
public function setArguments($arguments);
|
38 |
|
vendor/Twig/Lexer.php
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
-
class
|
19 |
{
|
20 |
protected $tokens;
|
21 |
protected $code;
|
@@ -49,7 +49,7 @@ class Twig_SupTwg_Lexer implements Twig_SupTwg_LexerInterface
|
|
49 |
const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As';
|
50 |
const PUNCTUATION = '()[]{}?:.,|';
|
51 |
|
52 |
-
public function __construct(
|
53 |
{
|
54 |
$this->env = $env;
|
55 |
|
@@ -77,15 +77,15 @@ class Twig_SupTwg_Lexer implements Twig_SupTwg_LexerInterface
|
|
77 |
|
78 |
public function tokenize($code, $name = null)
|
79 |
{
|
80 |
-
if (!$code instanceof
|
81 |
-
|
82 |
-
$this->source = new
|
83 |
} else {
|
84 |
$this->source = $code;
|
85 |
}
|
86 |
|
87 |
if (((int) ini_get('mbstring.func_overload')) & 2) {
|
88 |
-
|
89 |
}
|
90 |
|
91 |
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
|
@@ -136,25 +136,25 @@ class Twig_SupTwg_Lexer implements Twig_SupTwg_LexerInterface
|
|
136 |
}
|
137 |
}
|
138 |
|
139 |
-
$this->pushToken(
|
140 |
|
141 |
if (!empty($this->brackets)) {
|
142 |
list($expect, $lineno) = array_pop($this->brackets);
|
143 |
-
throw new
|
144 |
}
|
145 |
|
146 |
if ($mbEncoding) {
|
147 |
mb_internal_encoding($mbEncoding);
|
148 |
}
|
149 |
|
150 |
-
return new
|
151 |
}
|
152 |
|
153 |
protected function lexData()
|
154 |
{
|
155 |
// if no matches are left we return the rest of the template as simple text token
|
156 |
if ($this->position == count($this->positions[0]) - 1) {
|
157 |
-
$this->pushToken(
|
158 |
$this->cursor = $this->end;
|
159 |
|
160 |
return;
|
@@ -174,7 +174,7 @@ class Twig_SupTwg_Lexer implements Twig_SupTwg_LexerInterface
|
|
174 |
if (isset($this->positions[2][$this->position][0])) {
|
175 |
$text = rtrim($text);
|
176 |
}
|
177 |
-
$this->pushToken(
|
178 |
$this->moveCursor($textContent.$position[0]);
|
179 |
|
180 |
switch ($this->positions[1][$this->position][0]) {
|
@@ -184,22 +184,22 @@ class Twig_SupTwg_Lexer implements Twig_SupTwg_LexerInterface
|
|
184 |
|
185 |
case $this->options['tag_block'][0]:
|
186 |
// raw data?
|
187 |
-
if (preg_match($this->regexes['lex_block_raw'], $this->code, $match,
|
188 |
$this->moveCursor($match[0]);
|
189 |
$this->lexRawData($match[1]);
|
190 |
// {% line \d+ %}
|
191 |
-
|
192 |
$this->moveCursor($match[0]);
|
193 |
$this->lineno = (int) $match[1];
|
194 |
} else {
|
195 |
-
$this->pushToken(
|
196 |
$this->pushState(self::STATE_BLOCK);
|
197 |
$this->currentVarBlockLine = $this->lineno;
|
198 |
}
|
199 |
break;
|
200 |
|
201 |
case $this->options['tag_variable'][0]:
|
202 |
-
$this->pushToken(
|
203 |
$this->pushState(self::STATE_VAR);
|
204 |
$this->currentVarBlockLine = $this->lineno;
|
205 |
break;
|
@@ -208,8 +208,8 @@ class Twig_SupTwg_Lexer implements Twig_SupTwg_LexerInterface
|
|
208 |
|
209 |
protected function lexBlock()
|
210 |
{
|
211 |
-
if (empty($this->brackets) && preg_match($this->regexes['lex_block'], $this->code, $match,
|
212 |
-
$this->pushToken(
|
213 |
$this->moveCursor($match[0]);
|
214 |
$this->popState();
|
215 |
} else {
|
@@ -219,8 +219,8 @@ class Twig_SupTwg_Lexer implements Twig_SupTwg_LexerInterface
|
|
219 |
|
220 |
protected function lexVar()
|
221 |
{
|
222 |
-
if (empty($this->brackets) && preg_match($this->regexes['lex_var'], $this->code, $match,
|
223 |
-
$this->pushToken(
|
224 |
$this->moveCursor($match[0]);
|
225 |
$this->popState();
|
226 |
} else {
|
@@ -231,31 +231,31 @@ class Twig_SupTwg_Lexer implements Twig_SupTwg_LexerInterface
|
|
231 |
protected function lexExpression()
|
232 |
{
|
233 |
// whitespace
|
234 |
-
if (preg_match('/\s+/A', $this->code, $match,
|
235 |
$this->moveCursor($match[0]);
|
236 |
|
237 |
if ($this->cursor >= $this->end) {
|
238 |
-
throw new
|
239 |
}
|
240 |
}
|
241 |
|
242 |
// operators
|
243 |
-
if (preg_match($this->regexes['operator'], $this->code, $match,
|
244 |
-
$this->pushToken(
|
245 |
$this->moveCursor($match[0]);
|
246 |
}
|
247 |
// names
|
248 |
-
elseif (preg_match(self::REGEX_NAME, $this->code, $match,
|
249 |
-
$this->pushToken(
|
250 |
$this->moveCursor($match[0]);
|
251 |
}
|
252 |
// numbers
|
253 |
-
elseif (preg_match(self::REGEX_NUMBER, $this->code, $match,
|
254 |
$number = (float) $match[0]; // floats
|
255 |
if (ctype_digit($match[0]) && $number <= PHP_INT_MAX) {
|
256 |
$number = (int) $match[0]; // integers lower than the maximum
|
257 |
}
|
258 |
-
$this->pushToken(
|
259 |
$this->moveCursor($match[0]);
|
260 |
}
|
261 |
// punctuation
|
@@ -267,43 +267,43 @@ class Twig_SupTwg_Lexer implements Twig_SupTwg_LexerInterface
|
|
267 |
// closing bracket
|
268 |
elseif (false !== strpos(')]}', $this->code[$this->cursor])) {
|
269 |
if (empty($this->brackets)) {
|
270 |
-
throw new
|
271 |
}
|
272 |
|
273 |
list($expect, $lineno) = array_pop($this->brackets);
|
274 |
if ($this->code[$this->cursor] != strtr($expect, '([{', ')]}')) {
|
275 |
-
throw new
|
276 |
}
|
277 |
}
|
278 |
|
279 |
-
$this->pushToken(
|
280 |
++$this->cursor;
|
281 |
}
|
282 |
// strings
|
283 |
-
elseif (preg_match(self::REGEX_STRING, $this->code, $match,
|
284 |
-
$this->pushToken(
|
285 |
$this->moveCursor($match[0]);
|
286 |
}
|
287 |
// opening double quoted string
|
288 |
-
elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match,
|
289 |
$this->brackets[] = array('"', $this->lineno);
|
290 |
$this->pushState(self::STATE_STRING);
|
291 |
$this->moveCursor($match[0]);
|
292 |
}
|
293 |
// unlexable
|
294 |
else {
|
295 |
-
throw new
|
296 |
}
|
297 |
}
|
298 |
|
299 |
protected function lexRawData($tag)
|
300 |
{
|
301 |
if ('raw' === $tag) {
|
302 |
-
|
303 |
}
|
304 |
|
305 |
if (!preg_match(str_replace('%s', $tag, $this->regexes['lex_raw_data']), $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
|
306 |
-
throw new
|
307 |
}
|
308 |
|
309 |
$text = substr($this->code, $this->cursor, $match[0][1] - $this->cursor);
|
@@ -313,13 +313,13 @@ class Twig_SupTwg_Lexer implements Twig_SupTwg_LexerInterface
|
|
313 |
$text = rtrim($text);
|
314 |
}
|
315 |
|
316 |
-
$this->pushToken(
|
317 |
}
|
318 |
|
319 |
protected function lexComment()
|
320 |
{
|
321 |
if (!preg_match($this->regexes['lex_comment'], $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
|
322 |
-
throw new
|
323 |
}
|
324 |
|
325 |
$this->moveCursor(substr($this->code, $this->cursor, $match[0][1] - $this->cursor).$match[0][0]);
|
@@ -327,18 +327,18 @@ class Twig_SupTwg_Lexer implements Twig_SupTwg_LexerInterface
|
|
327 |
|
328 |
protected function lexString()
|
329 |
{
|
330 |
-
if (preg_match($this->regexes['interpolation_start'], $this->code, $match,
|
331 |
$this->brackets[] = array($this->options['interpolation'][0], $this->lineno);
|
332 |
-
$this->pushToken(
|
333 |
$this->moveCursor($match[0]);
|
334 |
$this->pushState(self::STATE_INTERPOLATION);
|
335 |
-
} elseif (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match,
|
336 |
-
$this->pushToken(
|
337 |
$this->moveCursor($match[0]);
|
338 |
-
} elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match,
|
339 |
list($expect, $lineno) = array_pop($this->brackets);
|
340 |
if ($this->code[$this->cursor] != '"') {
|
341 |
-
throw new
|
342 |
}
|
343 |
|
344 |
$this->popState();
|
@@ -349,9 +349,9 @@ class Twig_SupTwg_Lexer implements Twig_SupTwg_LexerInterface
|
|
349 |
protected function lexInterpolation()
|
350 |
{
|
351 |
$bracket = end($this->brackets);
|
352 |
-
if ($this->options['interpolation'][0] === $bracket[0] && preg_match($this->regexes['interpolation_end'], $this->code, $match,
|
353 |
array_pop($this->brackets);
|
354 |
-
$this->pushToken(
|
355 |
$this->moveCursor($match[0]);
|
356 |
$this->popState();
|
357 |
} else {
|
@@ -362,11 +362,11 @@ class Twig_SupTwg_Lexer implements Twig_SupTwg_LexerInterface
|
|
362 |
protected function pushToken($type, $value = '')
|
363 |
{
|
364 |
// do not push empty text tokens
|
365 |
-
if (
|
366 |
return;
|
367 |
}
|
368 |
|
369 |
-
$this->tokens[] = new
|
370 |
}
|
371 |
|
372 |
protected function moveCursor($text)
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_SupTwgSgg_Lexer implements Twig_SupTwgSgg_LexerInterface
|
19 |
{
|
20 |
protected $tokens;
|
21 |
protected $code;
|
49 |
const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As';
|
50 |
const PUNCTUATION = '()[]{}?:.,|';
|
51 |
|
52 |
+
public function __construct(Twig_SupTwgSgg_Environment $env, array $options = array())
|
53 |
{
|
54 |
$this->env = $env;
|
55 |
|
77 |
|
78 |
public function tokenize($code, $name = null)
|
79 |
{
|
80 |
+
if (!$code instanceof Twig_SupTwgSgg_Source) {
|
81 |
+
//@trigger_error(sprintf('Passing a string as the $code argument of %s() is deprecated since version 1.27 and will be removed in 2.0. Pass a Twig_SupTwgSgg_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
82 |
+
$this->source = new Twig_SupTwgSgg_Source($code, $name);
|
83 |
} else {
|
84 |
$this->source = $code;
|
85 |
}
|
86 |
|
87 |
if (((int) ini_get('mbstring.func_overload')) & 2) {
|
88 |
+
//@trigger_error('Support for having "mbstring.func_overload" different from 0 is deprecated version 1.29 and will be removed in 2.0.', E_USER_DEPRECATED);
|
89 |
}
|
90 |
|
91 |
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
|
136 |
}
|
137 |
}
|
138 |
|
139 |
+
$this->pushToken(Twig_SupTwgSgg_Token::EOF_TYPE);
|
140 |
|
141 |
if (!empty($this->brackets)) {
|
142 |
list($expect, $lineno) = array_pop($this->brackets);
|
143 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->source);
|
144 |
}
|
145 |
|
146 |
if ($mbEncoding) {
|
147 |
mb_internal_encoding($mbEncoding);
|
148 |
}
|
149 |
|
150 |
+
return new Twig_SupTwgSgg_TokenStream($this->tokens, $this->source);
|
151 |
}
|
152 |
|
153 |
protected function lexData()
|
154 |
{
|
155 |
// if no matches are left we return the rest of the template as simple text token
|
156 |
if ($this->position == count($this->positions[0]) - 1) {
|
157 |
+
$this->pushToken(Twig_SupTwgSgg_Token::TEXT_TYPE, substr($this->code, $this->cursor));
|
158 |
$this->cursor = $this->end;
|
159 |
|
160 |
return;
|
174 |
if (isset($this->positions[2][$this->position][0])) {
|
175 |
$text = rtrim($text);
|
176 |
}
|
177 |
+
$this->pushToken(Twig_SupTwgSgg_Token::TEXT_TYPE, $text);
|
178 |
$this->moveCursor($textContent.$position[0]);
|
179 |
|
180 |
switch ($this->positions[1][$this->position][0]) {
|
184 |
|
185 |
case $this->options['tag_block'][0]:
|
186 |
// raw data?
|
187 |
+
if (preg_match($this->regexes['lex_block_raw'], $this->code, $match, 0, $this->cursor)) {
|
188 |
$this->moveCursor($match[0]);
|
189 |
$this->lexRawData($match[1]);
|
190 |
// {% line \d+ %}
|
191 |
+
} elseif (preg_match($this->regexes['lex_block_line'], $this->code, $match, 0, $this->cursor)) {
|
192 |
$this->moveCursor($match[0]);
|
193 |
$this->lineno = (int) $match[1];
|
194 |
} else {
|
195 |
+
$this->pushToken(Twig_SupTwgSgg_Token::BLOCK_START_TYPE);
|
196 |
$this->pushState(self::STATE_BLOCK);
|
197 |
$this->currentVarBlockLine = $this->lineno;
|
198 |
}
|
199 |
break;
|
200 |
|
201 |
case $this->options['tag_variable'][0]:
|
202 |
+
$this->pushToken(Twig_SupTwgSgg_Token::VAR_START_TYPE);
|
203 |
$this->pushState(self::STATE_VAR);
|
204 |
$this->currentVarBlockLine = $this->lineno;
|
205 |
break;
|
208 |
|
209 |
protected function lexBlock()
|
210 |
{
|
211 |
+
if (empty($this->brackets) && preg_match($this->regexes['lex_block'], $this->code, $match, 0, $this->cursor)) {
|
212 |
+
$this->pushToken(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
213 |
$this->moveCursor($match[0]);
|
214 |
$this->popState();
|
215 |
} else {
|
219 |
|
220 |
protected function lexVar()
|
221 |
{
|
222 |
+
if (empty($this->brackets) && preg_match($this->regexes['lex_var'], $this->code, $match, 0, $this->cursor)) {
|
223 |
+
$this->pushToken(Twig_SupTwgSgg_Token::VAR_END_TYPE);
|
224 |
$this->moveCursor($match[0]);
|
225 |
$this->popState();
|
226 |
} else {
|
231 |
protected function lexExpression()
|
232 |
{
|
233 |
// whitespace
|
234 |
+
if (preg_match('/\s+/A', $this->code, $match, 0, $this->cursor)) {
|
235 |
$this->moveCursor($match[0]);
|
236 |
|
237 |
if ($this->cursor >= $this->end) {
|
238 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('Unclosed "%s".', $this->state === self::STATE_BLOCK ? 'block' : 'variable'), $this->currentVarBlockLine, $this->source);
|
239 |
}
|
240 |
}
|
241 |
|
242 |
// operators
|
243 |
+
if (preg_match($this->regexes['operator'], $this->code, $match, 0, $this->cursor)) {
|
244 |
+
$this->pushToken(Twig_SupTwgSgg_Token::OPERATOR_TYPE, preg_replace('/\s+/', ' ', $match[0]));
|
245 |
$this->moveCursor($match[0]);
|
246 |
}
|
247 |
// names
|
248 |
+
elseif (preg_match(self::REGEX_NAME, $this->code, $match, 0, $this->cursor)) {
|
249 |
+
$this->pushToken(Twig_SupTwgSgg_Token::NAME_TYPE, $match[0]);
|
250 |
$this->moveCursor($match[0]);
|
251 |
}
|
252 |
// numbers
|
253 |
+
elseif (preg_match(self::REGEX_NUMBER, $this->code, $match, 0, $this->cursor)) {
|
254 |
$number = (float) $match[0]; // floats
|
255 |
if (ctype_digit($match[0]) && $number <= PHP_INT_MAX) {
|
256 |
$number = (int) $match[0]; // integers lower than the maximum
|
257 |
}
|
258 |
+
$this->pushToken(Twig_SupTwgSgg_Token::NUMBER_TYPE, $number);
|
259 |
$this->moveCursor($match[0]);
|
260 |
}
|
261 |
// punctuation
|
267 |
// closing bracket
|
268 |
elseif (false !== strpos(')]}', $this->code[$this->cursor])) {
|
269 |
if (empty($this->brackets)) {
|
270 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('Unexpected "%s".', $this->code[$this->cursor]), $this->lineno, $this->source);
|
271 |
}
|
272 |
|
273 |
list($expect, $lineno) = array_pop($this->brackets);
|
274 |
if ($this->code[$this->cursor] != strtr($expect, '([{', ')]}')) {
|
275 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->source);
|
276 |
}
|
277 |
}
|
278 |
|
279 |
+
$this->pushToken(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, $this->code[$this->cursor]);
|
280 |
++$this->cursor;
|
281 |
}
|
282 |
// strings
|
283 |
+
elseif (preg_match(self::REGEX_STRING, $this->code, $match, 0, $this->cursor)) {
|
284 |
+
$this->pushToken(Twig_SupTwgSgg_Token::STRING_TYPE, stripcslashes(substr($match[0], 1, -1)));
|
285 |
$this->moveCursor($match[0]);
|
286 |
}
|
287 |
// opening double quoted string
|
288 |
+
elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, 0, $this->cursor)) {
|
289 |
$this->brackets[] = array('"', $this->lineno);
|
290 |
$this->pushState(self::STATE_STRING);
|
291 |
$this->moveCursor($match[0]);
|
292 |
}
|
293 |
// unlexable
|
294 |
else {
|
295 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('Unexpected character "%s".', $this->code[$this->cursor]), $this->lineno, $this->source);
|
296 |
}
|
297 |
}
|
298 |
|
299 |
protected function lexRawData($tag)
|
300 |
{
|
301 |
if ('raw' === $tag) {
|
302 |
+
//@trigger_error(sprintf('Twig Tag "raw" is deprecated since version 1.21. Use "verbatim" instead in %s at line %d.', $this->filename, $this->lineno), E_USER_DEPRECATED);
|
303 |
}
|
304 |
|
305 |
if (!preg_match(str_replace('%s', $tag, $this->regexes['lex_raw_data']), $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
|
306 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('Unexpected end of file: Unclosed "%s" block.', $tag), $this->lineno, $this->source);
|
307 |
}
|
308 |
|
309 |
$text = substr($this->code, $this->cursor, $match[0][1] - $this->cursor);
|
313 |
$text = rtrim($text);
|
314 |
}
|
315 |
|
316 |
+
$this->pushToken(Twig_SupTwgSgg_Token::TEXT_TYPE, $text);
|
317 |
}
|
318 |
|
319 |
protected function lexComment()
|
320 |
{
|
321 |
if (!preg_match($this->regexes['lex_comment'], $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
|
322 |
+
throw new Twig_SupTwgSgg_Error_Syntax('Unclosed comment.', $this->lineno, $this->source);
|
323 |
}
|
324 |
|
325 |
$this->moveCursor(substr($this->code, $this->cursor, $match[0][1] - $this->cursor).$match[0][0]);
|
327 |
|
328 |
protected function lexString()
|
329 |
{
|
330 |
+
if (preg_match($this->regexes['interpolation_start'], $this->code, $match, 0, $this->cursor)) {
|
331 |
$this->brackets[] = array($this->options['interpolation'][0], $this->lineno);
|
332 |
+
$this->pushToken(Twig_SupTwgSgg_Token::INTERPOLATION_START_TYPE);
|
333 |
$this->moveCursor($match[0]);
|
334 |
$this->pushState(self::STATE_INTERPOLATION);
|
335 |
+
} elseif (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match, 0, $this->cursor) && strlen($match[0]) > 0) {
|
336 |
+
$this->pushToken(Twig_SupTwgSgg_Token::STRING_TYPE, stripcslashes($match[0]));
|
337 |
$this->moveCursor($match[0]);
|
338 |
+
} elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, 0, $this->cursor)) {
|
339 |
list($expect, $lineno) = array_pop($this->brackets);
|
340 |
if ($this->code[$this->cursor] != '"') {
|
341 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->source);
|
342 |
}
|
343 |
|
344 |
$this->popState();
|
349 |
protected function lexInterpolation()
|
350 |
{
|
351 |
$bracket = end($this->brackets);
|
352 |
+
if ($this->options['interpolation'][0] === $bracket[0] && preg_match($this->regexes['interpolation_end'], $this->code, $match, 0, $this->cursor)) {
|
353 |
array_pop($this->brackets);
|
354 |
+
$this->pushToken(Twig_SupTwgSgg_Token::INTERPOLATION_END_TYPE);
|
355 |
$this->moveCursor($match[0]);
|
356 |
$this->popState();
|
357 |
} else {
|
362 |
protected function pushToken($type, $value = '')
|
363 |
{
|
364 |
// do not push empty text tokens
|
365 |
+
if (Twig_SupTwgSgg_Token::TEXT_TYPE === $type && '' === $value) {
|
366 |
return;
|
367 |
}
|
368 |
|
369 |
+
$this->tokens[] = new Twig_SupTwgSgg_Token($type, $value, $this->lineno);
|
370 |
}
|
371 |
|
372 |
protected function moveCursor($text)
|
vendor/Twig/LexerInterface.php
CHANGED
@@ -16,17 +16,17 @@
|
|
16 |
*
|
17 |
* @deprecated since 1.12 (to be removed in 3.0)
|
18 |
*/
|
19 |
-
interface
|
20 |
{
|
21 |
/**
|
22 |
* Tokenizes a source code.
|
23 |
*
|
24 |
-
* @param string|
|
25 |
* @param string $name A unique identifier for the source code
|
26 |
*
|
27 |
-
* @return
|
28 |
*
|
29 |
-
* @throws
|
30 |
*/
|
31 |
public function tokenize($code, $name = null);
|
32 |
}
|
16 |
*
|
17 |
* @deprecated since 1.12 (to be removed in 3.0)
|
18 |
*/
|
19 |
+
interface Twig_SupTwgSgg_LexerInterface
|
20 |
{
|
21 |
/**
|
22 |
* Tokenizes a source code.
|
23 |
*
|
24 |
+
* @param string|Twig_SupTwgSgg_Source $code The source code
|
25 |
* @param string $name A unique identifier for the source code
|
26 |
*
|
27 |
+
* @return Twig_SupTwgSgg_TokenStream
|
28 |
*
|
29 |
+
* @throws Twig_SupTwgSgg_Error_Syntax When the code is syntactically wrong
|
30 |
*/
|
31 |
public function tokenize($code, $name = null);
|
32 |
}
|
vendor/Twig/Loader/Array.php
CHANGED
@@ -23,7 +23,7 @@
|
|
23 |
*
|
24 |
* @author Fabien Potencier <fabien@symfony.com>
|
25 |
*/
|
26 |
-
class
|
27 |
{
|
28 |
protected $templates = array();
|
29 |
|
@@ -48,11 +48,11 @@ class Twig_SupTwg_Loader_Array implements Twig_SupTwg_LoaderInterface, Twig_SupT
|
|
48 |
|
49 |
public function getSource($name)
|
50 |
{
|
51 |
-
|
52 |
|
53 |
$name = (string) $name;
|
54 |
if (!isset($this->templates[$name])) {
|
55 |
-
throw new
|
56 |
}
|
57 |
|
58 |
return $this->templates[$name];
|
@@ -62,10 +62,10 @@ class Twig_SupTwg_Loader_Array implements Twig_SupTwg_LoaderInterface, Twig_SupT
|
|
62 |
{
|
63 |
$name = (string) $name;
|
64 |
if (!isset($this->templates[$name])) {
|
65 |
-
throw new
|
66 |
}
|
67 |
|
68 |
-
return new
|
69 |
}
|
70 |
|
71 |
public function exists($name)
|
@@ -77,7 +77,7 @@ class Twig_SupTwg_Loader_Array implements Twig_SupTwg_LoaderInterface, Twig_SupT
|
|
77 |
{
|
78 |
$name = (string) $name;
|
79 |
if (!isset($this->templates[$name])) {
|
80 |
-
throw new
|
81 |
}
|
82 |
|
83 |
return $name.':'.$this->templates[$name];
|
@@ -87,7 +87,7 @@ class Twig_SupTwg_Loader_Array implements Twig_SupTwg_LoaderInterface, Twig_SupT
|
|
87 |
{
|
88 |
$name = (string) $name;
|
89 |
if (!isset($this->templates[$name])) {
|
90 |
-
throw new
|
91 |
}
|
92 |
|
93 |
return true;
|
23 |
*
|
24 |
* @author Fabien Potencier <fabien@symfony.com>
|
25 |
*/
|
26 |
+
class Twig_SupTwgSgg_Loader_Array implements Twig_SupTwgSgg_LoaderInterface, Twig_SupTwgSgg_ExistsLoaderInterface, Twig_SupTwgSgg_SourceContextLoaderInterface
|
27 |
{
|
28 |
protected $templates = array();
|
29 |
|
48 |
|
49 |
public function getSource($name)
|
50 |
{
|
51 |
+
//@trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED);
|
52 |
|
53 |
$name = (string) $name;
|
54 |
if (!isset($this->templates[$name])) {
|
55 |
+
throw new Twig_SupTwgSgg_Error_Loader(sprintf('Template "%s" is not defined.', $name));
|
56 |
}
|
57 |
|
58 |
return $this->templates[$name];
|
62 |
{
|
63 |
$name = (string) $name;
|
64 |
if (!isset($this->templates[$name])) {
|
65 |
+
throw new Twig_SupTwgSgg_Error_Loader(sprintf('Template "%s" is not defined.', $name));
|
66 |
}
|
67 |
|
68 |
+
return new Twig_SupTwgSgg_Source($this->templates[$name], $name);
|
69 |
}
|
70 |
|
71 |
public function exists($name)
|
77 |
{
|
78 |
$name = (string) $name;
|
79 |
if (!isset($this->templates[$name])) {
|
80 |
+
throw new Twig_SupTwgSgg_Error_Loader(sprintf('Template "%s" is not defined.', $name));
|
81 |
}
|
82 |
|
83 |
return $name.':'.$this->templates[$name];
|
87 |
{
|
88 |
$name = (string) $name;
|
89 |
if (!isset($this->templates[$name])) {
|
90 |
+
throw new Twig_SupTwgSgg_Error_Loader(sprintf('Template "%s" is not defined.', $name));
|
91 |
}
|
92 |
|
93 |
return true;
|
vendor/Twig/Loader/Chain.php
CHANGED
@@ -16,13 +16,13 @@
|
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
-
class
|
20 |
{
|
21 |
private $hasSourceCache = array();
|
22 |
protected $loaders = array();
|
23 |
|
24 |
/**
|
25 |
-
* @param
|
26 |
*/
|
27 |
public function __construct(array $loaders = array())
|
28 |
{
|
@@ -31,7 +31,7 @@ class Twig_SupTwg_Loader_Chain implements Twig_SupTwg_LoaderInterface, Twig_SupT
|
|
31 |
}
|
32 |
}
|
33 |
|
34 |
-
public function addLoader(
|
35 |
{
|
36 |
$this->loaders[] = $loader;
|
37 |
$this->hasSourceCache = array();
|
@@ -39,44 +39,44 @@ class Twig_SupTwg_Loader_Chain implements Twig_SupTwg_LoaderInterface, Twig_SupT
|
|
39 |
|
40 |
public function getSource($name)
|
41 |
{
|
42 |
-
|
43 |
|
44 |
$exceptions = array();
|
45 |
foreach ($this->loaders as $loader) {
|
46 |
-
if ($loader instanceof
|
47 |
continue;
|
48 |
}
|
49 |
|
50 |
try {
|
51 |
return $loader->getSource($name);
|
52 |
-
} catch (
|
53 |
$exceptions[] = $e->getMessage();
|
54 |
}
|
55 |
}
|
56 |
|
57 |
-
throw new
|
58 |
}
|
59 |
|
60 |
public function getSourceContext($name)
|
61 |
{
|
62 |
$exceptions = array();
|
63 |
foreach ($this->loaders as $loader) {
|
64 |
-
if ($loader instanceof
|
65 |
continue;
|
66 |
}
|
67 |
|
68 |
try {
|
69 |
-
if ($loader instanceof
|
70 |
return $loader->getSourceContext($name);
|
71 |
}
|
72 |
|
73 |
-
return new
|
74 |
-
} catch (
|
75 |
$exceptions[] = $e->getMessage();
|
76 |
}
|
77 |
}
|
78 |
|
79 |
-
throw new
|
80 |
}
|
81 |
|
82 |
public function exists($name)
|
@@ -88,7 +88,7 @@ class Twig_SupTwg_Loader_Chain implements Twig_SupTwg_LoaderInterface, Twig_SupT
|
|
88 |
}
|
89 |
|
90 |
foreach ($this->loaders as $loader) {
|
91 |
-
if ($loader instanceof
|
92 |
if ($loader->exists($name)) {
|
93 |
return $this->hasSourceCache[$name] = true;
|
94 |
}
|
@@ -97,14 +97,14 @@ class Twig_SupTwg_Loader_Chain implements Twig_SupTwg_LoaderInterface, Twig_SupT
|
|
97 |
}
|
98 |
|
99 |
try {
|
100 |
-
if ($loader instanceof
|
101 |
$loader->getSourceContext($name);
|
102 |
} else {
|
103 |
$loader->getSource($name);
|
104 |
}
|
105 |
|
106 |
return $this->hasSourceCache[$name] = true;
|
107 |
-
} catch (
|
108 |
}
|
109 |
}
|
110 |
|
@@ -115,35 +115,35 @@ class Twig_SupTwg_Loader_Chain implements Twig_SupTwg_LoaderInterface, Twig_SupT
|
|
115 |
{
|
116 |
$exceptions = array();
|
117 |
foreach ($this->loaders as $loader) {
|
118 |
-
if ($loader instanceof
|
119 |
continue;
|
120 |
}
|
121 |
|
122 |
try {
|
123 |
return $loader->getCacheKey($name);
|
124 |
-
} catch (
|
125 |
$exceptions[] = get_class($loader).': '.$e->getMessage();
|
126 |
}
|
127 |
}
|
128 |
|
129 |
-
throw new
|
130 |
}
|
131 |
|
132 |
public function isFresh($name, $time)
|
133 |
{
|
134 |
$exceptions = array();
|
135 |
foreach ($this->loaders as $loader) {
|
136 |
-
if ($loader instanceof
|
137 |
continue;
|
138 |
}
|
139 |
|
140 |
try {
|
141 |
return $loader->isFresh($name, $time);
|
142 |
-
} catch (
|
143 |
$exceptions[] = get_class($loader).': '.$e->getMessage();
|
144 |
}
|
145 |
}
|
146 |
|
147 |
-
throw new
|
148 |
}
|
149 |
}
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class Twig_SupTwgSgg_Loader_Chain implements Twig_SupTwgSgg_LoaderInterface, Twig_SupTwgSgg_ExistsLoaderInterface, Twig_SupTwgSgg_SourceContextLoaderInterface
|
20 |
{
|
21 |
private $hasSourceCache = array();
|
22 |
protected $loaders = array();
|
23 |
|
24 |
/**
|
25 |
+
* @param Twig_SupTwgSgg_LoaderInterface[] $loaders
|
26 |
*/
|
27 |
public function __construct(array $loaders = array())
|
28 |
{
|
31 |
}
|
32 |
}
|
33 |
|
34 |
+
public function addLoader(Twig_SupTwgSgg_LoaderInterface $loader)
|
35 |
{
|
36 |
$this->loaders[] = $loader;
|
37 |
$this->hasSourceCache = array();
|
39 |
|
40 |
public function getSource($name)
|
41 |
{
|
42 |
+
//@trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED);
|
43 |
|
44 |
$exceptions = array();
|
45 |
foreach ($this->loaders as $loader) {
|
46 |
+
if ($loader instanceof Twig_SupTwgSgg_ExistsLoaderInterface && !$loader->exists($name)) {
|
47 |
continue;
|
48 |
}
|
49 |
|
50 |
try {
|
51 |
return $loader->getSource($name);
|
52 |
+
} catch (Twig_SupTwgSgg_Error_Loader $e) {
|
53 |
$exceptions[] = $e->getMessage();
|
54 |
}
|
55 |
}
|
56 |
|
57 |
+
throw new Twig_SupTwgSgg_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
|
58 |
}
|
59 |
|
60 |
public function getSourceContext($name)
|
61 |
{
|
62 |
$exceptions = array();
|
63 |
foreach ($this->loaders as $loader) {
|
64 |
+
if ($loader instanceof Twig_SupTwgSgg_ExistsLoaderInterface && !$loader->exists($name)) {
|
65 |
continue;
|
66 |
}
|
67 |
|
68 |
try {
|
69 |
+
if ($loader instanceof Twig_SupTwgSgg_SourceContextLoaderInterface) {
|
70 |
return $loader->getSourceContext($name);
|
71 |
}
|
72 |
|
73 |
+
return new Twig_SupTwgSgg_Source($loader->getSource($name), $name);
|
74 |
+
} catch (Twig_SupTwgSgg_Error_Loader $e) {
|
75 |
$exceptions[] = $e->getMessage();
|
76 |
}
|
77 |
}
|
78 |
|
79 |
+
throw new Twig_SupTwgSgg_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
|
80 |
}
|
81 |
|
82 |
public function exists($name)
|
88 |
}
|
89 |
|
90 |
foreach ($this->loaders as $loader) {
|
91 |
+
if ($loader instanceof Twig_SupTwgSgg_ExistsLoaderInterface) {
|
92 |
if ($loader->exists($name)) {
|
93 |
return $this->hasSourceCache[$name] = true;
|
94 |
}
|
97 |
}
|
98 |
|
99 |
try {
|
100 |
+
if ($loader instanceof Twig_SupTwgSgg_SourceContextLoaderInterface) {
|
101 |
$loader->getSourceContext($name);
|
102 |
} else {
|
103 |
$loader->getSource($name);
|
104 |
}
|
105 |
|
106 |
return $this->hasSourceCache[$name] = true;
|
107 |
+
} catch (Twig_SupTwgSgg_Error_Loader $e) {
|
108 |
}
|
109 |
}
|
110 |
|
115 |
{
|
116 |
$exceptions = array();
|
117 |
foreach ($this->loaders as $loader) {
|
118 |
+
if ($loader instanceof Twig_SupTwgSgg_ExistsLoaderInterface && !$loader->exists($name)) {
|
119 |
continue;
|
120 |
}
|
121 |
|
122 |
try {
|
123 |
return $loader->getCacheKey($name);
|
124 |
+
} catch (Twig_SupTwgSgg_Error_Loader $e) {
|
125 |
$exceptions[] = get_class($loader).': '.$e->getMessage();
|
126 |
}
|
127 |
}
|
128 |
|
129 |
+
throw new Twig_SupTwgSgg_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
|
130 |
}
|
131 |
|
132 |
public function isFresh($name, $time)
|
133 |
{
|
134 |
$exceptions = array();
|
135 |
foreach ($this->loaders as $loader) {
|
136 |
+
if ($loader instanceof Twig_SupTwgSgg_ExistsLoaderInterface && !$loader->exists($name)) {
|
137 |
continue;
|
138 |
}
|
139 |
|
140 |
try {
|
141 |
return $loader->isFresh($name, $time);
|
142 |
+
} catch (Twig_SupTwgSgg_Error_Loader $e) {
|
143 |
$exceptions[] = get_class($loader).': '.$e->getMessage();
|
144 |
}
|
145 |
}
|
146 |
|
147 |
+
throw new Twig_SupTwgSgg_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
|
148 |
}
|
149 |
}
|
vendor/Twig/Loader/Filesystem.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
/** Identifier of the main namespace. */
|
20 |
const MAIN_NAMESPACE = '__main__';
|
@@ -29,9 +29,9 @@ class Twig_SupTwg_Loader_Filesystem implements Twig_SupTwg_LoaderInterface, Twig
|
|
29 |
* @param string|array $paths A path or an array of paths where to look for templates
|
30 |
* @param string|null $rootPath The root path common to all relative paths (null for getcwd())
|
31 |
*/
|
32 |
-
public function __construct($paths = array(), $rootPath =
|
33 |
{
|
34 |
-
$this->rootPath = (
|
35 |
if (false !== $realPath = realpath($rootPath)) {
|
36 |
$this->rootPath = $realPath.DIRECTORY_SEPARATOR;
|
37 |
}
|
@@ -89,7 +89,7 @@ class Twig_SupTwg_Loader_Filesystem implements Twig_SupTwg_LoaderInterface, Twig
|
|
89 |
* @param string $path A path where to look for templates
|
90 |
* @param string $namespace A path namespace
|
91 |
*
|
92 |
-
* @throws
|
93 |
*/
|
94 |
public function addPath($path, $namespace = self::MAIN_NAMESPACE)
|
95 |
{
|
@@ -98,7 +98,7 @@ class Twig_SupTwg_Loader_Filesystem implements Twig_SupTwg_LoaderInterface, Twig
|
|
98 |
|
99 |
$checkPath = $this->isAbsolutePath($path) ? $path : $this->rootPath.$path;
|
100 |
if (!is_dir($checkPath)) {
|
101 |
-
throw new
|
102 |
}
|
103 |
|
104 |
$this->paths[$namespace][] = rtrim($path, '/\\');
|
@@ -110,7 +110,7 @@ class Twig_SupTwg_Loader_Filesystem implements Twig_SupTwg_LoaderInterface, Twig
|
|
110 |
* @param string $path A path where to look for templates
|
111 |
* @param string $namespace A path namespace
|
112 |
*
|
113 |
-
* @throws
|
114 |
*/
|
115 |
public function prependPath($path, $namespace = self::MAIN_NAMESPACE)
|
116 |
{
|
@@ -119,7 +119,7 @@ class Twig_SupTwg_Loader_Filesystem implements Twig_SupTwg_LoaderInterface, Twig
|
|
119 |
|
120 |
$checkPath = $this->isAbsolutePath($path) ? $path : $this->rootPath.$path;
|
121 |
if (!is_dir($checkPath)) {
|
122 |
-
throw new
|
123 |
}
|
124 |
|
125 |
$path = rtrim($path, '/\\');
|
@@ -133,7 +133,7 @@ class Twig_SupTwg_Loader_Filesystem implements Twig_SupTwg_LoaderInterface, Twig
|
|
133 |
|
134 |
public function getSource($name)
|
135 |
{
|
136 |
-
|
137 |
|
138 |
return file_get_contents($this->findTemplate($name));
|
139 |
}
|
@@ -142,7 +142,7 @@ class Twig_SupTwg_Loader_Filesystem implements Twig_SupTwg_LoaderInterface, Twig
|
|
142 |
{
|
143 |
$path = $this->findTemplate($name);
|
144 |
|
145 |
-
return new
|
146 |
}
|
147 |
|
148 |
public function getCacheKey($name)
|
@@ -166,8 +166,8 @@ class Twig_SupTwg_Loader_Filesystem implements Twig_SupTwg_LoaderInterface, Twig
|
|
166 |
|
167 |
try {
|
168 |
return false !== $this->findTemplate($name, false);
|
169 |
-
} catch (
|
170 |
-
|
171 |
|
172 |
return false;
|
173 |
}
|
@@ -192,7 +192,7 @@ class Twig_SupTwg_Loader_Filesystem implements Twig_SupTwg_LoaderInterface, Twig
|
|
192 |
return false;
|
193 |
}
|
194 |
|
195 |
-
throw new
|
196 |
}
|
197 |
|
198 |
$this->validateName($name);
|
@@ -206,7 +206,7 @@ class Twig_SupTwg_Loader_Filesystem implements Twig_SupTwg_LoaderInterface, Twig
|
|
206 |
return false;
|
207 |
}
|
208 |
|
209 |
-
throw new
|
210 |
}
|
211 |
|
212 |
foreach ($this->paths[$namespace] as $path) {
|
@@ -229,14 +229,14 @@ class Twig_SupTwg_Loader_Filesystem implements Twig_SupTwg_LoaderInterface, Twig
|
|
229 |
return false;
|
230 |
}
|
231 |
|
232 |
-
throw new
|
233 |
}
|
234 |
|
235 |
protected function parseName($name, $default = self::MAIN_NAMESPACE)
|
236 |
{
|
237 |
if (isset($name[0]) && '@' == $name[0]) {
|
238 |
if (false === $pos = strpos($name, '/')) {
|
239 |
-
throw new
|
240 |
}
|
241 |
|
242 |
$namespace = substr($name, 1, $pos - 1);
|
@@ -256,7 +256,7 @@ class Twig_SupTwg_Loader_Filesystem implements Twig_SupTwg_LoaderInterface, Twig
|
|
256 |
protected function validateName($name)
|
257 |
{
|
258 |
if (false !== strpos($name, "\0")) {
|
259 |
-
throw new
|
260 |
}
|
261 |
|
262 |
$name = ltrim($name, '/');
|
@@ -270,7 +270,7 @@ class Twig_SupTwg_Loader_Filesystem implements Twig_SupTwg_LoaderInterface, Twig
|
|
270 |
}
|
271 |
|
272 |
if ($level < 0) {
|
273 |
-
throw new
|
274 |
}
|
275 |
}
|
276 |
}
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Loader_Filesystem implements Twig_SupTwgSgg_LoaderInterface, Twig_SupTwgSgg_ExistsLoaderInterface, Twig_SupTwgSgg_SourceContextLoaderInterface
|
18 |
{
|
19 |
/** Identifier of the main namespace. */
|
20 |
const MAIN_NAMESPACE = '__main__';
|
29 |
* @param string|array $paths A path or an array of paths where to look for templates
|
30 |
* @param string|null $rootPath The root path common to all relative paths (null for getcwd())
|
31 |
*/
|
32 |
+
public function __construct($paths = array(), $rootPath = '')
|
33 |
{
|
34 |
+
$this->rootPath = ('' === $rootPath ? getcwd() : $rootPath).DIRECTORY_SEPARATOR;
|
35 |
if (false !== $realPath = realpath($rootPath)) {
|
36 |
$this->rootPath = $realPath.DIRECTORY_SEPARATOR;
|
37 |
}
|
89 |
* @param string $path A path where to look for templates
|
90 |
* @param string $namespace A path namespace
|
91 |
*
|
92 |
+
* @throws Twig_SupTwgSgg_Error_Loader
|
93 |
*/
|
94 |
public function addPath($path, $namespace = self::MAIN_NAMESPACE)
|
95 |
{
|
98 |
|
99 |
$checkPath = $this->isAbsolutePath($path) ? $path : $this->rootPath.$path;
|
100 |
if (!is_dir($checkPath)) {
|
101 |
+
throw new Twig_SupTwgSgg_Error_Loader(sprintf('The "%s" directory does not exist ("%s").', $path, $checkPath));
|
102 |
}
|
103 |
|
104 |
$this->paths[$namespace][] = rtrim($path, '/\\');
|
110 |
* @param string $path A path where to look for templates
|
111 |
* @param string $namespace A path namespace
|
112 |
*
|
113 |
+
* @throws Twig_SupTwgSgg_Error_Loader
|
114 |
*/
|
115 |
public function prependPath($path, $namespace = self::MAIN_NAMESPACE)
|
116 |
{
|
119 |
|
120 |
$checkPath = $this->isAbsolutePath($path) ? $path : $this->rootPath.$path;
|
121 |
if (!is_dir($checkPath)) {
|
122 |
+
throw new Twig_SupTwgSgg_Error_Loader(sprintf('The "%s" directory does not exist ("%s").', $path, $checkPath));
|
123 |
}
|
124 |
|
125 |
$path = rtrim($path, '/\\');
|
133 |
|
134 |
public function getSource($name)
|
135 |
{
|
136 |
+
//@trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED);
|
137 |
|
138 |
return file_get_contents($this->findTemplate($name));
|
139 |
}
|
142 |
{
|
143 |
$path = $this->findTemplate($name);
|
144 |
|
145 |
+
return new Twig_SupTwgSgg_Source(file_get_contents($path), $name, $path);
|
146 |
}
|
147 |
|
148 |
public function getCacheKey($name)
|
166 |
|
167 |
try {
|
168 |
return false !== $this->findTemplate($name, false);
|
169 |
+
} catch (Twig_SupTwgSgg_Error_Loader $exception) {
|
170 |
+
//@trigger_error(sprintf('In %s::findTemplate(), you must accept a second argument that when set to "false" returns "false" instead of throwing an exception. Not supporting this argument is deprecated since version 1.27.', get_class($this)), E_USER_DEPRECATED);
|
171 |
|
172 |
return false;
|
173 |
}
|
192 |
return false;
|
193 |
}
|
194 |
|
195 |
+
throw new Twig_SupTwgSgg_Error_Loader($this->errorCache[$name]);
|
196 |
}
|
197 |
|
198 |
$this->validateName($name);
|
206 |
return false;
|
207 |
}
|
208 |
|
209 |
+
throw new Twig_SupTwgSgg_Error_Loader($this->errorCache[$name]);
|
210 |
}
|
211 |
|
212 |
foreach ($this->paths[$namespace] as $path) {
|
229 |
return false;
|
230 |
}
|
231 |
|
232 |
+
throw new Twig_SupTwgSgg_Error_Loader($this->errorCache[$name]);
|
233 |
}
|
234 |
|
235 |
protected function parseName($name, $default = self::MAIN_NAMESPACE)
|
236 |
{
|
237 |
if (isset($name[0]) && '@' == $name[0]) {
|
238 |
if (false === $pos = strpos($name, '/')) {
|
239 |
+
throw new Twig_SupTwgSgg_Error_Loader(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name));
|
240 |
}
|
241 |
|
242 |
$namespace = substr($name, 1, $pos - 1);
|
256 |
protected function validateName($name)
|
257 |
{
|
258 |
if (false !== strpos($name, "\0")) {
|
259 |
+
throw new Twig_SupTwgSgg_Error_Loader('A template name cannot contain NUL bytes.');
|
260 |
}
|
261 |
|
262 |
$name = ltrim($name, '/');
|
270 |
}
|
271 |
|
272 |
if ($level < 0) {
|
273 |
+
throw new Twig_SupTwgSgg_Error_Loader(sprintf('Looks like you try to load a template outside configured directories (%s).', $name));
|
274 |
}
|
275 |
}
|
276 |
}
|
vendor/Twig/Loader/String.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
|
14 |
/**
|
15 |
* Loads a template from a string.
|
@@ -27,18 +27,18 @@
|
|
27 |
*
|
28 |
* @author Fabien Potencier <fabien@symfony.com>
|
29 |
*/
|
30 |
-
class
|
31 |
{
|
32 |
public function getSource($name)
|
33 |
{
|
34 |
-
|
35 |
|
36 |
return $name;
|
37 |
}
|
38 |
|
39 |
public function getSourceContext($name)
|
40 |
{
|
41 |
-
return new
|
42 |
}
|
43 |
|
44 |
public function exists($name)
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
+
//@trigger_error('The Twig_SupTwgSgg_Loader_String class is deprecated since version 1.18.1 and will be removed in 2.0. Use Twig_SupTwgSgg_Loader_Array instead or Twig_SupTwgSgg_Environment::createTemplate().', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Loads a template from a string.
|
27 |
*
|
28 |
* @author Fabien Potencier <fabien@symfony.com>
|
29 |
*/
|
30 |
+
class Twig_SupTwgSgg_Loader_String implements Twig_SupTwgSgg_LoaderInterface, Twig_SupTwgSgg_ExistsLoaderInterface, Twig_SupTwgSgg_SourceContextLoaderInterface
|
31 |
{
|
32 |
public function getSource($name)
|
33 |
{
|
34 |
+
//@trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED);
|
35 |
|
36 |
return $name;
|
37 |
}
|
38 |
|
39 |
public function getSourceContext($name)
|
40 |
{
|
41 |
+
return new Twig_SupTwgSgg_Source($name, $name);
|
42 |
}
|
43 |
|
44 |
public function exists($name)
|
vendor/Twig/LoaderInterface.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
interface
|
18 |
{
|
19 |
/**
|
20 |
* Gets the source code of a template, given its name.
|
@@ -23,9 +23,9 @@ interface Twig_SupTwg_LoaderInterface
|
|
23 |
*
|
24 |
* @return string The template source code
|
25 |
*
|
26 |
-
* @throws
|
27 |
*
|
28 |
-
* @deprecated since 1.27 (to be removed in 2.0), implement
|
29 |
*/
|
30 |
public function getSource($name);
|
31 |
|
@@ -36,7 +36,7 @@ interface Twig_SupTwg_LoaderInterface
|
|
36 |
*
|
37 |
* @return string The cache key
|
38 |
*
|
39 |
-
* @throws
|
40 |
*/
|
41 |
public function getCacheKey($name);
|
42 |
|
@@ -49,7 +49,7 @@ interface Twig_SupTwg_LoaderInterface
|
|
49 |
*
|
50 |
* @return bool true if the template is fresh, false otherwise
|
51 |
*
|
52 |
-
* @throws
|
53 |
*/
|
54 |
public function isFresh($name, $time);
|
55 |
}
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
interface Twig_SupTwgSgg_LoaderInterface
|
18 |
{
|
19 |
/**
|
20 |
* Gets the source code of a template, given its name.
|
23 |
*
|
24 |
* @return string The template source code
|
25 |
*
|
26 |
+
* @throws Twig_SupTwgSgg_Error_Loader When $name is not found
|
27 |
*
|
28 |
+
* @deprecated since 1.27 (to be removed in 2.0), implement Twig_SupTwgSgg_SourceContextLoaderInterface
|
29 |
*/
|
30 |
public function getSource($name);
|
31 |
|
36 |
*
|
37 |
* @return string The cache key
|
38 |
*
|
39 |
+
* @throws Twig_SupTwgSgg_Error_Loader When $name is not found
|
40 |
*/
|
41 |
public function getCacheKey($name);
|
42 |
|
49 |
*
|
50 |
* @return bool true if the template is fresh, false otherwise
|
51 |
*
|
52 |
+
* @throws Twig_SupTwgSgg_Error_Loader When $name is not found
|
53 |
*/
|
54 |
public function isFresh($name, $time);
|
55 |
}
|
vendor/Twig/Markup.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
protected $content;
|
20 |
protected $charset;
|
@@ -29,7 +29,7 @@ class Twig_SupTwg_Markup implements Countable
|
|
29 |
{
|
30 |
return $this->content;
|
31 |
}
|
32 |
-
|
33 |
public function count()
|
34 |
{
|
35 |
return function_exists('mb_get_info') ? mb_strlen($this->content, $this->charset) : strlen($this->content);
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Markup implements Countable
|
18 |
{
|
19 |
protected $content;
|
20 |
protected $charset;
|
29 |
{
|
30 |
return $this->content;
|
31 |
}
|
32 |
+
#[\ReturnTypeWillChange]
|
33 |
public function count()
|
34 |
{
|
35 |
return function_exists('mb_get_info') ? mb_strlen($this->content, $this->charset) : strlen($this->content);
|
vendor/Twig/Node.php
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
-
class
|
19 |
{
|
20 |
protected $nodes;
|
21 |
protected $attributes;
|
@@ -38,8 +38,8 @@ class Twig_SupTwg_Node implements Twig_SupTwg_NodeInterface
|
|
38 |
public function __construct(array $nodes = array(), array $attributes = array(), $lineno = 0, $tag = null)
|
39 |
{
|
40 |
foreach ($nodes as $name => $node) {
|
41 |
-
// if (!$node instanceof
|
42 |
-
//
|
43 |
// }
|
44 |
}
|
45 |
$this->nodes = $nodes;
|
@@ -81,7 +81,7 @@ class Twig_SupTwg_Node implements Twig_SupTwg_NodeInterface
|
|
81 |
*/
|
82 |
public function toXml($asDom = false)
|
83 |
{
|
84 |
-
|
85 |
|
86 |
$dom = new DOMDocument('1.0', 'UTF-8');
|
87 |
$dom->formatOutput = true;
|
@@ -111,7 +111,7 @@ class Twig_SupTwg_Node implements Twig_SupTwg_NodeInterface
|
|
111 |
return $asDom ? $dom : $dom->saveXML();
|
112 |
}
|
113 |
|
114 |
-
public function compile(
|
115 |
{
|
116 |
foreach ($this->nodes as $node) {
|
117 |
$node->compile($compiler);
|
@@ -128,7 +128,7 @@ class Twig_SupTwg_Node implements Twig_SupTwg_NodeInterface
|
|
128 |
*/
|
129 |
public function getLine()
|
130 |
{
|
131 |
-
|
132 |
|
133 |
return $this->lineno;
|
134 |
}
|
@@ -175,14 +175,16 @@ class Twig_SupTwg_Node implements Twig_SupTwg_NodeInterface
|
|
175 |
/**
|
176 |
* @return bool
|
177 |
*/
|
|
|
178 |
public function hasNode($name)
|
179 |
{
|
180 |
return array_key_exists($name, $this->nodes);
|
181 |
}
|
182 |
|
183 |
/**
|
184 |
-
* @return
|
185 |
*/
|
|
|
186 |
public function getNode($name)
|
187 |
{
|
188 |
if (!array_key_exists($name, $this->nodes)) {
|
@@ -191,31 +193,31 @@ class Twig_SupTwg_Node implements Twig_SupTwg_NodeInterface
|
|
191 |
|
192 |
return $this->nodes[$name];
|
193 |
}
|
194 |
-
|
195 |
public function setNode($name, $node = null)
|
196 |
{
|
197 |
-
// if (!$node instanceof
|
198 |
-
//
|
199 |
// }
|
200 |
|
201 |
$this->nodes[$name] = $node;
|
202 |
}
|
203 |
-
|
204 |
public function removeNode($name)
|
205 |
{
|
206 |
unset($this->nodes[$name]);
|
207 |
}
|
208 |
-
|
209 |
public function count()
|
210 |
{
|
211 |
return count($this->nodes);
|
212 |
}
|
213 |
-
|
214 |
public function getIterator()
|
215 |
{
|
216 |
return new ArrayIterator($this->nodes);
|
217 |
}
|
218 |
-
|
219 |
public function setTemplateName($name)
|
220 |
{
|
221 |
$this->name = $name;
|
@@ -236,7 +238,7 @@ class Twig_SupTwg_Node implements Twig_SupTwg_NodeInterface
|
|
236 |
*/
|
237 |
public function setFilename($name)
|
238 |
{
|
239 |
-
|
240 |
|
241 |
$this->setTemplateName($name);
|
242 |
}
|
@@ -246,7 +248,7 @@ class Twig_SupTwg_Node implements Twig_SupTwg_NodeInterface
|
|
246 |
*/
|
247 |
public function getFilename()
|
248 |
{
|
249 |
-
|
250 |
|
251 |
return $this->name;
|
252 |
}
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_SupTwgSgg_Node implements Twig_SupTwgSgg_NodeInterface
|
19 |
{
|
20 |
protected $nodes;
|
21 |
protected $attributes;
|
38 |
public function __construct(array $nodes = array(), array $attributes = array(), $lineno = 0, $tag = null)
|
39 |
{
|
40 |
foreach ($nodes as $name => $node) {
|
41 |
+
// if (!$node instanceof Twig_SupTwgSgg_NodeInterface) {
|
42 |
+
// //@trigger_error(sprintf('Using "%s" for the value of node "%s" of "%s" is deprecated since version 1.25 and will be removed in 2.0.', is_object($node) ? get_class($node) : null === $node ? 'null' : gettype($node), $name, get_class($this)), E_USER_DEPRECATED);
|
43 |
// }
|
44 |
}
|
45 |
$this->nodes = $nodes;
|
81 |
*/
|
82 |
public function toXml($asDom = false)
|
83 |
{
|
84 |
+
//@trigger_error(sprintf('%s is deprecated since version 1.16.1 and will be removed in 2.0.', __METHOD__), E_USER_DEPRECATED);
|
85 |
|
86 |
$dom = new DOMDocument('1.0', 'UTF-8');
|
87 |
$dom->formatOutput = true;
|
111 |
return $asDom ? $dom : $dom->saveXML();
|
112 |
}
|
113 |
|
114 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
115 |
{
|
116 |
foreach ($this->nodes as $node) {
|
117 |
$node->compile($compiler);
|
128 |
*/
|
129 |
public function getLine()
|
130 |
{
|
131 |
+
//@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getTemplateLine() instead.', E_USER_DEPRECATED);
|
132 |
|
133 |
return $this->lineno;
|
134 |
}
|
175 |
/**
|
176 |
* @return bool
|
177 |
*/
|
178 |
+
#[\ReturnTypeWillChange]
|
179 |
public function hasNode($name)
|
180 |
{
|
181 |
return array_key_exists($name, $this->nodes);
|
182 |
}
|
183 |
|
184 |
/**
|
185 |
+
* @return Twig_SupTwgSgg_Node
|
186 |
*/
|
187 |
+
#[\ReturnTypeWillChange]
|
188 |
public function getNode($name)
|
189 |
{
|
190 |
if (!array_key_exists($name, $this->nodes)) {
|
193 |
|
194 |
return $this->nodes[$name];
|
195 |
}
|
196 |
+
#[\ReturnTypeWillChange]
|
197 |
public function setNode($name, $node = null)
|
198 |
{
|
199 |
+
// if (!$node instanceof Twig_SupTwgSgg_NodeInterface) {
|
200 |
+
// //@trigger_error(sprintf('Using "%s" for the value of node "%s" of "%s" is deprecated since version 1.25 and will be removed in 2.0.', is_object($node) ? get_class($node) : null === $node ? 'null' : gettype($node), $name, get_class($this)), E_USER_DEPRECATED);
|
201 |
// }
|
202 |
|
203 |
$this->nodes[$name] = $node;
|
204 |
}
|
205 |
+
#[\ReturnTypeWillChange]
|
206 |
public function removeNode($name)
|
207 |
{
|
208 |
unset($this->nodes[$name]);
|
209 |
}
|
210 |
+
#[\ReturnTypeWillChange]
|
211 |
public function count()
|
212 |
{
|
213 |
return count($this->nodes);
|
214 |
}
|
215 |
+
#[\ReturnTypeWillChange]
|
216 |
public function getIterator()
|
217 |
{
|
218 |
return new ArrayIterator($this->nodes);
|
219 |
}
|
220 |
+
#[\ReturnTypeWillChange]
|
221 |
public function setTemplateName($name)
|
222 |
{
|
223 |
$this->name = $name;
|
238 |
*/
|
239 |
public function setFilename($name)
|
240 |
{
|
241 |
+
//@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use setTemplateName() instead.', E_USER_DEPRECATED);
|
242 |
|
243 |
$this->setTemplateName($name);
|
244 |
}
|
248 |
*/
|
249 |
public function getFilename()
|
250 |
{
|
251 |
+
//@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getTemplateName() instead.', E_USER_DEPRECATED);
|
252 |
|
253 |
return $this->name;
|
254 |
}
|
vendor/Twig/Node/AutoEscape.php
CHANGED
@@ -20,14 +20,14 @@
|
|
20 |
*
|
21 |
* @author Fabien Potencier <fabien@symfony.com>
|
22 |
*/
|
23 |
-
class
|
24 |
{
|
25 |
-
public function __construct($value,
|
26 |
{
|
27 |
parent::__construct(array('body' => $body), array('value' => $value), $lineno, $tag);
|
28 |
}
|
29 |
|
30 |
-
public function compile(
|
31 |
{
|
32 |
$compiler->subcompile($this->getNode('body'));
|
33 |
}
|
20 |
*
|
21 |
* @author Fabien Potencier <fabien@symfony.com>
|
22 |
*/
|
23 |
+
class Twig_SupTwgSgg_Node_AutoEscape extends Twig_SupTwgSgg_Node
|
24 |
{
|
25 |
+
public function __construct($value, Twig_SupTwgSgg_NodeInterface $body, $lineno, $tag = 'autoescape')
|
26 |
{
|
27 |
parent::__construct(array('body' => $body), array('value' => $value), $lineno, $tag);
|
28 |
}
|
29 |
|
30 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
31 |
{
|
32 |
$compiler->subcompile($this->getNode('body'));
|
33 |
}
|
vendor/Twig/Node/Block.php
CHANGED
@@ -15,14 +15,14 @@
|
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
-
class
|
19 |
{
|
20 |
-
public function __construct($name,
|
21 |
{
|
22 |
parent::__construct(array('body' => $body), array('name' => $name), $lineno, $tag);
|
23 |
}
|
24 |
|
25 |
-
public function compile(
|
26 |
{
|
27 |
$compiler
|
28 |
->addDebugInfo($this)
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_SupTwgSgg_Node_Block extends Twig_SupTwgSgg_Node
|
19 |
{
|
20 |
+
public function __construct($name, Twig_SupTwgSgg_NodeInterface $body, $lineno, $tag = null)
|
21 |
{
|
22 |
parent::__construct(array('body' => $body), array('name' => $name), $lineno, $tag);
|
23 |
}
|
24 |
|
25 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
26 |
{
|
27 |
$compiler
|
28 |
->addDebugInfo($this)
|
vendor/Twig/Node/BlockReference.php
CHANGED
@@ -15,14 +15,14 @@
|
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
-
class
|
19 |
{
|
20 |
public function __construct($name, $lineno, $tag = null)
|
21 |
{
|
22 |
parent::__construct(array(), array('name' => $name), $lineno, $tag);
|
23 |
}
|
24 |
|
25 |
-
public function compile(
|
26 |
{
|
27 |
$compiler
|
28 |
->addDebugInfo($this)
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_SupTwgSgg_Node_BlockReference extends Twig_SupTwgSgg_Node implements Twig_SupTwgSgg_NodeOutputInterface
|
19 |
{
|
20 |
public function __construct($name, $lineno, $tag = null)
|
21 |
{
|
22 |
parent::__construct(array(), array('name' => $name), $lineno, $tag);
|
23 |
}
|
24 |
|
25 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
26 |
{
|
27 |
$compiler
|
28 |
->addDebugInfo($this)
|
vendor/Twig/Node/Body.php
CHANGED
@@ -14,6 +14,6 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
}
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Node_Body extends Twig_SupTwgSgg_Node
|
18 |
{
|
19 |
}
|
vendor/Twig/Node/CheckSecurity.php
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
14 |
*/
|
15 |
-
class
|
16 |
{
|
17 |
protected $usedFilters;
|
18 |
protected $usedTags;
|
@@ -27,12 +27,12 @@ class Twig_SupTwg_Node_CheckSecurity extends Twig_SupTwg_Node
|
|
27 |
parent::__construct();
|
28 |
}
|
29 |
|
30 |
-
public function compile(
|
31 |
{
|
32 |
$tags = $filters = $functions = array();
|
33 |
foreach (array('tags', 'filters', 'functions') as $type) {
|
34 |
foreach ($this->{'used'.ucfirst($type)} as $name => $node) {
|
35 |
-
if ($node instanceof
|
36 |
${$type}[$name] = $node->getTemplateLine();
|
37 |
} else {
|
38 |
${$type}[$node] = null;
|
@@ -46,7 +46,7 @@ class Twig_SupTwg_Node_CheckSecurity extends Twig_SupTwg_Node
|
|
46 |
->write('$functions = ')->repr(array_filter($functions))->raw(";\n\n")
|
47 |
->write("try {\n")
|
48 |
->indent()
|
49 |
-
->write("\$this->env->getExtension('
|
50 |
->indent()
|
51 |
->write(!$tags ? "array(),\n" : "array('".implode("', '", array_keys($tags))."'),\n")
|
52 |
->write(!$filters ? "array(),\n" : "array('".implode("', '", array_keys($filters))."'),\n")
|
@@ -54,18 +54,18 @@ class Twig_SupTwg_Node_CheckSecurity extends Twig_SupTwg_Node
|
|
54 |
->outdent()
|
55 |
->write(");\n")
|
56 |
->outdent()
|
57 |
-
->write("} catch (
|
58 |
->indent()
|
59 |
->write("\$e->setSourceContext(\$this->getSourceContext());\n\n")
|
60 |
-
->write("if (\$e instanceof
|
61 |
->indent()
|
62 |
->write("\$e->setTemplateLine(\$tags[\$e->getTagName()]);\n")
|
63 |
->outdent()
|
64 |
-
->write("} elseif (\$e instanceof
|
65 |
->indent()
|
66 |
->write("\$e->setTemplateLine(\$filters[\$e->getFilterName()]);\n")
|
67 |
->outdent()
|
68 |
-
->write("} elseif (\$e instanceof
|
69 |
->indent()
|
70 |
->write("\$e->setTemplateLine(\$functions[\$e->getFunctionName()]);\n")
|
71 |
->outdent()
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
14 |
*/
|
15 |
+
class Twig_SupTwgSgg_Node_CheckSecurity extends Twig_SupTwgSgg_Node
|
16 |
{
|
17 |
protected $usedFilters;
|
18 |
protected $usedTags;
|
27 |
parent::__construct();
|
28 |
}
|
29 |
|
30 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
31 |
{
|
32 |
$tags = $filters = $functions = array();
|
33 |
foreach (array('tags', 'filters', 'functions') as $type) {
|
34 |
foreach ($this->{'used'.ucfirst($type)} as $name => $node) {
|
35 |
+
if ($node instanceof Twig_SupTwgSgg_Node) {
|
36 |
${$type}[$name] = $node->getTemplateLine();
|
37 |
} else {
|
38 |
${$type}[$node] = null;
|
46 |
->write('$functions = ')->repr(array_filter($functions))->raw(";\n\n")
|
47 |
->write("try {\n")
|
48 |
->indent()
|
49 |
+
->write("\$this->env->getExtension('Twig_SupTwgSgg_Extension_Sandbox')->checkSecurity(\n")
|
50 |
->indent()
|
51 |
->write(!$tags ? "array(),\n" : "array('".implode("', '", array_keys($tags))."'),\n")
|
52 |
->write(!$filters ? "array(),\n" : "array('".implode("', '", array_keys($filters))."'),\n")
|
54 |
->outdent()
|
55 |
->write(");\n")
|
56 |
->outdent()
|
57 |
+
->write("} catch (Twig_SupTwgSgg_Sandbox_SecurityError \$e) {\n")
|
58 |
->indent()
|
59 |
->write("\$e->setSourceContext(\$this->getSourceContext());\n\n")
|
60 |
+
->write("if (\$e instanceof Twig_SupTwgSgg_Sandbox_SecurityNotAllowedTagError && isset(\$tags[\$e->getTagName()])) {\n")
|
61 |
->indent()
|
62 |
->write("\$e->setTemplateLine(\$tags[\$e->getTagName()]);\n")
|
63 |
->outdent()
|
64 |
+
->write("} elseif (\$e instanceof Twig_SupTwgSgg_Sandbox_SecurityNotAllowedFilterError && isset(\$filters[\$e->getFilterName()])) {\n")
|
65 |
->indent()
|
66 |
->write("\$e->setTemplateLine(\$filters[\$e->getFilterName()]);\n")
|
67 |
->outdent()
|
68 |
+
->write("} elseif (\$e instanceof Twig_SupTwgSgg_Sandbox_SecurityNotAllowedFunctionError && isset(\$functions[\$e->getFunctionName()])) {\n")
|
69 |
->indent()
|
70 |
->write("\$e->setTemplateLine(\$functions[\$e->getFunctionName()]);\n")
|
71 |
->outdent()
|
vendor/Twig/Node/Do.php
CHANGED
@@ -14,14 +14,14 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
-
public function __construct(
|
20 |
{
|
21 |
parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
|
22 |
}
|
23 |
|
24 |
-
public function compile(
|
25 |
{
|
26 |
$compiler
|
27 |
->addDebugInfo($this)
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Node_Do extends Twig_SupTwgSgg_Node
|
18 |
{
|
19 |
+
public function __construct(Twig_SupTwgSgg_Node_Expression $expr, $lineno, $tag = null)
|
20 |
{
|
21 |
parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
25 |
{
|
26 |
$compiler
|
27 |
->addDebugInfo($this)
|
vendor/Twig/Node/Embed.php
CHANGED
@@ -14,12 +14,12 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
// we don't inject the module to avoid node visitors to traverse it twice (as it will be already visited in the main module)
|
20 |
-
public function __construct($name, $index,
|
21 |
{
|
22 |
-
parent::__construct(new
|
23 |
|
24 |
$this->setAttribute('name', $name);
|
25 |
// to be removed in 2.0, used name instead
|
@@ -27,7 +27,7 @@ class Twig_SupTwg_Node_Embed extends Twig_SupTwg_Node_Include
|
|
27 |
$this->setAttribute('index', $index);
|
28 |
}
|
29 |
|
30 |
-
protected function addGetTemplate(
|
31 |
{
|
32 |
$compiler
|
33 |
->write('$this->loadTemplate(')
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Node_Embed extends Twig_SupTwgSgg_Node_Include
|
18 |
{
|
19 |
// we don't inject the module to avoid node visitors to traverse it twice (as it will be already visited in the main module)
|
20 |
+
public function __construct($name, $index, Twig_SupTwgSgg_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno = null, $tag = null)
|
21 |
{
|
22 |
+
parent::__construct(new Twig_SupTwgSgg_Node_Expression_Constant('not_used', $lineno), $variables, $only, $ignoreMissing, $lineno, $tag);
|
23 |
|
24 |
$this->setAttribute('name', $name);
|
25 |
// to be removed in 2.0, used name instead
|
27 |
$this->setAttribute('index', $index);
|
28 |
}
|
29 |
|
30 |
+
protected function addGetTemplate(Twig_SupTwgSgg_Compiler $compiler)
|
31 |
{
|
32 |
$compiler
|
33 |
->write('$this->loadTemplate(')
|
vendor/Twig/Node/Expression.php
CHANGED
@@ -15,6 +15,6 @@
|
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
-
abstract class
|
19 |
{
|
20 |
}
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
abstract class Twig_SupTwgSgg_Node_Expression extends Twig_SupTwgSgg_Node
|
19 |
{
|
20 |
}
|
vendor/Twig/Node/Expression/Array.php
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
protected $index;
|
14 |
|
@@ -18,7 +18,7 @@ class Twig_SupTwg_Node_Expression_Array extends Twig_SupTwg_Node_Expression
|
|
18 |
|
19 |
$this->index = -1;
|
20 |
foreach ($this->getKeyValuePairs() as $pair) {
|
21 |
-
if ($pair['key'] instanceof
|
22 |
$this->index = $pair['key']->getAttribute('value');
|
23 |
}
|
24 |
}
|
@@ -38,7 +38,7 @@ class Twig_SupTwg_Node_Expression_Array extends Twig_SupTwg_Node_Expression
|
|
38 |
return $pairs;
|
39 |
}
|
40 |
|
41 |
-
public function hasElement(
|
42 |
{
|
43 |
foreach ($this->getKeyValuePairs() as $pair) {
|
44 |
// we compare the string representation of the keys
|
@@ -51,16 +51,16 @@ class Twig_SupTwg_Node_Expression_Array extends Twig_SupTwg_Node_Expression
|
|
51 |
return false;
|
52 |
}
|
53 |
|
54 |
-
public function addElement(
|
55 |
{
|
56 |
if (null === $key) {
|
57 |
-
$key = new
|
58 |
}
|
59 |
|
60 |
array_push($this->nodes, $key, $value);
|
61 |
}
|
62 |
|
63 |
-
public function compile(
|
64 |
{
|
65 |
$compiler->raw('array(');
|
66 |
$first = true;
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_Array extends Twig_SupTwgSgg_Node_Expression
|
12 |
{
|
13 |
protected $index;
|
14 |
|
18 |
|
19 |
$this->index = -1;
|
20 |
foreach ($this->getKeyValuePairs() as $pair) {
|
21 |
+
if ($pair['key'] instanceof Twig_SupTwgSgg_Node_Expression_Constant && ctype_digit((string) $pair['key']->getAttribute('value')) && $pair['key']->getAttribute('value') > $this->index) {
|
22 |
$this->index = $pair['key']->getAttribute('value');
|
23 |
}
|
24 |
}
|
38 |
return $pairs;
|
39 |
}
|
40 |
|
41 |
+
public function hasElement(Twig_SupTwgSgg_Node_Expression $key)
|
42 |
{
|
43 |
foreach ($this->getKeyValuePairs() as $pair) {
|
44 |
// we compare the string representation of the keys
|
51 |
return false;
|
52 |
}
|
53 |
|
54 |
+
public function addElement(Twig_SupTwgSgg_Node_Expression $value, Twig_SupTwgSgg_Node_Expression $key = null)
|
55 |
{
|
56 |
if (null === $key) {
|
57 |
+
$key = new Twig_SupTwgSgg_Node_Expression_Constant(++$this->index, $value->getTemplateLine());
|
58 |
}
|
59 |
|
60 |
array_push($this->nodes, $key, $value);
|
61 |
}
|
62 |
|
63 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
64 |
{
|
65 |
$compiler->raw('array(');
|
66 |
$first = true;
|
vendor/Twig/Node/Expression/AssignName.php
CHANGED
@@ -10,9 +10,9 @@
|
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
-
class
|
14 |
{
|
15 |
-
public function compile(
|
16 |
{
|
17 |
$compiler
|
18 |
->raw('$context[')
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
|
13 |
+
class Twig_SupTwgSgg_Node_Expression_AssignName extends Twig_SupTwgSgg_Node_Expression_Name
|
14 |
{
|
15 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
16 |
{
|
17 |
$compiler
|
18 |
->raw('$context[')
|
vendor/Twig/Node/Expression/Binary.php
CHANGED
@@ -9,14 +9,14 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
abstract class
|
13 |
{
|
14 |
-
public function __construct(
|
15 |
{
|
16 |
parent::__construct(array('left' => $left, 'right' => $right), array(), $lineno);
|
17 |
}
|
18 |
|
19 |
-
public function compile(
|
20 |
{
|
21 |
$compiler
|
22 |
->raw('(')
|
@@ -31,5 +31,5 @@ abstract class Twig_SupTwg_Node_Expression_Binary extends Twig_SupTwg_Node_Expre
|
|
31 |
;
|
32 |
}
|
33 |
|
34 |
-
abstract public function operator(
|
35 |
}
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
abstract class Twig_SupTwgSgg_Node_Expression_Binary extends Twig_SupTwgSgg_Node_Expression
|
13 |
{
|
14 |
+
public function __construct(Twig_SupTwgSgg_NodeInterface $left, Twig_SupTwgSgg_NodeInterface $right, $lineno)
|
15 |
{
|
16 |
parent::__construct(array('left' => $left, 'right' => $right), array(), $lineno);
|
17 |
}
|
18 |
|
19 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
20 |
{
|
21 |
$compiler
|
22 |
->raw('(')
|
31 |
;
|
32 |
}
|
33 |
|
34 |
+
abstract public function operator(Twig_SupTwgSgg_Compiler $compiler);
|
35 |
}
|
vendor/Twig/Node/Expression/Binary/Add.php
CHANGED
@@ -9,9 +9,9 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
-
public function operator(
|
15 |
{
|
16 |
return $compiler->raw('+');
|
17 |
}
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_Add extends Twig_SupTwgSgg_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('+');
|
17 |
}
|
vendor/Twig/Node/Expression/Binary/And.php
CHANGED
@@ -9,9 +9,9 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
-
public function operator(
|
15 |
{
|
16 |
return $compiler->raw('&&');
|
17 |
}
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_And extends Twig_SupTwgSgg_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('&&');
|
17 |
}
|
vendor/Twig/Node/Expression/Binary/BitwiseAnd.php
CHANGED
@@ -9,9 +9,9 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
-
public function operator(
|
15 |
{
|
16 |
return $compiler->raw('&');
|
17 |
}
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_BitwiseAnd extends Twig_SupTwgSgg_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('&');
|
17 |
}
|
vendor/Twig/Node/Expression/Binary/BitwiseOr.php
CHANGED
@@ -9,9 +9,9 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
-
public function operator(
|
15 |
{
|
16 |
return $compiler->raw('|');
|
17 |
}
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_BitwiseOr extends Twig_SupTwgSgg_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('|');
|
17 |
}
|
vendor/Twig/Node/Expression/Binary/BitwiseXor.php
CHANGED
@@ -9,9 +9,9 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
-
public function operator(
|
15 |
{
|
16 |
return $compiler->raw('^');
|
17 |
}
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_BitwiseXor extends Twig_SupTwgSgg_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('^');
|
17 |
}
|
vendor/Twig/Node/Expression/Binary/Concat.php
CHANGED
@@ -9,9 +9,9 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
-
public function operator(
|
15 |
{
|
16 |
return $compiler->raw('.');
|
17 |
}
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_Concat extends Twig_SupTwgSgg_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('.');
|
17 |
}
|
vendor/Twig/Node/Expression/Binary/Div.php
CHANGED
@@ -9,9 +9,9 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
-
public function operator(
|
15 |
{
|
16 |
return $compiler->raw('/');
|
17 |
}
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_Div extends Twig_SupTwgSgg_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('/');
|
17 |
}
|
vendor/Twig/Node/Expression/Binary/EndsWith.php
CHANGED
@@ -8,9 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
-
public function compile(
|
14 |
{
|
15 |
$left = $compiler->getVarName();
|
16 |
$right = $compiler->getVarName();
|
@@ -23,7 +23,7 @@ class Twig_SupTwg_Node_Expression_Binary_EndsWith extends Twig_SupTwg_Node_Expre
|
|
23 |
;
|
24 |
}
|
25 |
|
26 |
-
public function operator(
|
27 |
{
|
28 |
return $compiler->raw('');
|
29 |
}
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_EndsWith extends Twig_SupTwgSgg_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
14 |
{
|
15 |
$left = $compiler->getVarName();
|
16 |
$right = $compiler->getVarName();
|
23 |
;
|
24 |
}
|
25 |
|
26 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
27 |
{
|
28 |
return $compiler->raw('');
|
29 |
}
|
vendor/Twig/Node/Expression/Binary/Equal.php
CHANGED
@@ -8,9 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
-
public function operator(
|
14 |
{
|
15 |
return $compiler->raw('==');
|
16 |
}
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_Equal extends Twig_SupTwgSgg_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
14 |
{
|
15 |
return $compiler->raw('==');
|
16 |
}
|
vendor/Twig/Node/Expression/Binary/FloorDiv.php
CHANGED
@@ -8,16 +8,16 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
-
public function compile(
|
14 |
{
|
15 |
$compiler->raw('(int) floor(');
|
16 |
parent::compile($compiler);
|
17 |
$compiler->raw(')');
|
18 |
}
|
19 |
|
20 |
-
public function operator(
|
21 |
{
|
22 |
return $compiler->raw('/');
|
23 |
}
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_FloorDiv extends Twig_SupTwgSgg_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
14 |
{
|
15 |
$compiler->raw('(int) floor(');
|
16 |
parent::compile($compiler);
|
17 |
$compiler->raw(')');
|
18 |
}
|
19 |
|
20 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
21 |
{
|
22 |
return $compiler->raw('/');
|
23 |
}
|
vendor/Twig/Node/Expression/Binary/Greater.php
CHANGED
@@ -8,9 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
-
public function operator(
|
14 |
{
|
15 |
return $compiler->raw('>');
|
16 |
}
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_Greater extends Twig_SupTwgSgg_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
14 |
{
|
15 |
return $compiler->raw('>');
|
16 |
}
|
vendor/Twig/Node/Expression/Binary/GreaterEqual.php
CHANGED
@@ -8,9 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
-
public function operator(
|
14 |
{
|
15 |
return $compiler->raw('>=');
|
16 |
}
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_GreaterEqual extends Twig_SupTwgSgg_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
14 |
{
|
15 |
return $compiler->raw('>=');
|
16 |
}
|
vendor/Twig/Node/Expression/Binary/In.php
CHANGED
@@ -8,12 +8,12 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
-
public function compile(
|
14 |
{
|
15 |
$compiler
|
16 |
-
->raw('
|
17 |
->subcompile($this->getNode('left'))
|
18 |
->raw(', ')
|
19 |
->subcompile($this->getNode('right'))
|
@@ -21,7 +21,7 @@ class Twig_SupTwg_Node_Expression_Binary_In extends Twig_SupTwg_Node_Expression_
|
|
21 |
;
|
22 |
}
|
23 |
|
24 |
-
public function operator(
|
25 |
{
|
26 |
return $compiler->raw('in');
|
27 |
}
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_In extends Twig_SupTwgSgg_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
14 |
{
|
15 |
$compiler
|
16 |
+
->raw('Twig_SupTwgSgg_in_filter(')
|
17 |
->subcompile($this->getNode('left'))
|
18 |
->raw(', ')
|
19 |
->subcompile($this->getNode('right'))
|
21 |
;
|
22 |
}
|
23 |
|
24 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
25 |
{
|
26 |
return $compiler->raw('in');
|
27 |
}
|
vendor/Twig/Node/Expression/Binary/Less.php
CHANGED
@@ -8,9 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
-
public function operator(
|
14 |
{
|
15 |
return $compiler->raw('<');
|
16 |
}
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_Less extends Twig_SupTwgSgg_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
14 |
{
|
15 |
return $compiler->raw('<');
|
16 |
}
|
vendor/Twig/Node/Expression/Binary/LessEqual.php
CHANGED
@@ -8,9 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
-
public function operator(
|
14 |
{
|
15 |
return $compiler->raw('<=');
|
16 |
}
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_LessEqual extends Twig_SupTwgSgg_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
14 |
{
|
15 |
return $compiler->raw('<=');
|
16 |
}
|
vendor/Twig/Node/Expression/Binary/Matches.php
CHANGED
@@ -8,9 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
-
public function compile(
|
14 |
{
|
15 |
$compiler
|
16 |
->raw('preg_match(')
|
@@ -21,7 +21,7 @@ class Twig_SupTwg_Node_Expression_Binary_Matches extends Twig_SupTwg_Node_Expres
|
|
21 |
;
|
22 |
}
|
23 |
|
24 |
-
public function operator(
|
25 |
{
|
26 |
return $compiler->raw('');
|
27 |
}
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_Matches extends Twig_SupTwgSgg_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
14 |
{
|
15 |
$compiler
|
16 |
->raw('preg_match(')
|
21 |
;
|
22 |
}
|
23 |
|
24 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
25 |
{
|
26 |
return $compiler->raw('');
|
27 |
}
|
vendor/Twig/Node/Expression/Binary/Mod.php
CHANGED
@@ -9,9 +9,9 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
-
public function operator(
|
15 |
{
|
16 |
return $compiler->raw('%');
|
17 |
}
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_Mod extends Twig_SupTwgSgg_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('%');
|
17 |
}
|
vendor/Twig/Node/Expression/Binary/Mul.php
CHANGED
@@ -9,9 +9,9 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
-
public function operator(
|
15 |
{
|
16 |
return $compiler->raw('*');
|
17 |
}
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_Mul extends Twig_SupTwgSgg_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('*');
|
17 |
}
|
vendor/Twig/Node/Expression/Binary/NotEqual.php
CHANGED
@@ -8,9 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
-
public function operator(
|
14 |
{
|
15 |
return $compiler->raw('!=');
|
16 |
}
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_NotEqual extends Twig_SupTwgSgg_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
14 |
{
|
15 |
return $compiler->raw('!=');
|
16 |
}
|
vendor/Twig/Node/Expression/Binary/NotIn.php
CHANGED
@@ -8,12 +8,12 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
-
public function compile(
|
14 |
{
|
15 |
$compiler
|
16 |
-
->raw('!
|
17 |
->subcompile($this->getNode('left'))
|
18 |
->raw(', ')
|
19 |
->subcompile($this->getNode('right'))
|
@@ -21,7 +21,7 @@ class Twig_SupTwg_Node_Expression_Binary_NotIn extends Twig_SupTwg_Node_Expressi
|
|
21 |
;
|
22 |
}
|
23 |
|
24 |
-
public function operator(
|
25 |
{
|
26 |
return $compiler->raw('not in');
|
27 |
}
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_NotIn extends Twig_SupTwgSgg_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
14 |
{
|
15 |
$compiler
|
16 |
+
->raw('!Twig_SupTwgSgg_in_filter(')
|
17 |
->subcompile($this->getNode('left'))
|
18 |
->raw(', ')
|
19 |
->subcompile($this->getNode('right'))
|
21 |
;
|
22 |
}
|
23 |
|
24 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
25 |
{
|
26 |
return $compiler->raw('not in');
|
27 |
}
|
vendor/Twig/Node/Expression/Binary/Or.php
CHANGED
@@ -9,9 +9,9 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
-
public function operator(
|
15 |
{
|
16 |
return $compiler->raw('||');
|
17 |
}
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_Or extends Twig_SupTwgSgg_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('||');
|
17 |
}
|
vendor/Twig/Node/Expression/Binary/Power.php
CHANGED
@@ -8,9 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
-
public function compile(
|
14 |
{
|
15 |
if (PHP_VERSION_ID >= 50600) {
|
16 |
return parent::compile($compiler);
|
@@ -25,7 +25,7 @@ class Twig_SupTwg_Node_Expression_Binary_Power extends Twig_SupTwg_Node_Expressi
|
|
25 |
;
|
26 |
}
|
27 |
|
28 |
-
public function operator(
|
29 |
{
|
30 |
return $compiler->raw('**');
|
31 |
}
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_Power extends Twig_SupTwgSgg_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
14 |
{
|
15 |
if (PHP_VERSION_ID >= 50600) {
|
16 |
return parent::compile($compiler);
|
25 |
;
|
26 |
}
|
27 |
|
28 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
29 |
{
|
30 |
return $compiler->raw('**');
|
31 |
}
|
vendor/Twig/Node/Expression/Binary/Range.php
CHANGED
@@ -8,9 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
-
public function compile(
|
14 |
{
|
15 |
$compiler
|
16 |
->raw('range(')
|
@@ -21,7 +21,7 @@ class Twig_SupTwg_Node_Expression_Binary_Range extends Twig_SupTwg_Node_Expressi
|
|
21 |
;
|
22 |
}
|
23 |
|
24 |
-
public function operator(
|
25 |
{
|
26 |
return $compiler->raw('..');
|
27 |
}
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_Range extends Twig_SupTwgSgg_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
14 |
{
|
15 |
$compiler
|
16 |
->raw('range(')
|
21 |
;
|
22 |
}
|
23 |
|
24 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
25 |
{
|
26 |
return $compiler->raw('..');
|
27 |
}
|
vendor/Twig/Node/Expression/Binary/StartsWith.php
CHANGED
@@ -8,9 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
-
public function compile(
|
14 |
{
|
15 |
$left = $compiler->getVarName();
|
16 |
$right = $compiler->getVarName();
|
@@ -23,7 +23,7 @@ class Twig_SupTwg_Node_Expression_Binary_StartsWith extends Twig_SupTwg_Node_Exp
|
|
23 |
;
|
24 |
}
|
25 |
|
26 |
-
public function operator(
|
27 |
{
|
28 |
return $compiler->raw('');
|
29 |
}
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_StartsWith extends Twig_SupTwgSgg_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
14 |
{
|
15 |
$left = $compiler->getVarName();
|
16 |
$right = $compiler->getVarName();
|
23 |
;
|
24 |
}
|
25 |
|
26 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
27 |
{
|
28 |
return $compiler->raw('');
|
29 |
}
|
vendor/Twig/Node/Expression/Binary/Sub.php
CHANGED
@@ -9,9 +9,9 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
-
public function operator(
|
15 |
{
|
16 |
return $compiler->raw('-');
|
17 |
}
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_Binary_Sub extends Twig_SupTwgSgg_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
15 |
{
|
16 |
return $compiler->raw('-');
|
17 |
}
|
vendor/Twig/Node/Expression/BlockReference.php
CHANGED
@@ -15,15 +15,15 @@
|
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
-
class
|
19 |
{
|
20 |
/**
|
21 |
-
* @param
|
22 |
*/
|
23 |
-
public function __construct(
|
24 |
{
|
25 |
if (is_bool($template)) {
|
26 |
-
|
27 |
|
28 |
$template = null;
|
29 |
}
|
@@ -36,7 +36,7 @@ class Twig_SupTwg_Node_Expression_BlockReference extends Twig_SupTwg_Node_Expres
|
|
36 |
parent::__construct($nodes, array('is_defined_test' => false, 'output' => false), $lineno, $tag);
|
37 |
}
|
38 |
|
39 |
-
public function compile(
|
40 |
{
|
41 |
if ($this->getAttribute('is_defined_test')) {
|
42 |
$this->compileTemplateCall($compiler, 'hasBlock');
|
@@ -53,7 +53,7 @@ class Twig_SupTwg_Node_Expression_BlockReference extends Twig_SupTwg_Node_Expres
|
|
53 |
}
|
54 |
}
|
55 |
|
56 |
-
private function compileTemplateCall(
|
57 |
{
|
58 |
if (!$this->hasNode('template')) {
|
59 |
$compiler->write('$this');
|
@@ -75,7 +75,7 @@ class Twig_SupTwg_Node_Expression_BlockReference extends Twig_SupTwg_Node_Expres
|
|
75 |
return $compiler;
|
76 |
}
|
77 |
|
78 |
-
private function compileBlockArguments(
|
79 |
{
|
80 |
$compiler
|
81 |
->raw('(')
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_SupTwgSgg_Node_Expression_BlockReference extends Twig_SupTwgSgg_Node_Expression
|
19 |
{
|
20 |
/**
|
21 |
+
* @param Twig_SupTwgSgg_Node|null $template
|
22 |
*/
|
23 |
+
public function __construct(Twig_SupTwgSgg_NodeInterface $name, $template = null, $lineno, $tag = null)
|
24 |
{
|
25 |
if (is_bool($template)) {
|
26 |
+
//@trigger_error(sprintf('The %s method "$asString" argument is deprecated since version 1.28 and will be removed in 2.0.', __METHOD__), E_USER_DEPRECATED);
|
27 |
|
28 |
$template = null;
|
29 |
}
|
36 |
parent::__construct($nodes, array('is_defined_test' => false, 'output' => false), $lineno, $tag);
|
37 |
}
|
38 |
|
39 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
40 |
{
|
41 |
if ($this->getAttribute('is_defined_test')) {
|
42 |
$this->compileTemplateCall($compiler, 'hasBlock');
|
53 |
}
|
54 |
}
|
55 |
|
56 |
+
private function compileTemplateCall(Twig_SupTwgSgg_Compiler $compiler, $method)
|
57 |
{
|
58 |
if (!$this->hasNode('template')) {
|
59 |
$compiler->write('$this');
|
75 |
return $compiler;
|
76 |
}
|
77 |
|
78 |
+
private function compileBlockArguments(Twig_SupTwgSgg_Compiler $compiler)
|
79 |
{
|
80 |
$compiler
|
81 |
->raw('(')
|
vendor/Twig/Node/Expression/Call.php
CHANGED
@@ -8,11 +8,11 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
abstract class
|
12 |
{
|
13 |
private $reflector;
|
14 |
|
15 |
-
protected function compileCallable(
|
16 |
{
|
17 |
$closingParenthesis = false;
|
18 |
if ($this->hasAttribute('callable') && $callable = $this->getAttribute('callable')) {
|
@@ -26,7 +26,7 @@ abstract class Twig_SupTwg_Node_Expression_Call extends Twig_SupTwg_Node_Express
|
|
26 |
} else {
|
27 |
$compiler->raw(sprintf('$this->env->getRuntime(\'%s\')->%s', $callable[0], $callable[1]));
|
28 |
}
|
29 |
-
} elseif ($r instanceof ReflectionMethod && $callable[0] instanceof
|
30 |
$compiler->raw(sprintf('$this->env->getExtension(\'%s\')->%s', get_class($callable[0]), $callable[1]));
|
31 |
} else {
|
32 |
$type = ucfirst($this->getAttribute('type'));
|
@@ -45,7 +45,7 @@ abstract class Twig_SupTwg_Node_Expression_Call extends Twig_SupTwg_Node_Express
|
|
45 |
}
|
46 |
}
|
47 |
|
48 |
-
protected function compileArguments(
|
49 |
{
|
50 |
$compiler->raw('(');
|
51 |
|
@@ -111,7 +111,7 @@ abstract class Twig_SupTwg_Node_Expression_Call extends Twig_SupTwg_Node_Express
|
|
111 |
$named = true;
|
112 |
$name = $this->normalizeName($name);
|
113 |
} elseif ($named) {
|
114 |
-
throw new
|
115 |
}
|
116 |
|
117 |
$parameters[$name] = $node;
|
@@ -143,11 +143,11 @@ abstract class Twig_SupTwg_Node_Expression_Call extends Twig_SupTwg_Node_Express
|
|
143 |
|
144 |
if (array_key_exists($name, $parameters)) {
|
145 |
if (array_key_exists($pos, $parameters)) {
|
146 |
-
throw new
|
147 |
}
|
148 |
|
149 |
if (count($missingArguments)) {
|
150 |
-
throw new
|
151 |
'Argument "%s" could not be assigned for %s "%s(%s)" because it is mapped to an internal PHP function which cannot determine default value for optional argument%s "%s".',
|
152 |
$name, $callType, $callName, implode(', ', $names), count($missingArguments) > 1 ? 's' : '', implode('", "', $missingArguments))
|
153 |
);
|
@@ -164,7 +164,7 @@ abstract class Twig_SupTwg_Node_Expression_Call extends Twig_SupTwg_Node_Express
|
|
164 |
$optionalArguments = array();
|
165 |
++$pos;
|
166 |
} elseif ($callableParameter->isDefaultValueAvailable()) {
|
167 |
-
$optionalArguments[] = new
|
168 |
} elseif ($callableParameter->isOptional()) {
|
169 |
if (empty($parameters)) {
|
170 |
break;
|
@@ -172,17 +172,17 @@ abstract class Twig_SupTwg_Node_Expression_Call extends Twig_SupTwg_Node_Express
|
|
172 |
$missingArguments[] = $name;
|
173 |
}
|
174 |
} else {
|
175 |
-
throw new
|
176 |
}
|
177 |
}
|
178 |
|
179 |
if ($isVariadic) {
|
180 |
-
$arbitraryArguments = new
|
181 |
foreach ($parameters as $key => $value) {
|
182 |
if (is_int($key)) {
|
183 |
$arbitraryArguments->addElement($value);
|
184 |
} else {
|
185 |
-
$arbitraryArguments->addElement($value, new
|
186 |
}
|
187 |
unset($parameters[$key]);
|
188 |
}
|
@@ -196,13 +196,13 @@ abstract class Twig_SupTwg_Node_Expression_Call extends Twig_SupTwg_Node_Express
|
|
196 |
if (!empty($parameters)) {
|
197 |
$unknownParameter = null;
|
198 |
foreach ($parameters as $parameter) {
|
199 |
-
if ($parameter instanceof
|
200 |
$unknownParameter = $parameter;
|
201 |
break;
|
202 |
}
|
203 |
}
|
204 |
|
205 |
-
throw new
|
206 |
'Unknown argument%s "%s" for %s "%s(%s)".',
|
207 |
count($parameters) > 1 ? 's' : '', implode('", "', array_keys($parameters)), $callType, $callName, implode(', ', $names)
|
208 |
), $unknownParameter ? $unknownParameter->getTemplateLine() : -1);
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
abstract class Twig_SupTwgSgg_Node_Expression_Call extends Twig_SupTwgSgg_Node_Expression
|
12 |
{
|
13 |
private $reflector;
|
14 |
|
15 |
+
protected function compileCallable(Twig_SupTwgSgg_Compiler $compiler)
|
16 |
{
|
17 |
$closingParenthesis = false;
|
18 |
if ($this->hasAttribute('callable') && $callable = $this->getAttribute('callable')) {
|
26 |
} else {
|
27 |
$compiler->raw(sprintf('$this->env->getRuntime(\'%s\')->%s', $callable[0], $callable[1]));
|
28 |
}
|
29 |
+
} elseif ($r instanceof ReflectionMethod && $callable[0] instanceof Twig_SupTwgSgg_ExtensionInterface) {
|
30 |
$compiler->raw(sprintf('$this->env->getExtension(\'%s\')->%s', get_class($callable[0]), $callable[1]));
|
31 |
} else {
|
32 |
$type = ucfirst($this->getAttribute('type'));
|
45 |
}
|
46 |
}
|
47 |
|
48 |
+
protected function compileArguments(Twig_SupTwgSgg_Compiler $compiler)
|
49 |
{
|
50 |
$compiler->raw('(');
|
51 |
|
111 |
$named = true;
|
112 |
$name = $this->normalizeName($name);
|
113 |
} elseif ($named) {
|
114 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('Positional arguments cannot be used after named arguments for %s "%s".', $callType, $callName));
|
115 |
}
|
116 |
|
117 |
$parameters[$name] = $node;
|
143 |
|
144 |
if (array_key_exists($name, $parameters)) {
|
145 |
if (array_key_exists($pos, $parameters)) {
|
146 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('Argument "%s" is defined twice for %s "%s".', $name, $callType, $callName));
|
147 |
}
|
148 |
|
149 |
if (count($missingArguments)) {
|
150 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf(
|
151 |
'Argument "%s" could not be assigned for %s "%s(%s)" because it is mapped to an internal PHP function which cannot determine default value for optional argument%s "%s".',
|
152 |
$name, $callType, $callName, implode(', ', $names), count($missingArguments) > 1 ? 's' : '', implode('", "', $missingArguments))
|
153 |
);
|
164 |
$optionalArguments = array();
|
165 |
++$pos;
|
166 |
} elseif ($callableParameter->isDefaultValueAvailable()) {
|
167 |
+
$optionalArguments[] = new Twig_SupTwgSgg_Node_Expression_Constant($callableParameter->getDefaultValue(), -1);
|
168 |
} elseif ($callableParameter->isOptional()) {
|
169 |
if (empty($parameters)) {
|
170 |
break;
|
172 |
$missingArguments[] = $name;
|
173 |
}
|
174 |
} else {
|
175 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('Value for argument "%s" is required for %s "%s".', $name, $callType, $callName));
|
176 |
}
|
177 |
}
|
178 |
|
179 |
if ($isVariadic) {
|
180 |
+
$arbitraryArguments = new Twig_SupTwgSgg_Node_Expression_Array(array(), -1);
|
181 |
foreach ($parameters as $key => $value) {
|
182 |
if (is_int($key)) {
|
183 |
$arbitraryArguments->addElement($value);
|
184 |
} else {
|
185 |
+
$arbitraryArguments->addElement($value, new Twig_SupTwgSgg_Node_Expression_Constant($key, -1));
|
186 |
}
|
187 |
unset($parameters[$key]);
|
188 |
}
|
196 |
if (!empty($parameters)) {
|
197 |
$unknownParameter = null;
|
198 |
foreach ($parameters as $parameter) {
|
199 |
+
if ($parameter instanceof Twig_SupTwgSgg_Node) {
|
200 |
$unknownParameter = $parameter;
|
201 |
break;
|
202 |
}
|
203 |
}
|
204 |
|
205 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf(
|
206 |
'Unknown argument%s "%s" for %s "%s(%s)".',
|
207 |
count($parameters) > 1 ? 's' : '', implode('", "', array_keys($parameters)), $callType, $callName, implode(', ', $names)
|
208 |
), $unknownParameter ? $unknownParameter->getTemplateLine() : -1);
|
vendor/Twig/Node/Expression/Conditional.php
CHANGED
@@ -9,14 +9,14 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
-
public function __construct(
|
15 |
{
|
16 |
parent::__construct(array('expr1' => $expr1, 'expr2' => $expr2, 'expr3' => $expr3), array(), $lineno);
|
17 |
}
|
18 |
|
19 |
-
public function compile(
|
20 |
{
|
21 |
$compiler
|
22 |
->raw('((')
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_Conditional extends Twig_SupTwgSgg_Node_Expression
|
13 |
{
|
14 |
+
public function __construct(Twig_SupTwgSgg_Node_Expression $expr1, Twig_SupTwgSgg_Node_Expression $expr2, Twig_SupTwgSgg_Node_Expression $expr3, $lineno)
|
15 |
{
|
16 |
parent::__construct(array('expr1' => $expr1, 'expr2' => $expr2, 'expr3' => $expr3), array(), $lineno);
|
17 |
}
|
18 |
|
19 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
20 |
{
|
21 |
$compiler
|
22 |
->raw('((')
|
vendor/Twig/Node/Expression/Constant.php
CHANGED
@@ -9,14 +9,14 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
public function __construct($value, $lineno)
|
15 |
{
|
16 |
parent::__construct(array(), array('value' => $value), $lineno);
|
17 |
}
|
18 |
|
19 |
-
public function compile(
|
20 |
{
|
21 |
$compiler->repr($this->getAttribute('value'));
|
22 |
}
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_Constant extends Twig_SupTwgSgg_Node_Expression
|
13 |
{
|
14 |
public function __construct($value, $lineno)
|
15 |
{
|
16 |
parent::__construct(array(), array('value' => $value), $lineno);
|
17 |
}
|
18 |
|
19 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
20 |
{
|
21 |
$compiler->repr($this->getAttribute('value'));
|
22 |
}
|
vendor/Twig/Node/Expression/ExtensionReference.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
|
14 |
/**
|
15 |
* Represents an extension call node.
|
@@ -18,14 +18,14 @@
|
|
18 |
*
|
19 |
* @deprecated since 1.23 and will be removed in 2.0.
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
public function __construct($name, $lineno, $tag = null)
|
24 |
{
|
25 |
parent::__construct(array(), array('name' => $name), $lineno, $tag);
|
26 |
}
|
27 |
|
28 |
-
public function compile(
|
29 |
{
|
30 |
$compiler->raw(sprintf("\$this->env->getExtension('%s')", $this->getAttribute('name')));
|
31 |
}
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
+
//@trigger_error('The Twig_SupTwgSgg_Node_Expression_ExtensionReference class is deprecated since version 1.23 and will be removed in 2.0.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Represents an extension call node.
|
18 |
*
|
19 |
* @deprecated since 1.23 and will be removed in 2.0.
|
20 |
*/
|
21 |
+
class Twig_SupTwgSgg_Node_Expression_ExtensionReference extends Twig_SupTwgSgg_Node_Expression
|
22 |
{
|
23 |
public function __construct($name, $lineno, $tag = null)
|
24 |
{
|
25 |
parent::__construct(array(), array('name' => $name), $lineno, $tag);
|
26 |
}
|
27 |
|
28 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
29 |
{
|
30 |
$compiler->raw(sprintf("\$this->env->getExtension('%s')", $this->getAttribute('name')));
|
31 |
}
|
vendor/Twig/Node/Expression/Filter.php
CHANGED
@@ -9,14 +9,14 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
-
public function __construct(
|
15 |
{
|
16 |
parent::__construct(array('node' => $node, 'filter' => $filterName, 'arguments' => $arguments), array(), $lineno, $tag);
|
17 |
}
|
18 |
|
19 |
-
public function compile(
|
20 |
{
|
21 |
$name = $this->getNode('filter')->getAttribute('value');
|
22 |
$filter = $compiler->getEnvironment()->getFilter($name);
|
@@ -27,10 +27,10 @@ class Twig_SupTwg_Node_Expression_Filter extends Twig_SupTwg_Node_Expression_Cal
|
|
27 |
$this->setAttribute('needs_environment', $filter->needsEnvironment());
|
28 |
$this->setAttribute('needs_context', $filter->needsContext());
|
29 |
$this->setAttribute('arguments', $filter->getArguments());
|
30 |
-
if ($filter instanceof
|
31 |
$this->setAttribute('callable', $filter->getCallable());
|
32 |
}
|
33 |
-
if ($filter instanceof
|
34 |
$this->setAttribute('is_variadic', $filter->isVariadic());
|
35 |
}
|
36 |
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_Filter extends Twig_SupTwgSgg_Node_Expression_Call
|
13 |
{
|
14 |
+
public function __construct(Twig_SupTwgSgg_NodeInterface $node, Twig_SupTwgSgg_Node_Expression_Constant $filterName, Twig_SupTwgSgg_NodeInterface $arguments, $lineno, $tag = null)
|
15 |
{
|
16 |
parent::__construct(array('node' => $node, 'filter' => $filterName, 'arguments' => $arguments), array(), $lineno, $tag);
|
17 |
}
|
18 |
|
19 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
20 |
{
|
21 |
$name = $this->getNode('filter')->getAttribute('value');
|
22 |
$filter = $compiler->getEnvironment()->getFilter($name);
|
27 |
$this->setAttribute('needs_environment', $filter->needsEnvironment());
|
28 |
$this->setAttribute('needs_context', $filter->needsContext());
|
29 |
$this->setAttribute('arguments', $filter->getArguments());
|
30 |
+
if ($filter instanceof Twig_SupTwgSgg_FilterCallableInterface || $filter instanceof Twig_SupTwgSgg_SimpleFilter) {
|
31 |
$this->setAttribute('callable', $filter->getCallable());
|
32 |
}
|
33 |
+
if ($filter instanceof Twig_SupTwgSgg_SimpleFilter) {
|
34 |
$this->setAttribute('is_variadic', $filter->isVariadic());
|
35 |
}
|
36 |
|
vendor/Twig/Node/Expression/Filter/Default.php
CHANGED
@@ -18,17 +18,17 @@
|
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
-
public function __construct(
|
24 |
{
|
25 |
-
$default = new
|
26 |
|
27 |
-
if ('default' === $filterName->getAttribute('value') && ($node instanceof
|
28 |
-
$test = new
|
29 |
-
$false = count($arguments) ? $arguments->getNode(0) : new
|
30 |
|
31 |
-
$node = new
|
32 |
} else {
|
33 |
$node = $default;
|
34 |
}
|
@@ -36,7 +36,7 @@ class Twig_SupTwg_Node_Expression_Filter_Default extends Twig_SupTwg_Node_Expres
|
|
36 |
parent::__construct($node, $filterName, $arguments, $lineno, $tag);
|
37 |
}
|
38 |
|
39 |
-
public function compile(
|
40 |
{
|
41 |
$compiler->subcompile($this->getNode('node'));
|
42 |
}
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
+
class Twig_SupTwgSgg_Node_Expression_Filter_Default extends Twig_SupTwgSgg_Node_Expression_Filter
|
22 |
{
|
23 |
+
public function __construct(Twig_SupTwgSgg_NodeInterface $node, Twig_SupTwgSgg_Node_Expression_Constant $filterName, Twig_SupTwgSgg_NodeInterface $arguments, $lineno, $tag = null)
|
24 |
{
|
25 |
+
$default = new Twig_SupTwgSgg_Node_Expression_Filter($node, new Twig_SupTwgSgg_Node_Expression_Constant('default', $node->getTemplateLine()), $arguments, $node->getTemplateLine());
|
26 |
|
27 |
+
if ('default' === $filterName->getAttribute('value') && ($node instanceof Twig_SupTwgSgg_Node_Expression_Name || $node instanceof Twig_SupTwgSgg_Node_Expression_GetAttr)) {
|
28 |
+
$test = new Twig_SupTwgSgg_Node_Expression_Test_Defined(clone $node, 'defined', new Twig_SupTwgSgg_Node(), $node->getTemplateLine());
|
29 |
+
$false = count($arguments) ? $arguments->getNode(0) : new Twig_SupTwgSgg_Node_Expression_Constant('', $node->getTemplateLine());
|
30 |
|
31 |
+
$node = new Twig_SupTwgSgg_Node_Expression_Conditional($test, $default, $false, $node->getTemplateLine());
|
32 |
} else {
|
33 |
$node = $default;
|
34 |
}
|
36 |
parent::__construct($node, $filterName, $arguments, $lineno, $tag);
|
37 |
}
|
38 |
|
39 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
40 |
{
|
41 |
$compiler->subcompile($this->getNode('node'));
|
42 |
}
|
vendor/Twig/Node/Expression/Function.php
CHANGED
@@ -8,14 +8,14 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
-
public function __construct($name,
|
14 |
{
|
15 |
parent::__construct(array('arguments' => $arguments), array('name' => $name, 'is_defined_test' => false), $lineno);
|
16 |
}
|
17 |
|
18 |
-
public function compile(
|
19 |
{
|
20 |
$name = $this->getAttribute('name');
|
21 |
$function = $compiler->getEnvironment()->getFunction($name);
|
@@ -26,15 +26,15 @@ class Twig_SupTwg_Node_Expression_Function extends Twig_SupTwg_Node_Expression_C
|
|
26 |
$this->setAttribute('needs_environment', $function->needsEnvironment());
|
27 |
$this->setAttribute('needs_context', $function->needsContext());
|
28 |
$this->setAttribute('arguments', $function->getArguments());
|
29 |
-
if ($function instanceof
|
30 |
$callable = $function->getCallable();
|
31 |
if ('constant' === $name && $this->getAttribute('is_defined_test')) {
|
32 |
-
$callable = '
|
33 |
}
|
34 |
|
35 |
$this->setAttribute('callable', $callable);
|
36 |
}
|
37 |
-
if ($function instanceof
|
38 |
$this->setAttribute('is_variadic', $function->isVariadic());
|
39 |
}
|
40 |
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_Function extends Twig_SupTwgSgg_Node_Expression_Call
|
12 |
{
|
13 |
+
public function __construct($name, Twig_SupTwgSgg_NodeInterface $arguments, $lineno)
|
14 |
{
|
15 |
parent::__construct(array('arguments' => $arguments), array('name' => $name, 'is_defined_test' => false), $lineno);
|
16 |
}
|
17 |
|
18 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
19 |
{
|
20 |
$name = $this->getAttribute('name');
|
21 |
$function = $compiler->getEnvironment()->getFunction($name);
|
26 |
$this->setAttribute('needs_environment', $function->needsEnvironment());
|
27 |
$this->setAttribute('needs_context', $function->needsContext());
|
28 |
$this->setAttribute('arguments', $function->getArguments());
|
29 |
+
if ($function instanceof Twig_SupTwgSgg_FunctionCallableInterface || $function instanceof Twig_SupTwgSgg_SimpleFunction) {
|
30 |
$callable = $function->getCallable();
|
31 |
if ('constant' === $name && $this->getAttribute('is_defined_test')) {
|
32 |
+
$callable = 'Twig_SupTwgSgg_constant_is_defined';
|
33 |
}
|
34 |
|
35 |
$this->setAttribute('callable', $callable);
|
36 |
}
|
37 |
+
if ($function instanceof Twig_SupTwgSgg_SimpleFunction) {
|
38 |
$this->setAttribute('is_variadic', $function->isVariadic());
|
39 |
}
|
40 |
|
vendor/Twig/Node/Expression/GetAttr.php
CHANGED
@@ -9,9 +9,9 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
-
public function __construct(
|
15 |
{
|
16 |
$nodes = array('node' => $node, 'attribute' => $attribute);
|
17 |
if (null !== $arguments) {
|
@@ -21,14 +21,14 @@ class Twig_SupTwg_Node_Expression_GetAttr extends Twig_SupTwg_Node_Expression
|
|
21 |
parent::__construct($nodes, array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno);
|
22 |
}
|
23 |
|
24 |
-
public function compile(
|
25 |
{
|
26 |
if ($this->getAttribute('disable_c_ext')) {
|
27 |
-
|
28 |
}
|
29 |
|
30 |
-
if (function_exists('
|
31 |
-
$compiler->raw('
|
32 |
} else {
|
33 |
$compiler->raw('$this->getAttribute(');
|
34 |
}
|
@@ -44,7 +44,7 @@ class Twig_SupTwg_Node_Expression_GetAttr extends Twig_SupTwg_Node_Expression
|
|
44 |
// only generate optional arguments when needed (to make generated code more readable)
|
45 |
$needFourth = $this->getAttribute('ignore_strict_check');
|
46 |
$needThird = $needFourth || $this->getAttribute('is_defined_test');
|
47 |
-
$needSecond = $needThird ||
|
48 |
$needFirst = $needSecond || $this->hasNode('arguments');
|
49 |
|
50 |
if ($needFirst) {
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_GetAttr extends Twig_SupTwgSgg_Node_Expression
|
13 |
{
|
14 |
+
public function __construct(Twig_SupTwgSgg_Node_Expression $node, Twig_SupTwgSgg_Node_Expression $attribute, Twig_SupTwgSgg_Node_Expression $arguments = null, $type, $lineno)
|
15 |
{
|
16 |
$nodes = array('node' => $node, 'attribute' => $attribute);
|
17 |
if (null !== $arguments) {
|
21 |
parent::__construct($nodes, array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno);
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
25 |
{
|
26 |
if ($this->getAttribute('disable_c_ext')) {
|
27 |
+
//@trigger_error(sprintf('Using the "disable_c_ext" attribute on %s is deprecated since version 1.30 and will be removed in 2.0.', __CLASS__), E_USER_DEPRECATED);
|
28 |
}
|
29 |
|
30 |
+
if (function_exists('Twig_SupTwgSgg_template_get_attributes') && !$this->getAttribute('disable_c_ext')) {
|
31 |
+
$compiler->raw('Twig_SupTwgSgg_template_get_attributes($this, ');
|
32 |
} else {
|
33 |
$compiler->raw('$this->getAttribute(');
|
34 |
}
|
44 |
// only generate optional arguments when needed (to make generated code more readable)
|
45 |
$needFourth = $this->getAttribute('ignore_strict_check');
|
46 |
$needThird = $needFourth || $this->getAttribute('is_defined_test');
|
47 |
+
$needSecond = $needThird || Twig_SupTwgSgg_Template::ANY_CALL !== $this->getAttribute('type');
|
48 |
$needFirst = $needSecond || $this->hasNode('arguments');
|
49 |
|
50 |
if ($needFirst) {
|
vendor/Twig/Node/Expression/MethodCall.php
CHANGED
@@ -8,18 +8,18 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
-
public function __construct(
|
14 |
{
|
15 |
parent::__construct(array('node' => $node, 'arguments' => $arguments), array('method' => $method, 'safe' => false), $lineno);
|
16 |
|
17 |
-
if ($node instanceof
|
18 |
$node->setAttribute('always_defined', true);
|
19 |
}
|
20 |
}
|
21 |
|
22 |
-
public function compile(
|
23 |
{
|
24 |
$compiler
|
25 |
->subcompile($this->getNode('node'))
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_MethodCall extends Twig_SupTwgSgg_Node_Expression
|
12 |
{
|
13 |
+
public function __construct(Twig_SupTwgSgg_Node_Expression $node, $method, Twig_SupTwgSgg_Node_Expression_Array $arguments, $lineno)
|
14 |
{
|
15 |
parent::__construct(array('node' => $node, 'arguments' => $arguments), array('method' => $method, 'safe' => false), $lineno);
|
16 |
|
17 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Expression_Name) {
|
18 |
$node->setAttribute('always_defined', true);
|
19 |
}
|
20 |
}
|
21 |
|
22 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
23 |
{
|
24 |
$compiler
|
25 |
->subcompile($this->getNode('node'))
|
vendor/Twig/Node/Expression/Name.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
protected $specialVars = array(
|
15 |
'_self' => '$this',
|
@@ -22,7 +22,7 @@ class Twig_SupTwg_Node_Expression_Name extends Twig_SupTwg_Node_Expression
|
|
22 |
parent::__construct(array(), array('name' => $name, 'is_defined_test' => false, 'ignore_strict_check' => false, 'always_defined' => false), $lineno);
|
23 |
}
|
24 |
|
25 |
-
public function compile(
|
26 |
{
|
27 |
$name = $this->getAttribute('name');
|
28 |
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_Name extends Twig_SupTwgSgg_Node_Expression
|
13 |
{
|
14 |
protected $specialVars = array(
|
15 |
'_self' => '$this',
|
22 |
parent::__construct(array(), array('name' => $name, 'is_defined_test' => false, 'ignore_strict_check' => false, 'always_defined' => false), $lineno);
|
23 |
}
|
24 |
|
25 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
26 |
{
|
27 |
$name = $this->getAttribute('name');
|
28 |
|
vendor/Twig/Node/Expression/NullCoalesce.php
CHANGED
@@ -8,20 +8,20 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
-
public function __construct(
|
14 |
{
|
15 |
-
$test = new
|
16 |
-
new
|
17 |
-
new
|
18 |
$left->getTemplateLine()
|
19 |
);
|
20 |
|
21 |
parent::__construct($test, $left, $right, $lineno);
|
22 |
}
|
23 |
|
24 |
-
public function compile(
|
25 |
{
|
26 |
/*
|
27 |
* This optimizes only one case. PHP 7 also supports more complex expressions
|
@@ -30,7 +30,7 @@ class Twig_SupTwg_Node_Expression_NullCoalesce extends Twig_SupTwg_Node_Expressi
|
|
30 |
* cases might be implemented as an optimizer node visitor, but has not been done
|
31 |
* as benefits are probably not worth the added complexity.
|
32 |
*/
|
33 |
-
if (PHP_VERSION_ID >= 70000 && $this->getNode('expr2') instanceof
|
34 |
$this->getNode('expr2')->setAttribute('always_defined', true);
|
35 |
$compiler
|
36 |
->raw('((')
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_NullCoalesce extends Twig_SupTwgSgg_Node_Expression_Conditional
|
12 |
{
|
13 |
+
public function __construct(Twig_SupTwgSgg_NodeInterface $left, Twig_SupTwgSgg_NodeInterface $right, $lineno)
|
14 |
{
|
15 |
+
$test = new Twig_SupTwgSgg_Node_Expression_Binary_And(
|
16 |
+
new Twig_SupTwgSgg_Node_Expression_Test_Defined(clone $left, 'defined', new Twig_SupTwgSgg_Node(), $left->getTemplateLine()),
|
17 |
+
new Twig_SupTwgSgg_Node_Expression_Unary_Not(new Twig_SupTwgSgg_Node_Expression_Test_Null($left, 'null', new Twig_SupTwgSgg_Node(), $left->getTemplateLine()), $left->getTemplateLine()),
|
18 |
$left->getTemplateLine()
|
19 |
);
|
20 |
|
21 |
parent::__construct($test, $left, $right, $lineno);
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
25 |
{
|
26 |
/*
|
27 |
* This optimizes only one case. PHP 7 also supports more complex expressions
|
30 |
* cases might be implemented as an optimizer node visitor, but has not been done
|
31 |
* as benefits are probably not worth the added complexity.
|
32 |
*/
|
33 |
+
if (PHP_VERSION_ID >= 70000 && $this->getNode('expr2') instanceof Twig_SupTwgSgg_Node_Expression_Name) {
|
34 |
$this->getNode('expr2')->setAttribute('always_defined', true);
|
35 |
$compiler
|
36 |
->raw('((')
|
vendor/Twig/Node/Expression/Parent.php
CHANGED
@@ -15,14 +15,14 @@
|
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
-
class
|
19 |
{
|
20 |
public function __construct($name, $lineno, $tag = null)
|
21 |
{
|
22 |
parent::__construct(array(), array('output' => false, 'name' => $name), $lineno, $tag);
|
23 |
}
|
24 |
|
25 |
-
public function compile(
|
26 |
{
|
27 |
if ($this->getAttribute('output')) {
|
28 |
$compiler
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_SupTwgSgg_Node_Expression_Parent extends Twig_SupTwgSgg_Node_Expression
|
19 |
{
|
20 |
public function __construct($name, $lineno, $tag = null)
|
21 |
{
|
22 |
parent::__construct(array(), array('output' => false, 'name' => $name), $lineno, $tag);
|
23 |
}
|
24 |
|
25 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
26 |
{
|
27 |
if ($this->getAttribute('output')) {
|
28 |
$compiler
|
vendor/Twig/Node/Expression/TempName.php
CHANGED
@@ -8,14 +8,14 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
public function __construct($name, $lineno)
|
14 |
{
|
15 |
parent::__construct(array(), array('name' => $name), $lineno);
|
16 |
}
|
17 |
|
18 |
-
public function compile(
|
19 |
{
|
20 |
$compiler
|
21 |
->raw('$_')
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_TempName extends Twig_SupTwgSgg_Node_Expression
|
12 |
{
|
13 |
public function __construct($name, $lineno)
|
14 |
{
|
15 |
parent::__construct(array(), array('name' => $name), $lineno);
|
16 |
}
|
17 |
|
18 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
19 |
{
|
20 |
$compiler
|
21 |
->raw('$_')
|
vendor/Twig/Node/Expression/Test.php
CHANGED
@@ -8,9 +8,9 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
class
|
12 |
{
|
13 |
-
public function __construct(
|
14 |
{
|
15 |
$nodes = array('node' => $node);
|
16 |
if (null !== $arguments) {
|
@@ -20,7 +20,7 @@ class Twig_SupTwg_Node_Expression_Test extends Twig_SupTwg_Node_Expression_Call
|
|
20 |
parent::__construct($nodes, array('name' => $name), $lineno);
|
21 |
}
|
22 |
|
23 |
-
public function compile(
|
24 |
{
|
25 |
$name = $this->getAttribute('name');
|
26 |
$test = $compiler->getEnvironment()->getTest($name);
|
@@ -28,10 +28,10 @@ class Twig_SupTwg_Node_Expression_Test extends Twig_SupTwg_Node_Expression_Call
|
|
28 |
$this->setAttribute('name', $name);
|
29 |
$this->setAttribute('type', 'test');
|
30 |
$this->setAttribute('thing', $test);
|
31 |
-
if ($test instanceof
|
32 |
$this->setAttribute('callable', $test->getCallable());
|
33 |
}
|
34 |
-
if ($test instanceof
|
35 |
$this->setAttribute('is_variadic', $test->isVariadic());
|
36 |
}
|
37 |
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
class Twig_SupTwgSgg_Node_Expression_Test extends Twig_SupTwgSgg_Node_Expression_Call
|
12 |
{
|
13 |
+
public function __construct(Twig_SupTwgSgg_NodeInterface $node, $name, Twig_SupTwgSgg_NodeInterface $arguments = null, $lineno)
|
14 |
{
|
15 |
$nodes = array('node' => $node);
|
16 |
if (null !== $arguments) {
|
20 |
parent::__construct($nodes, array('name' => $name), $lineno);
|
21 |
}
|
22 |
|
23 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
24 |
{
|
25 |
$name = $this->getAttribute('name');
|
26 |
$test = $compiler->getEnvironment()->getTest($name);
|
28 |
$this->setAttribute('name', $name);
|
29 |
$this->setAttribute('type', 'test');
|
30 |
$this->setAttribute('thing', $test);
|
31 |
+
if ($test instanceof Twig_SupTwgSgg_TestCallableInterface || $test instanceof Twig_SupTwgSgg_SimpleTest) {
|
32 |
$this->setAttribute('callable', $test->getCallable());
|
33 |
}
|
34 |
+
if ($test instanceof Twig_SupTwgSgg_SimpleTest) {
|
35 |
$this->setAttribute('is_variadic', $test->isVariadic());
|
36 |
}
|
37 |
|
vendor/Twig/Node/Expression/Test/Constant.php
CHANGED
@@ -20,9 +20,9 @@
|
|
20 |
*
|
21 |
* @author Fabien Potencier <fabien@symfony.com>
|
22 |
*/
|
23 |
-
class
|
24 |
{
|
25 |
-
public function compile(
|
26 |
{
|
27 |
$compiler
|
28 |
->raw('(')
|
20 |
*
|
21 |
* @author Fabien Potencier <fabien@symfony.com>
|
22 |
*/
|
23 |
+
class Twig_SupTwgSgg_Node_Expression_Test_Constant extends Twig_SupTwgSgg_Node_Expression_Test
|
24 |
{
|
25 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
26 |
{
|
27 |
$compiler
|
28 |
->raw('(')
|
vendor/Twig/Node/Expression/Test/Defined.php
CHANGED
@@ -21,38 +21,38 @@
|
|
21 |
*
|
22 |
* @author Fabien Potencier <fabien@symfony.com>
|
23 |
*/
|
24 |
-
class
|
25 |
{
|
26 |
-
public function __construct(
|
27 |
{
|
28 |
-
if ($node instanceof
|
29 |
$node->setAttribute('is_defined_test', true);
|
30 |
-
} elseif ($node instanceof
|
31 |
$node->setAttribute('is_defined_test', true);
|
32 |
$this->changeIgnoreStrictCheck($node);
|
33 |
-
} elseif ($node instanceof
|
34 |
$node->setAttribute('is_defined_test', true);
|
35 |
-
} elseif ($node instanceof
|
36 |
$node->setAttribute('is_defined_test', true);
|
37 |
-
} elseif ($node instanceof
|
38 |
-
$node = new
|
39 |
} else {
|
40 |
-
throw new
|
41 |
}
|
42 |
|
43 |
parent::__construct($node, $name, $arguments, $lineno);
|
44 |
}
|
45 |
|
46 |
-
protected function changeIgnoreStrictCheck(
|
47 |
{
|
48 |
$node->setAttribute('ignore_strict_check', true);
|
49 |
|
50 |
-
if ($node->getNode('node') instanceof
|
51 |
$this->changeIgnoreStrictCheck($node->getNode('node'));
|
52 |
}
|
53 |
}
|
54 |
|
55 |
-
public function compile(
|
56 |
{
|
57 |
$compiler->subcompile($this->getNode('node'));
|
58 |
}
|
21 |
*
|
22 |
* @author Fabien Potencier <fabien@symfony.com>
|
23 |
*/
|
24 |
+
class Twig_SupTwgSgg_Node_Expression_Test_Defined extends Twig_SupTwgSgg_Node_Expression_Test
|
25 |
{
|
26 |
+
public function __construct(Twig_SupTwgSgg_NodeInterface $node, $name, Twig_SupTwgSgg_NodeInterface $arguments = null, $lineno)
|
27 |
{
|
28 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Expression_Name) {
|
29 |
$node->setAttribute('is_defined_test', true);
|
30 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_Expression_GetAttr) {
|
31 |
$node->setAttribute('is_defined_test', true);
|
32 |
$this->changeIgnoreStrictCheck($node);
|
33 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_Expression_BlockReference) {
|
34 |
$node->setAttribute('is_defined_test', true);
|
35 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_Expression_Function && 'constant' === $node->getAttribute('name')) {
|
36 |
$node->setAttribute('is_defined_test', true);
|
37 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_Expression_Constant || $node instanceof Twig_SupTwgSgg_Node_Expression_Array) {
|
38 |
+
$node = new Twig_SupTwgSgg_Node_Expression_Constant(true, $node->getTemplateLine());
|
39 |
} else {
|
40 |
+
throw new Twig_SupTwgSgg_Error_Syntax('The "defined" test only works with simple variables.', $this->getTemplateLine());
|
41 |
}
|
42 |
|
43 |
parent::__construct($node, $name, $arguments, $lineno);
|
44 |
}
|
45 |
|
46 |
+
protected function changeIgnoreStrictCheck(Twig_SupTwgSgg_Node_Expression_GetAttr $node)
|
47 |
{
|
48 |
$node->setAttribute('ignore_strict_check', true);
|
49 |
|
50 |
+
if ($node->getNode('node') instanceof Twig_SupTwgSgg_Node_Expression_GetAttr) {
|
51 |
$this->changeIgnoreStrictCheck($node->getNode('node'));
|
52 |
}
|
53 |
}
|
54 |
|
55 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
56 |
{
|
57 |
$compiler->subcompile($this->getNode('node'));
|
58 |
}
|
vendor/Twig/Node/Expression/Test/Divisibleby.php
CHANGED
@@ -18,9 +18,9 @@
|
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
-
public function compile(
|
24 |
{
|
25 |
$compiler
|
26 |
->raw('(0 == ')
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
+
class Twig_SupTwgSgg_Node_Expression_Test_Divisibleby extends Twig_SupTwgSgg_Node_Expression_Test
|
22 |
{
|
23 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
24 |
{
|
25 |
$compiler
|
26 |
->raw('(0 == ')
|
vendor/Twig/Node/Expression/Test/Even.php
CHANGED
@@ -18,9 +18,9 @@
|
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
-
public function compile(
|
24 |
{
|
25 |
$compiler
|
26 |
->raw('(')
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
+
class Twig_SupTwgSgg_Node_Expression_Test_Even extends Twig_SupTwgSgg_Node_Expression_Test
|
22 |
{
|
23 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
24 |
{
|
25 |
$compiler
|
26 |
->raw('(')
|
vendor/Twig/Node/Expression/Test/Null.php
CHANGED
@@ -18,9 +18,9 @@
|
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
-
public function compile(
|
24 |
{
|
25 |
$compiler
|
26 |
->raw('(null === ')
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
+
class Twig_SupTwgSgg_Node_Expression_Test_Null extends Twig_SupTwgSgg_Node_Expression_Test
|
22 |
{
|
23 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
24 |
{
|
25 |
$compiler
|
26 |
->raw('(null === ')
|
vendor/Twig/Node/Expression/Test/Odd.php
CHANGED
@@ -18,9 +18,9 @@
|
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
-
public function compile(
|
24 |
{
|
25 |
$compiler
|
26 |
->raw('(')
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
+
class Twig_SupTwgSgg_Node_Expression_Test_Odd extends Twig_SupTwgSgg_Node_Expression_Test
|
22 |
{
|
23 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
24 |
{
|
25 |
$compiler
|
26 |
->raw('(')
|
vendor/Twig/Node/Expression/Test/Sameas.php
CHANGED
@@ -14,9 +14,9 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
-
public function compile(
|
20 |
{
|
21 |
$compiler
|
22 |
->raw('(')
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Node_Expression_Test_Sameas extends Twig_SupTwgSgg_Node_Expression_Test
|
18 |
{
|
19 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
20 |
{
|
21 |
$compiler
|
22 |
->raw('(')
|
vendor/Twig/Node/Expression/Unary.php
CHANGED
@@ -9,19 +9,19 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
abstract class
|
13 |
{
|
14 |
-
public function __construct(
|
15 |
{
|
16 |
parent::__construct(array('node' => $node), array(), $lineno);
|
17 |
}
|
18 |
|
19 |
-
public function compile(
|
20 |
{
|
21 |
$compiler->raw(' ');
|
22 |
$this->operator($compiler);
|
23 |
$compiler->subcompile($this->getNode('node'));
|
24 |
}
|
25 |
|
26 |
-
abstract public function operator(
|
27 |
}
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
abstract class Twig_SupTwgSgg_Node_Expression_Unary extends Twig_SupTwgSgg_Node_Expression
|
13 |
{
|
14 |
+
public function __construct(Twig_SupTwgSgg_NodeInterface $node, $lineno)
|
15 |
{
|
16 |
parent::__construct(array('node' => $node), array(), $lineno);
|
17 |
}
|
18 |
|
19 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
20 |
{
|
21 |
$compiler->raw(' ');
|
22 |
$this->operator($compiler);
|
23 |
$compiler->subcompile($this->getNode('node'));
|
24 |
}
|
25 |
|
26 |
+
abstract public function operator(Twig_SupTwgSgg_Compiler $compiler);
|
27 |
}
|
vendor/Twig/Node/Expression/Unary/Neg.php
CHANGED
@@ -9,9 +9,9 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
-
public function operator(
|
15 |
{
|
16 |
$compiler->raw('-');
|
17 |
}
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_Unary_Neg extends Twig_SupTwgSgg_Node_Expression_Unary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
15 |
{
|
16 |
$compiler->raw('-');
|
17 |
}
|
vendor/Twig/Node/Expression/Unary/Not.php
CHANGED
@@ -9,9 +9,9 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
-
public function operator(
|
15 |
{
|
16 |
$compiler->raw('!');
|
17 |
}
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_Unary_Not extends Twig_SupTwgSgg_Node_Expression_Unary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
15 |
{
|
16 |
$compiler->raw('!');
|
17 |
}
|
vendor/Twig/Node/Expression/Unary/Pos.php
CHANGED
@@ -9,9 +9,9 @@
|
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
-
class
|
13 |
{
|
14 |
-
public function operator(
|
15 |
{
|
16 |
$compiler->raw('+');
|
17 |
}
|
9 |
* For the full copyright and license information, please view the LICENSE
|
10 |
* file that was distributed with this source code.
|
11 |
*/
|
12 |
+
class Twig_SupTwgSgg_Node_Expression_Unary_Pos extends Twig_SupTwgSgg_Node_Expression_Unary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSgg_Compiler $compiler)
|
15 |
{
|
16 |
$compiler->raw('+');
|
17 |
}
|
vendor/Twig/Node/Flush.php
CHANGED
@@ -14,14 +14,14 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
public function __construct($lineno, $tag)
|
20 |
{
|
21 |
parent::__construct(array(), array(), $lineno, $tag);
|
22 |
}
|
23 |
|
24 |
-
public function compile(
|
25 |
{
|
26 |
$compiler
|
27 |
->addDebugInfo($this)
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Node_Flush extends Twig_SupTwgSgg_Node
|
18 |
{
|
19 |
public function __construct($lineno, $tag)
|
20 |
{
|
21 |
parent::__construct(array(), array(), $lineno, $tag);
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
25 |
{
|
26 |
$compiler
|
27 |
->addDebugInfo($this)
|
vendor/Twig/Node/For.php
CHANGED
@@ -15,16 +15,16 @@
|
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
-
class
|
19 |
{
|
20 |
protected $loop;
|
21 |
|
22 |
-
public function __construct(
|
23 |
{
|
24 |
-
$body = new
|
25 |
|
26 |
if (null !== $ifexpr) {
|
27 |
-
$body = new
|
28 |
}
|
29 |
|
30 |
$nodes = array('key_target' => $keyTarget, 'value_target' => $valueTarget, 'seq' => $seq, 'body' => $body);
|
@@ -35,12 +35,12 @@ class Twig_SupTwg_Node_For extends Twig_SupTwg_Node
|
|
35 |
parent::__construct($nodes, array('with_loop' => true, 'ifexpr' => null !== $ifexpr), $lineno, $tag);
|
36 |
}
|
37 |
|
38 |
-
public function compile(
|
39 |
{
|
40 |
$compiler
|
41 |
->addDebugInfo($this)
|
42 |
->write("\$context['_parent'] = \$context;\n")
|
43 |
-
->write("\$context['_seq'] =
|
44 |
->subcompile($this->getNode('seq'))
|
45 |
->raw(");\n")
|
46 |
;
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_SupTwgSgg_Node_For extends Twig_SupTwgSgg_Node
|
19 |
{
|
20 |
protected $loop;
|
21 |
|
22 |
+
public function __construct(Twig_SupTwgSgg_Node_Expression_AssignName $keyTarget, Twig_SupTwgSgg_Node_Expression_AssignName $valueTarget, Twig_SupTwgSgg_Node_Expression $seq, Twig_SupTwgSgg_Node_Expression $ifexpr = null, Twig_SupTwgSgg_NodeInterface $body, Twig_SupTwgSgg_NodeInterface $else = null, $lineno, $tag = null)
|
23 |
{
|
24 |
+
$body = new Twig_SupTwgSgg_Node(array($body, $this->loop = new Twig_SupTwgSgg_Node_ForLoop($lineno, $tag)));
|
25 |
|
26 |
if (null !== $ifexpr) {
|
27 |
+
$body = new Twig_SupTwgSgg_Node_If(new Twig_SupTwgSgg_Node(array($ifexpr, $body)), null, $lineno, $tag);
|
28 |
}
|
29 |
|
30 |
$nodes = array('key_target' => $keyTarget, 'value_target' => $valueTarget, 'seq' => $seq, 'body' => $body);
|
35 |
parent::__construct($nodes, array('with_loop' => true, 'ifexpr' => null !== $ifexpr), $lineno, $tag);
|
36 |
}
|
37 |
|
38 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
39 |
{
|
40 |
$compiler
|
41 |
->addDebugInfo($this)
|
42 |
->write("\$context['_parent'] = \$context;\n")
|
43 |
+
->write("\$context['_seq'] = Twig_SupTwgSgg_ensure_traversable(")
|
44 |
->subcompile($this->getNode('seq'))
|
45 |
->raw(");\n")
|
46 |
;
|
vendor/Twig/Node/ForLoop.php
CHANGED
@@ -14,14 +14,14 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
public function __construct($lineno, $tag = null)
|
20 |
{
|
21 |
parent::__construct(array(), array('with_loop' => false, 'ifexpr' => false, 'else' => false), $lineno, $tag);
|
22 |
}
|
23 |
|
24 |
-
public function compile(
|
25 |
{
|
26 |
if ($this->getAttribute('else')) {
|
27 |
$compiler->write("\$context['_iterated'] = true;\n");
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Node_ForLoop extends Twig_SupTwgSgg_Node
|
18 |
{
|
19 |
public function __construct($lineno, $tag = null)
|
20 |
{
|
21 |
parent::__construct(array(), array('with_loop' => false, 'ifexpr' => false, 'else' => false), $lineno, $tag);
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
25 |
{
|
26 |
if ($this->getAttribute('else')) {
|
27 |
$compiler->write("\$context['_iterated'] = true;\n");
|
vendor/Twig/Node/If.php
CHANGED
@@ -15,9 +15,9 @@
|
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
-
class
|
19 |
{
|
20 |
-
public function __construct(
|
21 |
{
|
22 |
$nodes = array('tests' => $tests);
|
23 |
if (null !== $else) {
|
@@ -27,7 +27,7 @@ class Twig_SupTwg_Node_If extends Twig_SupTwg_Node
|
|
27 |
parent::__construct($nodes, array(), $lineno, $tag);
|
28 |
}
|
29 |
|
30 |
-
public function compile(
|
31 |
{
|
32 |
$compiler->addDebugInfo($this);
|
33 |
for ($i = 0, $count = count($this->getNode('tests')); $i < $count; $i += 2) {
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_SupTwgSgg_Node_If extends Twig_SupTwgSgg_Node
|
19 |
{
|
20 |
+
public function __construct(Twig_SupTwgSgg_NodeInterface $tests, Twig_SupTwgSgg_NodeInterface $else = null, $lineno, $tag = null)
|
21 |
{
|
22 |
$nodes = array('tests' => $tests);
|
23 |
if (null !== $else) {
|
27 |
parent::__construct($nodes, array(), $lineno, $tag);
|
28 |
}
|
29 |
|
30 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
31 |
{
|
32 |
$compiler->addDebugInfo($this);
|
33 |
for ($i = 0, $count = count($this->getNode('tests')); $i < $count; $i += 2) {
|
vendor/Twig/Node/Import.php
CHANGED
@@ -14,14 +14,14 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
-
public function __construct(
|
20 |
{
|
21 |
parent::__construct(array('expr' => $expr, 'var' => $var), array(), $lineno, $tag);
|
22 |
}
|
23 |
|
24 |
-
public function compile(
|
25 |
{
|
26 |
$compiler
|
27 |
->addDebugInfo($this)
|
@@ -30,7 +30,7 @@ class Twig_SupTwg_Node_Import extends Twig_SupTwg_Node
|
|
30 |
->raw(' = ')
|
31 |
;
|
32 |
|
33 |
-
if ($this->getNode('expr') instanceof
|
34 |
$compiler->raw('$this');
|
35 |
} else {
|
36 |
$compiler
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Node_Import extends Twig_SupTwgSgg_Node
|
18 |
{
|
19 |
+
public function __construct(Twig_SupTwgSgg_Node_Expression $expr, Twig_SupTwgSgg_Node_Expression $var, $lineno, $tag = null)
|
20 |
{
|
21 |
parent::__construct(array('expr' => $expr, 'var' => $var), array(), $lineno, $tag);
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
25 |
{
|
26 |
$compiler
|
27 |
->addDebugInfo($this)
|
30 |
->raw(' = ')
|
31 |
;
|
32 |
|
33 |
+
if ($this->getNode('expr') instanceof Twig_SupTwgSgg_Node_Expression_Name && '_self' === $this->getNode('expr')->getAttribute('name')) {
|
34 |
$compiler->raw('$this');
|
35 |
} else {
|
36 |
$compiler
|
vendor/Twig/Node/Include.php
CHANGED
@@ -15,9 +15,9 @@
|
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
-
class
|
19 |
{
|
20 |
-
public function __construct(
|
21 |
{
|
22 |
$nodes = array('expr' => $expr);
|
23 |
if (null !== $variables) {
|
@@ -27,7 +27,7 @@ class Twig_SupTwg_Node_Include extends Twig_SupTwg_Node implements Twig_SupTwg_N
|
|
27 |
parent::__construct($nodes, array('only' => (bool) $only, 'ignore_missing' => (bool) $ignoreMissing), $lineno, $tag);
|
28 |
}
|
29 |
|
30 |
-
public function compile(
|
31 |
{
|
32 |
$compiler->addDebugInfo($this);
|
33 |
|
@@ -49,7 +49,7 @@ class Twig_SupTwg_Node_Include extends Twig_SupTwg_Node implements Twig_SupTwg_N
|
|
49 |
if ($this->getAttribute('ignore_missing')) {
|
50 |
$compiler
|
51 |
->outdent()
|
52 |
-
->write("} catch (
|
53 |
->indent()
|
54 |
->write("// ignore missing template\n")
|
55 |
->outdent()
|
@@ -58,7 +58,7 @@ class Twig_SupTwg_Node_Include extends Twig_SupTwg_Node implements Twig_SupTwg_N
|
|
58 |
}
|
59 |
}
|
60 |
|
61 |
-
protected function addGetTemplate(
|
62 |
{
|
63 |
$compiler
|
64 |
->write('$this->loadTemplate(')
|
@@ -71,7 +71,7 @@ class Twig_SupTwg_Node_Include extends Twig_SupTwg_Node implements Twig_SupTwg_N
|
|
71 |
;
|
72 |
}
|
73 |
|
74 |
-
protected function addTemplateArguments(
|
75 |
{
|
76 |
if (!$this->hasNode('variables')) {
|
77 |
$compiler->raw(false === $this->getAttribute('only') ? '$context' : 'array()');
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_SupTwgSgg_Node_Include extends Twig_SupTwgSgg_Node implements Twig_SupTwgSgg_NodeOutputInterface
|
19 |
{
|
20 |
+
public function __construct(Twig_SupTwgSgg_Node_Expression $expr, Twig_SupTwgSgg_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno = null, $tag = null)
|
21 |
{
|
22 |
$nodes = array('expr' => $expr);
|
23 |
if (null !== $variables) {
|
27 |
parent::__construct($nodes, array('only' => (bool) $only, 'ignore_missing' => (bool) $ignoreMissing), $lineno, $tag);
|
28 |
}
|
29 |
|
30 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
31 |
{
|
32 |
$compiler->addDebugInfo($this);
|
33 |
|
49 |
if ($this->getAttribute('ignore_missing')) {
|
50 |
$compiler
|
51 |
->outdent()
|
52 |
+
->write("} catch (Twig_SupTwgSgg_Error_Loader \$e) {\n")
|
53 |
->indent()
|
54 |
->write("// ignore missing template\n")
|
55 |
->outdent()
|
58 |
}
|
59 |
}
|
60 |
|
61 |
+
protected function addGetTemplate(Twig_SupTwgSgg_Compiler $compiler)
|
62 |
{
|
63 |
$compiler
|
64 |
->write('$this->loadTemplate(')
|
71 |
;
|
72 |
}
|
73 |
|
74 |
+
protected function addTemplateArguments(Twig_SupTwgSgg_Compiler $compiler)
|
75 |
{
|
76 |
if (!$this->hasNode('variables')) {
|
77 |
$compiler->raw(false === $this->getAttribute('only') ? '$context' : 'array()');
|
vendor/Twig/Node/Macro.php
CHANGED
@@ -14,22 +14,22 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
const VARARGS_NAME = 'varargs';
|
20 |
|
21 |
-
public function __construct($name,
|
22 |
{
|
23 |
foreach ($arguments as $argumentName => $argument) {
|
24 |
if (self::VARARGS_NAME === $argumentName) {
|
25 |
-
throw new
|
26 |
}
|
27 |
}
|
28 |
|
29 |
parent::__construct(array('body' => $body, 'arguments' => $arguments), array('name' => $name), $lineno, $tag);
|
30 |
}
|
31 |
|
32 |
-
public function compile(
|
33 |
{
|
34 |
$compiler
|
35 |
->addDebugInfo($this)
|
@@ -115,7 +115,7 @@ class Twig_SupTwg_Node_Macro extends Twig_SupTwg_Node
|
|
115 |
->write("throw \$e;\n")
|
116 |
->outdent()
|
117 |
->write("}\n\n")
|
118 |
-
->write("return ('' === \$tmp = ob_get_clean()) ? '' : new
|
119 |
->outdent()
|
120 |
->write("}\n\n")
|
121 |
;
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Node_Macro extends Twig_SupTwgSgg_Node
|
18 |
{
|
19 |
const VARARGS_NAME = 'varargs';
|
20 |
|
21 |
+
public function __construct($name, Twig_SupTwgSgg_NodeInterface $body, Twig_SupTwgSgg_NodeInterface $arguments, $lineno, $tag = null)
|
22 |
{
|
23 |
foreach ($arguments as $argumentName => $argument) {
|
24 |
if (self::VARARGS_NAME === $argumentName) {
|
25 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('The argument "%s" in macro "%s" cannot be defined because the variable "%s" is reserved for arbitrary arguments.', self::VARARGS_NAME, $name, self::VARARGS_NAME), $argument->getTemplateLine());
|
26 |
}
|
27 |
}
|
28 |
|
29 |
parent::__construct(array('body' => $body, 'arguments' => $arguments), array('name' => $name), $lineno, $tag);
|
30 |
}
|
31 |
|
32 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
33 |
{
|
34 |
$compiler
|
35 |
->addDebugInfo($this)
|
115 |
->write("throw \$e;\n")
|
116 |
->outdent()
|
117 |
->write("}\n\n")
|
118 |
+
->write("return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_SupTwgSgg_Markup(\$tmp, \$this->env->getCharset());\n")
|
119 |
->outdent()
|
120 |
->write("}\n\n")
|
121 |
;
|
vendor/Twig/Node/Module.php
CHANGED
@@ -19,15 +19,15 @@
|
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*/
|
22 |
-
class
|
23 |
{
|
24 |
private $source;
|
25 |
|
26 |
-
public function __construct(
|
27 |
{
|
28 |
-
if (!$name instanceof
|
29 |
-
|
30 |
-
$this->source = new
|
31 |
} else {
|
32 |
$this->source = $name;
|
33 |
}
|
@@ -37,11 +37,11 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
37 |
'blocks' => $blocks,
|
38 |
'macros' => $macros,
|
39 |
'traits' => $traits,
|
40 |
-
'display_start' => new
|
41 |
-
'display_end' => new
|
42 |
-
'constructor_start' => new
|
43 |
-
'constructor_end' => new
|
44 |
-
'class_end' => new
|
45 |
);
|
46 |
if (null !== $parent) {
|
47 |
$nodes['parent'] = $parent;
|
@@ -66,7 +66,7 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
66 |
$this->setAttribute('index', $index);
|
67 |
}
|
68 |
|
69 |
-
public function compile(
|
70 |
{
|
71 |
$this->compileTemplate($compiler);
|
72 |
|
@@ -75,7 +75,7 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
75 |
}
|
76 |
}
|
77 |
|
78 |
-
protected function compileTemplate(
|
79 |
{
|
80 |
if (!$this->getAttribute('index')) {
|
81 |
$compiler->write('<?php');
|
@@ -87,7 +87,7 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
87 |
count($this->getNode('blocks'))
|
88 |
|| count($this->getNode('traits'))
|
89 |
|| !$this->hasNode('parent')
|
90 |
-
|| $this->getNode('parent') instanceof
|
91 |
|| count($this->getNode('constructor_start'))
|
92 |
|| count($this->getNode('constructor_end'))
|
93 |
) {
|
@@ -115,7 +115,7 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
115 |
$this->compileClassFooter($compiler);
|
116 |
}
|
117 |
|
118 |
-
protected function compileGetParent(
|
119 |
{
|
120 |
if (!$this->hasNode('parent')) {
|
121 |
return;
|
@@ -129,7 +129,7 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
129 |
->write('return ')
|
130 |
;
|
131 |
|
132 |
-
if ($parent instanceof
|
133 |
$compiler->subcompile($parent);
|
134 |
} else {
|
135 |
$compiler
|
@@ -150,7 +150,7 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
150 |
;
|
151 |
}
|
152 |
|
153 |
-
protected function compileClassHeader(
|
154 |
{
|
155 |
$compiler
|
156 |
->write("\n\n")
|
@@ -163,10 +163,10 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
163 |
;
|
164 |
}
|
165 |
|
166 |
-
protected function compileConstructor(
|
167 |
{
|
168 |
$compiler
|
169 |
-
->write("public function __construct(
|
170 |
->indent()
|
171 |
->subcompile($this->getNode('constructor_start'))
|
172 |
->write("parent::__construct(\$env);\n\n")
|
@@ -175,7 +175,7 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
175 |
// parent
|
176 |
if (!$this->hasNode('parent')) {
|
177 |
$compiler->write("\$this->parent = false;\n\n");
|
178 |
-
} elseif (($parent = $this->getNode('parent')) && $parent instanceof
|
179 |
$compiler
|
180 |
->addDebugInfo($parent)
|
181 |
->write('$this->parent = $this->loadTemplate(')
|
@@ -198,7 +198,7 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
198 |
->addDebugInfo($trait->getNode('template'))
|
199 |
->write(sprintf("if (!\$_trait_%s->isTraitable()) {\n", $i))
|
200 |
->indent()
|
201 |
-
->write("throw new
|
202 |
->subcompile($trait->getNode('template'))
|
203 |
->raw(".'\" cannot be used as a trait.');\n")
|
204 |
->outdent()
|
@@ -212,7 +212,7 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
212 |
->string($key)
|
213 |
->raw("])) {\n")
|
214 |
->indent()
|
215 |
-
->write("throw new
|
216 |
->string($key)
|
217 |
->raw(' is not defined in trait ')
|
218 |
->subcompile($trait->getNode('template'))
|
@@ -292,7 +292,7 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
292 |
;
|
293 |
}
|
294 |
|
295 |
-
protected function compileDisplay(
|
296 |
{
|
297 |
$compiler
|
298 |
->write("protected function doDisplay(array \$context, array \$blocks = array())\n", "{\n")
|
@@ -304,7 +304,7 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
304 |
if ($this->hasNode('parent')) {
|
305 |
$parent = $this->getNode('parent');
|
306 |
$compiler->addDebugInfo($parent);
|
307 |
-
if ($parent instanceof
|
308 |
$compiler->write('$this->parent');
|
309 |
} else {
|
310 |
$compiler->write('$this->getParent($context)');
|
@@ -319,7 +319,7 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
319 |
;
|
320 |
}
|
321 |
|
322 |
-
protected function compileClassFooter(
|
323 |
{
|
324 |
$compiler
|
325 |
->subcompile($this->getNode('class_end'))
|
@@ -328,12 +328,12 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
328 |
;
|
329 |
}
|
330 |
|
331 |
-
protected function compileMacros(
|
332 |
{
|
333 |
$compiler->subcompile($this->getNode('macros'));
|
334 |
}
|
335 |
|
336 |
-
protected function compileGetTemplateName(
|
337 |
{
|
338 |
$compiler
|
339 |
->write("public function getTemplateName()\n", "{\n")
|
@@ -346,7 +346,7 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
346 |
;
|
347 |
}
|
348 |
|
349 |
-
protected function compileIsTraitable(
|
350 |
{
|
351 |
// A template can be used as a trait if:
|
352 |
// * it has no parent
|
@@ -357,14 +357,14 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
357 |
// only contains blocks and use statements.
|
358 |
$traitable = !$this->hasNode('parent') && 0 === count($this->getNode('macros'));
|
359 |
if ($traitable) {
|
360 |
-
if ($this->getNode('body') instanceof
|
361 |
$nodes = $this->getNode('body')->getNode(0);
|
362 |
} else {
|
363 |
$nodes = $this->getNode('body');
|
364 |
}
|
365 |
|
366 |
if (!count($nodes)) {
|
367 |
-
$nodes = new
|
368 |
}
|
369 |
|
370 |
foreach ($nodes as $node) {
|
@@ -372,11 +372,11 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
372 |
continue;
|
373 |
}
|
374 |
|
375 |
-
if ($node instanceof
|
376 |
continue;
|
377 |
}
|
378 |
|
379 |
-
if ($node instanceof
|
380 |
continue;
|
381 |
}
|
382 |
|
@@ -398,7 +398,7 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
398 |
;
|
399 |
}
|
400 |
|
401 |
-
protected function compileDebugInfo(
|
402 |
{
|
403 |
$compiler
|
404 |
->write("public function getDebugInfo()\n", "{\n")
|
@@ -409,13 +409,13 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
409 |
;
|
410 |
}
|
411 |
|
412 |
-
protected function compileGetSource(
|
413 |
{
|
414 |
$compiler
|
415 |
->write("/** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */\n")
|
416 |
->write("public function getSource()\n", "{\n")
|
417 |
->indent()
|
418 |
-
->write("
|
419 |
->write('return $this->getSourceContext()->getCode();')
|
420 |
->raw("\n")
|
421 |
->outdent()
|
@@ -423,12 +423,12 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
423 |
;
|
424 |
}
|
425 |
|
426 |
-
protected function compileGetSourceContext(
|
427 |
{
|
428 |
$compiler
|
429 |
->write("public function getSourceContext()\n", "{\n")
|
430 |
->indent()
|
431 |
-
->write('return new
|
432 |
->string($compiler->getEnvironment()->isDebug() ? $this->source->getCode() : '')
|
433 |
->raw(', ')
|
434 |
->string($this->source->getName())
|
@@ -440,9 +440,9 @@ class Twig_SupTwg_Node_Module extends Twig_SupTwg_Node
|
|
440 |
;
|
441 |
}
|
442 |
|
443 |
-
protected function compileLoadTemplate(
|
444 |
{
|
445 |
-
if ($node instanceof
|
446 |
$compiler
|
447 |
->write(sprintf('%s = $this->loadTemplate(', $var))
|
448 |
->subcompile($node)
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*/
|
22 |
+
class Twig_SupTwgSgg_Node_Module extends Twig_SupTwgSgg_Node
|
23 |
{
|
24 |
private $source;
|
25 |
|
26 |
+
public function __construct(Twig_SupTwgSgg_NodeInterface $body, Twig_SupTwgSgg_Node_Expression $parent = null, Twig_SupTwgSgg_NodeInterface $blocks, Twig_SupTwgSgg_NodeInterface $macros, Twig_SupTwgSgg_NodeInterface $traits, $embeddedTemplates, $name, $source = '')
|
27 |
{
|
28 |
+
if (!$name instanceof Twig_SupTwgSgg_Source) {
|
29 |
+
//@trigger_error(sprintf('Passing a string as the $name argument of %s() is deprecated since version 1.27. Pass a Twig_SupTwgSgg_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
30 |
+
$this->source = new Twig_SupTwgSgg_Source($source, $name);
|
31 |
} else {
|
32 |
$this->source = $name;
|
33 |
}
|
37 |
'blocks' => $blocks,
|
38 |
'macros' => $macros,
|
39 |
'traits' => $traits,
|
40 |
+
'display_start' => new Twig_SupTwgSgg_Node(),
|
41 |
+
'display_end' => new Twig_SupTwgSgg_Node(),
|
42 |
+
'constructor_start' => new Twig_SupTwgSgg_Node(),
|
43 |
+
'constructor_end' => new Twig_SupTwgSgg_Node(),
|
44 |
+
'class_end' => new Twig_SupTwgSgg_Node(),
|
45 |
);
|
46 |
if (null !== $parent) {
|
47 |
$nodes['parent'] = $parent;
|
66 |
$this->setAttribute('index', $index);
|
67 |
}
|
68 |
|
69 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
70 |
{
|
71 |
$this->compileTemplate($compiler);
|
72 |
|
75 |
}
|
76 |
}
|
77 |
|
78 |
+
protected function compileTemplate(Twig_SupTwgSgg_Compiler $compiler)
|
79 |
{
|
80 |
if (!$this->getAttribute('index')) {
|
81 |
$compiler->write('<?php');
|
87 |
count($this->getNode('blocks'))
|
88 |
|| count($this->getNode('traits'))
|
89 |
|| !$this->hasNode('parent')
|
90 |
+
|| $this->getNode('parent') instanceof Twig_SupTwgSgg_Node_Expression_Constant
|
91 |
|| count($this->getNode('constructor_start'))
|
92 |
|| count($this->getNode('constructor_end'))
|
93 |
) {
|
115 |
$this->compileClassFooter($compiler);
|
116 |
}
|
117 |
|
118 |
+
protected function compileGetParent(Twig_SupTwgSgg_Compiler $compiler)
|
119 |
{
|
120 |
if (!$this->hasNode('parent')) {
|
121 |
return;
|
129 |
->write('return ')
|
130 |
;
|
131 |
|
132 |
+
if ($parent instanceof Twig_SupTwgSgg_Node_Expression_Constant) {
|
133 |
$compiler->subcompile($parent);
|
134 |
} else {
|
135 |
$compiler
|
150 |
;
|
151 |
}
|
152 |
|
153 |
+
protected function compileClassHeader(Twig_SupTwgSgg_Compiler $compiler)
|
154 |
{
|
155 |
$compiler
|
156 |
->write("\n\n")
|
163 |
;
|
164 |
}
|
165 |
|
166 |
+
protected function compileConstructor(Twig_SupTwgSgg_Compiler $compiler)
|
167 |
{
|
168 |
$compiler
|
169 |
+
->write("public function __construct(Twig_SupTwgSgg_Environment \$env)\n", "{\n")
|
170 |
->indent()
|
171 |
->subcompile($this->getNode('constructor_start'))
|
172 |
->write("parent::__construct(\$env);\n\n")
|
175 |
// parent
|
176 |
if (!$this->hasNode('parent')) {
|
177 |
$compiler->write("\$this->parent = false;\n\n");
|
178 |
+
} elseif (($parent = $this->getNode('parent')) && $parent instanceof Twig_SupTwgSgg_Node_Expression_Constant) {
|
179 |
$compiler
|
180 |
->addDebugInfo($parent)
|
181 |
->write('$this->parent = $this->loadTemplate(')
|
198 |
->addDebugInfo($trait->getNode('template'))
|
199 |
->write(sprintf("if (!\$_trait_%s->isTraitable()) {\n", $i))
|
200 |
->indent()
|
201 |
+
->write("throw new Twig_SupTwgSgg_Error_Runtime('Template \"'.")
|
202 |
->subcompile($trait->getNode('template'))
|
203 |
->raw(".'\" cannot be used as a trait.');\n")
|
204 |
->outdent()
|
212 |
->string($key)
|
213 |
->raw("])) {\n")
|
214 |
->indent()
|
215 |
+
->write("throw new Twig_SupTwgSgg_Error_Runtime(sprintf('Block ")
|
216 |
->string($key)
|
217 |
->raw(' is not defined in trait ')
|
218 |
->subcompile($trait->getNode('template'))
|
292 |
;
|
293 |
}
|
294 |
|
295 |
+
protected function compileDisplay(Twig_SupTwgSgg_Compiler $compiler)
|
296 |
{
|
297 |
$compiler
|
298 |
->write("protected function doDisplay(array \$context, array \$blocks = array())\n", "{\n")
|
304 |
if ($this->hasNode('parent')) {
|
305 |
$parent = $this->getNode('parent');
|
306 |
$compiler->addDebugInfo($parent);
|
307 |
+
if ($parent instanceof Twig_SupTwgSgg_Node_Expression_Constant) {
|
308 |
$compiler->write('$this->parent');
|
309 |
} else {
|
310 |
$compiler->write('$this->getParent($context)');
|
319 |
;
|
320 |
}
|
321 |
|
322 |
+
protected function compileClassFooter(Twig_SupTwgSgg_Compiler $compiler)
|
323 |
{
|
324 |
$compiler
|
325 |
->subcompile($this->getNode('class_end'))
|
328 |
;
|
329 |
}
|
330 |
|
331 |
+
protected function compileMacros(Twig_SupTwgSgg_Compiler $compiler)
|
332 |
{
|
333 |
$compiler->subcompile($this->getNode('macros'));
|
334 |
}
|
335 |
|
336 |
+
protected function compileGetTemplateName(Twig_SupTwgSgg_Compiler $compiler)
|
337 |
{
|
338 |
$compiler
|
339 |
->write("public function getTemplateName()\n", "{\n")
|
346 |
;
|
347 |
}
|
348 |
|
349 |
+
protected function compileIsTraitable(Twig_SupTwgSgg_Compiler $compiler)
|
350 |
{
|
351 |
// A template can be used as a trait if:
|
352 |
// * it has no parent
|
357 |
// only contains blocks and use statements.
|
358 |
$traitable = !$this->hasNode('parent') && 0 === count($this->getNode('macros'));
|
359 |
if ($traitable) {
|
360 |
+
if ($this->getNode('body') instanceof Twig_SupTwgSgg_Node_Body) {
|
361 |
$nodes = $this->getNode('body')->getNode(0);
|
362 |
} else {
|
363 |
$nodes = $this->getNode('body');
|
364 |
}
|
365 |
|
366 |
if (!count($nodes)) {
|
367 |
+
$nodes = new Twig_SupTwgSgg_Node(array($nodes));
|
368 |
}
|
369 |
|
370 |
foreach ($nodes as $node) {
|
372 |
continue;
|
373 |
}
|
374 |
|
375 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Text && ctype_space($node->getAttribute('data'))) {
|
376 |
continue;
|
377 |
}
|
378 |
|
379 |
+
if ($node instanceof Twig_SupTwgSgg_Node_BlockReference) {
|
380 |
continue;
|
381 |
}
|
382 |
|
398 |
;
|
399 |
}
|
400 |
|
401 |
+
protected function compileDebugInfo(Twig_SupTwgSgg_Compiler $compiler)
|
402 |
{
|
403 |
$compiler
|
404 |
->write("public function getDebugInfo()\n", "{\n")
|
409 |
;
|
410 |
}
|
411 |
|
412 |
+
protected function compileGetSource(Twig_SupTwgSgg_Compiler $compiler)
|
413 |
{
|
414 |
$compiler
|
415 |
->write("/** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */\n")
|
416 |
->write("public function getSource()\n", "{\n")
|
417 |
->indent()
|
418 |
+
->write("//@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', E_USER_DEPRECATED);\n\n")
|
419 |
->write('return $this->getSourceContext()->getCode();')
|
420 |
->raw("\n")
|
421 |
->outdent()
|
423 |
;
|
424 |
}
|
425 |
|
426 |
+
protected function compileGetSourceContext(Twig_SupTwgSgg_Compiler $compiler)
|
427 |
{
|
428 |
$compiler
|
429 |
->write("public function getSourceContext()\n", "{\n")
|
430 |
->indent()
|
431 |
+
->write('return new Twig_SupTwgSgg_Source(')
|
432 |
->string($compiler->getEnvironment()->isDebug() ? $this->source->getCode() : '')
|
433 |
->raw(', ')
|
434 |
->string($this->source->getName())
|
440 |
;
|
441 |
}
|
442 |
|
443 |
+
protected function compileLoadTemplate(Twig_SupTwgSgg_Compiler $compiler, $node, $var)
|
444 |
{
|
445 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Expression_Constant) {
|
446 |
$compiler
|
447 |
->write(sprintf('%s = $this->loadTemplate(', $var))
|
448 |
->subcompile($node)
|
vendor/Twig/Node/Print.php
CHANGED
@@ -15,14 +15,14 @@
|
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
-
class
|
19 |
{
|
20 |
-
public function __construct(
|
21 |
{
|
22 |
parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
|
23 |
}
|
24 |
|
25 |
-
public function compile(
|
26 |
{
|
27 |
$compiler
|
28 |
->addDebugInfo($this)
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_SupTwgSgg_Node_Print extends Twig_SupTwgSgg_Node implements Twig_SupTwgSgg_NodeOutputInterface
|
19 |
{
|
20 |
+
public function __construct(Twig_SupTwgSgg_Node_Expression $expr, $lineno, $tag = null)
|
21 |
{
|
22 |
parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
|
23 |
}
|
24 |
|
25 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
26 |
{
|
27 |
$compiler
|
28 |
->addDebugInfo($this)
|
vendor/Twig/Node/Sandbox.php
CHANGED
@@ -14,18 +14,18 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
-
public function __construct(
|
20 |
{
|
21 |
parent::__construct(array('body' => $body), array(), $lineno, $tag);
|
22 |
}
|
23 |
|
24 |
-
public function compile(
|
25 |
{
|
26 |
$compiler
|
27 |
->addDebugInfo($this)
|
28 |
-
->write("\$sandbox = \$this->env->getExtension('
|
29 |
->write("if (!\$alreadySandboxed = \$sandbox->isSandboxed()) {\n")
|
30 |
->indent()
|
31 |
->write("\$sandbox->enableSandbox();\n")
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Node_Sandbox extends Twig_SupTwgSgg_Node
|
18 |
{
|
19 |
+
public function __construct(Twig_SupTwgSgg_NodeInterface $body, $lineno, $tag = null)
|
20 |
{
|
21 |
parent::__construct(array('body' => $body), array(), $lineno, $tag);
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
25 |
{
|
26 |
$compiler
|
27 |
->addDebugInfo($this)
|
28 |
+
->write("\$sandbox = \$this->env->getExtension('Twig_SupTwgSgg_Extension_Sandbox');\n")
|
29 |
->write("if (!\$alreadySandboxed = \$sandbox->isSandboxed()) {\n")
|
30 |
->indent()
|
31 |
->write("\$sandbox->enableSandbox();\n")
|
vendor/Twig/Node/SandboxedPrint.php
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
* when the variable is an object and the sandbox is activated.
|
15 |
*
|
16 |
* When there is a simple Print statement, like {{ article }},
|
@@ -19,13 +19,13 @@
|
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*/
|
22 |
-
class
|
23 |
{
|
24 |
-
public function compile(
|
25 |
{
|
26 |
$compiler
|
27 |
->addDebugInfo($this)
|
28 |
-
->write('echo $this->env->getExtension(\'
|
29 |
->subcompile($this->getNode('expr'))
|
30 |
->raw(");\n")
|
31 |
;
|
@@ -36,11 +36,11 @@ class Twig_SupTwg_Node_SandboxedPrint extends Twig_SupTwg_Node_Print
|
|
36 |
*
|
37 |
* This is mostly needed when another visitor adds filters (like the escaper one).
|
38 |
*
|
39 |
-
* @return
|
40 |
*/
|
41 |
-
protected function removeNodeFilter(
|
42 |
{
|
43 |
-
if ($node instanceof
|
44 |
return $this->removeNodeFilter($node->getNode('node'));
|
45 |
}
|
46 |
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
+
* Twig_SupTwgSgg_Node_SandboxedPrint adds a check for the __toString() method
|
14 |
* when the variable is an object and the sandbox is activated.
|
15 |
*
|
16 |
* When there is a simple Print statement, like {{ article }},
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*/
|
22 |
+
class Twig_SupTwgSgg_Node_SandboxedPrint extends Twig_SupTwgSgg_Node_Print
|
23 |
{
|
24 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
25 |
{
|
26 |
$compiler
|
27 |
->addDebugInfo($this)
|
28 |
+
->write('echo $this->env->getExtension(\'Twig_SupTwgSgg_Extension_Sandbox\')->ensureToStringAllowed(')
|
29 |
->subcompile($this->getNode('expr'))
|
30 |
->raw(");\n")
|
31 |
;
|
36 |
*
|
37 |
* This is mostly needed when another visitor adds filters (like the escaper one).
|
38 |
*
|
39 |
+
* @return Twig_SupTwgSgg_Node
|
40 |
*/
|
41 |
+
protected function removeNodeFilter(Twig_SupTwgSgg_Node $node)
|
42 |
{
|
43 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Expression_Filter) {
|
44 |
return $this->removeNodeFilter($node->getNode('node'));
|
45 |
}
|
46 |
|
vendor/Twig/Node/Set.php
CHANGED
@@ -14,29 +14,29 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
-
public function __construct($capture,
|
20 |
{
|
21 |
parent::__construct(array('names' => $names, 'values' => $values), array('capture' => $capture, 'safe' => false), $lineno, $tag);
|
22 |
|
23 |
/*
|
24 |
* Optimizes the node when capture is used for a large block of text.
|
25 |
*
|
26 |
-
* {% set foo %}foo{% endset %} is compiled to $context['foo'] = new
|
27 |
*/
|
28 |
if ($this->getAttribute('capture')) {
|
29 |
$this->setAttribute('safe', true);
|
30 |
|
31 |
$values = $this->getNode('values');
|
32 |
-
if ($values instanceof
|
33 |
-
$this->setNode('values', new
|
34 |
$this->setAttribute('capture', false);
|
35 |
}
|
36 |
}
|
37 |
}
|
38 |
|
39 |
-
public function compile(
|
40 |
{
|
41 |
$compiler->addDebugInfo($this);
|
42 |
|
@@ -61,7 +61,7 @@ class Twig_SupTwg_Node_Set extends Twig_SupTwg_Node implements Twig_SupTwg_NodeC
|
|
61 |
$compiler->subcompile($this->getNode('names'), false);
|
62 |
|
63 |
if ($this->getAttribute('capture')) {
|
64 |
-
$compiler->raw(" = ('' === \$tmp = ob_get_clean()) ? '' : new
|
65 |
}
|
66 |
}
|
67 |
|
@@ -83,7 +83,7 @@ class Twig_SupTwg_Node_Set extends Twig_SupTwg_Node implements Twig_SupTwg_NodeC
|
|
83 |
$compiler
|
84 |
->raw("('' === \$tmp = ")
|
85 |
->subcompile($this->getNode('values'))
|
86 |
-
->raw(") ? '' : new
|
87 |
;
|
88 |
} else {
|
89 |
$compiler->subcompile($this->getNode('values'));
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Node_Set extends Twig_SupTwgSgg_Node implements Twig_SupTwgSgg_NodeCaptureInterface
|
18 |
{
|
19 |
+
public function __construct($capture, Twig_SupTwgSgg_NodeInterface $names, Twig_SupTwgSgg_NodeInterface $values, $lineno, $tag = null)
|
20 |
{
|
21 |
parent::__construct(array('names' => $names, 'values' => $values), array('capture' => $capture, 'safe' => false), $lineno, $tag);
|
22 |
|
23 |
/*
|
24 |
* Optimizes the node when capture is used for a large block of text.
|
25 |
*
|
26 |
+
* {% set foo %}foo{% endset %} is compiled to $context['foo'] = new Twig_SupTwgSgg_Markup("foo");
|
27 |
*/
|
28 |
if ($this->getAttribute('capture')) {
|
29 |
$this->setAttribute('safe', true);
|
30 |
|
31 |
$values = $this->getNode('values');
|
32 |
+
if ($values instanceof Twig_SupTwgSgg_Node_Text) {
|
33 |
+
$this->setNode('values', new Twig_SupTwgSgg_Node_Expression_Constant($values->getAttribute('data'), $values->getTemplateLine()));
|
34 |
$this->setAttribute('capture', false);
|
35 |
}
|
36 |
}
|
37 |
}
|
38 |
|
39 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
40 |
{
|
41 |
$compiler->addDebugInfo($this);
|
42 |
|
61 |
$compiler->subcompile($this->getNode('names'), false);
|
62 |
|
63 |
if ($this->getAttribute('capture')) {
|
64 |
+
$compiler->raw(" = ('' === \$tmp = ob_get_clean()) ? '' : new Twig_SupTwgSgg_Markup(\$tmp, \$this->env->getCharset())");
|
65 |
}
|
66 |
}
|
67 |
|
83 |
$compiler
|
84 |
->raw("('' === \$tmp = ")
|
85 |
->subcompile($this->getNode('values'))
|
86 |
+
->raw(") ? '' : new Twig_SupTwgSgg_Markup(\$tmp, \$this->env->getCharset())")
|
87 |
;
|
88 |
} else {
|
89 |
$compiler->subcompile($this->getNode('values'));
|
vendor/Twig/Node/SetTemp.php
CHANGED
@@ -9,14 +9,14 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
class
|
13 |
{
|
14 |
public function __construct($name, $lineno)
|
15 |
{
|
16 |
parent::__construct(array(), array('name' => $name), $lineno);
|
17 |
}
|
18 |
|
19 |
-
public function compile(
|
20 |
{
|
21 |
$name = $this->getAttribute('name');
|
22 |
$compiler
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
+
class Twig_SupTwgSgg_Node_SetTemp extends Twig_SupTwgSgg_Node
|
13 |
{
|
14 |
public function __construct($name, $lineno)
|
15 |
{
|
16 |
parent::__construct(array(), array('name' => $name), $lineno);
|
17 |
}
|
18 |
|
19 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
20 |
{
|
21 |
$name = $this->getAttribute('name');
|
22 |
$compiler
|
vendor/Twig/Node/Spaceless.php
CHANGED
@@ -16,14 +16,14 @@
|
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
-
class
|
20 |
{
|
21 |
-
public function __construct(
|
22 |
{
|
23 |
parent::__construct(array('body' => $body), array(), $lineno, $tag);
|
24 |
}
|
25 |
|
26 |
-
public function compile(
|
27 |
{
|
28 |
$compiler
|
29 |
->addDebugInfo($this)
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class Twig_SupTwgSgg_Node_Spaceless extends Twig_SupTwgSgg_Node
|
20 |
{
|
21 |
+
public function __construct(Twig_SupTwgSgg_NodeInterface $body, $lineno, $tag = 'spaceless')
|
22 |
{
|
23 |
parent::__construct(array('body' => $body), array(), $lineno, $tag);
|
24 |
}
|
25 |
|
26 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
27 |
{
|
28 |
$compiler
|
29 |
->addDebugInfo($this)
|
vendor/Twig/Node/Text.php
CHANGED
@@ -15,14 +15,14 @@
|
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
-
class
|
19 |
{
|
20 |
public function __construct($data, $lineno)
|
21 |
{
|
22 |
parent::__construct(array(), array('data' => $data), $lineno);
|
23 |
}
|
24 |
|
25 |
-
public function compile(
|
26 |
{
|
27 |
$compiler
|
28 |
->addDebugInfo($this)
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_SupTwgSgg_Node_Text extends Twig_SupTwgSgg_Node implements Twig_SupTwgSgg_NodeOutputInterface
|
19 |
{
|
20 |
public function __construct($data, $lineno)
|
21 |
{
|
22 |
parent::__construct(array(), array('data' => $data), $lineno);
|
23 |
}
|
24 |
|
25 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
26 |
{
|
27 |
$compiler
|
28 |
->addDebugInfo($this)
|
vendor/Twig/Node/With.php
CHANGED
@@ -14,9 +14,9 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
-
public function __construct(
|
20 |
{
|
21 |
$nodes = array('body' => $body);
|
22 |
if (null !== $variables) {
|
@@ -26,7 +26,7 @@ class Twig_SupTwg_Node_With extends Twig_SupTwg_Node
|
|
26 |
parent::__construct($nodes, array('only' => (bool) $only), $lineno, $tag);
|
27 |
}
|
28 |
|
29 |
-
public function compile(
|
30 |
{
|
31 |
$compiler->addDebugInfo($this);
|
32 |
|
@@ -38,7 +38,7 @@ class Twig_SupTwg_Node_With extends Twig_SupTwg_Node
|
|
38 |
->raw(";\n")
|
39 |
->write(sprintf("if (!is_array(\$%s)) {\n", $varsName))
|
40 |
->indent()
|
41 |
-
->write("throw new
|
42 |
->outdent()
|
43 |
->write("}\n")
|
44 |
;
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Node_With extends Twig_SupTwgSgg_Node
|
18 |
{
|
19 |
+
public function __construct(Twig_SupTwgSgg_Node $body, Twig_SupTwgSgg_Node $variables = null, $only = false, $lineno, $tag = null)
|
20 |
{
|
21 |
$nodes = array('body' => $body);
|
22 |
if (null !== $variables) {
|
26 |
parent::__construct($nodes, array('only' => (bool) $only), $lineno, $tag);
|
27 |
}
|
28 |
|
29 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
30 |
{
|
31 |
$compiler->addDebugInfo($this);
|
32 |
|
38 |
->raw(";\n")
|
39 |
->write(sprintf("if (!is_array(\$%s)) {\n", $varsName))
|
40 |
->indent()
|
41 |
+
->write("throw new Twig_SupTwgSgg_Error_Runtime('Variables passed to the \"with\" tag must be a hash.');\n")
|
42 |
->outdent()
|
43 |
->write("}\n")
|
44 |
;
|
vendor/Twig/NodeCaptureInterface.php
CHANGED
@@ -14,6 +14,6 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
interface
|
18 |
{
|
19 |
}
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
interface Twig_SupTwgSgg_NodeCaptureInterface
|
18 |
{
|
19 |
}
|
vendor/Twig/NodeInterface.php
CHANGED
@@ -16,12 +16,12 @@
|
|
16 |
*
|
17 |
* @deprecated since 1.12 (to be removed in 3.0)
|
18 |
*/
|
19 |
-
interface
|
20 |
{
|
21 |
/**
|
22 |
* Compiles the node to PHP.
|
23 |
*/
|
24 |
-
public function compile(
|
25 |
|
26 |
/**
|
27 |
* @deprecated since 1.27 (to be removed in 2.0)
|
16 |
*
|
17 |
* @deprecated since 1.12 (to be removed in 3.0)
|
18 |
*/
|
19 |
+
interface Twig_SupTwgSgg_NodeInterface extends Countable, IteratorAggregate
|
20 |
{
|
21 |
/**
|
22 |
* Compiles the node to PHP.
|
23 |
*/
|
24 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler);
|
25 |
|
26 |
/**
|
27 |
* @deprecated since 1.27 (to be removed in 2.0)
|
vendor/Twig/NodeOutputInterface.php
CHANGED
@@ -14,6 +14,6 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
interface
|
18 |
{
|
19 |
}
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
interface Twig_SupTwgSgg_NodeOutputInterface
|
18 |
{
|
19 |
}
|
vendor/Twig/NodeTraverser.php
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
*
|
15 |
* It visits all nodes and their children and calls the given visitor for each.
|
16 |
*
|
@@ -18,16 +18,16 @@
|
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
protected $env;
|
24 |
protected $visitors = array();
|
25 |
|
26 |
/**
|
27 |
-
* @param
|
28 |
-
* @param
|
29 |
*/
|
30 |
-
public function __construct(
|
31 |
{
|
32 |
$this->env = $env;
|
33 |
foreach ($visitors as $visitor) {
|
@@ -35,7 +35,7 @@ class Twig_SupTwg_NodeTraverser
|
|
35 |
}
|
36 |
}
|
37 |
|
38 |
-
public function addVisitor(
|
39 |
{
|
40 |
if (!isset($this->visitors[$visitor->getPriority()])) {
|
41 |
$this->visitors[$visitor->getPriority()] = array();
|
@@ -47,9 +47,9 @@ class Twig_SupTwg_NodeTraverser
|
|
47 |
/**
|
48 |
* Traverses a node and calls the registered visitors.
|
49 |
*
|
50 |
-
* @return
|
51 |
*/
|
52 |
-
public function traverse(
|
53 |
{
|
54 |
ksort($this->visitors);
|
55 |
foreach ($this->visitors as $visitors) {
|
@@ -61,7 +61,7 @@ class Twig_SupTwg_NodeTraverser
|
|
61 |
return $node;
|
62 |
}
|
63 |
|
64 |
-
protected function traverseForVisitor(
|
65 |
{
|
66 |
if (null === $node) {
|
67 |
return;
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
+
* Twig_SupTwgSgg_NodeTraverser is a node traverser.
|
14 |
*
|
15 |
* It visits all nodes and their children and calls the given visitor for each.
|
16 |
*
|
18 |
*
|
19 |
* @author Fabien Potencier <fabien@symfony.com>
|
20 |
*/
|
21 |
+
class Twig_SupTwgSgg_NodeTraverser
|
22 |
{
|
23 |
protected $env;
|
24 |
protected $visitors = array();
|
25 |
|
26 |
/**
|
27 |
+
* @param Twig_SupTwgSgg_Environment $env
|
28 |
+
* @param Twig_SupTwgSgg_NodeVisitorInterface[] $visitors
|
29 |
*/
|
30 |
+
public function __construct(Twig_SupTwgSgg_Environment $env, array $visitors = array())
|
31 |
{
|
32 |
$this->env = $env;
|
33 |
foreach ($visitors as $visitor) {
|
35 |
}
|
36 |
}
|
37 |
|
38 |
+
public function addVisitor(Twig_SupTwgSgg_NodeVisitorInterface $visitor)
|
39 |
{
|
40 |
if (!isset($this->visitors[$visitor->getPriority()])) {
|
41 |
$this->visitors[$visitor->getPriority()] = array();
|
47 |
/**
|
48 |
* Traverses a node and calls the registered visitors.
|
49 |
*
|
50 |
+
* @return Twig_SupTwgSgg_NodeInterface
|
51 |
*/
|
52 |
+
public function traverse(Twig_SupTwgSgg_NodeInterface $node)
|
53 |
{
|
54 |
ksort($this->visitors);
|
55 |
foreach ($this->visitors as $visitors) {
|
61 |
return $node;
|
62 |
}
|
63 |
|
64 |
+
protected function traverseForVisitor(Twig_SupTwgSgg_NodeVisitorInterface $visitor, Twig_SupTwgSgg_NodeInterface $node = null)
|
65 |
{
|
66 |
if (null === $node) {
|
67 |
return;
|
vendor/Twig/NodeVisitor/Escaper.php
CHANGED
@@ -10,13 +10,13 @@
|
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
*
|
15 |
* @final
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
-
class
|
20 |
{
|
21 |
protected $statusStack = array();
|
22 |
protected $blocks = array();
|
@@ -27,50 +27,50 @@ class Twig_SupTwg_NodeVisitor_Escaper extends Twig_SupTwg_BaseNodeVisitor
|
|
27 |
|
28 |
public function __construct()
|
29 |
{
|
30 |
-
$this->safeAnalysis = new
|
31 |
}
|
32 |
|
33 |
-
protected function doEnterNode(
|
34 |
{
|
35 |
-
if ($node instanceof
|
36 |
-
if ($env->hasExtension('
|
37 |
$this->defaultStrategy = $defaultStrategy;
|
38 |
}
|
39 |
$this->safeVars = array();
|
40 |
$this->blocks = array();
|
41 |
-
} elseif ($node instanceof
|
42 |
$this->statusStack[] = $node->getAttribute('value');
|
43 |
-
} elseif ($node instanceof
|
44 |
$this->statusStack[] = isset($this->blocks[$node->getAttribute('name')]) ? $this->blocks[$node->getAttribute('name')] : $this->needEscaping($env);
|
45 |
-
} elseif ($node instanceof
|
46 |
$this->safeVars[] = $node->getNode('var')->getAttribute('name');
|
47 |
}
|
48 |
|
49 |
return $node;
|
50 |
}
|
51 |
|
52 |
-
protected function doLeaveNode(
|
53 |
{
|
54 |
-
if ($node instanceof
|
55 |
$this->defaultStrategy = false;
|
56 |
$this->safeVars = array();
|
57 |
$this->blocks = array();
|
58 |
-
} elseif ($node instanceof
|
59 |
return $this->preEscapeFilterNode($node, $env);
|
60 |
-
} elseif ($node instanceof
|
61 |
return $this->escapePrintNode($node, $env, $this->needEscaping($env));
|
62 |
}
|
63 |
|
64 |
-
if ($node instanceof
|
65 |
array_pop($this->statusStack);
|
66 |
-
} elseif ($node instanceof
|
67 |
$this->blocks[$node->getAttribute('name')] = $this->needEscaping($env);
|
68 |
}
|
69 |
|
70 |
return $node;
|
71 |
}
|
72 |
|
73 |
-
protected function escapePrintNode(
|
74 |
{
|
75 |
if (false === $type) {
|
76 |
return $node;
|
@@ -90,7 +90,7 @@ class Twig_SupTwg_NodeVisitor_Escaper extends Twig_SupTwg_BaseNodeVisitor
|
|
90 |
);
|
91 |
}
|
92 |
|
93 |
-
protected function preEscapeFilterNode(
|
94 |
{
|
95 |
$name = $filter->getNode('filter')->getAttribute('value');
|
96 |
|
@@ -109,13 +109,13 @@ class Twig_SupTwg_NodeVisitor_Escaper extends Twig_SupTwg_BaseNodeVisitor
|
|
109 |
return $filter;
|
110 |
}
|
111 |
|
112 |
-
protected function isSafeFor($type,
|
113 |
{
|
114 |
$safe = $this->safeAnalysis->getSafe($expression);
|
115 |
|
116 |
if (null === $safe) {
|
117 |
if (null === $this->traverser) {
|
118 |
-
$this->traverser = new
|
119 |
}
|
120 |
|
121 |
$this->safeAnalysis->setSafeVars($this->safeVars);
|
@@ -127,7 +127,7 @@ class Twig_SupTwg_NodeVisitor_Escaper extends Twig_SupTwg_BaseNodeVisitor
|
|
127 |
return in_array($type, $safe) || in_array('all', $safe);
|
128 |
}
|
129 |
|
130 |
-
protected function needEscaping(
|
131 |
{
|
132 |
if (count($this->statusStack)) {
|
133 |
return $this->statusStack[count($this->statusStack) - 1];
|
@@ -136,13 +136,13 @@ class Twig_SupTwg_NodeVisitor_Escaper extends Twig_SupTwg_BaseNodeVisitor
|
|
136 |
return $this->defaultStrategy ? $this->defaultStrategy : false;
|
137 |
}
|
138 |
|
139 |
-
protected function getEscaperFilter($type,
|
140 |
{
|
141 |
$line = $node->getTemplateLine();
|
142 |
-
$name = new
|
143 |
-
$args = new
|
144 |
|
145 |
-
return new
|
146 |
}
|
147 |
|
148 |
public function getPriority()
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
+
* Twig_SupTwgSgg_NodeVisitor_Escaper implements output escaping.
|
14 |
*
|
15 |
* @final
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class Twig_SupTwgSgg_NodeVisitor_Escaper extends Twig_SupTwgSgg_BaseNodeVisitor
|
20 |
{
|
21 |
protected $statusStack = array();
|
22 |
protected $blocks = array();
|
27 |
|
28 |
public function __construct()
|
29 |
{
|
30 |
+
$this->safeAnalysis = new Twig_SupTwgSgg_NodeVisitor_SafeAnalysis();
|
31 |
}
|
32 |
|
33 |
+
protected function doEnterNode(Twig_SupTwgSgg_Node $node, Twig_SupTwgSgg_Environment $env)
|
34 |
{
|
35 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Module) {
|
36 |
+
if ($env->hasExtension('Twig_SupTwgSgg_Extension_Escaper') && $defaultStrategy = $env->getExtension('Twig_SupTwgSgg_Extension_Escaper')->getDefaultStrategy($node->getTemplateName())) {
|
37 |
$this->defaultStrategy = $defaultStrategy;
|
38 |
}
|
39 |
$this->safeVars = array();
|
40 |
$this->blocks = array();
|
41 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_AutoEscape) {
|
42 |
$this->statusStack[] = $node->getAttribute('value');
|
43 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_Block) {
|
44 |
$this->statusStack[] = isset($this->blocks[$node->getAttribute('name')]) ? $this->blocks[$node->getAttribute('name')] : $this->needEscaping($env);
|
45 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_Import) {
|
46 |
$this->safeVars[] = $node->getNode('var')->getAttribute('name');
|
47 |
}
|
48 |
|
49 |
return $node;
|
50 |
}
|
51 |
|
52 |
+
protected function doLeaveNode(Twig_SupTwgSgg_Node $node, Twig_SupTwgSgg_Environment $env)
|
53 |
{
|
54 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Module) {
|
55 |
$this->defaultStrategy = false;
|
56 |
$this->safeVars = array();
|
57 |
$this->blocks = array();
|
58 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_Expression_Filter) {
|
59 |
return $this->preEscapeFilterNode($node, $env);
|
60 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_Print) {
|
61 |
return $this->escapePrintNode($node, $env, $this->needEscaping($env));
|
62 |
}
|
63 |
|
64 |
+
if ($node instanceof Twig_SupTwgSgg_Node_AutoEscape || $node instanceof Twig_SupTwgSgg_Node_Block) {
|
65 |
array_pop($this->statusStack);
|
66 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_BlockReference) {
|
67 |
$this->blocks[$node->getAttribute('name')] = $this->needEscaping($env);
|
68 |
}
|
69 |
|
70 |
return $node;
|
71 |
}
|
72 |
|
73 |
+
protected function escapePrintNode(Twig_SupTwgSgg_Node_Print $node, Twig_SupTwgSgg_Environment $env, $type)
|
74 |
{
|
75 |
if (false === $type) {
|
76 |
return $node;
|
90 |
);
|
91 |
}
|
92 |
|
93 |
+
protected function preEscapeFilterNode(Twig_SupTwgSgg_Node_Expression_Filter $filter, Twig_SupTwgSgg_Environment $env)
|
94 |
{
|
95 |
$name = $filter->getNode('filter')->getAttribute('value');
|
96 |
|
109 |
return $filter;
|
110 |
}
|
111 |
|
112 |
+
protected function isSafeFor($type, Twig_SupTwgSgg_NodeInterface $expression, $env)
|
113 |
{
|
114 |
$safe = $this->safeAnalysis->getSafe($expression);
|
115 |
|
116 |
if (null === $safe) {
|
117 |
if (null === $this->traverser) {
|
118 |
+
$this->traverser = new Twig_SupTwgSgg_NodeTraverser($env, array($this->safeAnalysis));
|
119 |
}
|
120 |
|
121 |
$this->safeAnalysis->setSafeVars($this->safeVars);
|
127 |
return in_array($type, $safe) || in_array('all', $safe);
|
128 |
}
|
129 |
|
130 |
+
protected function needEscaping(Twig_SupTwgSgg_Environment $env)
|
131 |
{
|
132 |
if (count($this->statusStack)) {
|
133 |
return $this->statusStack[count($this->statusStack) - 1];
|
136 |
return $this->defaultStrategy ? $this->defaultStrategy : false;
|
137 |
}
|
138 |
|
139 |
+
protected function getEscaperFilter($type, Twig_SupTwgSgg_NodeInterface $node)
|
140 |
{
|
141 |
$line = $node->getTemplateLine();
|
142 |
+
$name = new Twig_SupTwgSgg_Node_Expression_Constant('escape', $line);
|
143 |
+
$args = new Twig_SupTwgSgg_Node(array(new Twig_SupTwgSgg_Node_Expression_Constant((string) $type, $line), new Twig_SupTwgSgg_Node_Expression_Constant(null, $line), new Twig_SupTwgSgg_Node_Expression_Constant(true, $line)));
|
144 |
|
145 |
+
return new Twig_SupTwgSgg_Node_Expression_Filter($node, $name, $args, $line);
|
146 |
}
|
147 |
|
148 |
public function getPriority()
|
vendor/Twig/NodeVisitor/Optimizer.php
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
*
|
15 |
* This visitor is always the last registered one.
|
16 |
*
|
@@ -21,7 +21,7 @@
|
|
21 |
*
|
22 |
* @author Fabien Potencier <fabien@symfony.com>
|
23 |
*/
|
24 |
-
class
|
25 |
{
|
26 |
const OPTIMIZE_ALL = -1;
|
27 |
const OPTIMIZE_NONE = 0;
|
@@ -47,22 +47,22 @@ class Twig_SupTwg_NodeVisitor_Optimizer extends Twig_SupTwg_BaseNodeVisitor
|
|
47 |
$this->optimizers = $optimizers;
|
48 |
}
|
49 |
|
50 |
-
protected function doEnterNode(
|
51 |
{
|
52 |
if (self::OPTIMIZE_FOR === (self::OPTIMIZE_FOR & $this->optimizers)) {
|
53 |
$this->enterOptimizeFor($node, $env);
|
54 |
}
|
55 |
|
56 |
-
if (PHP_VERSION_ID < 50400 && self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->isStrictVariables() && !$env->hasExtension('
|
57 |
if ($this->inABody) {
|
58 |
-
if (!$node instanceof
|
59 |
-
if (get_class($node) !== '
|
60 |
array_unshift($this->prependedNodes, array());
|
61 |
}
|
62 |
} else {
|
63 |
$node = $this->optimizeVariables($node, $env);
|
64 |
}
|
65 |
-
} elseif ($node instanceof
|
66 |
$this->inABody = true;
|
67 |
}
|
68 |
}
|
@@ -70,9 +70,9 @@ class Twig_SupTwg_NodeVisitor_Optimizer extends Twig_SupTwg_BaseNodeVisitor
|
|
70 |
return $node;
|
71 |
}
|
72 |
|
73 |
-
protected function doLeaveNode(
|
74 |
{
|
75 |
-
$expression = $node instanceof
|
76 |
|
77 |
if (self::OPTIMIZE_FOR === (self::OPTIMIZE_FOR & $this->optimizers)) {
|
78 |
$this->leaveOptimizeFor($node, $env);
|
@@ -84,18 +84,18 @@ class Twig_SupTwg_NodeVisitor_Optimizer extends Twig_SupTwg_BaseNodeVisitor
|
|
84 |
|
85 |
$node = $this->optimizePrintNode($node, $env);
|
86 |
|
87 |
-
if (self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->isStrictVariables() && !$env->hasExtension('
|
88 |
-
if ($node instanceof
|
89 |
$this->inABody = false;
|
90 |
} elseif ($this->inABody) {
|
91 |
-
if (!$expression && get_class($node) !== '
|
92 |
$nodes = array();
|
93 |
foreach (array_unique($prependedNodes) as $name) {
|
94 |
-
$nodes[] = new
|
95 |
}
|
96 |
|
97 |
$nodes[] = $node;
|
98 |
-
$node = new
|
99 |
}
|
100 |
}
|
101 |
}
|
@@ -103,12 +103,12 @@ class Twig_SupTwg_NodeVisitor_Optimizer extends Twig_SupTwg_BaseNodeVisitor
|
|
103 |
return $node;
|
104 |
}
|
105 |
|
106 |
-
protected function optimizeVariables(
|
107 |
{
|
108 |
-
if ('
|
109 |
$this->prependedNodes[0][] = $node->getAttribute('name');
|
110 |
|
111 |
-
return new
|
112 |
}
|
113 |
|
114 |
return $node;
|
@@ -121,18 +121,18 @@ class Twig_SupTwg_NodeVisitor_Optimizer extends Twig_SupTwg_BaseNodeVisitor
|
|
121 |
*
|
122 |
* * "echo $this->render(Parent)Block()" with "$this->display(Parent)Block()"
|
123 |
*
|
124 |
-
* @return
|
125 |
*/
|
126 |
-
protected function optimizePrintNode(
|
127 |
{
|
128 |
-
if (!$node instanceof
|
129 |
return $node;
|
130 |
}
|
131 |
|
132 |
$exprNode = $node->getNode('expr');
|
133 |
if (
|
134 |
-
$exprNode instanceof
|
135 |
-
$exprNode instanceof
|
136 |
) {
|
137 |
$exprNode->setAttribute('output', true);
|
138 |
|
@@ -145,11 +145,11 @@ class Twig_SupTwg_NodeVisitor_Optimizer extends Twig_SupTwg_BaseNodeVisitor
|
|
145 |
/**
|
146 |
* Removes "raw" filters.
|
147 |
*
|
148 |
-
* @return
|
149 |
*/
|
150 |
-
protected function optimizeRawFilter(
|
151 |
{
|
152 |
-
if ($node instanceof
|
153 |
return $node->getNode('node');
|
154 |
}
|
155 |
|
@@ -159,9 +159,9 @@ class Twig_SupTwg_NodeVisitor_Optimizer extends Twig_SupTwg_BaseNodeVisitor
|
|
159 |
/**
|
160 |
* Optimizes "for" tag by removing the "loop" variable creation whenever possible.
|
161 |
*/
|
162 |
-
protected function enterOptimizeFor(
|
163 |
{
|
164 |
-
if ($node instanceof
|
165 |
// disable the loop variable by default
|
166 |
$node->setAttribute('with_loop', false);
|
167 |
array_unshift($this->loops, $node);
|
@@ -175,28 +175,28 @@ class Twig_SupTwg_NodeVisitor_Optimizer extends Twig_SupTwg_BaseNodeVisitor
|
|
175 |
// when do we need to add the loop variable back?
|
176 |
|
177 |
// the loop variable is referenced for the current loop
|
178 |
-
elseif ($node instanceof
|
179 |
$node->setAttribute('always_defined', true);
|
180 |
$this->addLoopToCurrent();
|
181 |
}
|
182 |
|
183 |
// optimize access to loop targets
|
184 |
-
elseif ($node instanceof
|
185 |
$node->setAttribute('always_defined', true);
|
186 |
}
|
187 |
|
188 |
// block reference
|
189 |
-
elseif ($node instanceof
|
190 |
$this->addLoopToCurrent();
|
191 |
}
|
192 |
|
193 |
// include without the only attribute
|
194 |
-
elseif ($node instanceof
|
195 |
$this->addLoopToAll();
|
196 |
}
|
197 |
|
198 |
// include function without the with_context=false parameter
|
199 |
-
elseif ($node instanceof
|
200 |
&& 'include' === $node->getAttribute('name')
|
201 |
&& (!$node->getNode('arguments')->hasNode('with_context')
|
202 |
|| false !== $node->getNode('arguments')->getNode('with_context')->getAttribute('value')
|
@@ -206,12 +206,12 @@ class Twig_SupTwg_NodeVisitor_Optimizer extends Twig_SupTwg_BaseNodeVisitor
|
|
206 |
}
|
207 |
|
208 |
// the loop variable is referenced via an attribute
|
209 |
-
elseif ($node instanceof
|
210 |
-
&& (!$node->getNode('attribute') instanceof
|
211 |
|| 'parent' === $node->getNode('attribute')->getAttribute('value')
|
212 |
)
|
213 |
&& (true === $this->loops[0]->getAttribute('with_loop')
|
214 |
-
|| ($node->getNode('node') instanceof
|
215 |
&& 'loop' === $node->getNode('node')->getAttribute('name')
|
216 |
)
|
217 |
)
|
@@ -223,9 +223,9 @@ class Twig_SupTwg_NodeVisitor_Optimizer extends Twig_SupTwg_BaseNodeVisitor
|
|
223 |
/**
|
224 |
* Optimizes "for" tag by removing the "loop" variable creation whenever possible.
|
225 |
*/
|
226 |
-
protected function leaveOptimizeFor(
|
227 |
{
|
228 |
-
if ($node instanceof
|
229 |
array_shift($this->loops);
|
230 |
array_shift($this->loopsTargets);
|
231 |
array_shift($this->loopsTargets);
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
+
* Twig_SupTwgSgg_NodeVisitor_Optimizer tries to optimizes the AST.
|
14 |
*
|
15 |
* This visitor is always the last registered one.
|
16 |
*
|
21 |
*
|
22 |
* @author Fabien Potencier <fabien@symfony.com>
|
23 |
*/
|
24 |
+
class Twig_SupTwgSgg_NodeVisitor_Optimizer extends Twig_SupTwgSgg_BaseNodeVisitor
|
25 |
{
|
26 |
const OPTIMIZE_ALL = -1;
|
27 |
const OPTIMIZE_NONE = 0;
|
47 |
$this->optimizers = $optimizers;
|
48 |
}
|
49 |
|
50 |
+
protected function doEnterNode(Twig_SupTwgSgg_Node $node, Twig_SupTwgSgg_Environment $env)
|
51 |
{
|
52 |
if (self::OPTIMIZE_FOR === (self::OPTIMIZE_FOR & $this->optimizers)) {
|
53 |
$this->enterOptimizeFor($node, $env);
|
54 |
}
|
55 |
|
56 |
+
if (PHP_VERSION_ID < 50400 && self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->isStrictVariables() && !$env->hasExtension('Twig_SupTwgSgg_Extension_Sandbox')) {
|
57 |
if ($this->inABody) {
|
58 |
+
if (!$node instanceof Twig_SupTwgSgg_Node_Expression) {
|
59 |
+
if (get_class($node) !== 'Twig_SupTwgSgg_Node') {
|
60 |
array_unshift($this->prependedNodes, array());
|
61 |
}
|
62 |
} else {
|
63 |
$node = $this->optimizeVariables($node, $env);
|
64 |
}
|
65 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_Body) {
|
66 |
$this->inABody = true;
|
67 |
}
|
68 |
}
|
70 |
return $node;
|
71 |
}
|
72 |
|
73 |
+
protected function doLeaveNode(Twig_SupTwgSgg_Node $node, Twig_SupTwgSgg_Environment $env)
|
74 |
{
|
75 |
+
$expression = $node instanceof Twig_SupTwgSgg_Node_Expression;
|
76 |
|
77 |
if (self::OPTIMIZE_FOR === (self::OPTIMIZE_FOR & $this->optimizers)) {
|
78 |
$this->leaveOptimizeFor($node, $env);
|
84 |
|
85 |
$node = $this->optimizePrintNode($node, $env);
|
86 |
|
87 |
+
if (self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->isStrictVariables() && !$env->hasExtension('Twig_SupTwgSgg_Extension_Sandbox')) {
|
88 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Body) {
|
89 |
$this->inABody = false;
|
90 |
} elseif ($this->inABody) {
|
91 |
+
if (!$expression && get_class($node) !== 'Twig_SupTwgSgg_Node' && $prependedNodes = array_shift($this->prependedNodes)) {
|
92 |
$nodes = array();
|
93 |
foreach (array_unique($prependedNodes) as $name) {
|
94 |
+
$nodes[] = new Twig_SupTwgSgg_Node_SetTemp($name, $node->getTemplateLine());
|
95 |
}
|
96 |
|
97 |
$nodes[] = $node;
|
98 |
+
$node = new Twig_SupTwgSgg_Node($nodes);
|
99 |
}
|
100 |
}
|
101 |
}
|
103 |
return $node;
|
104 |
}
|
105 |
|
106 |
+
protected function optimizeVariables(Twig_SupTwgSgg_NodeInterface $node, Twig_SupTwgSgg_Environment $env)
|
107 |
{
|
108 |
+
if ('Twig_SupTwgSgg_Node_Expression_Name' === get_class($node) && $node->isSimple()) {
|
109 |
$this->prependedNodes[0][] = $node->getAttribute('name');
|
110 |
|
111 |
+
return new Twig_SupTwgSgg_Node_Expression_TempName($node->getAttribute('name'), $node->getTemplateLine());
|
112 |
}
|
113 |
|
114 |
return $node;
|
121 |
*
|
122 |
* * "echo $this->render(Parent)Block()" with "$this->display(Parent)Block()"
|
123 |
*
|
124 |
+
* @return Twig_SupTwgSgg_NodeInterface
|
125 |
*/
|
126 |
+
protected function optimizePrintNode(Twig_SupTwgSgg_NodeInterface $node, Twig_SupTwgSgg_Environment $env)
|
127 |
{
|
128 |
+
if (!$node instanceof Twig_SupTwgSgg_Node_Print) {
|
129 |
return $node;
|
130 |
}
|
131 |
|
132 |
$exprNode = $node->getNode('expr');
|
133 |
if (
|
134 |
+
$exprNode instanceof Twig_SupTwgSgg_Node_Expression_BlockReference ||
|
135 |
+
$exprNode instanceof Twig_SupTwgSgg_Node_Expression_Parent
|
136 |
) {
|
137 |
$exprNode->setAttribute('output', true);
|
138 |
|
145 |
/**
|
146 |
* Removes "raw" filters.
|
147 |
*
|
148 |
+
* @return Twig_SupTwgSgg_NodeInterface
|
149 |
*/
|
150 |
+
protected function optimizeRawFilter(Twig_SupTwgSgg_NodeInterface $node, Twig_SupTwgSgg_Environment $env)
|
151 |
{
|
152 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Expression_Filter && 'raw' == $node->getNode('filter')->getAttribute('value')) {
|
153 |
return $node->getNode('node');
|
154 |
}
|
155 |
|
159 |
/**
|
160 |
* Optimizes "for" tag by removing the "loop" variable creation whenever possible.
|
161 |
*/
|
162 |
+
protected function enterOptimizeFor(Twig_SupTwgSgg_NodeInterface $node, Twig_SupTwgSgg_Environment $env)
|
163 |
{
|
164 |
+
if ($node instanceof Twig_SupTwgSgg_Node_For) {
|
165 |
// disable the loop variable by default
|
166 |
$node->setAttribute('with_loop', false);
|
167 |
array_unshift($this->loops, $node);
|
175 |
// when do we need to add the loop variable back?
|
176 |
|
177 |
// the loop variable is referenced for the current loop
|
178 |
+
elseif ($node instanceof Twig_SupTwgSgg_Node_Expression_Name && 'loop' === $node->getAttribute('name')) {
|
179 |
$node->setAttribute('always_defined', true);
|
180 |
$this->addLoopToCurrent();
|
181 |
}
|
182 |
|
183 |
// optimize access to loop targets
|
184 |
+
elseif ($node instanceof Twig_SupTwgSgg_Node_Expression_Name && in_array($node->getAttribute('name'), $this->loopsTargets)) {
|
185 |
$node->setAttribute('always_defined', true);
|
186 |
}
|
187 |
|
188 |
// block reference
|
189 |
+
elseif ($node instanceof Twig_SupTwgSgg_Node_BlockReference || $node instanceof Twig_SupTwgSgg_Node_Expression_BlockReference) {
|
190 |
$this->addLoopToCurrent();
|
191 |
}
|
192 |
|
193 |
// include without the only attribute
|
194 |
+
elseif ($node instanceof Twig_SupTwgSgg_Node_Include && !$node->getAttribute('only')) {
|
195 |
$this->addLoopToAll();
|
196 |
}
|
197 |
|
198 |
// include function without the with_context=false parameter
|
199 |
+
elseif ($node instanceof Twig_SupTwgSgg_Node_Expression_Function
|
200 |
&& 'include' === $node->getAttribute('name')
|
201 |
&& (!$node->getNode('arguments')->hasNode('with_context')
|
202 |
|| false !== $node->getNode('arguments')->getNode('with_context')->getAttribute('value')
|
206 |
}
|
207 |
|
208 |
// the loop variable is referenced via an attribute
|
209 |
+
elseif ($node instanceof Twig_SupTwgSgg_Node_Expression_GetAttr
|
210 |
+
&& (!$node->getNode('attribute') instanceof Twig_SupTwgSgg_Node_Expression_Constant
|
211 |
|| 'parent' === $node->getNode('attribute')->getAttribute('value')
|
212 |
)
|
213 |
&& (true === $this->loops[0]->getAttribute('with_loop')
|
214 |
+
|| ($node->getNode('node') instanceof Twig_SupTwgSgg_Node_Expression_Name
|
215 |
&& 'loop' === $node->getNode('node')->getAttribute('name')
|
216 |
)
|
217 |
)
|
223 |
/**
|
224 |
* Optimizes "for" tag by removing the "loop" variable creation whenever possible.
|
225 |
*/
|
226 |
+
protected function leaveOptimizeFor(Twig_SupTwgSgg_NodeInterface $node, Twig_SupTwgSgg_Environment $env)
|
227 |
{
|
228 |
+
if ($node instanceof Twig_SupTwgSgg_Node_For) {
|
229 |
array_shift($this->loops);
|
230 |
array_shift($this->loopsTargets);
|
231 |
array_shift($this->loopsTargets);
|
vendor/Twig/NodeVisitor/SafeAnalysis.php
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
/**
|
13 |
* @final
|
14 |
*/
|
15 |
-
class
|
16 |
{
|
17 |
protected $data = array();
|
18 |
protected $safeVars = array();
|
@@ -22,7 +22,7 @@ class Twig_SupTwg_NodeVisitor_SafeAnalysis extends Twig_SupTwg_BaseNodeVisitor
|
|
22 |
$this->safeVars = $safeVars;
|
23 |
}
|
24 |
|
25 |
-
public function getSafe(
|
26 |
{
|
27 |
$hash = spl_object_hash($node);
|
28 |
if (!isset($this->data[$hash])) {
|
@@ -42,7 +42,7 @@ class Twig_SupTwg_NodeVisitor_SafeAnalysis extends Twig_SupTwg_BaseNodeVisitor
|
|
42 |
}
|
43 |
}
|
44 |
|
45 |
-
protected function setSafe(
|
46 |
{
|
47 |
$hash = spl_object_hash($node);
|
48 |
if (isset($this->data[$hash])) {
|
@@ -60,27 +60,27 @@ class Twig_SupTwg_NodeVisitor_SafeAnalysis extends Twig_SupTwg_BaseNodeVisitor
|
|
60 |
);
|
61 |
}
|
62 |
|
63 |
-
protected function doEnterNode(
|
64 |
{
|
65 |
return $node;
|
66 |
}
|
67 |
|
68 |
-
protected function doLeaveNode(
|
69 |
{
|
70 |
-
if ($node instanceof
|
71 |
// constants are marked safe for all
|
72 |
$this->setSafe($node, array('all'));
|
73 |
-
} elseif ($node instanceof
|
74 |
// blocks are safe by definition
|
75 |
$this->setSafe($node, array('all'));
|
76 |
-
} elseif ($node instanceof
|
77 |
// parent block is safe by definition
|
78 |
$this->setSafe($node, array('all'));
|
79 |
-
} elseif ($node instanceof
|
80 |
// intersect safeness of both operands
|
81 |
$safe = $this->intersectSafe($this->getSafe($node->getNode('expr2')), $this->getSafe($node->getNode('expr3')));
|
82 |
$this->setSafe($node, $safe);
|
83 |
-
} elseif ($node instanceof
|
84 |
// filter expression is safe when the filter is safe
|
85 |
$name = $node->getNode('filter')->getAttribute('value');
|
86 |
$args = $node->getNode('arguments');
|
@@ -93,7 +93,7 @@ class Twig_SupTwg_NodeVisitor_SafeAnalysis extends Twig_SupTwg_BaseNodeVisitor
|
|
93 |
} else {
|
94 |
$this->setSafe($node, array());
|
95 |
}
|
96 |
-
} elseif ($node instanceof
|
97 |
// function expression is safe when the function is safe
|
98 |
$name = $node->getAttribute('name');
|
99 |
$args = $node->getNode('arguments');
|
@@ -103,13 +103,13 @@ class Twig_SupTwg_NodeVisitor_SafeAnalysis extends Twig_SupTwg_BaseNodeVisitor
|
|
103 |
} else {
|
104 |
$this->setSafe($node, array());
|
105 |
}
|
106 |
-
} elseif ($node instanceof
|
107 |
if ($node->getAttribute('safe')) {
|
108 |
$this->setSafe($node, array('all'));
|
109 |
} else {
|
110 |
$this->setSafe($node, array());
|
111 |
}
|
112 |
-
} elseif ($node instanceof
|
113 |
$name = $node->getNode('node')->getAttribute('name');
|
114 |
// attributes on template instances are safe
|
115 |
if ('_self' == $name || in_array($name, $this->safeVars)) {
|
12 |
/**
|
13 |
* @final
|
14 |
*/
|
15 |
+
class Twig_SupTwgSgg_NodeVisitor_SafeAnalysis extends Twig_SupTwgSgg_BaseNodeVisitor
|
16 |
{
|
17 |
protected $data = array();
|
18 |
protected $safeVars = array();
|
22 |
$this->safeVars = $safeVars;
|
23 |
}
|
24 |
|
25 |
+
public function getSafe(Twig_SupTwgSgg_NodeInterface $node)
|
26 |
{
|
27 |
$hash = spl_object_hash($node);
|
28 |
if (!isset($this->data[$hash])) {
|
42 |
}
|
43 |
}
|
44 |
|
45 |
+
protected function setSafe(Twig_SupTwgSgg_NodeInterface $node, array $safe)
|
46 |
{
|
47 |
$hash = spl_object_hash($node);
|
48 |
if (isset($this->data[$hash])) {
|
60 |
);
|
61 |
}
|
62 |
|
63 |
+
protected function doEnterNode(Twig_SupTwgSgg_Node $node, Twig_SupTwgSgg_Environment $env)
|
64 |
{
|
65 |
return $node;
|
66 |
}
|
67 |
|
68 |
+
protected function doLeaveNode(Twig_SupTwgSgg_Node $node, Twig_SupTwgSgg_Environment $env)
|
69 |
{
|
70 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Expression_Constant) {
|
71 |
// constants are marked safe for all
|
72 |
$this->setSafe($node, array('all'));
|
73 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_Expression_BlockReference) {
|
74 |
// blocks are safe by definition
|
75 |
$this->setSafe($node, array('all'));
|
76 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_Expression_Parent) {
|
77 |
// parent block is safe by definition
|
78 |
$this->setSafe($node, array('all'));
|
79 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_Expression_Conditional) {
|
80 |
// intersect safeness of both operands
|
81 |
$safe = $this->intersectSafe($this->getSafe($node->getNode('expr2')), $this->getSafe($node->getNode('expr3')));
|
82 |
$this->setSafe($node, $safe);
|
83 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_Expression_Filter) {
|
84 |
// filter expression is safe when the filter is safe
|
85 |
$name = $node->getNode('filter')->getAttribute('value');
|
86 |
$args = $node->getNode('arguments');
|
93 |
} else {
|
94 |
$this->setSafe($node, array());
|
95 |
}
|
96 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_Expression_Function) {
|
97 |
// function expression is safe when the function is safe
|
98 |
$name = $node->getAttribute('name');
|
99 |
$args = $node->getNode('arguments');
|
103 |
} else {
|
104 |
$this->setSafe($node, array());
|
105 |
}
|
106 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_Expression_MethodCall) {
|
107 |
if ($node->getAttribute('safe')) {
|
108 |
$this->setSafe($node, array('all'));
|
109 |
} else {
|
110 |
$this->setSafe($node, array());
|
111 |
}
|
112 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_SupTwgSgg_Node_Expression_Name) {
|
113 |
$name = $node->getNode('node')->getAttribute('name');
|
114 |
// attributes on template instances are safe
|
115 |
if ('_self' == $name || in_array($name, $this->safeVars)) {
|
vendor/Twig/NodeVisitor/Sandbox.php
CHANGED
@@ -10,22 +10,22 @@
|
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
*
|
15 |
* @final
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
-
class
|
20 |
{
|
21 |
protected $inAModule = false;
|
22 |
protected $tags;
|
23 |
protected $filters;
|
24 |
protected $functions;
|
25 |
|
26 |
-
protected function doEnterNode(
|
27 |
{
|
28 |
-
if ($node instanceof
|
29 |
$this->inAModule = true;
|
30 |
$this->tags = array();
|
31 |
$this->filters = array();
|
@@ -39,30 +39,30 @@ class Twig_SupTwg_NodeVisitor_Sandbox extends Twig_SupTwg_BaseNodeVisitor
|
|
39 |
}
|
40 |
|
41 |
// look for filters
|
42 |
-
if ($node instanceof
|
43 |
$this->filters[$node->getNode('filter')->getAttribute('value')] = $node;
|
44 |
}
|
45 |
|
46 |
// look for functions
|
47 |
-
if ($node instanceof
|
48 |
$this->functions[$node->getAttribute('name')] = $node;
|
49 |
}
|
50 |
|
51 |
// wrap print to check __toString() calls
|
52 |
-
if ($node instanceof
|
53 |
-
return new
|
54 |
}
|
55 |
}
|
56 |
|
57 |
return $node;
|
58 |
}
|
59 |
|
60 |
-
protected function doLeaveNode(
|
61 |
{
|
62 |
-
if ($node instanceof
|
63 |
$this->inAModule = false;
|
64 |
|
65 |
-
$node->setNode('display_start', new
|
66 |
}
|
67 |
|
68 |
return $node;
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
+
* Twig_SupTwgSgg_NodeVisitor_Sandbox implements sandboxing.
|
14 |
*
|
15 |
* @final
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class Twig_SupTwgSgg_NodeVisitor_Sandbox extends Twig_SupTwgSgg_BaseNodeVisitor
|
20 |
{
|
21 |
protected $inAModule = false;
|
22 |
protected $tags;
|
23 |
protected $filters;
|
24 |
protected $functions;
|
25 |
|
26 |
+
protected function doEnterNode(Twig_SupTwgSgg_Node $node, Twig_SupTwgSgg_Environment $env)
|
27 |
{
|
28 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Module) {
|
29 |
$this->inAModule = true;
|
30 |
$this->tags = array();
|
31 |
$this->filters = array();
|
39 |
}
|
40 |
|
41 |
// look for filters
|
42 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Expression_Filter && !isset($this->filters[$node->getNode('filter')->getAttribute('value')])) {
|
43 |
$this->filters[$node->getNode('filter')->getAttribute('value')] = $node;
|
44 |
}
|
45 |
|
46 |
// look for functions
|
47 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Expression_Function && !isset($this->functions[$node->getAttribute('name')])) {
|
48 |
$this->functions[$node->getAttribute('name')] = $node;
|
49 |
}
|
50 |
|
51 |
// wrap print to check __toString() calls
|
52 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Print) {
|
53 |
+
return new Twig_SupTwgSgg_Node_SandboxedPrint($node->getNode('expr'), $node->getTemplateLine(), $node->getNodeTag());
|
54 |
}
|
55 |
}
|
56 |
|
57 |
return $node;
|
58 |
}
|
59 |
|
60 |
+
protected function doLeaveNode(Twig_SupTwgSgg_Node $node, Twig_SupTwgSgg_Environment $env)
|
61 |
{
|
62 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Module) {
|
63 |
$this->inAModule = false;
|
64 |
|
65 |
+
$node->setNode('display_start', new Twig_SupTwgSgg_Node(array(new Twig_SupTwgSgg_Node_CheckSecurity($this->filters, $this->tags, $this->functions), $node->getNode('display_start'))));
|
66 |
}
|
67 |
|
68 |
return $node;
|
vendor/Twig/NodeVisitorInterface.php
CHANGED
@@ -10,25 +10,25 @@
|
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
-
*
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
interface
|
18 |
{
|
19 |
/**
|
20 |
* Called before child nodes are visited.
|
21 |
*
|
22 |
-
* @return
|
23 |
*/
|
24 |
-
public function enterNode(
|
25 |
|
26 |
/**
|
27 |
* Called after child nodes are visited.
|
28 |
*
|
29 |
-
* @return
|
30 |
*/
|
31 |
-
public function leaveNode(
|
32 |
|
33 |
/**
|
34 |
* Returns the priority for this visitor.
|
10 |
*/
|
11 |
|
12 |
/**
|
13 |
+
* Twig_SupTwgSgg_NodeVisitorInterface is the interface the all node visitor classes must implement.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
interface Twig_SupTwgSgg_NodeVisitorInterface
|
18 |
{
|
19 |
/**
|
20 |
* Called before child nodes are visited.
|
21 |
*
|
22 |
+
* @return Twig_SupTwgSgg_NodeInterface The modified node
|
23 |
*/
|
24 |
+
public function enterNode(Twig_SupTwgSgg_NodeInterface $node, Twig_SupTwgSgg_Environment $env);
|
25 |
|
26 |
/**
|
27 |
* Called after child nodes are visited.
|
28 |
*
|
29 |
+
* @return Twig_SupTwgSgg_NodeInterface|false The modified node or false if the node must be removed
|
30 |
*/
|
31 |
+
public function leaveNode(Twig_SupTwgSgg_NodeInterface $node, Twig_SupTwgSgg_Environment $env);
|
32 |
|
33 |
/**
|
34 |
* Returns the priority for this visitor.
|
vendor/Twig/Parser.php
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
-
class
|
19 |
{
|
20 |
protected $stack = array();
|
21 |
protected $stream;
|
@@ -32,7 +32,7 @@ class Twig_SupTwg_Parser implements Twig_SupTwg_ParserInterface
|
|
32 |
protected $traits;
|
33 |
protected $embeddedTemplates = array();
|
34 |
|
35 |
-
public function __construct(
|
36 |
{
|
37 |
$this->env = $env;
|
38 |
}
|
@@ -42,7 +42,7 @@ class Twig_SupTwg_Parser implements Twig_SupTwg_ParserInterface
|
|
42 |
*/
|
43 |
public function getEnvironment()
|
44 |
{
|
45 |
-
|
46 |
|
47 |
return $this->env;
|
48 |
}
|
@@ -57,12 +57,12 @@ class Twig_SupTwg_Parser implements Twig_SupTwg_ParserInterface
|
|
57 |
*/
|
58 |
public function getFilename()
|
59 |
{
|
60 |
-
|
61 |
|
62 |
return $this->stream->getSourceContext()->getName();
|
63 |
}
|
64 |
|
65 |
-
public function parse(
|
66 |
{
|
67 |
// push all variables into the stack to keep the current state of the parser
|
68 |
// using get_object_vars() instead of foreach would lead to https://bugs.php.net/71336
|
@@ -87,7 +87,7 @@ class Twig_SupTwg_Parser implements Twig_SupTwg_ParserInterface
|
|
87 |
}
|
88 |
|
89 |
if (null === $this->expressionParser) {
|
90 |
-
$this->expressionParser = new
|
91 |
}
|
92 |
|
93 |
$this->stream = $stream;
|
@@ -103,9 +103,9 @@ class Twig_SupTwg_Parser implements Twig_SupTwg_ParserInterface
|
|
103 |
$body = $this->subparse($test, $dropNeedle);
|
104 |
|
105 |
if (null !== $this->parent && null === $body = $this->filterBodyNodes($body)) {
|
106 |
-
$body = new
|
107 |
}
|
108 |
-
} catch (
|
109 |
if (!$e->getSourceContext()) {
|
110 |
$e->setSourceContext($this->stream->getSourceContext());
|
111 |
}
|
@@ -117,9 +117,9 @@ class Twig_SupTwg_Parser implements Twig_SupTwg_ParserInterface
|
|
117 |
throw $e;
|
118 |
}
|
119 |
|
120 |
-
$node = new
|
121 |
|
122 |
-
$traverser = new
|
123 |
|
124 |
$node = $traverser->traverse($node);
|
125 |
|
@@ -137,24 +137,24 @@ class Twig_SupTwg_Parser implements Twig_SupTwg_ParserInterface
|
|
137 |
$rv = array();
|
138 |
while (!$this->stream->isEOF()) {
|
139 |
switch ($this->getCurrentToken()->getType()) {
|
140 |
-
case
|
141 |
$token = $this->stream->next();
|
142 |
-
$rv[] = new
|
143 |
break;
|
144 |
|
145 |
-
case
|
146 |
$token = $this->stream->next();
|
147 |
$expr = $this->expressionParser->parseExpression();
|
148 |
-
$this->stream->expect(
|
149 |
-
$rv[] = new
|
150 |
break;
|
151 |
|
152 |
-
case
|
153 |
$this->stream->next();
|
154 |
$token = $this->getCurrentToken();
|
155 |
|
156 |
-
if ($token->getType() !==
|
157 |
-
throw new
|
158 |
}
|
159 |
|
160 |
if (null !== $test && call_user_func($test, $token)) {
|
@@ -166,19 +166,19 @@ class Twig_SupTwg_Parser implements Twig_SupTwg_ParserInterface
|
|
166 |
return $rv[0];
|
167 |
}
|
168 |
|
169 |
-
return new
|
170 |
}
|
171 |
|
172 |
$subparser = $this->handlers->getTokenParser($token->getValue());
|
173 |
if (null === $subparser) {
|
174 |
if (null !== $test) {
|
175 |
-
$e = new
|
176 |
|
177 |
-
if (is_array($test) && isset($test[0]) && $test[0] instanceof
|
178 |
$e->appendMessage(sprintf(' (expecting closing tag for the "%s" tag defined near line %s).', $test[0]->getTag(), $lineno));
|
179 |
}
|
180 |
} else {
|
181 |
-
$e = new
|
182 |
$e->addSuggestions($token->getValue(), array_keys($this->env->getTags()));
|
183 |
}
|
184 |
|
@@ -194,7 +194,7 @@ class Twig_SupTwg_Parser implements Twig_SupTwg_ParserInterface
|
|
194 |
break;
|
195 |
|
196 |
default:
|
197 |
-
throw new
|
198 |
}
|
199 |
}
|
200 |
|
@@ -202,7 +202,7 @@ class Twig_SupTwg_Parser implements Twig_SupTwg_ParserInterface
|
|
202 |
return $rv[0];
|
203 |
}
|
204 |
|
205 |
-
return new
|
206 |
}
|
207 |
|
208 |
/**
|
@@ -210,7 +210,7 @@ class Twig_SupTwg_Parser implements Twig_SupTwg_ParserInterface
|
|
210 |
*/
|
211 |
public function addHandler($name, $class)
|
212 |
{
|
213 |
-
|
214 |
|
215 |
$this->handlers[$name] = $class;
|
216 |
}
|
@@ -218,9 +218,9 @@ class Twig_SupTwg_Parser implements Twig_SupTwg_ParserInterface
|
|
218 |
/**
|
219 |
* @deprecated since 1.27 (to be removed in 2.0)
|
220 |
*/
|
221 |
-
public function addNodeVisitor(
|
222 |
{
|
223 |
-
|
224 |
|
225 |
$this->visitors[] = $visitor;
|
226 |
}
|
@@ -255,9 +255,9 @@ class Twig_SupTwg_Parser implements Twig_SupTwg_ParserInterface
|
|
255 |
return $this->blocks[$name];
|
256 |
}
|
257 |
|
258 |
-
public function setBlock($name,
|
259 |
{
|
260 |
-
$this->blocks[$name] = new
|
261 |
}
|
262 |
|
263 |
public function hasMacro($name)
|
@@ -265,10 +265,10 @@ class Twig_SupTwg_Parser implements Twig_SupTwg_ParserInterface
|
|
265 |
return isset($this->macros[$name]);
|
266 |
}
|
267 |
|
268 |
-
public function setMacro($name,
|
269 |
{
|
270 |
if ($this->isReservedMacroName($name)) {
|
271 |
-
throw new
|
272 |
}
|
273 |
|
274 |
$this->macros[$name] = $node;
|
@@ -301,14 +301,14 @@ class Twig_SupTwg_Parser implements Twig_SupTwg_ParserInterface
|
|
301 |
return count($this->traits) > 0;
|
302 |
}
|
303 |
|
304 |
-
public function embedTemplate(
|
305 |
{
|
306 |
$template->setIndex(mt_rand());
|
307 |
|
308 |
$this->embeddedTemplates[] = $template;
|
309 |
}
|
310 |
|
311 |
-
public function addImportedSymbol($type, $alias, $name = null,
|
312 |
{
|
313 |
$this->importedSymbols[0][$type][$alias] = array('name' => $name, 'node' => $node);
|
314 |
}
|
@@ -338,7 +338,7 @@ class Twig_SupTwg_Parser implements Twig_SupTwg_ParserInterface
|
|
338 |
}
|
339 |
|
340 |
/**
|
341 |
-
* @return
|
342 |
*/
|
343 |
public function getExpressionParser()
|
344 |
{
|
@@ -356,7 +356,7 @@ class Twig_SupTwg_Parser implements Twig_SupTwg_ParserInterface
|
|
356 |
}
|
357 |
|
358 |
/**
|
359 |
-
* @return
|
360 |
*/
|
361 |
public function getStream()
|
362 |
{
|
@@ -364,34 +364,34 @@ class Twig_SupTwg_Parser implements Twig_SupTwg_ParserInterface
|
|
364 |
}
|
365 |
|
366 |
/**
|
367 |
-
* @return
|
368 |
*/
|
369 |
public function getCurrentToken()
|
370 |
{
|
371 |
return $this->stream->getCurrent();
|
372 |
}
|
373 |
|
374 |
-
protected function filterBodyNodes(
|
375 |
{
|
376 |
// check that the body does not contain non-empty output nodes
|
377 |
if (
|
378 |
-
($node instanceof
|
379 |
||
|
380 |
-
(!$node instanceof
|
381 |
) {
|
382 |
if (false !== strpos((string) $node, chr(0xEF).chr(0xBB).chr(0xBF))) {
|
383 |
-
throw new
|
384 |
}
|
385 |
|
386 |
-
throw new
|
387 |
}
|
388 |
|
389 |
// bypass nodes that will "capture" the output
|
390 |
-
if ($node instanceof
|
391 |
return $node;
|
392 |
}
|
393 |
|
394 |
-
if ($node instanceof
|
395 |
return;
|
396 |
}
|
397 |
|
15 |
*
|
16 |
* @author Fabien Potencier <fabien@symfony.com>
|
17 |
*/
|
18 |
+
class Twig_SupTwgSgg_Parser implements Twig_SupTwgSgg_ParserInterface
|
19 |
{
|
20 |
protected $stack = array();
|
21 |
protected $stream;
|
32 |
protected $traits;
|
33 |
protected $embeddedTemplates = array();
|
34 |
|
35 |
+
public function __construct(Twig_SupTwgSgg_Environment $env)
|
36 |
{
|
37 |
$this->env = $env;
|
38 |
}
|
42 |
*/
|
43 |
public function getEnvironment()
|
44 |
{
|
45 |
+
//@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0.', E_USER_DEPRECATED);
|
46 |
|
47 |
return $this->env;
|
48 |
}
|
57 |
*/
|
58 |
public function getFilename()
|
59 |
{
|
60 |
+
//@trigger_error(sprintf('The "%s" method is deprecated since version 1.27 and will be removed in 2.0. Use $parser->getStream()->getSourceContext()->getPath() instead.', __METHOD__), E_USER_DEPRECATED);
|
61 |
|
62 |
return $this->stream->getSourceContext()->getName();
|
63 |
}
|
64 |
|
65 |
+
public function parse(Twig_SupTwgSgg_TokenStream $stream, $test = null, $dropNeedle = false)
|
66 |
{
|
67 |
// push all variables into the stack to keep the current state of the parser
|
68 |
// using get_object_vars() instead of foreach would lead to https://bugs.php.net/71336
|
87 |
}
|
88 |
|
89 |
if (null === $this->expressionParser) {
|
90 |
+
$this->expressionParser = new Twig_SupTwgSgg_ExpressionParser($this, $this->env);
|
91 |
}
|
92 |
|
93 |
$this->stream = $stream;
|
103 |
$body = $this->subparse($test, $dropNeedle);
|
104 |
|
105 |
if (null !== $this->parent && null === $body = $this->filterBodyNodes($body)) {
|
106 |
+
$body = new Twig_SupTwgSgg_Node();
|
107 |
}
|
108 |
+
} catch (Twig_SupTwgSgg_Error_Syntax $e) {
|
109 |
if (!$e->getSourceContext()) {
|
110 |
$e->setSourceContext($this->stream->getSourceContext());
|
111 |
}
|
117 |
throw $e;
|
118 |
}
|
119 |
|
120 |
+
$node = new Twig_SupTwgSgg_Node_Module(new Twig_SupTwgSgg_Node_Body(array($body)), $this->parent, new Twig_SupTwgSgg_Node($this->blocks), new Twig_SupTwgSgg_Node($this->macros), new Twig_SupTwgSgg_Node($this->traits), $this->embeddedTemplates, $stream->getSourceContext());
|
121 |
|
122 |
+
$traverser = new Twig_SupTwgSgg_NodeTraverser($this->env, $this->visitors);
|
123 |
|
124 |
$node = $traverser->traverse($node);
|
125 |
|
137 |
$rv = array();
|
138 |
while (!$this->stream->isEOF()) {
|
139 |
switch ($this->getCurrentToken()->getType()) {
|
140 |
+
case Twig_SupTwgSgg_Token::TEXT_TYPE:
|
141 |
$token = $this->stream->next();
|
142 |
+
$rv[] = new Twig_SupTwgSgg_Node_Text($token->getValue(), $token->getLine());
|
143 |
break;
|
144 |
|
145 |
+
case Twig_SupTwgSgg_Token::VAR_START_TYPE:
|
146 |
$token = $this->stream->next();
|
147 |
$expr = $this->expressionParser->parseExpression();
|
148 |
+
$this->stream->expect(Twig_SupTwgSgg_Token::VAR_END_TYPE);
|
149 |
+
$rv[] = new Twig_SupTwgSgg_Node_Print($expr, $token->getLine());
|
150 |
break;
|
151 |
|
152 |
+
case Twig_SupTwgSgg_Token::BLOCK_START_TYPE:
|
153 |
$this->stream->next();
|
154 |
$token = $this->getCurrentToken();
|
155 |
|
156 |
+
if ($token->getType() !== Twig_SupTwgSgg_Token::NAME_TYPE) {
|
157 |
+
throw new Twig_SupTwgSgg_Error_Syntax('A block must start with a tag name.', $token->getLine(), $this->stream->getSourceContext());
|
158 |
}
|
159 |
|
160 |
if (null !== $test && call_user_func($test, $token)) {
|
166 |
return $rv[0];
|
167 |
}
|
168 |
|
169 |
+
return new Twig_SupTwgSgg_Node($rv, array(), $lineno);
|
170 |
}
|
171 |
|
172 |
$subparser = $this->handlers->getTokenParser($token->getValue());
|
173 |
if (null === $subparser) {
|
174 |
if (null !== $test) {
|
175 |
+
$e = new Twig_SupTwgSgg_Error_Syntax(sprintf('Unexpected "%s" tag', $token->getValue()), $token->getLine(), $this->stream->getSourceContext());
|
176 |
|
177 |
+
if (is_array($test) && isset($test[0]) && $test[0] instanceof Twig_SupTwgSgg_TokenParserInterface) {
|
178 |
$e->appendMessage(sprintf(' (expecting closing tag for the "%s" tag defined near line %s).', $test[0]->getTag(), $lineno));
|
179 |
}
|
180 |
} else {
|
181 |
+
$e = new Twig_SupTwgSgg_Error_Syntax(sprintf('Unknown "%s" tag.', $token->getValue()), $token->getLine(), $this->stream->getSourceContext());
|
182 |
$e->addSuggestions($token->getValue(), array_keys($this->env->getTags()));
|
183 |
}
|
184 |
|
194 |
break;
|
195 |
|
196 |
default:
|
197 |
+
throw new Twig_SupTwgSgg_Error_Syntax('Lexer or parser ended up in unsupported state.', $this->getCurrentToken()->getLine(), $this->stream->getSourceContext());
|
198 |
}
|
199 |
}
|
200 |
|
202 |
return $rv[0];
|
203 |
}
|
204 |
|
205 |
+
return new Twig_SupTwgSgg_Node($rv, array(), $lineno);
|
206 |
}
|
207 |
|
208 |
/**
|
210 |
*/
|
211 |
public function addHandler($name, $class)
|
212 |
{
|
213 |
+
//@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0.', E_USER_DEPRECATED);
|
214 |
|
215 |
$this->handlers[$name] = $class;
|
216 |
}
|
218 |
/**
|
219 |
* @deprecated since 1.27 (to be removed in 2.0)
|
220 |
*/
|
221 |
+
public function addNodeVisitor(Twig_SupTwgSgg_NodeVisitorInterface $visitor)
|
222 |
{
|
223 |
+
//@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0.', E_USER_DEPRECATED);
|
224 |
|
225 |
$this->visitors[] = $visitor;
|
226 |
}
|
255 |
return $this->blocks[$name];
|
256 |
}
|
257 |
|
258 |
+
public function setBlock($name, Twig_SupTwgSgg_Node_Block $value)
|
259 |
{
|
260 |
+
$this->blocks[$name] = new Twig_SupTwgSgg_Node_Body(array($value), array(), $value->getTemplateLine());
|
261 |
}
|
262 |
|
263 |
public function hasMacro($name)
|
265 |
return isset($this->macros[$name]);
|
266 |
}
|
267 |
|
268 |
+
public function setMacro($name, Twig_SupTwgSgg_Node_Macro $node)
|
269 |
{
|
270 |
if ($this->isReservedMacroName($name)) {
|
271 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('"%s" cannot be used as a macro name as it is a reserved keyword.', $name), $node->getTemplateLine(), $this->stream->getSourceContext());
|
272 |
}
|
273 |
|
274 |
$this->macros[$name] = $node;
|
301 |
return count($this->traits) > 0;
|
302 |
}
|
303 |
|
304 |
+
public function embedTemplate(Twig_SupTwgSgg_Node_Module $template)
|
305 |
{
|
306 |
$template->setIndex(mt_rand());
|
307 |
|
308 |
$this->embeddedTemplates[] = $template;
|
309 |
}
|
310 |
|
311 |
+
public function addImportedSymbol($type, $alias, $name = null, Twig_SupTwgSgg_Node_Expression $node = null)
|
312 |
{
|
313 |
$this->importedSymbols[0][$type][$alias] = array('name' => $name, 'node' => $node);
|
314 |
}
|
338 |
}
|
339 |
|
340 |
/**
|
341 |
+
* @return Twig_SupTwgSgg_ExpressionParser
|
342 |
*/
|
343 |
public function getExpressionParser()
|
344 |
{
|
356 |
}
|
357 |
|
358 |
/**
|
359 |
+
* @return Twig_SupTwgSgg_TokenStream
|
360 |
*/
|
361 |
public function getStream()
|
362 |
{
|
364 |
}
|
365 |
|
366 |
/**
|
367 |
+
* @return Twig_SupTwgSgg_Token
|
368 |
*/
|
369 |
public function getCurrentToken()
|
370 |
{
|
371 |
return $this->stream->getCurrent();
|
372 |
}
|
373 |
|
374 |
+
protected function filterBodyNodes(Twig_SupTwgSgg_NodeInterface $node)
|
375 |
{
|
376 |
// check that the body does not contain non-empty output nodes
|
377 |
if (
|
378 |
+
($node instanceof Twig_SupTwgSgg_Node_Text && !ctype_space($node->getAttribute('data')))
|
379 |
||
|
380 |
+
(!$node instanceof Twig_SupTwgSgg_Node_Text && !$node instanceof Twig_SupTwgSgg_Node_BlockReference && $node instanceof Twig_SupTwgSgg_NodeOutputInterface)
|
381 |
) {
|
382 |
if (false !== strpos((string) $node, chr(0xEF).chr(0xBB).chr(0xBF))) {
|
383 |
+
throw new Twig_SupTwgSgg_Error_Syntax('A template that extends another one cannot start with a byte order mark (BOM); it must be removed.', $node->getTemplateLine(), $this->stream->getSourceContext());
|
384 |
}
|
385 |
|
386 |
+
throw new Twig_SupTwgSgg_Error_Syntax('A template that extends another one cannot include contents outside Twig blocks. Did you forget to put the contents inside a {% block %} tag?', $node->getTemplateLine(), $this->stream->getSourceContext());
|
387 |
}
|
388 |
|
389 |
// bypass nodes that will "capture" the output
|
390 |
+
if ($node instanceof Twig_SupTwgSgg_NodeCaptureInterface) {
|
391 |
return $node;
|
392 |
}
|
393 |
|
394 |
+
if ($node instanceof Twig_SupTwgSgg_NodeOutputInterface) {
|
395 |
return;
|
396 |
}
|
397 |
|
vendor/Twig/ParserInterface.php
CHANGED
@@ -16,14 +16,14 @@
|
|
16 |
*
|
17 |
* @deprecated since 1.12 (to be removed in 3.0)
|
18 |
*/
|
19 |
-
interface
|
20 |
{
|
21 |
/**
|
22 |
* Converts a token stream to a node tree.
|
23 |
*
|
24 |
-
* @return
|
25 |
*
|
26 |
-
* @throws
|
27 |
*/
|
28 |
-
public function parse(
|
29 |
}
|
16 |
*
|
17 |
* @deprecated since 1.12 (to be removed in 3.0)
|
18 |
*/
|
19 |
+
interface Twig_SupTwgSgg_ParserInterface
|
20 |
{
|
21 |
/**
|
22 |
* Converts a token stream to a node tree.
|
23 |
*
|
24 |
+
* @return Twig_SupTwgSgg_Node_Module
|
25 |
*
|
26 |
+
* @throws Twig_SupTwgSgg_Error_Syntax When the token stream is syntactically or semantically wrong
|
27 |
*/
|
28 |
+
public function parse(Twig_SupTwgSgg_TokenStream $stream);
|
29 |
}
|
vendor/Twig/Profiler/Dumper/Blackfire.php
CHANGED
@@ -14,9 +14,9 @@
|
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
-
public function dump(
|
20 |
{
|
21 |
$data = array();
|
22 |
$this->dumpProfile('main()', $profile, $data);
|
@@ -38,7 +38,7 @@ EOF;
|
|
38 |
return $str;
|
39 |
}
|
40 |
|
41 |
-
private function dumpChildren($parent,
|
42 |
{
|
43 |
foreach ($profile as $p) {
|
44 |
if ($p->isTemplate()) {
|
@@ -51,7 +51,7 @@ EOF;
|
|
51 |
}
|
52 |
}
|
53 |
|
54 |
-
private function dumpProfile($edge,
|
55 |
{
|
56 |
if (isset($data[$edge])) {
|
57 |
$data[$edge]['ct'] += 1;
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Profiler_Dumper_Blackfire
|
18 |
{
|
19 |
+
public function dump(Twig_SupTwgSgg_Profiler_Profile $profile)
|
20 |
{
|
21 |
$data = array();
|
22 |
$this->dumpProfile('main()', $profile, $data);
|
38 |
return $str;
|
39 |
}
|
40 |
|
41 |
+
private function dumpChildren($parent, Twig_SupTwgSgg_Profiler_Profile $profile, &$data)
|
42 |
{
|
43 |
foreach ($profile as $p) {
|
44 |
if ($p->isTemplate()) {
|
51 |
}
|
52 |
}
|
53 |
|
54 |
+
private function dumpProfile($edge, Twig_SupTwgSgg_Profiler_Profile $profile, &$data)
|
55 |
{
|
56 |
if (isset($data[$edge])) {
|
57 |
$data[$edge]['ct'] += 1;
|
vendor/Twig/Profiler/Dumper/Html.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
private static $colors = array(
|
20 |
'block' => '#dfd',
|
@@ -23,22 +23,22 @@ class Twig_SupTwg_Profiler_Dumper_Html extends Twig_SupTwg_Profiler_Dumper_Text
|
|
23 |
'big' => '#d44',
|
24 |
);
|
25 |
|
26 |
-
public function dump(
|
27 |
{
|
28 |
return '<pre>'.parent::dump($profile).'</pre>';
|
29 |
}
|
30 |
|
31 |
-
protected function formatTemplate(
|
32 |
{
|
33 |
return sprintf('%s└ <span style="background-color: %s">%s</span>', $prefix, self::$colors['template'], $profile->getTemplate());
|
34 |
}
|
35 |
|
36 |
-
protected function formatNonTemplate(
|
37 |
{
|
38 |
return sprintf('%s└ %s::%s(<span style="background-color: %s">%s</span>)', $prefix, $profile->getTemplate(), $profile->getType(), isset(self::$colors[$profile->getType()]) ? self::$colors[$profile->getType()] : 'auto', $profile->getName());
|
39 |
}
|
40 |
|
41 |
-
protected function formatTime(
|
42 |
{
|
43 |
return sprintf('<span style="color: %s">%.2fms/%.0f%%</span>', $percent > 20 ? self::$colors['big'] : 'auto', $profile->getDuration() * 1000, $percent);
|
44 |
}
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Profiler_Dumper_Html extends Twig_SupTwgSgg_Profiler_Dumper_Text
|
18 |
{
|
19 |
private static $colors = array(
|
20 |
'block' => '#dfd',
|
23 |
'big' => '#d44',
|
24 |
);
|
25 |
|
26 |
+
public function dump(Twig_SupTwgSgg_Profiler_Profile $profile)
|
27 |
{
|
28 |
return '<pre>'.parent::dump($profile).'</pre>';
|
29 |
}
|
30 |
|
31 |
+
protected function formatTemplate(Twig_SupTwgSgg_Profiler_Profile $profile, $prefix)
|
32 |
{
|
33 |
return sprintf('%s└ <span style="background-color: %s">%s</span>', $prefix, self::$colors['template'], $profile->getTemplate());
|
34 |
}
|
35 |
|
36 |
+
protected function formatNonTemplate(Twig_SupTwgSgg_Profiler_Profile $profile, $prefix)
|
37 |
{
|
38 |
return sprintf('%s└ %s::%s(<span style="background-color: %s">%s</span>)', $prefix, $profile->getTemplate(), $profile->getType(), isset(self::$colors[$profile->getType()]) ? self::$colors[$profile->getType()] : 'auto', $profile->getName());
|
39 |
}
|
40 |
|
41 |
+
protected function formatTime(Twig_SupTwgSgg_Profiler_Profile $profile, $percent)
|
42 |
{
|
43 |
return sprintf('<span style="color: %s">%.2fms/%.0f%%</span>', $percent > 20 ? self::$colors['big'] : 'auto', $profile->getDuration() * 1000, $percent);
|
44 |
}
|
vendor/Twig/Profiler/Dumper/Text.php
CHANGED
@@ -14,31 +14,31 @@
|
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
private $root;
|
20 |
|
21 |
-
public function dump(
|
22 |
{
|
23 |
return $this->dumpProfile($profile);
|
24 |
}
|
25 |
|
26 |
-
protected function formatTemplate(
|
27 |
{
|
28 |
return sprintf('%s└ %s', $prefix, $profile->getTemplate());
|
29 |
}
|
30 |
|
31 |
-
protected function formatNonTemplate(
|
32 |
{
|
33 |
return sprintf('%s└ %s::%s(%s)', $prefix, $profile->getTemplate(), $profile->getType(), $profile->getName());
|
34 |
}
|
35 |
|
36 |
-
protected function formatTime(
|
37 |
{
|
38 |
return sprintf('%.2fms/%.0f%%', $profile->getDuration() * 1000, $percent);
|
39 |
}
|
40 |
|
41 |
-
private function dumpProfile(
|
42 |
{
|
43 |
if ($profile->isRoot()) {
|
44 |
$this->root = $profile->getDuration();
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Profiler_Dumper_Text
|
18 |
{
|
19 |
private $root;
|
20 |
|
21 |
+
public function dump(Twig_SupTwgSgg_Profiler_Profile $profile)
|
22 |
{
|
23 |
return $this->dumpProfile($profile);
|
24 |
}
|
25 |
|
26 |
+
protected function formatTemplate(Twig_SupTwgSgg_Profiler_Profile $profile, $prefix)
|
27 |
{
|
28 |
return sprintf('%s└ %s', $prefix, $profile->getTemplate());
|
29 |
}
|
30 |
|
31 |
+
protected function formatNonTemplate(Twig_SupTwgSgg_Profiler_Profile $profile, $prefix)
|
32 |
{
|
33 |
return sprintf('%s└ %s::%s(%s)', $prefix, $profile->getTemplate(), $profile->getType(), $profile->getName());
|
34 |
}
|
35 |
|
36 |
+
protected function formatTime(Twig_SupTwgSgg_Profiler_Profile $profile, $percent)
|
37 |
{
|
38 |
return sprintf('%.2fms/%.0f%%', $profile->getDuration() * 1000, $percent);
|
39 |
}
|
40 |
|
41 |
+
private function dumpProfile(Twig_SupTwgSgg_Profiler_Profile $profile, $prefix = '', $sibling = false)
|
42 |
{
|
43 |
if ($profile->isRoot()) {
|
44 |
$this->root = $profile->getDuration();
|
vendor/Twig/Profiler/Node/EnterProfile.php
CHANGED
@@ -14,20 +14,20 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
public function __construct($extensionName, $type, $name, $varName)
|
20 |
{
|
21 |
parent::__construct(array(), array('extension_name' => $extensionName, 'name' => $name, 'type' => $type, 'var_name' => $varName));
|
22 |
}
|
23 |
|
24 |
-
public function compile(
|
25 |
{
|
26 |
$compiler
|
27 |
->write(sprintf('$%s = $this->env->getExtension(', $this->getAttribute('var_name')))
|
28 |
->repr($this->getAttribute('extension_name'))
|
29 |
->raw(");\n")
|
30 |
-
->write(sprintf('$%s->enter($%s = new
|
31 |
->repr($this->getAttribute('type'))
|
32 |
->raw(', ')
|
33 |
->repr($this->getAttribute('name'))
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Profiler_Node_EnterProfile extends Twig_SupTwgSgg_Node
|
18 |
{
|
19 |
public function __construct($extensionName, $type, $name, $varName)
|
20 |
{
|
21 |
parent::__construct(array(), array('extension_name' => $extensionName, 'name' => $name, 'type' => $type, 'var_name' => $varName));
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
25 |
{
|
26 |
$compiler
|
27 |
->write(sprintf('$%s = $this->env->getExtension(', $this->getAttribute('var_name')))
|
28 |
->repr($this->getAttribute('extension_name'))
|
29 |
->raw(");\n")
|
30 |
+
->write(sprintf('$%s->enter($%s = new Twig_SupTwgSgg_Profiler_Profile($this->getTemplateName(), ', $this->getAttribute('var_name'), $this->getAttribute('var_name').'_prof'))
|
31 |
->repr($this->getAttribute('type'))
|
32 |
->raw(', ')
|
33 |
->repr($this->getAttribute('name'))
|
vendor/Twig/Profiler/Node/LeaveProfile.php
CHANGED
@@ -14,14 +14,14 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
public function __construct($varName)
|
20 |
{
|
21 |
parent::__construct(array(), array('var_name' => $varName));
|
22 |
}
|
23 |
|
24 |
-
public function compile(
|
25 |
{
|
26 |
$compiler
|
27 |
->write("\n")
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Profiler_Node_LeaveProfile extends Twig_SupTwgSgg_Node
|
18 |
{
|
19 |
public function __construct($varName)
|
20 |
{
|
21 |
parent::__construct(array(), array('var_name' => $varName));
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_SupTwgSgg_Compiler $compiler)
|
25 |
{
|
26 |
$compiler
|
27 |
->write("\n")
|
vendor/Twig/Profiler/NodeVisitor/Profiler.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
private $extensionName;
|
20 |
|
@@ -23,30 +23,30 @@ class Twig_SupTwg_Profiler_NodeVisitor_Profiler extends Twig_SupTwg_BaseNodeVisi
|
|
23 |
$this->extensionName = $extensionName;
|
24 |
}
|
25 |
|
26 |
-
protected function doEnterNode(
|
27 |
{
|
28 |
return $node;
|
29 |
}
|
30 |
|
31 |
-
protected function doLeaveNode(
|
32 |
{
|
33 |
-
if ($node instanceof
|
34 |
$varName = $this->getVarName();
|
35 |
-
$node->setNode('display_start', new
|
36 |
-
$node->setNode('display_end', new
|
37 |
-
} elseif ($node instanceof
|
38 |
$varName = $this->getVarName();
|
39 |
-
$node->setNode('body', new
|
40 |
-
new
|
41 |
$node->getNode('body'),
|
42 |
-
new
|
43 |
)));
|
44 |
-
} elseif ($node instanceof
|
45 |
$varName = $this->getVarName();
|
46 |
-
$node->setNode('body', new
|
47 |
-
new
|
48 |
$node->getNode('body'),
|
49 |
-
new
|
50 |
)));
|
51 |
}
|
52 |
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Profiler_NodeVisitor_Profiler extends Twig_SupTwgSgg_BaseNodeVisitor
|
18 |
{
|
19 |
private $extensionName;
|
20 |
|
23 |
$this->extensionName = $extensionName;
|
24 |
}
|
25 |
|
26 |
+
protected function doEnterNode(Twig_SupTwgSgg_Node $node, Twig_SupTwgSgg_Environment $env)
|
27 |
{
|
28 |
return $node;
|
29 |
}
|
30 |
|
31 |
+
protected function doLeaveNode(Twig_SupTwgSgg_Node $node, Twig_SupTwgSgg_Environment $env)
|
32 |
{
|
33 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Module) {
|
34 |
$varName = $this->getVarName();
|
35 |
+
$node->setNode('display_start', new Twig_SupTwgSgg_Node(array(new Twig_SupTwgSgg_Profiler_Node_EnterProfile($this->extensionName, Twig_SupTwgSgg_Profiler_Profile::TEMPLATE, $node->getTemplateName(), $varName), $node->getNode('display_start'))));
|
36 |
+
$node->setNode('display_end', new Twig_SupTwgSgg_Node(array(new Twig_SupTwgSgg_Profiler_Node_LeaveProfile($varName), $node->getNode('display_end'))));
|
37 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_Block) {
|
38 |
$varName = $this->getVarName();
|
39 |
+
$node->setNode('body', new Twig_SupTwgSgg_Node_Body(array(
|
40 |
+
new Twig_SupTwgSgg_Profiler_Node_EnterProfile($this->extensionName, Twig_SupTwgSgg_Profiler_Profile::BLOCK, $node->getAttribute('name'), $varName),
|
41 |
$node->getNode('body'),
|
42 |
+
new Twig_SupTwgSgg_Profiler_Node_LeaveProfile($varName),
|
43 |
)));
|
44 |
+
} elseif ($node instanceof Twig_SupTwgSgg_Node_Macro) {
|
45 |
$varName = $this->getVarName();
|
46 |
+
$node->setNode('body', new Twig_SupTwgSgg_Node_Body(array(
|
47 |
+
new Twig_SupTwgSgg_Profiler_Node_EnterProfile($this->extensionName, Twig_SupTwgSgg_Profiler_Profile::MACRO, $node->getAttribute('name'), $varName),
|
48 |
$node->getNode('body'),
|
49 |
+
new Twig_SupTwgSgg_Profiler_Node_LeaveProfile($varName),
|
50 |
)));
|
51 |
}
|
52 |
|
vendor/Twig/Profiler/Profile.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
const ROOT = 'ROOT';
|
20 |
const BLOCK = 'block';
|
@@ -76,7 +76,7 @@ class Twig_SupTwg_Profiler_Profile implements IteratorAggregate, Serializable
|
|
76 |
return $this->profiles;
|
77 |
}
|
78 |
|
79 |
-
public function addProfile(
|
80 |
{
|
81 |
$this->profiles[] = $profile;
|
82 |
}
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Profiler_Profile implements IteratorAggregate, Serializable
|
18 |
{
|
19 |
const ROOT = 'ROOT';
|
20 |
const BLOCK = 'block';
|
76 |
return $this->profiles;
|
77 |
}
|
78 |
|
79 |
+
public function addProfile(Twig_SupTwgSgg_Profiler_Profile $profile)
|
80 |
{
|
81 |
$this->profiles[] = $profile;
|
82 |
}
|
vendor/Twig/RuntimeLoaderInterface.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
interface
|
18 |
{
|
19 |
/**
|
20 |
* Creates the runtime implementation of a Twig element (filter/function/test).
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
interface Twig_SupTwgSgg_RuntimeLoaderInterface
|
18 |
{
|
19 |
/**
|
20 |
* Creates the runtime implementation of a Twig element (filter/function/test).
|
vendor/Twig/Sandbox/SecurityError.php
CHANGED
@@ -14,6 +14,6 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
}
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Sandbox_SecurityError extends Twig_SupTwgSgg_Error
|
18 |
{
|
19 |
}
|
vendor/Twig/Sandbox/SecurityNotAllowedFilterError.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @author Martin Hasoň <martin.hason@gmail.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
private $filterName;
|
20 |
|
14 |
*
|
15 |
* @author Martin Hasoň <martin.hason@gmail.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Sandbox_SecurityNotAllowedFilterError extends Twig_SupTwgSgg_Sandbox_SecurityError
|
18 |
{
|
19 |
private $filterName;
|
20 |
|
vendor/Twig/Sandbox/SecurityNotAllowedFunctionError.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @author Martin Hasoň <martin.hason@gmail.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
private $functionName;
|
20 |
|
14 |
*
|
15 |
* @author Martin Hasoň <martin.hason@gmail.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Sandbox_SecurityNotAllowedFunctionError extends Twig_SupTwgSgg_Sandbox_SecurityError
|
18 |
{
|
19 |
private $functionName;
|
20 |
|
vendor/Twig/Sandbox/SecurityNotAllowedMethodError.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @author Kit Burton-Senior <mail@kitbs.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
private $className;
|
20 |
private $methodName;
|
14 |
*
|
15 |
* @author Kit Burton-Senior <mail@kitbs.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Sandbox_SecurityNotAllowedMethodError extends Twig_SupTwgSgg_Sandbox_SecurityError
|
18 |
{
|
19 |
private $className;
|
20 |
private $methodName;
|
vendor/Twig/Sandbox/SecurityNotAllowedPropertyError.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @author Kit Burton-Senior <mail@kitbs.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
private $className;
|
20 |
private $propertyName;
|
14 |
*
|
15 |
* @author Kit Burton-Senior <mail@kitbs.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Sandbox_SecurityNotAllowedPropertyError extends Twig_SupTwgSgg_Sandbox_SecurityError
|
18 |
{
|
19 |
private $className;
|
20 |
private $propertyName;
|
vendor/Twig/Sandbox/SecurityNotAllowedTagError.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @author Martin Hasoň <martin.hason@gmail.com>
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
private $tagName;
|
20 |
|
14 |
*
|
15 |
* @author Martin Hasoň <martin.hason@gmail.com>
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Sandbox_SecurityNotAllowedTagError extends Twig_SupTwgSgg_Sandbox_SecurityError
|
18 |
{
|
19 |
private $tagName;
|
20 |
|
vendor/Twig/Sandbox/SecurityPolicy.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
-
class
|
20 |
{
|
21 |
protected $allowedTags;
|
22 |
protected $allowedFilters;
|
@@ -65,26 +65,26 @@ class Twig_SupTwg_Sandbox_SecurityPolicy implements Twig_SupTwg_Sandbox_Security
|
|
65 |
{
|
66 |
foreach ($tags as $tag) {
|
67 |
if (!in_array($tag, $this->allowedTags)) {
|
68 |
-
throw new
|
69 |
}
|
70 |
}
|
71 |
|
72 |
foreach ($filters as $filter) {
|
73 |
if (!in_array($filter, $this->allowedFilters)) {
|
74 |
-
throw new
|
75 |
}
|
76 |
}
|
77 |
|
78 |
foreach ($functions as $function) {
|
79 |
if (!in_array($function, $this->allowedFunctions)) {
|
80 |
-
throw new
|
81 |
}
|
82 |
}
|
83 |
}
|
84 |
|
85 |
public function checkMethodAllowed($obj, $method)
|
86 |
{
|
87 |
-
if ($obj instanceof
|
88 |
return true;
|
89 |
}
|
90 |
|
@@ -100,7 +100,7 @@ class Twig_SupTwg_Sandbox_SecurityPolicy implements Twig_SupTwg_Sandbox_Security
|
|
100 |
|
101 |
if (!$allowed) {
|
102 |
$class = get_class($obj);
|
103 |
-
throw new
|
104 |
}
|
105 |
}
|
106 |
|
@@ -117,7 +117,7 @@ class Twig_SupTwg_Sandbox_SecurityPolicy implements Twig_SupTwg_Sandbox_Security
|
|
117 |
|
118 |
if (!$allowed) {
|
119 |
$class = get_class($obj);
|
120 |
-
throw new
|
121 |
}
|
122 |
}
|
123 |
}
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class Twig_SupTwgSgg_Sandbox_SecurityPolicy implements Twig_SupTwgSgg_Sandbox_SecurityPolicyInterface
|
20 |
{
|
21 |
protected $allowedTags;
|
22 |
protected $allowedFilters;
|
65 |
{
|
66 |
foreach ($tags as $tag) {
|
67 |
if (!in_array($tag, $this->allowedTags)) {
|
68 |
+
throw new Twig_SupTwgSgg_Sandbox_SecurityNotAllowedTagError(sprintf('Tag "%s" is not allowed.', $tag), $tag);
|
69 |
}
|
70 |
}
|
71 |
|
72 |
foreach ($filters as $filter) {
|
73 |
if (!in_array($filter, $this->allowedFilters)) {
|
74 |
+
throw new Twig_SupTwgSgg_Sandbox_SecurityNotAllowedFilterError(sprintf('Filter "%s" is not allowed.', $filter), $filter);
|
75 |
}
|
76 |
}
|
77 |
|
78 |
foreach ($functions as $function) {
|
79 |
if (!in_array($function, $this->allowedFunctions)) {
|
80 |
+
throw new Twig_SupTwgSgg_Sandbox_SecurityNotAllowedFunctionError(sprintf('Function "%s" is not allowed.', $function), $function);
|
81 |
}
|
82 |
}
|
83 |
}
|
84 |
|
85 |
public function checkMethodAllowed($obj, $method)
|
86 |
{
|
87 |
+
if ($obj instanceof Twig_SupTwgSgg_TemplateInterface || $obj instanceof Twig_SupTwgSgg_Markup) {
|
88 |
return true;
|
89 |
}
|
90 |
|
100 |
|
101 |
if (!$allowed) {
|
102 |
$class = get_class($obj);
|
103 |
+
throw new Twig_SupTwgSgg_Sandbox_SecurityNotAllowedMethodError(sprintf('Calling "%s" method on a "%s" object is not allowed.', $method, $class), $class, $method);
|
104 |
}
|
105 |
}
|
106 |
|
117 |
|
118 |
if (!$allowed) {
|
119 |
$class = get_class($obj);
|
120 |
+
throw new Twig_SupTwgSgg_Sandbox_SecurityNotAllowedPropertyError(sprintf('Calling "%s" property on a "%s" object is not allowed.', $property, $class), $class, $property);
|
121 |
}
|
122 |
}
|
123 |
}
|
vendor/Twig/Sandbox/SecurityPolicyInterface.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
interface
|
18 |
{
|
19 |
public function checkSecurity($tags, $filters, $functions);
|
20 |
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
interface Twig_SupTwgSgg_Sandbox_SecurityPolicyInterface
|
18 |
{
|
19 |
public function checkSecurity($tags, $filters, $functions);
|
20 |
|
vendor/Twig/SimpleFilter.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
-
class
|
20 |
{
|
21 |
protected $name;
|
22 |
protected $callable;
|
@@ -35,7 +35,7 @@ class Twig_SupTwg_SimpleFilter
|
|
35 |
'is_safe_callback' => null,
|
36 |
'pre_escape' => null,
|
37 |
'preserves_safety' => null,
|
38 |
-
'node_class' => '
|
39 |
'deprecated' => false,
|
40 |
'alternative' => null,
|
41 |
), $options);
|
@@ -76,7 +76,7 @@ class Twig_SupTwg_SimpleFilter
|
|
76 |
return $this->options['needs_context'];
|
77 |
}
|
78 |
|
79 |
-
public function getSafe(
|
80 |
{
|
81 |
if (null !== $this->options['is_safe']) {
|
82 |
return $this->options['is_safe'];
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class Twig_SupTwgSgg_SimpleFilter
|
20 |
{
|
21 |
protected $name;
|
22 |
protected $callable;
|
35 |
'is_safe_callback' => null,
|
36 |
'pre_escape' => null,
|
37 |
'preserves_safety' => null,
|
38 |
+
'node_class' => 'Twig_SupTwgSgg_Node_Expression_Filter',
|
39 |
'deprecated' => false,
|
40 |
'alternative' => null,
|
41 |
), $options);
|
76 |
return $this->options['needs_context'];
|
77 |
}
|
78 |
|
79 |
+
public function getSafe(Twig_SupTwgSgg_Node $filterArgs)
|
80 |
{
|
81 |
if (null !== $this->options['is_safe']) {
|
82 |
return $this->options['is_safe'];
|
vendor/Twig/SimpleFunction.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
-
class
|
20 |
{
|
21 |
protected $name;
|
22 |
protected $callable;
|
@@ -33,7 +33,7 @@ class Twig_SupTwg_SimpleFunction
|
|
33 |
'is_variadic' => false,
|
34 |
'is_safe' => null,
|
35 |
'is_safe_callback' => null,
|
36 |
-
'node_class' => '
|
37 |
'deprecated' => false,
|
38 |
'alternative' => null,
|
39 |
), $options);
|
@@ -74,7 +74,7 @@ class Twig_SupTwg_SimpleFunction
|
|
74 |
return $this->options['needs_context'];
|
75 |
}
|
76 |
|
77 |
-
public function getSafe(
|
78 |
{
|
79 |
if (null !== $this->options['is_safe']) {
|
80 |
return $this->options['is_safe'];
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class Twig_SupTwgSgg_SimpleFunction
|
20 |
{
|
21 |
protected $name;
|
22 |
protected $callable;
|
33 |
'is_variadic' => false,
|
34 |
'is_safe' => null,
|
35 |
'is_safe_callback' => null,
|
36 |
+
'node_class' => 'Twig_SupTwgSgg_Node_Expression_Function',
|
37 |
'deprecated' => false,
|
38 |
'alternative' => null,
|
39 |
), $options);
|
74 |
return $this->options['needs_context'];
|
75 |
}
|
76 |
|
77 |
+
public function getSafe(Twig_SupTwgSgg_Node $functionArgs)
|
78 |
{
|
79 |
if (null !== $this->options['is_safe']) {
|
80 |
return $this->options['is_safe'];
|
vendor/Twig/SimpleTest.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
-
class
|
20 |
{
|
21 |
protected $name;
|
22 |
protected $callable;
|
@@ -28,7 +28,7 @@ class Twig_SupTwg_SimpleTest
|
|
28 |
$this->callable = $callable;
|
29 |
$this->options = array_merge(array(
|
30 |
'is_variadic' => false,
|
31 |
-
'node_class' => '
|
32 |
'deprecated' => false,
|
33 |
'alternative' => null,
|
34 |
), $options);
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class Twig_SupTwgSgg_SimpleTest
|
20 |
{
|
21 |
protected $name;
|
22 |
protected $callable;
|
28 |
$this->callable = $callable;
|
29 |
$this->options = array_merge(array(
|
30 |
'is_variadic' => false,
|
31 |
+
'node_class' => 'Twig_SupTwgSgg_Node_Expression_Test',
|
32 |
'deprecated' => false,
|
33 |
'alternative' => null,
|
34 |
), $options);
|
vendor/Twig/Source.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
-
class
|
20 |
{
|
21 |
private $code;
|
22 |
private $name;
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class Twig_SupTwgSgg_Source
|
20 |
{
|
21 |
private $code;
|
22 |
private $name;
|
vendor/Twig/SourceContextLoaderInterface.php
CHANGED
@@ -16,16 +16,16 @@
|
|
16 |
*
|
17 |
* @deprecated since 1.27 (to be removed in 3.0)
|
18 |
*/
|
19 |
-
interface
|
20 |
{
|
21 |
/**
|
22 |
* Returns the source context for a given template logical name.
|
23 |
*
|
24 |
* @param string $name The template logical name
|
25 |
*
|
26 |
-
* @return
|
27 |
*
|
28 |
-
* @throws
|
29 |
*/
|
30 |
public function getSourceContext($name);
|
31 |
}
|
16 |
*
|
17 |
* @deprecated since 1.27 (to be removed in 3.0)
|
18 |
*/
|
19 |
+
interface Twig_SupTwgSgg_SourceContextLoaderInterface
|
20 |
{
|
21 |
/**
|
22 |
* Returns the source context for a given template logical name.
|
23 |
*
|
24 |
* @param string $name The template logical name
|
25 |
*
|
26 |
+
* @return Twig_SupTwgSgg_Source
|
27 |
*
|
28 |
+
* @throws Twig_SupTwgSgg_Error_Loader When $name is not found
|
29 |
*/
|
30 |
public function getSourceContext($name);
|
31 |
}
|
vendor/Twig/Template.php
CHANGED
@@ -15,13 +15,13 @@
|
|
15 |
*
|
16 |
* This class is an implementation detail of how template compilation currently
|
17 |
* works, which might change. It should never be used directly. Use $twig->load()
|
18 |
-
* instead, which returns an instance of
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*
|
22 |
* @internal
|
23 |
*/
|
24 |
-
abstract class
|
25 |
{
|
26 |
/**
|
27 |
* @internal
|
@@ -34,7 +34,7 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
34 |
protected $blocks = array();
|
35 |
protected $traits = array();
|
36 |
|
37 |
-
public function __construct(
|
38 |
{
|
39 |
$this->env = $env;
|
40 |
}
|
@@ -75,7 +75,7 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
75 |
*/
|
76 |
public function getSource()
|
77 |
{
|
78 |
-
|
79 |
|
80 |
return '';
|
81 |
}
|
@@ -83,11 +83,11 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
83 |
/**
|
84 |
* Returns information about the original template source code.
|
85 |
*
|
86 |
-
* @return
|
87 |
*/
|
88 |
public function getSourceContext()
|
89 |
{
|
90 |
-
return new
|
91 |
}
|
92 |
|
93 |
/**
|
@@ -95,7 +95,7 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
95 |
*/
|
96 |
public function getEnvironment()
|
97 |
{
|
98 |
-
|
99 |
|
100 |
return $this->env;
|
101 |
}
|
@@ -108,7 +108,7 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
108 |
*
|
109 |
* @param array $context
|
110 |
*
|
111 |
-
* @return
|
112 |
*
|
113 |
* @internal
|
114 |
*/
|
@@ -132,7 +132,7 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
132 |
if (!isset($this->parents[$parent])) {
|
133 |
$this->parents[$parent] = $this->loadTemplate($parent);
|
134 |
}
|
135 |
-
} catch (
|
136 |
$e->setSourceContext(null);
|
137 |
$e->guess();
|
138 |
|
@@ -173,7 +173,7 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
173 |
} elseif (false !== $parent = $this->getParent($context)) {
|
174 |
$parent->displayBlock($name, $context, $blocks, false);
|
175 |
} else {
|
176 |
-
throw new
|
177 |
}
|
178 |
}
|
179 |
|
@@ -207,19 +207,19 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
207 |
|
208 |
// avoid RCEs when sandbox is enabled
|
209 |
if (null !== $template && !$template instanceof self) {
|
210 |
-
throw new LogicException('A block must be a method on a
|
211 |
}
|
212 |
|
213 |
if (null !== $template) {
|
214 |
try {
|
215 |
$template->$block($context, $blocks);
|
216 |
-
} catch (
|
217 |
if (!$e->getSourceContext()) {
|
218 |
$e->setSourceContext($template->getSourceContext());
|
219 |
}
|
220 |
|
221 |
-
// this is mostly useful for
|
222 |
-
// see
|
223 |
if (false === $e->getTemplateLine()) {
|
224 |
$e->setTemplateLine(-1);
|
225 |
$e->guess();
|
@@ -227,12 +227,12 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
227 |
|
228 |
throw $e;
|
229 |
} catch (Exception $e) {
|
230 |
-
throw new
|
231 |
}
|
232 |
} elseif (false !== $parent = $this->getParent($context)) {
|
233 |
$parent->displayBlock($name, $context, array_merge($this->blocks, $blocks), false);
|
234 |
} else {
|
235 |
-
|
236 |
}
|
237 |
}
|
238 |
|
@@ -298,7 +298,7 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
298 |
public function hasBlock($name, array $context = null, array $blocks = array())
|
299 |
{
|
300 |
if (null === $context) {
|
301 |
-
|
302 |
|
303 |
return isset($this->blocks[(string) $name]);
|
304 |
}
|
@@ -334,7 +334,7 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
334 |
public function getBlockNames(array $context = null, array $blocks = array())
|
335 |
{
|
336 |
if (null === $context) {
|
337 |
-
|
338 |
|
339 |
return array_keys($this->blocks);
|
340 |
}
|
@@ -359,14 +359,14 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
359 |
return $template;
|
360 |
}
|
361 |
|
362 |
-
if ($template instanceof
|
363 |
return $template;
|
364 |
}
|
365 |
|
366 |
return $this->env->loadTemplate($template, $index);
|
367 |
-
} catch (
|
368 |
if (!$e->getSourceContext()) {
|
369 |
-
$e->setSourceContext($templateName ? new
|
370 |
}
|
371 |
|
372 |
if ($e->getTemplateLine()) {
|
@@ -430,13 +430,13 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
430 |
{
|
431 |
try {
|
432 |
$this->doDisplay($context, $blocks);
|
433 |
-
} catch (
|
434 |
if (!$e->getSourceContext()) {
|
435 |
$e->setSourceContext($this->getSourceContext());
|
436 |
}
|
437 |
|
438 |
-
// this is mostly useful for
|
439 |
-
// see
|
440 |
if (false === $e->getTemplateLine()) {
|
441 |
$e->setTemplateLine(-1);
|
442 |
$e->guess();
|
@@ -444,7 +444,7 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
444 |
|
445 |
throw $e;
|
446 |
} catch (Exception $e) {
|
447 |
-
throw new
|
448 |
}
|
449 |
}
|
450 |
|
@@ -473,7 +473,7 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
473 |
*
|
474 |
* @return mixed The content of the context variable
|
475 |
*
|
476 |
-
* @throws
|
477 |
*
|
478 |
* @internal
|
479 |
*/
|
@@ -484,7 +484,7 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
484 |
return;
|
485 |
}
|
486 |
|
487 |
-
throw new
|
488 |
}
|
489 |
|
490 |
return $context[$item];
|
@@ -496,13 +496,13 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
496 |
* @param mixed $object The object or array from where to get the item
|
497 |
* @param mixed $item The item to get from the array or object
|
498 |
* @param array $arguments An array of arguments to pass if the item is an object method
|
499 |
-
* @param string $type The type of attribute (@see
|
500 |
* @param bool $isDefinedTest Whether this is only a defined check
|
501 |
* @param bool $ignoreStrictCheck Whether to ignore the strict attribute check or not
|
502 |
*
|
503 |
* @return mixed The attribute value, or a Boolean when $isDefinedTest is true, or null when the attribute is not set and $ignoreStrictCheck is true
|
504 |
*
|
505 |
-
* @throws
|
506 |
*
|
507 |
* @internal
|
508 |
*/
|
@@ -553,7 +553,7 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
553 |
$message = sprintf('Impossible to access an attribute ("%s") on a %s variable ("%s").', $item, gettype($object), $object);
|
554 |
}
|
555 |
|
556 |
-
throw new
|
557 |
}
|
558 |
}
|
559 |
|
@@ -572,18 +572,18 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
572 |
$message = sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s").', $item, gettype($object), $object);
|
573 |
}
|
574 |
|
575 |
-
throw new
|
576 |
}
|
577 |
|
578 |
// object property
|
579 |
-
if (self::METHOD_CALL !== $type && !$object instanceof self) { //
|
580 |
if (isset($object->$item) || !empty($object->$item)) {
|
581 |
if ($isDefinedTest) {
|
582 |
return true;
|
583 |
}
|
584 |
|
585 |
-
if ($this->env->hasExtension('
|
586 |
-
$this->env->getExtension('
|
587 |
}
|
588 |
|
589 |
return $object->$item;
|
@@ -657,15 +657,15 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
657 |
return;
|
658 |
}
|
659 |
|
660 |
-
throw new
|
661 |
}
|
662 |
|
663 |
if ($isDefinedTest) {
|
664 |
return true;
|
665 |
}
|
666 |
|
667 |
-
if ($this->env->hasExtension('
|
668 |
-
$this->env->getExtension('
|
669 |
}
|
670 |
|
671 |
// Some objects throw exceptions when they have __call, and the method we try
|
@@ -684,7 +684,7 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
684 |
}
|
685 |
|
686 |
// @deprecated in 1.28
|
687 |
-
if ($object instanceof
|
688 |
$self = $object->getTemplateName() === $this->getTemplateName();
|
689 |
$message = sprintf('Calling "%s" on template "%s" from template "%s" is deprecated since version 1.28 and won\'t be supported anymore in 2.0.', $item, $object->getTemplateName(), $this->getTemplateName());
|
690 |
if ('renderBlock' === $method || 'displayBlock' === $method) {
|
@@ -694,9 +694,9 @@ abstract class Twig_SupTwg_Template implements Twig_SupTwg_TemplateInterface
|
|
694 |
} elseif ('render' === $method || 'display' === $method) {
|
695 |
$message .= sprintf(' Use include("%s") instead).', $object->getTemplateName());
|
696 |
}
|
697 |
-
|
698 |
|
699 |
-
return $ret === '' ? '' : new
|
700 |
}
|
701 |
|
702 |
return $ret;
|
15 |
*
|
16 |
* This class is an implementation detail of how template compilation currently
|
17 |
* works, which might change. It should never be used directly. Use $twig->load()
|
18 |
+
* instead, which returns an instance of Twig_SupTwgSgg_TemplateWrapper.
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*
|
22 |
* @internal
|
23 |
*/
|
24 |
+
abstract class Twig_SupTwgSgg_Template implements Twig_SupTwgSgg_TemplateInterface
|
25 |
{
|
26 |
/**
|
27 |
* @internal
|
34 |
protected $blocks = array();
|
35 |
protected $traits = array();
|
36 |
|
37 |
+
public function __construct(Twig_SupTwgSgg_Environment $env)
|
38 |
{
|
39 |
$this->env = $env;
|
40 |
}
|
75 |
*/
|
76 |
public function getSource()
|
77 |
{
|
78 |
+
//@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', E_USER_DEPRECATED);
|
79 |
|
80 |
return '';
|
81 |
}
|
83 |
/**
|
84 |
* Returns information about the original template source code.
|
85 |
*
|
86 |
+
* @return Twig_SupTwgSgg_Source
|
87 |
*/
|
88 |
public function getSourceContext()
|
89 |
{
|
90 |
+
return new Twig_SupTwgSgg_Source('', $this->getTemplateName());
|
91 |
}
|
92 |
|
93 |
/**
|
95 |
*/
|
96 |
public function getEnvironment()
|
97 |
{
|
98 |
+
//@trigger_error('The '.__METHOD__.' method is deprecated since version 1.20 and will be removed in 2.0.', E_USER_DEPRECATED);
|
99 |
|
100 |
return $this->env;
|
101 |
}
|
108 |
*
|
109 |
* @param array $context
|
110 |
*
|
111 |
+
* @return Twig_SupTwgSgg_TemplateInterface|false The parent template or false if there is no parent
|
112 |
*
|
113 |
* @internal
|
114 |
*/
|
132 |
if (!isset($this->parents[$parent])) {
|
133 |
$this->parents[$parent] = $this->loadTemplate($parent);
|
134 |
}
|
135 |
+
} catch (Twig_SupTwgSgg_Error_Loader $e) {
|
136 |
$e->setSourceContext(null);
|
137 |
$e->guess();
|
138 |
|
173 |
} elseif (false !== $parent = $this->getParent($context)) {
|
174 |
$parent->displayBlock($name, $context, $blocks, false);
|
175 |
} else {
|
176 |
+
throw new Twig_SupTwgSgg_Error_Runtime(sprintf('The template has no parent and no traits defining the "%s" block.', $name), -1, $this->getSourceContext());
|
177 |
}
|
178 |
}
|
179 |
|
207 |
|
208 |
// avoid RCEs when sandbox is enabled
|
209 |
if (null !== $template && !$template instanceof self) {
|
210 |
+
throw new LogicException('A block must be a method on a Twig_SupTwgSgg_Template instance.');
|
211 |
}
|
212 |
|
213 |
if (null !== $template) {
|
214 |
try {
|
215 |
$template->$block($context, $blocks);
|
216 |
+
} catch (Twig_SupTwgSgg_Error $e) {
|
217 |
if (!$e->getSourceContext()) {
|
218 |
$e->setSourceContext($template->getSourceContext());
|
219 |
}
|
220 |
|
221 |
+
// this is mostly useful for Twig_SupTwgSgg_Error_Loader exceptions
|
222 |
+
// see Twig_SupTwgSgg_Error_Loader
|
223 |
if (false === $e->getTemplateLine()) {
|
224 |
$e->setTemplateLine(-1);
|
225 |
$e->guess();
|
227 |
|
228 |
throw $e;
|
229 |
} catch (Exception $e) {
|
230 |
+
throw new Twig_SupTwgSgg_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $template->getSourceContext(), $e);
|
231 |
}
|
232 |
} elseif (false !== $parent = $this->getParent($context)) {
|
233 |
$parent->displayBlock($name, $context, array_merge($this->blocks, $blocks), false);
|
234 |
} else {
|
235 |
+
//@trigger_error(sprintf('Silent display of undefined block "%s" in template "%s" is deprecated since version 1.29 and will throw an exception in 2.0. Use the "block(\'%s\') is defined" expression to test for block existence.', $name, $this->getTemplateName(), $name), E_USER_DEPRECATED);
|
236 |
}
|
237 |
}
|
238 |
|
298 |
public function hasBlock($name, array $context = null, array $blocks = array())
|
299 |
{
|
300 |
if (null === $context) {
|
301 |
+
//@trigger_error('The '.__METHOD__.' method is internal and should never be called; calling it directly is deprecated since version 1.28 and won\'t be possible anymore in 2.0.', E_USER_DEPRECATED);
|
302 |
|
303 |
return isset($this->blocks[(string) $name]);
|
304 |
}
|
334 |
public function getBlockNames(array $context = null, array $blocks = array())
|
335 |
{
|
336 |
if (null === $context) {
|
337 |
+
//@trigger_error('The '.__METHOD__.' method is internal and should never be called; calling it directly is deprecated since version 1.28 and won\'t be possible anymore in 2.0.', E_USER_DEPRECATED);
|
338 |
|
339 |
return array_keys($this->blocks);
|
340 |
}
|
359 |
return $template;
|
360 |
}
|
361 |
|
362 |
+
if ($template instanceof Twig_SupTwgSgg_TemplateWrapper) {
|
363 |
return $template;
|
364 |
}
|
365 |
|
366 |
return $this->env->loadTemplate($template, $index);
|
367 |
+
} catch (Twig_SupTwgSgg_Error $e) {
|
368 |
if (!$e->getSourceContext()) {
|
369 |
+
$e->setSourceContext($templateName ? new Twig_SupTwgSgg_Source('', $templateName) : $this->getSourceContext());
|
370 |
}
|
371 |
|
372 |
if ($e->getTemplateLine()) {
|
430 |
{
|
431 |
try {
|
432 |
$this->doDisplay($context, $blocks);
|
433 |
+
} catch (Twig_SupTwgSgg_Error $e) {
|
434 |
if (!$e->getSourceContext()) {
|
435 |
$e->setSourceContext($this->getSourceContext());
|
436 |
}
|
437 |
|
438 |
+
// this is mostly useful for Twig_SupTwgSgg_Error_Loader exceptions
|
439 |
+
// see Twig_SupTwgSgg_Error_Loader
|
440 |
if (false === $e->getTemplateLine()) {
|
441 |
$e->setTemplateLine(-1);
|
442 |
$e->guess();
|
444 |
|
445 |
throw $e;
|
446 |
} catch (Exception $e) {
|
447 |
+
throw new Twig_SupTwgSgg_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $this->getSourceContext(), $e);
|
448 |
}
|
449 |
}
|
450 |
|
473 |
*
|
474 |
* @return mixed The content of the context variable
|
475 |
*
|
476 |
+
* @throws Twig_SupTwgSgg_Error_Runtime if the variable does not exist and Twig is running in strict mode
|
477 |
*
|
478 |
* @internal
|
479 |
*/
|
484 |
return;
|
485 |
}
|
486 |
|
487 |
+
throw new Twig_SupTwgSgg_Error_Runtime(sprintf('Variable "%s" does not exist.', $item), -1, $this->getSourceContext());
|
488 |
}
|
489 |
|
490 |
return $context[$item];
|
496 |
* @param mixed $object The object or array from where to get the item
|
497 |
* @param mixed $item The item to get from the array or object
|
498 |
* @param array $arguments An array of arguments to pass if the item is an object method
|
499 |
+
* @param string $type The type of attribute (@see Twig_SupTwgSgg_Template constants)
|
500 |
* @param bool $isDefinedTest Whether this is only a defined check
|
501 |
* @param bool $ignoreStrictCheck Whether to ignore the strict attribute check or not
|
502 |
*
|
503 |
* @return mixed The attribute value, or a Boolean when $isDefinedTest is true, or null when the attribute is not set and $ignoreStrictCheck is true
|
504 |
*
|
505 |
+
* @throws Twig_SupTwgSgg_Error_Runtime if the attribute does not exist and Twig is running in strict mode and $isDefinedTest is false
|
506 |
*
|
507 |
* @internal
|
508 |
*/
|
553 |
$message = sprintf('Impossible to access an attribute ("%s") on a %s variable ("%s").', $item, gettype($object), $object);
|
554 |
}
|
555 |
|
556 |
+
throw new Twig_SupTwgSgg_Error_Runtime($message, -1, $this->getSourceContext());
|
557 |
}
|
558 |
}
|
559 |
|
572 |
$message = sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s").', $item, gettype($object), $object);
|
573 |
}
|
574 |
|
575 |
+
throw new Twig_SupTwgSgg_Error_Runtime($message, -1, $this->getSourceContext());
|
576 |
}
|
577 |
|
578 |
// object property
|
579 |
+
if (self::METHOD_CALL !== $type && !$object instanceof self) { // Twig_SupTwgSgg_Template does not have public properties, and we don't want to allow access to internal ones
|
580 |
if (isset($object->$item) || !empty($object->$item)) {
|
581 |
if ($isDefinedTest) {
|
582 |
return true;
|
583 |
}
|
584 |
|
585 |
+
if ($this->env->hasExtension('Twig_SupTwgSgg_Extension_Sandbox')) {
|
586 |
+
$this->env->getExtension('Twig_SupTwgSgg_Extension_Sandbox')->checkPropertyAllowed($object, $item);
|
587 |
}
|
588 |
|
589 |
return $object->$item;
|
657 |
return;
|
658 |
}
|
659 |
|
660 |
+
throw new Twig_SupTwgSgg_Error_Runtime(sprintf('Neither the property "%1$s" nor one of the methods "%1$s()", "get%1$s()"/"is%1$s()" or "__call()" exist and have public access in class "%2$s".', $item, $class), -1, $this->getSourceContext());
|
661 |
}
|
662 |
|
663 |
if ($isDefinedTest) {
|
664 |
return true;
|
665 |
}
|
666 |
|
667 |
+
if ($this->env->hasExtension('Twig_SupTwgSgg_Extension_Sandbox')) {
|
668 |
+
$this->env->getExtension('Twig_SupTwgSgg_Extension_Sandbox')->checkMethodAllowed($object, $method);
|
669 |
}
|
670 |
|
671 |
// Some objects throw exceptions when they have __call, and the method we try
|
684 |
}
|
685 |
|
686 |
// @deprecated in 1.28
|
687 |
+
if ($object instanceof Twig_SupTwgSgg_TemplateInterface) {
|
688 |
$self = $object->getTemplateName() === $this->getTemplateName();
|
689 |
$message = sprintf('Calling "%s" on template "%s" from template "%s" is deprecated since version 1.28 and won\'t be supported anymore in 2.0.', $item, $object->getTemplateName(), $this->getTemplateName());
|
690 |
if ('renderBlock' === $method || 'displayBlock' === $method) {
|
694 |
} elseif ('render' === $method || 'display' === $method) {
|
695 |
$message .= sprintf(' Use include("%s") instead).', $object->getTemplateName());
|
696 |
}
|
697 |
+
//@trigger_error($message, E_USER_DEPRECATED);
|
698 |
|
699 |
+
return $ret === '' ? '' : new Twig_SupTwgSgg_Markup($ret, $this->env->getCharset());
|
700 |
}
|
701 |
|
702 |
return $ret;
|
vendor/Twig/TemplateInterface.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
*
|
17 |
* @deprecated since 1.12 (to be removed in 3.0)
|
18 |
*/
|
19 |
-
interface
|
20 |
{
|
21 |
const ANY_CALL = 'any';
|
22 |
const ARRAY_CALL = 'array';
|
@@ -42,7 +42,7 @@ interface Twig_SupTwg_TemplateInterface
|
|
42 |
/**
|
43 |
* Returns the bound environment for this template.
|
44 |
*
|
45 |
-
* @return
|
46 |
*/
|
47 |
public function getEnvironment();
|
48 |
}
|
16 |
*
|
17 |
* @deprecated since 1.12 (to be removed in 3.0)
|
18 |
*/
|
19 |
+
interface Twig_SupTwgSgg_TemplateInterface
|
20 |
{
|
21 |
const ANY_CALL = 'any';
|
22 |
const ARRAY_CALL = 'array';
|
42 |
/**
|
43 |
* Returns the bound environment for this template.
|
44 |
*
|
45 |
+
* @return Twig_SupTwgSgg_Environment
|
46 |
*/
|
47 |
public function getEnvironment();
|
48 |
}
|
vendor/Twig/TemplateWrapper.php
CHANGED
@@ -14,18 +14,18 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
final class
|
18 |
{
|
19 |
private $env;
|
20 |
private $template;
|
21 |
|
22 |
/**
|
23 |
* This method is for internal use only and should never be called
|
24 |
-
* directly (use
|
25 |
*
|
26 |
* @internal
|
27 |
*/
|
28 |
-
public function __construct(
|
29 |
{
|
30 |
$this->env = $env;
|
31 |
$this->template = $template;
|
@@ -122,7 +122,7 @@ final class Twig_SupTwg_TemplateWrapper
|
|
122 |
}
|
123 |
|
124 |
/**
|
125 |
-
* @return
|
126 |
*/
|
127 |
public function getSourceContext()
|
128 |
{
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
final class Twig_SupTwgSgg_TemplateWrapper
|
18 |
{
|
19 |
private $env;
|
20 |
private $template;
|
21 |
|
22 |
/**
|
23 |
* This method is for internal use only and should never be called
|
24 |
+
* directly (use Twig_SupTwgSgg_Environment::load() instead).
|
25 |
*
|
26 |
* @internal
|
27 |
*/
|
28 |
+
public function __construct(Twig_SupTwgSgg_Environment $env, Twig_SupTwgSgg_Template $template)
|
29 |
{
|
30 |
$this->env = $env;
|
31 |
$this->template = $template;
|
122 |
}
|
123 |
|
124 |
/**
|
125 |
+
* @return Twig_SupTwgSgg_Source
|
126 |
*/
|
127 |
public function getSourceContext()
|
128 |
{
|
vendor/Twig/Test.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
|
14 |
/**
|
15 |
* Represents a template test.
|
@@ -18,7 +18,7 @@
|
|
18 |
*
|
19 |
* @deprecated since 1.12 (to be removed in 2.0)
|
20 |
*/
|
21 |
-
abstract class
|
22 |
{
|
23 |
protected $options;
|
24 |
protected $arguments = array();
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
+
//@trigger_error('The Twig_SupTwgSgg_Test class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSgg_SimpleTest instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Represents a template test.
|
18 |
*
|
19 |
* @deprecated since 1.12 (to be removed in 2.0)
|
20 |
*/
|
21 |
+
abstract class Twig_SupTwgSgg_Test implements Twig_SupTwgSgg_TestInterface, Twig_SupTwgSgg_TestCallableInterface
|
22 |
{
|
23 |
protected $options;
|
24 |
protected $arguments = array();
|
vendor/Twig/Test/Function.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
|
14 |
/**
|
15 |
* Represents a function template test.
|
@@ -18,7 +18,7 @@
|
|
18 |
*
|
19 |
* @deprecated since 1.12 (to be removed in 2.0)
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
protected $function;
|
24 |
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
+
//@trigger_error('The Twig_SupTwgSgg_Test_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSgg_SimpleTest instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Represents a function template test.
|
18 |
*
|
19 |
* @deprecated since 1.12 (to be removed in 2.0)
|
20 |
*/
|
21 |
+
class Twig_SupTwgSgg_Test_Function extends Twig_SupTwgSgg_Test
|
22 |
{
|
23 |
protected $function;
|
24 |
|
vendor/Twig/Test/IntegrationTestCase.php
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
* @author Karma Dordrak <drak@zikula.org>
|
17 |
*/
|
18 |
-
abstract class
|
19 |
{
|
20 |
/**
|
21 |
* @return string
|
@@ -23,7 +23,7 @@ abstract class Twig_SupTwg_Test_IntegrationTestCase extends PHPUnit_Framework_Te
|
|
23 |
abstract protected function getFixturesDir();
|
24 |
|
25 |
/**
|
26 |
-
* @return
|
27 |
*/
|
28 |
protected function getExtensions()
|
29 |
{
|
@@ -31,7 +31,7 @@ abstract class Twig_SupTwg_Test_IntegrationTestCase extends PHPUnit_Framework_Te
|
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
-
* @return
|
35 |
*/
|
36 |
protected function getTwigFilters()
|
37 |
{
|
@@ -39,7 +39,7 @@ abstract class Twig_SupTwg_Test_IntegrationTestCase extends PHPUnit_Framework_Te
|
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
-
* @return
|
43 |
*/
|
44 |
protected function getTwigFunctions()
|
45 |
{
|
@@ -47,7 +47,7 @@ abstract class Twig_SupTwg_Test_IntegrationTestCase extends PHPUnit_Framework_Te
|
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
-
* @return
|
51 |
*/
|
52 |
protected function getTwigTests()
|
53 |
{
|
@@ -132,14 +132,14 @@ abstract class Twig_SupTwg_Test_IntegrationTestCase extends PHPUnit_Framework_Te
|
|
132 |
}
|
133 |
}
|
134 |
|
135 |
-
$loader = new
|
136 |
|
137 |
foreach ($outputs as $i => $match) {
|
138 |
$config = array_merge(array(
|
139 |
'cache' => false,
|
140 |
'strict_variables' => true,
|
141 |
), $match[2] ? eval($match[2].';') : array());
|
142 |
-
$twig = new
|
143 |
$twig->addGlobal('global', 'global');
|
144 |
foreach ($this->getExtensions() as $extension) {
|
145 |
$twig->addExtension($extension);
|
@@ -177,7 +177,7 @@ abstract class Twig_SupTwg_Test_IntegrationTestCase extends PHPUnit_Framework_Te
|
|
177 |
return;
|
178 |
}
|
179 |
|
180 |
-
throw new
|
181 |
}
|
182 |
|
183 |
try {
|
@@ -189,7 +189,7 @@ abstract class Twig_SupTwg_Test_IntegrationTestCase extends PHPUnit_Framework_Te
|
|
189 |
return;
|
190 |
}
|
191 |
|
192 |
-
$e = new
|
193 |
|
194 |
$output = trim(sprintf('%s: %s', get_class($e), $e->getMessage()));
|
195 |
}
|
@@ -207,8 +207,8 @@ abstract class Twig_SupTwg_Test_IntegrationTestCase extends PHPUnit_Framework_Te
|
|
207 |
foreach (array_keys($templates) as $name) {
|
208 |
echo "Template: $name\n";
|
209 |
$loader = $twig->getLoader();
|
210 |
-
if (!$loader instanceof
|
211 |
-
$source = new
|
212 |
} else {
|
213 |
$source = $loader->getSourceContext($name);
|
214 |
}
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
* @author Karma Dordrak <drak@zikula.org>
|
17 |
*/
|
18 |
+
abstract class Twig_SupTwgSgg_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
|
19 |
{
|
20 |
/**
|
21 |
* @return string
|
23 |
abstract protected function getFixturesDir();
|
24 |
|
25 |
/**
|
26 |
+
* @return Twig_SupTwgSgg_ExtensionInterface[]
|
27 |
*/
|
28 |
protected function getExtensions()
|
29 |
{
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
+
* @return Twig_SupTwgSgg_SimpleFilter[]
|
35 |
*/
|
36 |
protected function getTwigFilters()
|
37 |
{
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
+
* @return Twig_SupTwgSgg_SimpleFunction[]
|
43 |
*/
|
44 |
protected function getTwigFunctions()
|
45 |
{
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* @return Twig_SupTwgSgg_SimpleTest[]
|
51 |
*/
|
52 |
protected function getTwigTests()
|
53 |
{
|
132 |
}
|
133 |
}
|
134 |
|
135 |
+
$loader = new Twig_SupTwgSgg_Loader_Array($templates);
|
136 |
|
137 |
foreach ($outputs as $i => $match) {
|
138 |
$config = array_merge(array(
|
139 |
'cache' => false,
|
140 |
'strict_variables' => true,
|
141 |
), $match[2] ? eval($match[2].';') : array());
|
142 |
+
$twig = new Twig_SupTwgSgg_Environment($loader, $config);
|
143 |
$twig->addGlobal('global', 'global');
|
144 |
foreach ($this->getExtensions() as $extension) {
|
145 |
$twig->addExtension($extension);
|
177 |
return;
|
178 |
}
|
179 |
|
180 |
+
throw new Twig_SupTwgSgg_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e);
|
181 |
}
|
182 |
|
183 |
try {
|
189 |
return;
|
190 |
}
|
191 |
|
192 |
+
$e = new Twig_SupTwgSgg_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e);
|
193 |
|
194 |
$output = trim(sprintf('%s: %s', get_class($e), $e->getMessage()));
|
195 |
}
|
207 |
foreach (array_keys($templates) as $name) {
|
208 |
echo "Template: $name\n";
|
209 |
$loader = $twig->getLoader();
|
210 |
+
if (!$loader instanceof Twig_SupTwgSgg_SourceContextLoaderInterface) {
|
211 |
+
$source = new Twig_SupTwgSgg_Source($loader->getSource($name), $name);
|
212 |
} else {
|
213 |
$source = $loader->getSourceContext($name);
|
214 |
}
|
vendor/Twig/Test/Method.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
|
14 |
/**
|
15 |
* Represents a method template test.
|
@@ -18,12 +18,12 @@
|
|
18 |
*
|
19 |
* @deprecated since 1.12 (to be removed in 2.0)
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
protected $extension;
|
24 |
protected $method;
|
25 |
|
26 |
-
public function __construct(
|
27 |
{
|
28 |
$options['callable'] = array($extension, $method);
|
29 |
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
+
//@trigger_error('The Twig_SupTwgSgg_Test_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSgg_SimpleTest instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Represents a method template test.
|
18 |
*
|
19 |
* @deprecated since 1.12 (to be removed in 2.0)
|
20 |
*/
|
21 |
+
class Twig_SupTwgSgg_Test_Method extends Twig_SupTwgSgg_Test
|
22 |
{
|
23 |
protected $extension;
|
24 |
protected $method;
|
25 |
|
26 |
+
public function __construct(Twig_SupTwgSgg_ExtensionInterface $extension, $method, array $options = array())
|
27 |
{
|
28 |
$options['callable'] = array($extension, $method);
|
29 |
|
vendor/Twig/Test/Node.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
|
14 |
/**
|
15 |
* Represents a template test as a Node.
|
@@ -18,7 +18,7 @@
|
|
18 |
*
|
19 |
* @deprecated since 1.12 (to be removed in 2.0)
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
protected $class;
|
24 |
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
|
12 |
+
//@trigger_error('The Twig_SupTwgSgg_Test_Node class is deprecated since version 1.12 and will be removed in 2.0.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Represents a template test as a Node.
|
18 |
*
|
19 |
* @deprecated since 1.12 (to be removed in 2.0)
|
20 |
*/
|
21 |
+
class Twig_SupTwgSgg_Test_Node extends Twig_SupTwgSgg_Test
|
22 |
{
|
23 |
protected $class;
|
24 |
|
vendor/Twig/Test/NodeTestCase.php
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
-
abstract class
|
12 |
{
|
13 |
abstract public function getTests();
|
14 |
|
@@ -20,7 +20,7 @@ abstract class Twig_SupTwg_Test_NodeTestCase extends PHPUnit_Framework_TestCase
|
|
20 |
$this->assertNodeCompilation($source, $node, $environment, $isPattern);
|
21 |
}
|
22 |
|
23 |
-
public function assertNodeCompilation($source,
|
24 |
{
|
25 |
$compiler = $this->getCompiler($environment);
|
26 |
$compiler->compile($node);
|
@@ -32,14 +32,14 @@ abstract class Twig_SupTwg_Test_NodeTestCase extends PHPUnit_Framework_TestCase
|
|
32 |
}
|
33 |
}
|
34 |
|
35 |
-
protected function getCompiler(
|
36 |
{
|
37 |
-
return new
|
38 |
}
|
39 |
|
40 |
protected function getEnvironment()
|
41 |
{
|
42 |
-
return new
|
43 |
}
|
44 |
|
45 |
protected function getVariableGetter($name, $line = false)
|
@@ -59,8 +59,8 @@ abstract class Twig_SupTwg_Test_NodeTestCase extends PHPUnit_Framework_TestCase
|
|
59 |
|
60 |
protected function getAttributeGetter()
|
61 |
{
|
62 |
-
if (function_exists('
|
63 |
-
return '
|
64 |
}
|
65 |
|
66 |
return '$this->getAttribute(';
|
8 |
* For the full copyright and license information, please view the LICENSE
|
9 |
* file that was distributed with this source code.
|
10 |
*/
|
11 |
+
abstract class Twig_SupTwgSgg_Test_NodeTestCase extends PHPUnit_Framework_TestCase
|
12 |
{
|
13 |
abstract public function getTests();
|
14 |
|
20 |
$this->assertNodeCompilation($source, $node, $environment, $isPattern);
|
21 |
}
|
22 |
|
23 |
+
public function assertNodeCompilation($source, Twig_SupTwgSgg_Node $node, Twig_SupTwgSgg_Environment $environment = null, $isPattern = false)
|
24 |
{
|
25 |
$compiler = $this->getCompiler($environment);
|
26 |
$compiler->compile($node);
|
32 |
}
|
33 |
}
|
34 |
|
35 |
+
protected function getCompiler(Twig_SupTwgSgg_Environment $environment = null)
|
36 |
{
|
37 |
+
return new Twig_SupTwgSgg_Compiler(null === $environment ? $this->getEnvironment() : $environment);
|
38 |
}
|
39 |
|
40 |
protected function getEnvironment()
|
41 |
{
|
42 |
+
return new Twig_SupTwgSgg_Environment(new Twig_SupTwgSgg_Loader_Array(array()));
|
43 |
}
|
44 |
|
45 |
protected function getVariableGetter($name, $line = false)
|
59 |
|
60 |
protected function getAttributeGetter()
|
61 |
{
|
62 |
+
if (function_exists('Twig_SupTwgSgg_template_get_attributes')) {
|
63 |
+
return 'Twig_SupTwgSgg_template_get_attributes($this, ';
|
64 |
}
|
65 |
|
66 |
return '$this->getAttribute(';
|
vendor/Twig/TestCallableInterface.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
*
|
17 |
* @deprecated since 1.12 (to be removed in 2.0)
|
18 |
*/
|
19 |
-
interface
|
20 |
{
|
21 |
public function getCallable();
|
22 |
}
|
16 |
*
|
17 |
* @deprecated since 1.12 (to be removed in 2.0)
|
18 |
*/
|
19 |
+
interface Twig_SupTwgSgg_TestCallableInterface
|
20 |
{
|
21 |
public function getCallable();
|
22 |
}
|
vendor/Twig/TestInterface.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
*
|
17 |
* @deprecated since 1.12 (to be removed in 2.0)
|
18 |
*/
|
19 |
-
interface
|
20 |
{
|
21 |
/**
|
22 |
* Compiles a test.
|
16 |
*
|
17 |
* @deprecated since 1.12 (to be removed in 2.0)
|
18 |
*/
|
19 |
+
interface Twig_SupTwgSgg_TestInterface
|
20 |
{
|
21 |
/**
|
22 |
* Compiles a test.
|
vendor/Twig/Token.php
CHANGED
@@ -17,7 +17,7 @@
|
|
17 |
*
|
18 |
* @final
|
19 |
*/
|
20 |
-
class
|
21 |
{
|
22 |
protected $value;
|
23 |
protected $type;
|
@@ -159,7 +159,7 @@ class Twig_SupTwg_Token
|
|
159 |
throw new LogicException(sprintf('Token of type "%s" does not exist.', $type));
|
160 |
}
|
161 |
|
162 |
-
return $short ? $name : '
|
163 |
}
|
164 |
|
165 |
/**
|
17 |
*
|
18 |
* @final
|
19 |
*/
|
20 |
+
class Twig_SupTwgSgg_Token
|
21 |
{
|
22 |
protected $value;
|
23 |
protected $type;
|
159 |
throw new LogicException(sprintf('Token of type "%s" does not exist.', $type));
|
160 |
}
|
161 |
|
162 |
+
return $short ? $name : 'Twig_SupTwgSgg_Token::'.$name;
|
163 |
}
|
164 |
|
165 |
/**
|
vendor/Twig/TokenParser.php
CHANGED
@@ -14,17 +14,17 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
abstract class
|
18 |
{
|
19 |
/**
|
20 |
-
* @var
|
21 |
*/
|
22 |
protected $parser;
|
23 |
|
24 |
/**
|
25 |
* Sets the parser associated with this token parser.
|
26 |
*/
|
27 |
-
public function setParser(
|
28 |
{
|
29 |
$this->parser = $parser;
|
30 |
}
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
abstract class Twig_SupTwgSgg_TokenParser implements Twig_SupTwgSgg_TokenParserInterface
|
18 |
{
|
19 |
/**
|
20 |
+
* @var Twig_SupTwgSgg_Parser
|
21 |
*/
|
22 |
protected $parser;
|
23 |
|
24 |
/**
|
25 |
* Sets the parser associated with this token parser.
|
26 |
*/
|
27 |
+
public function setParser(Twig_SupTwgSgg_Parser $parser)
|
28 |
{
|
29 |
$this->parser = $parser;
|
30 |
}
|
vendor/Twig/TokenParser/AutoEscape.php
CHANGED
@@ -29,19 +29,19 @@
|
|
29 |
*
|
30 |
* @final
|
31 |
*/
|
32 |
-
class
|
33 |
{
|
34 |
-
public function parse(
|
35 |
{
|
36 |
$lineno = $token->getLine();
|
37 |
$stream = $this->parser->getStream();
|
38 |
|
39 |
-
if ($stream->test(
|
40 |
$value = 'html';
|
41 |
} else {
|
42 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
43 |
-
if (!$expr instanceof
|
44 |
-
throw new
|
45 |
}
|
46 |
$value = $expr->getAttribute('value');
|
47 |
|
@@ -51,25 +51,25 @@ class Twig_SupTwg_TokenParser_AutoEscape extends Twig_SupTwg_TokenParser
|
|
51 |
$value = 'html';
|
52 |
}
|
53 |
|
54 |
-
if ($compat && $stream->test(
|
55 |
-
|
56 |
|
57 |
if (false === $value) {
|
58 |
-
throw new
|
59 |
}
|
60 |
|
61 |
$value = $stream->next()->getValue();
|
62 |
}
|
63 |
}
|
64 |
|
65 |
-
$stream->expect(
|
66 |
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
67 |
-
$stream->expect(
|
68 |
|
69 |
-
return new
|
70 |
}
|
71 |
|
72 |
-
public function decideBlockEnd(
|
73 |
{
|
74 |
return $token->test('endautoescape');
|
75 |
}
|
29 |
*
|
30 |
* @final
|
31 |
*/
|
32 |
+
class Twig_SupTwgSgg_TokenParser_AutoEscape extends Twig_SupTwgSgg_TokenParser
|
33 |
{
|
34 |
+
public function parse(Twig_SupTwgSgg_Token $token)
|
35 |
{
|
36 |
$lineno = $token->getLine();
|
37 |
$stream = $this->parser->getStream();
|
38 |
|
39 |
+
if ($stream->test(Twig_SupTwgSgg_Token::BLOCK_END_TYPE)) {
|
40 |
$value = 'html';
|
41 |
} else {
|
42 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
43 |
+
if (!$expr instanceof Twig_SupTwgSgg_Node_Expression_Constant) {
|
44 |
+
throw new Twig_SupTwgSgg_Error_Syntax('An escaping strategy must be a string or a bool.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
45 |
}
|
46 |
$value = $expr->getAttribute('value');
|
47 |
|
51 |
$value = 'html';
|
52 |
}
|
53 |
|
54 |
+
if ($compat && $stream->test(Twig_SupTwgSgg_Token::NAME_TYPE)) {
|
55 |
+
//@trigger_error('Using the autoescape tag with "true" or "false" before the strategy name is deprecated since version 1.21.', E_USER_DEPRECATED);
|
56 |
|
57 |
if (false === $value) {
|
58 |
+
throw new Twig_SupTwgSgg_Error_Syntax('Unexpected escaping strategy as you set autoescaping to false.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
59 |
}
|
60 |
|
61 |
$value = $stream->next()->getValue();
|
62 |
}
|
63 |
}
|
64 |
|
65 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
66 |
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
67 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
68 |
|
69 |
+
return new Twig_SupTwgSgg_Node_AutoEscape($value, $body, $lineno, $this->getTag());
|
70 |
}
|
71 |
|
72 |
+
public function decideBlockEnd(Twig_SupTwgSgg_Token $token)
|
73 |
{
|
74 |
return $token->test('endautoescape');
|
75 |
}
|
vendor/Twig/TokenParser/Block.php
CHANGED
@@ -22,44 +22,44 @@
|
|
22 |
*
|
23 |
* @final
|
24 |
*/
|
25 |
-
class
|
26 |
{
|
27 |
-
public function parse(
|
28 |
{
|
29 |
$lineno = $token->getLine();
|
30 |
$stream = $this->parser->getStream();
|
31 |
-
$name = $stream->expect(
|
32 |
if ($this->parser->hasBlock($name)) {
|
33 |
-
throw new
|
34 |
}
|
35 |
-
$this->parser->setBlock($name, $block = new
|
36 |
$this->parser->pushLocalScope();
|
37 |
$this->parser->pushBlockStack($name);
|
38 |
|
39 |
-
if ($stream->nextIf(
|
40 |
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
41 |
-
if ($token = $stream->nextIf(
|
42 |
$value = $token->getValue();
|
43 |
|
44 |
if ($value != $name) {
|
45 |
-
throw new
|
46 |
}
|
47 |
}
|
48 |
} else {
|
49 |
-
$body = new
|
50 |
-
new
|
51 |
));
|
52 |
}
|
53 |
-
$stream->expect(
|
54 |
|
55 |
$block->setNode('body', $body);
|
56 |
$this->parser->popBlockStack();
|
57 |
$this->parser->popLocalScope();
|
58 |
|
59 |
-
return new
|
60 |
}
|
61 |
|
62 |
-
public function decideBlockEnd(
|
63 |
{
|
64 |
return $token->test('endblock');
|
65 |
}
|
22 |
*
|
23 |
* @final
|
24 |
*/
|
25 |
+
class Twig_SupTwgSgg_TokenParser_Block extends Twig_SupTwgSgg_TokenParser
|
26 |
{
|
27 |
+
public function parse(Twig_SupTwgSgg_Token $token)
|
28 |
{
|
29 |
$lineno = $token->getLine();
|
30 |
$stream = $this->parser->getStream();
|
31 |
+
$name = $stream->expect(Twig_SupTwgSgg_Token::NAME_TYPE)->getValue();
|
32 |
if ($this->parser->hasBlock($name)) {
|
33 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf("The block '%s' has already been defined line %d.", $name, $this->parser->getBlock($name)->getTemplateLine()), $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
34 |
}
|
35 |
+
$this->parser->setBlock($name, $block = new Twig_SupTwgSgg_Node_Block($name, new Twig_SupTwgSgg_Node(array()), $lineno));
|
36 |
$this->parser->pushLocalScope();
|
37 |
$this->parser->pushBlockStack($name);
|
38 |
|
39 |
+
if ($stream->nextIf(Twig_SupTwgSgg_Token::BLOCK_END_TYPE)) {
|
40 |
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
41 |
+
if ($token = $stream->nextIf(Twig_SupTwgSgg_Token::NAME_TYPE)) {
|
42 |
$value = $token->getValue();
|
43 |
|
44 |
if ($value != $name) {
|
45 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('Expected endblock for block "%s" (but "%s" given).', $name, $value), $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
46 |
}
|
47 |
}
|
48 |
} else {
|
49 |
+
$body = new Twig_SupTwgSgg_Node(array(
|
50 |
+
new Twig_SupTwgSgg_Node_Print($this->parser->getExpressionParser()->parseExpression(), $lineno),
|
51 |
));
|
52 |
}
|
53 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
54 |
|
55 |
$block->setNode('body', $body);
|
56 |
$this->parser->popBlockStack();
|
57 |
$this->parser->popLocalScope();
|
58 |
|
59 |
+
return new Twig_SupTwgSgg_Node_BlockReference($name, $lineno, $this->getTag());
|
60 |
}
|
61 |
|
62 |
+
public function decideBlockEnd(Twig_SupTwgSgg_Token $token)
|
63 |
{
|
64 |
return $token->test('endblock');
|
65 |
}
|
vendor/Twig/TokenParser/Do.php
CHANGED
@@ -14,15 +14,15 @@
|
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
-
public function parse(
|
20 |
{
|
21 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
22 |
|
23 |
-
$this->parser->getStream()->expect(
|
24 |
|
25 |
-
return new
|
26 |
}
|
27 |
|
28 |
public function getTag()
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_TokenParser_Do extends Twig_SupTwgSgg_TokenParser
|
18 |
{
|
19 |
+
public function parse(Twig_SupTwgSgg_Token $token)
|
20 |
{
|
21 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
22 |
|
23 |
+
$this->parser->getStream()->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
24 |
|
25 |
+
return new Twig_SupTwgSgg_Node_Do($expr, $token->getLine(), $this->getTag());
|
26 |
}
|
27 |
|
28 |
public function getTag()
|
vendor/Twig/TokenParser/Embed.php
CHANGED
@@ -14,9 +14,9 @@
|
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
-
public function parse(
|
20 |
{
|
21 |
$stream = $this->parser->getStream();
|
22 |
|
@@ -24,19 +24,19 @@ class Twig_SupTwg_TokenParser_Embed extends Twig_SupTwg_TokenParser_Include
|
|
24 |
|
25 |
list($variables, $only, $ignoreMissing) = $this->parseArguments();
|
26 |
|
27 |
-
$parentToken = $fakeParentToken = new
|
28 |
-
if ($parent instanceof
|
29 |
-
$parentToken = new
|
30 |
-
} elseif ($parent instanceof
|
31 |
-
$parentToken = new
|
32 |
}
|
33 |
|
34 |
// inject a fake parent to make the parent() function work
|
35 |
$stream->injectTokens(array(
|
36 |
-
new
|
37 |
-
new
|
38 |
$parentToken,
|
39 |
-
new
|
40 |
));
|
41 |
|
42 |
$module = $this->parser->parse($stream, array($this, 'decideBlockEnd'), true);
|
@@ -48,12 +48,12 @@ class Twig_SupTwg_TokenParser_Embed extends Twig_SupTwg_TokenParser_Include
|
|
48 |
|
49 |
$this->parser->embedTemplate($module);
|
50 |
|
51 |
-
$stream->expect(
|
52 |
|
53 |
-
return new
|
54 |
}
|
55 |
|
56 |
-
public function decideBlockEnd(
|
57 |
{
|
58 |
return $token->test('endembed');
|
59 |
}
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_TokenParser_Embed extends Twig_SupTwgSgg_TokenParser_Include
|
18 |
{
|
19 |
+
public function parse(Twig_SupTwgSgg_Token $token)
|
20 |
{
|
21 |
$stream = $this->parser->getStream();
|
22 |
|
24 |
|
25 |
list($variables, $only, $ignoreMissing) = $this->parseArguments();
|
26 |
|
27 |
+
$parentToken = $fakeParentToken = new Twig_SupTwgSgg_Token(Twig_SupTwgSgg_Token::STRING_TYPE, '__parent__', $token->getLine());
|
28 |
+
if ($parent instanceof Twig_SupTwgSgg_Node_Expression_Constant) {
|
29 |
+
$parentToken = new Twig_SupTwgSgg_Token(Twig_SupTwgSgg_Token::STRING_TYPE, $parent->getAttribute('value'), $token->getLine());
|
30 |
+
} elseif ($parent instanceof Twig_SupTwgSgg_Node_Expression_Name) {
|
31 |
+
$parentToken = new Twig_SupTwgSgg_Token(Twig_SupTwgSgg_Token::NAME_TYPE, $parent->getAttribute('name'), $token->getLine());
|
32 |
}
|
33 |
|
34 |
// inject a fake parent to make the parent() function work
|
35 |
$stream->injectTokens(array(
|
36 |
+
new Twig_SupTwgSgg_Token(Twig_SupTwgSgg_Token::BLOCK_START_TYPE, '', $token->getLine()),
|
37 |
+
new Twig_SupTwgSgg_Token(Twig_SupTwgSgg_Token::NAME_TYPE, 'extends', $token->getLine()),
|
38 |
$parentToken,
|
39 |
+
new Twig_SupTwgSgg_Token(Twig_SupTwgSgg_Token::BLOCK_END_TYPE, '', $token->getLine()),
|
40 |
));
|
41 |
|
42 |
$module = $this->parser->parse($stream, array($this, 'decideBlockEnd'), true);
|
48 |
|
49 |
$this->parser->embedTemplate($module);
|
50 |
|
51 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
52 |
|
53 |
+
return new Twig_SupTwgSgg_Node_Embed($module->getTemplateName(), $module->getAttribute('index'), $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag());
|
54 |
}
|
55 |
|
56 |
+
public function decideBlockEnd(Twig_SupTwgSgg_Token $token)
|
57 |
{
|
58 |
return $token->test('endembed');
|
59 |
}
|
vendor/Twig/TokenParser/Extends.php
CHANGED
@@ -19,22 +19,22 @@
|
|
19 |
*
|
20 |
* @final
|
21 |
*/
|
22 |
-
class
|
23 |
{
|
24 |
-
public function parse(
|
25 |
{
|
26 |
$stream = $this->parser->getStream();
|
27 |
|
28 |
if (!$this->parser->isMainScope()) {
|
29 |
-
throw new
|
30 |
}
|
31 |
|
32 |
if (null !== $this->parser->getParent()) {
|
33 |
-
throw new
|
34 |
}
|
35 |
$this->parser->setParent($this->parser->getExpressionParser()->parseExpression());
|
36 |
|
37 |
-
$stream->expect(
|
38 |
}
|
39 |
|
40 |
public function getTag()
|
19 |
*
|
20 |
* @final
|
21 |
*/
|
22 |
+
class Twig_SupTwgSgg_TokenParser_Extends extends Twig_SupTwgSgg_TokenParser
|
23 |
{
|
24 |
+
public function parse(Twig_SupTwgSgg_Token $token)
|
25 |
{
|
26 |
$stream = $this->parser->getStream();
|
27 |
|
28 |
if (!$this->parser->isMainScope()) {
|
29 |
+
throw new Twig_SupTwgSgg_Error_Syntax('Cannot extend from a block.', $token->getLine(), $stream->getSourceContext());
|
30 |
}
|
31 |
|
32 |
if (null !== $this->parser->getParent()) {
|
33 |
+
throw new Twig_SupTwgSgg_Error_Syntax('Multiple extends tags are forbidden.', $token->getLine(), $stream->getSourceContext());
|
34 |
}
|
35 |
$this->parser->setParent($this->parser->getExpressionParser()->parseExpression());
|
36 |
|
37 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
38 |
}
|
39 |
|
40 |
public function getTag()
|
vendor/Twig/TokenParser/Filter.php
CHANGED
@@ -20,26 +20,26 @@
|
|
20 |
*
|
21 |
* @final
|
22 |
*/
|
23 |
-
class
|
24 |
{
|
25 |
-
public function parse(
|
26 |
{
|
27 |
$name = $this->parser->getVarName();
|
28 |
-
$ref = new
|
29 |
|
30 |
$filter = $this->parser->getExpressionParser()->parseFilterExpressionRaw($ref, $this->getTag());
|
31 |
-
$this->parser->getStream()->expect(
|
32 |
|
33 |
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
34 |
-
$this->parser->getStream()->expect(
|
35 |
|
36 |
-
$block = new
|
37 |
$this->parser->setBlock($name, $block);
|
38 |
|
39 |
-
return new
|
40 |
}
|
41 |
|
42 |
-
public function decideBlockEnd(
|
43 |
{
|
44 |
return $token->test('endfilter');
|
45 |
}
|
20 |
*
|
21 |
* @final
|
22 |
*/
|
23 |
+
class Twig_SupTwgSgg_TokenParser_Filter extends Twig_SupTwgSgg_TokenParser
|
24 |
{
|
25 |
+
public function parse(Twig_SupTwgSgg_Token $token)
|
26 |
{
|
27 |
$name = $this->parser->getVarName();
|
28 |
+
$ref = new Twig_SupTwgSgg_Node_Expression_BlockReference(new Twig_SupTwgSgg_Node_Expression_Constant($name, $token->getLine()), null, $token->getLine(), $this->getTag());
|
29 |
|
30 |
$filter = $this->parser->getExpressionParser()->parseFilterExpressionRaw($ref, $this->getTag());
|
31 |
+
$this->parser->getStream()->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
32 |
|
33 |
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
34 |
+
$this->parser->getStream()->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
35 |
|
36 |
+
$block = new Twig_SupTwgSgg_Node_Block($name, $body, $token->getLine());
|
37 |
$this->parser->setBlock($name, $block);
|
38 |
|
39 |
+
return new Twig_SupTwgSgg_Node_Print($filter, $token->getLine(), $this->getTag());
|
40 |
}
|
41 |
|
42 |
+
public function decideBlockEnd(Twig_SupTwgSgg_Token $token)
|
43 |
{
|
44 |
return $token->test('endfilter');
|
45 |
}
|
vendor/Twig/TokenParser/Flush.php
CHANGED
@@ -16,13 +16,13 @@
|
|
16 |
*
|
17 |
* @final
|
18 |
*/
|
19 |
-
class
|
20 |
{
|
21 |
-
public function parse(
|
22 |
{
|
23 |
-
$this->parser->getStream()->expect(
|
24 |
|
25 |
-
return new
|
26 |
}
|
27 |
|
28 |
public function getTag()
|
16 |
*
|
17 |
* @final
|
18 |
*/
|
19 |
+
class Twig_SupTwgSgg_TokenParser_Flush extends Twig_SupTwgSgg_TokenParser
|
20 |
{
|
21 |
+
public function parse(Twig_SupTwgSgg_Token $token)
|
22 |
{
|
23 |
+
$this->parser->getStream()->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
24 |
|
25 |
+
return new Twig_SupTwgSgg_Node_Flush($token->getLine(), $this->getTag());
|
26 |
}
|
27 |
|
28 |
public function getTag()
|
vendor/Twig/TokenParser/For.php
CHANGED
@@ -23,40 +23,40 @@
|
|
23 |
*
|
24 |
* @final
|
25 |
*/
|
26 |
-
class
|
27 |
{
|
28 |
-
public function parse(
|
29 |
{
|
30 |
$lineno = $token->getLine();
|
31 |
$stream = $this->parser->getStream();
|
32 |
$targets = $this->parser->getExpressionParser()->parseAssignmentExpression();
|
33 |
-
$stream->expect(
|
34 |
$seq = $this->parser->getExpressionParser()->parseExpression();
|
35 |
|
36 |
$ifexpr = null;
|
37 |
-
if ($stream->nextIf(
|
38 |
$ifexpr = $this->parser->getExpressionParser()->parseExpression();
|
39 |
}
|
40 |
|
41 |
-
$stream->expect(
|
42 |
$body = $this->parser->subparse(array($this, 'decideForFork'));
|
43 |
if ($stream->next()->getValue() == 'else') {
|
44 |
-
$stream->expect(
|
45 |
$else = $this->parser->subparse(array($this, 'decideForEnd'), true);
|
46 |
} else {
|
47 |
$else = null;
|
48 |
}
|
49 |
-
$stream->expect(
|
50 |
|
51 |
if (count($targets) > 1) {
|
52 |
$keyTarget = $targets->getNode(0);
|
53 |
-
$keyTarget = new
|
54 |
$valueTarget = $targets->getNode(1);
|
55 |
-
$valueTarget = new
|
56 |
} else {
|
57 |
-
$keyTarget = new
|
58 |
$valueTarget = $targets->getNode(0);
|
59 |
-
$valueTarget = new
|
60 |
}
|
61 |
|
62 |
if ($ifexpr) {
|
@@ -64,24 +64,24 @@ class Twig_SupTwg_TokenParser_For extends Twig_SupTwg_TokenParser
|
|
64 |
$this->checkLoopUsageBody($stream, $body);
|
65 |
}
|
66 |
|
67 |
-
return new
|
68 |
}
|
69 |
|
70 |
-
public function decideForFork(
|
71 |
{
|
72 |
return $token->test(array('else', 'endfor'));
|
73 |
}
|
74 |
|
75 |
-
public function decideForEnd(
|
76 |
{
|
77 |
return $token->test('endfor');
|
78 |
}
|
79 |
|
80 |
// the loop variable cannot be used in the condition
|
81 |
-
protected function checkLoopUsageCondition(
|
82 |
{
|
83 |
-
if ($node instanceof
|
84 |
-
throw new
|
85 |
}
|
86 |
|
87 |
foreach ($node as $n) {
|
@@ -95,17 +95,17 @@ class Twig_SupTwg_TokenParser_For extends Twig_SupTwg_TokenParser
|
|
95 |
|
96 |
// check usage of non-defined loop-items
|
97 |
// it does not catch all problems (for instance when a for is included into another or when the variable is used in an include)
|
98 |
-
protected function checkLoopUsageBody(
|
99 |
{
|
100 |
-
if ($node instanceof
|
101 |
$attribute = $node->getNode('attribute');
|
102 |
-
if ($attribute instanceof
|
103 |
-
throw new
|
104 |
}
|
105 |
}
|
106 |
|
107 |
// should check for parent.loop.XXX usage
|
108 |
-
if ($node instanceof
|
109 |
return;
|
110 |
}
|
111 |
|
23 |
*
|
24 |
* @final
|
25 |
*/
|
26 |
+
class Twig_SupTwgSgg_TokenParser_For extends Twig_SupTwgSgg_TokenParser
|
27 |
{
|
28 |
+
public function parse(Twig_SupTwgSgg_Token $token)
|
29 |
{
|
30 |
$lineno = $token->getLine();
|
31 |
$stream = $this->parser->getStream();
|
32 |
$targets = $this->parser->getExpressionParser()->parseAssignmentExpression();
|
33 |
+
$stream->expect(Twig_SupTwgSgg_Token::OPERATOR_TYPE, 'in');
|
34 |
$seq = $this->parser->getExpressionParser()->parseExpression();
|
35 |
|
36 |
$ifexpr = null;
|
37 |
+
if ($stream->nextIf(Twig_SupTwgSgg_Token::NAME_TYPE, 'if')) {
|
38 |
$ifexpr = $this->parser->getExpressionParser()->parseExpression();
|
39 |
}
|
40 |
|
41 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
42 |
$body = $this->parser->subparse(array($this, 'decideForFork'));
|
43 |
if ($stream->next()->getValue() == 'else') {
|
44 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
45 |
$else = $this->parser->subparse(array($this, 'decideForEnd'), true);
|
46 |
} else {
|
47 |
$else = null;
|
48 |
}
|
49 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
50 |
|
51 |
if (count($targets) > 1) {
|
52 |
$keyTarget = $targets->getNode(0);
|
53 |
+
$keyTarget = new Twig_SupTwgSgg_Node_Expression_AssignName($keyTarget->getAttribute('name'), $keyTarget->getTemplateLine());
|
54 |
$valueTarget = $targets->getNode(1);
|
55 |
+
$valueTarget = new Twig_SupTwgSgg_Node_Expression_AssignName($valueTarget->getAttribute('name'), $valueTarget->getTemplateLine());
|
56 |
} else {
|
57 |
+
$keyTarget = new Twig_SupTwgSgg_Node_Expression_AssignName('_key', $lineno);
|
58 |
$valueTarget = $targets->getNode(0);
|
59 |
+
$valueTarget = new Twig_SupTwgSgg_Node_Expression_AssignName($valueTarget->getAttribute('name'), $valueTarget->getTemplateLine());
|
60 |
}
|
61 |
|
62 |
if ($ifexpr) {
|
64 |
$this->checkLoopUsageBody($stream, $body);
|
65 |
}
|
66 |
|
67 |
+
return new Twig_SupTwgSgg_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, $lineno, $this->getTag());
|
68 |
}
|
69 |
|
70 |
+
public function decideForFork(Twig_SupTwgSgg_Token $token)
|
71 |
{
|
72 |
return $token->test(array('else', 'endfor'));
|
73 |
}
|
74 |
|
75 |
+
public function decideForEnd(Twig_SupTwgSgg_Token $token)
|
76 |
{
|
77 |
return $token->test('endfor');
|
78 |
}
|
79 |
|
80 |
// the loop variable cannot be used in the condition
|
81 |
+
protected function checkLoopUsageCondition(Twig_SupTwgSgg_TokenStream $stream, Twig_SupTwgSgg_NodeInterface $node)
|
82 |
{
|
83 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_SupTwgSgg_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) {
|
84 |
+
throw new Twig_SupTwgSgg_Error_Syntax('The "loop" variable cannot be used in a looping condition.', $node->getTemplateLine(), $stream->getSourceContext());
|
85 |
}
|
86 |
|
87 |
foreach ($node as $n) {
|
95 |
|
96 |
// check usage of non-defined loop-items
|
97 |
// it does not catch all problems (for instance when a for is included into another or when the variable is used in an include)
|
98 |
+
protected function checkLoopUsageBody(Twig_SupTwgSgg_TokenStream $stream, Twig_SupTwgSgg_NodeInterface $node)
|
99 |
{
|
100 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_SupTwgSgg_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) {
|
101 |
$attribute = $node->getNode('attribute');
|
102 |
+
if ($attribute instanceof Twig_SupTwgSgg_Node_Expression_Constant && in_array($attribute->getAttribute('value'), array('length', 'revindex0', 'revindex', 'last'))) {
|
103 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('The "loop.%s" variable is not defined when looping with a condition.', $attribute->getAttribute('value')), $node->getTemplateLine(), $stream->getSourceContext());
|
104 |
}
|
105 |
}
|
106 |
|
107 |
// should check for parent.loop.XXX usage
|
108 |
+
if ($node instanceof Twig_SupTwgSgg_Node_For) {
|
109 |
return;
|
110 |
}
|
111 |
|
vendor/Twig/TokenParser/From.php
CHANGED
@@ -18,9 +18,9 @@
|
|
18 |
*
|
19 |
* @final
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
-
public function parse(
|
24 |
{
|
25 |
$macro = $this->parser->getExpressionParser()->parseExpression();
|
26 |
$stream = $this->parser->getStream();
|
@@ -28,27 +28,27 @@ class Twig_SupTwg_TokenParser_From extends Twig_SupTwg_TokenParser
|
|
28 |
|
29 |
$targets = array();
|
30 |
do {
|
31 |
-
$name = $stream->expect(
|
32 |
|
33 |
$alias = $name;
|
34 |
if ($stream->nextIf('as')) {
|
35 |
-
$alias = $stream->expect(
|
36 |
}
|
37 |
|
38 |
$targets[$name] = $alias;
|
39 |
|
40 |
-
if (!$stream->nextIf(
|
41 |
break;
|
42 |
}
|
43 |
} while (true);
|
44 |
|
45 |
-
$stream->expect(
|
46 |
|
47 |
-
$node = new
|
48 |
|
49 |
foreach ($targets as $name => $alias) {
|
50 |
if ($this->parser->isReservedMacroName($name)) {
|
51 |
-
throw new
|
52 |
}
|
53 |
|
54 |
$this->parser->addImportedSymbol('function', $alias, 'get'.$name, $node->getNode('var'));
|
18 |
*
|
19 |
* @final
|
20 |
*/
|
21 |
+
class Twig_SupTwgSgg_TokenParser_From extends Twig_SupTwgSgg_TokenParser
|
22 |
{
|
23 |
+
public function parse(Twig_SupTwgSgg_Token $token)
|
24 |
{
|
25 |
$macro = $this->parser->getExpressionParser()->parseExpression();
|
26 |
$stream = $this->parser->getStream();
|
28 |
|
29 |
$targets = array();
|
30 |
do {
|
31 |
+
$name = $stream->expect(Twig_SupTwgSgg_Token::NAME_TYPE)->getValue();
|
32 |
|
33 |
$alias = $name;
|
34 |
if ($stream->nextIf('as')) {
|
35 |
+
$alias = $stream->expect(Twig_SupTwgSgg_Token::NAME_TYPE)->getValue();
|
36 |
}
|
37 |
|
38 |
$targets[$name] = $alias;
|
39 |
|
40 |
+
if (!$stream->nextIf(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ',')) {
|
41 |
break;
|
42 |
}
|
43 |
} while (true);
|
44 |
|
45 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
46 |
|
47 |
+
$node = new Twig_SupTwgSgg_Node_Import($macro, new Twig_SupTwgSgg_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine()), $token->getLine(), $this->getTag());
|
48 |
|
49 |
foreach ($targets as $name => $alias) {
|
50 |
if ($this->parser->isReservedMacroName($name)) {
|
51 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('"%s" cannot be an imported macro as it is a reserved keyword.', $name), $token->getLine(), $stream->getSourceContext());
|
52 |
}
|
53 |
|
54 |
$this->parser->addImportedSymbol('function', $alias, 'get'.$name, $node->getNode('var'));
|
vendor/Twig/TokenParser/If.php
CHANGED
@@ -25,14 +25,14 @@
|
|
25 |
*
|
26 |
* @final
|
27 |
*/
|
28 |
-
class
|
29 |
{
|
30 |
-
public function parse(
|
31 |
{
|
32 |
$lineno = $token->getLine();
|
33 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
34 |
$stream = $this->parser->getStream();
|
35 |
-
$stream->expect(
|
36 |
$body = $this->parser->subparse(array($this, 'decideIfFork'));
|
37 |
$tests = array($expr, $body);
|
38 |
$else = null;
|
@@ -41,13 +41,13 @@ class Twig_SupTwg_TokenParser_If extends Twig_SupTwg_TokenParser
|
|
41 |
while (!$end) {
|
42 |
switch ($stream->next()->getValue()) {
|
43 |
case 'else':
|
44 |
-
$stream->expect(
|
45 |
$else = $this->parser->subparse(array($this, 'decideIfEnd'));
|
46 |
break;
|
47 |
|
48 |
case 'elseif':
|
49 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
50 |
-
$stream->expect(
|
51 |
$body = $this->parser->subparse(array($this, 'decideIfFork'));
|
52 |
$tests[] = $expr;
|
53 |
$tests[] = $body;
|
@@ -58,21 +58,21 @@ class Twig_SupTwg_TokenParser_If extends Twig_SupTwg_TokenParser
|
|
58 |
break;
|
59 |
|
60 |
default:
|
61 |
-
throw new
|
62 |
}
|
63 |
}
|
64 |
|
65 |
-
$stream->expect(
|
66 |
|
67 |
-
return new
|
68 |
}
|
69 |
|
70 |
-
public function decideIfFork(
|
71 |
{
|
72 |
return $token->test(array('elseif', 'else', 'endif'));
|
73 |
}
|
74 |
|
75 |
-
public function decideIfEnd(
|
76 |
{
|
77 |
return $token->test(array('endif'));
|
78 |
}
|
25 |
*
|
26 |
* @final
|
27 |
*/
|
28 |
+
class Twig_SupTwgSgg_TokenParser_If extends Twig_SupTwgSgg_TokenParser
|
29 |
{
|
30 |
+
public function parse(Twig_SupTwgSgg_Token $token)
|
31 |
{
|
32 |
$lineno = $token->getLine();
|
33 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
34 |
$stream = $this->parser->getStream();
|
35 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
36 |
$body = $this->parser->subparse(array($this, 'decideIfFork'));
|
37 |
$tests = array($expr, $body);
|
38 |
$else = null;
|
41 |
while (!$end) {
|
42 |
switch ($stream->next()->getValue()) {
|
43 |
case 'else':
|
44 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
45 |
$else = $this->parser->subparse(array($this, 'decideIfEnd'));
|
46 |
break;
|
47 |
|
48 |
case 'elseif':
|
49 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
50 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
51 |
$body = $this->parser->subparse(array($this, 'decideIfFork'));
|
52 |
$tests[] = $expr;
|
53 |
$tests[] = $body;
|
58 |
break;
|
59 |
|
60 |
default:
|
61 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('Unexpected end of template. Twig was looking for the following tags "else", "elseif", or "endif" to close the "if" block started at line %d).', $lineno), $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
62 |
}
|
63 |
}
|
64 |
|
65 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
66 |
|
67 |
+
return new Twig_SupTwgSgg_Node_If(new Twig_SupTwgSgg_Node($tests), $else, $lineno, $this->getTag());
|
68 |
}
|
69 |
|
70 |
+
public function decideIfFork(Twig_SupTwgSgg_Token $token)
|
71 |
{
|
72 |
return $token->test(array('elseif', 'else', 'endif'));
|
73 |
}
|
74 |
|
75 |
+
public function decideIfEnd(Twig_SupTwgSgg_Token $token)
|
76 |
{
|
77 |
return $token->test(array('endif'));
|
78 |
}
|
vendor/Twig/TokenParser/Import.php
CHANGED
@@ -18,18 +18,18 @@
|
|
18 |
*
|
19 |
* @final
|
20 |
*/
|
21 |
-
class
|
22 |
{
|
23 |
-
public function parse(
|
24 |
{
|
25 |
$macro = $this->parser->getExpressionParser()->parseExpression();
|
26 |
$this->parser->getStream()->expect('as');
|
27 |
-
$var = new
|
28 |
-
$this->parser->getStream()->expect(
|
29 |
|
30 |
$this->parser->addImportedSymbol('template', $var->getAttribute('name'));
|
31 |
|
32 |
-
return new
|
33 |
}
|
34 |
|
35 |
public function getTag()
|
18 |
*
|
19 |
* @final
|
20 |
*/
|
21 |
+
class Twig_SupTwgSgg_TokenParser_Import extends Twig_SupTwgSgg_TokenParser
|
22 |
{
|
23 |
+
public function parse(Twig_SupTwgSgg_Token $token)
|
24 |
{
|
25 |
$macro = $this->parser->getExpressionParser()->parseExpression();
|
26 |
$this->parser->getStream()->expect('as');
|
27 |
+
$var = new Twig_SupTwgSgg_Node_Expression_AssignName($this->parser->getStream()->expect(Twig_SupTwgSgg_Token::NAME_TYPE)->getValue(), $token->getLine());
|
28 |
+
$this->parser->getStream()->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
29 |
|
30 |
$this->parser->addImportedSymbol('template', $var->getAttribute('name'));
|
31 |
|
32 |
+
return new Twig_SupTwgSgg_Node_Import($macro, $var, $token->getLine(), $this->getTag());
|
33 |
}
|
34 |
|
35 |
public function getTag()
|
vendor/Twig/TokenParser/Include.php
CHANGED
@@ -21,15 +21,15 @@
|
|
21 |
*
|
22 |
* @final
|
23 |
*/
|
24 |
-
class
|
25 |
{
|
26 |
-
public function parse(
|
27 |
{
|
28 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
29 |
|
30 |
list($variables, $only, $ignoreMissing) = $this->parseArguments();
|
31 |
|
32 |
-
return new
|
33 |
}
|
34 |
|
35 |
protected function parseArguments()
|
@@ -37,23 +37,23 @@ class Twig_SupTwg_TokenParser_Include extends Twig_SupTwg_TokenParser
|
|
37 |
$stream = $this->parser->getStream();
|
38 |
|
39 |
$ignoreMissing = false;
|
40 |
-
if ($stream->nextIf(
|
41 |
-
$stream->expect(
|
42 |
|
43 |
$ignoreMissing = true;
|
44 |
}
|
45 |
|
46 |
$variables = null;
|
47 |
-
if ($stream->nextIf(
|
48 |
$variables = $this->parser->getExpressionParser()->parseExpression();
|
49 |
}
|
50 |
|
51 |
$only = false;
|
52 |
-
if ($stream->nextIf(
|
53 |
$only = true;
|
54 |
}
|
55 |
|
56 |
-
$stream->expect(
|
57 |
|
58 |
return array($variables, $only, $ignoreMissing);
|
59 |
}
|
21 |
*
|
22 |
* @final
|
23 |
*/
|
24 |
+
class Twig_SupTwgSgg_TokenParser_Include extends Twig_SupTwgSgg_TokenParser
|
25 |
{
|
26 |
+
public function parse(Twig_SupTwgSgg_Token $token)
|
27 |
{
|
28 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
29 |
|
30 |
list($variables, $only, $ignoreMissing) = $this->parseArguments();
|
31 |
|
32 |
+
return new Twig_SupTwgSgg_Node_Include($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag());
|
33 |
}
|
34 |
|
35 |
protected function parseArguments()
|
37 |
$stream = $this->parser->getStream();
|
38 |
|
39 |
$ignoreMissing = false;
|
40 |
+
if ($stream->nextIf(Twig_SupTwgSgg_Token::NAME_TYPE, 'ignore')) {
|
41 |
+
$stream->expect(Twig_SupTwgSgg_Token::NAME_TYPE, 'missing');
|
42 |
|
43 |
$ignoreMissing = true;
|
44 |
}
|
45 |
|
46 |
$variables = null;
|
47 |
+
if ($stream->nextIf(Twig_SupTwgSgg_Token::NAME_TYPE, 'with')) {
|
48 |
$variables = $this->parser->getExpressionParser()->parseExpression();
|
49 |
}
|
50 |
|
51 |
$only = false;
|
52 |
+
if ($stream->nextIf(Twig_SupTwgSgg_Token::NAME_TYPE, 'only')) {
|
53 |
$only = true;
|
54 |
}
|
55 |
|
56 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
57 |
|
58 |
return array($variables, $only, $ignoreMissing);
|
59 |
}
|
vendor/Twig/TokenParser/Macro.php
CHANGED
@@ -20,33 +20,33 @@
|
|
20 |
*
|
21 |
* @final
|
22 |
*/
|
23 |
-
class
|
24 |
{
|
25 |
-
public function parse(
|
26 |
{
|
27 |
$lineno = $token->getLine();
|
28 |
$stream = $this->parser->getStream();
|
29 |
-
$name = $stream->expect(
|
30 |
|
31 |
$arguments = $this->parser->getExpressionParser()->parseArguments(true, true);
|
32 |
|
33 |
-
$stream->expect(
|
34 |
$this->parser->pushLocalScope();
|
35 |
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
36 |
-
if ($token = $stream->nextIf(
|
37 |
$value = $token->getValue();
|
38 |
|
39 |
if ($value != $name) {
|
40 |
-
throw new
|
41 |
}
|
42 |
}
|
43 |
$this->parser->popLocalScope();
|
44 |
-
$stream->expect(
|
45 |
|
46 |
-
$this->parser->setMacro($name, new
|
47 |
}
|
48 |
|
49 |
-
public function decideBlockEnd(
|
50 |
{
|
51 |
return $token->test('endmacro');
|
52 |
}
|
20 |
*
|
21 |
* @final
|
22 |
*/
|
23 |
+
class Twig_SupTwgSgg_TokenParser_Macro extends Twig_SupTwgSgg_TokenParser
|
24 |
{
|
25 |
+
public function parse(Twig_SupTwgSgg_Token $token)
|
26 |
{
|
27 |
$lineno = $token->getLine();
|
28 |
$stream = $this->parser->getStream();
|
29 |
+
$name = $stream->expect(Twig_SupTwgSgg_Token::NAME_TYPE)->getValue();
|
30 |
|
31 |
$arguments = $this->parser->getExpressionParser()->parseArguments(true, true);
|
32 |
|
33 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
34 |
$this->parser->pushLocalScope();
|
35 |
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
36 |
+
if ($token = $stream->nextIf(Twig_SupTwgSgg_Token::NAME_TYPE)) {
|
37 |
$value = $token->getValue();
|
38 |
|
39 |
if ($value != $name) {
|
40 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('Expected endmacro for macro "%s" (but "%s" given).', $name, $value), $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
41 |
}
|
42 |
}
|
43 |
$this->parser->popLocalScope();
|
44 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
45 |
|
46 |
+
$this->parser->setMacro($name, new Twig_SupTwgSgg_Node_Macro($name, new Twig_SupTwgSgg_Node_Body(array($body)), $arguments, $lineno, $this->getTag()));
|
47 |
}
|
48 |
|
49 |
+
public function decideBlockEnd(Twig_SupTwgSgg_Token $token)
|
50 |
{
|
51 |
return $token->test('endmacro');
|
52 |
}
|
vendor/Twig/TokenParser/Sandbox.php
CHANGED
@@ -22,32 +22,32 @@
|
|
22 |
*
|
23 |
* @final
|
24 |
*/
|
25 |
-
class
|
26 |
{
|
27 |
-
public function parse(
|
28 |
{
|
29 |
$stream = $this->parser->getStream();
|
30 |
-
$stream->expect(
|
31 |
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
32 |
-
$stream->expect(
|
33 |
|
34 |
// in a sandbox tag, only include tags are allowed
|
35 |
-
if (!$body instanceof
|
36 |
foreach ($body as $node) {
|
37 |
-
if ($node instanceof
|
38 |
continue;
|
39 |
}
|
40 |
|
41 |
-
if (!$node instanceof
|
42 |
-
throw new
|
43 |
}
|
44 |
}
|
45 |
}
|
46 |
|
47 |
-
return new
|
48 |
}
|
49 |
|
50 |
-
public function decideBlockEnd(
|
51 |
{
|
52 |
return $token->test('endsandbox');
|
53 |
}
|
22 |
*
|
23 |
* @final
|
24 |
*/
|
25 |
+
class Twig_SupTwgSgg_TokenParser_Sandbox extends Twig_SupTwgSgg_TokenParser
|
26 |
{
|
27 |
+
public function parse(Twig_SupTwgSgg_Token $token)
|
28 |
{
|
29 |
$stream = $this->parser->getStream();
|
30 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
31 |
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
32 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
33 |
|
34 |
// in a sandbox tag, only include tags are allowed
|
35 |
+
if (!$body instanceof Twig_SupTwgSgg_Node_Include) {
|
36 |
foreach ($body as $node) {
|
37 |
+
if ($node instanceof Twig_SupTwgSgg_Node_Text && ctype_space($node->getAttribute('data'))) {
|
38 |
continue;
|
39 |
}
|
40 |
|
41 |
+
if (!$node instanceof Twig_SupTwgSgg_Node_Include) {
|
42 |
+
throw new Twig_SupTwgSgg_Error_Syntax('Only "include" tags are allowed within a "sandbox" section.', $node->getTemplateLine(), $stream->getSourceContext());
|
43 |
}
|
44 |
}
|
45 |
}
|
46 |
|
47 |
+
return new Twig_SupTwgSgg_Node_Sandbox($body, $token->getLine(), $this->getTag());
|
48 |
}
|
49 |
|
50 |
+
public function decideBlockEnd(Twig_SupTwgSgg_Token $token)
|
51 |
{
|
52 |
return $token->test('endsandbox');
|
53 |
}
|
vendor/Twig/TokenParser/Set.php
CHANGED
@@ -28,40 +28,40 @@
|
|
28 |
*
|
29 |
* @final
|
30 |
*/
|
31 |
-
class
|
32 |
{
|
33 |
-
public function parse(
|
34 |
{
|
35 |
$lineno = $token->getLine();
|
36 |
$stream = $this->parser->getStream();
|
37 |
$names = $this->parser->getExpressionParser()->parseAssignmentExpression();
|
38 |
|
39 |
$capture = false;
|
40 |
-
if ($stream->nextIf(
|
41 |
$values = $this->parser->getExpressionParser()->parseMultitargetExpression();
|
42 |
|
43 |
-
$stream->expect(
|
44 |
|
45 |
if (count($names) !== count($values)) {
|
46 |
-
throw new
|
47 |
}
|
48 |
} else {
|
49 |
$capture = true;
|
50 |
|
51 |
if (count($names) > 1) {
|
52 |
-
throw new
|
53 |
}
|
54 |
|
55 |
-
$stream->expect(
|
56 |
|
57 |
$values = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
58 |
-
$stream->expect(
|
59 |
}
|
60 |
|
61 |
-
return new
|
62 |
}
|
63 |
|
64 |
-
public function decideBlockEnd(
|
65 |
{
|
66 |
return $token->test('endset');
|
67 |
}
|
28 |
*
|
29 |
* @final
|
30 |
*/
|
31 |
+
class Twig_SupTwgSgg_TokenParser_Set extends Twig_SupTwgSgg_TokenParser
|
32 |
{
|
33 |
+
public function parse(Twig_SupTwgSgg_Token $token)
|
34 |
{
|
35 |
$lineno = $token->getLine();
|
36 |
$stream = $this->parser->getStream();
|
37 |
$names = $this->parser->getExpressionParser()->parseAssignmentExpression();
|
38 |
|
39 |
$capture = false;
|
40 |
+
if ($stream->nextIf(Twig_SupTwgSgg_Token::OPERATOR_TYPE, '=')) {
|
41 |
$values = $this->parser->getExpressionParser()->parseMultitargetExpression();
|
42 |
|
43 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
44 |
|
45 |
if (count($names) !== count($values)) {
|
46 |
+
throw new Twig_SupTwgSgg_Error_Syntax('When using set, you must have the same number of variables and assignments.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
47 |
}
|
48 |
} else {
|
49 |
$capture = true;
|
50 |
|
51 |
if (count($names) > 1) {
|
52 |
+
throw new Twig_SupTwgSgg_Error_Syntax('When using set with a block, you cannot have a multi-target.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
53 |
}
|
54 |
|
55 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
56 |
|
57 |
$values = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
58 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
59 |
}
|
60 |
|
61 |
+
return new Twig_SupTwgSgg_Node_Set($capture, $names, $values, $lineno, $this->getTag());
|
62 |
}
|
63 |
|
64 |
+
public function decideBlockEnd(Twig_SupTwgSgg_Token $token)
|
65 |
{
|
66 |
return $token->test('endset');
|
67 |
}
|
vendor/Twig/TokenParser/Spaceless.php
CHANGED
@@ -24,20 +24,20 @@
|
|
24 |
*
|
25 |
* @final
|
26 |
*/
|
27 |
-
class
|
28 |
{
|
29 |
-
public function parse(
|
30 |
{
|
31 |
$lineno = $token->getLine();
|
32 |
|
33 |
-
$this->parser->getStream()->expect(
|
34 |
$body = $this->parser->subparse(array($this, 'decideSpacelessEnd'), true);
|
35 |
-
$this->parser->getStream()->expect(
|
36 |
|
37 |
-
return new
|
38 |
}
|
39 |
|
40 |
-
public function decideSpacelessEnd(
|
41 |
{
|
42 |
return $token->test('endspaceless');
|
43 |
}
|
24 |
*
|
25 |
* @final
|
26 |
*/
|
27 |
+
class Twig_SupTwgSgg_TokenParser_Spaceless extends Twig_SupTwgSgg_TokenParser
|
28 |
{
|
29 |
+
public function parse(Twig_SupTwgSgg_Token $token)
|
30 |
{
|
31 |
$lineno = $token->getLine();
|
32 |
|
33 |
+
$this->parser->getStream()->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
34 |
$body = $this->parser->subparse(array($this, 'decideSpacelessEnd'), true);
|
35 |
+
$this->parser->getStream()->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
36 |
|
37 |
+
return new Twig_SupTwgSgg_Node_Spaceless($body, $lineno, $this->getTag());
|
38 |
}
|
39 |
|
40 |
+
public function decideSpacelessEnd(Twig_SupTwgSgg_Token $token)
|
41 |
{
|
42 |
return $token->test('endspaceless');
|
43 |
}
|
vendor/Twig/TokenParser/Use.php
CHANGED
@@ -25,38 +25,38 @@
|
|
25 |
*
|
26 |
* @final
|
27 |
*/
|
28 |
-
class
|
29 |
{
|
30 |
-
public function parse(
|
31 |
{
|
32 |
$template = $this->parser->getExpressionParser()->parseExpression();
|
33 |
$stream = $this->parser->getStream();
|
34 |
|
35 |
-
if (!$template instanceof
|
36 |
-
throw new
|
37 |
}
|
38 |
|
39 |
$targets = array();
|
40 |
if ($stream->nextIf('with')) {
|
41 |
do {
|
42 |
-
$name = $stream->expect(
|
43 |
|
44 |
$alias = $name;
|
45 |
if ($stream->nextIf('as')) {
|
46 |
-
$alias = $stream->expect(
|
47 |
}
|
48 |
|
49 |
-
$targets[$name] = new
|
50 |
|
51 |
-
if (!$stream->nextIf(
|
52 |
break;
|
53 |
}
|
54 |
} while (true);
|
55 |
}
|
56 |
|
57 |
-
$stream->expect(
|
58 |
|
59 |
-
$this->parser->addTrait(new
|
60 |
}
|
61 |
|
62 |
public function getTag()
|
25 |
*
|
26 |
* @final
|
27 |
*/
|
28 |
+
class Twig_SupTwgSgg_TokenParser_Use extends Twig_SupTwgSgg_TokenParser
|
29 |
{
|
30 |
+
public function parse(Twig_SupTwgSgg_Token $token)
|
31 |
{
|
32 |
$template = $this->parser->getExpressionParser()->parseExpression();
|
33 |
$stream = $this->parser->getStream();
|
34 |
|
35 |
+
if (!$template instanceof Twig_SupTwgSgg_Node_Expression_Constant) {
|
36 |
+
throw new Twig_SupTwgSgg_Error_Syntax('The template references in a "use" statement must be a string.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
|
37 |
}
|
38 |
|
39 |
$targets = array();
|
40 |
if ($stream->nextIf('with')) {
|
41 |
do {
|
42 |
+
$name = $stream->expect(Twig_SupTwgSgg_Token::NAME_TYPE)->getValue();
|
43 |
|
44 |
$alias = $name;
|
45 |
if ($stream->nextIf('as')) {
|
46 |
+
$alias = $stream->expect(Twig_SupTwgSgg_Token::NAME_TYPE)->getValue();
|
47 |
}
|
48 |
|
49 |
+
$targets[$name] = new Twig_SupTwgSgg_Node_Expression_Constant($alias, -1);
|
50 |
|
51 |
+
if (!$stream->nextIf(Twig_SupTwgSgg_Token::PUNCTUATION_TYPE, ',')) {
|
52 |
break;
|
53 |
}
|
54 |
} while (true);
|
55 |
}
|
56 |
|
57 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
58 |
|
59 |
+
$this->parser->addTrait(new Twig_SupTwgSgg_Node(array('template' => $template, 'targets' => new Twig_SupTwgSgg_Node($targets))));
|
60 |
}
|
61 |
|
62 |
public function getTag()
|
vendor/Twig/TokenParser/With.php
CHANGED
@@ -16,29 +16,29 @@
|
|
16 |
*
|
17 |
* @final
|
18 |
*/
|
19 |
-
class
|
20 |
{
|
21 |
-
public function parse(
|
22 |
{
|
23 |
$stream = $this->parser->getStream();
|
24 |
|
25 |
$variables = null;
|
26 |
$only = false;
|
27 |
-
if (!$stream->test(
|
28 |
$variables = $this->parser->getExpressionParser()->parseExpression();
|
29 |
-
$only = $stream->nextIf(
|
30 |
}
|
31 |
|
32 |
-
$stream->expect(
|
33 |
|
34 |
$body = $this->parser->subparse(array($this, 'decideWithEnd'), true);
|
35 |
|
36 |
-
$stream->expect(
|
37 |
|
38 |
-
return new
|
39 |
}
|
40 |
|
41 |
-
public function decideWithEnd(
|
42 |
{
|
43 |
return $token->test('endwith');
|
44 |
}
|
16 |
*
|
17 |
* @final
|
18 |
*/
|
19 |
+
class Twig_SupTwgSgg_TokenParser_With extends Twig_SupTwgSgg_TokenParser
|
20 |
{
|
21 |
+
public function parse(Twig_SupTwgSgg_Token $token)
|
22 |
{
|
23 |
$stream = $this->parser->getStream();
|
24 |
|
25 |
$variables = null;
|
26 |
$only = false;
|
27 |
+
if (!$stream->test(Twig_SupTwgSgg_Token::BLOCK_END_TYPE)) {
|
28 |
$variables = $this->parser->getExpressionParser()->parseExpression();
|
29 |
+
$only = $stream->nextIf(Twig_SupTwgSgg_Token::NAME_TYPE, 'only');
|
30 |
}
|
31 |
|
32 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
33 |
|
34 |
$body = $this->parser->subparse(array($this, 'decideWithEnd'), true);
|
35 |
|
36 |
+
$stream->expect(Twig_SupTwgSgg_Token::BLOCK_END_TYPE);
|
37 |
|
38 |
+
return new Twig_SupTwgSgg_Node_With($body, $variables, $only, $token->getLine(), $this->getTag());
|
39 |
}
|
40 |
|
41 |
+
public function decideWithEnd(Twig_SupTwgSgg_Token $token)
|
42 |
{
|
43 |
return $token->test('endwith');
|
44 |
}
|
vendor/Twig/TokenParserBroker.php
CHANGED
@@ -17,43 +17,43 @@
|
|
17 |
*
|
18 |
* @deprecated since 1.12 (to be removed in 2.0)
|
19 |
*/
|
20 |
-
class
|
21 |
{
|
22 |
protected $parser;
|
23 |
protected $parsers = array();
|
24 |
protected $brokers = array();
|
25 |
|
26 |
/**
|
27 |
-
* @param array|Traversable $parsers A Traversable of
|
28 |
-
* @param array|Traversable $brokers A Traversable of
|
29 |
* @param bool $triggerDeprecationError
|
30 |
*/
|
31 |
public function __construct($parsers = array(), $brokers = array(), $triggerDeprecationError = true)
|
32 |
{
|
33 |
if ($triggerDeprecationError) {
|
34 |
-
|
35 |
}
|
36 |
|
37 |
foreach ($parsers as $parser) {
|
38 |
-
if (!$parser instanceof
|
39 |
-
throw new LogicException('$parsers must a an array of
|
40 |
}
|
41 |
$this->parsers[$parser->getTag()] = $parser;
|
42 |
}
|
43 |
foreach ($brokers as $broker) {
|
44 |
-
if (!$broker instanceof
|
45 |
-
throw new LogicException('$brokers must a an array of
|
46 |
}
|
47 |
$this->brokers[] = $broker;
|
48 |
}
|
49 |
}
|
50 |
|
51 |
-
public function addTokenParser(
|
52 |
{
|
53 |
$this->parsers[$parser->getTag()] = $parser;
|
54 |
}
|
55 |
|
56 |
-
public function removeTokenParser(
|
57 |
{
|
58 |
$name = $parser->getTag();
|
59 |
if (isset($this->parsers[$name]) && $parser === $this->parsers[$name]) {
|
@@ -61,12 +61,12 @@ class Twig_SupTwg_TokenParserBroker implements Twig_SupTwg_TokenParserBrokerInte
|
|
61 |
}
|
62 |
}
|
63 |
|
64 |
-
public function addTokenParserBroker(
|
65 |
{
|
66 |
$this->brokers[] = $broker;
|
67 |
}
|
68 |
|
69 |
-
public function removeTokenParserBroker(
|
70 |
{
|
71 |
if (false !== $pos = array_search($broker, $this->brokers)) {
|
72 |
unset($this->brokers[$pos]);
|
@@ -80,7 +80,7 @@ class Twig_SupTwg_TokenParserBroker implements Twig_SupTwg_TokenParserBrokerInte
|
|
80 |
*
|
81 |
* @param string $tag A tag name
|
82 |
*
|
83 |
-
* @return null|
|
84 |
*/
|
85 |
public function getTokenParser($tag)
|
86 |
{
|
@@ -107,7 +107,7 @@ class Twig_SupTwg_TokenParserBroker implements Twig_SupTwg_TokenParserBrokerInte
|
|
107 |
return $this->parser;
|
108 |
}
|
109 |
|
110 |
-
public function setParser(
|
111 |
{
|
112 |
$this->parser = $parser;
|
113 |
foreach ($this->parsers as $tokenParser) {
|
17 |
*
|
18 |
* @deprecated since 1.12 (to be removed in 2.0)
|
19 |
*/
|
20 |
+
class Twig_SupTwgSgg_TokenParserBroker implements Twig_SupTwgSgg_TokenParserBrokerInterface
|
21 |
{
|
22 |
protected $parser;
|
23 |
protected $parsers = array();
|
24 |
protected $brokers = array();
|
25 |
|
26 |
/**
|
27 |
+
* @param array|Traversable $parsers A Traversable of Twig_SupTwgSgg_TokenParserInterface instances
|
28 |
+
* @param array|Traversable $brokers A Traversable of Twig_SupTwgSgg_TokenParserBrokerInterface instances
|
29 |
* @param bool $triggerDeprecationError
|
30 |
*/
|
31 |
public function __construct($parsers = array(), $brokers = array(), $triggerDeprecationError = true)
|
32 |
{
|
33 |
if ($triggerDeprecationError) {
|
34 |
+
//@trigger_error('The '.__CLASS__.' class is deprecated since version 1.12 and will be removed in 2.0.', E_USER_DEPRECATED);
|
35 |
}
|
36 |
|
37 |
foreach ($parsers as $parser) {
|
38 |
+
if (!$parser instanceof Twig_SupTwgSgg_TokenParserInterface) {
|
39 |
+
throw new LogicException('$parsers must a an array of Twig_SupTwgSgg_TokenParserInterface.');
|
40 |
}
|
41 |
$this->parsers[$parser->getTag()] = $parser;
|
42 |
}
|
43 |
foreach ($brokers as $broker) {
|
44 |
+
if (!$broker instanceof Twig_SupTwgSgg_TokenParserBrokerInterface) {
|
45 |
+
throw new LogicException('$brokers must a an array of Twig_SupTwgSgg_TokenParserBrokerInterface.');
|
46 |
}
|
47 |
$this->brokers[] = $broker;
|
48 |
}
|
49 |
}
|
50 |
|
51 |
+
public function addTokenParser(Twig_SupTwgSgg_TokenParserInterface $parser)
|
52 |
{
|
53 |
$this->parsers[$parser->getTag()] = $parser;
|
54 |
}
|
55 |
|
56 |
+
public function removeTokenParser(Twig_SupTwgSgg_TokenParserInterface $parser)
|
57 |
{
|
58 |
$name = $parser->getTag();
|
59 |
if (isset($this->parsers[$name]) && $parser === $this->parsers[$name]) {
|
61 |
}
|
62 |
}
|
63 |
|
64 |
+
public function addTokenParserBroker(Twig_SupTwgSgg_TokenParserBroker $broker)
|
65 |
{
|
66 |
$this->brokers[] = $broker;
|
67 |
}
|
68 |
|
69 |
+
public function removeTokenParserBroker(Twig_SupTwgSgg_TokenParserBroker $broker)
|
70 |
{
|
71 |
if (false !== $pos = array_search($broker, $this->brokers)) {
|
72 |
unset($this->brokers[$pos]);
|
80 |
*
|
81 |
* @param string $tag A tag name
|
82 |
*
|
83 |
+
* @return null|Twig_SupTwgSgg_TokenParserInterface A Twig_SupTwgSgg_TokenParserInterface or null if no suitable TokenParser was found
|
84 |
*/
|
85 |
public function getTokenParser($tag)
|
86 |
{
|
107 |
return $this->parser;
|
108 |
}
|
109 |
|
110 |
+
public function setParser(Twig_SupTwgSgg_ParserInterface $parser)
|
111 |
{
|
112 |
$this->parser = $parser;
|
113 |
foreach ($this->parsers as $tokenParser) {
|
vendor/Twig/TokenParserBrokerInterface.php
CHANGED
@@ -19,26 +19,26 @@
|
|
19 |
*
|
20 |
* @deprecated since 1.12 (to be removed in 2.0)
|
21 |
*/
|
22 |
-
interface
|
23 |
{
|
24 |
/**
|
25 |
* Gets a TokenParser suitable for a tag.
|
26 |
*
|
27 |
* @param string $tag A tag name
|
28 |
*
|
29 |
-
* @return
|
30 |
*/
|
31 |
public function getTokenParser($tag);
|
32 |
|
33 |
/**
|
34 |
-
* Calls
|
35 |
*/
|
36 |
-
public function setParser(
|
37 |
|
38 |
/**
|
39 |
-
* Gets the
|
40 |
*
|
41 |
-
* @return null|
|
42 |
*/
|
43 |
public function getParser();
|
44 |
}
|
19 |
*
|
20 |
* @deprecated since 1.12 (to be removed in 2.0)
|
21 |
*/
|
22 |
+
interface Twig_SupTwgSgg_TokenParserBrokerInterface
|
23 |
{
|
24 |
/**
|
25 |
* Gets a TokenParser suitable for a tag.
|
26 |
*
|
27 |
* @param string $tag A tag name
|
28 |
*
|
29 |
+
* @return Twig_SupTwgSgg_TokenParserInterface|null A Twig_SupTwgSgg_TokenParserInterface or null if no suitable TokenParser was found
|
30 |
*/
|
31 |
public function getTokenParser($tag);
|
32 |
|
33 |
/**
|
34 |
+
* Calls Twig_SupTwgSgg_TokenParserInterface::setParser on all parsers the implementation knows of.
|
35 |
*/
|
36 |
+
public function setParser(Twig_SupTwgSgg_ParserInterface $parser);
|
37 |
|
38 |
/**
|
39 |
+
* Gets the Twig_SupTwgSgg_ParserInterface.
|
40 |
*
|
41 |
+
* @return null|Twig_SupTwgSgg_ParserInterface A Twig_SupTwgSgg_ParserInterface instance or null
|
42 |
*/
|
43 |
public function getParser();
|
44 |
}
|
vendor/Twig/TokenParserInterface.php
CHANGED
@@ -14,21 +14,21 @@
|
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
-
interface
|
18 |
{
|
19 |
/**
|
20 |
* Sets the parser associated with this token parser.
|
21 |
*/
|
22 |
-
public function setParser(
|
23 |
|
24 |
/**
|
25 |
* Parses a token and returns a node.
|
26 |
*
|
27 |
-
* @return
|
28 |
*
|
29 |
-
* @throws
|
30 |
*/
|
31 |
-
public function parse(
|
32 |
|
33 |
/**
|
34 |
* Gets the tag name associated with this token parser.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
interface Twig_SupTwgSgg_TokenParserInterface
|
18 |
{
|
19 |
/**
|
20 |
* Sets the parser associated with this token parser.
|
21 |
*/
|
22 |
+
public function setParser(Twig_SupTwgSgg_Parser $parser);
|
23 |
|
24 |
/**
|
25 |
* Parses a token and returns a node.
|
26 |
*
|
27 |
+
* @return Twig_SupTwgSgg_NodeInterface
|
28 |
*
|
29 |
+
* @throws Twig_SupTwgSgg_Error_Syntax
|
30 |
*/
|
31 |
+
public function parse(Twig_SupTwgSgg_Token $token);
|
32 |
|
33 |
/**
|
34 |
* Gets the tag name associated with this token parser.
|
vendor/Twig/TokenStream.php
CHANGED
@@ -17,7 +17,7 @@
|
|
17 |
*
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*/
|
20 |
-
class
|
21 |
{
|
22 |
protected $tokens;
|
23 |
protected $current = 0;
|
@@ -32,11 +32,11 @@ class Twig_SupTwg_TokenStream
|
|
32 |
*/
|
33 |
public function __construct(array $tokens, $name = null, $source = null)
|
34 |
{
|
35 |
-
if (!$name instanceof
|
36 |
if (null !== $name || null !== $source) {
|
37 |
-
|
38 |
}
|
39 |
-
$this->source = new
|
40 |
} else {
|
41 |
$this->source = $name;
|
42 |
}
|
@@ -60,12 +60,12 @@ class Twig_SupTwg_TokenStream
|
|
60 |
/**
|
61 |
* Sets the pointer to the next token and returns the old one.
|
62 |
*
|
63 |
-
* @return
|
64 |
*/
|
65 |
public function next()
|
66 |
{
|
67 |
if (!isset($this->tokens[++$this->current])) {
|
68 |
-
throw new
|
69 |
}
|
70 |
|
71 |
return $this->tokens[$this->current - 1];
|
@@ -74,7 +74,7 @@ class Twig_SupTwg_TokenStream
|
|
74 |
/**
|
75 |
* Tests a token, sets the pointer to the next one and returns it or throws a syntax error.
|
76 |
*
|
77 |
-
* @return
|
78 |
*/
|
79 |
public function nextIf($primary, $secondary = null)
|
80 |
{
|
@@ -86,17 +86,17 @@ class Twig_SupTwg_TokenStream
|
|
86 |
/**
|
87 |
* Tests a token and returns it or throws a syntax error.
|
88 |
*
|
89 |
-
* @return
|
90 |
*/
|
91 |
public function expect($type, $value = null, $message = null)
|
92 |
{
|
93 |
$token = $this->tokens[$this->current];
|
94 |
if (!$token->test($type, $value)) {
|
95 |
$line = $token->getLine();
|
96 |
-
throw new
|
97 |
$message ? $message.'. ' : '',
|
98 |
-
|
99 |
-
|
100 |
$line,
|
101 |
$this->source
|
102 |
);
|
@@ -111,12 +111,12 @@ class Twig_SupTwg_TokenStream
|
|
111 |
*
|
112 |
* @param int $number
|
113 |
*
|
114 |
-
* @return
|
115 |
*/
|
116 |
public function look($number = 1)
|
117 |
{
|
118 |
if (!isset($this->tokens[$this->current + $number])) {
|
119 |
-
throw new
|
120 |
}
|
121 |
|
122 |
return $this->tokens[$this->current + $number];
|
@@ -139,11 +139,11 @@ class Twig_SupTwg_TokenStream
|
|
139 |
*/
|
140 |
public function isEOF()
|
141 |
{
|
142 |
-
return $this->tokens[$this->current]->getType() ===
|
143 |
}
|
144 |
|
145 |
/**
|
146 |
-
* @return
|
147 |
*/
|
148 |
public function getCurrent()
|
149 |
{
|
@@ -159,7 +159,7 @@ class Twig_SupTwg_TokenStream
|
|
159 |
*/
|
160 |
public function getFilename()
|
161 |
{
|
162 |
-
|
163 |
|
164 |
return $this->source->getName();
|
165 |
}
|
@@ -175,7 +175,7 @@ class Twig_SupTwg_TokenStream
|
|
175 |
*/
|
176 |
public function getSource()
|
177 |
{
|
178 |
-
|
179 |
|
180 |
return $this->source->getCode();
|
181 |
}
|
@@ -183,7 +183,7 @@ class Twig_SupTwg_TokenStream
|
|
183 |
/**
|
184 |
* Gets the source associated with this stream.
|
185 |
*
|
186 |
-
* @return
|
187 |
*
|
188 |
* @internal
|
189 |
*/
|
17 |
*
|
18 |
* @author Fabien Potencier <fabien@symfony.com>
|
19 |
*/
|
20 |
+
class Twig_SupTwgSgg_TokenStream
|
21 |
{
|
22 |
protected $tokens;
|
23 |
protected $current = 0;
|
32 |
*/
|
33 |
public function __construct(array $tokens, $name = null, $source = null)
|
34 |
{
|
35 |
+
if (!$name instanceof Twig_SupTwgSgg_Source) {
|
36 |
if (null !== $name || null !== $source) {
|
37 |
+
//@trigger_error(sprintf('Passing a string as the $name argument of %s() is deprecated since version 1.27. Pass a Twig_SupTwgSgg_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
38 |
}
|
39 |
+
$this->source = new Twig_SupTwgSgg_Source($source, $name);
|
40 |
} else {
|
41 |
$this->source = $name;
|
42 |
}
|
60 |
/**
|
61 |
* Sets the pointer to the next token and returns the old one.
|
62 |
*
|
63 |
+
* @return Twig_SupTwgSgg_Token
|
64 |
*/
|
65 |
public function next()
|
66 |
{
|
67 |
if (!isset($this->tokens[++$this->current])) {
|
68 |
+
throw new Twig_SupTwgSgg_Error_Syntax('Unexpected end of template.', $this->tokens[$this->current - 1]->getLine(), $this->source);
|
69 |
}
|
70 |
|
71 |
return $this->tokens[$this->current - 1];
|
74 |
/**
|
75 |
* Tests a token, sets the pointer to the next one and returns it or throws a syntax error.
|
76 |
*
|
77 |
+
* @return Twig_SupTwgSgg_Token|null The next token if the condition is true, null otherwise
|
78 |
*/
|
79 |
public function nextIf($primary, $secondary = null)
|
80 |
{
|
86 |
/**
|
87 |
* Tests a token and returns it or throws a syntax error.
|
88 |
*
|
89 |
+
* @return Twig_SupTwgSgg_Token
|
90 |
*/
|
91 |
public function expect($type, $value = null, $message = null)
|
92 |
{
|
93 |
$token = $this->tokens[$this->current];
|
94 |
if (!$token->test($type, $value)) {
|
95 |
$line = $token->getLine();
|
96 |
+
throw new Twig_SupTwgSgg_Error_Syntax(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s).',
|
97 |
$message ? $message.'. ' : '',
|
98 |
+
Twig_SupTwgSgg_Token::typeToEnglish($token->getType()), $token->getValue(),
|
99 |
+
Twig_SupTwgSgg_Token::typeToEnglish($type), $value ? sprintf(' with value "%s"', $value) : ''),
|
100 |
$line,
|
101 |
$this->source
|
102 |
);
|
111 |
*
|
112 |
* @param int $number
|
113 |
*
|
114 |
+
* @return Twig_SupTwgSgg_Token
|
115 |
*/
|
116 |
public function look($number = 1)
|
117 |
{
|
118 |
if (!isset($this->tokens[$this->current + $number])) {
|
119 |
+
throw new Twig_SupTwgSgg_Error_Syntax('Unexpected end of template.', $this->tokens[$this->current + $number - 1]->getLine(), $this->source);
|
120 |
}
|
121 |
|
122 |
return $this->tokens[$this->current + $number];
|
139 |
*/
|
140 |
public function isEOF()
|
141 |
{
|
142 |
+
return $this->tokens[$this->current]->getType() === Twig_SupTwgSgg_Token::EOF_TYPE;
|
143 |
}
|
144 |
|
145 |
/**
|
146 |
+
* @return Twig_SupTwgSgg_Token
|
147 |
*/
|
148 |
public function getCurrent()
|
149 |
{
|
159 |
*/
|
160 |
public function getFilename()
|
161 |
{
|
162 |
+
//@trigger_error(sprintf('The %s() method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', __METHOD__), E_USER_DEPRECATED);
|
163 |
|
164 |
return $this->source->getName();
|
165 |
}
|
175 |
*/
|
176 |
public function getSource()
|
177 |
{
|
178 |
+
//@trigger_error(sprintf('The %s() method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', __METHOD__), E_USER_DEPRECATED);
|
179 |
|
180 |
return $this->source->getCode();
|
181 |
}
|
183 |
/**
|
184 |
* Gets the source associated with this stream.
|
185 |
*
|
186 |
+
* @return Twig_SupTwgSgg_Source
|
187 |
*
|
188 |
* @internal
|
189 |
*/
|
vendor/Twig/Util/DeprecationCollector.php
CHANGED
@@ -14,12 +14,12 @@
|
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
-
class
|
18 |
{
|
19 |
private $twig;
|
20 |
private $deprecations;
|
21 |
|
22 |
-
public function __construct(
|
23 |
{
|
24 |
$this->twig = $twig;
|
25 |
}
|
@@ -40,7 +40,7 @@ class Twig_SupTwg_Util_DeprecationCollector
|
|
40 |
), '{'.preg_quote($ext).'$}'
|
41 |
);
|
42 |
|
43 |
-
return $this->collect(new
|
44 |
}
|
45 |
|
46 |
/**
|
@@ -58,8 +58,8 @@ class Twig_SupTwg_Util_DeprecationCollector
|
|
58 |
|
59 |
foreach ($iterator as $name => $contents) {
|
60 |
try {
|
61 |
-
$this->twig->parse($this->twig->tokenize(new
|
62 |
-
} catch (
|
63 |
// ignore templates containing syntax errors
|
64 |
}
|
65 |
}
|
14 |
*
|
15 |
* @final
|
16 |
*/
|
17 |
+
class Twig_SupTwgSgg_Util_DeprecationCollector
|
18 |
{
|
19 |
private $twig;
|
20 |
private $deprecations;
|
21 |
|
22 |
+
public function __construct(Twig_SupTwgSgg_Environment $twig)
|
23 |
{
|
24 |
$this->twig = $twig;
|
25 |
}
|
40 |
), '{'.preg_quote($ext).'$}'
|
41 |
);
|
42 |
|
43 |
+
return $this->collect(new Twig_SupTwgSgg_Util_TemplateDirIterator($iterator));
|
44 |
}
|
45 |
|
46 |
/**
|
58 |
|
59 |
foreach ($iterator as $name => $contents) {
|
60 |
try {
|
61 |
+
$this->twig->parse($this->twig->tokenize(new Twig_SupTwgSgg_Source($contents, $name)));
|
62 |
+
} catch (Twig_SupTwgSgg_Error_Syntax $e) {
|
63 |
// ignore templates containing syntax errors
|
64 |
}
|
65 |
}
|
vendor/Twig/Util/TemplateDirIterator.php
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
14 |
*/
|
15 |
-
class
|
16 |
{
|
17 |
public function current()
|
18 |
{
|
12 |
/**
|
13 |
* @author Fabien Potencier <fabien@symfony.com>
|
14 |
*/
|
15 |
+
class Twig_SupTwgSgg_Util_TemplateDirIterator extends IteratorIterator
|
16 |
{
|
17 |
public function current()
|
18 |
{
|