Version Description
/ 30.08.2022 = * Required min PRO 1.2.3
Download this release
Release Info
Developer | supsystic.com |
Plugin | Social Share Buttons by Supsystic |
Version | 2.2.9 |
Comparing to | |
See all releases |
Code changes from version 2.2.7 to 2.2.9
- app/SupsysticSocialSharing.php +20 -7
- app/assets/css/supsystic-ui.css +6 -7
- app/assets/js/supsystic.ui.js +1 -1
- app/templates/base.twig +0 -1
- app/templates/layout.twig +51 -29
- index.php +20 -1
- readme.txt +8 -1
- src/SocialSharing/Ajax/RequestHandler.php +6 -6
- src/SocialSharing/Ajax/RequestHandlerInterface.php +2 -2
- src/SocialSharing/Core/BaseController.php +10 -10
- src/SocialSharing/Core/BaseModel.php +4 -4
- src/SocialSharing/Core/BaseModule.php +1 -1
- src/SocialSharing/Core/ModelsFactory.php +4 -4
- src/SocialSharing/Core/Module.php +41 -8
- src/SocialSharing/Core/assets/js/core.js +1 -1
- src/SocialSharing/Featuredplugins/Controller.php +0 -51
- src/SocialSharing/Featuredplugins/Module.php +0 -57
- src/SocialSharing/Featuredplugins/assets/css/admin.featured-plugins.css +0 -291
- src/SocialSharing/Featuredplugins/assets/css/img/bg_texture.png +0 -0
- src/SocialSharing/Featuredplugins/assets/img/256.png +0 -0
- src/SocialSharing/Featuredplugins/assets/img/Backup_256.png +0 -0
- src/SocialSharing/Featuredplugins/assets/img/Coming_Soon_256.png +0 -0
- src/SocialSharing/Featuredplugins/assets/img/Contact_Form_256.png +0 -0
- src/SocialSharing/Featuredplugins/assets/img/Data_Tables_256.png +0 -0
- src/SocialSharing/Featuredplugins/assets/img/Digital_Publication_256.png +0 -0
- src/SocialSharing/Featuredplugins/assets/img/Gallery_256.png +0 -0
- src/SocialSharing/Featuredplugins/assets/img/Google_Maps_256.png +0 -0
- src/SocialSharing/Featuredplugins/assets/img/Live_Chat_256.png +0 -0
- src/SocialSharing/Featuredplugins/assets/img/Popup_256.png +0 -0
- src/SocialSharing/Featuredplugins/assets/img/Pricing_Table_256.png +0 -0
- src/SocialSharing/Featuredplugins/assets/img/Slider_256.png +0 -0
- src/SocialSharing/Featuredplugins/assets/img/Social_Buttons_256.png +0 -0
- src/SocialSharing/Featuredplugins/assets/img/heatmap.jpg +0 -0
- src/SocialSharing/Featuredplugins/assets/img/icon-256x256.png +0 -0
- src/SocialSharing/Featuredplugins/assets/img/kinsta_banner.png +0 -0
- src/SocialSharing/Featuredplugins/assets/img/shapes.jpg +0 -0
- src/SocialSharing/Featuredplugins/views/index.twig +0 -46
- src/SocialSharing/Networks/Controller.php +17 -17
- src/SocialSharing/Overview/Controller.php +62 -3
- src/SocialSharing/Overview/Module.php +1 -1
- src/SocialSharing/Overview/assets/css/overview-styles.css +259 -12
- src/SocialSharing/Overview/assets/img/overview-01.png +0 -0
- src/SocialSharing/Overview/assets/img/overview-02.png +0 -0
- src/SocialSharing/Overview/assets/img/overview-03.png +0 -0
- src/SocialSharing/Overview/assets/img/plugin-icon.png +0 -0
- src/SocialSharing/Overview/assets/img/supsystic-logo-small.png +0 -0
- src/SocialSharing/Overview/assets/js/overview-settings.js +218 -12
- src/SocialSharing/Overview/views/form.twig +66 -11
- src/SocialSharing/Overview/views/index.twig +135 -97
- src/SocialSharing/Projects/Builder.php +4 -4
- src/SocialSharing/Projects/Builder/Standard.php +6 -4
- src/SocialSharing/Projects/Controller.php +30 -30
- src/SocialSharing/Projects/Handler.php +2 -2
- src/SocialSharing/Projects/Model/Tooltips.php +17 -18
- src/SocialSharing/Projects/Module.php +2 -2
- src/SocialSharing/Projects/assets/css/projects.css +2 -9
- src/SocialSharing/Projects/assets/js/projects.edit.js +19 -17
- src/SocialSharing/Projects/views/add.twig +3 -3
- src/SocialSharing/Projects/views/index.twig +2 -2
- src/SocialSharing/Promo/Controller.php +2 -2
- src/SocialSharing/Shares/Controller.php +17 -17
- src/SocialSharing/Shares/Model/SharesObject.php +16 -37
- src/SocialSharing/Shares/Module.php +3 -3
- src/SocialSharing/Shares/assets/js/share.js +1 -1
- src/SocialSharing/Shares/assets/js/shares.statistic.js +1 -1
- src/SocialSharing/Tester/Controller.php +2 -2
- src/SocialSharing/Ui/Asset.php +2 -2
- src/SocialSharing/Ui/Module.php +4 -4
- 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 +18 -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 +48 -58
- 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 +1 -1
- 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 +9 -9
- 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 +227 -227
- 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 +8 -8
- 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 +13 -12
- 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/SupsysticSocialSharing.php
CHANGED
@@ -9,16 +9,16 @@ class SupsysticSocialSharing
|
|
9 |
|
10 |
public function __construct()
|
11 |
{
|
12 |
-
if (!class_exists('
|
13 |
require dirname(dirname(__FILE__)) . '/vendor/Rsc/Autoloader.php';
|
14 |
-
|
15 |
}
|
16 |
|
17 |
$pluginPath = dirname(dirname(__FILE__));
|
18 |
$pluginName = 'sss';
|
19 |
$pluginTitleName = 'Social Share by Supsystic';
|
20 |
$pluginSlug = 'supsystic-social-sharing';
|
21 |
-
$environment = new
|
22 |
|
23 |
/* Configure */
|
24 |
$environment->configure(
|
@@ -46,7 +46,7 @@ class SupsysticSocialSharing
|
|
46 |
'icon_url' => 'dashicons-share',
|
47 |
'position' => '101.8',
|
48 |
),
|
49 |
-
'shortcode_name' => '
|
50 |
'db_prefix' => 'supsystic_ss_',
|
51 |
'hooks_prefix' => 'supsystic_ss_',
|
52 |
'ajax_url' => admin_url('admin-ajax.php'),
|
@@ -118,7 +118,7 @@ class SupsysticSocialSharing
|
|
118 |
public function createSchema()
|
119 |
{
|
120 |
global $wpdb;
|
121 |
-
if(get_option('sss'.'_installed')) return;
|
122 |
|
123 |
if (!function_exists('dbDelta')) {
|
124 |
require_once(ABSPATH.'wp-admin/includes/upgrade.php');
|
@@ -330,6 +330,19 @@ class SupsysticSocialSharing
|
|
330 |
dbDelta( $sql );
|
331 |
}
|
332 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
333 |
if (!$this->db_table_exist('supsystic_ss_views')) {
|
334 |
$charset_collate = $wpdb->get_charset_collate();
|
335 |
$table_name = $wpdb->prefix . 'supsystic_ss_views';
|
@@ -377,13 +390,13 @@ class SupsysticSocialSharing
|
|
377 |
|
378 |
protected function getPluginEnvironment()
|
379 |
{
|
380 |
-
$environment =
|
381 |
|
382 |
if ((defined('WP_DEBUG') && WP_DEBUG) || (defined(
|
383 |
'SUPSYSTIC_SS_DEBUG'
|
384 |
) && SUPSYSTIC_SS_DEBUG)
|
385 |
) {
|
386 |
-
$environment =
|
387 |
}
|
388 |
|
389 |
return $environment;
|
9 |
|
10 |
public function __construct()
|
11 |
{
|
12 |
+
if (!class_exists('RscSss_Autoloader', false)) {
|
13 |
require dirname(dirname(__FILE__)) . '/vendor/Rsc/Autoloader.php';
|
14 |
+
RscSss_Autoloader::register();
|
15 |
}
|
16 |
|
17 |
$pluginPath = dirname(dirname(__FILE__));
|
18 |
$pluginName = 'sss';
|
19 |
$pluginTitleName = 'Social Share by Supsystic';
|
20 |
$pluginSlug = 'supsystic-social-sharing';
|
21 |
+
$environment = new RscSss_Environment($pluginName, '2.2.9', $pluginPath);
|
22 |
|
23 |
/* Configure */
|
24 |
$environment->configure(
|
46 |
'icon_url' => 'dashicons-share',
|
47 |
'position' => '101.8',
|
48 |
),
|
49 |
+
'shortcode_name' => 'social-share',
|
50 |
'db_prefix' => 'supsystic_ss_',
|
51 |
'hooks_prefix' => 'supsystic_ss_',
|
52 |
'ajax_url' => admin_url('admin-ajax.php'),
|
118 |
public function createSchema()
|
119 |
{
|
120 |
global $wpdb;
|
121 |
+
// if(get_option('sss'.'_installed')) return;
|
122 |
|
123 |
if (!function_exists('dbDelta')) {
|
124 |
require_once(ABSPATH.'wp-admin/includes/upgrade.php');
|
330 |
dbDelta( $sql );
|
331 |
}
|
332 |
|
333 |
+
if (!$this->db_table_exist('supsystic_ss_shares_object')) {
|
334 |
+
$charset_collate = $wpdb->get_charset_collate();
|
335 |
+
$table_name = $wpdb->prefix . 'supsystic_ss_shares_object';
|
336 |
+
$sql = "CREATE TABLE IF NOT EXISTS $table_name (
|
337 |
+
`share_id` INT NOT NULL,
|
338 |
+
`code` VARCHAR(10) NOT NULL,
|
339 |
+
`item_id`INT NOT NULL,
|
340 |
+
PRIMARY KEY (`share_id`),
|
341 |
+
KEY `idx_search1` (`code`,`item_id`)
|
342 |
+
) $charset_collate";
|
343 |
+
dbDelta( $sql );
|
344 |
+
}
|
345 |
+
|
346 |
if (!$this->db_table_exist('supsystic_ss_views')) {
|
347 |
$charset_collate = $wpdb->get_charset_collate();
|
348 |
$table_name = $wpdb->prefix . 'supsystic_ss_views';
|
390 |
|
391 |
protected function getPluginEnvironment()
|
392 |
{
|
393 |
+
$environment = RscSss_Environment::ENV_PRODUCTION;
|
394 |
|
395 |
if ((defined('WP_DEBUG') && WP_DEBUG) || (defined(
|
396 |
'SUPSYSTIC_SS_DEBUG'
|
397 |
) && SUPSYSTIC_SS_DEBUG)
|
398 |
) {
|
399 |
+
$environment = RscSss_Environment::ENV_DEVELOPMENT;
|
400 |
}
|
401 |
|
402 |
return $environment;
|
app/assets/css/supsystic-ui.css
CHANGED
@@ -29,13 +29,13 @@
|
|
29 |
box-sizing: border-box;
|
30 |
float: left;
|
31 |
position: relative;
|
32 |
-
width:
|
33 |
min-height: 353px;
|
34 |
}
|
35 |
|
36 |
.supsystic-plugin .supsystic-content .supsystic-container {
|
37 |
margin-left: 75px;
|
38 |
-
min-height:
|
39 |
background-color: #fff;
|
40 |
}
|
41 |
|
@@ -276,10 +276,10 @@ ul.supsystic-bar-controls > li.separator {
|
|
276 |
}
|
277 |
|
278 |
.supsystic-item {
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
}
|
284 |
|
285 |
.supsystic-checked {
|
@@ -388,7 +388,6 @@ h2.nav-tab-wrapper, h3.nav-tab-wrapper {
|
|
388 |
box-shadow: none;
|
389 |
border: 1px solid #000 !important;
|
390 |
line-height: 31px;
|
391 |
-
margin-right: 10px;
|
392 |
}
|
393 |
|
394 |
.supsystic-plugin .button.hover,
|
29 |
box-sizing: border-box;
|
30 |
float: left;
|
31 |
position: relative;
|
32 |
+
width: 100%;
|
33 |
min-height: 353px;
|
34 |
}
|
35 |
|
36 |
.supsystic-plugin .supsystic-content .supsystic-container {
|
37 |
margin-left: 75px;
|
38 |
+
min-height: 360px;
|
39 |
background-color: #fff;
|
40 |
}
|
41 |
|
276 |
}
|
277 |
|
278 |
.supsystic-item {
|
279 |
+
background: #fff;
|
280 |
+
padding: 10px 10px 10px 40px;
|
281 |
+
margin-bottom: 20px;
|
282 |
+
position: relative;
|
283 |
}
|
284 |
|
285 |
.supsystic-checked {
|
388 |
box-shadow: none;
|
389 |
border: 1px solid #000 !important;
|
390 |
line-height: 31px;
|
|
|
391 |
}
|
392 |
|
393 |
.supsystic-plugin .button.hover,
|
app/assets/js/supsystic.ui.js
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
increaseArea: '20%'
|
16 |
});*/
|
17 |
|
18 |
-
ppsInitCustomCheckRadio();
|
19 |
removeDuplicateSubmenu();
|
20 |
|
21 |
//$('[data-toggle="tooltip"]').tooltip();
|
15 |
increaseArea: '20%'
|
16 |
});*/
|
17 |
|
18 |
+
// ppsInitCustomCheckRadio();
|
19 |
removeDuplicateSubmenu();
|
20 |
|
21 |
//$('[data-toggle="tooltip"]').tooltip();
|
app/templates/base.twig
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
<div class="wrap">
|
2 |
-
<h2><!-- notice fix --></h2>
|
3 |
{% spaceless %}
|
4 |
{% block layout %}{% endblock %}
|
5 |
{% endspaceless %}
|
1 |
<div class="wrap">
|
|
|
2 |
{% spaceless %}
|
3 |
{% block layout %}{% endblock %}
|
4 |
{% endspaceless %}
|
app/templates/layout.twig
CHANGED
@@ -2,28 +2,30 @@
|
|
2 |
|
3 |
{% block layout %}
|
4 |
<div class="supsystic-plugin">
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
7 |
<ul>
|
8 |
{% block navigation %}
|
9 |
<li class="{% if request.query.module == 'overview' %}active{% endif %}" data-menu-item-title="Overview">
|
10 |
<a href="{{ environment.generateUrl('overview') }}">
|
11 |
<i class="fa fa-fw fa-info"></i>
|
12 |
-
<!-- /.fa fa-fw fa-plus -->
|
13 |
{{ environment.translate('Overview') }}
|
14 |
</a>
|
15 |
</li>
|
16 |
<li class="{% if request.query.module == 'projects' and request.query.action == 'add' %}active{% endif %}" data-menu-item-title="Add new">
|
17 |
<a href="{{ environment.generateUrl('projects', 'add') }}">
|
18 |
-
<i class="fa fa-
|
19 |
-
|
20 |
-
{{ environment.translate('Add new project') }}
|
21 |
</a>
|
22 |
</li>
|
23 |
<li class="{% if (request.query.module == 'projects' or request.query.module is not defined) and request.query.action != 'add' %}active{% endif %}" data-menu-item-title="Projects">
|
24 |
<a href="{{ environment.generateUrl('projects') }}">
|
25 |
<i class="fa fa-fw fa-archive"></i>
|
26 |
-
<!-- /.fa fa-fw fa-archive -->
|
27 |
{{ environment.translate('Projects') }}
|
28 |
</a>
|
29 |
</li>
|
@@ -31,38 +33,58 @@
|
|
31 |
<li class="{% if request.query.module == 'license' %}active{% endif %}" data-menu-item-title="License">
|
32 |
<a href="{{ environment.generateUrl('license') }}">
|
33 |
<i class="fa fa-fw fa-hand-o-right"></i>
|
34 |
-
<!-- /.fa fa-fw fa-plus -->
|
35 |
{{ environment.translate('License') }}
|
36 |
</a>
|
37 |
</li>
|
38 |
{% endif %}
|
39 |
-
<li class="{% if request.query.module == 'featuredplugins' %}active{% endif %}" data-menu-item-title="Featured Plugins">
|
40 |
-
<a href="{{ environment.generateUrl('featuredplugins') }}">
|
41 |
-
<i class="fa fa-fw fa-heart"></i>
|
42 |
-
{{ environment.translate('Featured Plugins') }}
|
43 |
-
</a>
|
44 |
-
</li>
|
45 |
-
{#<li>#}
|
46 |
-
{#<a href="#">#}
|
47 |
-
{#<i class="fa fa-fw fa-cogs"></i>#}
|
48 |
-
{#<!-- /.fa fa-fw fa-cogs -->#}
|
49 |
-
{#{{ environment.translate('Settings') }}#}
|
50 |
-
{#</a>#}
|
51 |
-
{#</li>#}
|
52 |
{% endblock %}
|
53 |
</ul>
|
54 |
<div class="clear"></div>
|
55 |
-
<!-- /.clear -->
|
56 |
</nav>
|
57 |
-
|
58 |
-
<div class="supsystic-container">
|
59 |
{{ environment.getDispatcher().dispatch('messages') }}
|
60 |
{% block content %}{% endblock %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
</div>
|
62 |
-
|
63 |
</div>
|
64 |
-
{% block dialogs %}{% endblock %}
|
65 |
-
<!-- /.supsystic-content -->
|
66 |
-
</div>
|
67 |
<!-- /.supsystic-plugin -->
|
68 |
-
{% endblock layout %}
|
2 |
|
3 |
{% block layout %}
|
4 |
<div class="supsystic-plugin">
|
5 |
+
{% block header %}
|
6 |
+
<div class="supsystic-breadcrumbs">
|
7 |
+
Social Share by Supsystic
|
8 |
+
</div>
|
9 |
+
{% endblock %}
|
10 |
+
<section class="supsystic-content" >
|
11 |
+
<nav class="supsystic-navigation" style="top: 0px;">
|
12 |
<ul>
|
13 |
{% block navigation %}
|
14 |
<li class="{% if request.query.module == 'overview' %}active{% endif %}" data-menu-item-title="Overview">
|
15 |
<a href="{{ environment.generateUrl('overview') }}">
|
16 |
<i class="fa fa-fw fa-info"></i>
|
|
|
17 |
{{ environment.translate('Overview') }}
|
18 |
</a>
|
19 |
</li>
|
20 |
<li class="{% if request.query.module == 'projects' and request.query.action == 'add' %}active{% endif %}" data-menu-item-title="Add new">
|
21 |
<a href="{{ environment.generateUrl('projects', 'add') }}">
|
22 |
+
<i class="fa fa-plus-circle"></i>
|
23 |
+
{{ environment.translate('New Project') }}
|
|
|
24 |
</a>
|
25 |
</li>
|
26 |
<li class="{% if (request.query.module == 'projects' or request.query.module is not defined) and request.query.action != 'add' %}active{% endif %}" data-menu-item-title="Projects">
|
27 |
<a href="{{ environment.generateUrl('projects') }}">
|
28 |
<i class="fa fa-fw fa-archive"></i>
|
|
|
29 |
{{ environment.translate('Projects') }}
|
30 |
</a>
|
31 |
</li>
|
33 |
<li class="{% if request.query.module == 'license' %}active{% endif %}" data-menu-item-title="License">
|
34 |
<a href="{{ environment.generateUrl('license') }}">
|
35 |
<i class="fa fa-fw fa-hand-o-right"></i>
|
|
|
36 |
{{ environment.translate('License') }}
|
37 |
</a>
|
38 |
</li>
|
39 |
{% endif %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
{% endblock %}
|
41 |
</ul>
|
42 |
<div class="clear"></div>
|
|
|
43 |
</nav>
|
44 |
+
<div class="supsystic-container supsystic-item supsystic-panel">
|
|
|
45 |
{{ environment.getDispatcher().dispatch('messages') }}
|
46 |
{% block content %}{% endblock %}
|
47 |
+
<div class="clear"></div>
|
48 |
+
|
49 |
+
{% if SSS_AC_SHOW == true %}
|
50 |
+
<div class="supsysticOverviewACFormOverlay">
|
51 |
+
<form method="post" id="overview-ac-form" class="supsysticOverviewACForm">
|
52 |
+
<div class="supsysticOverviewACTitle">
|
53 |
+
<div class="supsysticOverviewACClose"><i class="fa fa-times" aria-hidden="true"></i></div>
|
54 |
+
<a href="https://supsystic.com/" target="_blank"><img src="{{ SSS_PLUGIN_URL }}/src/SocialSharing/Overview/assets/img/supsystic-logo-small.png"></a><br>
|
55 |
+
<b>PRO plugins</b> and <b>amazing gifts</b>!
|
56 |
+
</div>
|
57 |
+
<label>Name *</label>
|
58 |
+
<input type="text" name="username" value="{{ SSS_USER_NAME }}">
|
59 |
+
<label>Email *</label>
|
60 |
+
<input type="text" name="email" value="{{ SSS_USER_EMAIL }}">
|
61 |
+
<input type="hidden" name="nonce" value="{{ environment.getNonce() }}">
|
62 |
+
<button id="subscribe-btn" type="submit" class="button button-primary button-hero">
|
63 |
+
<i class="fa fa-check-square" aria-hidden="true"></i>
|
64 |
+
Subscribe
|
65 |
+
</button>
|
66 |
+
<div class="button button-primary button-hero supsysticOverviewACBtn supsysticOverviewACBtnRemind"><i class="fa fa-hourglass-half" aria-hidden="true"></i> Remind me tomorrow</div>
|
67 |
+
<div class="button button-primary button-hero supsysticOverviewACBtn supsysticOverviewACBtnDisable"><i class="fa fa-times" aria-hidden="true"></i> Do not disturb me again</div>
|
68 |
+
<div class="supsysticOverviewACFormNotification" style="color: red; float: left;" hidden>Fields with * are required to fill</div>
|
69 |
+
</form>
|
70 |
+
<div class="clear"></div>
|
71 |
+
</div>
|
72 |
+
<div id="supsysticOverviewACFormDialog" hidden>
|
73 |
+
<div class="on-error" style="display:none">
|
74 |
+
<p>{{ translate('Some errors occurred while sending mail please send your message trough this contact form:') }}</p>
|
75 |
+
<p><a href="https://supsystic.com/plugins/social-share-plugin/#contact" target="_blank">https://supsystic.com/plugins/social-share-plugin/#contact</a></p>
|
76 |
+
</div>
|
77 |
+
<div class="message"></div>
|
78 |
+
</div>
|
79 |
+
{% endif %}
|
80 |
+
</div>
|
81 |
+
{% block dialogs %}{% endblock %}
|
82 |
+
<div class="supsystic-footer-wrapper">
|
83 |
+
<div class="supsystic-footer-add-review">Add your <a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/social-share-buttons-by-supsystic?filter=5#postform">★★★★★</a> on wordpress.org</div>
|
84 |
+
<a href="https://supsystic.com/" target="_blank"><img src="{{SSS_PLUGIN_URL}}/src/SocialSharing/Overview/assets/img/supsystic-logo-small.png"></a>
|
85 |
+
<div class="supsystic-footer-plugin-version">Social Share by Supsystic Version:{{' '}} {{SSS_PLUGIN_VERSION}}</div>
|
86 |
</div>
|
87 |
+
</section>
|
88 |
</div>
|
|
|
|
|
|
|
89 |
<!-- /.supsystic-plugin -->
|
90 |
+
{% endblock layout %}
|
index.php
CHANGED
@@ -4,11 +4,30 @@
|
|
4 |
* Plugin Name: Social Share Buttons by Supsystic
|
5 |
* Plugin URI: http://supsystic.com
|
6 |
* Description: Social share buttons to increase social traffic and popularity. Social sharing to Facebook, Twitter and other social networks
|
7 |
-
* Version: 2.2.
|
8 |
* Author: supsystic.com
|
9 |
* Author URI: http://supsystic.com
|
10 |
**/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
include dirname(__FILE__) . '/app/SupsysticSocialSharing.php';
|
13 |
|
14 |
if (!defined('SSS_PLUGIN_URL')) {
|
4 |
* Plugin Name: Social Share Buttons by Supsystic
|
5 |
* Plugin URI: http://supsystic.com
|
6 |
* Description: Social share buttons to increase social traffic and popularity. Social sharing to Facebook, Twitter and other social networks
|
7 |
+
* Version: 2.2.9
|
8 |
* Author: supsystic.com
|
9 |
* Author URI: http://supsystic.com
|
10 |
**/
|
11 |
|
12 |
+
//Fix RSC Class rename for PRO plugin
|
13 |
+
function sssChangeProVersionNotice(){
|
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 Social Share Buttons 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/social-share-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('social-share-buttons-by-supsystic', 'social-share-pro', $proPluginPath);
|
22 |
+
$proPluginPath = $proPluginPath . '/index.php';
|
23 |
+
if (file_exists($proPluginPath)) {
|
24 |
+
$pluginData = get_file_data($proPluginPath, array('Version' => 'Version'), false);
|
25 |
+
if (!empty($pluginData['Version']) && version_compare($pluginData['Version'], '1.2.3', '<')) {
|
26 |
+
add_action('admin_notices', 'sssChangeProVersionNotice');
|
27 |
+
deactivate_plugins('social-share-pro/index.php');
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
include dirname(__FILE__) . '/app/SupsysticSocialSharing.php';
|
32 |
|
33 |
if (!defined('SSS_PLUGIN_URL')) {
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: supsystic.com
|
3 |
Tags: share counter, social media share, social network share, social share, social share buttons, social sharing, facebook like, facebook share, facebook share button, like, share buttons, share links, sharebar, social buttons, facebook, facebook integration, facebook connect, google+, twitter, twitter share, linkedin share, pinterest button, button, share
|
4 |
Tested up to: 6.0
|
5 |
-
Stable tag: 2.2.
|
6 |
|
7 |
Social share buttons to increase social traffic and popularity. Social sharing to Facebook like and share, Twitter, Pinterest and other social networks
|
8 |
|
@@ -198,6 +198,13 @@ Here you can set when to show social share buttons:
|
|
198 |
|
199 |
|
200 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
= 2.2.7 / 06.07.2022 =
|
202 |
* Fixes for SQLi
|
203 |
|
2 |
Contributors: supsystic.com
|
3 |
Tags: share counter, social media share, social network share, social share, social share buttons, social sharing, facebook like, facebook share, facebook share button, like, share buttons, share links, sharebar, social buttons, facebook, facebook integration, facebook connect, google+, twitter, twitter share, linkedin share, pinterest button, button, share
|
4 |
Tested up to: 6.0
|
5 |
+
Stable tag: 2.2.9
|
6 |
|
7 |
Social share buttons to increase social traffic and popularity. Social sharing to Facebook like and share, Twitter, Pinterest and other social networks
|
8 |
|
198 |
|
199 |
|
200 |
== Changelog ==
|
201 |
+
= 2.2.9 / 30.08.2022 =
|
202 |
+
* Required min PRO 1.2.3
|
203 |
+
|
204 |
+
= 2.2.8 / 30.08.2022 =
|
205 |
+
* Add support WP 6.0
|
206 |
+
* Add support PHP 8.1
|
207 |
+
|
208 |
= 2.2.7 / 06.07.2022 =
|
209 |
* Fixes for SQLi
|
210 |
|
src/SocialSharing/Ajax/RequestHandler.php
CHANGED
@@ -4,28 +4,28 @@
|
|
4 |
class SocialSharing_Ajax_RequestHandler implements SocialSharing_Ajax_RequestHandlerInterface
|
5 |
{
|
6 |
/**
|
7 |
-
* @var
|
8 |
*/
|
9 |
private $environment;
|
10 |
|
11 |
/**
|
12 |
-
* @param
|
13 |
*/
|
14 |
-
public function __construct(
|
15 |
{
|
16 |
$this->environment = $environment;
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
* Takes AJAX request and re-route it to requested module.
|
21 |
-
* @param
|
22 |
* @return mixed
|
23 |
*/
|
24 |
-
public function handleRequest(
|
25 |
{
|
26 |
$request->server->set('X_REQUESTED_WITH', 'XMLHttpRequest');
|
27 |
|
28 |
-
/** @var
|
29 |
if (!$request->post->has('route')) {
|
30 |
return false;
|
31 |
}
|
4 |
class SocialSharing_Ajax_RequestHandler implements SocialSharing_Ajax_RequestHandlerInterface
|
5 |
{
|
6 |
/**
|
7 |
+
* @var RscSss_Environment
|
8 |
*/
|
9 |
private $environment;
|
10 |
|
11 |
/**
|
12 |
+
* @param RscSss_Environment $environment
|
13 |
*/
|
14 |
+
public function __construct(RscSss_Environment $environment)
|
15 |
{
|
16 |
$this->environment = $environment;
|
17 |
}
|
18 |
|
19 |
/**
|
20 |
* Takes AJAX request and re-route it to requested module.
|
21 |
+
* @param RscSss_Http_Request $request
|
22 |
* @return mixed
|
23 |
*/
|
24 |
+
public function handleRequest(RscSss_Http_Request $request)
|
25 |
{
|
26 |
$request->server->set('X_REQUESTED_WITH', 'XMLHttpRequest');
|
27 |
|
28 |
+
/** @var RscSss_Mvc_Module $module */
|
29 |
if (!$request->post->has('route')) {
|
30 |
return false;
|
31 |
}
|
src/SocialSharing/Ajax/RequestHandlerInterface.php
CHANGED
@@ -5,8 +5,8 @@ interface SocialSharing_Ajax_RequestHandlerInterface
|
|
5 |
{
|
6 |
/**
|
7 |
* Takes AJAX request and re-route it to requested module.
|
8 |
-
* @param
|
9 |
* @return mixed
|
10 |
*/
|
11 |
-
public function handleRequest(
|
12 |
}
|
5 |
{
|
6 |
/**
|
7 |
* Takes AJAX request and re-route it to requested module.
|
8 |
+
* @param RscSss_Http_Request $request
|
9 |
* @return mixed
|
10 |
*/
|
11 |
+
public function handleRequest(RscSss_Http_Request $request);
|
12 |
}
|
src/SocialSharing/Core/BaseController.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
* Class SocialSharing_Core_BaseController
|
5 |
*/
|
6 |
-
class SocialSharing_Core_BaseController extends
|
7 |
{
|
8 |
/**
|
9 |
* @var SocialSharing_Core_ModelsFactory
|
@@ -14,8 +14,8 @@ class SocialSharing_Core_BaseController extends Rsc_Mvc_Controller
|
|
14 |
* {@inheritdoc}
|
15 |
*/
|
16 |
public function __construct(
|
17 |
-
|
18 |
-
|
19 |
) {
|
20 |
parent::__construct(
|
21 |
$environment,
|
@@ -32,7 +32,7 @@ class SocialSharing_Core_BaseController extends Rsc_Mvc_Controller
|
|
32 |
* @param string $template The name of the template
|
33 |
* @param array $data An associative array of the data
|
34 |
* @param string $filter Filter name
|
35 |
-
* @return
|
36 |
*/
|
37 |
public function response($template, array $data = array(), $filter = null)
|
38 |
{
|
@@ -63,7 +63,7 @@ class SocialSharing_Core_BaseController extends Rsc_Mvc_Controller
|
|
63 |
|
64 |
$data = $dispatcher->apply($filter, array($data));
|
65 |
|
66 |
-
if ($template !==
|
67 |
try {
|
68 |
$twig = $this->getEnvironment()->getTwig();
|
69 |
$content = $twig->render($template, $data);
|
@@ -74,7 +74,7 @@ class SocialSharing_Core_BaseController extends Rsc_Mvc_Controller
|
|
74 |
wp_send_json($data);
|
75 |
}
|
76 |
|
77 |
-
return
|
78 |
}
|
79 |
|
80 |
/**
|
@@ -106,7 +106,7 @@ class SocialSharing_Core_BaseController extends Rsc_Mvc_Controller
|
|
106 |
public function ajaxSuccess(array $data = array())
|
107 |
{
|
108 |
return $this->response(
|
109 |
-
|
110 |
array_merge(array('success' => true), $data)
|
111 |
);
|
112 |
}
|
@@ -114,7 +114,7 @@ class SocialSharing_Core_BaseController extends Rsc_Mvc_Controller
|
|
114 |
public function ajaxError($message, array $data = array())
|
115 |
{
|
116 |
return $this->response(
|
117 |
-
|
118 |
array_merge(array('success' => false, 'message' => $message), $data)
|
119 |
);
|
120 |
}
|
@@ -132,7 +132,7 @@ class SocialSharing_Core_BaseController extends Rsc_Mvc_Controller
|
|
132 |
if (!empty($request->query->get('nonce'))) {
|
133 |
$nonce = $request->query->get('nonce');
|
134 |
}
|
135 |
-
if ( !empty($nonce) && wp_verify_nonce($nonce, '
|
136 |
return true;
|
137 |
}
|
138 |
return false;
|
@@ -151,7 +151,7 @@ class SocialSharing_Core_BaseController extends Rsc_Mvc_Controller
|
|
151 |
if (!empty($request->query->get('nonce'))) {
|
152 |
$nonce = $request->query->get('nonce');
|
153 |
}
|
154 |
-
if ( !empty($nonce) && wp_verify_nonce( $nonce, '
|
155 |
return true;
|
156 |
}
|
157 |
return false;
|
3 |
/**
|
4 |
* Class SocialSharing_Core_BaseController
|
5 |
*/
|
6 |
+
class SocialSharing_Core_BaseController extends RscSss_Mvc_Controller
|
7 |
{
|
8 |
/**
|
9 |
* @var SocialSharing_Core_ModelsFactory
|
14 |
* {@inheritdoc}
|
15 |
*/
|
16 |
public function __construct(
|
17 |
+
RscSss_Environment $environment,
|
18 |
+
RscSss_Http_Request $request
|
19 |
) {
|
20 |
parent::__construct(
|
21 |
$environment,
|
32 |
* @param string $template The name of the template
|
33 |
* @param array $data An associative array of the data
|
34 |
* @param string $filter Filter name
|
35 |
+
* @return RscSss_Http_Response
|
36 |
*/
|
37 |
public function response($template, array $data = array(), $filter = null)
|
38 |
{
|
63 |
|
64 |
$data = $dispatcher->apply($filter, array($data));
|
65 |
|
66 |
+
if ($template !== RscSss_Http_Response::AJAX) {
|
67 |
try {
|
68 |
$twig = $this->getEnvironment()->getTwig();
|
69 |
$content = $twig->render($template, $data);
|
74 |
wp_send_json($data);
|
75 |
}
|
76 |
|
77 |
+
return RscSss_Http_Response::create()->setContent($content);
|
78 |
}
|
79 |
|
80 |
/**
|
106 |
public function ajaxSuccess(array $data = array())
|
107 |
{
|
108 |
return $this->response(
|
109 |
+
RscSss_Http_Response::AJAX,
|
110 |
array_merge(array('success' => true), $data)
|
111 |
);
|
112 |
}
|
114 |
public function ajaxError($message, array $data = array())
|
115 |
{
|
116 |
return $this->response(
|
117 |
+
RscSss_Http_Response::AJAX,
|
118 |
array_merge(array('success' => false, 'message' => $message), $data)
|
119 |
);
|
120 |
}
|
132 |
if (!empty($request->query->get('nonce'))) {
|
133 |
$nonce = $request->query->get('nonce');
|
134 |
}
|
135 |
+
if ( !empty($nonce) && wp_verify_nonce($nonce, 'sss_nonce') && is_admin() && current_user_can('administrator') ) {
|
136 |
return true;
|
137 |
}
|
138 |
return false;
|
151 |
if (!empty($request->query->get('nonce'))) {
|
152 |
$nonce = $request->query->get('nonce');
|
153 |
}
|
154 |
+
if ( !empty($nonce) && wp_verify_nonce( $nonce, 'sss_nonce_frontend') ) {
|
155 |
return true;
|
156 |
}
|
157 |
return false;
|
src/SocialSharing/Core/BaseModel.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
abstract class SocialSharing_Core_BaseModel extends
|
5 |
{
|
6 |
/**
|
7 |
-
* @var
|
8 |
*/
|
9 |
protected $environment;
|
10 |
|
11 |
/**
|
12 |
* Sets the environment.
|
13 |
-
* @param
|
14 |
*/
|
15 |
-
public function setEnvironment(
|
16 |
{
|
17 |
$this->environment = $environment;
|
18 |
}
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
abstract class SocialSharing_Core_BaseModel extends RscSss_Mvc_Model implements RscSss_Environment_AwareInterface
|
5 |
{
|
6 |
/**
|
7 |
+
* @var RscSss_Environment
|
8 |
*/
|
9 |
protected $environment;
|
10 |
|
11 |
/**
|
12 |
* Sets the environment.
|
13 |
+
* @param RscSss_Environment $environment
|
14 |
*/
|
15 |
+
public function setEnvironment(RscSss_Environment $environment)
|
16 |
{
|
17 |
$this->environment = $environment;
|
18 |
}
|
src/SocialSharing/Core/BaseModule.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class SocialSharing_Core_BaseModule extends
|
5 |
{
|
6 |
/**
|
7 |
* @return SocialSharing_Core_ModelsFactory
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class SocialSharing_Core_BaseModule extends RscSss_Mvc_Module
|
5 |
{
|
6 |
/**
|
7 |
* @return SocialSharing_Core_ModelsFactory
|
src/SocialSharing/Core/ModelsFactory.php
CHANGED
@@ -12,15 +12,15 @@ class SocialSharing_Core_ModelsFactory
|
|
12 |
protected $models;
|
13 |
|
14 |
/**
|
15 |
-
* @var
|
16 |
*/
|
17 |
protected $environment;
|
18 |
|
19 |
/**
|
20 |
* Constructor
|
21 |
-
* @param
|
22 |
*/
|
23 |
-
public function __construct(
|
24 |
{
|
25 |
$this->models = array();
|
26 |
$this->environment = $environment;
|
@@ -67,7 +67,7 @@ class SocialSharing_Core_ModelsFactory
|
|
67 |
}
|
68 |
|
69 |
$model = new $className;
|
70 |
-
if ($model instanceof
|
71 |
$model->setEnvironment($this->environment);
|
72 |
}
|
73 |
|
12 |
protected $models;
|
13 |
|
14 |
/**
|
15 |
+
* @var RscSss_Environment
|
16 |
*/
|
17 |
protected $environment;
|
18 |
|
19 |
/**
|
20 |
* Constructor
|
21 |
+
* @param RscSss_Environment $environment
|
22 |
*/
|
23 |
+
public function __construct(RscSss_Environment $environment)
|
24 |
{
|
25 |
$this->models = array();
|
26 |
$this->environment = $environment;
|
67 |
}
|
68 |
|
69 |
$model = new $className;
|
70 |
+
if ($model instanceof RscSss_Environment_AwareInterface) {
|
71 |
$model->setEnvironment($this->environment);
|
72 |
}
|
73 |
|
src/SocialSharing/Core/Module.php
CHANGED
@@ -65,33 +65,66 @@ class SocialSharing_Core_Module extends SocialSharing_Core_BaseModule
|
|
65 |
private function registerTwigFunctions()
|
66 |
{
|
67 |
$twig = $this->getEnvironment()->getTwig();
|
68 |
-
|
69 |
$twig->addFunction(
|
70 |
-
new
|
71 |
'plugin_directory_url',
|
72 |
array($this, 'getPluginDirectoryUrl')
|
73 |
)
|
74 |
);
|
75 |
-
|
76 |
$twig->addFunction(
|
77 |
-
new
|
78 |
'get_posts',
|
79 |
'get_posts'
|
80 |
)
|
81 |
);
|
82 |
-
|
83 |
$twig->addFunction(
|
84 |
-
new
|
85 |
'ucfirst',
|
86 |
'ucfirst'
|
87 |
)
|
88 |
);
|
89 |
-
|
90 |
$twig->addFunction(
|
91 |
-
new
|
92 |
'wp_get_attachment_image_url',
|
93 |
'wp_get_attachment_image_url'
|
94 |
)
|
95 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
97 |
}
|
65 |
private function registerTwigFunctions()
|
66 |
{
|
67 |
$twig = $this->getEnvironment()->getTwig();
|
|
|
68 |
$twig->addFunction(
|
69 |
+
new Twig_SupTwgSss_SimpleFunction(
|
70 |
'plugin_directory_url',
|
71 |
array($this, 'getPluginDirectoryUrl')
|
72 |
)
|
73 |
);
|
|
|
74 |
$twig->addFunction(
|
75 |
+
new Twig_SupTwgSss_SimpleFunction(
|
76 |
'get_posts',
|
77 |
'get_posts'
|
78 |
)
|
79 |
);
|
|
|
80 |
$twig->addFunction(
|
81 |
+
new Twig_SupTwgSss_SimpleFunction(
|
82 |
'ucfirst',
|
83 |
'ucfirst'
|
84 |
)
|
85 |
);
|
|
|
86 |
$twig->addFunction(
|
87 |
+
new Twig_SupTwgSss_SimpleFunction(
|
88 |
'wp_get_attachment_image_url',
|
89 |
'wp_get_attachment_image_url'
|
90 |
)
|
91 |
);
|
92 |
+
$twig->addFunction(
|
93 |
+
new Twig_SupTwgSss_SimpleFunction(
|
94 |
+
'translate', array($this, 'translate')
|
95 |
+
)
|
96 |
+
);
|
97 |
+
$twig->addFunction(
|
98 |
+
new Twig_SupTwgSss_SimpleFunction(
|
99 |
+
'getProUrl', array($this, 'getProUrl')
|
100 |
+
)
|
101 |
+
);
|
102 |
+
$config = $this->getEnvironment()->getConfig();
|
103 |
+
$twig->addGlobal('SSS_PLUGIN_URL', SSS_PLUGIN_URL);
|
104 |
+
$twig->addGlobal('SSS_PLUGIN_VERSION', $config->get('plugin_version'));
|
105 |
+
$twig->addGlobal('SSS_PLUGIN_NAME', $config->get('plugin_name'));
|
106 |
+
global $current_user;
|
107 |
+
$twig->addGlobal('SSS_USER_NAME', $current_user->user_firstname.' '.$current_user->user_lastname);
|
108 |
+
$twig->addGlobal('SSS_USER_EMAIL', $current_user->user_email);
|
109 |
+
$twig->addGlobal('SSS_WEBSITE', get_bloginfo('url'));
|
110 |
+
$show = true;
|
111 |
+
$acRemind = get_option('sss_ac_remind', false);
|
112 |
+
if (!empty($acRemind)) {
|
113 |
+
$currentDate = date('Y-m-d h:i:s');
|
114 |
+
if ($currentDate > $acRemind) {
|
115 |
+
$show = true;
|
116 |
+
} else {
|
117 |
+
$show = false;
|
118 |
+
}
|
119 |
+
}
|
120 |
+
$acSubscribe = get_option('sss_ac_subscribe', false);
|
121 |
+
if (!empty($acSubscribe)) {
|
122 |
+
$show = false;
|
123 |
+
}
|
124 |
+
$acDisabled = get_option('sss_ac_disabled', false);
|
125 |
+
if (!empty($acDisabled)) {
|
126 |
+
$show = false;
|
127 |
+
}
|
128 |
+
$twig->addGlobal('SSS_AC_SHOW', $show);
|
129 |
}
|
130 |
}
|
src/SocialSharing/Core/assets/js/core.js
CHANGED
@@ -23,7 +23,7 @@
|
|
23 |
}
|
24 |
|
25 |
data.action = 'social-sharing';
|
26 |
-
data.nonce =
|
27 |
|
28 |
var request = $.post(window.ajaxurl, $.extend({}, { route: route }, data)),
|
29 |
deferred = $.Deferred();
|
23 |
}
|
24 |
|
25 |
data.action = 'social-sharing';
|
26 |
+
data.nonce = sss_nonce;
|
27 |
|
28 |
var request = $.post(window.ajaxurl, $.extend({}, { route: route }, data)),
|
29 |
deferred = $.Deferred();
|
src/SocialSharing/Featuredplugins/Controller.php
DELETED
@@ -1,51 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class SocialSharing_Featuredplugins_Controller
|
5 |
-
* Featuredplugins page controller
|
6 |
-
*
|
7 |
-
* @package SocialSharing\Featuredplugins
|
8 |
-
*/
|
9 |
-
class SocialSharing_Featuredplugins_Controller extends SocialSharing_Core_BaseController
|
10 |
-
{
|
11 |
-
/**
|
12 |
-
* @param Rsc_Http_Request $request
|
13 |
-
*/
|
14 |
-
public function indexAction(Rsc_Http_Request $request)
|
15 |
-
{
|
16 |
-
$environment = $this->getEnvironment();
|
17 |
-
|
18 |
-
|
19 |
-
$pluginsUrl = 'https://supsystic.com/plugins/';
|
20 |
-
$uploadsUrl = SSS_PLUGIN_URL.'src/SocialSharing/Featuredplugins/assets/img/';
|
21 |
-
$downloadsUrl = 'https://downloads.wordpress.org/plugin/';
|
22 |
-
$promoCampaign = 'socialbuttons';
|
23 |
-
$pluginsList = array(
|
24 |
-
array('label' => $environment->translate('Popup Plugin'), 'url' => $pluginsUrl. 'popup-plugin/', 'img' => $uploadsUrl. 'Popup_256.png', 'desc' => $environment->translate('The Best WordPress PopUp option plugin to help you gain more subscribers, social followers or advertisement. Responsive pop-ups with friendly options.'), 'download' => $downloadsUrl. 'popup-by-supsystic.zip'),
|
25 |
-
array('label' => $environment->translate('Slider Plugin'), 'url' => $pluginsUrl. 'slider/', 'img' => $uploadsUrl. 'Slider_256.png', 'desc' => $environment->translate('Creating slideshows with Slider plugin is fast and easy. Simply select images from your WordPress Media Library, Flickr, Instagram or Facebook, set slide captions, links and SEO fields all from one page.'), 'download' => $downloadsUrl. 'slider-by-supsystic.zip'),
|
26 |
-
array('label' => $environment->translate('Photo Gallery Plugin'), 'url' => $pluginsUrl. 'photo-gallery/', 'img' => $uploadsUrl. 'Gallery_256.png', 'desc' => $environment->translate('Photo Gallery Plugin with a great number of layouts will help you to create quality respectable portfolios and image galleries.'), 'download' => $downloadsUrl. 'gallery-by-supsystic.zip'),
|
27 |
-
array('label' => $environment->translate('Data Tables Generator'), 'url' => $pluginsUrl. 'data-tables-generator-plugin/', 'img' => $uploadsUrl. 'Data_Tables_256.png', 'desc' => $environment->translate('Create and manage beautiful data tables with custom design. No HTML knowledge is required.'), 'download' => $downloadsUrl. 'data-tables-generator-by-supsystic.zip'),
|
28 |
-
array('label' => $environment->translate('Social Share Buttons'), 'url' => $pluginsUrl. 'social-share-plugin/', 'img' => $uploadsUrl. 'Social_Buttons_256.png', 'desc' => $environment->translate('Social share buttons to increase social traffic and popularity. Social sharing to Facebook, Twitter and other social networks.'), 'download' => $downloadsUrl. 'social-share-buttons-by-supsystic.zip'),
|
29 |
-
array('label' => $environment->translate('Live Chat Plugin'), 'url' => $pluginsUrl. 'live-chat/', 'img' => $uploadsUrl. 'Live_Chat_256.png', 'desc' => $environment->translate('Be closer to your visitors and customers with Live Chat Support by Supsystic. Help you visitors, support them in real-time with exceptional Live Chat WordPress plugin by Supsystic.'), 'download' => $downloadsUrl. 'live-chat-by-supsystic.zip'),
|
30 |
-
array('label' => $environment->translate('Pricing Table'), 'url' => $pluginsUrl. 'pricing-table/', 'img' => $uploadsUrl. 'Pricing_Table_256.png', 'desc' => $environment->translate('It’s never been so easy to create and manage pricing and comparison tables with table builder. Any element of the table can be customise with mouse click.'), 'download' => $downloadsUrl. 'pricing-table-by-supsystic.zip'),
|
31 |
-
array('label' => $environment->translate('Coming Soon Plugin'), 'url' => $pluginsUrl. 'coming-soon-plugin/', 'img' => $uploadsUrl. 'Coming_Soon_256.png', 'desc' => $environment->translate('Coming soon page with drag-and-drop builder or under construction | maintenance mode to notify visitors and collects emails.'), 'download' => $downloadsUrl. 'coming-soon-by-supsystic.zip'),
|
32 |
-
array('label' => $environment->translate('Backup Plugin'), 'url' => $pluginsUrl. 'backup-plugin/', 'img' => $uploadsUrl. 'Backup_256.png', 'desc' => $environment->translate('Backup and Restore WordPress Plugin by Supsystic provides quick and unhitched DropBox, FTP, Amazon S3, Google Drive backup for your WordPress website.'), 'download' => $downloadsUrl. 'backup-by-supsystic.zip'),
|
33 |
-
array('label' => $environment->translate('Google Maps Easy'), 'url' => $pluginsUrl. 'google-maps-plugin/', 'img' => $uploadsUrl. 'Google_Maps_256.png', 'desc' => $environment->translate('Display custom Google Maps. Set markers and locations with text, images, categories and links. Customize google map in a simple and intuitive way.'), 'download' => $downloadsUrl. 'google-maps-easy.zip'),
|
34 |
-
array('label' => $environment->translate('Digital Publication Plugin'), 'url' => $pluginsUrl. 'digital-publication-plugin/', 'img' => $uploadsUrl. 'Digital_Publication_256.png', 'desc' => $environment->translate('Digital Publication WordPress Plugin by Supsystic for Magazines, Catalogs, Portfolios. Convert images, posts, PDF to the page flip book.'), 'download' => $downloadsUrl. 'digital-publications-by-supsystic.zip'),
|
35 |
-
array('label' => $environment->translate('Contact Form Plugin'), 'url' => $pluginsUrl. 'contact-form-plugin/', 'img' => $uploadsUrl. 'Contact_Form_256.png', 'desc' => $environment->translate('One of the best plugin for creating Contact Forms on your WordPress site. Changeable fonts, backgrounds, an option for adding fields etc.'), 'download' => $downloadsUrl. 'contact-form-by-supsystic.zip'),
|
36 |
-
);
|
37 |
-
foreach($pluginsList as $i => $p) {
|
38 |
-
if(empty($p['external'])) {
|
39 |
-
$pluginsList[$i]['url'] = $pluginsList[$i]['url'] . '?utm_source=plugin&utm_medium=featured_plugins&utm_campaign=' . $promoCampaign;
|
40 |
-
}
|
41 |
-
}
|
42 |
-
|
43 |
-
return $this->response(
|
44 |
-
'@featuredplugins/index.twig',
|
45 |
-
array(
|
46 |
-
'pluginsList' => $pluginsList,
|
47 |
-
'bundleUrl' => 'https://supsystic.com/product/plugins-bundle/'. '?utm_source=plugin&utm_medium=featured_plugins&utm_campaign='. $promoCampaign,
|
48 |
-
)
|
49 |
-
);
|
50 |
-
}
|
51 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/SocialSharing/Featuredplugins/Module.php
DELETED
@@ -1,57 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
class SocialSharing_Featuredplugins_Module extends SocialSharing_Core_BaseModule
|
5 |
-
{
|
6 |
-
|
7 |
-
/**
|
8 |
-
* {@inheritdoc}
|
9 |
-
*/
|
10 |
-
public function onInit()
|
11 |
-
{
|
12 |
-
$environment = $this->getEnvironment();
|
13 |
-
$config = $environment->getConfig();
|
14 |
-
|
15 |
-
$this->registerMenu();
|
16 |
-
|
17 |
-
$prefix = $config->get('hooks_prefix');
|
18 |
-
|
19 |
-
add_action($prefix . 'after_ui_loaded', array(
|
20 |
-
$this, 'loadAssets'
|
21 |
-
));
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Loads the assets required by the module
|
26 |
-
*/
|
27 |
-
public function loadAssets(SocialSharing_Ui_Module $ui)
|
28 |
-
{
|
29 |
-
if($this->getEnvironment()->isModule('featuredplugins')) {
|
30 |
-
$ui->addAsset(
|
31 |
-
$ui->create('style', 'sss-featured-plugins')
|
32 |
-
->setModuleSource($this, 'css/admin.featured-plugins.css')
|
33 |
-
->setHookName('admin_enqueue_scripts')
|
34 |
-
);
|
35 |
-
}
|
36 |
-
}
|
37 |
-
|
38 |
-
public function registerMenu()
|
39 |
-
{
|
40 |
-
$menu = $this->getMenu();
|
41 |
-
$plugin_menu = $this->getConfig()->get('plugin_menu');
|
42 |
-
$capability = $plugin_menu['capability'];
|
43 |
-
$submenu = $menu->createSubmenuItem();
|
44 |
-
|
45 |
-
$submenu->setCapability($capability)
|
46 |
-
->setMenuSlug('supsystic-social-sharing&module=featuredplugins')
|
47 |
-
->setMenuTitle($this->translate('Featured Plugins'))
|
48 |
-
->setPageTitle($this->translate('Featured Plugins'))
|
49 |
-
->setModuleName('featuredplugins');
|
50 |
-
// Avoid conflicts with old vendor version
|
51 |
-
if(method_exists($submenu, 'setSortOrder')) {
|
52 |
-
$submenu->setSortOrder(99);
|
53 |
-
}
|
54 |
-
|
55 |
-
$menu->addSubmenuItem('featuredplugins', $submenu);
|
56 |
-
}
|
57 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/SocialSharing/Featuredplugins/assets/css/admin.featured-plugins.css
DELETED
@@ -1,291 +0,0 @@
|
|
1 |
-
#supsystic-featured-plugins, #supsystic-featured-plugins * {
|
2 |
-
-webkit-box-sizing: border-box;
|
3 |
-
-moz-box-sizing: border-box;
|
4 |
-
box-sizing: border-box;
|
5 |
-
}
|
6 |
-
#supsystic-featured-plugins {
|
7 |
-
font-family: Montserrat, Hind-Regular, sans-serif;
|
8 |
-
font-style: normal;
|
9 |
-
font-weight: 400;
|
10 |
-
font-size: 14px;
|
11 |
-
line-height: 25px;
|
12 |
-
background-color: #ffffff;
|
13 |
-
color: #4D4C4C;
|
14 |
-
}
|
15 |
-
#supsystic-featured-plugins a {
|
16 |
-
text-decoration: none !important;
|
17 |
-
margin-top: 0!important;
|
18 |
-
margin-bottom: 0!important;
|
19 |
-
margin-right: 0!important;
|
20 |
-
letter-spacing: normal!important;
|
21 |
-
}
|
22 |
-
#supsystic-featured-plugins a.btn-center {
|
23 |
-
margin:0px auto !important;
|
24 |
-
}
|
25 |
-
.catitem .download-product-item .dp-title a {
|
26 |
-
display: inline-block;
|
27 |
-
width: 100%;
|
28 |
-
text-overflow: ellipsis;
|
29 |
-
overflow: hidden;
|
30 |
-
white-space: nowrap;
|
31 |
-
font-size: 24px;
|
32 |
-
font-style: normal;
|
33 |
-
text-align: center;
|
34 |
-
padding: 8px 20px;
|
35 |
-
background-image: url(img/bg_texture.png);
|
36 |
-
color: #ffffff;
|
37 |
-
text-decoration: none;
|
38 |
-
}
|
39 |
-
.catitem .download-product-item .dp-title a:hover {
|
40 |
-
color: #ffffff;
|
41 |
-
text-decoration: none;
|
42 |
-
}
|
43 |
-
.catitem .download-product-item .dp-excerpt {
|
44 |
-
display: block;
|
45 |
-
height: 210px;
|
46 |
-
min-height: 210px;
|
47 |
-
max-height: 210px;
|
48 |
-
padding: 15px;
|
49 |
-
text-align: center;
|
50 |
-
overflow: hidden;
|
51 |
-
}
|
52 |
-
.catitem .download-product-item .dp-excerpt .dp-excerpt-wrapper {
|
53 |
-
height: 100%;
|
54 |
-
column-width: 210px;
|
55 |
-
-webkit-column-width: 210px;
|
56 |
-
}
|
57 |
-
.catitem .download-product-item .dp-thumb {
|
58 |
-
margin: 30px 0;
|
59 |
-
height: 190px;
|
60 |
-
min-height: 190px;
|
61 |
-
}
|
62 |
-
.catitem .download-product-item .dp-thumb img, .all-plugins-item .dp-thumb img {
|
63 |
-
width: auto;
|
64 |
-
max-height: 100%;
|
65 |
-
margin: 0 auto;
|
66 |
-
}
|
67 |
-
.catitem .download-product-item .dp-excerpt, .catitem .download-product-item .dp-buttons {
|
68 |
-
background: #FAFAFA;
|
69 |
-
}
|
70 |
-
.catitem .download-product-item .dp-buttons {
|
71 |
-
padding-bottom: 20px;
|
72 |
-
}
|
73 |
-
.catitem .download-product-item .dp-buttons a {
|
74 |
-
display: inline-block;
|
75 |
-
width: 40%;
|
76 |
-
padding: 10px 0 !important;
|
77 |
-
margin-left: 6%;
|
78 |
-
}
|
79 |
-
.catitem .download-product-item .dp-buttons a.btn-info {
|
80 |
-
border: none !important;
|
81 |
-
color: #ffffff !important;
|
82 |
-
font-size: 18px !important;
|
83 |
-
padding: 12px 0 !important;
|
84 |
-
}
|
85 |
-
.catitem .download-product-item .dp-buttons a.btn-center {
|
86 |
-
display: block;
|
87 |
-
margin: 0 auto;
|
88 |
-
}
|
89 |
-
.catitem .download-product-item .dp-buttons a.dp-full {
|
90 |
-
border-color: #e8eded!important;
|
91 |
-
}
|
92 |
-
.catitem .download-product-item {
|
93 |
-
font-size: 16px;
|
94 |
-
border: 2px solid #4D4C4C;
|
95 |
-
}
|
96 |
-
.catitem .bottom-buttons a, .catitem .free-product-item p {
|
97 |
-
font-weight: 400;
|
98 |
-
}
|
99 |
-
.select_version .selecter-item:hover {
|
100 |
-
background: #4ae8ea;
|
101 |
-
color: #fff;
|
102 |
-
}
|
103 |
-
.selecter.open {
|
104 |
-
z-index: 99999999!important;
|
105 |
-
}
|
106 |
-
.catitem {
|
107 |
-
display: block;
|
108 |
-
margin-bottom: 30px;
|
109 |
-
}
|
110 |
-
.catitem .free-label, .catitem .psd-label, .catitem .responsive-label {
|
111 |
-
margin-bottom: 5px;
|
112 |
-
display: inline-block;
|
113 |
-
}
|
114 |
-
.catitem .labels {
|
115 |
-
position: absolute;
|
116 |
-
top: 10px;
|
117 |
-
right: 5px;
|
118 |
-
width: 25px;
|
119 |
-
z-index: 0;
|
120 |
-
}
|
121 |
-
.catitem .responsive-label {
|
122 |
-
width: 21px;
|
123 |
-
height: 14px;
|
124 |
-
background: url(img/pattern.png) -130px -32px no-repeat;
|
125 |
-
}
|
126 |
-
.catitem .free-label {
|
127 |
-
width: 17px;
|
128 |
-
height: 17px;
|
129 |
-
background: url(img/pattern.png) -135px -47px no-repeat;
|
130 |
-
}
|
131 |
-
.catitem .psd-label {
|
132 |
-
width: 22px;
|
133 |
-
height: 8px;
|
134 |
-
background: url(img/pattern.png) -80px -32px no-repeat;
|
135 |
-
}
|
136 |
-
.catitem .zoom-label {
|
137 |
-
width: 13px;
|
138 |
-
height: 13px;
|
139 |
-
display: inline-block;
|
140 |
-
background: url(img/pattern.png) -115px -32px no-repeat;
|
141 |
-
position: absolute;
|
142 |
-
right: 11px;
|
143 |
-
bottom: 10px;
|
144 |
-
}
|
145 |
-
.catitem .fpi {
|
146 |
-
border: 1px solid #e8eded;
|
147 |
-
display: inline-block;
|
148 |
-
position: relative;
|
149 |
-
z-index: 10;
|
150 |
-
margin-bottom: 15px;
|
151 |
-
}
|
152 |
-
.catitem .free-product-item {
|
153 |
-
display: inline-block;
|
154 |
-
}
|
155 |
-
.catitem .free-product-item p {
|
156 |
-
font-size: 16px;
|
157 |
-
font-style: normal;
|
158 |
-
display: inline-block;
|
159 |
-
}
|
160 |
-
.catitem .free-product-item .fpi {
|
161 |
-
transition: all .3s;
|
162 |
-
-moz-transition: all .3s;
|
163 |
-
-webkit-transition: all .3s;
|
164 |
-
-o-transition: all .3s;
|
165 |
-
}
|
166 |
-
.catitem .free-product-item .fpi.hover {
|
167 |
-
background: #4ae8ea;
|
168 |
-
}
|
169 |
-
.catitem .fpi img {
|
170 |
-
border: 3px solid rgba(215, 219, 219, .4);
|
171 |
-
margin: -13px 0 0 -35px;
|
172 |
-
}
|
173 |
-
.catitem .bottom-buttons a {
|
174 |
-
color: #4D4C4C;
|
175 |
-
text-align: center;
|
176 |
-
display: block;
|
177 |
-
padding: 5px 35px 5px 5px;
|
178 |
-
font-size: 18px;
|
179 |
-
font-style: normal;
|
180 |
-
}
|
181 |
-
.btn, .btn-download, .btn-preview, .btn-pro, .btn-extension, .btn-black {
|
182 |
-
font-size: 18px!important;
|
183 |
-
font-weight: 400!important;
|
184 |
-
font-style: normal!important;
|
185 |
-
}
|
186 |
-
.supsystic-plugin #supsystic-featured-plugins .btn {
|
187 |
-
color: #4D4C4C;
|
188 |
-
/*-webkit-transition-timing-function: initial;
|
189 |
-
transition-timing-function: initial;*/
|
190 |
-
}
|
191 |
-
.btn {
|
192 |
-
background: transparent;
|
193 |
-
color: #4D4C4C;
|
194 |
-
text-align: center;
|
195 |
-
border: 2px solid #4D4C4C !important;
|
196 |
-
border-radius: 0!important;
|
197 |
-
-moz-border-radius: 0!important;
|
198 |
-
-webkit-border-radius: 0!important;
|
199 |
-
padding: 17px 45px !important;
|
200 |
-
}
|
201 |
-
.btn-full {
|
202 |
-
width: 100%;
|
203 |
-
}
|
204 |
-
.btn-info {
|
205 |
-
padding: 12px 38px !important;
|
206 |
-
background-color: #4ae8ea !important;
|
207 |
-
border: none !important;
|
208 |
-
color: #ffffff !important;
|
209 |
-
font-size: 18px !important;
|
210 |
-
}
|
211 |
-
.btn-revert {
|
212 |
-
color: #ffffff !important;
|
213 |
-
border-color: #ffffff !important;
|
214 |
-
}
|
215 |
-
/* Shutter Out Horizontal Start */
|
216 |
-
.hvr-shutter-out-horizontal {
|
217 |
-
display: inline-block;
|
218 |
-
vertical-align: middle;
|
219 |
-
-webkit-transform: translateZ(0);
|
220 |
-
transform: translateZ(0);
|
221 |
-
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
|
222 |
-
/*-webkit-backface-visibility: hidden;
|
223 |
-
backface-visibility: hidden;*/
|
224 |
-
-moz-osx-font-smoothing: grayscale;
|
225 |
-
position: relative;
|
226 |
-
/*background: #e1e1e1;*/
|
227 |
-
-webkit-transition-property: color;
|
228 |
-
transition-property: color;
|
229 |
-
-webkit-transition-duration: 0.3s;
|
230 |
-
transition-duration: 0.3s;
|
231 |
-
}
|
232 |
-
.hvr-shutter-out-horizontal:before {
|
233 |
-
content: "";
|
234 |
-
position: absolute !important;
|
235 |
-
z-index: -1;
|
236 |
-
top: 0;
|
237 |
-
bottom: 0;
|
238 |
-
left: 0;
|
239 |
-
right: 0;
|
240 |
-
background: #2098d1;
|
241 |
-
-webkit-transform: scaleX(0);
|
242 |
-
transform: scaleX(0);
|
243 |
-
-webkit-transform-origin: 50%;
|
244 |
-
transform-origin: 50%;
|
245 |
-
-webkit-transition-property: transform;
|
246 |
-
transition-property: transform;
|
247 |
-
-webkit-transition-duration: 0.3s;
|
248 |
-
transition-duration: 0.3s;
|
249 |
-
-webkit-transition-timing-function: ease-out;
|
250 |
-
transition-timing-function: ease-out;
|
251 |
-
}
|
252 |
-
.hvr-shutter-out-horizontal:hover, .hvr-shutter-out-horizontal:focus, .hvr-shutter-out-horizontal:active {
|
253 |
-
color: white !important;
|
254 |
-
}
|
255 |
-
.hvr-shutter-out-horizontal:hover:before, .hvr-shutter-out-horizontal:focus:before, .hvr-shutter-out-horizontal:active:before {
|
256 |
-
-webkit-transform: scaleX(1);
|
257 |
-
transform: scaleX(1);
|
258 |
-
}
|
259 |
-
/* For blog navigation */
|
260 |
-
.meta-nav.hvr-shutter-out-horizontal:before, .supsystic-social-button.hvr-shutter-out-horizontal:before {
|
261 |
-
border-radius: 100%;
|
262 |
-
}
|
263 |
-
/* Shutter Out Horizontal End */
|
264 |
-
/* Page Bundle Container Styles Start */
|
265 |
-
.supsysticPageBundleContainer {
|
266 |
-
background-color: #56DADC;
|
267 |
-
padding-top: 28px;
|
268 |
-
padding-bottom: 28px;
|
269 |
-
display: table;
|
270 |
-
width: 100%;
|
271 |
-
}
|
272 |
-
.supsysticPageBundleContainer .bundle-text {
|
273 |
-
padding-top: 5px;
|
274 |
-
font-size: 25px;
|
275 |
-
color: #ffffff;
|
276 |
-
}
|
277 |
-
.supsysticPageBundleContainer .bundle-btn a {
|
278 |
-
font-size: 15px !important;
|
279 |
-
padding: 5px 38px !important;
|
280 |
-
margin: 0!important;
|
281 |
-
letter-spacing: normal!important;
|
282 |
-
}
|
283 |
-
/*.supsysticPageBundleContainer .container {
|
284 |
-
width: 100% !important;
|
285 |
-
}*/
|
286 |
-
@media only screen and (max-width:991px) {
|
287 |
-
.supsysticPageBundleContainer .bundle-btn {
|
288 |
-
margin-top: 20px;
|
289 |
-
}
|
290 |
-
}
|
291 |
-
/* Page Bundle Container Styles End */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/SocialSharing/Featuredplugins/assets/css/img/bg_texture.png
DELETED
Binary file
|
src/SocialSharing/Featuredplugins/assets/img/256.png
DELETED
Binary file
|
src/SocialSharing/Featuredplugins/assets/img/Backup_256.png
DELETED
Binary file
|
src/SocialSharing/Featuredplugins/assets/img/Coming_Soon_256.png
DELETED
Binary file
|
src/SocialSharing/Featuredplugins/assets/img/Contact_Form_256.png
DELETED
Binary file
|
src/SocialSharing/Featuredplugins/assets/img/Data_Tables_256.png
DELETED
Binary file
|
src/SocialSharing/Featuredplugins/assets/img/Digital_Publication_256.png
DELETED
Binary file
|
src/SocialSharing/Featuredplugins/assets/img/Gallery_256.png
DELETED
Binary file
|
src/SocialSharing/Featuredplugins/assets/img/Google_Maps_256.png
DELETED
Binary file
|
src/SocialSharing/Featuredplugins/assets/img/Live_Chat_256.png
DELETED
Binary file
|
src/SocialSharing/Featuredplugins/assets/img/Popup_256.png
DELETED
Binary file
|
src/SocialSharing/Featuredplugins/assets/img/Pricing_Table_256.png
DELETED
Binary file
|
src/SocialSharing/Featuredplugins/assets/img/Slider_256.png
DELETED
Binary file
|
src/SocialSharing/Featuredplugins/assets/img/Social_Buttons_256.png
DELETED
Binary file
|
src/SocialSharing/Featuredplugins/assets/img/heatmap.jpg
DELETED
Binary file
|
src/SocialSharing/Featuredplugins/assets/img/icon-256x256.png
DELETED
Binary file
|
src/SocialSharing/Featuredplugins/assets/img/kinsta_banner.png
DELETED
Binary file
|
src/SocialSharing/Featuredplugins/assets/img/shapes.jpg
DELETED
Binary file
|
src/SocialSharing/Featuredplugins/views/index.twig
DELETED
@@ -1,46 +0,0 @@
|
|
1 |
-
{% extends 'layout.twig' %}
|
2 |
-
|
3 |
-
{% block content %}
|
4 |
-
<section id="supsystic-featured-plugins">
|
5 |
-
<div class="supsysticPageBundleContainer supContainer-fluid">
|
6 |
-
<div class="bundle-text supMd7 supXs12">{{ environment.translate('Get plugins bundle today and save over 80%', PPS_LANG_CODE) }}</div>
|
7 |
-
<div class="bundle-btn supMd5 supXs12">
|
8 |
-
<a href="{{ bundleUrl }}" class="btn btn-full btn-revert hvr-shutter-out-horizontal" target="_blank">
|
9 |
-
{{ environment.translate('Check It out', PPS_LANG_CODE) }}
|
10 |
-
</a>
|
11 |
-
</div>
|
12 |
-
</div>
|
13 |
-
<hr />
|
14 |
-
{% for p in pluginsList %}
|
15 |
-
<div class="catitem supMd4 supSm6 supXs12">
|
16 |
-
<div class="download-product-item">
|
17 |
-
<div class="dp-thumb text-center">
|
18 |
-
<a href="{{ p.url }}" target="_blank">
|
19 |
-
<img src="{{ p.img }}" class="img-responsive wp-post-image" alt="{{ p.label }}" />
|
20 |
-
</a>
|
21 |
-
</div>
|
22 |
-
<div class="dp-title">
|
23 |
-
<a href="{{ p.url }}" target="_blank">
|
24 |
-
{{ p.label }}
|
25 |
-
</a>
|
26 |
-
</div>
|
27 |
-
<div class="dp-excerpt">
|
28 |
-
<div class="dp-excerpt-wrapper">
|
29 |
-
{{ p.desc }}
|
30 |
-
</div>
|
31 |
-
</div>
|
32 |
-
<div class="dp-buttons">
|
33 |
-
<a href="{{ p.url }}" target="_blank" class="btn btn-full hvr-shutter-out-horizontal {% if p.download is empty %}btn-center{% endif %}">
|
34 |
-
{{ environment.translate('More info') }}
|
35 |
-
</a>
|
36 |
-
{% if p.download is not empty %}
|
37 |
-
<a href="{{ p.download }}" target="_blank" class="btn btn-full btn-info hvr-shutter-out-horizontal">
|
38 |
-
{{ environment.translate('Download') }}
|
39 |
-
</a>
|
40 |
-
{% endif %}
|
41 |
-
</div>
|
42 |
-
</div>
|
43 |
-
</div>
|
44 |
-
{% endfor %}
|
45 |
-
</section>
|
46 |
-
{% endblock %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/SocialSharing/Networks/Controller.php
CHANGED
@@ -7,7 +7,7 @@ class SocialSharing_Networks_Controller extends SocialSharing_Core_BaseControlle
|
|
7 |
{
|
8 |
/**
|
9 |
* Returns list of the all networks.
|
10 |
-
* @return
|
11 |
*/
|
12 |
public function allAction()
|
13 |
{
|
@@ -15,16 +15,16 @@ class SocialSharing_Networks_Controller extends SocialSharing_Core_BaseControlle
|
|
15 |
$networks = $this->modelsFactory->get('networks')->all();
|
16 |
|
17 |
return $this->response(
|
18 |
-
|
19 |
$networks
|
20 |
);
|
21 |
}
|
22 |
|
23 |
/**
|
24 |
* Adds networks to the project
|
25 |
-
* @param
|
26 |
*/
|
27 |
-
public function addToProjectAction(
|
28 |
{
|
29 |
if (!$this->_checkNonce($request)) die();
|
30 |
$networks = $request->post->get('networks');
|
@@ -43,19 +43,19 @@ class SocialSharing_Networks_Controller extends SocialSharing_Core_BaseControlle
|
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
-
* @param
|
47 |
-
* @return
|
48 |
*/
|
49 |
-
public function incrementAction(
|
50 |
{
|
51 |
if (!$this->_checkNonce($request)) die();
|
52 |
$id = $request->post->get('id');
|
53 |
$this->modelsFactory->get('networks')->incrementTotalShares($id);
|
54 |
|
55 |
-
return $this->response(
|
56 |
}
|
57 |
|
58 |
-
public function saveTooltipsAction(
|
59 |
if (!$this->_checkNonce($request)) die();
|
60 |
$projectId = (int)$request->post->get('project_id');
|
61 |
$data = $request->post->get('data', array());
|
@@ -72,7 +72,7 @@ class SocialSharing_Networks_Controller extends SocialSharing_Core_BaseControlle
|
|
72 |
return $this->ajaxSuccess();
|
73 |
}
|
74 |
|
75 |
-
public function saveTitlesAction(
|
76 |
if (!$this->_checkNonce($request)) die();
|
77 |
$projectId = (int)$request->post->get('project_id');
|
78 |
$data = $request->post->get('data', array());
|
@@ -89,7 +89,7 @@ class SocialSharing_Networks_Controller extends SocialSharing_Core_BaseControlle
|
|
89 |
return $this->ajaxSuccess();
|
90 |
}
|
91 |
|
92 |
-
public function saveProfileNameAction(
|
93 |
if (!$this->_checkNonce($request)) die();
|
94 |
$projectId = (int)$request->post->get('project_id');
|
95 |
$data = $request->post->get('data', array());
|
@@ -106,7 +106,7 @@ class SocialSharing_Networks_Controller extends SocialSharing_Core_BaseControlle
|
|
106 |
return $this->ajaxSuccess();
|
107 |
}
|
108 |
|
109 |
-
public function saveIconImageAction(
|
110 |
if (!$this->_checkNonce($request)) die();
|
111 |
$projectId = (int)$request->post->get('project_id');
|
112 |
$data = $request->post->get('data', array());
|
@@ -124,7 +124,7 @@ class SocialSharing_Networks_Controller extends SocialSharing_Core_BaseControlle
|
|
124 |
return $this->ajaxSuccess();
|
125 |
}
|
126 |
|
127 |
-
public function saveTextFormatAction(
|
128 |
if (!$this->_checkNonce($request)) die();
|
129 |
$projectId = (int)$request->post->get('project_id');
|
130 |
$data = $request->post->get('data', array());
|
@@ -141,7 +141,7 @@ class SocialSharing_Networks_Controller extends SocialSharing_Core_BaseControlle
|
|
141 |
return $this->ajaxSuccess();
|
142 |
}
|
143 |
|
144 |
-
public function saveUseShortUrlAction(
|
145 |
if (!$this->_checkNonce($request)) die();
|
146 |
$projectId = (int)$request->post->get('project_id');
|
147 |
$data = $request->post->get('data', array());
|
@@ -158,7 +158,7 @@ class SocialSharing_Networks_Controller extends SocialSharing_Core_BaseControlle
|
|
158 |
return $this->ajaxSuccess();
|
159 |
}
|
160 |
|
161 |
-
public function saveNamesAction(
|
162 |
if (!$this->_checkNonce($request)) die();
|
163 |
$projectId = (int)$request->post->get('project_id');
|
164 |
$data = $request->post->get('data', array());
|
@@ -175,7 +175,7 @@ class SocialSharing_Networks_Controller extends SocialSharing_Core_BaseControlle
|
|
175 |
return $this->ajaxSuccess();
|
176 |
}
|
177 |
|
178 |
-
public function saveMailToDefaultAction(
|
179 |
if (!$this->_checkNonce($request)) die();
|
180 |
$projectId = (int)$request->post->get('project_id');
|
181 |
$data = $request->post->get('data', array());
|
@@ -192,7 +192,7 @@ class SocialSharing_Networks_Controller extends SocialSharing_Core_BaseControlle
|
|
192 |
return $this->ajaxSuccess();
|
193 |
}
|
194 |
|
195 |
-
public function updateSortingAction(
|
196 |
{
|
197 |
if (!$this->_checkNonce($request)) die();
|
198 |
$projectId = $request->post->get('project_id');
|
7 |
{
|
8 |
/**
|
9 |
* Returns list of the all networks.
|
10 |
+
* @return RscSss_Http_Response
|
11 |
*/
|
12 |
public function allAction()
|
13 |
{
|
15 |
$networks = $this->modelsFactory->get('networks')->all();
|
16 |
|
17 |
return $this->response(
|
18 |
+
RscSss_Http_Response::AJAX,
|
19 |
$networks
|
20 |
);
|
21 |
}
|
22 |
|
23 |
/**
|
24 |
* Adds networks to the project
|
25 |
+
* @param RscSss_Http_Request $request
|
26 |
*/
|
27 |
+
public function addToProjectAction(RscSss_Http_Request $request)
|
28 |
{
|
29 |
if (!$this->_checkNonce($request)) die();
|
30 |
$networks = $request->post->get('networks');
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
+
* @param RscSss_Http_Request $request
|
47 |
+
* @return RscSss_Http_Response
|
48 |
*/
|
49 |
+
public function incrementAction(RscSss_Http_Request $request)
|
50 |
{
|
51 |
if (!$this->_checkNonce($request)) die();
|
52 |
$id = $request->post->get('id');
|
53 |
$this->modelsFactory->get('networks')->incrementTotalShares($id);
|
54 |
|
55 |
+
return $this->response(RscSss_Http_Response::AJAX);
|
56 |
}
|
57 |
|
58 |
+
public function saveTooltipsAction(RscSss_Http_Request $request) {
|
59 |
if (!$this->_checkNonce($request)) die();
|
60 |
$projectId = (int)$request->post->get('project_id');
|
61 |
$data = $request->post->get('data', array());
|
72 |
return $this->ajaxSuccess();
|
73 |
}
|
74 |
|
75 |
+
public function saveTitlesAction(RscSss_Http_Request $request) {
|
76 |
if (!$this->_checkNonce($request)) die();
|
77 |
$projectId = (int)$request->post->get('project_id');
|
78 |
$data = $request->post->get('data', array());
|
89 |
return $this->ajaxSuccess();
|
90 |
}
|
91 |
|
92 |
+
public function saveProfileNameAction(RscSss_Http_Request $request) {
|
93 |
if (!$this->_checkNonce($request)) die();
|
94 |
$projectId = (int)$request->post->get('project_id');
|
95 |
$data = $request->post->get('data', array());
|
106 |
return $this->ajaxSuccess();
|
107 |
}
|
108 |
|
109 |
+
public function saveIconImageAction(RscSss_Http_Request $request) {
|
110 |
if (!$this->_checkNonce($request)) die();
|
111 |
$projectId = (int)$request->post->get('project_id');
|
112 |
$data = $request->post->get('data', array());
|
124 |
return $this->ajaxSuccess();
|
125 |
}
|
126 |
|
127 |
+
public function saveTextFormatAction(RscSss_Http_Request $request) {
|
128 |
if (!$this->_checkNonce($request)) die();
|
129 |
$projectId = (int)$request->post->get('project_id');
|
130 |
$data = $request->post->get('data', array());
|
141 |
return $this->ajaxSuccess();
|
142 |
}
|
143 |
|
144 |
+
public function saveUseShortUrlAction(RscSss_Http_Request $request) {
|
145 |
if (!$this->_checkNonce($request)) die();
|
146 |
$projectId = (int)$request->post->get('project_id');
|
147 |
$data = $request->post->get('data', array());
|
158 |
return $this->ajaxSuccess();
|
159 |
}
|
160 |
|
161 |
+
public function saveNamesAction(RscSss_Http_Request $request) {
|
162 |
if (!$this->_checkNonce($request)) die();
|
163 |
$projectId = (int)$request->post->get('project_id');
|
164 |
$data = $request->post->get('data', array());
|
175 |
return $this->ajaxSuccess();
|
176 |
}
|
177 |
|
178 |
+
public function saveMailToDefaultAction(RscSss_Http_Request $request) {
|
179 |
if (!$this->_checkNonce($request)) die();
|
180 |
$projectId = (int)$request->post->get('project_id');
|
181 |
$data = $request->post->get('data', array());
|
192 |
return $this->ajaxSuccess();
|
193 |
}
|
194 |
|
195 |
+
public function updateSortingAction(RscSss_Http_Request $request)
|
196 |
{
|
197 |
if (!$this->_checkNonce($request)) die();
|
198 |
$projectId = $request->post->get('project_id');
|
src/SocialSharing/Overview/Controller.php
CHANGED
@@ -3,8 +3,7 @@
|
|
3 |
|
4 |
class SocialSharing_Overview_Controller extends SocialSharing_Core_BaseController
|
5 |
{
|
6 |
-
|
7 |
-
public function indexAction(Rsc_Http_Request $request)
|
8 |
{
|
9 |
$serverSettings = $this->getServerSettings();
|
10 |
$config = $this->getEnvironment()->getConfig();
|
@@ -22,7 +21,7 @@ class SocialSharing_Overview_Controller extends SocialSharing_Core_BaseControlle
|
|
22 |
);
|
23 |
}
|
24 |
|
25 |
-
public function sendMailAction(
|
26 |
if (!$this->_checkNonce($request)) die();
|
27 |
$mail = $request->post->get('mail');
|
28 |
$headers = 'From: ' . $mail['name'] . ' ' . $mail['email'] . "\r\n" . 'Website: ' . $mail['website'] . "\r\n" . 'Question: ' . $mail['question'] . "\r\n";
|
@@ -32,6 +31,66 @@ class SocialSharing_Overview_Controller extends SocialSharing_Core_BaseControlle
|
|
32 |
|
33 |
return $this->redirect($this->generateUrl('overview', 'index'));
|
34 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
protected function getServerSettings() {
|
37 |
global $wpdb;
|
3 |
|
4 |
class SocialSharing_Overview_Controller extends SocialSharing_Core_BaseController
|
5 |
{
|
6 |
+
public function indexAction(RscSss_Http_Request $request)
|
|
|
7 |
{
|
8 |
$serverSettings = $this->getServerSettings();
|
9 |
$config = $this->getEnvironment()->getConfig();
|
21 |
);
|
22 |
}
|
23 |
|
24 |
+
public function sendMailAction(RscSss_Http_Request $request) {
|
25 |
if (!$this->_checkNonce($request)) die();
|
26 |
$mail = $request->post->get('mail');
|
27 |
$headers = 'From: ' . $mail['name'] . ' ' . $mail['email'] . "\r\n" . 'Website: ' . $mail['website'] . "\r\n" . 'Question: ' . $mail['question'] . "\r\n";
|
31 |
|
32 |
return $this->redirect($this->generateUrl('overview', 'index'));
|
33 |
}
|
34 |
+
/**
|
35 |
+
* @param RscSss_Http_Request $request
|
36 |
+
*/
|
37 |
+
public function sendSubscribeMailAction(RscSss_Http_Request $request)
|
38 |
+
{
|
39 |
+
$apiUrl = 'https://supsystic.com/wp-admin/admin-ajax.php';
|
40 |
+
$reqUrl = $apiUrl . '?action=ac_get_plugin_installed';
|
41 |
+
$config = $this->getEnvironment()->getConfig();
|
42 |
+
$mail = $request->post['route']['data'];
|
43 |
+
$isPro = !empty($config->get('is_pro')) ? true : false;
|
44 |
+
$data = array(
|
45 |
+
'body' => array(
|
46 |
+
'key' => 'kJ#f3(FjkF9fasd124t5t589u9d4389r3r3R#2asdas3(#R03r#(r#t-4t5t589u9d4389r3r3R#$%lfdj',
|
47 |
+
'user_name' => $mail['username'],
|
48 |
+
'user_email' => $mail['email'],
|
49 |
+
'site_url' => get_bloginfo('wpurl'),
|
50 |
+
'site_name' => get_bloginfo('name'),
|
51 |
+
'plugin_code' => $config->get('plugin_name'),
|
52 |
+
'is_pro' => $isPro,
|
53 |
+
),
|
54 |
+
);
|
55 |
+
|
56 |
+
$response = wp_remote_post(
|
57 |
+
$reqUrl,
|
58 |
+
$data
|
59 |
+
);
|
60 |
+
if (is_wp_error($response)) {
|
61 |
+
$response = array(
|
62 |
+
'success' => false,
|
63 |
+
'message' => $this->translate('Some errors.')
|
64 |
+
);
|
65 |
+
} else {
|
66 |
+
$response = array(
|
67 |
+
'success' => true,
|
68 |
+
'message' => $this->translate('Thank you for subscribtions.')
|
69 |
+
);
|
70 |
+
update_option('sss_ac_subscribe', true);
|
71 |
+
}
|
72 |
+
return $this->response(RscSss_Http_Response::AJAX, $response);
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @param RscSss_Http_Request $request
|
77 |
+
*/
|
78 |
+
public function sendSubscribeRemindAction(RscSss_Http_Request $request)
|
79 |
+
{
|
80 |
+
update_option('sss_ac_remind', date("Y-m-d h:i:s", time() + 86400));
|
81 |
+
$response = array ('success' => true);
|
82 |
+
return $this->response(RscSss_Http_Response::AJAX, $response);
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* @param RscSss_Http_Request $request
|
87 |
+
*/
|
88 |
+
public function sendSubscribeDisableAction(RscSss_Http_Request $request)
|
89 |
+
{
|
90 |
+
update_option('sss_ac_disabled', true);
|
91 |
+
$response = array ('success' => true);
|
92 |
+
return $this->response(RscSss_Http_Response::AJAX, $response);
|
93 |
+
}
|
94 |
|
95 |
protected function getServerSettings() {
|
96 |
global $wpdb;
|
src/SocialSharing/Overview/Module.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class SocialSharing_Overview_Module extends
|
5 |
{
|
6 |
/**
|
7 |
* {@inheritdoc}
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class SocialSharing_Overview_Module extends RscSss_Mvc_Module
|
5 |
{
|
6 |
/**
|
7 |
* {@inheritdoc}
|
src/SocialSharing/Overview/assets/css/overview-styles.css
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
.supsystic-overview {
|
2 |
width: 100%;
|
|
|
3 |
float: left;
|
4 |
}
|
5 |
|
@@ -17,10 +18,6 @@
|
|
17 |
width: 40%;
|
18 |
}
|
19 |
|
20 |
-
.supsystic-overview .half-page-right a {
|
21 |
-
color: #4ae8ea;
|
22 |
-
}
|
23 |
-
|
24 |
.supsystic-overview .half-page > div {
|
25 |
border-bottom: 1px solid rgba(164, 170, 172, 0.28);
|
26 |
padding-bottom: 20px;
|
@@ -55,10 +52,14 @@
|
|
55 |
}
|
56 |
|
57 |
.supsystic-overview .button {
|
|
|
58 |
margin-top: 24px;
|
59 |
display: block;
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
62 |
}
|
63 |
|
64 |
.supsystic-overview .settings-title {
|
@@ -101,18 +102,264 @@
|
|
101 |
float: left;
|
102 |
font-size: 18px;
|
103 |
font-weight: 800;
|
|
|
|
|
104 |
}
|
105 |
|
106 |
.supsystic-overview form input,
|
107 |
.supsystic-overview form select,
|
108 |
.supsystic-overview form textarea {
|
109 |
-
|
|
|
|
|
110 |
}
|
111 |
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
}
|
115 |
|
116 |
-
.supsystic-overview-
|
117 |
-
|
118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
.supsystic-overview {
|
2 |
width: 100%;
|
3 |
+
margin-top: 20px;
|
4 |
float: left;
|
5 |
}
|
6 |
|
18 |
width: 40%;
|
19 |
}
|
20 |
|
|
|
|
|
|
|
|
|
21 |
.supsystic-overview .half-page > div {
|
22 |
border-bottom: 1px solid rgba(164, 170, 172, 0.28);
|
23 |
padding-bottom: 20px;
|
52 |
}
|
53 |
|
54 |
.supsystic-overview .button {
|
55 |
+
float: right;
|
56 |
margin-top: 24px;
|
57 |
display: block;
|
58 |
+
}
|
59 |
+
|
60 |
+
.supsystic-overview .faq-list .button.button-primary.button-hero{
|
61 |
+
float: left;
|
62 |
+
margin-left: 10px;
|
63 |
}
|
64 |
|
65 |
.supsystic-overview .settings-title {
|
102 |
float: left;
|
103 |
font-size: 18px;
|
104 |
font-weight: 800;
|
105 |
+
margin-top: 10px;
|
106 |
+
white-space: nowrap;
|
107 |
}
|
108 |
|
109 |
.supsystic-overview form input,
|
110 |
.supsystic-overview form select,
|
111 |
.supsystic-overview form textarea {
|
112 |
+
float: left;
|
113 |
+
margin-left: 50px;
|
114 |
+
width: calc(100% - 50px);
|
115 |
}
|
116 |
|
117 |
+
#contact-form-dialog p {
|
118 |
+
font-size: 15px;
|
119 |
+
}
|
120 |
+
#contact-form-dialog a {
|
121 |
+
color: #4ae8ea;
|
122 |
+
}
|
123 |
+
#contact-form-dialog a:focus {
|
124 |
+
outline: none;
|
125 |
}
|
126 |
|
127 |
+
.supsystic-overview .half-page > div {
|
128 |
+
border-bottom:0px;
|
129 |
+
padding-bottom:inherit;
|
130 |
+
}
|
131 |
+
.overview-section {
|
132 |
+
display:none;
|
133 |
+
}
|
134 |
+
.overview-section-btn {
|
135 |
+
list-style:square;
|
136 |
+
cursor:pointer;
|
137 |
+
margin-left:20px;
|
138 |
+
}
|
139 |
+
.overview-section-btn:hover {
|
140 |
+
color: #4ae8ea;
|
141 |
+
}
|
142 |
+
.border-wrapper {
|
143 |
+
display:block;
|
144 |
+
position:relative;
|
145 |
+
border:1px solid rgba(164, 170, 172, 0.28) !important;
|
146 |
+
padding:30px;
|
147 |
+
padding-top:0px;
|
148 |
+
margin-bottom:20px;
|
149 |
+
border-left: 3px solid #4ae8ea !important;
|
150 |
+
}
|
151 |
+
.border-wrapper .button-hero {
|
152 |
+
margin-bottom:30px;
|
153 |
+
line-height:auto !important;
|
154 |
+
padding:0px 10px !important;
|
155 |
+
margin:10px 4px !important;
|
156 |
+
}
|
157 |
+
.overview-section-btn-active {
|
158 |
+
color: #4ae8ea;
|
159 |
+
font-weight:bold;
|
160 |
+
}
|
161 |
+
.overview-contact-form form {
|
162 |
+
margin:0px !important;
|
163 |
+
padding:0px !important;
|
164 |
+
}
|
165 |
+
.overview-contact-form input,
|
166 |
+
.overview-contact-form select,
|
167 |
+
.overview-contact-form textarea {
|
168 |
+
display:block;
|
169 |
+
position:relative;
|
170 |
+
width:100%;
|
171 |
+
max-width:100% !important;
|
172 |
+
background-color: #f6f7f7;
|
173 |
+
color: #252728;
|
174 |
+
border: 1px solid #dfe4e4;
|
175 |
+
outline:0px;
|
176 |
+
}
|
177 |
+
.overview-contact-form #form-settings {
|
178 |
+
height:auto;
|
179 |
+
}
|
180 |
+
.overview-section-btn a {
|
181 |
+
text-decoration:none;
|
182 |
+
color: #3c434a;
|
183 |
+
}
|
184 |
+
.overview-section-btn a:hover {
|
185 |
+
color: #4ae8ea;
|
186 |
+
}
|
187 |
+
.overview-section h3 {
|
188 |
+
border-bottom:1px solid rgba(164, 170, 172, 0.28) !important;
|
189 |
+
padding-bottom:.5em;
|
190 |
+
margin-bottom:.5em;
|
191 |
+
}
|
192 |
+
.contact-info-section {
|
193 |
+
border: 1px solid rgba(164, 170, 172, 0.28) !important;
|
194 |
+
padding: 5px;
|
195 |
+
}
|
196 |
+
.contact-info-section p {
|
197 |
+
font-size:12px;
|
198 |
+
white-space: inherit;
|
199 |
+
line-height: 18px;
|
200 |
+
}
|
201 |
+
.contact-info-section ul {
|
202 |
+
margin:0px;
|
203 |
+
}
|
204 |
+
.contact-info-section ul li {
|
205 |
+
padding-left:5px;
|
206 |
+
line-height: 18px;
|
207 |
+
margin:0px;
|
208 |
+
padding:0px;
|
209 |
+
}
|
210 |
+
.contact-info-section {
|
211 |
+
margin-bottom:20px;
|
212 |
+
}
|
213 |
+
.overview-section-btn sup {
|
214 |
+
font-size:10px !important;
|
215 |
+
line-height:0px;
|
216 |
+
}
|
217 |
+
.plugin-title {
|
218 |
+
display: flex;
|
219 |
+
position: relative;
|
220 |
+
flex-direction: row;
|
221 |
+
align-content: center;
|
222 |
+
flex-wrap: nowrap;
|
223 |
+
align-items: center;
|
224 |
+
font-size:24px;
|
225 |
+
color:#313846;
|
226 |
+
font-weight:bold;
|
227 |
+
margin-bottom:10px;
|
228 |
+
}
|
229 |
+
.plugin-title img {
|
230 |
+
padding-right:15px;
|
231 |
+
}
|
232 |
+
.plugin-description {
|
233 |
+
margin-bottom:20px;
|
234 |
+
}
|
235 |
+
.supsystic-overview-flex {
|
236 |
+
display: flex;
|
237 |
+
position: relative;
|
238 |
+
flex-direction: row;
|
239 |
+
flex-wrap: nowrap;
|
240 |
+
align-content: center;
|
241 |
+
align-items: stretch;
|
242 |
+
justify-content: space-between;
|
243 |
+
}
|
244 |
+
.half-page {
|
245 |
+
display:inline-block;
|
246 |
+
position:relative;
|
247 |
+
width:49% !important;
|
248 |
+
float:inherit !important;
|
249 |
+
margin:0px !important;
|
250 |
+
padding:0px !important;
|
251 |
+
border:0px !important;
|
252 |
+
}
|
253 |
+
.full-page {
|
254 |
+
width:98%;
|
255 |
+
}
|
256 |
+
.overview-supsystic-img {
|
257 |
+
max-width:770px;
|
258 |
+
width:100%;
|
259 |
+
}
|
260 |
+
@media (max-width:1100px) {
|
261 |
+
.supsystic-overview-flex {
|
262 |
+
flex-direction: column;
|
263 |
+
}
|
264 |
+
.half-page {
|
265 |
+
width: 100% !important;
|
266 |
+
}
|
267 |
+
.full-page {
|
268 |
+
width:100%;
|
269 |
+
}
|
270 |
+
}
|
271 |
+
|
272 |
+
.supsysticOverviewACTitle {
|
273 |
+
background:#2a3545;
|
274 |
+
color:white;
|
275 |
+
font-size:14px;
|
276 |
+
padding:10px 0px;
|
277 |
+
text-align:center;
|
278 |
+
margin-bottom:10px;
|
279 |
+
width:100%;
|
280 |
+
}
|
281 |
+
.supsysticOverviewACForm input {
|
282 |
+
width:94%;
|
283 |
+
text-align:center;
|
284 |
+
}
|
285 |
+
.supsysticOverviewACForm button, .supsysticOverviewACBtn {
|
286 |
+
display:block;
|
287 |
+
position:relative;
|
288 |
+
width:94%;
|
289 |
+
margin:0px;
|
290 |
+
padding:0px;
|
291 |
+
text-align:center;
|
292 |
+
margin-top:10px !important;
|
293 |
+
}
|
294 |
+
.supsysticOverviewACFormOverlay {
|
295 |
+
display:block;
|
296 |
+
position:absolute;
|
297 |
+
left:0px;
|
298 |
+
top:0px;
|
299 |
+
width:100%;
|
300 |
+
height:100%;
|
301 |
+
background: rgb(223 223 223 / 80%);
|
302 |
+
z-index:99;
|
303 |
+
}
|
304 |
+
#overview-ac-form {
|
305 |
+
position: relative;
|
306 |
+
display: flex;
|
307 |
+
flex-direction: column;
|
308 |
+
flex-wrap: nowrap;
|
309 |
+
align-content: center;
|
310 |
+
align-items: center;
|
311 |
+
justify-content: flex-start;
|
312 |
+
background:white;
|
313 |
+
box-shadow: 0px 3px 9px 0px #919191cf;
|
314 |
+
margin:30px auto;
|
315 |
+
width: 100%;
|
316 |
+
max-width: 300px;
|
317 |
+
padding-bottom:20px;
|
318 |
+
}
|
319 |
+
.supsystic-footer-wrapper {
|
320 |
+
display: flex;
|
321 |
+
position: relative;
|
322 |
+
background: #263546;
|
323 |
+
margin-left: 75px;
|
324 |
+
color: white;
|
325 |
+
padding: 10px;
|
326 |
+
flex-direction: row;
|
327 |
+
flex-wrap: nowrap;
|
328 |
+
align-content: center;
|
329 |
+
justify-content: space-between;
|
330 |
+
align-items: center;
|
331 |
+
}
|
332 |
+
.supsystic-panel {
|
333 |
+
margin-bottom:0px;
|
334 |
+
}
|
335 |
+
.supsystic-breadcrumbs {
|
336 |
+
background: #263546;
|
337 |
+
color: white;
|
338 |
+
margin-left: 75px;
|
339 |
+
padding: 10px;
|
340 |
+
}
|
341 |
+
.supsystic-breadcrumbs * {
|
342 |
+
color: white !important;
|
343 |
+
}
|
344 |
+
.ui-dialog-titlebar-close {
|
345 |
+
display:none;
|
346 |
+
}
|
347 |
+
.supsysticOverviewACFormNotification,
|
348 |
+
.required-notification {
|
349 |
+
margin-top:10px;
|
350 |
+
}
|
351 |
+
.supsysticOverviewACClose {
|
352 |
+
display:inline-block;
|
353 |
+
position:absolute;
|
354 |
+
right:-7.5px;
|
355 |
+
top:-7.5px;
|
356 |
+
background:#4ae8ea !important;
|
357 |
+
border-radius:50%;
|
358 |
+
text-align:center;
|
359 |
+
font-size:18px;
|
360 |
+
width:21px;
|
361 |
+
height:21px;
|
362 |
+
cursor:pointer;
|
363 |
+
z-index:99;
|
364 |
+
text-shadow: 0px 1px 2px black;
|
365 |
+
}
|
src/SocialSharing/Overview/assets/img/overview-01.png
ADDED
Binary file
|
src/SocialSharing/Overview/assets/img/overview-02.png
ADDED
Binary file
|
src/SocialSharing/Overview/assets/img/overview-03.png
ADDED
Binary file
|
src/SocialSharing/Overview/assets/img/plugin-icon.png
ADDED
Binary file
|
src/SocialSharing/Overview/assets/img/supsystic-logo-small.png
ADDED
Binary file
|
src/SocialSharing/Overview/assets/js/overview-settings.js
CHANGED
@@ -1,8 +1,11 @@
|
|
1 |
-
(function(
|
2 |
|
3 |
var Controller = function () {
|
4 |
this.$newsContainer = $('.supsystic-overview-news');
|
5 |
this.$mailButton = $('#send-mail');
|
|
|
|
|
|
|
6 |
this.$faqToggles = $('.faq-title');
|
7 |
};
|
8 |
|
@@ -17,39 +20,242 @@
|
|
17 |
};
|
18 |
|
19 |
Controller.prototype.checkMail = function() {
|
20 |
-
var
|
21 |
-
$
|
22 |
-
$
|
|
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
};
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
Controller.prototype.initFaqToggles = function() {
|
36 |
var self = this;
|
37 |
|
38 |
this.$faqToggles.on('click', function() {
|
39 |
-
|
40 |
-
$(this).find('div.description').show();
|
41 |
});
|
42 |
};
|
43 |
|
44 |
Controller.prototype.init = function() {
|
45 |
this.initScroll();
|
46 |
this.checkMail();
|
|
|
|
|
|
|
47 |
this.initFaqToggles();
|
48 |
};
|
49 |
|
50 |
$(document).ready(function() {
|
51 |
var controller = new Controller();
|
52 |
-
|
53 |
controller.init();
|
54 |
});
|
|
|
55 |
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function($, app) {
|
2 |
|
3 |
var Controller = function () {
|
4 |
this.$newsContainer = $('.supsystic-overview-news');
|
5 |
this.$mailButton = $('#send-mail');
|
6 |
+
this.$subscribeButton = $('#subscribe-btn');
|
7 |
+
this.$subscribeButtonRemind = $('.supsysticOverviewACBtnRemind');
|
8 |
+
this.$subscribeButtonDisable = $('.supsysticOverviewACBtnDisable');
|
9 |
this.$faqToggles = $('.faq-title');
|
10 |
};
|
11 |
|
20 |
};
|
21 |
|
22 |
Controller.prototype.checkMail = function() {
|
23 |
+
var self = this,
|
24 |
+
$userMail = $('[name="email"]'),
|
25 |
+
$userText = $('[name="message"]'),
|
26 |
+
$dialog = $('#contact-form-dialog');
|
27 |
|
28 |
+
function sendMail() {
|
29 |
+
|
30 |
+
var defaultIconClass = self.$mailButton.find('i').attr('class');
|
31 |
+
self.$mailButton.find('i').attr('class', 'fa fa-spinner fa-spin');
|
32 |
+
self.$mailButton.attr('disabled', true);
|
33 |
+
|
34 |
+
data = {};
|
35 |
+
$.each($('#form-settings').serializeArray(), function(index, obj){
|
36 |
+
data[obj.name] = obj.value;
|
37 |
+
});
|
38 |
+
|
39 |
+
app.Ajax.Post({
|
40 |
+
module: 'overview',
|
41 |
+
action: 'sendMail',
|
42 |
+
data: data
|
43 |
+
}).send(function(response) {
|
44 |
+
self.$mailButton.find('i').attr('class', defaultIconClass);
|
45 |
+
self.$mailButton.attr('disabled', false);
|
46 |
|
47 |
+
if (!response.success) {
|
48 |
+
$('#contact-form-dialog').find('.on-error').show();
|
49 |
+
}
|
50 |
+
$('#contact-form-dialog').find('.message').text(response.message);
|
51 |
+
$('#contact-form-dialog').dialog({
|
52 |
+
autoOpen: true,
|
53 |
+
resizable: false,
|
54 |
+
width: 500,
|
55 |
+
height: 280,
|
56 |
+
modal: true,
|
57 |
+
buttons: {
|
58 |
+
Close: function() {
|
59 |
+
$('#contact-form-dialog').find('.on-error').hide();
|
60 |
+
$(this).dialog("close");
|
61 |
+
}
|
62 |
}
|
63 |
});
|
64 |
+
});
|
65 |
+
}
|
66 |
+
|
67 |
+
this.$mailButton.on('click', function(e) {
|
68 |
+
e.preventDefault();
|
69 |
+
if(!$userMail.val() || !$userText.val()) {
|
70 |
+
$userMail.closest('tr').find('.required').css('color', 'red');
|
71 |
+
$userText.closest('tr').find('.required').css('color', 'red');
|
72 |
+
$('.required-notification').show();
|
73 |
+
return;
|
74 |
+
}
|
75 |
+
$('.required-notification').hide();
|
76 |
+
sendMail();
|
77 |
});
|
78 |
+
|
79 |
+
};
|
80 |
+
|
81 |
+
Controller.prototype.subscribeMail = function() {
|
82 |
+
var self = this,
|
83 |
+
$userMail = $('.supsysticOverviewACForm [name="email"]'),
|
84 |
+
$userName = $('.supsysticOverviewACForm [name="username"]'),
|
85 |
+
$dialog = $('#supsysticOverviewACFormDialog');
|
86 |
+
|
87 |
+
function sendSubscribeMail() {
|
88 |
+
|
89 |
+
var defaultIconClass = self.$subscribeButton.find('i').attr('class');
|
90 |
+
self.$subscribeButton.find('i').attr('class', 'fa fa-spinner fa-spin');
|
91 |
+
self.$subscribeButton.attr('disabled', true);
|
92 |
+
|
93 |
+
data = {};
|
94 |
+
$.each($('#overview-ac-form').serializeArray(), function(index, obj){
|
95 |
+
data[obj.name] = obj.value;
|
96 |
+
});
|
97 |
+
|
98 |
+
var nonce = jQuery("[name='nonce']").val();
|
99 |
+
jQuery.ajax({
|
100 |
+
url : ajaxurl,
|
101 |
+
type : 'post',
|
102 |
+
data : {'action' : 'social-sharing', 'route': {'module' : 'overview', 'action' : 'sendSubscribeMail', 'nonce' : nonce, 'data' : data}, 'nonce' : nonce},
|
103 |
+
success : function( response ) {
|
104 |
+
self.$subscribeButtonDisable.find('i').attr('class', defaultIconClass);
|
105 |
+
self.$subscribeButtonDisable.attr('disabled', false);
|
106 |
+
$('.supsysticOverviewACFormOverlay').fadeOut();
|
107 |
+
|
108 |
+
$('#supsysticOverviewACFormDialog').find('.message').text(response.message);
|
109 |
+
$('#supsysticOverviewACFormDialog').dialog({
|
110 |
+
autoOpen: true,
|
111 |
+
resizable: false,
|
112 |
+
width: 500,
|
113 |
+
height: 280,
|
114 |
+
modal: true,
|
115 |
+
buttons: {
|
116 |
+
Close: function() {
|
117 |
+
$('#supsysticOverviewACFormDialog').find('.on-error').hide();
|
118 |
+
$('.supsysticOverviewACFormOverlay').fadeOut();
|
119 |
+
$(this).dialog("close");
|
120 |
+
}
|
121 |
+
}
|
122 |
+
});
|
123 |
+
|
124 |
+
},
|
125 |
+
fail : function( err ) {
|
126 |
+
$('#supsysticOverviewACFormDialog').find('.on-error').show();
|
127 |
+
}
|
128 |
+
});
|
129 |
+
|
130 |
+
// app.Ajax.Post({
|
131 |
+
// module: 'overview',
|
132 |
+
// action: 'sendSubscribeMail',
|
133 |
+
// data: data
|
134 |
+
// }).send(function(response) {
|
135 |
+
// self.$subscribeButton.find('i').attr('class', defaultIconClass);
|
136 |
+
// self.$subscribeButton.attr('disabled', false);
|
137 |
+
//
|
138 |
+
// if (!response.success) {
|
139 |
+
// $('#supsysticOverviewACFormDialog').find('.on-error').show();
|
140 |
+
// }
|
141 |
+
// $('#supsysticOverviewACFormDialog').find('.message').text(response.message);
|
142 |
+
// $('#supsysticOverviewACFormDialog').dialog({
|
143 |
+
// autoOpen: true,
|
144 |
+
// resizable: false,
|
145 |
+
// width: 500,
|
146 |
+
// height: 280,
|
147 |
+
// modal: true,
|
148 |
+
// buttons: {
|
149 |
+
// Close: function() {
|
150 |
+
// $('#supsysticOverviewACFormDialog').find('.on-error').hide();
|
151 |
+
// $('.supsysticOverviewACFormOverlay').fadeOut();
|
152 |
+
// $(this).dialog("close");
|
153 |
+
// }
|
154 |
+
// }
|
155 |
+
// });
|
156 |
+
// });
|
157 |
+
}
|
158 |
+
|
159 |
+
this.$subscribeButton.on('click', function(e) {
|
160 |
+
e.preventDefault();
|
161 |
+
if(!$userMail.val() || !$userName.val()) {
|
162 |
+
$('.supsysticOverviewACFormNotification').show();
|
163 |
+
return;
|
164 |
+
}
|
165 |
+
$('.supsysticOverviewACFormNotification').hide();
|
166 |
+
jQuery('#subscribe-btn, .supsysticOverviewACBtnRemind, .supsysticOverviewACBtnDisable').attr('disabled','disabled').prop('disabled','disabled');
|
167 |
+
sendSubscribeMail();
|
168 |
+
});
|
169 |
+
|
170 |
+
};
|
171 |
+
|
172 |
+
Controller.prototype.subscribeRemind = function() {
|
173 |
+
var self = this;
|
174 |
+
function sendSubscribeRemind() {
|
175 |
+
var defaultIconClass = self.$subscribeButtonRemind.find('i').attr('class');
|
176 |
+
self.$subscribeButtonRemind.find('i').attr('class', 'fa fa-spinner fa-spin');
|
177 |
+
self.$subscribeButtonRemind.attr('disabled', true);
|
178 |
+
var form_data = jQuery('#overview-ac-form').serializeArray();
|
179 |
+
var nonce = jQuery("[name='nonce']").val();
|
180 |
+
jQuery.ajax({
|
181 |
+
url : ajaxurl,
|
182 |
+
type : 'post',
|
183 |
+
data : {'action' : 'social-sharing', 'route': {'module' : 'overview', 'action' : 'sendSubscribeRemind', 'nonce' : nonce}, 'nonce' : nonce},
|
184 |
+
success : function( response ) {
|
185 |
+
self.$subscribeButtonDisable.find('i').attr('class', defaultIconClass);
|
186 |
+
self.$subscribeButtonDisable.attr('disabled', false);
|
187 |
+
$('.supsysticOverviewACFormOverlay').fadeOut();
|
188 |
+
},
|
189 |
+
fail : function( err ) {
|
190 |
+
}
|
191 |
+
});
|
192 |
+
}
|
193 |
+
this.$subscribeButtonRemind.on('click', function(e) {
|
194 |
+
e.preventDefault();
|
195 |
+
sendSubscribeRemind();
|
196 |
+
});
|
197 |
};
|
198 |
|
199 |
+
Controller.prototype.subscribeDisable = function() {
|
200 |
+
var self = this;
|
201 |
+
function sendSubscribeDisable() {
|
202 |
+
var defaultIconClass = self.$subscribeButtonDisable.find('i').attr('class');
|
203 |
+
self.$subscribeButtonDisable.find('i').attr('class', 'fa fa-spinner fa-spin');
|
204 |
+
self.$subscribeButtonDisable.attr('disabled', true);
|
205 |
+
var form_data = jQuery('#overview-ac-form').serializeArray();
|
206 |
+
var nonce = jQuery("[name='nonce']").val();
|
207 |
+
jQuery.ajax({
|
208 |
+
url : ajaxurl,
|
209 |
+
type : 'post',
|
210 |
+
data : {'action' : 'social-sharing', 'route': {'module' : 'overview', 'action' : 'sendSubscribeDisable', 'nonce' : nonce}, 'nonce' : nonce},
|
211 |
+
success : function( response ) {
|
212 |
+
self.$subscribeButtonDisable.find('i').attr('class', defaultIconClass);
|
213 |
+
self.$subscribeButtonDisable.attr('disabled', false);
|
214 |
+
$('.supsysticOverviewACFormOverlay').fadeOut();
|
215 |
+
},
|
216 |
+
fail : function( err ) {
|
217 |
+
}
|
218 |
+
});
|
219 |
+
}
|
220 |
+
this.$subscribeButtonDisable.on('click', function(e) {
|
221 |
+
e.preventDefault();
|
222 |
+
sendSubscribeDisable();
|
223 |
+
});
|
224 |
+
};
|
225 |
+
|
226 |
Controller.prototype.initFaqToggles = function() {
|
227 |
var self = this;
|
228 |
|
229 |
this.$faqToggles.on('click', function() {
|
230 |
+
jQuery(this).find('div.description').toggle();
|
|
|
231 |
});
|
232 |
};
|
233 |
|
234 |
Controller.prototype.init = function() {
|
235 |
this.initScroll();
|
236 |
this.checkMail();
|
237 |
+
this.subscribeMail();
|
238 |
+
this.subscribeRemind();
|
239 |
+
this.subscribeDisable();
|
240 |
this.initFaqToggles();
|
241 |
};
|
242 |
|
243 |
$(document).ready(function() {
|
244 |
var controller = new Controller();
|
|
|
245 |
controller.init();
|
246 |
});
|
247 |
+
|
248 |
})(jQuery);
|
249 |
+
|
250 |
+
jQuery(document).ready(function(){
|
251 |
+
jQuery('.overview-section-btn').on('click', function(){
|
252 |
+
jQuery(".overview-section").hide();
|
253 |
+
jQuery(".overview-section[data-section='"+jQuery(this).data("section")+"']").show();
|
254 |
+
jQuery('.overview-section-btn-active').removeClass('overview-section-btn-active');
|
255 |
+
jQuery(this).addClass('overview-section-btn-active');
|
256 |
+
});
|
257 |
+
jQuery('.supsysticOverviewACBtnDisable, .supsysticOverviewACClose, .supsysticOverviewACBtnRemind').on('click', function(){
|
258 |
+
jQuery('.supsysticOverviewACFormOverlay').fadeOut();
|
259 |
+
});
|
260 |
+
jQuery('.overview-section-btn').eq(0).trigger('click');
|
261 |
+
});
|
src/SocialSharing/Overview/views/form.twig
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
{% macro open(method, action, attributes) %}
|
2 |
<form method="{{ method|upper }}" {% if action is not empty %}action="{{ action }}"{% endif %}
|
3 |
-
|
4 |
{% endmacro %}
|
5 |
|
6 |
{% macro close() %}
|
@@ -8,7 +8,6 @@
|
|
8 |
{% endmacro %}
|
9 |
|
10 |
{% macro show_tooltip(id) %}
|
11 |
-
|
12 |
{# Uncomment to enable tooptips: #}
|
13 |
{% set title = tooltips[id] %}
|
14 |
|
@@ -17,11 +16,45 @@
|
|
17 |
title="{{ title|raw }}"
|
18 |
style="{% for property, value in tooltips_icon.style %}{{ property|trim }}:{{ value|trim }};{% endfor %}"></i>
|
19 |
{% endif %}
|
20 |
-
|
21 |
{% endmacro %}
|
22 |
|
23 |
-
{% macro row(label, element, id, titleRow) %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
|
|
25 |
{% import _self as form %}
|
26 |
|
27 |
<tr>
|
@@ -37,10 +70,12 @@
|
|
37 |
{{ form.show_tooltip(id) }}
|
38 |
</label>
|
39 |
{% endif %}
|
|
|
|
|
|
|
|
|
40 |
</th>
|
41 |
-
<td
|
42 |
-
{{ element|raw }}
|
43 |
-
</td>
|
44 |
</tr>
|
45 |
{% endmacro %}
|
46 |
|
@@ -119,8 +154,7 @@
|
|
119 |
{% endmacro %}
|
120 |
|
121 |
{% macro select(name, options, selected, attributes) %}
|
122 |
-
|
123 |
-
<select name="{{ name }}" {% for attribute, value in attributes %}{{ attribute }}="{{ value }}"{% endfor %}>
|
124 |
{% for value, text in options %}
|
125 |
<option value="{{ value }}" name = "{{ text|lower }}" {% if selected == value %}selected{% endif %}>{{ text }}</option>
|
126 |
{% endfor %}
|
@@ -128,7 +162,6 @@
|
|
128 |
{% endmacro %}
|
129 |
|
130 |
{% macro selectv(name, options, selected, attributes) %}
|
131 |
-
|
132 |
<select name="{{ name }}" {% for attribute, value in attributes %}{{ attribute }}="{{ value }}"{% endfor %}>
|
133 |
{% for text in options %}
|
134 |
<option value="{{ text }}" name = "{{ text|lower }}" {% if selected == text %}selected{% endif %}>{{ text }}</option>
|
@@ -136,11 +169,33 @@
|
|
136 |
</select>
|
137 |
{% endmacro %}
|
138 |
|
139 |
-
{% macro
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
|
|
|
141 |
<span name="{{ name }}" {% for attribute, value in attributes %}{{ attribute }}="{{ value }}"{% endfor %}>
|
142 |
{{ text|lower }}
|
143 |
</span>
|
144 |
{% endmacro %}
|
145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
<input type="hidden" name="route[nonce]" value="{{ environment.getNonce() }}" />
|
1 |
{% macro open(method, action, attributes) %}
|
2 |
<form method="{{ method|upper }}" {% if action is not empty %}action="{{ action }}"{% endif %}
|
3 |
+
{% for attribute, value in attributes %}{{ attribute }}="{{ value }}" {% endfor %}>
|
4 |
{% endmacro %}
|
5 |
|
6 |
{% macro close() %}
|
8 |
{% endmacro %}
|
9 |
|
10 |
{% macro show_tooltip(id) %}
|
|
|
11 |
{# Uncomment to enable tooptips: #}
|
12 |
{% set title = tooltips[id] %}
|
13 |
|
16 |
title="{{ title|raw }}"
|
17 |
style="{% for property, value in tooltips_icon.style %}{{ property|trim }}:{{ value|trim }};{% endfor %}"></i>
|
18 |
{% endif %}
|
|
|
19 |
{% endmacro %}
|
20 |
|
21 |
+
{% macro row(label, element, id, titleRow, row_id) %}
|
22 |
+
{% import _self as form %}
|
23 |
+
|
24 |
+
{% if row_id is not empty %}
|
25 |
+
<tr id="{{ row_id }}">
|
26 |
+
{% else %}
|
27 |
+
<tr>
|
28 |
+
{% endif %}
|
29 |
+
<th scope="row">
|
30 |
+
{% if titleRow | length == 2 and titleRow == "h4" %}
|
31 |
+
<h4 style="margin: 0 !important;" {% if id is not empty %}id="label-{{ id }}"{% endif %}>
|
32 |
+
{{ label | raw }}
|
33 |
+
{{ form.show_tooltip(id) }}
|
34 |
+
</h4>
|
35 |
+
{% elseif titleRow is not empty %}
|
36 |
+
<h3 style="margin: 0 !important;" {% if id is not empty %}id="label-{{ id }}"{% endif %}>
|
37 |
+
{{ label | raw }}
|
38 |
+
{{ form.show_tooltip(id) }}
|
39 |
+
</h3>
|
40 |
+
{% else %}
|
41 |
+
<label {{ ' ' }} {% if id is not empty %}id="label-{{ id }}" for="{{ id }}"{% endif %}>
|
42 |
+
{{ label }}
|
43 |
+
{{ form.show_tooltip(id) }}
|
44 |
+
</label>
|
45 |
+
{% endif %}
|
46 |
+
</th>
|
47 |
+
{% if id is not empty %}
|
48 |
+
<td id="{{ id }}">
|
49 |
+
{% else %}
|
50 |
+
<td>
|
51 |
+
{% endif %}
|
52 |
+
{{ element|raw }}
|
53 |
+
</td>
|
54 |
+
</tr>
|
55 |
+
{% endmacro %}
|
56 |
|
57 |
+
{% macro rowpro(label, link, id, element, titleRow, notAddBr) %}
|
58 |
{% import _self as form %}
|
59 |
|
60 |
<tr>
|
70 |
{{ form.show_tooltip(id) }}
|
71 |
</label>
|
72 |
{% endif %}
|
73 |
+
{% if notAddBr == null %}
|
74 |
+
<br/>
|
75 |
+
{% endif %}
|
76 |
+
<label><a href="{{ getProUrl(link) }}" target="_blank" style="color: #0074a2; font-size: 10px; text-decoration: none;" class="sggLinkToProVer">PRO Option</a> </label>
|
77 |
</th>
|
78 |
+
<td>{{ element|raw }}</td>
|
|
|
|
|
79 |
</tr>
|
80 |
{% endmacro %}
|
81 |
|
154 |
{% endmacro %}
|
155 |
|
156 |
{% macro select(name, options, selected, attributes) %}
|
157 |
+
<select name="{{ name }}" {% for attribute, value in attributes %}{{ attribute }}="{{ value }}" {% endfor %}>
|
|
|
158 |
{% for value, text in options %}
|
159 |
<option value="{{ value }}" name = "{{ text|lower }}" {% if selected == value %}selected{% endif %}>{{ text }}</option>
|
160 |
{% endfor %}
|
162 |
{% endmacro %}
|
163 |
|
164 |
{% macro selectv(name, options, selected, attributes) %}
|
|
|
165 |
<select name="{{ name }}" {% for attribute, value in attributes %}{{ attribute }}="{{ value }}"{% endfor %}>
|
166 |
{% for text in options %}
|
167 |
<option value="{{ text }}" name = "{{ text|lower }}" {% if selected == text %}selected{% endif %}>{{ text }}</option>
|
169 |
</select>
|
170 |
{% endmacro %}
|
171 |
|
172 |
+
{% macro selectWithElem(name, options, selected, attributes) %}
|
173 |
+
<select name="{{ name }}" {% for attribute, value in attributes %}{{ attribute }}="{{ value }}"{% endfor %}>
|
174 |
+
{% for value in options %}
|
175 |
+
<option value="{{ value.value }}" name = "{{ value.title|lower }}"
|
176 |
+
{% if selected == value.value %}selected="selected"{% endif %}
|
177 |
+
{% if value.disabled == 1 %} disabled="disabled"{% endif %}
|
178 |
+
>{{ value.title }}</option>
|
179 |
+
{% endfor %}
|
180 |
+
</select>
|
181 |
+
{% endmacro %}
|
182 |
|
183 |
+
{% macro span(name, text, attributes) %}
|
184 |
<span name="{{ name }}" {% for attribute, value in attributes %}{{ attribute }}="{{ value }}"{% endfor %}>
|
185 |
{{ text|lower }}
|
186 |
</span>
|
187 |
{% endmacro %}
|
188 |
|
189 |
+
{% macro selected(actual, expected) %}
|
190 |
+
{% if actual == expected %}selected="selected"{% endif %}
|
191 |
+
{% endmacro %}
|
192 |
+
|
193 |
+
{% macro label(label, for, attributes) %}
|
194 |
+
<label for="{{ for }}" {% for attribute, value in attributes %}{{ attribute }}="{{ value }}"{% endfor %}>{{ label }}</label>
|
195 |
+
{% endmacro %}
|
196 |
+
|
197 |
+
{% macro icon(name, size, id) %}
|
198 |
+
<i class="fa {{name}} mp-icon-preview" style="font-size:{{size}}px;" id="{{id}}"></i>
|
199 |
+
{% endmacro %}
|
200 |
+
|
201 |
<input type="hidden" name="route[nonce]" value="{{ environment.getNonce() }}" />
|
src/SocialSharing/Overview/views/index.twig
CHANGED
@@ -1,16 +1,113 @@
|
|
1 |
{% extends 'layout.twig' %}
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
{% block content %}
|
4 |
-
<div class="supsystic-overview"
|
|
|
|
|
|
|
|
|
|
|
5 |
<div class="half-page half-page-left">
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
<div class="faq-title">
|
13 |
-
<i class="fa fa-info-circle"></i>
|
14 |
{{ environment.translate('Social Share Buttons Installation') }}
|
15 |
<div class="description" hidden>
|
16 |
<p>{{ environment.translate('One more advantage of Social Share WordPress Plugin is an easy installation. To install it, you should make three following steps:') }}</p>
|
@@ -20,7 +117,7 @@
|
|
20 |
</div>
|
21 |
</div>
|
22 |
<div class="faq-title">
|
23 |
-
<i class="fa fa-info-circle"></i>
|
24 |
{{ environment.translate('How to use Social Share Buttons plugin?') }}
|
25 |
<div class="description" hidden>
|
26 |
<p>{{ environment.translate('Step 1: Creating Responsive Social Share Buttons') }}</p>
|
@@ -31,8 +128,8 @@
|
|
31 |
</div>
|
32 |
</div>
|
33 |
<div class="faq-title">
|
34 |
-
<i class="fa fa-info-circle"></i>
|
35 |
-
{{ environment.translate('How to show Social Buttons in Popup?') }}
|
36 |
<div class="description" hidden>
|
37 |
{{ environment.translate('You can do it using our awesome Popup plugin!') }}
|
38 |
<p>{{ environment.translate('1. At first, you need to install Popup by Supsystic plugin.') }}</p>
|
@@ -42,29 +139,35 @@
|
|
42 |
<p>{{ environment.translate('5. Popup plugin will automatically create the popup window with buttons.') }}</p>
|
43 |
</div>
|
44 |
</div>
|
45 |
-
<
|
|
|
46 |
<i class="fa fa-info-circle"></i>
|
47 |
-
|
48 |
</a>
|
49 |
<div class="clear"></div>
|
50 |
</div>
|
51 |
-
<div class="video">
|
52 |
-
<h3>
|
53 |
<iframe type="text/html"
|
54 |
-
width="
|
55 |
-
height="
|
56 |
src="http://www.youtube.com/embed/_GvD8fZryzY"
|
57 |
frameborder="0">
|
58 |
</iframe>
|
|
|
59 |
</div>
|
60 |
-
<div class="
|
61 |
-
<
|
62 |
-
<
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
65 |
</div>
|
66 |
-
<div class="server-settings">
|
67 |
-
<h3>
|
68 |
<ul class="settings-list">
|
69 |
{% for title, element in serverSettings %}
|
70 |
<li class="settings-line" style="float: none;">
|
@@ -73,81 +176,16 @@
|
|
73 |
</li>
|
74 |
{% endfor %}
|
75 |
</ul>
|
76 |
-
</div>
|
77 |
-
</div>
|
78 |
-
<div class="half-page half-page-right">
|
79 |
-
<div class="supsystic-overview-news-container">
|
80 |
-
<h3>{{ environment.translate('News') }}</h3>
|
81 |
-
<div class="supsystic-overview-news">
|
82 |
-
{{ news|raw }}
|
83 |
-
</div>
|
84 |
-
<p style="border-bottom: 1px solid rgba(164, 170, 172, 0.28); padding-bottom: 20px;">
|
85 |
-
<a href="http://supsystic.com/plugins/social-share-plugin/" class="button button-primary button-hero" style="color: #000000;">
|
86 |
-
<i class="fa fa-info-circle"></i>
|
87 |
-
{{ environment.translate('All news') }}
|
88 |
-
</a>
|
89 |
-
</p>
|
90 |
<div class="clear"></div>
|
91 |
</div>
|
92 |
-
|
93 |
-
<div class="overview-contact-form">
|
94 |
-
<h3>{{ environment.translate('Contact Form') }}</h3>
|
95 |
-
{#<div class="description">Translate plugin in your language and get a Premium license for FREE</div>#}
|
96 |
-
|
97 |
-
{% import '@overview/form.twig' as form %}
|
98 |
-
|
99 |
-
{{ form.open('post', environment.generateUrl('overview', 'sendMail'), { 'id': 'form-settings', 'style': 'width: 100%;' }) }}
|
100 |
-
<table class="contact-form-table" style="width: 100%;">
|
101 |
-
<thead>
|
102 |
-
{{ form.row(environment.translate('Name'),
|
103 |
-
form.text('mail[name]', '', { 'style': { 'width': 'auto;' } })) }}
|
104 |
-
{{ form.row(environment.translate('Email'),
|
105 |
-
form.text('mail[email]', user.user_email , { 'style': { 'width': 'auto;' } })
|
106 |
-
) }}
|
107 |
-
{{ form.row(environment.translate('Website'),
|
108 |
-
form.text('mail[website]', user.url, { 'style': { 'width': 'auto;' } })) }}
|
109 |
-
{{ form.row(environment.translate('Subject'),
|
110 |
-
form.text('mail[subject]', '', { 'style': { 'width': 'auto;' } })) }}
|
111 |
-
<input type="hidden" name="route[nonce]" value="{{ environment.getNonce() }}" />
|
112 |
-
<tr>
|
113 |
-
<th scope="row">
|
114 |
-
<label for="select-question">{{ environment.translate('Topic') }}</label>
|
115 |
-
</th>
|
116 |
-
<td>
|
117 |
-
<select id="select-question" style="width: 207px;" name="mail[question]">
|
118 |
-
<option value="plugin_options">
|
119 |
-
{{ environment.translate('Plugin options') }}
|
120 |
-
</option>
|
121 |
-
<option value="bug">
|
122 |
-
{{ environment.translate('Report a bug') }}
|
123 |
-
</option>
|
124 |
-
<option value="functionallity">
|
125 |
-
{{ environment.translate('Require a new functionallity') }}
|
126 |
-
</option>
|
127 |
-
<option value="other">
|
128 |
-
{{ environment.translate('Other') }}
|
129 |
-
</option>
|
130 |
-
</select>
|
131 |
-
</td>
|
132 |
-
</tr>
|
133 |
-
<tr>
|
134 |
-
<th scope="row">
|
135 |
-
<label for="mail-text">{{ environment.translate('Message') }}</label>
|
136 |
-
</th>
|
137 |
-
<td>
|
138 |
-
<textarea id="mail-text" name="mail[message]" style="width: auto; height: 100px;" placeholder="Hello Supsystic Team!"></textarea>
|
139 |
-
</td>
|
140 |
-
</tr>
|
141 |
-
</thead>
|
142 |
-
</table>
|
143 |
-
<button id="send-mail" type="submit" class="button button-primary button-hero" style="margin-left: 65%;">
|
144 |
-
<i class="fa fa-upload"></i>
|
145 |
-
{{ environment.translate('Send email') }}
|
146 |
-
</button>
|
147 |
-
{#<div class="required-notification" style="color: red; float: left;" hidden></div>#}
|
148 |
-
{{ form.close() }}
|
149 |
-
<div class="clear"></div>
|
150 |
</div>
|
151 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
</div>
|
153 |
{% endblock %}
|
1 |
{% extends 'layout.twig' %}
|
2 |
+
{% block header %}
|
3 |
+
<nav id="supsystic-breadcrumbs" class="supsystic-breadcrumbs">
|
4 |
+
<a href="{{ environment.generateUrl('supsystic-social-sharing') }}">{{ environment.translate('Social Share') }}</a>
|
5 |
+
<i class="fa fa-angle-right"></i>
|
6 |
+
<a href="{{ environment.generateUrl('supsystic-social-sharing') }}">{{ environment.translate('Overview') }}</a>
|
7 |
+
</nav>
|
8 |
+
{% endblock %}
|
9 |
{% block content %}
|
10 |
+
<div class="supsystic-overview">
|
11 |
+
<div class="full-page">
|
12 |
+
<div class="plugin-title"><img src="{{ SSS_PLUGIN_URL }}/src/SocialSharing/Overview/assets/img/plugin-icon.png">Social Share by Supsystic</div>
|
13 |
+
<div class="plugin-description">Simple Social Sharing WordPress plugin with custom buttons design and placement. Choose any social network (Facebook, Twitter, etc.), social buttons design and share bare location. Choose share buttons design template, social networks to share, save your project and that’s it. Simple, eye-catching social share buttons plugin for WordPress with counter, great customization and tons of features!</div>
|
14 |
+
</div>
|
15 |
+
<div class="supsystic-overview-flex">
|
16 |
<div class="half-page half-page-left">
|
17 |
+
<div class="border-wrapper">
|
18 |
+
<ul>
|
19 |
+
<li class="overview-section-btn" data-section="faq"><i class="fa fa-info-circle"></i> FAQ and Documentation</li>
|
20 |
+
<li class="overview-section-btn" data-section="video"><i class="fa fa-play"></i> Video tutorial</li>
|
21 |
+
<li class="overview-section-btn" data-section="settings"><i class="fa fa-cog"></i> Server Settings</li>
|
22 |
+
<li class="overview-section-btn" data-section="support"><i class="fa fa-life-ring"></i> Support</li>
|
23 |
+
<li class="overview-section-btn" data-section="promo_video"><i class="fa fa-star"></i> Our promo video</li>
|
24 |
+
<li class="overview-section-btn"><a target="_blank" title="Go to supsystic.com" href="https://supsystic.com/plugins/social-share-plugin/?utm_source=plugin&utm_campaign=social-share"> Plugin page on supsystic.com <sup><i class="fa fa-external-link"></i></sup></a></li>
|
25 |
+
<li class="overview-section-btn"><a target="_blank" title="Go to supsystic.com" href="https://supsystic.com/plugins/social-share-plugin/?utm_source=plugin&utm_campaign=social-share"> Compare FREE and PRO features <sup><i class="fa fa-external-link"></i></sup></a></li>
|
26 |
+
<li class="overview-section-btn"><a target="_blank" title="Go to supsystic.com" href="https://supsystic.com/all-plugins/?utm_source=plugin&utm_campaign=social-share"> Check other supsystic FREE plugins <sup><i class="fa fa-external-link"></i></sup></a></li>
|
27 |
+
</ul>
|
28 |
+
</div>
|
29 |
+
<div class="border-wrapper">
|
30 |
+
<div class="overview-contact-form overview-section" data-section="support">
|
31 |
+
<h3><i class="fa fa-life-ring"></i> Support</h3>
|
32 |
+
<div class="contact-info-section">
|
33 |
+
<p><i class="fa fa-clock-o" aria-hidden="true"></i> Our official support hours are 09:00 - 18:00 GMT+02:00, Monday to Friday – excluding bank holidays and other official holidays.</p>
|
34 |
+
<p>The timescales listed below refer to these working hours.</p><br>
|
35 |
+
<p><em>Support requests are prioritized based on the type of license:</em></p>
|
36 |
+
<ul>
|
37 |
+
<li><p><em>Pro Support</em> is reserved for customers with an active Pro license. We respond to new priority support requests within 12 hours.</p></li>
|
38 |
+
<li><p><em>Standard Support</em> is provided to customers with an active Free license. We respond to standard support requests within 24h-48h.</p></li>
|
39 |
+
</ul><br>
|
40 |
+
<p><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> While we don’t guarantee that we will resolve the request in this time period, we will acknowledge it and communicate with the customer as appropriate to help resolve the issue.</p>
|
41 |
+
</div>
|
42 |
+
{% import '@overview/form.twig' as form %}
|
43 |
+
{{ form.open('post', environment.generateUrl('overview', 'sendMail'), { 'id': 'form-settings', 'style': 'max-width: 100%;', '_wpnonce': environment.getNonce() }) }}
|
44 |
+
<table class="contact-form-table" style="width: 100%;">
|
45 |
+
<thead>
|
46 |
+
{{ form.row(environment.translate('Name') ~ ' *',
|
47 |
+
form.text('name', SSS_USER_NAME, { 'required': '' })) }}
|
48 |
+
|
49 |
+
{{ form.row(environment.translate('Email') ~ ' *',
|
50 |
+
form.text('email', SSS_USER_EMAIL, { 'required': '' })) }}
|
51 |
+
|
52 |
+
{{ form.row(environment.translate('Website') ~ ' *',
|
53 |
+
form.text('website', SSS_WEBSITE, { 'required': '' })) }}
|
54 |
+
|
55 |
+
{{ form.row(environment.translate('Subject') ~ ' *',
|
56 |
+
form.text('subject', '', { 'required': '' })) }}
|
57 |
+
<tr>
|
58 |
+
<th scope="row">
|
59 |
+
<label for="select-question">{{ environment.translate('Topic') }}</label>
|
60 |
+
</th>
|
61 |
+
<td>
|
62 |
+
<select id="select-question" name="question">
|
63 |
+
<option value="plugin_options">
|
64 |
+
{{ environment.translate('Plugin options') }}
|
65 |
+
</option>
|
66 |
+
<option value="bug">
|
67 |
+
{{ environment.translate('Report a bug') }}
|
68 |
+
</option>
|
69 |
+
<option value="functionallity">
|
70 |
+
{{ environment.translate('Require a new functionallity') }}
|
71 |
+
</option>
|
72 |
+
<option value="security_issue">
|
73 |
+
{{ environment.translate('Report about security issue (XSS/SQLi and others)') }}
|
74 |
+
</option>
|
75 |
+
<option value="other">
|
76 |
+
{{ environment.translate('Other') }}
|
77 |
+
</option>
|
78 |
+
</select>
|
79 |
+
</td>
|
80 |
+
</tr>
|
81 |
+
<tr>
|
82 |
+
<th scope="row" style="vertical-align: top;">
|
83 |
+
<label for="mail-text">{{ environment.translate('Message') ~ ' *' }}</label>
|
84 |
+
</th>
|
85 |
+
<td>
|
86 |
+
<textarea id="mail-text" name="message" cols="50" rows="3" placeholder="{{ environment.translate('Hello Supsystic Team!') }}" required=""></textarea>
|
87 |
+
</td>
|
88 |
+
</tr>
|
89 |
+
</thead>
|
90 |
+
</table>
|
91 |
+
<button id="send-mail" type="submit" class="button button-primary button-hero">
|
92 |
+
<i class="fa fa-check-square" aria-hidden="true"></i>
|
93 |
+
Send email
|
94 |
+
</button>
|
95 |
+
<div class="required-notification" style="color: red; float: left;" hidden>Fields with * are required to fill</div>
|
96 |
+
{{ form.close() }}
|
97 |
+
<div class="clear"></div>
|
98 |
+
</div>
|
99 |
+
|
100 |
+
<div id="contact-form-dialog" hidden>
|
101 |
+
<div class="on-error" style="display:none">
|
102 |
+
<p>{{ environment.translate('Some errors occurred while sending mail please send your message trough this contact form:') }}</p>
|
103 |
+
<p><a href="https://supsystic.com/plugins/photo-gallery/#contact" target="_blank">https://supsystic.com/plugins/photo-gallery/#contact</a></p>
|
104 |
+
</div>
|
105 |
+
<div class="message"></div>
|
106 |
+
</div>
|
107 |
+
<div data-section="faq" class="faq-list overview-section">
|
108 |
+
<h3><i class="fa fa-info-circle"></i> FAQ and Documentation</h3>
|
109 |
<div class="faq-title">
|
110 |
+
<i class="fa fa-info-circle"></i>{{ ' ' }}
|
111 |
{{ environment.translate('Social Share Buttons Installation') }}
|
112 |
<div class="description" hidden>
|
113 |
<p>{{ environment.translate('One more advantage of Social Share WordPress Plugin is an easy installation. To install it, you should make three following steps:') }}</p>
|
117 |
</div>
|
118 |
</div>
|
119 |
<div class="faq-title">
|
120 |
+
<i class="fa fa-info-circle"></i>{{ ' ' }}
|
121 |
{{ environment.translate('How to use Social Share Buttons plugin?') }}
|
122 |
<div class="description" hidden>
|
123 |
<p>{{ environment.translate('Step 1: Creating Responsive Social Share Buttons') }}</p>
|
128 |
</div>
|
129 |
</div>
|
130 |
<div class="faq-title">
|
131 |
+
<i class="fa fa-info-circle"></i>{{ ' ' }}
|
132 |
+
{{ environment.translate('How to show Social Buttons in Popup?') }}
|
133 |
<div class="description" hidden>
|
134 |
{{ environment.translate('You can do it using our awesome Popup plugin!') }}
|
135 |
<p>{{ environment.translate('1. At first, you need to install Popup by Supsystic plugin.') }}</p>
|
139 |
<p>{{ environment.translate('5. Popup plugin will automatically create the popup window with buttons.') }}</p>
|
140 |
</div>
|
141 |
</div>
|
142 |
+
<div style="clear: both;"></div>
|
143 |
+
<a target="_blank" href="https://supsystic.com/docs/social-share-buttons/?utm_source=plugin&utm_medium=faq&utm_campaign=gallery" class="button button-primary button-hero">
|
144 |
<i class="fa fa-info-circle"></i>
|
145 |
+
Check all FAQs
|
146 |
</a>
|
147 |
<div class="clear"></div>
|
148 |
</div>
|
149 |
+
<div data-section="video" class="video overview-section">
|
150 |
+
<h3><i class="fa fa-play"></i> Video tutorial</h3>
|
151 |
<iframe type="text/html"
|
152 |
+
width="100%"
|
153 |
+
height="350px"
|
154 |
src="http://www.youtube.com/embed/_GvD8fZryzY"
|
155 |
frameborder="0">
|
156 |
</iframe>
|
157 |
+
<div class="clear"></div>
|
158 |
</div>
|
159 |
+
<div data-section="promo_video" class="video overview-section">
|
160 |
+
<h3><i class="fa fa-star"></i> Our promo video</h3>
|
161 |
+
<iframe type="text/html"
|
162 |
+
width="100%"
|
163 |
+
height="350px"
|
164 |
+
src="http://www.youtube.com/embed/dKd_9g6JzfU"
|
165 |
+
frameborder="0">
|
166 |
+
</iframe>
|
167 |
+
<div class="clear"></div>
|
168 |
</div>
|
169 |
+
<div data-section="settings" class="server-settings overview-section">
|
170 |
+
<h3><i class="fa fa-cog"></i> Server settings</h3>
|
171 |
<ul class="settings-list">
|
172 |
{% for title, element in serverSettings %}
|
173 |
<li class="settings-line" style="float: none;">
|
176 |
</li>
|
177 |
{% endfor %}
|
178 |
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
<div class="clear"></div>
|
180 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
</div>
|
182 |
</div>
|
183 |
+
<div class="half-page half-page-right">
|
184 |
+
<a href="https://supsystic.com/pricing/?utm_source=plugin&utm_campaign=social-share" target="_blank"><img class="overview-supsystic-img" src="{{ SSS_PLUGIN_URL }}/src/SocialSharing/Overview/assets/img/overview-01.png"></a>
|
185 |
+
<a href="https://supsystic.com/bundle-mix/?utm_source=plugin&utm_campaign=social-share" target="_blank"><img class="overview-supsystic-img" src="{{ SSS_PLUGIN_URL }}/src/SocialSharing/Overview/assets/img/overview-02.png"></a>
|
186 |
+
<a href="https://supsystic.com/all-plugins/?utm_source=plugin&utm_campaign=social-share" target="_blank"><img style="margin-top:20px;" class="overview-supsystic-img" src="{{ SSS_PLUGIN_URL }}/src/SocialSharing/Overview/assets/img/overview-03.png"></a>
|
187 |
+
<div class="clear"></div>
|
188 |
+
</div>
|
189 |
+
</div>
|
190 |
</div>
|
191 |
{% endblock %}
|
src/SocialSharing/Projects/Builder.php
CHANGED
@@ -15,7 +15,7 @@ abstract class SocialSharing_Projects_Builder
|
|
15 |
private $isHomepageSet = false;
|
16 |
|
17 |
/**
|
18 |
-
* @var
|
19 |
*/
|
20 |
private $environment;
|
21 |
|
@@ -27,9 +27,9 @@ abstract class SocialSharing_Projects_Builder
|
|
27 |
/**
|
28 |
* Constructs the builder.
|
29 |
* @param \SocialSharing_Projects_Project $project
|
30 |
-
* @param \
|
31 |
*/
|
32 |
-
public function __construct(SocialSharing_Projects_Project $project,
|
33 |
{
|
34 |
$this->project = $project;
|
35 |
$this->environment = $environment;
|
@@ -138,7 +138,7 @@ abstract class SocialSharing_Projects_Builder
|
|
138 |
|
139 |
/**
|
140 |
* Returns Environment.
|
141 |
-
* @return
|
142 |
*/
|
143 |
public function getEnvironment()
|
144 |
{
|
15 |
private $isHomepageSet = false;
|
16 |
|
17 |
/**
|
18 |
+
* @var RscSss_Environment
|
19 |
*/
|
20 |
private $environment;
|
21 |
|
27 |
/**
|
28 |
* Constructs the builder.
|
29 |
* @param \SocialSharing_Projects_Project $project
|
30 |
+
* @param \RscSss_Environment $environment
|
31 |
*/
|
32 |
+
public function __construct(SocialSharing_Projects_Project $project, RscSss_Environment $environment)
|
33 |
{
|
34 |
$this->project = $project;
|
35 |
$this->environment = $environment;
|
138 |
|
139 |
/**
|
140 |
* Returns Environment.
|
141 |
+
* @return RscSss_Environment
|
142 |
*/
|
143 |
public function getEnvironment()
|
144 |
{
|
src/SocialSharing/Projects/Builder/Standard.php
CHANGED
@@ -92,6 +92,8 @@ abstract class SocialSharing_Projects_Builder_Standard extends SocialSharing_Pro
|
|
92 |
|
93 |
$projectSettings = $project->getSettings();
|
94 |
$getSharesLists = htmlspecialchars(json_encode($getSharesLists));
|
|
|
|
|
95 |
$atributesButton = array(
|
96 |
$builder->createAttribute(
|
97 |
'data-networks',
|
@@ -137,10 +139,10 @@ abstract class SocialSharing_Projects_Builder_Standard extends SocialSharing_Pro
|
|
137 |
'data-url',
|
138 |
admin_url('admin-ajax.php')
|
139 |
),
|
140 |
-
$builder->createAttribute(
|
141 |
-
|
142 |
-
|
143 |
-
),
|
144 |
$builder->createAttribute(
|
145 |
'rel',
|
146 |
'nofollow'
|
92 |
|
93 |
$projectSettings = $project->getSettings();
|
94 |
$getSharesLists = htmlspecialchars(json_encode($getSharesLists));
|
95 |
+
$description = str_replace('"',"",$description);
|
96 |
+
$description = str_replace("'","",$description);
|
97 |
$atributesButton = array(
|
98 |
$builder->createAttribute(
|
99 |
'data-networks',
|
139 |
'data-url',
|
140 |
admin_url('admin-ajax.php')
|
141 |
),
|
142 |
+
// $builder->createAttribute(
|
143 |
+
// 'data-description',
|
144 |
+
// $description
|
145 |
+
// ),
|
146 |
$builder->createAttribute(
|
147 |
'rel',
|
148 |
'nofollow'
|
src/SocialSharing/Projects/Controller.php
CHANGED
@@ -11,10 +11,10 @@ class SocialSharing_Projects_Controller extends SocialSharing_Core_BaseControlle
|
|
11 |
/**
|
12 |
* Shows list of the created projects.
|
13 |
*
|
14 |
-
* @param
|
15 |
-
* @return
|
16 |
*/
|
17 |
-
public function indexAction(
|
18 |
{
|
19 |
$projects = $this->modelsFactory->get('projects')->all();
|
20 |
|
@@ -37,10 +37,10 @@ class SocialSharing_Projects_Controller extends SocialSharing_Core_BaseControlle
|
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
-
* @param
|
41 |
-
* @return
|
42 |
*/
|
43 |
-
public function addAction(
|
44 |
{
|
45 |
$title = sanitize_text_field($request->post->get('title'));
|
46 |
$design = $request->post->get('design');
|
@@ -88,10 +88,10 @@ class SocialSharing_Projects_Controller extends SocialSharing_Core_BaseControlle
|
|
88 |
}
|
89 |
|
90 |
/**
|
91 |
-
* @param
|
92 |
-
* @return
|
93 |
*/
|
94 |
-
public function saveAction(
|
95 |
{
|
96 |
if (!$this->_checkNonce($request)) die();
|
97 |
$id = $request->post->get('id');
|
@@ -143,10 +143,10 @@ class SocialSharing_Projects_Controller extends SocialSharing_Core_BaseControlle
|
|
143 |
/**
|
144 |
* View specific project.
|
145 |
*
|
146 |
-
* @param
|
147 |
-
* @return
|
148 |
*/
|
149 |
-
public function viewAction(
|
150 |
{
|
151 |
if (!$this->_checkNonce($request)) die();
|
152 |
$projectId = (int)$request->query->get('id');
|
@@ -218,18 +218,18 @@ class SocialSharing_Projects_Controller extends SocialSharing_Core_BaseControlle
|
|
218 |
'other_post_types' => $otherPostTypes,
|
219 |
'popup_installed' => $popupInstalled,
|
220 |
'slider_installed' => $sliderInstalled,
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
'popups' => $popups,
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
'tooltips' => $tooltips,
|
234 |
'buttons_preview' => $buttonsPreview,
|
235 |
'button_sets' => $buttonSets,
|
@@ -242,10 +242,10 @@ class SocialSharing_Projects_Controller extends SocialSharing_Core_BaseControlle
|
|
242 |
}
|
243 |
|
244 |
/**
|
245 |
-
* @param
|
246 |
-
* @return
|
247 |
*/
|
248 |
-
public function deleteAction(
|
249 |
{
|
250 |
if (!$this->_checkNonce($request)) die();
|
251 |
$this->modelsFactory->get('projects')->delete($request->query->get('id'));
|
@@ -253,7 +253,7 @@ class SocialSharing_Projects_Controller extends SocialSharing_Core_BaseControlle
|
|
253 |
return $this->redirect($this->generateUrl('projects', 'index'));
|
254 |
}
|
255 |
|
256 |
-
public function renameAction(
|
257 |
{
|
258 |
if (!$this->_checkNonce($request)) die();
|
259 |
try {
|
@@ -270,7 +270,7 @@ class SocialSharing_Projects_Controller extends SocialSharing_Core_BaseControlle
|
|
270 |
return $this->ajaxSuccess();
|
271 |
}
|
272 |
|
273 |
-
public function cloneAction(
|
274 |
{
|
275 |
if (!$this->_checkNonce($request)) die();
|
276 |
$id = $request->post->get('id', $request->query->get('id'));
|
@@ -292,7 +292,7 @@ class SocialSharing_Projects_Controller extends SocialSharing_Core_BaseControlle
|
|
292 |
|
293 |
if ($request->isXmlHttpRequest()) {
|
294 |
return $this->response(
|
295 |
-
|
296 |
array(
|
297 |
'location' => $redirectUri
|
298 |
)
|
@@ -319,7 +319,7 @@ class SocialSharing_Projects_Controller extends SocialSharing_Core_BaseControlle
|
|
319 |
}
|
320 |
}
|
321 |
|
322 |
-
public function removeNetworkAction(
|
323 |
{
|
324 |
if (!$this->_checkNonce($request)) die();
|
325 |
/** @var int $networkId */
|
11 |
/**
|
12 |
* Shows list of the created projects.
|
13 |
*
|
14 |
+
* @param RscSss_Http_Request $request Http request
|
15 |
+
* @return RscSss_Http_Response
|
16 |
*/
|
17 |
+
public function indexAction(RscSss_Http_Request $request)
|
18 |
{
|
19 |
$projects = $this->modelsFactory->get('projects')->all();
|
20 |
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
+
* @param RscSss_Http_Request $request
|
41 |
+
* @return RscSss_Http_Response
|
42 |
*/
|
43 |
+
public function addAction(RscSss_Http_Request $request)
|
44 |
{
|
45 |
$title = sanitize_text_field($request->post->get('title'));
|
46 |
$design = $request->post->get('design');
|
88 |
}
|
89 |
|
90 |
/**
|
91 |
+
* @param RscSss_Http_Request $request
|
92 |
+
* @return RscSss_Http_Response
|
93 |
*/
|
94 |
+
public function saveAction(RscSss_Http_Request $request)
|
95 |
{
|
96 |
if (!$this->_checkNonce($request)) die();
|
97 |
$id = $request->post->get('id');
|
143 |
/**
|
144 |
* View specific project.
|
145 |
*
|
146 |
+
* @param RscSss_Http_Request $request Http request
|
147 |
+
* @return RscSss_Http_Response Http response
|
148 |
*/
|
149 |
+
public function viewAction(RscSss_Http_Request $request)
|
150 |
{
|
151 |
if (!$this->_checkNonce($request)) die();
|
152 |
$projectId = (int)$request->query->get('id');
|
218 |
'other_post_types' => $otherPostTypes,
|
219 |
'popup_installed' => $popupInstalled,
|
220 |
'slider_installed' => $sliderInstalled,
|
221 |
+
'gallery_installed' => $galleryInstalled,
|
222 |
+
'gmap_installed' => $gmapInstalled,
|
223 |
+
'popup_activate' => $popupInstalled ? '' : admin_url('plugin-install.php?s=popup+by+supsystic&tab=search&type=term'),
|
224 |
+
'slider_activate' => $sliderInstalled ? '' : admin_url('plugin-install.php?s=slider+by+supsystic&tab=search&type=term'),
|
225 |
+
'gallery_activate' => $galleryInstalled ? '' : admin_url('plugin-install.php?s=gallery+by+supsystic&tab=search&type=term'),
|
226 |
+
'membership_installed' => false,
|
227 |
+
'membership_install_url' => false,
|
228 |
+
'gmap_activate' => $gmapInstalled ? '' : admin_url('plugin-install.php?s=google+maps+by+supsystic&tab=search&type=term'),
|
229 |
'popups' => $popups,
|
230 |
+
'popup_add_new_url' => $popupAddUrl,
|
231 |
+
'gmaps' => $gmaps,
|
232 |
+
'gmap_add_new_url' => $gmapAddUrl,
|
233 |
'tooltips' => $tooltips,
|
234 |
'buttons_preview' => $buttonsPreview,
|
235 |
'button_sets' => $buttonSets,
|
242 |
}
|
243 |
|
244 |
/**
|
245 |
+
* @param RscSss_Http_Request $request
|
246 |
+
* @return RscSss_Http_Response
|
247 |
*/
|
248 |
+
public function deleteAction(RscSss_Http_Request $request)
|
249 |
{
|
250 |
if (!$this->_checkNonce($request)) die();
|
251 |
$this->modelsFactory->get('projects')->delete($request->query->get('id'));
|
253 |
return $this->redirect($this->generateUrl('projects', 'index'));
|
254 |
}
|
255 |
|
256 |
+
public function renameAction(RscSss_Http_Request $request)
|
257 |
{
|
258 |
if (!$this->_checkNonce($request)) die();
|
259 |
try {
|
270 |
return $this->ajaxSuccess();
|
271 |
}
|
272 |
|
273 |
+
public function cloneAction(RscSss_Http_Request $request)
|
274 |
{
|
275 |
if (!$this->_checkNonce($request)) die();
|
276 |
$id = $request->post->get('id', $request->query->get('id'));
|
292 |
|
293 |
if ($request->isXmlHttpRequest()) {
|
294 |
return $this->response(
|
295 |
+
RscSss_Http_Response::AJAX,
|
296 |
array(
|
297 |
'location' => $redirectUri
|
298 |
)
|
319 |
}
|
320 |
}
|
321 |
|
322 |
+
public function removeNetworkAction(RscSss_Http_Request $request)
|
323 |
{
|
324 |
if (!$this->_checkNonce($request)) die();
|
325 |
/** @var int $networkId */
|
src/SocialSharing/Projects/Handler.php
CHANGED
@@ -14,7 +14,7 @@ class SocialSharing_Projects_Handler
|
|
14 |
protected $project;
|
15 |
|
16 |
/**
|
17 |
-
* @var
|
18 |
*/
|
19 |
protected $environment;
|
20 |
|
@@ -27,7 +27,7 @@ class SocialSharing_Projects_Handler
|
|
27 |
* Constructs the handler.
|
28 |
* @param \SocialSharing_Projects_Project $project
|
29 |
*/
|
30 |
-
public function __construct(SocialSharing_Projects_Project $project,
|
31 |
{
|
32 |
$this->project = $project;
|
33 |
$this->environment = $environment;
|
14 |
protected $project;
|
15 |
|
16 |
/**
|
17 |
+
* @var RscSss_Environment
|
18 |
*/
|
19 |
protected $environment;
|
20 |
|
27 |
* Constructs the handler.
|
28 |
* @param \SocialSharing_Projects_Project $project
|
29 |
*/
|
30 |
+
public function __construct(SocialSharing_Projects_Project $project, RscSss_Environment $environment)
|
31 |
{
|
32 |
$this->project = $project;
|
33 |
$this->environment = $environment;
|
src/SocialSharing/Projects/Model/Tooltips.php
CHANGED
@@ -18,10 +18,10 @@ class SocialSharing_Projects_Model_Tooltips extends SocialSharing_Core_BaseModel
|
|
18 |
'content-tooltip' => $e->translate('Buttons will appear at the post or page content.'),
|
19 |
'popup-tooltip' => $e->translate('Now you can use this project in any Popup. Check Popup setting for details.'),
|
20 |
'slider-tooltip' => $e->translate('Now you can use this project in any Slider. Check Slider setting for details.'),
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
'widget-tooltip' => $e->translate('Creates a widget of the current project at Appearance > Widgets and allows you to use project at theme\'s widgets areas.'),
|
26 |
'shortcode-tooltip' => $e->translate('Allows you to insert project shortcode and show buttons where you want.'),
|
27 |
'spacing-tooltip' => sprintf($e->translate('Adds space between the buttons %s'), '<img src="{url}/tooltips-images/distance-between-buttons.jpg"/>'),
|
@@ -43,18 +43,17 @@ class SocialSharing_Projects_Model_Tooltips extends SocialSharing_Core_BaseModel
|
|
43 |
'user-click' => $e->translate('Show Social Buttons when user clicks on page'),
|
44 |
'share-post-link' => $e->translate('Share post link even if post is in the list'),
|
45 |
'hide-on-pages' => $e->translate('Choose pages you want to hide buttons. You can choose "All Pages" or specify posts, pages'),
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
'button-transparency' => $e->translate('Choose transparency for buttons'),
|
58 |
)
|
59 |
);
|
60 |
}
|
@@ -98,7 +97,7 @@ class SocialSharing_Projects_Model_Tooltips extends SocialSharing_Core_BaseModel
|
|
98 |
{
|
99 |
$path = dirname(dirname(dirname(dirname(__FILE__))));
|
100 |
$url = plugin_dir_url($path) . 'app/assets/img';
|
101 |
-
|
102 |
return str_replace('{url}', $url, $text);
|
103 |
}
|
104 |
-
}
|
18 |
'content-tooltip' => $e->translate('Buttons will appear at the post or page content.'),
|
19 |
'popup-tooltip' => $e->translate('Now you can use this project in any Popup. Check Popup setting for details.'),
|
20 |
'slider-tooltip' => $e->translate('Now you can use this project in any Slider. Check Slider setting for details.'),
|
21 |
+
'grid-gallery-tooltip'=> $e->translate('Now you can use this project in any Photo Gallery. Check Photo Gallery setting for details.'),
|
22 |
+
'membership-tooltip' => $e->translate('Now you can use this project in any Membership. Check Membership setting for details.'),
|
23 |
+
'gmap-plug-req-tooltip'=> sprintf($e->translate('You need to install %s to use this feature.'), '<a href="https://supsystic.com/plugins/google-maps-plugin/" target="_blank">Google Maps Easy</a>'),
|
24 |
+
'gmap-tooltip' => $e->translate('Add your Social Buttons - to Google Maps'),
|
25 |
'widget-tooltip' => $e->translate('Creates a widget of the current project at Appearance > Widgets and allows you to use project at theme\'s widgets areas.'),
|
26 |
'shortcode-tooltip' => $e->translate('Allows you to insert project shortcode and show buttons where you want.'),
|
27 |
'spacing-tooltip' => sprintf($e->translate('Adds space between the buttons %s'), '<img src="{url}/tooltips-images/distance-between-buttons.jpg"/>'),
|
43 |
'user-click' => $e->translate('Show Social Buttons when user clicks on page'),
|
44 |
'share-post-link' => $e->translate('Share post link even if post is in the list'),
|
45 |
'hide-on-pages' => $e->translate('Choose pages you want to hide buttons. You can choose "All Pages" or specify posts, pages'),
|
46 |
+
'border-style' => $e->translate('Choose needed border type'),
|
47 |
+
'border-color' => $e->translate('Define border color for Social Share Buttons'),
|
48 |
+
'border-radius' => $e->translate('Set pixels to round border corners'),
|
49 |
+
'border-width' => $e->translate('Establish pixels quantity for width of the border'),
|
50 |
+
'button-width' => $e->translate('Button width tooltip'),
|
51 |
+
'button-vertical-margin' => $e->translate('Distance between buttons and screen side vertically in pixels'),
|
52 |
+
'button-horizontal-margin' => $e->translate('Distance between buttons and screen side horizontally in pixels'),
|
53 |
+
'icon-font-size' => $e->translate('Define size of the button letters in pixels'),
|
54 |
+
'button-background-color' => $e->translate('Set color for buttons background'),
|
55 |
+
'button-icon-color' => $e->translate('Set color for button icons'),
|
56 |
+
'button-transparency' => $e->translate('Choose transparency for buttons'),
|
|
|
57 |
)
|
58 |
);
|
59 |
}
|
97 |
{
|
98 |
$path = dirname(dirname(dirname(dirname(__FILE__))));
|
99 |
$url = plugin_dir_url($path) . 'app/assets/img';
|
100 |
+
|
101 |
return str_replace('{url}', $url, $text);
|
102 |
}
|
103 |
+
}
|
src/SocialSharing/Projects/Module.php
CHANGED
@@ -367,8 +367,8 @@ class SocialSharing_Projects_Module extends SocialSharing_Core_BaseModule
|
|
367 |
|
368 |
$submenuProjectsNew->setCapability('manage_options')
|
369 |
->setMenuSlug('supsystic-social-sharing&module=projects&action=add')
|
370 |
-
->setMenuTitle($lang->translate('
|
371 |
-
->setPageTitle($lang->translate('
|
372 |
->setModuleName('add-new');
|
373 |
// Avoid conflicts with old vendor version
|
374 |
if(method_exists($submenuProjectsNew, 'setSortOrder')) {
|
367 |
|
368 |
$submenuProjectsNew->setCapability('manage_options')
|
369 |
->setMenuSlug('supsystic-social-sharing&module=projects&action=add')
|
370 |
+
->setMenuTitle($lang->translate('New Project'))
|
371 |
+
->setPageTitle($lang->translate('New Project'))
|
372 |
->setModuleName('add-new');
|
373 |
// Avoid conflicts with old vendor version
|
374 |
if(method_exists($submenuProjectsNew, 'setSortOrder')) {
|
src/SocialSharing/Projects/assets/css/projects.css
CHANGED
@@ -22,13 +22,6 @@
|
|
22 |
padding-bottom: 10px;
|
23 |
}
|
24 |
|
25 |
-
.supsystic-plugin ul {
|
26 |
-
margin: 20px 0;
|
27 |
-
}
|
28 |
-
|
29 |
-
.supsystic-plugin li {
|
30 |
-
margin-bottom: 20px;
|
31 |
-
}
|
32 |
|
33 |
.supsystic-plugin .supsystic-social-sharing .iradio_minimal {
|
34 |
position: absolute !important;
|
@@ -362,7 +355,7 @@
|
|
362 |
|
363 |
/* buttons customization */
|
364 |
.form-table input.small {
|
365 |
-
width:
|
366 |
}
|
367 |
.form-table input.medium {
|
368 |
width: 4rem;
|
@@ -395,4 +388,4 @@ table.form-table.customization-checkbox th:first-child{
|
|
395 |
}
|
396 |
label.border-param {
|
397 |
margin-left:1rem;
|
398 |
-
}
|
22 |
padding-bottom: 10px;
|
23 |
}
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
.supsystic-plugin .supsystic-social-sharing .iradio_minimal {
|
27 |
position: absolute !important;
|
355 |
|
356 |
/* buttons customization */
|
357 |
.form-table input.small {
|
358 |
+
width: auto;
|
359 |
}
|
360 |
.form-table input.medium {
|
361 |
width: 4rem;
|
388 |
}
|
389 |
label.border-param {
|
390 |
margin-left:1rem;
|
391 |
+
}
|
src/SocialSharing/Projects/assets/js/projects.edit.js
CHANGED
@@ -229,7 +229,7 @@
|
|
229 |
'module': 'networks',
|
230 |
'action': 'updateSorting'
|
231 |
},
|
232 |
-
'nonce':
|
233 |
'project_id': parseInt($('#networks [name="project_id"]').val()),
|
234 |
'positions': networksPositions
|
235 |
}).done(function(response) {
|
@@ -817,21 +817,23 @@
|
|
817 |
$(this).find('i').removeClass('animate__animated animate__' + $(this).data('animation'));
|
818 |
});
|
819 |
|
820 |
-
$('[name="settings[where_to_show]"]').on('click', function() {
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
}
|
|
|
|
|
835 |
|
836 |
var saveTooltip = function($element) {
|
837 |
var networkId = $element.data('id'),
|
@@ -942,7 +944,7 @@
|
|
942 |
'module': 'networks',
|
943 |
'action': 'saveNames'
|
944 |
},
|
945 |
-
'nonce':
|
946 |
'project_id': parseInt($('#networks [name="project_id"]').val()),
|
947 |
'data': { 'id': networkId, 'value': name }
|
948 |
}).done(function(response) {
|
229 |
'module': 'networks',
|
230 |
'action': 'updateSorting'
|
231 |
},
|
232 |
+
'nonce': sss_nonce,
|
233 |
'project_id': parseInt($('#networks [name="project_id"]').val()),
|
234 |
'positions': networksPositions
|
235 |
}).done(function(response) {
|
817 |
$(this).find('i').removeClass('animate__animated animate__' + $(this).data('animation'));
|
818 |
});
|
819 |
|
820 |
+
// $('[name="settings[where_to_show]"]').on('click', function() {
|
821 |
+
//
|
822 |
+
// if($(this).val() == 'sidebar') {
|
823 |
+
// $('#wts-sidebar-nav').iCheck('update')
|
824 |
+
// .parent().parent().show();
|
825 |
+
// } else {
|
826 |
+
// $('#wts-sidebar-nav').iCheck('update')
|
827 |
+
// .parent().parent().hide();
|
828 |
+
// }
|
829 |
+
// window.ppsCheckUpdateArea($(this).closest('.where-to-show'));
|
830 |
+
// if ($(this).val() == 'content' || $(this).val() == 'code') {
|
831 |
+
// sharePostLinkInList.show();
|
832 |
+
// } else {
|
833 |
+
// sharePostLinkInList.hide();
|
834 |
+
// }
|
835 |
+
//
|
836 |
+
// });
|
837 |
|
838 |
var saveTooltip = function($element) {
|
839 |
var networkId = $element.data('id'),
|
944 |
'module': 'networks',
|
945 |
'action': 'saveNames'
|
946 |
},
|
947 |
+
'nonce': sss_nonce,
|
948 |
'project_id': parseInt($('#networks [name="project_id"]').val()),
|
949 |
'data': { 'id': networkId, 'value': name }
|
950 |
}).done(function(response) {
|
src/SocialSharing/Projects/views/add.twig
CHANGED
@@ -29,8 +29,8 @@
|
|
29 |
{{ environment.translate('Networks to show') }}
|
30 |
</span>
|
31 |
<button class="button" id="addNetwork" style="margin: 5px; vertical-align: middle;">
|
32 |
-
<i class="fa fa-
|
33 |
-
<!-- /.fa fa-
|
34 |
{{ environment.translate('Add Networks') }}
|
35 |
</button>
|
36 |
<!-- /#addNetwork.button -->
|
@@ -548,7 +548,7 @@
|
|
548 |
id="pro-designs"
|
549 |
class="button button-primary"
|
550 |
{% if environment.isPro() is not defined or environment.isPro() != 'true' %}disabled{% endif %}>
|
551 |
-
<i class="fa fa-
|
552 |
{{ environment.translate('Pro designs') }}
|
553 |
</a>
|
554 |
</div>#}
|
29 |
{{ environment.translate('Networks to show') }}
|
30 |
</span>
|
31 |
<button class="button" id="addNetwork" style="margin: 5px; vertical-align: middle;">
|
32 |
+
<i class="fa fa-plus-circle"></i>
|
33 |
+
<!-- /.fa fa-plus-circle -->
|
34 |
{{ environment.translate('Add Networks') }}
|
35 |
</button>
|
36 |
<!-- /#addNetwork.button -->
|
548 |
id="pro-designs"
|
549 |
class="button button-primary"
|
550 |
{% if environment.isPro() is not defined or environment.isPro() != 'true' %}disabled{% endif %}>
|
551 |
+
<i class="fa fa-plus-circle"></i>
|
552 |
{{ environment.translate('Pro designs') }}
|
553 |
</a>
|
554 |
</div>#}
|
src/SocialSharing/Projects/views/index.twig
CHANGED
@@ -26,7 +26,7 @@
|
|
26 |
<tr>
|
27 |
<th scope="row" class="id">{{ project.id }}</th>
|
28 |
<th scope="row" class="title">
|
29 |
-
<a href="{{ environment.generateUrl('projects', 'view', { 'id': project.id }) }}" data-toggle="tooltip" title="{{ environment.translate('Edit project') }}" style="color: black; text-decoration: underline;">
|
30 |
{{ project.title }}
|
31 |
<i class="fa fa-fw fa-pencil"></i>
|
32 |
</a>
|
@@ -67,4 +67,4 @@
|
|
67 |
<input type="text" name="title" id="projectTitle" class="regular-text" style="margin-left: 10px; margin-top: 10px;/>
|
68 |
<!-- /#projectTitle.regular-text -->
|
69 |
</div>
|
70 |
-
{% endblock %}
|
26 |
<tr>
|
27 |
<th scope="row" class="id">{{ project.id }}</th>
|
28 |
<th scope="row" class="title">
|
29 |
+
<a href="{{ environment.generateUrl('projects', 'view', { 'id': project.id }) }}&nonce={{ environment.getNonce() }}" data-toggle="tooltip" title="{{ environment.translate('Edit project') }}" style="color: black; text-decoration: underline;">
|
30 |
{{ project.title }}
|
31 |
<i class="fa fa-fw fa-pencil"></i>
|
32 |
</a>
|
67 |
<input type="text" name="title" id="projectTitle" class="regular-text" style="margin-left: 10px; margin-top: 10px;/>
|
68 |
<!-- /#projectTitle.regular-text -->
|
69 |
</div>
|
70 |
+
{% endblock %}
|
src/SocialSharing/Promo/Controller.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
*/
|
8 |
class SocialSharing_Promo_Controller extends SocialSharing_Core_BaseController
|
9 |
{
|
10 |
-
public function indexAction(
|
11 |
{
|
12 |
$this->getModelsFactory()->get('promo', 'promo')->welcomePageSaveInfo();
|
13 |
|
@@ -16,7 +16,7 @@ class SocialSharing_Promo_Controller extends SocialSharing_Core_BaseController
|
|
16 |
array(
|
17 |
'plugin_name' => $this->getEnvironment()->getConfig()->get('plugin_title_name'),
|
18 |
'plugin_version' => $this->getEnvironment()->getConfig()->get('plugin_version'),
|
19 |
-
'start_url' => '?page=supsystic-social-sharing&module=projects&action=add'.'&nonce='.wp_create_nonce('
|
20 |
)
|
21 |
);
|
22 |
}
|
7 |
*/
|
8 |
class SocialSharing_Promo_Controller extends SocialSharing_Core_BaseController
|
9 |
{
|
10 |
+
public function indexAction(RscSss_Http_Request $request)
|
11 |
{
|
12 |
$this->getModelsFactory()->get('promo', 'promo')->welcomePageSaveInfo();
|
13 |
|
16 |
array(
|
17 |
'plugin_name' => $this->getEnvironment()->getConfig()->get('plugin_title_name'),
|
18 |
'plugin_version' => $this->getEnvironment()->getConfig()->get('plugin_version'),
|
19 |
+
'start_url' => '?page=supsystic-social-sharing&module=projects&action=add'.'&nonce='.wp_create_nonce('sss_nonce')
|
20 |
)
|
21 |
);
|
22 |
}
|
src/SocialSharing/Shares/Controller.php
CHANGED
@@ -5,10 +5,10 @@ class SocialSharing_Shares_Controller extends SocialSharing_Core_BaseController
|
|
5 |
{
|
6 |
/**
|
7 |
* Saves share to the database.
|
8 |
-
* @param
|
9 |
-
* @return
|
10 |
*/
|
11 |
-
public function saveAction(
|
12 |
{
|
13 |
if (!$this->_checkNonce($request) && !$this->_checkNonceFrontend($request)) die();
|
14 |
$projectId = $request->post->get('project_id');
|
@@ -48,7 +48,7 @@ class SocialSharing_Shares_Controller extends SocialSharing_Core_BaseController
|
|
48 |
return $this->ajaxSuccess();
|
49 |
}
|
50 |
|
51 |
-
public function setOptionEnableStatAction(
|
52 |
{
|
53 |
if (!$this->_checkNonce($request)) die();
|
54 |
$isEnable = (bool) $request->post->get('isEnable');
|
@@ -60,7 +60,7 @@ class SocialSharing_Shares_Controller extends SocialSharing_Core_BaseController
|
|
60 |
return $this->ajaxSuccess();
|
61 |
}
|
62 |
|
63 |
-
public function setOptionViewsLogAction(
|
64 |
{
|
65 |
if (!$this->_checkNonce($request)) die();
|
66 |
$shares = $this->modelsFactory->get('shares');
|
@@ -70,7 +70,7 @@ class SocialSharing_Shares_Controller extends SocialSharing_Core_BaseController
|
|
70 |
return $this->ajaxSuccess();
|
71 |
}
|
72 |
|
73 |
-
public function setOptionSharesLogAction(
|
74 |
{
|
75 |
if (!$this->_checkNonce($request)) die();
|
76 |
$shares = $this->modelsFactory->get('shares');
|
@@ -80,7 +80,7 @@ class SocialSharing_Shares_Controller extends SocialSharing_Core_BaseController
|
|
80 |
return $this->ajaxSuccess();
|
81 |
}
|
82 |
|
83 |
-
public function clearDataAction(
|
84 |
{
|
85 |
if (!$this->_checkNonce($request)) die();
|
86 |
$projectId = $request->post->get('project_id');
|
@@ -93,7 +93,7 @@ class SocialSharing_Shares_Controller extends SocialSharing_Core_BaseController
|
|
93 |
return $this->ajaxSuccess(array('clearStatus' => 1));
|
94 |
}
|
95 |
|
96 |
-
public function statisticAction(
|
97 |
{
|
98 |
if (!$this->_checkNonce($request)) die();
|
99 |
$project = $this->modelsFactory->get('projects')->get(
|
@@ -105,7 +105,7 @@ class SocialSharing_Shares_Controller extends SocialSharing_Core_BaseController
|
|
105 |
));
|
106 |
}
|
107 |
|
108 |
-
public function getTotalSharesAction(
|
109 |
{
|
110 |
if (!$this->_checkNonce($request)) die();
|
111 |
try {
|
@@ -119,7 +119,7 @@ class SocialSharing_Shares_Controller extends SocialSharing_Core_BaseController
|
|
119 |
return $this->ajaxSuccess(array('stats' => $stats));
|
120 |
}
|
121 |
|
122 |
-
public function getTotalViewsAction(
|
123 |
{
|
124 |
if (!$this->_checkNonce($request)) die();
|
125 |
try {
|
@@ -133,7 +133,7 @@ class SocialSharing_Shares_Controller extends SocialSharing_Core_BaseController
|
|
133 |
return $this->ajaxSuccess(array('stats' => $stats));
|
134 |
}
|
135 |
|
136 |
-
public function getTotalSharesByDaysAction(
|
137 |
{
|
138 |
if (!$this->_checkNonce($request)) die();
|
139 |
try {
|
@@ -162,7 +162,7 @@ class SocialSharing_Shares_Controller extends SocialSharing_Core_BaseController
|
|
162 |
return $this->ajaxSuccess(array('stats' => $stats));
|
163 |
}
|
164 |
|
165 |
-
public function getPopularPagesByDaysAction(
|
166 |
{
|
167 |
if (!$this->_checkNonce($request)) die();
|
168 |
try {
|
@@ -198,7 +198,7 @@ class SocialSharing_Shares_Controller extends SocialSharing_Core_BaseController
|
|
198 |
return $this->ajaxSuccess(array('stats' => $stats));
|
199 |
}
|
200 |
|
201 |
-
public function getPopularPagesByDaysViewsAction(
|
202 |
{
|
203 |
if (!$this->_checkNonce($request)) die();
|
204 |
try {
|
@@ -234,7 +234,7 @@ class SocialSharing_Shares_Controller extends SocialSharing_Core_BaseController
|
|
234 |
return $this->ajaxSuccess(array('stats' => $stats));
|
235 |
}
|
236 |
|
237 |
-
public function checkReviewNoticeAction(
|
238 |
if (!$this->_checkNonce($request)) die();
|
239 |
$showNotice = get_option('showSharingRevNotice');
|
240 |
$show = false;
|
@@ -253,12 +253,12 @@ class SocialSharing_Shares_Controller extends SocialSharing_Core_BaseController
|
|
253 |
}
|
254 |
|
255 |
return $this->response(
|
256 |
-
|
257 |
array('show' => $show)
|
258 |
);
|
259 |
}
|
260 |
|
261 |
-
public function checkNoticeButtonAction(
|
262 |
if (!$this->_checkNonce($request)) die();
|
263 |
$code = $request->post->get('buttonCode');
|
264 |
$showNotice = get_option('showSharingRevNotice');
|
@@ -271,7 +271,7 @@ class SocialSharing_Shares_Controller extends SocialSharing_Core_BaseController
|
|
271 |
|
272 |
update_option('showSharingRevNotice', $showNotice);
|
273 |
|
274 |
-
return $this->response(
|
275 |
}
|
276 |
|
277 |
}
|
5 |
{
|
6 |
/**
|
7 |
* Saves share to the database.
|
8 |
+
* @param RscSss_Http_Request $request
|
9 |
+
* @return RscSss_Http_Response
|
10 |
*/
|
11 |
+
public function saveAction(RscSss_Http_Request $request)
|
12 |
{
|
13 |
if (!$this->_checkNonce($request) && !$this->_checkNonceFrontend($request)) die();
|
14 |
$projectId = $request->post->get('project_id');
|
48 |
return $this->ajaxSuccess();
|
49 |
}
|
50 |
|
51 |
+
public function setOptionEnableStatAction(RscSss_Http_Request $request)
|
52 |
{
|
53 |
if (!$this->_checkNonce($request)) die();
|
54 |
$isEnable = (bool) $request->post->get('isEnable');
|
60 |
return $this->ajaxSuccess();
|
61 |
}
|
62 |
|
63 |
+
public function setOptionViewsLogAction(RscSss_Http_Request $request)
|
64 |
{
|
65 |
if (!$this->_checkNonce($request)) die();
|
66 |
$shares = $this->modelsFactory->get('shares');
|
70 |
return $this->ajaxSuccess();
|
71 |
}
|
72 |
|
73 |
+
public function setOptionSharesLogAction(RscSss_Http_Request $request)
|
74 |
{
|
75 |
if (!$this->_checkNonce($request)) die();
|
76 |
$shares = $this->modelsFactory->get('shares');
|
80 |
return $this->ajaxSuccess();
|
81 |
}
|
82 |
|
83 |
+
public function clearDataAction(RscSss_Http_Request $request)
|
84 |
{
|
85 |
if (!$this->_checkNonce($request)) die();
|
86 |
$projectId = $request->post->get('project_id');
|
93 |
return $this->ajaxSuccess(array('clearStatus' => 1));
|
94 |
}
|
95 |
|
96 |
+
public function statisticAction(RscSss_Http_Request $request)
|
97 |
{
|
98 |
if (!$this->_checkNonce($request)) die();
|
99 |
$project = $this->modelsFactory->get('projects')->get(
|
105 |
));
|
106 |
}
|
107 |
|
108 |
+
public function getTotalSharesAction(RscSss_Http_Request $request)
|
109 |
{
|
110 |
if (!$this->_checkNonce($request)) die();
|
111 |
try {
|
119 |
return $this->ajaxSuccess(array('stats' => $stats));
|
120 |
}
|
121 |
|
122 |
+
public function getTotalViewsAction(RscSss_Http_Request $request)
|
123 |
{
|
124 |
if (!$this->_checkNonce($request)) die();
|
125 |
try {
|
133 |
return $this->ajaxSuccess(array('stats' => $stats));
|
134 |
}
|
135 |
|
136 |
+
public function getTotalSharesByDaysAction(RscSss_Http_Request $request)
|
137 |
{
|
138 |
if (!$this->_checkNonce($request)) die();
|
139 |
try {
|
162 |
return $this->ajaxSuccess(array('stats' => $stats));
|
163 |
}
|
164 |
|
165 |
+
public function getPopularPagesByDaysAction(RscSss_Http_Request $request)
|
166 |
{
|
167 |
if (!$this->_checkNonce($request)) die();
|
168 |
try {
|
198 |
return $this->ajaxSuccess(array('stats' => $stats));
|
199 |
}
|
200 |
|
201 |
+
public function getPopularPagesByDaysViewsAction(RscSss_Http_Request $request)
|
202 |
{
|
203 |
if (!$this->_checkNonce($request)) die();
|
204 |
try {
|
234 |
return $this->ajaxSuccess(array('stats' => $stats));
|
235 |
}
|
236 |
|
237 |
+
public function checkReviewNoticeAction(RscSss_Http_Request $request) {
|
238 |
if (!$this->_checkNonce($request)) die();
|
239 |
$showNotice = get_option('showSharingRevNotice');
|
240 |
$show = false;
|
253 |
}
|
254 |
|
255 |
return $this->response(
|
256 |
+
RscSss_Http_Response::AJAX,
|
257 |
array('show' => $show)
|
258 |
);
|
259 |
}
|
260 |
|
261 |
+
public function checkNoticeButtonAction(RscSss_Http_Request $request) {
|
262 |
if (!$this->_checkNonce($request)) die();
|
263 |
$code = $request->post->get('buttonCode');
|
264 |
$showNotice = get_option('showSharingRevNotice');
|
271 |
|
272 |
update_option('showSharingRevNotice', $showNotice);
|
273 |
|
274 |
+
return $this->response(RscSss_Http_Response::AJAX);
|
275 |
}
|
276 |
|
277 |
}
|
src/SocialSharing/Shares/Model/SharesObject.php
CHANGED
@@ -3,61 +3,40 @@
|
|
3 |
class SocialSharing_Shares_Model_SharesObject extends SocialSharing_Core_BaseModel {
|
4 |
|
5 |
public function addObject($shareId, $code, $itemId) {
|
6 |
-
|
7 |
-
$
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
);
|
13 |
-
$this->db->query($insertQuery);
|
14 |
return true;
|
15 |
}
|
16 |
|
17 |
public function getObjectsListProjectPageShares($projectId, array $networksId, $itemCode, $itemId) {
|
18 |
-
|
19 |
-
$query = $this->getQueryBuilder()
|
20 |
-
->select(array('network_id', 'COUNT(*) AS total_shares'))
|
21 |
-
->from($this->getPrefix() . 'shares')
|
22 |
-
->join($this->getPrefix() . 'shares_object')
|
23 |
-
->on('share_id', '=', 'id')
|
24 |
-
->where('project_id', '=', (int)$projectId)
|
25 |
-
->andWhere('network_id', 'in', implode(',', $networksId))
|
26 |
-
->andWhere('code', '=', $itemCode)
|
27 |
-
->andWhere('item_id', '=', (int) $itemId)
|
28 |
-
->groupBy('network_id');
|
29 |
-
|
30 |
-
$dbresult = $this->db->get_results($query->build());
|
31 |
$list = array();
|
32 |
-
|
|
|
|
|
|
|
33 |
if(count($networksId)) {
|
34 |
foreach($networksId as $oneNwkId) {
|
35 |
$list[$oneNwkId] = 0;
|
36 |
}
|
37 |
}
|
38 |
-
|
39 |
if(is_array($dbresult) && count($dbresult)) {
|
40 |
foreach ($dbresult as $item) {
|
41 |
-
$list[$item
|
42 |
}
|
43 |
}
|
44 |
-
|
45 |
return $list;
|
46 |
}
|
47 |
public function getGalleryResources($galleryId) {
|
48 |
-
|
49 |
-
|
50 |
-
->from($this->db->prefix . 'gg_galleries_resources')
|
51 |
-
->where('gallery_id', '=', (int)$galleryId);
|
52 |
-
$dbresult = $this->db->get_results($query->build(), ARRAY_A);
|
53 |
-
return $dbresult;
|
54 |
}
|
55 |
public function getGalleryAttachments($resourceId) {
|
56 |
-
|
57 |
-
|
58 |
-
->from($this->db->prefix . 'gg_photos')
|
59 |
-
->where('id', '=', (int)$resourceId);
|
60 |
-
$dbresult = $this->db->get_results($query->build(), ARRAY_A);
|
61 |
-
return $dbresult;
|
62 |
}
|
63 |
}
|
3 |
class SocialSharing_Shares_Model_SharesObject extends SocialSharing_Core_BaseModel {
|
4 |
|
5 |
public function addObject($shareId, $code, $itemId) {
|
6 |
+
global $wpdb;
|
7 |
+
$wpdb->insert($wpdb->prefix.'supsystic_ss_shares_object', array(
|
8 |
+
'share_id' => $shareId,
|
9 |
+
'code' => $code,
|
10 |
+
'item_id' => $itemId,
|
11 |
+
));
|
|
|
|
|
12 |
return true;
|
13 |
}
|
14 |
|
15 |
public function getObjectsListProjectPageShares($projectId, array $networksId, $itemCode, $itemId) {
|
16 |
+
global $wpdb;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
$list = array();
|
18 |
+
$networksIn = implode(',', $networksId);
|
19 |
+
$networksIn = '('.$networksIn.')';
|
20 |
+
$sql = $wpdb->prepare("SELECT network_id, COUNT(*) AS total_shares FROM {$wpdb->prefix}supsystic_ss_shares JOIN {$wpdb->prefix}supsystic_ss_shares_object ON share_id = id WHERE project_id = %d AND network_id IN %1s AND code = %s AND item_id = %d GROUP BY network_id ", array((int)$projectId, $networksIn, $itemCode, (int) $itemId));
|
21 |
+
$dbresult = $wpdb->get_results($sql, ARRAY_A);
|
22 |
if(count($networksId)) {
|
23 |
foreach($networksId as $oneNwkId) {
|
24 |
$list[$oneNwkId] = 0;
|
25 |
}
|
26 |
}
|
|
|
27 |
if(is_array($dbresult) && count($dbresult)) {
|
28 |
foreach ($dbresult as $item) {
|
29 |
+
$list[$item['network_id']] = $item['total_shares'];
|
30 |
}
|
31 |
}
|
|
|
32 |
return $list;
|
33 |
}
|
34 |
public function getGalleryResources($galleryId) {
|
35 |
+
global $wpdb;
|
36 |
+
return $wpdb->get_results("SELECT resource_id FROM {$wpdb->prefix}gg_galleries_resources WHERE " . $wpdb->prepare(" gallery_id = %d ", array($galleryId)), ARRAY_A);
|
|
|
|
|
|
|
|
|
37 |
}
|
38 |
public function getGalleryAttachments($resourceId) {
|
39 |
+
global $wpdb;
|
40 |
+
return $wpdb->get_results("SELECT attachment_id FROM {$wpdb->prefix}gg_photos WHERE " . $wpdb->prepare(" id = %d ", array($resourceId)), ARRAY_A);
|
|
|
|
|
|
|
|
|
41 |
}
|
42 |
}
|
src/SocialSharing/Shares/Module.php
CHANGED
@@ -32,7 +32,7 @@ class SocialSharing_Shares_Module extends SocialSharing_Core_BaseModule
|
|
32 |
|
33 |
/**
|
34 |
* Handles the AJAX request for share buttons.
|
35 |
-
* @return
|
36 |
*/
|
37 |
public function handleShareRequest()
|
38 |
{
|
@@ -46,7 +46,7 @@ class SocialSharing_Shares_Module extends SocialSharing_Core_BaseModule
|
|
46 |
|
47 |
/**
|
48 |
* Handles the AJAX request for view buttons.
|
49 |
-
* @return
|
50 |
*/
|
51 |
public function handleViewRequest()
|
52 |
{
|
@@ -100,7 +100,7 @@ class SocialSharing_Shares_Module extends SocialSharing_Core_BaseModule
|
|
100 |
try {
|
101 |
$views->add($projectId, $postId);
|
102 |
} catch (Exception $e) {
|
103 |
-
$logger = new
|
104 |
|
105 |
$logger->error(
|
106 |
$this->translate(
|
32 |
|
33 |
/**
|
34 |
* Handles the AJAX request for share buttons.
|
35 |
+
* @return RscSss_Http_Response
|
36 |
*/
|
37 |
public function handleShareRequest()
|
38 |
{
|
46 |
|
47 |
/**
|
48 |
* Handles the AJAX request for view buttons.
|
49 |
+
* @return RscSss_Http_Response
|
50 |
*/
|
51 |
public function handleViewRequest()
|
52 |
{
|
100 |
try {
|
101 |
$views->add($projectId, $postId);
|
102 |
} catch (Exception $e) {
|
103 |
+
$logger = new RscSss_Logger(__DIR__ . '/' . 'logs');
|
104 |
|
105 |
$logger->error(
|
106 |
$this->translate(
|
src/SocialSharing/Shares/assets/js/share.js
CHANGED
@@ -17,7 +17,7 @@
|
|
17 |
data.project_id = projectId;
|
18 |
data.network_id = networkId;
|
19 |
data.post_id = isNaN(postId) ? null : postId;
|
20 |
-
data.nonce =
|
21 |
|
22 |
if (additionalObjectCode == 'mbs') {
|
23 |
var additionalObjectItemId = parseInt($button.attr('data-plugin-item-id'))
|
17 |
data.project_id = projectId;
|
18 |
data.network_id = networkId;
|
19 |
data.post_id = isNaN(postId) ? null : postId;
|
20 |
+
data.nonce = sss_nonce_frontend;
|
21 |
|
22 |
if (additionalObjectCode == 'mbs') {
|
23 |
var additionalObjectItemId = parseInt($button.attr('data-plugin-item-id'))
|
src/SocialSharing/Shares/assets/js/shares.statistic.js
CHANGED
@@ -265,7 +265,7 @@ $(document).ready(function () {
|
|
265 |
$.post(window.ajaxurl,
|
266 |
{
|
267 |
action: 'social-sharing',
|
268 |
-
nonce:
|
269 |
route: {
|
270 |
module: 'shares',
|
271 |
action: 'checkReviewNotice'
|
265 |
$.post(window.ajaxurl,
|
266 |
{
|
267 |
action: 'social-sharing',
|
268 |
+
nonce: sss_nonce,
|
269 |
route: {
|
270 |
module: 'shares',
|
271 |
action: 'checkReviewNotice'
|
src/SocialSharing/Tester/Controller.php
CHANGED
@@ -3,14 +3,14 @@
|
|
3 |
|
4 |
class SocialSharing_Tester_Controller extends SocialSharing_Core_BaseController
|
5 |
{
|
6 |
-
public function indexAction(
|
7 |
{
|
8 |
$projects = $this->modelsFactory->get('projects')->all();
|
9 |
|
10 |
return $this->response('@tester/index.twig', array('projects' => $projects, 'notice' => (bool)$request->query->get('notice', false)));
|
11 |
}
|
12 |
|
13 |
-
public function updateAction(
|
14 |
{
|
15 |
if (!$this->_checkNonce($request)) die();
|
16 |
$id = $request->post->get('project');
|
3 |
|
4 |
class SocialSharing_Tester_Controller extends SocialSharing_Core_BaseController
|
5 |
{
|
6 |
+
public function indexAction(RscSss_Http_Request $request)
|
7 |
{
|
8 |
$projects = $this->modelsFactory->get('projects')->all();
|
9 |
|
10 |
return $this->response('@tester/index.twig', array('projects' => $projects, 'notice' => (bool)$request->query->get('notice', false)));
|
11 |
}
|
12 |
|
13 |
+
public function updateAction(RscSss_Http_Request $request)
|
14 |
{
|
15 |
if (!$this->_checkNonce($request)) die();
|
16 |
$id = $request->post->get('project');
|
src/SocialSharing/Ui/Asset.php
CHANGED
@@ -154,7 +154,7 @@ abstract class SocialSharing_Ui_Asset implements SocialSharing_Ui_AssetInterface
|
|
154 |
}
|
155 |
|
156 |
/**
|
157 |
-
* @param string|
|
158 |
* @param string $moduleSource
|
159 |
* @return SocialSharing_Ui_Asset
|
160 |
*/
|
@@ -164,7 +164,7 @@ abstract class SocialSharing_Ui_Asset implements SocialSharing_Ui_AssetInterface
|
|
164 |
|
165 |
if (is_string($module)) {
|
166 |
$module = ucfirst($module);
|
167 |
-
} elseif ($module instanceof
|
168 |
$module = ucfirst($module->getModuleName());
|
169 |
} else {
|
170 |
throw new InvalidArgumentException(
|
154 |
}
|
155 |
|
156 |
/**
|
157 |
+
* @param string|RscSss_Mvc_Module $module
|
158 |
* @param string $moduleSource
|
159 |
* @return SocialSharing_Ui_Asset
|
160 |
*/
|
164 |
|
165 |
if (is_string($module)) {
|
166 |
$module = ucfirst($module);
|
167 |
+
} elseif ($module instanceof RscSss_Mvc_Module) {
|
168 |
$module = ucfirst($module->getModuleName());
|
169 |
} else {
|
170 |
throw new InvalidArgumentException(
|
src/SocialSharing/Ui/Module.php
CHANGED
@@ -75,16 +75,16 @@ class SocialSharing_Ui_Module extends SocialSharing_Core_BaseModule
|
|
75 |
public function addNonce()
|
76 |
{
|
77 |
if ( is_admin() && current_user_can('administrator') ) {
|
78 |
-
$nonce = wp_create_nonce('
|
79 |
wp_register_script( 'ssbs-nonce', '' );
|
80 |
wp_enqueue_script( 'ssbs-nonce' );
|
81 |
-
wp_add_inline_script( 'ssbs-nonce', 'var
|
82 |
}
|
83 |
if ( !is_admin() ) {
|
84 |
-
$nonce = wp_create_nonce('
|
85 |
wp_register_script( 'ssbs-nonce', '' );
|
86 |
wp_enqueue_script( 'ssbs-nonce' );
|
87 |
-
wp_add_inline_script( 'ssbs-nonce', 'var
|
88 |
}
|
89 |
}
|
90 |
|
75 |
public function addNonce()
|
76 |
{
|
77 |
if ( is_admin() && current_user_can('administrator') ) {
|
78 |
+
$nonce = wp_create_nonce('sss_nonce');
|
79 |
wp_register_script( 'ssbs-nonce', '' );
|
80 |
wp_enqueue_script( 'ssbs-nonce' );
|
81 |
+
wp_add_inline_script( 'ssbs-nonce', 'var sss_nonce = "'.$nonce.'"' );
|
82 |
}
|
83 |
if ( !is_admin() ) {
|
84 |
+
$nonce = wp_create_nonce('sss_nonce_frontend');
|
85 |
wp_register_script( 'ssbs-nonce', '' );
|
86 |
wp_enqueue_script( 'ssbs-nonce' );
|
87 |
+
wp_add_inline_script( 'ssbs-nonce', 'var sss_nonce_frontend = "'.$nonce.'"' );
|
88 |
}
|
89 |
}
|
90 |
|
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 RscSss_Autoloader
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
+
* Register RscSss_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) !== 'RscSss') {
|
22 |
return;
|
23 |
}
|
24 |
+
$classname = str_replace('RscSss', '', $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 RscSss_Cache
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
+
* @var RscSss_Cache_Interface
|
9 |
*/
|
10 |
protected $adapter;
|
11 |
|
21 |
|
22 |
/**
|
23 |
* Constructor
|
24 |
+
* @param RscSss_Cache_Interface $adapter The caching adapter
|
25 |
*/
|
26 |
+
public function __construct(RscSss_Cache_Interface $adapter)
|
27 |
{
|
28 |
$this->adapter = $adapter;
|
29 |
}
|
71 |
/**
|
72 |
* Sets the prefix for keys
|
73 |
* @param string $prefix
|
74 |
+
* @return RscSss_Cache
|
75 |
*/
|
76 |
public function setPrefix($prefix)
|
77 |
{
|
91 |
/**
|
92 |
* Sets the time to life for cached data
|
93 |
* @param int $ttl
|
94 |
+
* @return RscSss_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 RscSss_Cache_Dummy implements RscSss_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 RscSss_Cache_Filesystem implements RscSss_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 RscSss_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 RscSss_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 RscSss_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 RscSss_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 RscSss_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 RscSss_ClassLoader
|
74 |
*/
|
75 |
public function setPrefixes(array $prefixes)
|
76 |
{
|
135 |
}
|
136 |
|
137 |
if (stripos($class,'Twig_') !== false) {
|
138 |
+
$className = str_replace('Twig_SupTwgSss_', '', $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_SupTwgSss_Attachment') {
|
147 |
$path = DIRECTORY_SEPARATOR.'SupsysticSlider'.DIRECTORY_SEPARATOR.'Slider'.DIRECTORY_SEPARATOR.'Twig'.DIRECTORY_SEPARATOR.'Attachment.php';
|
148 |
}
|
149 |
+
if ($class == 'SupsysticSliderPro_Slider_Twig_SupTwgSss_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,12 +1,15 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
/** @var array */
|
8 |
protected $collection;
|
9 |
|
|
|
|
|
|
|
10 |
/**
|
11 |
* Constructor
|
12 |
* @param array $collection An array of collection elements
|
@@ -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);
|
@@ -246,6 +250,7 @@ class Rsc_Common_Collection implements Countable, IteratorAggregate, Serializabl
|
|
246 |
* @link http://php.net/manual/en/serializable.serialize.php
|
247 |
* @return string the string representation of the object or null
|
248 |
*/
|
|
|
249 |
public function serialize()
|
250 |
{
|
251 |
return serialize($this->collection);
|
@@ -260,6 +265,7 @@ class Rsc_Common_Collection implements Countable, IteratorAggregate, Serializabl
|
|
260 |
* </p>
|
261 |
* @return void
|
262 |
*/
|
|
|
263 |
public function unserialize($serialized)
|
264 |
{
|
265 |
$this->collection = unserialize($serialized);
|
@@ -274,6 +280,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 +298,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 +313,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 +331,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 +350,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 RscSss_Common_Collection implements Countable, IteratorAggregate, Serializable, ArrayAccess
|
5 |
{
|
6 |
|
7 |
/** @var array */
|
8 |
protected $collection;
|
9 |
|
10 |
+
public function __serialize(): array {}
|
11 |
+
public function __unserialize(array $data): void {}
|
12 |
+
|
13 |
/**
|
14 |
* Constructor
|
15 |
* @param array $collection An array of collection elements
|
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 RscSss_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 RscSss_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 RscSss_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 RscSss_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 RscSss_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);
|
250 |
* @link http://php.net/manual/en/serializable.serialize.php
|
251 |
* @return string the string representation of the object or null
|
252 |
*/
|
253 |
+
#[\ReturnTypeWillChange]
|
254 |
public function serialize()
|
255 |
{
|
256 |
return serialize($this->collection);
|
265 |
* </p>
|
266 |
* @return void
|
267 |
*/
|
268 |
+
#[\ReturnTypeWillChange]
|
269 |
public function unserialize($serialized)
|
270 |
{
|
271 |
$this->collection = unserialize($serialized);
|
280 |
* <p>
|
281 |
* The return value is cast to an integer.
|
282 |
*/
|
283 |
+
#[\ReturnTypeWillChange]
|
284 |
public function count()
|
285 |
{
|
286 |
return count($this->collection);
|
298 |
* <p>
|
299 |
* The return value will be casted to boolean if non-boolean was returned.
|
300 |
*/
|
301 |
+
#[\ReturnTypeWillChange]
|
302 |
public function offsetExists($offset)
|
303 |
{
|
304 |
return $this->has($offset);
|
313 |
* </p>
|
314 |
* @return mixed Can return all value types.
|
315 |
*/
|
316 |
+
#[\ReturnTypeWillChange]
|
317 |
public function offsetGet($offset)
|
318 |
{
|
319 |
return $this->get($offset, null);
|
331 |
* </p>
|
332 |
* @return void
|
333 |
*/
|
334 |
+
#[\ReturnTypeWillChange]
|
335 |
public function offsetSet($offset, $value)
|
336 |
{
|
337 |
if (is_null($offset)) {
|
350 |
* </p>
|
351 |
* @return void
|
352 |
*/
|
353 |
+
#[\ReturnTypeWillChange]
|
354 |
public function offsetUnset($offset)
|
355 |
{
|
356 |
$this->delete($offset);
|
357 |
}
|
358 |
+
}
|
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 RscSss_Config extends RscSss_Common_Collection
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
+
* @var RscSss_Config_Loader
|
9 |
*/
|
10 |
protected $loader;
|
11 |
|
12 |
/**
|
13 |
+
* @var RscSss_Config_ListenerInterface[]
|
14 |
*/
|
15 |
protected $listener;
|
16 |
|
22 |
{
|
23 |
parent::__construct($config);
|
24 |
|
25 |
+
$this->loader = new RscSss_Config_Loader();
|
26 |
}
|
27 |
|
28 |
/**
|
55 |
try {
|
56 |
$this->merge($this->loader->load($filename));
|
57 |
return true;
|
58 |
+
} catch(RscSss_Exception_ConfigLoaderException $e) {
|
59 |
+
if ($this->isEnvironment(RscSss_Environment::ENV_DEVELOPMENT)) {
|
60 |
wp_die ($e->getMessage());
|
61 |
}
|
62 |
|
66 |
|
67 |
/**
|
68 |
* Returns the instance of the config loader
|
69 |
+
* @return RscSss_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 RscSss_Config_ListenerInterface $listener
|
80 |
+
* @return RscSss_Config
|
81 |
*/
|
82 |
+
public function addListener($name, RscSss_Config_ListenerInterface $listener)
|
83 |
{
|
84 |
$this->listener[$name] = $listener;
|
85 |
return $this;
|
156 |
{
|
157 |
$loader = $this->getLoader();
|
158 |
|
159 |
+
$loader->add($defaultPath, RscSss_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 RscSss_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 |
{
|
@@ -64,7 +64,7 @@ class Rsc_Config_Loader
|
|
64 |
try {
|
65 |
return $this->loadFromNamespace($file);
|
66 |
} catch (Exception $e) {
|
67 |
-
throw new
|
68 |
'Unable to load config %s: %s',
|
69 |
$file,
|
70 |
$e->getMessage()
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSss_Config_Loader
|
5 |
{
|
6 |
|
7 |
const DEFAULT_NAMESPACE = 'app';
|
15 |
* Adds
|
16 |
* @param string $path
|
17 |
* @param string $namespace
|
18 |
+
* @return RscSss_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 RscSss_Exception_ConfigLoaderException
|
57 |
*/
|
58 |
public function load($file)
|
59 |
{
|
64 |
try {
|
65 |
return $this->loadFromNamespace($file);
|
66 |
} catch (Exception $e) {
|
67 |
+
throw new RscSss_Exception_ConfigLoaderException(sprintf(
|
68 |
'Unable to load config %s: %s',
|
69 |
$file,
|
70 |
$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 RscSss_Dispatcher
|
8 |
{
|
9 |
|
10 |
/**
|
11 |
+
* @var RscSss_Environment;
|
12 |
*/
|
13 |
protected $environment;
|
14 |
|
15 |
/**
|
16 |
* Constructor.
|
17 |
+
* @param RscSss_Environment $environment Plugin environment.
|
18 |
*/
|
19 |
+
public function __construct(RscSss_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 RscSss_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 RscSss_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 \RscSss_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 RscSss_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' => $this->isDev(),
|
@@ -178,9 +178,9 @@ class Rsc_Environment
|
|
178 |
|
179 |
|
180 |
if ($this->isDev()) {
|
181 |
-
$this->twig->addExtension(new
|
182 |
}
|
183 |
-
} catch (
|
184 |
wp_die(
|
185 |
sprintf('Invalid plugin path specified: "%s"', $e->getMessage())
|
186 |
);
|
@@ -190,7 +190,7 @@ class Rsc_Environment
|
|
190 |
|
191 |
/** @TODO THROW TRY CATCH */
|
192 |
if ($this->config->has('plugin_menu')) {
|
193 |
-
$this->menu = new
|
194 |
|
195 |
foreach ($parameters = $this->config->get('plugin_menu') as $key => $value) {
|
196 |
if (method_exists($this->menu, $method = sprintf('set%s', str_replace('_', '', $key)))) {
|
@@ -207,7 +207,7 @@ class Rsc_Environment
|
|
207 |
}
|
208 |
|
209 |
$this->twig->addGlobal('environment', $this);
|
210 |
-
$this->twig->addGlobal('request', new
|
211 |
|
212 |
$this->resolver = apply_filters(
|
213 |
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 |
{
|
@@ -370,8 +370,8 @@ class Rsc_Environment
|
|
370 |
* @param array $parameters An associative array of the parameters
|
371 |
* @return string
|
372 |
*/
|
373 |
-
|
374 |
-
|
375 |
$url = $this->getUrl() . '&module=' . strtolower($module);
|
376 |
|
377 |
if (!empty($action) && $action != 'index') {
|
@@ -388,7 +388,7 @@ class Rsc_Environment
|
|
388 |
|
389 |
$pluginName = $this->config->get('plugin_name');
|
390 |
if ($pluginName === 'sss') {
|
391 |
-
$url .= '&nonce='.wp_create_nonce('
|
392 |
return $url;
|
393 |
} else {
|
394 |
$url .= '&nonce='.wp_create_nonce('dtgs_nonce');
|
@@ -397,26 +397,16 @@ class Rsc_Environment
|
|
397 |
}
|
398 |
public function getNonceFrontend()
|
399 |
{
|
400 |
-
|
401 |
-
if ($pluginName === 'sss') {
|
402 |
-
return wp_create_nonce('ssbs_nonce_frontend');
|
403 |
-
} else {
|
404 |
-
return wp_create_nonce('dtgs_nonce_frontend');
|
405 |
-
}
|
406 |
}
|
407 |
public function getNonce()
|
408 |
{
|
409 |
-
|
410 |
-
if ($pluginName === 'sss') {
|
411 |
-
return wp_create_nonce('ssbs_nonce');
|
412 |
-
} else {
|
413 |
-
return wp_create_nonce('dtgs_nonce');
|
414 |
-
}
|
415 |
}
|
416 |
/**
|
417 |
* Returns an instance of the specified module
|
418 |
* @param string $module The name of the module
|
419 |
-
* @return
|
420 |
*/
|
421 |
public function getModule($module)
|
422 |
{
|
@@ -435,19 +425,19 @@ class Rsc_Environment
|
|
435 |
|
436 |
/**
|
437 |
* Set an instance of the caching class
|
438 |
-
* @param
|
439 |
-
* @return
|
440 |
*/
|
441 |
-
public function setCacheAdapter(
|
442 |
{
|
443 |
-
$this->cache = new
|
444 |
return $this;
|
445 |
}
|
446 |
|
447 |
/**
|
448 |
* Set profiler state
|
449 |
* @param boolean $profilerEnabled
|
450 |
-
* @return
|
451 |
*/
|
452 |
public function setProfilerEnabled($profilerEnabled)
|
453 |
{
|
@@ -502,7 +492,7 @@ class Rsc_Environment
|
|
502 |
*/
|
503 |
public function isPluginPage()
|
504 |
{
|
505 |
-
$request = new
|
506 |
$menuSlug = $this->menu->getMenuSlug();
|
507 |
|
508 |
if ($menuSlug === null) {
|
@@ -521,7 +511,7 @@ class Rsc_Environment
|
|
521 |
*/
|
522 |
public function isModule($module, $action = null)
|
523 |
{
|
524 |
-
$request = new
|
525 |
$default = $this->config->get('default_module');
|
526 |
|
527 |
if (!$this->isPluginPage()) {
|
@@ -545,7 +535,7 @@ class Rsc_Environment
|
|
545 |
*/
|
546 |
public function isAction($action)
|
547 |
{
|
548 |
-
$request = new
|
549 |
|
550 |
if (!$this->isPluginPage()) {
|
551 |
return false;
|
@@ -567,7 +557,7 @@ class Rsc_Environment
|
|
567 |
/**
|
568 |
* Returns event dispatcher
|
569 |
*
|
570 |
-
* @return \
|
571 |
*/
|
572 |
public function getDispatcher()
|
573 |
{
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSss_Environment
|
5 |
{
|
6 |
|
7 |
const ENV_DEVELOPMENT = 'development';
|
27 |
protected $pluginPath;
|
28 |
|
29 |
/**
|
30 |
+
* @var RscSss_Config
|
31 |
*/
|
32 |
protected $config;
|
33 |
|
34 |
/**
|
35 |
+
* @var RscSss_Cache
|
36 |
*/
|
37 |
protected $cache;
|
38 |
|
39 |
/**
|
40 |
+
* @var RscSss_ClassLoader
|
41 |
*/
|
42 |
protected $loader;
|
43 |
|
44 |
/**
|
45 |
+
* @var RscSss_Lang
|
46 |
*/
|
47 |
protected $lang;
|
48 |
|
49 |
/**
|
50 |
+
* @var RscSss_Menu_Page
|
51 |
*/
|
52 |
protected $menu;
|
53 |
|
54 |
/**
|
55 |
+
* @var RscSss_Resolver
|
56 |
*/
|
57 |
protected $resolver;
|
58 |
|
59 |
/**
|
60 |
+
* @var Twig_SupTwgSss_Environment
|
61 |
*/
|
62 |
protected $twig;
|
63 |
|
64 |
/**
|
65 |
+
* @var RscSss_Logger_Interface
|
66 |
*/
|
67 |
protected $logger;
|
68 |
|
72 |
protected $profilerEnabled;
|
73 |
|
74 |
/**
|
75 |
+
* @var RscSss_Dispatcher
|
76 |
*/
|
77 |
protected $dispatcher;
|
78 |
|
92 |
$this->pluginPath = $path;
|
93 |
|
94 |
/* Class loader */
|
95 |
+
$this->loader = new RscSss_ClassLoader();
|
96 |
|
97 |
/* Modules resolver */
|
98 |
+
$this->resolver = new RscSss_Resolver($this);
|
99 |
|
100 |
/* Config */
|
101 |
+
$this->config = new RscSss_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 RscSss_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 RscSss_Environment
|
129 |
*/
|
130 |
public function configure(array $parameters)
|
131 |
{
|
167 |
try {
|
168 |
$templatesPath = $this->getPluginPath() . '/app/templates';
|
169 |
|
170 |
+
$this->twig = new Twig_SupTwgSss_Environment(
|
171 |
+
new Twig_SupTwgSss_Loader_Filesystem($templatesPath),
|
172 |
array(
|
173 |
'cache' => $this->config->get('plugin_cache_twig', false),
|
174 |
'debug' => $this->isDev(),
|
178 |
|
179 |
|
180 |
if ($this->isDev()) {
|
181 |
+
$this->twig->addExtension(new Twig_SupTwgSss_Extension_Debug());
|
182 |
}
|
183 |
+
} catch (Twig_SupTwgSss_Error_Loader $e) {
|
184 |
wp_die(
|
185 |
sprintf('Invalid plugin path specified: "%s"', $e->getMessage())
|
186 |
);
|
190 |
|
191 |
/** @TODO THROW TRY CATCH */
|
192 |
if ($this->config->has('plugin_menu')) {
|
193 |
+
$this->menu = new RscSss_Menu_Page($this->resolver);
|
194 |
|
195 |
foreach ($parameters = $this->config->get('plugin_menu') as $key => $value) {
|
196 |
if (method_exists($this->menu, $method = sprintf('set%s', str_replace('_', '', $key)))) {
|
207 |
}
|
208 |
|
209 |
$this->twig->addGlobal('environment', $this);
|
210 |
+
$this->twig->addGlobal('request', new RscSss_Http_Request());
|
211 |
|
212 |
$this->resolver = apply_filters(
|
213 |
sprintf('%s_before_resolver_register', $this->pluginName),
|
253 |
|
254 |
/**
|
255 |
* Returns an instance of the Twig
|
256 |
+
* @return Twig_SupTwgSss_Environment
|
257 |
*/
|
258 |
public function getTwig()
|
259 |
{
|
262 |
|
263 |
/**
|
264 |
* Returns an instance of the language class
|
265 |
+
* @return RscSss_Lang
|
266 |
*/
|
267 |
public function getLang()
|
268 |
{
|
281 |
$this->config->add('lang_path', $path);
|
282 |
}
|
283 |
|
284 |
+
$this->lang = new RscSss_Lang($domain, $path);
|
285 |
}
|
286 |
|
287 |
return $this->lang;
|
289 |
|
290 |
/**
|
291 |
* Returns plugin environment configurations
|
292 |
+
* @return RscSss_Config
|
293 |
*/
|
294 |
public function getConfig()
|
295 |
{
|
298 |
|
299 |
/**
|
300 |
* Returns an instance of the caching class
|
301 |
+
* @return RscSss_Cache
|
302 |
*/
|
303 |
public function getCache()
|
304 |
{
|
307 |
|
308 |
/**
|
309 |
* Returns ClassLoader
|
310 |
+
* @return RscSss_ClassLoader
|
311 |
*/
|
312 |
public function getLoader()
|
313 |
{
|
316 |
|
317 |
/**
|
318 |
* Returns an instance of the current menu page
|
319 |
+
* @return \RscSss_Menu_Page
|
320 |
*/
|
321 |
public function getMenu()
|
322 |
{
|
325 |
|
326 |
/**
|
327 |
* Returns an instance of the modules resolver
|
328 |
+
* @return RscSss_Resolver
|
329 |
*/
|
330 |
public function getResolver()
|
331 |
{
|
333 |
}
|
334 |
|
335 |
/**
|
336 |
+
* @param \RscSss_Logger_Interface $logger
|
337 |
+
* @return RscSss_Environment
|
338 |
*/
|
339 |
+
public function setLogger(RscSss_Logger_Interface $logger)
|
340 |
{
|
341 |
$this->logger = $logger;
|
342 |
return $this;
|
343 |
}
|
344 |
|
345 |
/**
|
346 |
+
* @return \RscSss_Logger_Interface
|
347 |
*/
|
348 |
public function getLogger()
|
349 |
{
|
370 |
* @param array $parameters An associative array of the parameters
|
371 |
* @return string
|
372 |
*/
|
373 |
+
public function generateUrl($module, $action = 'index', array $parameters = array(), $hash = '')
|
374 |
+
{
|
375 |
$url = $this->getUrl() . '&module=' . strtolower($module);
|
376 |
|
377 |
if (!empty($action) && $action != 'index') {
|
388 |
|
389 |
$pluginName = $this->config->get('plugin_name');
|
390 |
if ($pluginName === 'sss') {
|
391 |
+
$url .= '&nonce='.wp_create_nonce('sss_nonce');
|
392 |
return $url;
|
393 |
} else {
|
394 |
$url .= '&nonce='.wp_create_nonce('dtgs_nonce');
|
397 |
}
|
398 |
public function getNonceFrontend()
|
399 |
{
|
400 |
+
return wp_create_nonce('sss_nonce_frontend');
|
|
|
|
|
|
|
|
|
|
|
401 |
}
|
402 |
public function getNonce()
|
403 |
{
|
404 |
+
return wp_create_nonce('sss_nonce');
|
|
|
|
|
|
|
|
|
|
|
405 |
}
|
406 |
/**
|
407 |
* Returns an instance of the specified module
|
408 |
* @param string $module The name of the module
|
409 |
+
* @return RscSss_Mvc_Module|null
|
410 |
*/
|
411 |
public function getModule($module)
|
412 |
{
|
425 |
|
426 |
/**
|
427 |
* Set an instance of the caching class
|
428 |
+
* @param RscSss_Cache_Interface $adapter
|
429 |
+
* @return RscSss_Environment
|
430 |
*/
|
431 |
+
public function setCacheAdapter(RscSss_Cache_Interface $adapter)
|
432 |
{
|
433 |
+
$this->cache = new RscSss_Cache($adapter);
|
434 |
return $this;
|
435 |
}
|
436 |
|
437 |
/**
|
438 |
* Set profiler state
|
439 |
* @param boolean $profilerEnabled
|
440 |
+
* @return RscSss_Environment
|
441 |
*/
|
442 |
public function setProfilerEnabled($profilerEnabled)
|
443 |
{
|
492 |
*/
|
493 |
public function isPluginPage()
|
494 |
{
|
495 |
+
$request = new RscSss_Http_Request();
|
496 |
$menuSlug = $this->menu->getMenuSlug();
|
497 |
|
498 |
if ($menuSlug === null) {
|
511 |
*/
|
512 |
public function isModule($module, $action = null)
|
513 |
{
|
514 |
+
$request = new RscSss_Http_Request();
|
515 |
$default = $this->config->get('default_module');
|
516 |
|
517 |
if (!$this->isPluginPage()) {
|
535 |
*/
|
536 |
public function isAction($action)
|
537 |
{
|
538 |
+
$request = new RscSss_Http_Request();
|
539 |
|
540 |
if (!$this->isPluginPage()) {
|
541 |
return false;
|
557 |
/**
|
558 |
* Returns event dispatcher
|
559 |
*
|
560 |
+
* @return \RscSss_Dispatcher
|
561 |
*/
|
562 |
public function getDispatcher()
|
563 |
{
|
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 RscSss_Environment_Aware implements RscSss_Environment_AwareInterface
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
+
* @var RscSss_Environment
|
9 |
*/
|
10 |
protected $environment;
|
11 |
|
12 |
/**
|
13 |
* Sets the environment.
|
14 |
*
|
15 |
+
* @param RscSss_Environment $environment
|
16 |
*/
|
17 |
+
public function setEnvironment(RscSss_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 RscSss_Environment_AwareInterface
|
4 |
{
|
5 |
|
6 |
/**
|
7 |
* Sets the environment.
|
8 |
+
* @param RscSss_Environment $environment
|
9 |
*/
|
10 |
+
public function setEnvironment(RscSss_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 RscSss_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 RscSss_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 RscSss_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 RscSss_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 RscSss_Feedback_Mailer
|
70 |
*/
|
71 |
public function setHeaders(array $headers)
|
72 |
{
|
94 |
* Sets the attachments
|
95 |
*
|
96 |
* @param array $attachments
|
97 |
+
* @return RscSss_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 RscSss_Feedback_Mailer
|
133 |
*/
|
134 |
public function setEmails(array $emails)
|
135 |
{
|
187 |
* Sets the message
|
188 |
*
|
189 |
* @param string $message
|
190 |
+
* @return RscSss_Feedback_Mailer
|
191 |
*/
|
192 |
public function setMessage($message)
|
193 |
{
|
209 |
* Sets the subject
|
210 |
*
|
211 |
* @param string $subject
|
212 |
+
* @return RscSss_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 RscSss_Feedback_SupportMailer
|
5 |
* @package Rsc\Feedback
|
6 |
*/
|
7 |
+
class RscSss_Feedback_SupportMailer
|
8 |
{
|
9 |
/**
|
10 |
+
* @var RscSss_Feedback_Mailer
|
11 |
*/
|
12 |
private $mailer;
|
13 |
|
19 |
/**
|
20 |
* Constructor
|
21 |
*
|
22 |
+
* @param RscSss_Feedback_Mailer $mailer
|
23 |
* @param string $subject
|
24 |
* @param string $message
|
25 |
* @param array $parameters
|
26 |
*/
|
27 |
+
public function __construct(RscSss_Feedback_Mailer $mailer = null, $subject = '', $message = '', array $parameters = array())
|
28 |
{
|
29 |
+
$this->mailer = (is_null($mailer) ? new RscSss_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 RscSss_Feedback_SupportMailer
|
42 |
*/
|
43 |
public function setMessage($message)
|
44 |
{
|
51 |
* Sets the subject
|
52 |
*
|
53 |
* @param string $subject
|
54 |
+
* @return RscSss_Feedback_SupportMailer
|
55 |
*/
|
56 |
public function setSubject($subject)
|
57 |
{
|
64 |
* Sets the parameters
|
65 |
*
|
66 |
* @param array $parameters
|
67 |
+
* @return RscSss_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 RscSss_Form_Filter_Custom implements RscSss_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 RscSss_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 RscSss_Form_Filter_XssClear implements RscSss_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 RscSss_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 RscSss_Form_Rule_Numeric implements RscSss_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 RscSss_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 RscSss_Form_Rule_Regex implements RscSss_Form_Rule_Interface
|
5 |
{
|
6 |
|
7 |
/**
|
62 |
/**
|
63 |
* Sets the error message
|
64 |
* @param string $message Error message
|
65 |
+
* @return RscSss_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 RscSss_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 RscSss_Form_Rule_Required implements RscSss_Form_Rule_Interface
|
5 |
{
|
6 |
|
7 |
/**
|
73 |
/**
|
74 |
* Creates the new instance of the rule for chaining
|
75 |
* <code>
|
76 |
+
* RscSss_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 RscSss_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 RscSss_Form_Validator
|
5 |
{
|
6 |
|
7 |
const METHOD_POST = 'post';
|
8 |
const METHOD_GET = 'query';
|
9 |
|
10 |
/**
|
11 |
+
* @var RscSss_Http_Request
|
12 |
*/
|
13 |
protected $request;
|
14 |
|
18 |
protected $method;
|
19 |
|
20 |
/**
|
21 |
+
* @var RscSss_Common_Collection
|
22 |
*/
|
23 |
protected $rules;
|
24 |
|
25 |
/**
|
26 |
+
* @var RscSss_Common_Collection
|
27 |
*/
|
28 |
protected $filters;
|
29 |
|
34 |
|
35 |
/**
|
36 |
* Constructor
|
37 |
+
* @param RscSss_Http_Request $request
|
38 |
* @param string|null $method
|
39 |
+
* @param RscSss_Common_Collection|array $rules
|
40 |
+
* @param RscSss_Common_Collection|array $filters
|
41 |
*/
|
42 |
+
public function __construct(RscSss_Http_Request $request = null, $method = null, array $rules = array(), array $filters = array())
|
43 |
{
|
44 |
+
$this->request = ($request === null ? RscSss_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 RscSss_Form_Validator_EmptyRequestException If HTTP request is not specified
|
54 |
*/
|
55 |
public function isValid()
|
56 |
{
|
57 |
if (!$this->request) {
|
58 |
+
throw new RscSss_Form_Validator_EmptyRequestException('You must submit the request via ' . __CLASS__ . '::setRequest() method');
|
59 |
}
|
60 |
|
61 |
+
/** @var RscSss_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 RscSss_Http_Request $request
|
81 |
+
* @return RscSss_Form_Validator
|
82 |
*/
|
83 |
+
public function setRequest(RscSss_Http_Request $request)
|
84 |
{
|
85 |
$this->request = $request;
|
86 |
return $this;
|
88 |
|
89 |
/**
|
90 |
* Returns object of current HTTP request
|
91 |
+
* @return RscSss_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 RscSss_Form_Validator_InvalidMethodException If specified method is wrong
|
102 |
+
* @return RscSss_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 RscSss_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 RscSss_Form_Validator
|
128 |
*/
|
129 |
public function setFilters(array $filters)
|
130 |
{
|
145 |
/**
|
146 |
* Set validation rules
|
147 |
* @param array $rules
|
148 |
+
* @return RscSss_Form_Validator
|
149 |
*/
|
150 |
public function setRules(array $rules)
|
151 |
{
|
198 |
|
199 |
/**
|
200 |
* Applies the specified filters
|
201 |
+
* @param RscSss_Http_Parameters $method
|
202 |
*/
|
203 |
+
protected function applyFilters(RscSss_Http_Parameters $method)
|
204 |
{
|
205 |
if (empty($this->filters)) {
|
206 |
return;
|
207 |
}
|
208 |
|
209 |
+
/** @var RscSss_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 RscSss_Http_Parameters $method
|
229 |
*/
|
230 |
+
protected function doValidation(RscSss_Http_Parameters $method)
|
231 |
{
|
232 |
if (empty($this->rules)) {
|
233 |
return;
|
234 |
}
|
235 |
|
236 |
+
/** @var RscSss_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 RscSss_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 RscSss_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 RscSss_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 RscSss_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 |
{
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSss_Http_Parameters extends RscSss_Common_Collection
|
5 |
{
|
6 |
public function get_esc_html($key, $default = null)
|
7 |
{
|
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 RscSss_Http_Request
|
5 |
{
|
6 |
/**
|
7 |
+
* @var RscSss_Http_Parameters
|
8 |
*/
|
9 |
public $post;
|
10 |
|
11 |
/**
|
12 |
+
* @var RscSss_Http_Parameters
|
13 |
*/
|
14 |
public $query;
|
15 |
|
16 |
/**
|
17 |
+
* @var RscSss_Http_Parameters
|
18 |
*/
|
19 |
public $files;
|
20 |
|
21 |
/**
|
22 |
+
* @var RscSss_Http_ServerParameters
|
23 |
*/
|
24 |
public $server;
|
25 |
|
26 |
/**
|
27 |
+
* @var RscSss_Http_Parameters
|
28 |
*/
|
29 |
public $headers;
|
30 |
|
40 |
if(!is_array($postTempVar)) {
|
41 |
$postTempVar = array();
|
42 |
}
|
43 |
+
$this->post = new RscSss_Http_Parameters($postTempVar);
|
44 |
+
$this->query = new RscSss_Http_Parameters($_GET);
|
45 |
+
$this->files = new RscSss_Http_Parameters($_FILES);
|
46 |
+
$this->server = new RscSss_Http_ServerParameters($_SERVER);
|
47 |
+
$this->headers = new RscSss_Http_Parameters($this->server->getHeaders());
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
* Returns new request from the global variables
|
52 |
+
* @return RscSss_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 RscSss_Http_Response
|
5 |
{
|
6 |
|
7 |
const AJAX = 'ajax';
|
13 |
|
14 |
/**
|
15 |
* Creates the new response for chaining methods
|
16 |
+
* @return RscSss_Http_Response
|
17 |
*/
|
18 |
public static function create()
|
19 |
{
|
23 |
/**
|
24 |
* Sets the content of the response
|
25 |
* @param string $content
|
26 |
+
* @return RscSss_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 RscSss_Http_ServerParameters extends RscSss_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 |
}
|
@@ -32,16 +32,16 @@ class Rsc_Installer
|
|
32 |
}
|
33 |
|
34 |
} catch (Exception $e) {
|
35 |
-
trigger_error(
|
36 |
-
|
37 |
-
|
38 |
-
);
|
39 |
}
|
40 |
}
|
41 |
|
42 |
protected function delta($query)
|
43 |
{
|
44 |
-
|
45 |
return dbDelta($query);
|
46 |
}
|
47 |
}
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSss_Installer
|
5 |
{
|
6 |
/**
|
7 |
+
* @var RscSss_Installer_Parser
|
8 |
*/
|
9 |
private $parser;
|
10 |
|
11 |
/**
|
12 |
+
* @param RscSss_Installer_Parser $parser
|
13 |
*/
|
14 |
+
public function __construct(RscSss_Installer_Parser $parser)
|
15 |
{
|
16 |
$this->parser = $parser;
|
17 |
}
|
32 |
}
|
33 |
|
34 |
} catch (Exception $e) {
|
35 |
+
// trigger_error(
|
36 |
+
// sprintf(__('Failed to install the plugin: %s', 'rsc-framework'), $e->getMessage()),
|
37 |
+
// (int) $error
|
38 |
+
// );
|
39 |
}
|
40 |
}
|
41 |
|
42 |
protected function delta($query)
|
43 |
{
|
44 |
+
|
45 |
return dbDelta($query);
|
46 |
}
|
47 |
}
|
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 RscSss_Installer_Parser
|
5 |
* Abstract parser
|
6 |
*/
|
7 |
+
abstract class RscSss_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 RscSss_Installer_PhpParser extends RscSss_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 RscSss_Lang
|
5 |
{
|
6 |
|
7 |
/**
|
20 |
protected $files;
|
21 |
|
22 |
/**
|
23 |
+
* @var RscSss_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 RscSss_Cache $cache Caching class
|
32 |
*/
|
33 |
+
public function __construct($domain = null, $path = null, RscSss_Cache $cache = null)
|
34 |
{
|
35 |
$this->domain = $domain;
|
36 |
$this->path = $path;
|
39 |
|
40 |
/**
|
41 |
* Set caching class
|
42 |
+
* @param \RscSss_Cache_Interface $cache
|
43 |
+
* @return RscSss_Lang
|
44 |
*/
|
45 |
+
public function setCache(RscSss_Cache_Interface $cache)
|
46 |
{
|
47 |
$this->cache = $cache;
|
48 |
return $this;
|
50 |
|
51 |
/**
|
52 |
* Load text domain
|
53 |
+
* @throws RscSss_Exception_LangException If path or domain is not specified
|
54 |
*/
|
55 |
public function loadTextDomain()
|
56 |
{
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
+
* Alias for RscSss_Lang::translate()
|
81 |
* @param string $msgid Message ID
|
82 |
* @return string|void
|
83 |
*/
|
139 |
/**
|
140 |
* Set text domain
|
141 |
* @param string $domain
|
142 |
+
* @return RscSss_Lang
|
143 |
*/
|
144 |
public function setDomain($domain)
|
145 |
{
|
159 |
/**
|
160 |
* Set domain path
|
161 |
* @param string $path
|
162 |
+
* @return RscSss_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 RscSss_Logger implements RscSss_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 RscSss_Logger
|
27 |
*/
|
28 |
public function setPath($path)
|
29 |
{
|
154 |
* @param mixed $level
|
155 |
* @param string $message
|
156 |
* @param array $context
|
157 |
+
* @throws RscSss_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 RscSss_Logger_AwareInterface
|
7 |
{
|
8 |
/**
|
9 |
* Sets a logger instance on the object
|
10 |
*
|
11 |
+
* @param RscSss_Logger_Interface $logger
|
12 |
* @return null
|
13 |
*/
|
14 |
+
public function setLogger(RscSss_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 RscSss_Logger_Exception_InvalidPathException
|
5 |
*/
|
6 |
+
class RscSss_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 RscSss_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 RscSss_Menu_Item
|
5 |
{
|
6 |
|
7 |
/**
|
30 |
protected $menuSlug;
|
31 |
|
32 |
/**
|
33 |
+
* @var RscSss_Resolver
|
34 |
*/
|
35 |
protected $resolver;
|
36 |
|
47 |
/**
|
48 |
* Constructor
|
49 |
* @param string $parentSlug
|
50 |
+
* @param RscSss_Resolver $resolver
|
51 |
*/
|
52 |
+
public function __construct($parentSlug, RscSss_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 RscSss_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 RscSss_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 RscSss_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 RscSss_Menu_Item
|
122 |
*/
|
123 |
public function setPageTitle($pageTitle)
|
124 |
{
|
138 |
/**
|
139 |
* Sets the module name
|
140 |
* @param string $moduleName
|
141 |
+
* @return RscSss_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 RscSss_Menu_Page
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
+
* @var RscSss_Resolver
|
9 |
*/
|
10 |
protected $resolver;
|
11 |
|
44 |
*/
|
45 |
protected $submenu;
|
46 |
|
47 |
+
public function __construct(RscSss_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 RscSss_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 RscSss_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 RscSss_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 RscSss_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 RscSss_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 RscSss_Menu_Page
|
156 |
*/
|
157 |
public function setPosition($position)
|
158 |
{
|
172 |
|
173 |
/**
|
174 |
* Create an instance of the submenu item class
|
175 |
+
* @return RscSss_Menu_Item
|
176 |
*/
|
177 |
public function createSubmenuItem()
|
178 |
{
|
179 |
+
return new RscSss_Menu_Item($this->menuSlug, $this->resolver);
|
180 |
}
|
181 |
|
182 |
/**
|
183 |
* @param string $handle The handle of the item
|
184 |
+
* @param RscSss_Menu_Item $submenu An instance of the submenu item class
|
185 |
+
* @return RscSss_Menu_Page
|
186 |
*/
|
187 |
+
public function addSubmenuItem($handle, RscSss_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|RscSss_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 RscSss_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 RscSss_Mvc_Controller
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
+
* @var RscSss_Environment
|
9 |
*/
|
10 |
private $environment;
|
11 |
|
12 |
/**
|
13 |
+
* @var RscSss_Http_Request
|
14 |
*/
|
15 |
private $request;
|
16 |
|
17 |
/**
|
18 |
* Constructor
|
19 |
+
* @param RscSss_Environment $environment
|
20 |
+
* @param RscSss_Http_Request $request
|
21 |
*/
|
22 |
public function __construct(
|
23 |
+
RscSss_Environment $environment,
|
24 |
+
RscSss_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 RscSss_Http_Response
|
56 |
*/
|
57 |
public function response($template, array $data = array())
|
58 |
{
|
59 |
+
if ($template != RscSss_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 RscSss_Http_Response::create()->setContent($content);
|
71 |
}
|
72 |
|
73 |
/**
|
88 |
/**
|
89 |
* Makes redirects to the specified URL
|
90 |
* @param string $url
|
91 |
+
* @return \RscSss_Http_Response
|
92 |
*/
|
93 |
public function redirect($url)
|
94 |
{
|
99 |
|
100 |
$content = "<script type=\"text/javascript\">document.location.href = '$url'</script>";
|
101 |
|
102 |
+
return RscSss_Http_Response::create()->setContent($content);
|
103 |
}
|
104 |
|
105 |
/**
|
106 |
* Returns an instance of the environment
|
107 |
+
* @return \RscSss_Environment
|
108 |
*/
|
109 |
public function getEnvironment()
|
110 |
{
|
113 |
|
114 |
/**
|
115 |
* Returns an instance of the current request
|
116 |
+
* @return \RscSss_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 RscSss_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;
|
@@ -171,7 +171,7 @@ class Rsc_Mvc_Module
|
|
171 |
|
172 |
$twig = $this->environment->getTwig();
|
173 |
|
174 |
-
return
|
175 |
'controller' => $this->getModuleName(),
|
176 |
'action' => $action,
|
177 |
)));
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSss_Mvc_Module
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
+
* @var RscSss_Environment
|
9 |
*/
|
10 |
private $environment;
|
11 |
|
20 |
private $namespace;
|
21 |
|
22 |
/**
|
23 |
+
* @var RscSss_Http_Request
|
24 |
*/
|
25 |
private $request;
|
26 |
|
27 |
/**
|
28 |
+
* @var RscSss_Mvc_Controller
|
29 |
*/
|
30 |
private $controller;
|
31 |
|
36 |
|
37 |
/**
|
38 |
* Constructor.
|
39 |
+
* @param RscSss_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(RscSss_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 RscSss_Environment
|
70 |
*/
|
71 |
public function getEnvironment()
|
72 |
{
|
116 |
|
117 |
/**
|
118 |
* Returns an instance of controller
|
119 |
+
* @return null|RscSss_Mvc_Controller
|
120 |
*/
|
121 |
public function getController()
|
122 |
{
|
129 |
|
130 |
/**
|
131 |
* Returns the HTTP request to the module
|
132 |
+
* @return RscSss_Http_Request
|
133 |
*/
|
134 |
public function getRequest()
|
135 |
{
|
138 |
|
139 |
/**
|
140 |
* Set HTTP request to the module
|
141 |
+
* @param RscSss_Http_Request $request HTTP request
|
142 |
+
* @return RscSss_Mvc_Module
|
143 |
*/
|
144 |
+
public function setRequest(RscSss_Http_Request $request)
|
145 |
{
|
146 |
$this->request = $request;
|
147 |
return $this;
|
171 |
|
172 |
$twig = $this->environment->getTwig();
|
173 |
|
174 |
+
return RscSss_Http_Response::create()->setContent($twig->render('404.twig', array(
|
175 |
'controller' => $this->getModuleName(),
|
176 |
'action' => $action,
|
177 |
)));
|
vendor/Rsc/Profiler.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
4 |
-
class
|
5 |
{
|
6 |
|
7 |
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
class RscSss_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 RscSss_Resolver
|
5 |
{
|
6 |
|
7 |
/**
|
8 |
+
* @var RscSss_Environment
|
9 |
*/
|
10 |
private $environment;
|
11 |
|
12 |
/**
|
13 |
+
* @var RscSss_Common_Collection
|
14 |
*/
|
15 |
protected $modules;
|
16 |
|
17 |
/**
|
18 |
+
* @var RscSss_Http_Request
|
19 |
*/
|
20 |
protected $request;
|
21 |
|
31 |
|
32 |
/**
|
33 |
* Constructor
|
34 |
+
* @param RscSss_Environment $environment An instance of current environment
|
35 |
*/
|
36 |
+
public function __construct(RscSss_Environment $environment)
|
37 |
{
|
38 |
$this->environment = $environment;
|
39 |
+
$this->modules = new RscSss_Common_Collection();
|
40 |
+
$this->request = new RscSss_Http_Request();
|
41 |
$this->routes = array();
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
* Returns an instance of environment
|
46 |
+
* @return RscSss_Environment
|
47 |
*/
|
48 |
public function getEnvironment()
|
49 |
{
|
52 |
|
53 |
/**
|
54 |
* Returns the collection of the found modules
|
55 |
+
* @return RscSss_Common_Collection
|
56 |
*/
|
57 |
public function getModules()
|
58 |
{
|
62 |
public function setModules($modules)
|
63 |
{
|
64 |
if (is_array($modules)) {
|
65 |
+
$modules = new RscSss_Common_Collection($modules);
|
66 |
}
|
67 |
|
68 |
$this->modules = $modules;
|
81 |
{
|
82 |
$modules = $this->getModulesList();
|
83 |
|
84 |
+
/** @var RscSss_Mvc_Module $module */
|
85 |
foreach ($modules as $name => $module) {
|
86 |
$module->onInstall();
|
87 |
}
|
97 |
|
98 |
$modules = $this->getModulesList();
|
99 |
|
100 |
+
/** @var RscSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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 RscSss_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 RscSss_Http_Response $response */
|
229 |
$response = $module = $this->modules->get(strtolower($name))->setRequest($this->request)->handle();
|
230 |
|
231 |
+
if (!is_object($response) || !$response instanceof RscSss_Http_Response) {
|
232 |
wp_die ('The controller must return the response');
|
233 |
}
|
234 |
|
281 |
}
|
282 |
}
|
283 |
|
284 |
+
$this->modulesList = new RscSss_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_SupTwgSss_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_SupTwgSss_Autoloader
|
22 |
{
|
23 |
/**
|
24 |
+
* Registers Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss')) {
|
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_SupTwgSss_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_SupTwgSss_BaseNodeVisitor implements Twig_SupTwgSss_NodeVisitorInterface
|
18 |
{
|
19 |
+
final public function enterNode(Twig_SupTwgSss_NodeInterface $node, Twig_SupTwgSss_Environment $env)
|
20 |
{
|
21 |
+
if (!$node instanceof Twig_SupTwgSss_Node) {
|
22 |
+
throw new LogicException('Twig_SupTwgSss_BaseNodeVisitor only supports Twig_SupTwgSss_Node instances.');
|
23 |
}
|
24 |
|
25 |
return $this->doEnterNode($node, $env);
|
26 |
}
|
27 |
|
28 |
+
final public function leaveNode(Twig_SupTwgSss_NodeInterface $node, Twig_SupTwgSss_Environment $env)
|
29 |
{
|
30 |
+
if (!$node instanceof Twig_SupTwgSss_Node) {
|
31 |
+
throw new LogicException('Twig_SupTwgSss_BaseNodeVisitor only supports Twig_SupTwgSss_Node instances.');
|
32 |
}
|
33 |
|
34 |
return $this->doLeaveNode($node, $env);
|
37 |
/**
|
38 |
* Called before child nodes are visited.
|
39 |
*
|
40 |
+
* @return Twig_SupTwgSss_Node The modified node
|
41 |
*/
|
42 |
+
abstract protected function doEnterNode(Twig_SupTwgSss_Node $node, Twig_SupTwgSss_Environment $env);
|
43 |
|
44 |
/**
|
45 |
* Called after child nodes are visited.
|
46 |
*
|
47 |
+
* @return Twig_SupTwgSss_Node|false The modified node or false if the node must be removed
|
48 |
*/
|
49 |
+
abstract protected function doLeaveNode(Twig_SupTwgSss_Node $node, Twig_SupTwgSss_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_SupTwgSss_Cache_Filesystem implements Twig_SupTwgSss_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_SupTwgSss_Cache_Null implements Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Compiler implements Twig_SupTwgSss_CompilerInterface
|
19 |
{
|
20 |
protected $lastLine;
|
21 |
protected $source;
|
26 |
protected $sourceLine;
|
27 |
protected $filename;
|
28 |
|
29 |
+
public function __construct(Twig_SupTwgSss_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_SupTwgSss_Environment
|
48 |
*/
|
49 |
public function getEnvironment()
|
50 |
{
|
64 |
/**
|
65 |
* Compiles a node.
|
66 |
*
|
67 |
+
* @param Twig_SupTwgSss_NodeInterface $node The node to compile
|
68 |
* @param int $indentation The current indentation
|
69 |
*
|
70 |
* @return $this
|
71 |
*/
|
72 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_CompilerInterface
|
20 |
{
|
21 |
/**
|
22 |
* Compiles a node.
|
23 |
*
|
24 |
* @return $this
|
25 |
*/
|
26 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_ContainerRuntimeLoader implements Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Template).
|
74 |
*
|
75 |
* * cache: An absolute path where to store the compiled templates,
|
76 |
+
* a Twig_SupTwgSss_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_SupTwgSss_LoaderInterface $loader
|
98 |
* @param array $options An array of options
|
99 |
*/
|
100 |
+
public function __construct(Twig_SupTwgSss_LoaderInterface $loader = null, $options = array())
|
101 |
{
|
102 |
if (null !== $loader) {
|
103 |
$this->setLoader($loader);
|
104 |
} else {
|
105 |
+
//@trigger_error('Not passing a Twig_SupTwgSss_LoaderInterface as the first constructor argument of Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Extension_Core());
|
127 |
+
$this->addExtension(new Twig_SupTwgSss_Extension_Escaper($options['autoescape']));
|
128 |
+
$this->addExtension(new Twig_SupTwgSss_Extension_Optimizer($options['optimizations']));
|
129 |
+
$this->staging = new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_CacheInterface|string|false A Twig_SupTwgSss_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_SupTwgSss_CacheInterface|string|false $cache A Twig_SupTwgSss_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_SupTwgSss_Cache_Filesystem($cache);
|
278 |
} elseif (false === $cache) {
|
279 |
$this->originalCache = $cache;
|
280 |
+
$this->cache = new Twig_SupTwgSss_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_SupTwgSss_Cache_Null();
|
285 |
+
} elseif ($cache instanceof Twig_SupTwgSss_CacheInterface) {
|
286 |
$this->originalCache = $this->cache = $cache;
|
287 |
} else {
|
288 |
+
throw new LogicException(sprintf('Cache can only be a string, false, or a Twig_SupTwgSss_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_SupTwgSss_Error_Loader When the template cannot be found
|
357 |
+
* @throws Twig_SupTwgSss_Error_Syntax When an error occurred during compilation
|
358 |
+
* @throws Twig_SupTwgSss_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_SupTwgSss_Error_Loader When the template cannot be found
|
372 |
+
* @throws Twig_SupTwgSss_Error_Syntax When an error occurred during compilation
|
373 |
+
* @throws Twig_SupTwgSss_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_SupTwgSss_TemplateWrapper|Twig_SupTwgSss_Template $name The template name
|
384 |
*
|
385 |
+
* @return Twig_SupTwgSss_TemplateWrapper
|
386 |
*/
|
387 |
public function load($name)
|
388 |
{
|
389 |
+
if ($name instanceof Twig_SupTwgSss_TemplateWrapper) {
|
390 |
return $name;
|
391 |
}
|
392 |
|
393 |
+
if ($name instanceof Twig_SupTwgSss_Template) {
|
394 |
+
return new Twig_SupTwgSss_TemplateWrapper($this, $name);
|
395 |
}
|
396 |
|
397 |
+
return new Twig_SupTwgSss_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_SupTwgSss_TemplateInterface A template instance representing the given template name
|
410 |
*
|
411 |
+
* @throws Twig_SupTwgSss_Error_Loader When the template cannot be found
|
412 |
+
* @throws Twig_SupTwgSss_Error_Runtime When a previously generated cache is corrupted
|
413 |
+
* @throws Twig_SupTwgSss_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_SupTwgSss_SourceContextLoaderInterface) {
|
442 |
+
$source = new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Template A template instance representing the given template name
|
486 |
*
|
487 |
+
* @throws Twig_SupTwgSss_Error_Loader When the template cannot be found
|
488 |
+
* @throws Twig_SupTwgSss_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_SupTwgSss_Loader_Chain(array(
|
495 |
+
new Twig_SupTwgSss_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_SupTwgSss_TemplateInterface instances and an array
|
546 |
* of templates where each is tried to be loaded.
|
547 |
*
|
548 |
+
* @param string|Twig_SupTwgSss_Template|array $names A template or an array of templates to try consecutively
|
549 |
*
|
550 |
+
* @return Twig_SupTwgSss_Template
|
551 |
*
|
552 |
+
* @throws Twig_SupTwgSss_Error_Loader When none of the templates can be found
|
553 |
+
* @throws Twig_SupTwgSss_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_SupTwgSss_Template) {
|
563 |
return $name;
|
564 |
}
|
565 |
|
566 |
try {
|
567 |
return $this->loadTemplate($name);
|
568 |
+
} catch (Twig_SupTwgSss_Error_Loader $e) {
|
569 |
}
|
570 |
}
|
571 |
|
573 |
throw $e;
|
574 |
}
|
575 |
|
576 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Lexer($this);
|
622 |
}
|
623 |
|
624 |
return $this->lexer;
|
625 |
}
|
626 |
|
627 |
+
public function setLexer(Twig_SupTwgSss_LexerInterface $lexer)
|
628 |
{
|
629 |
$this->lexer = $lexer;
|
630 |
}
|
632 |
/**
|
633 |
* Tokenizes a source code.
|
634 |
*
|
635 |
+
* @param string|Twig_SupTwgSss_Source $source The template source code
|
636 |
* @param string $name The template name (deprecated)
|
637 |
*
|
638 |
+
* @return Twig_SupTwgSss_TokenStream
|
639 |
*
|
640 |
+
* @throws Twig_SupTwgSss_Error_Syntax When the code is syntactically wrong
|
641 |
*/
|
642 |
public function tokenize($source, $name = null)
|
643 |
{
|
644 |
+
if (!$source instanceof Twig_SupTwgSss_Source) {
|
645 |
+
//@trigger_error(sprintf('Passing a string as the $source argument of %s() is deprecated since version 1.27. Pass a Twig_SupTwgSss_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
646 |
+
$source = new Twig_SupTwgSss_Source($source, $name);
|
647 |
}
|
648 |
|
649 |
if (null === $this->lexer) {
|
650 |
+
$this->lexer = new Twig_SupTwgSss_Lexer($this);
|
651 |
}
|
652 |
|
653 |
return $this->lexer->tokenize($source);
|
656 |
/**
|
657 |
* Gets the Parser instance.
|
658 |
*
|
659 |
+
* @return Twig_SupTwgSss_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_SupTwgSss_Parser($this);
|
669 |
}
|
670 |
|
671 |
return $this->parser;
|
672 |
}
|
673 |
|
674 |
+
public function setParser(Twig_SupTwgSss_ParserInterface $parser)
|
675 |
{
|
676 |
$this->parser = $parser;
|
677 |
}
|
679 |
/**
|
680 |
* Converts a token stream to a node tree.
|
681 |
*
|
682 |
+
* @return Twig_SupTwgSss_Node_Module
|
683 |
*
|
684 |
+
* @throws Twig_SupTwgSss_Error_Syntax When the token stream is syntactically or semantically wrong
|
685 |
*/
|
686 |
+
public function parse(Twig_SupTwgSss_TokenStream $stream)
|
687 |
{
|
688 |
if (null === $this->parser) {
|
689 |
+
$this->parser = new Twig_SupTwgSss_Parser($this);
|
690 |
}
|
691 |
|
692 |
return $this->parser->parse($stream);
|
695 |
/**
|
696 |
* Gets the Compiler instance.
|
697 |
*
|
698 |
+
* @return Twig_SupTwgSss_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_SupTwgSss_Compiler($this);
|
708 |
}
|
709 |
|
710 |
return $this->compiler;
|
711 |
}
|
712 |
|
713 |
+
public function setCompiler(Twig_SupTwgSss_CompilerInterface $compiler)
|
714 |
{
|
715 |
$this->compiler = $compiler;
|
716 |
}
|
720 |
*
|
721 |
* @return string The compiled PHP source code
|
722 |
*/
|
723 |
+
public function compile(Twig_SupTwgSss_NodeInterface $node)
|
724 |
{
|
725 |
if (null === $this->compiler) {
|
726 |
+
$this->compiler = new Twig_SupTwgSss_Compiler($this);
|
727 |
}
|
728 |
|
729 |
return $this->compiler->compile($node)->getSource();
|
732 |
/**
|
733 |
* Compiles a template source code.
|
734 |
*
|
735 |
+
* @param string|Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Source) {
|
745 |
+
//@trigger_error(sprintf('Passing a string as the $source argument of %s() is deprecated since version 1.27. Pass a Twig_SupTwgSss_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
746 |
+
$source = new Twig_SupTwgSss_Source($source, $name);
|
747 |
}
|
748 |
|
749 |
try {
|
750 |
return $this->compile($this->parse($this->tokenize($source)));
|
751 |
+
} catch (Twig_SupTwgSss_Error $e) {
|
752 |
$e->setSourceContext($source);
|
753 |
throw $e;
|
754 |
} catch (Exception $e) {
|
755 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_LoaderInterface $loader)
|
760 |
{
|
761 |
+
if (!$loader instanceof Twig_SupTwgSss_SourceContextLoaderInterface && 0 !== strpos(get_class($loader), 'Mock_Twig_SupTwgSss_LoaderInterface')) {
|
762 |
+
//@trigger_error(sprintf('Twig loader "%s" should implement Twig_SupTwgSss_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_SupTwgSss_LoaderInterface
|
772 |
*/
|
773 |
public function getLoader()
|
774 |
{
|
809 |
$this->runtimeInitialized = true;
|
810 |
|
811 |
foreach ($this->getExtensions() as $name => $extension) {
|
812 |
+
if (!$extension instanceof Twig_SupTwgSss_Extension_InitRuntimeInterface) {
|
813 |
$m = new ReflectionMethod($extension, 'initRuntime');
|
814 |
|
815 |
+
if ('Twig_SupTwgSss_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_SupTwgSss_Environment instance in filters, functions, or tests; or explicitly implement Twig_SupTwgSss_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_SupTwgSss_RuntimeLoaderInterface $loader)
|
849 |
{
|
850 |
$this->runtimeLoaders[] = $loader;
|
851 |
}
|
855 |
*
|
856 |
* @param string $class The extension class name
|
857 |
*
|
858 |
+
* @return Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Error_Runtime When the template cannot be found
|
887 |
*/
|
888 |
public function getRuntime($class)
|
889 |
{
|
897 |
}
|
898 |
}
|
899 |
|
900 |
+
throw new Twig_SupTwgSss_Error_Runtime(sprintf('Unable to load the "%s" runtime.', $class));
|
901 |
}
|
902 |
|
903 |
+
public function addExtension(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_TokenParserBrokerInterface
|
988 |
*
|
989 |
* @internal
|
990 |
*/
|
1000 |
/**
|
1001 |
* Gets registered tags.
|
1002 |
*
|
1003 |
+
* Be warned that this method cannot return tags defined by Twig_SupTwgSss_TokenParserBrokerInterface classes.
|
1004 |
*
|
1005 |
+
* @return Twig_SupTwgSss_TokenParserInterface[]
|
1006 |
*
|
1007 |
* @internal
|
1008 |
*/
|
1010 |
{
|
1011 |
$tags = array();
|
1012 |
foreach ($this->getTokenParsers()->getParsers() as $parser) {
|
1013 |
+
if ($parser instanceof Twig_SupTwgSss_TokenParserInterface) {
|
1014 |
$tags[$parser->getTag()] = $parser;
|
1015 |
}
|
1016 |
}
|
1018 |
return $tags;
|
1019 |
}
|
1020 |
|
1021 |
+
public function addNodeVisitor(Twig_SupTwgSss_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_SupTwgSss_NodeVisitorInterface[]
|
1034 |
*
|
1035 |
* @internal
|
1036 |
*/
|
1046 |
/**
|
1047 |
* Registers a Filter.
|
1048 |
*
|
1049 |
+
* @param string|Twig_SupTwgSss_SimpleFilter $name The filter name or a Twig_SupTwgSss_SimpleFilter instance
|
1050 |
+
* @param Twig_SupTwgSss_FilterInterface|Twig_SupTwgSss_SimpleFilter $filter
|
1051 |
*/
|
1052 |
public function addFilter($name, $filter = null)
|
1053 |
{
|
1054 |
+
if (!$name instanceof Twig_SupTwgSss_SimpleFilter && !($filter instanceof Twig_SupTwgSss_SimpleFilter || $filter instanceof Twig_SupTwgSss_FilterInterface)) {
|
1055 |
+
throw new LogicException('A filter must be an instance of Twig_SupTwgSss_FilterInterface or Twig_SupTwgSss_SimpleFilter.');
|
1056 |
}
|
1057 |
|
1058 |
+
if ($name instanceof Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Filter|false A Twig_SupTwgSss_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_SupTwgSss_FilterInterface[]
|
1127 |
*
|
1128 |
* @see registerUndefinedFilterCallback
|
1129 |
*
|
1141 |
/**
|
1142 |
* Registers a Test.
|
1143 |
*
|
1144 |
+
* @param string|Twig_SupTwgSss_SimpleTest $name The test name or a Twig_SupTwgSss_SimpleTest instance
|
1145 |
+
* @param Twig_SupTwgSss_TestInterface|Twig_SupTwgSss_SimpleTest $test A Twig_SupTwgSss_TestInterface instance or a Twig_SupTwgSss_SimpleTest instance
|
1146 |
*/
|
1147 |
public function addTest($name, $test = null)
|
1148 |
{
|
1149 |
+
if (!$name instanceof Twig_SupTwgSss_SimpleTest && !($test instanceof Twig_SupTwgSss_SimpleTest || $test instanceof Twig_SupTwgSss_TestInterface)) {
|
1150 |
+
throw new LogicException('A test must be an instance of Twig_SupTwgSss_TestInterface or Twig_SupTwgSss_SimpleTest.');
|
1151 |
}
|
1152 |
|
1153 |
+
if ($name instanceof Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_TestInterface[]
|
1171 |
*
|
1172 |
* @internal
|
1173 |
*/
|
1185 |
*
|
1186 |
* @param string $name The test name
|
1187 |
*
|
1188 |
+
* @return Twig_SupTwgSss_Test|false A Twig_SupTwgSss_Test instance or false if the test does not exist
|
1189 |
*
|
1190 |
* @internal
|
1191 |
*/
|
1205 |
/**
|
1206 |
* Registers a Function.
|
1207 |
*
|
1208 |
+
* @param string|Twig_SupTwgSss_SimpleFunction $name The function name or a Twig_SupTwgSss_SimpleFunction instance
|
1209 |
+
* @param Twig_SupTwgSss_FunctionInterface|Twig_SupTwgSss_SimpleFunction $function
|
1210 |
*/
|
1211 |
public function addFunction($name, $function = null)
|
1212 |
{
|
1213 |
+
if (!$name instanceof Twig_SupTwgSss_SimpleFunction && !($function instanceof Twig_SupTwgSss_SimpleFunction || $function instanceof Twig_SupTwgSss_FunctionInterface)) {
|
1214 |
+
throw new LogicException('A function must be an instance of Twig_SupTwgSss_FunctionInterface or Twig_SupTwgSss_SimpleFunction.');
|
1215 |
}
|
1216 |
|
1217 |
+
if ($name instanceof Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Function|false A Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Error_Syntax::computeAlternatives($name, $items);
|
1411 |
}
|
1412 |
|
1413 |
/**
|
1417 |
{
|
1418 |
$globals = array();
|
1419 |
foreach ($this->extensions as $name => $extension) {
|
1420 |
+
if (!$extension instanceof Twig_SupTwgSss_Extension_GlobalsInterface) {
|
1421 |
$m = new ReflectionMethod($extension, 'getGlobals');
|
1422 |
|
1423 |
+
if ('Twig_SupTwgSss_Extension' !== $m->getDeclaringClass()->getName()) {
|
1424 |
+
//@trigger_error(sprintf('Defining the getGlobals() method in the "%s" extension without explicitly implementing Twig_SupTwgSss_Extension_GlobalsInterface is deprecated since version 1.23.', $name), E_USER_DEPRECATED);
|
1425 |
}
|
1426 |
}
|
1427 |
|
1447 |
return;
|
1448 |
}
|
1449 |
|
1450 |
+
$this->parsers = new Twig_SupTwgSss_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_SupTwgSss_ExtensionInterface $extension)
|
1470 |
{
|
1471 |
// filters
|
1472 |
foreach ($extension->getFilters() as $name => $filter) {
|
1473 |
+
if ($filter instanceof Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_TokenParserInterface) {
|
1507 |
$this->parsers->addTokenParser($parser);
|
1508 |
+
} elseif ($parser instanceof Twig_SupTwgSss_TokenParserBrokerInterface) {
|
1509 |
+
//@trigger_error('Registering a Twig_SupTwgSss_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_SupTwgSss_TokenParserInterface or Twig_SupTwgSss_TokenParserBrokerInterface instances.');
|
1514 |
}
|
1515 |
}
|
1516 |
|
1547 |
$hashParts = array_merge(
|
1548 |
array_keys($this->extensions),
|
1549 |
array(
|
1550 |
+
(int) function_exists('Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Source|null
|
190 |
*/
|
191 |
public function getSourceContext()
|
192 |
{
|
193 |
+
return $this->filename ? new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Template && 'Twig_SupTwgSss_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_SupTwgSss_Template::displayWithErrorHandling().
|
20 |
*
|
21 |
+
* This strategy makes Twig_SupTwgSss_Environment::resolveTemplate() much faster.
|
22 |
*
|
23 |
* @author Fabien Potencier <fabien@symfony.com>
|
24 |
*/
|
25 |
+
class Twig_SupTwgSss_Error_Loader extends Twig_SupTwgSss_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_SupTwgSss_Error_Runtime extends Twig_SupTwgSss_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_SupTwgSss_Error_Syntax extends Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_ExpressionParser
|
26 |
{
|
27 |
const OPERATOR_LEFT = 1;
|
28 |
const OPERATOR_RIGHT = 2;
|
33 |
|
34 |
private $env;
|
35 |
|
36 |
+
public function __construct(Twig_SupTwgSss_Parser $parser, $env = null)
|
37 |
{
|
38 |
$this->parser = $parser;
|
39 |
|
40 |
+
if ($env instanceof Twig_SupTwgSss_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_SupTwgSss_Token::PUNCTUATION_TYPE, '(')) {
|
95 |
$this->parser->getStream()->next();
|
96 |
$expr = $this->parseExpression();
|
97 |
+
$this->parser->getStream()->expect(Twig_SupTwgSss_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_SupTwgSss_Token::PUNCTUATION_TYPE, '?')) {
|
108 |
+
if (!$this->parser->getStream()->nextIf(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, ':')) {
|
109 |
$expr2 = $this->parseExpression();
|
110 |
+
if ($this->parser->getStream()->nextIf(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, ':')) {
|
111 |
$expr3 = $this->parseExpression();
|
112 |
} else {
|
113 |
+
$expr3 = new Twig_SupTwgSss_Node_Expression_Constant('', $this->parser->getCurrentToken()->getLine());
|
114 |
}
|
115 |
} else {
|
116 |
$expr2 = $expr;
|
117 |
$expr3 = $this->parseExpression();
|
118 |
}
|
119 |
|
120 |
+
$expr = new Twig_SupTwgSss_Node_Expression_Conditional($expr, $expr2, $expr3, $this->parser->getCurrentToken()->getLine());
|
121 |
}
|
122 |
|
123 |
return $expr;
|
124 |
}
|
125 |
|
126 |
+
protected function isUnary(Twig_SupTwgSss_Token $token)
|
127 |
{
|
128 |
+
return $token->test(Twig_SupTwgSss_Token::OPERATOR_TYPE) && isset($this->unaryOperators[$token->getValue()]);
|
129 |
}
|
130 |
|
131 |
+
protected function isBinary(Twig_SupTwgSss_Token $token)
|
132 |
{
|
133 |
+
return $token->test(Twig_SupTwgSss_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_SupTwgSss_Token::NAME_TYPE:
|
141 |
$this->parser->getStream()->next();
|
142 |
switch ($token->getValue()) {
|
143 |
case 'true':
|
144 |
case 'TRUE':
|
145 |
+
$node = new Twig_SupTwgSss_Node_Expression_Constant(true, $token->getLine());
|
146 |
break;
|
147 |
|
148 |
case 'false':
|
149 |
case 'FALSE':
|
150 |
+
$node = new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression_Name($token->getValue(), $token->getLine());
|
165 |
}
|
166 |
}
|
167 |
break;
|
168 |
|
169 |
+
case Twig_SupTwgSss_Token::NUMBER_TYPE:
|
170 |
$this->parser->getStream()->next();
|
171 |
+
$node = new Twig_SupTwgSss_Node_Expression_Constant($token->getValue(), $token->getLine());
|
172 |
break;
|
173 |
|
174 |
+
case Twig_SupTwgSss_Token::STRING_TYPE:
|
175 |
+
case Twig_SupTwgSss_Token::INTERPOLATION_START_TYPE:
|
176 |
$node = $this->parseStringExpression();
|
177 |
break;
|
178 |
|
179 |
+
case Twig_SupTwgSss_Token::OPERATOR_TYPE:
|
180 |
+
if (preg_match(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression_Unary_Neg';
|
190 |
+
$posClass = 'Twig_SupTwgSss_Node_Expression_Unary_Pos';
|
191 |
if (!(in_array($ref->getName(), array($negClass, $posClass)) || $ref->isSubclassOf($negClass) || $ref->isSubclassOf($posClass))) {
|
192 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_Token::PUNCTUATION_TYPE, '[')) {
|
204 |
$node = $this->parseArrayExpression();
|
205 |
+
} elseif ($token->test(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, '{')) {
|
206 |
$node = $this->parseHashExpression();
|
207 |
} else {
|
208 |
+
throw new Twig_SupTwgSss_Error_Syntax(sprintf('Unexpected token "%s" of value "%s".', Twig_SupTwgSss_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_SupTwgSss_Token::STRING_TYPE)) {
|
224 |
+
$nodes[] = new Twig_SupTwgSss_Node_Expression_Constant($token->getValue(), $token->getLine());
|
225 |
$nextCanBeString = false;
|
226 |
+
} elseif ($stream->nextIf(Twig_SupTwgSss_Token::INTERPOLATION_START_TYPE)) {
|
227 |
$nodes[] = $this->parseExpression();
|
228 |
+
$stream->expect(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Token::PUNCTUATION_TYPE, '[', 'An array element was expected');
|
247 |
|
248 |
+
$node = new Twig_SupTwgSss_Node_Expression_Array(array(), $stream->getCurrent()->getLine());
|
249 |
$first = true;
|
250 |
+
while (!$stream->test(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, ']')) {
|
251 |
if (!$first) {
|
252 |
+
$stream->expect(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, ',', 'An array element must be followed by a comma');
|
253 |
|
254 |
// trailing ,?
|
255 |
+
if ($stream->test(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, ']')) {
|
256 |
break;
|
257 |
}
|
258 |
}
|
260 |
|
261 |
$node->addElement($this->parseExpression());
|
262 |
}
|
263 |
+
$stream->expect(Twig_SupTwgSss_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_SupTwgSss_Token::PUNCTUATION_TYPE, '{', 'A hash element was expected');
|
272 |
|
273 |
+
$node = new Twig_SupTwgSss_Node_Expression_Array(array(), $stream->getCurrent()->getLine());
|
274 |
$first = true;
|
275 |
+
while (!$stream->test(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, '}')) {
|
276 |
if (!$first) {
|
277 |
+
$stream->expect(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, ',', 'A hash value must be followed by a comma');
|
278 |
|
279 |
// trailing ,?
|
280 |
+
if ($stream->test(Twig_SupTwgSss_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_SupTwgSss_Token::STRING_TYPE)) || ($token = $stream->nextIf(Twig_SupTwgSss_Token::NAME_TYPE)) || $token = $stream->nextIf(Twig_SupTwgSss_Token::NUMBER_TYPE)) {
|
293 |
+
$key = new Twig_SupTwgSss_Node_Expression_Constant($token->getValue(), $token->getLine());
|
294 |
+
} elseif ($stream->test(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, '(')) {
|
295 |
$key = $this->parseExpression();
|
296 |
} else {
|
297 |
$current = $stream->getCurrent();
|
298 |
|
299 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_Token::typeToEnglish($current->getType()), $current->getValue()), $current->getLine(), $stream->getSourceContext());
|
300 |
}
|
301 |
|
302 |
+
$stream->expect(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression_Parent($this->parser->peekBlockStack(), $line);
|
346 |
case 'block':
|
347 |
$args = $this->parseArguments();
|
348 |
if (count($args) < 1) {
|
349 |
+
throw new Twig_SupTwgSss_Error_Syntax('The "block" function takes one argument (the block name).', $line, $this->parser->getStream()->getSourceContext());
|
350 |
}
|
351 |
|
352 |
+
return new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression_GetAttr($args->getNode(0), $args->getNode(1), count($args) > 2 ? $args->getNode(2) : null, Twig_SupTwgSss_Template::ANY_CALL, $line);
|
360 |
default:
|
361 |
if (null !== $alias = $this->parser->getImportedSymbol('function', $name)) {
|
362 |
+
$arguments = new Twig_SupTwgSss_Node_Expression_Array(array(), $line);
|
363 |
foreach ($this->parseArguments() as $n) {
|
364 |
$arguments->addElement($n);
|
365 |
}
|
366 |
|
367 |
+
$node = new Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Array(array(), $lineno);
|
386 |
+
$type = Twig_SupTwgSss_Template::ANY_CALL;
|
387 |
if ($token->getValue() == '.') {
|
388 |
$token = $stream->next();
|
389 |
if (
|
390 |
+
$token->getType() == Twig_SupTwgSss_Token::NAME_TYPE
|
391 |
||
|
392 |
+
$token->getType() == Twig_SupTwgSss_Token::NUMBER_TYPE
|
393 |
||
|
394 |
+
($token->getType() == Twig_SupTwgSss_Token::OPERATOR_TYPE && preg_match(Twig_SupTwgSss_Lexer::REGEX_NAME, $token->getValue()))
|
395 |
) {
|
396 |
+
$arg = new Twig_SupTwgSss_Node_Expression_Constant($token->getValue(), $lineno);
|
397 |
|
398 |
+
if ($stream->test(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, '(')) {
|
399 |
+
$type = Twig_SupTwgSss_Template::METHOD_CALL;
|
400 |
foreach ($this->parseArguments() as $n) {
|
401 |
$arguments->addElement($n);
|
402 |
}
|
403 |
}
|
404 |
} else {
|
405 |
+
throw new Twig_SupTwgSss_Error_Syntax('Expected name or number.', $lineno, $stream->getSourceContext());
|
406 |
}
|
407 |
|
408 |
+
if ($node instanceof Twig_SupTwgSss_Node_Expression_Name && null !== $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) {
|
409 |
+
if (!$arg instanceof Twig_SupTwgSss_Node_Expression_Constant) {
|
410 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression_MethodCall($node, 'get'.$name, $arguments, $lineno);
|
420 |
$node->setAttribute('safe', true);
|
421 |
|
422 |
return $node;
|
423 |
}
|
424 |
} else {
|
425 |
+
$type = Twig_SupTwgSss_Template::ARRAY_CALL;
|
426 |
|
427 |
// slice?
|
428 |
$slice = false;
|
429 |
+
if ($stream->test(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, ':')) {
|
430 |
$slice = true;
|
431 |
+
$arg = new Twig_SupTwgSss_Node_Expression_Constant(0, $token->getLine());
|
432 |
} else {
|
433 |
$arg = $this->parseExpression();
|
434 |
}
|
435 |
|
436 |
+
if ($stream->nextIf(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, ':')) {
|
437 |
$slice = true;
|
438 |
}
|
439 |
|
440 |
if ($slice) {
|
441 |
+
if ($stream->test(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, ']')) {
|
442 |
+
$length = new Twig_SupTwgSss_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_SupTwgSss_Node(array($arg, $length));
|
449 |
+
$filter = new $class($node, new Twig_SupTwgSss_Node_Expression_Constant('slice', $token->getLine()), $arguments, $token->getLine());
|
450 |
|
451 |
+
$stream->expect(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, ']');
|
452 |
|
453 |
return $filter;
|
454 |
}
|
455 |
|
456 |
+
$stream->expect(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, ']');
|
457 |
}
|
458 |
|
459 |
+
return new Twig_SupTwgSss_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_SupTwgSss_Token::NAME_TYPE);
|
473 |
|
474 |
+
$name = new Twig_SupTwgSss_Node_Expression_Constant($token->getValue(), $token->getLine());
|
475 |
+
if (!$this->parser->getStream()->test(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, '(')) {
|
476 |
+
$arguments = new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node
|
502 |
*
|
503 |
+
* @throws Twig_SupTwgSss_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_SupTwgSss_Token::PUNCTUATION_TYPE, '(', 'A list of arguments must begin with an opening parenthesis');
|
511 |
+
while (!$stream->test(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, ')')) {
|
512 |
if (!empty($args)) {
|
513 |
+
$stream->expect(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, ',', 'Arguments must be separated by a comma');
|
514 |
}
|
515 |
|
516 |
if ($definition) {
|
517 |
+
$token = $stream->expect(Twig_SupTwgSss_Token::NAME_TYPE, null, 'An argument must be a name');
|
518 |
+
$value = new Twig_SupTwgSss_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_SupTwgSss_Token::OPERATOR_TYPE, '=')) {
|
525 |
+
if (!$value instanceof Twig_SupTwgSss_Node_Expression_Name) {
|
526 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression_Constant(null, $this->parser->getCurrentToken()->getLine());
|
545 |
}
|
546 |
$args[$name] = $value;
|
547 |
} else {
|
552 |
}
|
553 |
}
|
554 |
}
|
555 |
+
$stream->expect(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, ')', 'A list of arguments must be closed by a parenthesis');
|
556 |
|
557 |
+
return new Twig_SupTwgSss_Node($args);
|
558 |
}
|
559 |
|
560 |
public function parseAssignmentExpression()
|
562 |
$stream = $this->parser->getStream();
|
563 |
$targets = array();
|
564 |
while (true) {
|
565 |
+
$token = $stream->expect(Twig_SupTwgSss_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_SupTwgSss_Error_Syntax(sprintf('You cannot assign a value to "%s".', $value), $token->getLine(), $stream->getSourceContext());
|
569 |
}
|
570 |
+
$targets[] = new Twig_SupTwgSss_Node_Expression_AssignName($value, $token->getLine());
|
571 |
|
572 |
+
if (!$stream->nextIf(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, ',')) {
|
573 |
break;
|
574 |
}
|
575 |
}
|
576 |
|
577 |
+
return new Twig_SupTwgSss_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_SupTwgSss_Token::PUNCTUATION_TYPE, ',')) {
|
586 |
break;
|
587 |
}
|
588 |
}
|
589 |
|
590 |
+
return new Twig_SupTwgSss_Node($targets);
|
591 |
}
|
592 |
|
593 |
+
private function parseNotTestExpression(Twig_SupTwgSss_NodeInterface $node)
|
594 |
{
|
595 |
+
return new Twig_SupTwgSss_Node_Expression_Unary_Not($this->parseTestExpression($node), $this->parser->getCurrentToken()->getLine());
|
596 |
}
|
597 |
|
598 |
+
private function parseTestExpression(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Token::NAME_TYPE)->getValue();
|
616 |
|
617 |
if ($test = $this->env->getTest($name)) {
|
618 |
return array($name, $test);
|
619 |
}
|
620 |
|
621 |
+
if ($stream->test(Twig_SupTwgSss_Token::NAME_TYPE)) {
|
622 |
// try 2-words tests
|
623 |
$name = $name.' '.$this->parser->getCurrentToken()->getValue();
|
624 |
|
629 |
}
|
630 |
}
|
631 |
|
632 |
+
$e = new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_SimpleTest) {
|
656 |
return $test->getNodeClass();
|
657 |
}
|
658 |
|
659 |
+
return $test instanceof Twig_SupTwgSss_Test_Node ? $test->getClass() : 'Twig_SupTwgSss_Node_Expression_Test';
|
660 |
}
|
661 |
|
662 |
protected function getFunctionNodeClass($name, $line)
|
663 |
{
|
664 |
if (false === $function = $this->env->getFunction($name)) {
|
665 |
+
$e = new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_SimpleFunction) {
|
686 |
return $function->getNodeClass();
|
687 |
}
|
688 |
|
689 |
+
return $function instanceof Twig_SupTwgSss_Function_Node ? $function->getClass() : 'Twig_SupTwgSss_Node_Expression_Function';
|
690 |
}
|
691 |
|
692 |
protected function getFilterNodeClass($name, $line)
|
693 |
{
|
694 |
if (false === $filter = $this->env->getFilter($name)) {
|
695 |
+
$e = new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_SimpleFilter) {
|
716 |
return $filter->getNodeClass();
|
717 |
}
|
718 |
|
719 |
+
return $filter instanceof Twig_SupTwgSss_Filter_Node ? $filter->getClass() : 'Twig_SupTwgSss_Node_Expression_Filter';
|
720 |
}
|
721 |
|
722 |
// checks that the node only contains "constant" elements
|
723 |
+
protected function checkConstantExpression(Twig_SupTwgSss_NodeInterface $node)
|
724 |
{
|
725 |
+
if (!($node instanceof Twig_SupTwgSss_Node_Expression_Constant || $node instanceof Twig_SupTwgSss_Node_Expression_Array
|
726 |
+
|| $node instanceof Twig_SupTwgSss_Node_Expression_Unary_Neg || $node instanceof Twig_SupTwgSss_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_SupTwgSss_Extension implements Twig_SupTwgSss_ExtensionInterface
|
12 |
{
|
13 |
/**
|
14 |
+
* @deprecated since 1.23 (to be removed in 2.0), implement Twig_SupTwgSss_Extension_InitRuntimeInterface instead
|
15 |
*/
|
16 |
+
public function initRuntime(Twig_SupTwgSss_Environment $environment)
|
17 |
{
|
18 |
}
|
19 |
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
+
* @deprecated since 1.23 (to be removed in 2.0), implement Twig_SupTwgSss_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";
|
@@ -966,14 +966,14 @@ function Twig_SupTwg_trim_filter($string, $characterMask = null, $side = 'both')
|
|
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_SupTwgSss_Extension_Core extends Twig_SupTwgSss_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_SupTwgSss_TokenParser_For(),
|
125 |
+
new Twig_SupTwgSss_TokenParser_If(),
|
126 |
+
new Twig_SupTwgSss_TokenParser_Extends(),
|
127 |
+
new Twig_SupTwgSss_TokenParser_Include(),
|
128 |
+
new Twig_SupTwgSss_TokenParser_Block(),
|
129 |
+
new Twig_SupTwgSss_TokenParser_Use(),
|
130 |
+
new Twig_SupTwgSss_TokenParser_Filter(),
|
131 |
+
new Twig_SupTwgSss_TokenParser_Macro(),
|
132 |
+
new Twig_SupTwgSss_TokenParser_Import(),
|
133 |
+
new Twig_SupTwgSss_TokenParser_From(),
|
134 |
+
new Twig_SupTwgSss_TokenParser_Set(),
|
135 |
+
new Twig_SupTwgSss_TokenParser_Spaceless(),
|
136 |
+
new Twig_SupTwgSss_TokenParser_Flush(),
|
137 |
+
new Twig_SupTwgSss_TokenParser_Do(),
|
138 |
+
new Twig_SupTwgSss_TokenParser_Embed(),
|
139 |
+
new Twig_SupTwgSss_TokenParser_With(),
|
140 |
);
|
141 |
}
|
142 |
|
144 |
{
|
145 |
$filters = array(
|
146 |
// formatting filters
|
147 |
+
new Twig_SupTwgSss_SimpleFilter('date', 'Twig_SupTwgSss_date_format_filter', array('needs_environment' => true)),
|
148 |
+
new Twig_SupTwgSss_SimpleFilter('date_modify', 'Twig_SupTwgSss_date_modify_filter', array('needs_environment' => true)),
|
149 |
+
new Twig_SupTwgSss_SimpleFilter('format', 'sprintf'),
|
150 |
+
new Twig_SupTwgSss_SimpleFilter('replace', 'Twig_SupTwgSss_replace_filter'),
|
151 |
+
new Twig_SupTwgSss_SimpleFilter('number_format', 'Twig_SupTwgSss_number_format_filter', array('needs_environment' => true)),
|
152 |
+
new Twig_SupTwgSss_SimpleFilter('abs', 'abs'),
|
153 |
+
new Twig_SupTwgSss_SimpleFilter('round', 'Twig_SupTwgSss_round'),
|
154 |
|
155 |
// encoding
|
156 |
+
new Twig_SupTwgSss_SimpleFilter('url_encode', 'Twig_SupTwgSss_urlencode_filter'),
|
157 |
+
new Twig_SupTwgSss_SimpleFilter('json_encode', 'Twig_SupTwgSss_jsonencode_filter'),
|
158 |
+
new Twig_SupTwgSss_SimpleFilter('convert_encoding', 'Twig_SupTwgSss_convert_encoding'),
|
159 |
|
160 |
// string filters
|
161 |
+
new Twig_SupTwgSss_SimpleFilter('title', 'Twig_SupTwgSss_title_string_filter', array('needs_environment' => true)),
|
162 |
+
new Twig_SupTwgSss_SimpleFilter('capitalize', 'Twig_SupTwgSss_capitalize_string_filter', array('needs_environment' => true)),
|
163 |
+
new Twig_SupTwgSss_SimpleFilter('upper', 'strtoupper'),
|
164 |
+
new Twig_SupTwgSss_SimpleFilter('lower', 'strtolower'),
|
165 |
+
new Twig_SupTwgSss_SimpleFilter('striptags', 'strip_tags'),
|
166 |
+
new Twig_SupTwgSss_SimpleFilter('trim', 'Twig_SupTwgSss_trim_filter'),
|
167 |
+
new Twig_SupTwgSss_SimpleFilter('nl2br', 'nl2br', array('pre_escape' => 'html', 'is_safe' => array('html'))),
|
168 |
|
169 |
// array helpers
|
170 |
+
new Twig_SupTwgSss_SimpleFilter('join', 'Twig_SupTwgSss_join_filter'),
|
171 |
+
new Twig_SupTwgSss_SimpleFilter('split', 'Twig_SupTwgSss_split_filter', array('needs_environment' => true)),
|
172 |
+
new Twig_SupTwgSss_SimpleFilter('sort', 'Twig_SupTwgSss_sort_filter'),
|
173 |
+
new Twig_SupTwgSss_SimpleFilter('merge', 'Twig_SupTwgSss_array_merge'),
|
174 |
+
new Twig_SupTwgSss_SimpleFilter('batch', 'Twig_SupTwgSss_array_batch'),
|
175 |
|
176 |
// string/array filters
|
177 |
+
new Twig_SupTwgSss_SimpleFilter('reverse', 'Twig_SupTwgSss_reverse_filter', array('needs_environment' => true)),
|
178 |
+
new Twig_SupTwgSss_SimpleFilter('length', 'Twig_SupTwgSss_length_filter', array('needs_environment' => true)),
|
179 |
+
new Twig_SupTwgSss_SimpleFilter('slice', 'Twig_SupTwgSss_slice', array('needs_environment' => true)),
|
180 |
+
new Twig_SupTwgSss_SimpleFilter('first', 'Twig_SupTwgSss_first', array('needs_environment' => true)),
|
181 |
+
new Twig_SupTwgSss_SimpleFilter('last', 'Twig_SupTwgSss_last', array('needs_environment' => true)),
|
182 |
|
183 |
// iteration and runtime
|
184 |
+
new Twig_SupTwgSss_SimpleFilter('default', '_Twig_SupTwgSss_default_filter', array('node_class' => 'Twig_SupTwgSss_Node_Expression_Filter_Default')),
|
185 |
+
new Twig_SupTwgSss_SimpleFilter('keys', 'Twig_SupTwgSss_get_array_keys_filter'),
|
186 |
|
187 |
// escaping
|
188 |
+
new Twig_SupTwgSss_SimpleFilter('escape', 'Twig_SupTwgSss_escape_filter', array('needs_environment' => true, 'is_safe_callback' => 'Twig_SupTwgSss_escape_filter_is_safe')),
|
189 |
+
new Twig_SupTwgSss_SimpleFilter('e', 'Twig_SupTwgSss_escape_filter', array('needs_environment' => true, 'is_safe_callback' => 'Twig_SupTwgSss_escape_filter_is_safe')),
|
190 |
);
|
191 |
|
192 |
if (function_exists('mb_get_info')) {
|
193 |
+
$filters[] = new Twig_SupTwgSss_SimpleFilter('upper', 'Twig_SupTwgSss_upper_filter', array('needs_environment' => true));
|
194 |
+
$filters[] = new Twig_SupTwgSss_SimpleFilter('lower', 'Twig_SupTwgSss_lower_filter', array('needs_environment' => true));
|
195 |
}
|
196 |
|
197 |
return $filters;
|
200 |
public function getFunctions()
|
201 |
{
|
202 |
return array(
|
203 |
+
new Twig_SupTwgSss_SimpleFunction('max', 'max'),
|
204 |
+
new Twig_SupTwgSss_SimpleFunction('min', 'min'),
|
205 |
+
new Twig_SupTwgSss_SimpleFunction('range', 'range'),
|
206 |
+
new Twig_SupTwgSss_SimpleFunction('constant', 'Twig_SupTwgSss_constant'),
|
207 |
+
new Twig_SupTwgSss_SimpleFunction('cycle', 'Twig_SupTwgSss_cycle'),
|
208 |
+
new Twig_SupTwgSss_SimpleFunction('random', 'Twig_SupTwgSss_random', array('needs_environment' => true)),
|
209 |
+
new Twig_SupTwgSss_SimpleFunction('date', 'Twig_SupTwgSss_date_converter', array('needs_environment' => true)),
|
210 |
+
new Twig_SupTwgSss_SimpleFunction('include', 'Twig_SupTwgSss_include', array('needs_environment' => true, 'needs_context' => true, 'is_safe' => array('all'))),
|
211 |
+
new Twig_SupTwgSss_SimpleFunction('source', 'Twig_SupTwgSss_source', array('needs_environment' => true, 'is_safe' => array('all'))),
|
212 |
);
|
213 |
}
|
214 |
|
215 |
public function getTests()
|
216 |
{
|
217 |
return array(
|
218 |
+
new Twig_SupTwgSss_SimpleTest('even', null, array('node_class' => 'Twig_SupTwgSss_Node_Expression_Test_Even')),
|
219 |
+
new Twig_SupTwgSss_SimpleTest('odd', null, array('node_class' => 'Twig_SupTwgSss_Node_Expression_Test_Odd')),
|
220 |
+
new Twig_SupTwgSss_SimpleTest('defined', null, array('node_class' => 'Twig_SupTwgSss_Node_Expression_Test_Defined')),
|
221 |
+
new Twig_SupTwgSss_SimpleTest('sameas', null, array('node_class' => 'Twig_SupTwgSss_Node_Expression_Test_Sameas', 'deprecated' => '1.21', 'alternative' => 'same as')),
|
222 |
+
new Twig_SupTwgSss_SimpleTest('same as', null, array('node_class' => 'Twig_SupTwgSss_Node_Expression_Test_Sameas')),
|
223 |
+
new Twig_SupTwgSss_SimpleTest('none', null, array('node_class' => 'Twig_SupTwgSss_Node_Expression_Test_Null')),
|
224 |
+
new Twig_SupTwgSss_SimpleTest('null', null, array('node_class' => 'Twig_SupTwgSss_Node_Expression_Test_Null')),
|
225 |
+
new Twig_SupTwgSss_SimpleTest('divisibleby', null, array('node_class' => 'Twig_SupTwgSss_Node_Expression_Test_Divisibleby', 'deprecated' => '1.21', 'alternative' => 'divisible by')),
|
226 |
+
new Twig_SupTwgSss_SimpleTest('divisible by', null, array('node_class' => 'Twig_SupTwgSss_Node_Expression_Test_Divisibleby')),
|
227 |
+
new Twig_SupTwgSss_SimpleTest('constant', null, array('node_class' => 'Twig_SupTwgSss_Node_Expression_Test_Constant')),
|
228 |
+
new Twig_SupTwgSss_SimpleTest('empty', 'Twig_SupTwgSss_test_empty'),
|
229 |
+
new Twig_SupTwgSss_SimpleTest('iterable', 'Twig_SupTwgSss_test_iterable'),
|
230 |
);
|
231 |
}
|
232 |
|
234 |
{
|
235 |
return array(
|
236 |
array(
|
237 |
+
'not' => array('precedence' => 50, 'class' => 'Twig_SupTwgSss_Node_Expression_Unary_Not'),
|
238 |
+
'-' => array('precedence' => 500, 'class' => 'Twig_SupTwgSss_Node_Expression_Unary_Neg'),
|
239 |
+
'+' => array('precedence' => 500, 'class' => 'Twig_SupTwgSss_Node_Expression_Unary_Pos'),
|
240 |
),
|
241 |
array(
|
242 |
+
'or' => array('precedence' => 10, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_Or', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
243 |
+
'and' => array('precedence' => 15, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_And', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
244 |
+
'b-or' => array('precedence' => 16, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_BitwiseOr', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
245 |
+
'b-xor' => array('precedence' => 17, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_BitwiseXor', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
246 |
+
'b-and' => array('precedence' => 18, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_BitwiseAnd', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
247 |
+
'==' => array('precedence' => 20, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_Equal', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
248 |
+
'!=' => array('precedence' => 20, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_NotEqual', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
249 |
+
'<' => array('precedence' => 20, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_Less', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
250 |
+
'>' => array('precedence' => 20, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_Greater', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
251 |
+
'>=' => array('precedence' => 20, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_GreaterEqual', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
252 |
+
'<=' => array('precedence' => 20, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_LessEqual', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
253 |
+
'not in' => array('precedence' => 20, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_NotIn', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
254 |
+
'in' => array('precedence' => 20, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_In', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
255 |
+
'matches' => array('precedence' => 20, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_Matches', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
256 |
+
'starts with' => array('precedence' => 20, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_StartsWith', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
257 |
+
'ends with' => array('precedence' => 20, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_EndsWith', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
258 |
+
'..' => array('precedence' => 25, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_Range', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
259 |
+
'+' => array('precedence' => 30, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_Add', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
260 |
+
'-' => array('precedence' => 30, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_Sub', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
261 |
+
'~' => array('precedence' => 40, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_Concat', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
262 |
+
'*' => array('precedence' => 60, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_Mul', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
263 |
+
'/' => array('precedence' => 60, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_Div', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
264 |
+
'//' => array('precedence' => 60, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_FloorDiv', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
265 |
+
'%' => array('precedence' => 60, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_Mod', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
266 |
+
'is' => array('precedence' => 100, 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
267 |
+
'is not' => array('precedence' => 100, 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_LEFT),
|
268 |
+
'**' => array('precedence' => 200, 'class' => 'Twig_SupTwgSss_Node_Expression_Binary_Power', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_RIGHT),
|
269 |
+
'??' => array('precedence' => 300, 'class' => 'Twig_SupTwgSss_Node_Expression_NullCoalesce', 'associativity' => Twig_SupTwgSss_ExpressionParser::OPERATOR_RIGHT),
|
270 |
),
|
271 |
);
|
272 |
}
|
285 |
*
|
286 |
* @return string The next value in the cycle
|
287 |
*/
|
288 |
+
function Twig_SupTwgSss_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_SupTwgSss_Environment $env
|
304 |
* @param Traversable|array|int|float|string $values The values to pick a random item from
|
305 |
*
|
306 |
+
* @throws Twig_SupTwgSss_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_SupTwgSss_random(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_convert_encoding($value, $charset, 'UTF-8');
|
338 |
}
|
339 |
}
|
340 |
} else {
|
347 |
}
|
348 |
|
349 |
if (0 === count($values)) {
|
350 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_date_format_filter(Twig_SupTwgSss_Environment $env, $date, $format = null, $timezone = null)
|
371 |
{
|
372 |
if (null === $format) {
|
373 |
+
$formats = $env->getExtension('Twig_SupTwgSss_Extension_Core')->getDateFormat();
|
374 |
$format = $date instanceof DateInterval ? $formats[1] : $formats[0];
|
375 |
}
|
376 |
|
378 |
return $date->format($format);
|
379 |
}
|
380 |
|
381 |
+
return Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_date_modify_filter(Twig_SupTwgSss_Environment $env, $date, $modifier)
|
398 |
{
|
399 |
+
$date = Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_date_converter(Twig_SupTwgSss_Environment $env, $date = null, $timezone = null)
|
424 |
{
|
425 |
// determine the timezone
|
426 |
if (false !== $timezone) {
|
427 |
if (null === $timezone) {
|
428 |
+
$timezone = $env->getExtension('Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Extension_Core')->getTimezone());
|
457 |
}
|
458 |
|
459 |
if (false !== $timezone) {
|
472 |
*
|
473 |
* @return string
|
474 |
*/
|
475 |
+
function Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_number_format_filter(Twig_SupTwgSss_Environment $env, $number, $decimal = null, $decimalPoint = null, $thousandSep = null)
|
528 |
{
|
529 |
+
$defaults = $env->getExtension('Twig_SupTwgSss_Extension_Core')->getNumberFormat();
|
530 |
if (null === $decimal) {
|
531 |
$decimal = $defaults[0];
|
532 |
}
|
549 |
*
|
550 |
* @return string The URL encoded value
|
551 |
*/
|
552 |
+
function Twig_SupTwgSss_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_SupTwgSss_jsonencode_filter($value, $options = 0)
|
575 |
{
|
576 |
+
if ($value instanceof Twig_SupTwgSss_Markup) {
|
577 |
$value = (string) $value;
|
578 |
} elseif (is_array($value)) {
|
579 |
+
array_walk_recursive($value, '_Twig_SupTwgSss_markup2string');
|
580 |
}
|
581 |
|
582 |
return json_encode($value);
|
590 |
*
|
591 |
* @return mixed The JSON encoded value
|
592 |
*/
|
593 |
+
function Twig_SupTwgSss_jsonencode_filter($value, $options = 0)
|
594 |
{
|
595 |
+
if ($value instanceof Twig_SupTwgSss_Markup) {
|
596 |
$value = (string) $value;
|
597 |
} elseif (is_array($value)) {
|
598 |
+
array_walk_recursive($value, '_Twig_SupTwgSss_markup2string');
|
599 |
}
|
600 |
|
601 |
return json_encode($value, $options);
|
602 |
}
|
603 |
}
|
604 |
|
605 |
+
function _Twig_SupTwgSss_markup2string(&$value)
|
606 |
{
|
607 |
+
if ($value instanceof Twig_SupTwgSss_Markup) {
|
608 |
$value = (string) $value;
|
609 |
}
|
610 |
}
|
625 |
*
|
626 |
* @return array The merged array
|
627 |
*/
|
628 |
+
function Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_slice(Twig_SupTwgSss_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_SupTwgSss_Environment $env
|
691 |
* @param mixed $item A variable
|
692 |
*
|
693 |
* @return mixed The first element of the item
|
694 |
*/
|
695 |
+
function Twig_SupTwgSss_first(Twig_SupTwgSss_Environment $env, $item)
|
696 |
{
|
697 |
+
$elements = Twig_SupTwgSss_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_SupTwgSss_Environment $env
|
706 |
* @param mixed $item A variable
|
707 |
*
|
708 |
* @return mixed The last element of the item
|
709 |
*/
|
710 |
+
function Twig_SupTwgSss_last(Twig_SupTwgSss_Environment $env, $item)
|
711 |
{
|
712 |
+
$elements = Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_split_filter(Twig_SupTwgSss_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_SupTwgSss_default_filter($value, $default = '')
|
802 |
{
|
803 |
+
if (Twig_SupTwgSss_test_empty($value)) {
|
804 |
return $default;
|
805 |
}
|
806 |
|
822 |
*
|
823 |
* @return array The keys
|
824 |
*/
|
825 |
+
function Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_reverse_filter(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_convert_encoding($string, $charset, 'UTF-8');
|
890 |
}
|
891 |
|
892 |
return $string;
|
902 |
*
|
903 |
* @return array
|
904 |
*/
|
905 |
+
function Twig_SupTwgSss_sort_filter($array)
|
906 |
{
|
907 |
if ($array instanceof Traversable) {
|
908 |
$array = iterator_to_array($array);
|
909 |
} elseif (!is_array($array)) {
|
910 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Error_Runtime When an invalid trimming side is used (not a string or not 'left', 'right', or 'both')
|
954 |
*/
|
955 |
+
function Twig_SupTwgSss_trim_filter($string, $characterMask = null, $side = 'both')
|
956 |
{
|
957 |
if (null === $characterMask) {
|
958 |
$characterMask = " \t\n\r\0\x0B";
|
966 |
case 'right':
|
967 |
return rtrim($string, $characterMask);
|
968 |
default:
|
969 |
+
throw new Twig_SupTwgSss_Error_Runtime('Trimming side must be "left", "right" or "both".');
|
970 |
}
|
971 |
}
|
972 |
|
973 |
/**
|
974 |
* Escapes a string.
|
975 |
*
|
976 |
+
* @param Twig_SupTwgSss_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_SupTwgSss_escape_filter(Twig_SupTwgSss_Environment $env, $string, $strategy = 'html', $charset = null, $autoescape = false)
|
985 |
{
|
986 |
+
if ($autoescape && $string instanceof Twig_SupTwgSss_Markup) {
|
987 |
return $string;
|
988 |
}
|
989 |
|
1042 |
return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
|
1043 |
}
|
1044 |
|
1045 |
+
$string = Twig_SupTwgSss_convert_encoding($string, 'UTF-8', $charset);
|
1046 |
$string = htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
1047 |
|
1048 |
+
return Twig_SupTwgSss_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_SupTwgSss_convert_encoding($string, 'UTF-8', $charset);
|
1055 |
}
|
1056 |
|
1057 |
if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
|
1058 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_escape_js_callback', $string);
|
1062 |
|
1063 |
if ('UTF-8' !== $charset) {
|
1064 |
+
$string = Twig_SupTwgSss_convert_encoding($string, $charset, 'UTF-8');
|
1065 |
}
|
1066 |
|
1067 |
return $string;
|
1068 |
|
1069 |
case 'css':
|
1070 |
if ('UTF-8' !== $charset) {
|
1071 |
+
$string = Twig_SupTwgSss_convert_encoding($string, 'UTF-8', $charset);
|
1072 |
}
|
1073 |
|
1074 |
if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
|
1075 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_escape_css_callback', $string);
|
1079 |
|
1080 |
if ('UTF-8' !== $charset) {
|
1081 |
+
$string = Twig_SupTwgSss_convert_encoding($string, $charset, 'UTF-8');
|
1082 |
}
|
1083 |
|
1084 |
return $string;
|
1085 |
|
1086 |
case 'html_attr':
|
1087 |
if ('UTF-8' !== $charset) {
|
1088 |
+
$string = Twig_SupTwgSss_convert_encoding($string, 'UTF-8', $charset);
|
1089 |
}
|
1090 |
|
1091 |
if (0 == strlen($string) ? false : 1 !== preg_match('/^./su', $string)) {
|
1092 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_escape_html_attr_callback', $string);
|
1096 |
|
1097 |
if ('UTF-8' !== $charset) {
|
1098 |
+
$string = Twig_SupTwgSss_convert_encoding($string, $charset, 'UTF-8');
|
1099 |
}
|
1100 |
|
1101 |
return $string;
|
1111 |
static $escapers;
|
1112 |
|
1113 |
if (null === $escapers) {
|
1114 |
+
$escapers = $env->getExtension('Twig_SupTwgSss_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_SupTwgSss_Error_Runtime(sprintf('Invalid escaping strategy "%s" (valid ones: %s).', $strategy, $validStrategies));
|
1124 |
}
|
1125 |
}
|
1126 |
|
1127 |
/**
|
1128 |
* @internal
|
1129 |
*/
|
1130 |
+
function Twig_SupTwgSss_escape_filter_is_safe(Twig_SupTwgSss_Node $filterArgs)
|
1131 |
{
|
1132 |
foreach ($filterArgs as $arg) {
|
1133 |
+
if ($arg instanceof Twig_SupTwgSss_Node_Expression_Constant) {
|
1134 |
return array($arg->getAttribute('value'));
|
1135 |
}
|
1136 |
|
1141 |
}
|
1142 |
|
1143 |
if (function_exists('mb_convert_encoding')) {
|
1144 |
+
function Twig_SupTwgSss_convert_encoding($string, $to, $from)
|
1145 |
{
|
1146 |
return mb_convert_encoding($string, $to, $from);
|
1147 |
}
|
1148 |
} elseif (function_exists('iconv')) {
|
1149 |
+
function Twig_SupTwgSss_convert_encoding($string, $to, $from)
|
1150 |
{
|
1151 |
return iconv($from, $to, $string);
|
1152 |
}
|
1153 |
} else {
|
1154 |
+
function Twig_SupTwgSss_convert_encoding($string, $to, $from)
|
1155 |
{
|
1156 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_escape_js_callback($matches)
|
1161 |
{
|
1162 |
$char = $matches[0];
|
1163 |
|
1167 |
}
|
1168 |
|
1169 |
// \uHHHH
|
1170 |
+
$char = Twig_SupTwgSss_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_SupTwgSss_escape_css_callback($matches)
|
1181 |
{
|
1182 |
$char = $matches[0];
|
1183 |
|
1192 |
}
|
1193 |
|
1194 |
// \uHHHH
|
1195 |
+
$char = Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Environment $env
|
1261 |
* @param mixed $thing A variable
|
1262 |
*
|
1263 |
* @return int The length of the value
|
1264 |
*/
|
1265 |
+
function Twig_SupTwgSss_length_filter(Twig_SupTwgSss_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_SupTwgSss_Environment $env
|
1288 |
* @param string $string A string
|
1289 |
*
|
1290 |
* @return string The uppercased string
|
1291 |
*/
|
1292 |
+
function Twig_SupTwgSss_upper_filter(Twig_SupTwgSss_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_SupTwgSss_Environment $env
|
1305 |
* @param string $string A string
|
1306 |
*
|
1307 |
* @return string The lowercased string
|
1308 |
*/
|
1309 |
+
function Twig_SupTwgSss_lower_filter(Twig_SupTwgSss_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_SupTwgSss_Environment $env
|
1322 |
* @param string $string A string
|
1323 |
*
|
1324 |
* @return string The titlecased string
|
1325 |
*/
|
1326 |
+
function Twig_SupTwgSss_title_string_filter(Twig_SupTwgSss_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_SupTwgSss_Environment $env
|
1339 |
* @param string $string A string
|
1340 |
*
|
1341 |
* @return string The capitalized string
|
1342 |
*/
|
1343 |
+
function Twig_SupTwgSss_capitalize_string_filter(Twig_SupTwgSss_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_SupTwgSss_Environment $env
|
1358 |
* @param mixed $thing A variable
|
1359 |
*
|
1360 |
* @return int The length of the value
|
1361 |
*/
|
1362 |
+
function Twig_SupTwgSss_length_filter(Twig_SupTwgSss_Environment $env, $thing)
|
1363 |
{
|
1364 |
if (is_scalar($thing)) {
|
1365 |
return strlen($thing);
|
1375 |
/**
|
1376 |
* Returns a titlecased string.
|
1377 |
*
|
1378 |
+
* @param Twig_SupTwgSss_Environment $env
|
1379 |
* @param string $string A string
|
1380 |
*
|
1381 |
* @return string The titlecased string
|
1382 |
*/
|
1383 |
+
function Twig_SupTwgSss_title_string_filter(Twig_SupTwgSss_Environment $env, $string)
|
1384 |
{
|
1385 |
return ucwords(strtolower($string));
|
1386 |
}
|
1388 |
/**
|
1389 |
* Returns a capitalized string.
|
1390 |
*
|
1391 |
+
* @param Twig_SupTwgSss_Environment $env
|
1392 |
* @param string $string A string
|
1393 |
*
|
1394 |
* @return string The capitalized string
|
1395 |
*/
|
1396 |
+
function Twig_SupTwgSss_capitalize_string_filter(Twig_SupTwgSss_Environment $env, $string)
|
1397 |
{
|
1398 |
return ucfirst(strtolower($string));
|
1399 |
}
|
1402 |
/**
|
1403 |
* @internal
|
1404 |
*/
|
1405 |
+
function Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_test_iterable($value)
|
1456 |
{
|
1457 |
return $value instanceof Traversable || is_array($value);
|
1458 |
}
|
1460 |
/**
|
1461 |
* Renders a template.
|
1462 |
*
|
1463 |
+
* @param Twig_SupTwgSss_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_SupTwgSss_include(Twig_SupTwgSss_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_SupTwgSss_Extension_Sandbox')) {
|
1482 |
+
$sandbox = $env->getExtension('Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_source(Twig_SupTwgSss_Environment $env, $name, $ignoreMissing = false)
|
1530 |
{
|
1531 |
$loader = $env->getLoader();
|
1532 |
try {
|
1533 |
+
if (!$loader instanceof Twig_SupTwgSss_SourceContextLoaderInterface) {
|
1534 |
return $loader->getSource($name);
|
1535 |
} else {
|
1536 |
return $loader->getSourceContext($name)->getCode();
|
1537 |
}
|
1538 |
+
} catch (Twig_SupTwgSss_Error_Loader $e) {
|
1539 |
if (!$ignoreMissing) {
|
1540 |
throw $e;
|
1541 |
}
|
1550 |
*
|
1551 |
* @return string
|
1552 |
*/
|
1553 |
+
function Twig_SupTwgSss_constant($constant, $object = null)
|
1554 |
{
|
1555 |
if (null !== $object) {
|
1556 |
$constant = get_class($object).'::'.$constant;
|
1567 |
*
|
1568 |
* @return bool
|
1569 |
*/
|
1570 |
+
function Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Extension_Debug extends Twig_SupTwgSss_Extension
|
16 |
{
|
17 |
public function getFunctions()
|
18 |
{
|
27 |
;
|
28 |
|
29 |
return array(
|
30 |
+
new Twig_SupTwgSss_SimpleFunction('dump', 'Twig_SupTwgSss_var_dump', array('is_safe' => $isDumpOutputHtmlSafe ? array('html') : array(), 'needs_context' => true, 'needs_environment' => true)),
|
31 |
);
|
32 |
}
|
33 |
|
37 |
}
|
38 |
}
|
39 |
|
40 |
+
function Twig_SupTwgSss_var_dump(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Extension_Escaper extends Twig_SupTwgSss_Extension
|
16 |
{
|
17 |
protected $defaultStrategy;
|
18 |
|
28 |
|
29 |
public function getTokenParsers()
|
30 |
{
|
31 |
+
return array(new Twig_SupTwgSss_TokenParser_AutoEscape());
|
32 |
}
|
33 |
|
34 |
public function getNodeVisitors()
|
35 |
{
|
36 |
+
return array(new Twig_SupTwgSss_NodeVisitor_Escaper());
|
37 |
}
|
38 |
|
39 |
public function getFilters()
|
40 |
{
|
41 |
return array(
|
42 |
+
new Twig_SupTwgSss_SimpleFilter('raw', 'Twig_SupTwgSss_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_SupTwgSss_FileExtensionEscapingStrategy', 'guess');
|
71 |
}
|
72 |
|
73 |
$this->defaultStrategy = $defaultStrategy;
|
104 |
*
|
105 |
* @return string
|
106 |
*/
|
107 |
+
function Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Extension_Optimizer extends Twig_SupTwgSss_Extension
|
16 |
{
|
17 |
protected $optimizers;
|
18 |
|
23 |
|
24 |
public function getNodeVisitors()
|
25 |
{
|
26 |
+
return array(new Twig_SupTwgSss_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_SupTwgSss_Extension_Profiler extends Twig_SupTwgSss_Extension
|
13 |
{
|
14 |
private $actives = array();
|
15 |
|
16 |
+
public function __construct(Twig_SupTwgSss_Profiler_Profile $profile)
|
17 |
{
|
18 |
$this->actives[] = $profile;
|
19 |
}
|
20 |
|
21 |
+
public function enter(Twig_SupTwgSss_Profiler_Profile $profile)
|
22 |
{
|
23 |
$this->actives[0]->addProfile($profile);
|
24 |
array_unshift($this->actives, $profile);
|
25 |
}
|
26 |
|
27 |
+
public function leave(Twig_SupTwgSss_Profiler_Profile $profile)
|
28 |
{
|
29 |
$profile->leave();
|
30 |
array_shift($this->actives);
|
36 |
|
37 |
public function getNodeVisitors()
|
38 |
{
|
39 |
+
return array(new Twig_SupTwgSss_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_SupTwgSss_Extension_Sandbox extends Twig_SupTwgSss_Extension
|
16 |
{
|
17 |
protected $sandboxedGlobally;
|
18 |
protected $sandboxed;
|
19 |
protected $policy;
|
20 |
|
21 |
+
public function __construct(Twig_SupTwgSss_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_SupTwgSss_TokenParser_Sandbox());
|
30 |
}
|
31 |
|
32 |
public function getNodeVisitors()
|
33 |
{
|
34 |
+
return array(new Twig_SupTwgSss_NodeVisitor_Sandbox());
|
35 |
}
|
36 |
|
37 |
public function enableSandbox()
|
54 |
return $this->sandboxedGlobally;
|
55 |
}
|
56 |
|
57 |
+
public function setSecurityPolicy(Twig_SupTwgSss_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();
|
@@ -30,7 +30,7 @@ class Twig_SupTwg_Extension_Staging extends Twig_SupTwg_Extension
|
|
30 |
public function addFunction($name, $function)
|
31 |
{
|
32 |
if (isset($this->functions[$name])) {
|
33 |
-
|
34 |
}
|
35 |
|
36 |
$this->functions[$name] = $function;
|
@@ -44,7 +44,7 @@ class Twig_SupTwg_Extension_Staging extends Twig_SupTwg_Extension
|
|
44 |
public function addFilter($name, $filter)
|
45 |
{
|
46 |
if (isset($this->filters[$name])) {
|
47 |
-
|
48 |
}
|
49 |
|
50 |
$this->filters[$name] = $filter;
|
@@ -55,7 +55,7 @@ class Twig_SupTwg_Extension_Staging extends Twig_SupTwg_Extension
|
|
55 |
return $this->filters;
|
56 |
}
|
57 |
|
58 |
-
public function addNodeVisitor(
|
59 |
{
|
60 |
$this->visitors[] = $visitor;
|
61 |
}
|
@@ -65,10 +65,10 @@ class Twig_SupTwg_Extension_Staging extends Twig_SupTwg_Extension
|
|
65 |
return $this->visitors;
|
66 |
}
|
67 |
|
68 |
-
public function addTokenParser(
|
69 |
{
|
70 |
if (isset($this->tokenParsers[$parser->getTag()])) {
|
71 |
-
|
72 |
}
|
73 |
|
74 |
$this->tokenParsers[$parser->getTag()] = $parser;
|
@@ -92,7 +92,7 @@ class Twig_SupTwg_Extension_Staging extends Twig_SupTwg_Extension
|
|
92 |
public function addTest($name, $test)
|
93 |
{
|
94 |
if (isset($this->tests[$name])) {
|
95 |
-
|
96 |
}
|
97 |
|
98 |
$this->tests[$name] = $test;
|
12 |
/**
|
13 |
* Internal class.
|
14 |
*
|
15 |
+
* This class is used by Twig_SupTwgSss_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_SupTwgSss_Extension_Staging extends Twig_SupTwgSss_Extension
|
22 |
{
|
23 |
protected $functions = array();
|
24 |
protected $filters = array();
|
30 |
public function addFunction($name, $function)
|
31 |
{
|
32 |
if (isset($this->functions[$name])) {
|
33 |
+
//@trigger_error(sprintf('Overriding function "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $name), E_USER_DEPRECATED);
|
34 |
}
|
35 |
|
36 |
$this->functions[$name] = $function;
|
44 |
public function addFilter($name, $filter)
|
45 |
{
|
46 |
if (isset($this->filters[$name])) {
|
47 |
+
//@trigger_error(sprintf('Overriding filter "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $name), E_USER_DEPRECATED);
|
48 |
}
|
49 |
|
50 |
$this->filters[$name] = $filter;
|
55 |
return $this->filters;
|
56 |
}
|
57 |
|
58 |
+
public function addNodeVisitor(Twig_SupTwgSss_NodeVisitorInterface $visitor)
|
59 |
{
|
60 |
$this->visitors[] = $visitor;
|
61 |
}
|
65 |
return $this->visitors;
|
66 |
}
|
67 |
|
68 |
+
public function addTokenParser(Twig_SupTwgSss_TokenParserInterface $parser)
|
69 |
{
|
70 |
if (isset($this->tokenParsers[$parser->getTag()])) {
|
71 |
+
//@trigger_error(sprintf('Overriding tag "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $parser->getTag()), E_USER_DEPRECATED);
|
72 |
}
|
73 |
|
74 |
$this->tokenParsers[$parser->getTag()] = $parser;
|
92 |
public function addTest($name, $test)
|
93 |
{
|
94 |
if (isset($this->tests[$name])) {
|
95 |
+
//@trigger_error(sprintf('Overriding test "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $name), E_USER_DEPRECATED);
|
96 |
}
|
97 |
|
98 |
$this->tests[$name] = $test;
|
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_SupTwgSss_Extension_StringLoader extends Twig_SupTwgSss_Extension
|
16 |
{
|
17 |
public function getFunctions()
|
18 |
{
|
19 |
return array(
|
20 |
+
new Twig_SupTwgSss_SimpleFunction('template_from_string', 'Twig_SupTwgSss_template_from_string', array('needs_environment' => true)),
|
21 |
);
|
22 |
}
|
23 |
|
34 |
* {{ include(template_from_string("Hello {{ name }}")) }}
|
35 |
* </pre>
|
36 |
*
|
37 |
+
* @param Twig_SupTwgSss_Environment $env A Twig_SupTwgSss_Environment instance
|
38 |
* @param string $template A template as a string or object implementing __toString()
|
39 |
*
|
40 |
+
* @return Twig_SupTwgSss_Template
|
41 |
*/
|
42 |
+
function Twig_SupTwgSss_template_from_string(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Extension_InitRuntimeInterface instead
|
25 |
*/
|
26 |
+
public function initRuntime(Twig_SupTwgSss_Environment $environment);
|
27 |
|
28 |
/**
|
29 |
* Returns the token parser instances to add to the existing list.
|
30 |
*
|
31 |
+
* @return Twig_SupTwgSss_TokenParserInterface[]
|
32 |
*/
|
33 |
public function getTokenParsers();
|
34 |
|
35 |
/**
|
36 |
* Returns the node visitor instances to add to the existing list.
|
37 |
*
|
38 |
+
* @return Twig_SupTwgSss_NodeVisitorInterface[]
|
39 |
*/
|
40 |
public function getNodeVisitors();
|
41 |
|
42 |
/**
|
43 |
* Returns a list of filters to add to the existing list.
|
44 |
*
|
45 |
+
* @return Twig_SupTwgSss_SimpleFilter[]
|
46 |
*/
|
47 |
public function getFilters();
|
48 |
|
49 |
/**
|
50 |
* Returns a list of tests to add to the existing list.
|
51 |
*
|
52 |
+
* @return Twig_SupTwgSss_SimpleTest[]
|
53 |
*/
|
54 |
public function getTests();
|
55 |
|
56 |
/**
|
57 |
* Returns a list of functions to add to the existing list.
|
58 |
*
|
59 |
+
* @return Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_FactoryRuntimeLoader implements Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Filter class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSss_SimpleFilter instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Represents a template filter.
|
16 |
*
|
17 |
+
* Use Twig_SupTwgSss_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_SupTwgSss_Filter implements Twig_SupTwgSss_FilterInterface, Twig_SupTwgSss_FilterCallableInterface
|
24 |
{
|
25 |
protected $options;
|
26 |
protected $arguments = array();
|
56 |
return $this->options['needs_context'];
|
57 |
}
|
58 |
|
59 |
+
public function getSafe(Twig_SupTwgSss_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_SupTwgSss_Filter_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSss_SimpleFilter instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Represents a function template filter.
|
16 |
*
|
17 |
+
* Use Twig_SupTwgSss_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_SupTwgSss_Filter_Function extends Twig_SupTwgSss_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_SupTwgSss_Filter_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSss_SimpleFilter instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Represents a method template filter.
|
16 |
*
|
17 |
+
* Use Twig_SupTwgSss_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_SupTwgSss_Filter_Method extends Twig_SupTwgSss_Filter
|
24 |
{
|
25 |
protected $extension;
|
26 |
protected $method;
|
27 |
|
28 |
+
public function __construct(Twig_SupTwgSss_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_SupTwgSss_Filter_Node class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSss_SimpleFilter instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Represents a template filter as a node.
|
16 |
*
|
17 |
+
* Use Twig_SupTwgSss_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_SupTwgSss_Filter_Node extends Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_FilterInterface
|
22 |
{
|
23 |
/**
|
24 |
* Compiles a filter.
|
31 |
|
32 |
public function needsContext();
|
33 |
|
34 |
+
public function getSafe(Twig_SupTwgSss_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_SupTwgSss_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSss_SimpleFunction instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Represents a template function.
|
16 |
*
|
17 |
+
* Use Twig_SupTwgSss_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_SupTwgSss_Function implements Twig_SupTwgSss_FunctionInterface, Twig_SupTwgSss_FunctionCallableInterface
|
24 |
{
|
25 |
protected $options;
|
26 |
protected $arguments = array();
|
54 |
return $this->options['needs_context'];
|
55 |
}
|
56 |
|
57 |
+
public function getSafe(Twig_SupTwgSss_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_SupTwgSss_Function_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSss_SimpleFunction instead.', E_USER_DEPRECATED);
|
14 |
|
15 |
/**
|
16 |
* Represents a function template function.
|
17 |
*
|
18 |
+
* Use Twig_SupTwgSss_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_SupTwgSss_Function_Function extends Twig_SupTwgSss_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_SupTwgSss_Function_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSss_SimpleFunction instead.', E_USER_DEPRECATED);
|
14 |
|
15 |
/**
|
16 |
* Represents a method template function.
|
17 |
*
|
18 |
+
* Use Twig_SupTwgSss_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_SupTwgSss_Function_Method extends Twig_SupTwgSss_Function
|
25 |
{
|
26 |
protected $extension;
|
27 |
protected $method;
|
28 |
|
29 |
+
public function __construct(Twig_SupTwgSss_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_SupTwgSss_Function_Node class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSss_SimpleFunction instead.', E_USER_DEPRECATED);
|
13 |
|
14 |
/**
|
15 |
* Represents a template function as a node.
|
16 |
*
|
17 |
+
* Use Twig_SupTwgSss_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_SupTwgSss_Function_Node extends Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_FunctionInterface
|
23 |
{
|
24 |
/**
|
25 |
* Compiles a function.
|
32 |
|
33 |
public function needsContext();
|
34 |
|
35 |
+
public function getSafe(Twig_SupTwgSss_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 |
-
} elseif (preg_match($this->regexes['lex_block_line'], $this->code, $match,
|
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_SupTwgSss_Lexer implements Twig_SupTwgSss_LexerInterface
|
19 |
{
|
20 |
protected $tokens;
|
21 |
protected $code;
|
49 |
const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As';
|
50 |
const PUNCTUATION = '()[]{}?:.,|';
|
51 |
|
52 |
+
public function __construct(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
82 |
+
$this->source = new Twig_SupTwgSss_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_SupTwgSss_Token::EOF_TYPE);
|
140 |
|
141 |
if (!empty($this->brackets)) {
|
142 |
list($expect, $lineno) = array_pop($this->brackets);
|
143 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Error_Syntax(sprintf('Unclosed "%s".', $expect), $lineno, $this->source);
|
276 |
}
|
277 |
}
|
278 |
|
279 |
+
$this->pushToken(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Token::TEXT_TYPE === $type && '' === $value) {
|
366 |
return;
|
367 |
}
|
368 |
|
369 |
+
$this->tokens[] = new Twig_SupTwgSss_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_SupTwgSss_LexerInterface
|
20 |
{
|
21 |
/**
|
22 |
* Tokenizes a source code.
|
23 |
*
|
24 |
+
* @param string|Twig_SupTwgSss_Source $code The source code
|
25 |
* @param string $name A unique identifier for the source code
|
26 |
*
|
27 |
+
* @return Twig_SupTwgSss_TokenStream
|
28 |
*
|
29 |
+
* @throws Twig_SupTwgSss_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_SupTwgSss_Loader_Array implements Twig_SupTwgSss_LoaderInterface, Twig_SupTwgSss_ExistsLoaderInterface, Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Error_Loader(sprintf('Template "%s" is not defined.', $name));
|
66 |
}
|
67 |
|
68 |
+
return new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Loader_Chain implements Twig_SupTwgSss_LoaderInterface, Twig_SupTwgSss_ExistsLoaderInterface, Twig_SupTwgSss_SourceContextLoaderInterface
|
20 |
{
|
21 |
private $hasSourceCache = array();
|
22 |
protected $loaders = array();
|
23 |
|
24 |
/**
|
25 |
+
* @param Twig_SupTwgSss_LoaderInterface[] $loaders
|
26 |
*/
|
27 |
public function __construct(array $loaders = array())
|
28 |
{
|
31 |
}
|
32 |
}
|
33 |
|
34 |
+
public function addLoader(Twig_SupTwgSss_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_SupTwgSss_ExistsLoaderInterface && !$loader->exists($name)) {
|
47 |
continue;
|
48 |
}
|
49 |
|
50 |
try {
|
51 |
return $loader->getSource($name);
|
52 |
+
} catch (Twig_SupTwgSss_Error_Loader $e) {
|
53 |
$exceptions[] = $e->getMessage();
|
54 |
}
|
55 |
}
|
56 |
|
57 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_ExistsLoaderInterface && !$loader->exists($name)) {
|
65 |
continue;
|
66 |
}
|
67 |
|
68 |
try {
|
69 |
+
if ($loader instanceof Twig_SupTwgSss_SourceContextLoaderInterface) {
|
70 |
return $loader->getSourceContext($name);
|
71 |
}
|
72 |
|
73 |
+
return new Twig_SupTwgSss_Source($loader->getSource($name), $name);
|
74 |
+
} catch (Twig_SupTwgSss_Error_Loader $e) {
|
75 |
$exceptions[] = $e->getMessage();
|
76 |
}
|
77 |
}
|
78 |
|
79 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_ExistsLoaderInterface) {
|
92 |
if ($loader->exists($name)) {
|
93 |
return $this->hasSourceCache[$name] = true;
|
94 |
}
|
97 |
}
|
98 |
|
99 |
try {
|
100 |
+
if ($loader instanceof Twig_SupTwgSss_SourceContextLoaderInterface) {
|
101 |
$loader->getSourceContext($name);
|
102 |
} else {
|
103 |
$loader->getSource($name);
|
104 |
}
|
105 |
|
106 |
return $this->hasSourceCache[$name] = true;
|
107 |
+
} catch (Twig_SupTwgSss_Error_Loader $e) {
|
108 |
}
|
109 |
}
|
110 |
|
115 |
{
|
116 |
$exceptions = array();
|
117 |
foreach ($this->loaders as $loader) {
|
118 |
+
if ($loader instanceof Twig_SupTwgSss_ExistsLoaderInterface && !$loader->exists($name)) {
|
119 |
continue;
|
120 |
}
|
121 |
|
122 |
try {
|
123 |
return $loader->getCacheKey($name);
|
124 |
+
} catch (Twig_SupTwgSss_Error_Loader $e) {
|
125 |
$exceptions[] = get_class($loader).': '.$e->getMessage();
|
126 |
}
|
127 |
}
|
128 |
|
129 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_ExistsLoaderInterface && !$loader->exists($name)) {
|
137 |
continue;
|
138 |
}
|
139 |
|
140 |
try {
|
141 |
return $loader->isFresh($name, $time);
|
142 |
+
} catch (Twig_SupTwgSss_Error_Loader $e) {
|
143 |
$exceptions[] = get_class($loader).': '.$e->getMessage();
|
144 |
}
|
145 |
}
|
146 |
|
147 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_Loader_Filesystem implements Twig_SupTwgSss_LoaderInterface, Twig_SupTwgSss_ExistsLoaderInterface, Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Error_Loader($this->errorCache[$name]);
|
196 |
}
|
197 |
|
198 |
$this->validateName($name);
|
206 |
return false;
|
207 |
}
|
208 |
|
209 |
+
throw new Twig_SupTwgSss_Error_Loader($this->errorCache[$name]);
|
210 |
}
|
211 |
|
212 |
foreach ($this->paths[$namespace] as $path) {
|
229 |
return false;
|
230 |
}
|
231 |
|
232 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Loader_String class is deprecated since version 1.18.1 and will be removed in 2.0. Use Twig_SupTwgSss_Loader_Array instead or Twig_SupTwgSss_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_SupTwgSss_Loader_String implements Twig_SupTwgSss_LoaderInterface, Twig_SupTwgSss_ExistsLoaderInterface, Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Error_Loader When $name is not found
|
27 |
*
|
28 |
+
* @deprecated since 1.27 (to be removed in 2.0), implement Twig_SupTwgSss_SourceContextLoaderInterface
|
29 |
*/
|
30 |
public function getSource($name);
|
31 |
|
36 |
*
|
37 |
* @return string The cache key
|
38 |
*
|
39 |
+
* @throws Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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 |
}
|
@@ -181,7 +181,7 @@ class Twig_SupTwg_Node implements Twig_SupTwg_NodeInterface
|
|
181 |
}
|
182 |
|
183 |
/**
|
184 |
-
* @return
|
185 |
*/
|
186 |
public function getNode($name)
|
187 |
{
|
@@ -194,8 +194,8 @@ class Twig_SupTwg_Node implements Twig_SupTwg_NodeInterface
|
|
194 |
|
195 |
public function setNode($name, $node = null)
|
196 |
{
|
197 |
-
// if (!$node instanceof
|
198 |
-
//
|
199 |
// }
|
200 |
|
201 |
$this->nodes[$name] = $node;
|
@@ -205,12 +205,13 @@ class Twig_SupTwg_Node implements Twig_SupTwg_NodeInterface
|
|
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);
|
@@ -236,7 +237,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 +247,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_SupTwgSss_Node implements Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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 |
}
|
181 |
}
|
182 |
|
183 |
/**
|
184 |
+
* @return Twig_SupTwgSss_Node
|
185 |
*/
|
186 |
public function getNode($name)
|
187 |
{
|
194 |
|
195 |
public function setNode($name, $node = null)
|
196 |
{
|
197 |
+
// if (!$node instanceof Twig_SupTwgSss_NodeInterface) {
|
198 |
+
// //@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);
|
199 |
// }
|
200 |
|
201 |
$this->nodes[$name] = $node;
|
205 |
{
|
206 |
unset($this->nodes[$name]);
|
207 |
}
|
208 |
+
#[\ReturnTypeWillChange]
|
209 |
public function count()
|
210 |
{
|
211 |
return count($this->nodes);
|
212 |
}
|
213 |
|
214 |
+
#[\ReturnTypeWillChange]
|
215 |
public function getIterator()
|
216 |
{
|
217 |
return new ArrayIterator($this->nodes);
|
237 |
*/
|
238 |
public function setFilename($name)
|
239 |
{
|
240 |
+
//@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use setTemplateName() instead.', E_USER_DEPRECATED);
|
241 |
|
242 |
$this->setTemplateName($name);
|
243 |
}
|
247 |
*/
|
248 |
public function getFilename()
|
249 |
{
|
250 |
+
//@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getTemplateName() instead.', E_USER_DEPRECATED);
|
251 |
|
252 |
return $this->name;
|
253 |
}
|
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_SupTwgSss_Node_AutoEscape extends Twig_SupTwgSss_Node
|
24 |
{
|
25 |
+
public function __construct($value, Twig_SupTwgSss_NodeInterface $body, $lineno, $tag = 'autoescape')
|
26 |
{
|
27 |
parent::__construct(array('body' => $body), array('value' => $value), $lineno, $tag);
|
28 |
}
|
29 |
|
30 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_Block extends Twig_SupTwgSss_Node
|
19 |
{
|
20 |
+
public function __construct($name, Twig_SupTwgSss_NodeInterface $body, $lineno, $tag = null)
|
21 |
{
|
22 |
parent::__construct(array('body' => $body), array('name' => $name), $lineno, $tag);
|
23 |
}
|
24 |
|
25 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_BlockReference extends Twig_SupTwgSss_Node implements Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Body extends Twig_SupTwgSss_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_SupTwgSss_Node_CheckSecurity extends Twig_SupTwgSss_Node
|
16 |
{
|
17 |
protected $usedFilters;
|
18 |
protected $usedTags;
|
27 |
parent::__construct();
|
28 |
}
|
29 |
|
30 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Sandbox_SecurityError \$e) {\n")
|
58 |
->indent()
|
59 |
->write("\$e->setSourceContext(\$this->getSourceContext());\n\n")
|
60 |
+
->write("if (\$e instanceof Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Do extends Twig_SupTwgSss_Node
|
18 |
{
|
19 |
+
public function __construct(Twig_SupTwgSss_Node_Expression $expr, $lineno, $tag = null)
|
20 |
{
|
21 |
parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_Embed extends Twig_SupTwgSss_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_SupTwgSss_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null)
|
21 |
{
|
22 |
+
parent::__construct(new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression extends Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Array extends Twig_SupTwgSss_Node_Expression
|
12 |
{
|
13 |
protected $index;
|
14 |
|
18 |
|
19 |
$this->index = -1;
|
20 |
foreach ($this->getKeyValuePairs() as $pair) {
|
21 |
+
if ($pair['key'] instanceof Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression $value, Twig_SupTwgSss_Node_Expression $key = null)
|
55 |
{
|
56 |
if (null === $key) {
|
57 |
+
$key = new Twig_SupTwgSss_Node_Expression_Constant(++$this->index, $value->getTemplateLine());
|
58 |
}
|
59 |
|
60 |
array_push($this->nodes, $key, $value);
|
61 |
}
|
62 |
|
63 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_AssignName extends Twig_SupTwgSss_Node_Expression_Name
|
14 |
{
|
15 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary extends Twig_SupTwgSss_Node_Expression
|
13 |
{
|
14 |
+
public function __construct(Twig_SupTwgSss_NodeInterface $left, Twig_SupTwgSss_NodeInterface $right, $lineno)
|
15 |
{
|
16 |
parent::__construct(array('left' => $left, 'right' => $right), array(), $lineno);
|
17 |
}
|
18 |
|
19 |
+
public function compile(Twig_SupTwgSss_Compiler $compiler)
|
20 |
{
|
21 |
$compiler
|
22 |
->raw('(')
|
31 |
;
|
32 |
}
|
33 |
|
34 |
+
abstract public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_Add extends Twig_SupTwgSss_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_And extends Twig_SupTwgSss_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_BitwiseAnd extends Twig_SupTwgSss_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_BitwiseOr extends Twig_SupTwgSss_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_BitwiseXor extends Twig_SupTwgSss_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_Concat extends Twig_SupTwgSss_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_Div extends Twig_SupTwgSss_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_EndsWith extends Twig_SupTwgSss_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function compile(Twig_SupTwgSss_Compiler $compiler)
|
14 |
{
|
15 |
$left = $compiler->getVarName();
|
16 |
$right = $compiler->getVarName();
|
23 |
;
|
24 |
}
|
25 |
|
26 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_Equal extends Twig_SupTwgSss_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_FloorDiv extends Twig_SupTwgSss_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function compile(Twig_SupTwgSss_Compiler $compiler)
|
14 |
{
|
15 |
$compiler->raw('(int) floor(');
|
16 |
parent::compile($compiler);
|
17 |
$compiler->raw(')');
|
18 |
}
|
19 |
|
20 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_Greater extends Twig_SupTwgSss_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_GreaterEqual extends Twig_SupTwgSss_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_In extends Twig_SupTwgSss_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function compile(Twig_SupTwgSss_Compiler $compiler)
|
14 |
{
|
15 |
$compiler
|
16 |
+
->raw('Twig_SupTwgSss_in_filter(')
|
17 |
->subcompile($this->getNode('left'))
|
18 |
->raw(', ')
|
19 |
->subcompile($this->getNode('right'))
|
21 |
;
|
22 |
}
|
23 |
|
24 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_Less extends Twig_SupTwgSss_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_LessEqual extends Twig_SupTwgSss_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_Matches extends Twig_SupTwgSss_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function compile(Twig_SupTwgSss_Compiler $compiler)
|
14 |
{
|
15 |
$compiler
|
16 |
->raw('preg_match(')
|
21 |
;
|
22 |
}
|
23 |
|
24 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_Mod extends Twig_SupTwgSss_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_Mul extends Twig_SupTwgSss_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_NotEqual extends Twig_SupTwgSss_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_NotIn extends Twig_SupTwgSss_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function compile(Twig_SupTwgSss_Compiler $compiler)
|
14 |
{
|
15 |
$compiler
|
16 |
+
->raw('!Twig_SupTwgSss_in_filter(')
|
17 |
->subcompile($this->getNode('left'))
|
18 |
->raw(', ')
|
19 |
->subcompile($this->getNode('right'))
|
21 |
;
|
22 |
}
|
23 |
|
24 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_Or extends Twig_SupTwgSss_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_Power extends Twig_SupTwgSss_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function compile(Twig_SupTwgSss_Compiler $compiler)
|
14 |
{
|
15 |
if (PHP_VERSION_ID >= 50600) {
|
16 |
return parent::compile($compiler);
|
25 |
;
|
26 |
}
|
27 |
|
28 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_Range extends Twig_SupTwgSss_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function compile(Twig_SupTwgSss_Compiler $compiler)
|
14 |
{
|
15 |
$compiler
|
16 |
->raw('range(')
|
21 |
;
|
22 |
}
|
23 |
|
24 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_StartsWith extends Twig_SupTwgSss_Node_Expression_Binary
|
12 |
{
|
13 |
+
public function compile(Twig_SupTwgSss_Compiler $compiler)
|
14 |
{
|
15 |
$left = $compiler->getVarName();
|
16 |
$right = $compiler->getVarName();
|
23 |
;
|
24 |
}
|
25 |
|
26 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Binary_Sub extends Twig_SupTwgSss_Node_Expression_Binary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_BlockReference extends Twig_SupTwgSss_Node_Expression
|
19 |
{
|
20 |
/**
|
21 |
+
* @param Twig_SupTwgSss_Node|null $template
|
22 |
*/
|
23 |
+
public function __construct(Twig_SupTwgSss_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_SupTwgSss_Compiler $compiler)
|
40 |
{
|
41 |
if ($this->getAttribute('is_defined_test')) {
|
42 |
$this->compileTemplateCall($compiler, 'hasBlock');
|
53 |
}
|
54 |
}
|
55 |
|
56 |
+
private function compileTemplateCall(Twig_SupTwgSss_Compiler $compiler, $method)
|
57 |
{
|
58 |
if (!$this->hasNode('template')) {
|
59 |
$compiler->write('$this');
|
75 |
return $compiler;
|
76 |
}
|
77 |
|
78 |
+
private function compileBlockArguments(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Call extends Twig_SupTwgSss_Node_Expression
|
12 |
{
|
13 |
private $reflector;
|
14 |
|
15 |
+
protected function compileCallable(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Compiler $compiler)
|
49 |
{
|
50 |
$compiler->raw('(');
|
51 |
|
111 |
$named = true;
|
112 |
$name = $this->normalizeName($name);
|
113 |
} elseif ($named) {
|
114 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_Error_Syntax(sprintf('Argument "%s" is defined twice for %s "%s".', $name, $callType, $callName));
|
147 |
}
|
148 |
|
149 |
if (count($missingArguments)) {
|
150 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node) {
|
200 |
$unknownParameter = $parameter;
|
201 |
break;
|
202 |
}
|
203 |
}
|
204 |
|
205 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Conditional extends Twig_SupTwgSss_Node_Expression
|
13 |
{
|
14 |
+
public function __construct(Twig_SupTwgSss_Node_Expression $expr1, Twig_SupTwgSss_Node_Expression $expr2, Twig_SupTwgSss_Node_Expression $expr3, $lineno)
|
15 |
{
|
16 |
parent::__construct(array('expr1' => $expr1, 'expr2' => $expr2, 'expr3' => $expr3), array(), $lineno);
|
17 |
}
|
18 |
|
19 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Constant extends Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression_ExtensionReference extends Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression_Filter extends Twig_SupTwgSss_Node_Expression_Call
|
13 |
{
|
14 |
+
public function __construct(Twig_SupTwgSss_NodeInterface $node, Twig_SupTwgSss_Node_Expression_Constant $filterName, Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_FilterCallableInterface || $filter instanceof Twig_SupTwgSss_SimpleFilter) {
|
31 |
$this->setAttribute('callable', $filter->getCallable());
|
32 |
}
|
33 |
+
if ($filter instanceof Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Filter_Default extends Twig_SupTwgSss_Node_Expression_Filter
|
22 |
{
|
23 |
+
public function __construct(Twig_SupTwgSss_NodeInterface $node, Twig_SupTwgSss_Node_Expression_Constant $filterName, Twig_SupTwgSss_NodeInterface $arguments, $lineno, $tag = null)
|
24 |
{
|
25 |
+
$default = new Twig_SupTwgSss_Node_Expression_Filter($node, new Twig_SupTwgSss_Node_Expression_Constant('default', $node->getTemplateLine()), $arguments, $node->getTemplateLine());
|
26 |
|
27 |
+
if ('default' === $filterName->getAttribute('value') && ($node instanceof Twig_SupTwgSss_Node_Expression_Name || $node instanceof Twig_SupTwgSss_Node_Expression_GetAttr)) {
|
28 |
+
$test = new Twig_SupTwgSss_Node_Expression_Test_Defined(clone $node, 'defined', new Twig_SupTwgSss_Node(), $node->getTemplateLine());
|
29 |
+
$false = count($arguments) ? $arguments->getNode(0) : new Twig_SupTwgSss_Node_Expression_Constant('', $node->getTemplateLine());
|
30 |
|
31 |
+
$node = new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression_Function extends Twig_SupTwgSss_Node_Expression_Call
|
12 |
{
|
13 |
+
public function __construct($name, Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_FunctionCallableInterface || $function instanceof Twig_SupTwgSss_SimpleFunction) {
|
30 |
$callable = $function->getCallable();
|
31 |
if ('constant' === $name && $this->getAttribute('is_defined_test')) {
|
32 |
+
$callable = 'Twig_SupTwgSss_constant_is_defined';
|
33 |
}
|
34 |
|
35 |
$this->setAttribute('callable', $callable);
|
36 |
}
|
37 |
+
if ($function instanceof Twig_SupTwgSss_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_SupTwgSss_Node_Expression_GetAttr extends Twig_SupTwgSss_Node_Expression
|
13 |
{
|
14 |
+
public function __construct(Twig_SupTwgSss_Node_Expression $node, Twig_SupTwgSss_Node_Expression $attribute, Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_template_get_attributes') && !$this->getAttribute('disable_c_ext')) {
|
31 |
+
$compiler->raw('Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression_MethodCall extends Twig_SupTwgSss_Node_Expression
|
12 |
{
|
13 |
+
public function __construct(Twig_SupTwgSss_Node_Expression $node, $method, Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Name) {
|
18 |
$node->setAttribute('always_defined', true);
|
19 |
}
|
20 |
}
|
21 |
|
22 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Name extends Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression_NullCoalesce extends Twig_SupTwgSss_Node_Expression_Conditional
|
12 |
{
|
13 |
+
public function __construct(Twig_SupTwgSss_NodeInterface $left, Twig_SupTwgSss_NodeInterface $right, $lineno)
|
14 |
{
|
15 |
+
$test = new Twig_SupTwgSss_Node_Expression_Binary_And(
|
16 |
+
new Twig_SupTwgSss_Node_Expression_Test_Defined(clone $left, 'defined', new Twig_SupTwgSss_Node(), $left->getTemplateLine()),
|
17 |
+
new Twig_SupTwgSss_Node_Expression_Unary_Not(new Twig_SupTwgSss_Node_Expression_Test_Null($left, 'null', new Twig_SupTwgSss_Node(), $left->getTemplateLine()), $left->getTemplateLine()),
|
18 |
$left->getTemplateLine()
|
19 |
);
|
20 |
|
21 |
parent::__construct($test, $left, $right, $lineno);
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression_Parent extends Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression_TempName extends Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression_Test extends Twig_SupTwgSss_Node_Expression_Call
|
12 |
{
|
13 |
+
public function __construct(Twig_SupTwgSss_NodeInterface $node, $name, Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_TestCallableInterface || $test instanceof Twig_SupTwgSss_SimpleTest) {
|
32 |
$this->setAttribute('callable', $test->getCallable());
|
33 |
}
|
34 |
+
if ($test instanceof Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Test_Constant extends Twig_SupTwgSss_Node_Expression_Test
|
24 |
{
|
25 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Test_Defined extends Twig_SupTwgSss_Node_Expression_Test
|
25 |
{
|
26 |
+
public function __construct(Twig_SupTwgSss_NodeInterface $node, $name, Twig_SupTwgSss_NodeInterface $arguments = null, $lineno)
|
27 |
{
|
28 |
+
if ($node instanceof Twig_SupTwgSss_Node_Expression_Name) {
|
29 |
$node->setAttribute('is_defined_test', true);
|
30 |
+
} elseif ($node instanceof Twig_SupTwgSss_Node_Expression_GetAttr) {
|
31 |
$node->setAttribute('is_defined_test', true);
|
32 |
$this->changeIgnoreStrictCheck($node);
|
33 |
+
} elseif ($node instanceof Twig_SupTwgSss_Node_Expression_BlockReference) {
|
34 |
$node->setAttribute('is_defined_test', true);
|
35 |
+
} elseif ($node instanceof Twig_SupTwgSss_Node_Expression_Function && 'constant' === $node->getAttribute('name')) {
|
36 |
$node->setAttribute('is_defined_test', true);
|
37 |
+
} elseif ($node instanceof Twig_SupTwgSss_Node_Expression_Constant || $node instanceof Twig_SupTwgSss_Node_Expression_Array) {
|
38 |
+
$node = new Twig_SupTwgSss_Node_Expression_Constant(true, $node->getTemplateLine());
|
39 |
} else {
|
40 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_Node_Expression_GetAttr $node)
|
47 |
{
|
48 |
$node->setAttribute('ignore_strict_check', true);
|
49 |
|
50 |
+
if ($node->getNode('node') instanceof Twig_SupTwgSss_Node_Expression_GetAttr) {
|
51 |
$this->changeIgnoreStrictCheck($node->getNode('node'));
|
52 |
}
|
53 |
}
|
54 |
|
55 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Test_Divisibleby extends Twig_SupTwgSss_Node_Expression_Test
|
22 |
{
|
23 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Test_Even extends Twig_SupTwgSss_Node_Expression_Test
|
22 |
{
|
23 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Test_Null extends Twig_SupTwgSss_Node_Expression_Test
|
22 |
{
|
23 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Test_Odd extends Twig_SupTwgSss_Node_Expression_Test
|
22 |
{
|
23 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Test_Sameas extends Twig_SupTwgSss_Node_Expression_Test
|
18 |
{
|
19 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Unary extends Twig_SupTwgSss_Node_Expression
|
13 |
{
|
14 |
+
public function __construct(Twig_SupTwgSss_NodeInterface $node, $lineno)
|
15 |
{
|
16 |
parent::__construct(array('node' => $node), array(), $lineno);
|
17 |
}
|
18 |
|
19 |
+
public function compile(Twig_SupTwgSss_Compiler $compiler)
|
20 |
{
|
21 |
$compiler->raw(' ');
|
22 |
$this->operator($compiler);
|
23 |
$compiler->subcompile($this->getNode('node'));
|
24 |
}
|
25 |
|
26 |
+
abstract public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Unary_Neg extends Twig_SupTwgSss_Node_Expression_Unary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Unary_Not extends Twig_SupTwgSss_Node_Expression_Unary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Expression_Unary_Pos extends Twig_SupTwgSss_Node_Expression_Unary
|
13 |
{
|
14 |
+
public function operator(Twig_SupTwgSss_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_SupTwgSss_Node_Flush extends Twig_SupTwgSss_Node
|
18 |
{
|
19 |
public function __construct($lineno, $tag)
|
20 |
{
|
21 |
parent::__construct(array(), array(), $lineno, $tag);
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_For extends Twig_SupTwgSss_Node
|
19 |
{
|
20 |
protected $loop;
|
21 |
|
22 |
+
public function __construct(Twig_SupTwgSss_Node_Expression_AssignName $keyTarget, Twig_SupTwgSss_Node_Expression_AssignName $valueTarget, Twig_SupTwgSss_Node_Expression $seq, Twig_SupTwgSss_Node_Expression $ifexpr = null, Twig_SupTwgSss_NodeInterface $body, Twig_SupTwgSss_NodeInterface $else = null, $lineno, $tag = null)
|
23 |
{
|
24 |
+
$body = new Twig_SupTwgSss_Node(array($body, $this->loop = new Twig_SupTwgSss_Node_ForLoop($lineno, $tag)));
|
25 |
|
26 |
if (null !== $ifexpr) {
|
27 |
+
$body = new Twig_SupTwgSss_Node_If(new Twig_SupTwgSss_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_SupTwgSss_Compiler $compiler)
|
39 |
{
|
40 |
$compiler
|
41 |
->addDebugInfo($this)
|
42 |
->write("\$context['_parent'] = \$context;\n")
|
43 |
+
->write("\$context['_seq'] = Twig_SupTwgSss_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_SupTwgSss_Node_ForLoop extends Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_If extends Twig_SupTwgSss_Node
|
19 |
{
|
20 |
+
public function __construct(Twig_SupTwgSss_NodeInterface $tests, Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Import extends Twig_SupTwgSss_Node
|
18 |
{
|
19 |
+
public function __construct(Twig_SupTwgSss_Node_Expression $expr, Twig_SupTwgSss_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_SupTwgSss_Compiler $compiler)
|
25 |
{
|
26 |
$compiler
|
27 |
->addDebugInfo($this)
|
30 |
->raw(' = ')
|
31 |
;
|
32 |
|
33 |
+
if ($this->getNode('expr') instanceof Twig_SupTwgSss_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_SupTwgSss_Node_Include extends Twig_SupTwgSss_Node implements Twig_SupTwgSss_NodeOutputInterface
|
19 |
{
|
20 |
+
public function __construct(Twig_SupTwgSss_Node_Expression $expr, Twig_SupTwgSss_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $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_SupTwgSss_Compiler $compiler)
|
31 |
{
|
32 |
$compiler->addDebugInfo($this);
|
33 |
|
49 |
if ($this->getAttribute('ignore_missing')) {
|
50 |
$compiler
|
51 |
->outdent()
|
52 |
+
->write("} catch (Twig_SupTwgSss_Error_Loader \$e) {\n")
|
53 |
->indent()
|
54 |
->write("// ignore missing template\n")
|
55 |
->outdent()
|
58 |
}
|
59 |
}
|
60 |
|
61 |
+
protected function addGetTemplate(Twig_SupTwgSss_Compiler $compiler)
|
62 |
{
|
63 |
$compiler
|
64 |
->write('$this->loadTemplate(')
|
71 |
;
|
72 |
}
|
73 |
|
74 |
+
protected function addTemplateArguments(Twig_SupTwgSss_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_SupTwgSss_Node_Macro extends Twig_SupTwgSss_Node
|
18 |
{
|
19 |
const VARARGS_NAME = 'varargs';
|
20 |
|
21 |
+
public function __construct($name, Twig_SupTwgSss_NodeInterface $body, Twig_SupTwgSss_NodeInterface $arguments, $lineno, $tag = null)
|
22 |
{
|
23 |
foreach ($arguments as $argumentName => $argument) {
|
24 |
if (self::VARARGS_NAME === $argumentName) {
|
25 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Module extends Twig_SupTwgSss_Node
|
23 |
{
|
24 |
private $source;
|
25 |
|
26 |
+
public function __construct(Twig_SupTwgSss_NodeInterface $body, Twig_SupTwgSss_Node_Expression $parent = null, Twig_SupTwgSss_NodeInterface $blocks, Twig_SupTwgSss_NodeInterface $macros, Twig_SupTwgSss_NodeInterface $traits, $embeddedTemplates, $name, $source = '')
|
27 |
{
|
28 |
+
if (!$name instanceof Twig_SupTwgSss_Source) {
|
29 |
+
//@trigger_error(sprintf('Passing a string as the $name argument of %s() is deprecated since version 1.27. Pass a Twig_SupTwgSss_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
30 |
+
$this->source = new Twig_SupTwgSss_Source($source, $name);
|
31 |
} else {
|
32 |
$this->source = $name;
|
33 |
}
|
37 |
'blocks' => $blocks,
|
38 |
'macros' => $macros,
|
39 |
'traits' => $traits,
|
40 |
+
'display_start' => new Twig_SupTwgSss_Node(),
|
41 |
+
'display_end' => new Twig_SupTwgSss_Node(),
|
42 |
+
'constructor_start' => new Twig_SupTwgSss_Node(),
|
43 |
+
'constructor_end' => new Twig_SupTwgSss_Node(),
|
44 |
+
'class_end' => new Twig_SupTwgSss_Node(),
|
45 |
);
|
46 |
if (null !== $parent) {
|
47 |
$nodes['parent'] = $parent;
|
66 |
$this->setAttribute('index', $index);
|
67 |
}
|
68 |
|
69 |
+
public function compile(Twig_SupTwgSss_Compiler $compiler)
|
70 |
{
|
71 |
$this->compileTemplate($compiler);
|
72 |
|
75 |
}
|
76 |
}
|
77 |
|
78 |
+
protected function compileTemplate(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Compiler $compiler)
|
119 |
{
|
120 |
if (!$this->hasNode('parent')) {
|
121 |
return;
|
129 |
->write('return ')
|
130 |
;
|
131 |
|
132 |
+
if ($parent instanceof Twig_SupTwgSss_Node_Expression_Constant) {
|
133 |
$compiler->subcompile($parent);
|
134 |
} else {
|
135 |
$compiler
|
150 |
;
|
151 |
}
|
152 |
|
153 |
+
protected function compileClassHeader(Twig_SupTwgSss_Compiler $compiler)
|
154 |
{
|
155 |
$compiler
|
156 |
->write("\n\n")
|
163 |
;
|
164 |
}
|
165 |
|
166 |
+
protected function compileConstructor(Twig_SupTwgSss_Compiler $compiler)
|
167 |
{
|
168 |
$compiler
|
169 |
+
->write("public function __construct(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression_Constant) {
|
308 |
$compiler->write('$this->parent');
|
309 |
} else {
|
310 |
$compiler->write('$this->getParent($context)');
|
319 |
;
|
320 |
}
|
321 |
|
322 |
+
protected function compileClassFooter(Twig_SupTwgSss_Compiler $compiler)
|
323 |
{
|
324 |
$compiler
|
325 |
->subcompile($this->getNode('class_end'))
|
328 |
;
|
329 |
}
|
330 |
|
331 |
+
protected function compileMacros(Twig_SupTwgSss_Compiler $compiler)
|
332 |
{
|
333 |
$compiler->subcompile($this->getNode('macros'));
|
334 |
}
|
335 |
|
336 |
+
protected function compileGetTemplateName(Twig_SupTwgSss_Compiler $compiler)
|
337 |
{
|
338 |
$compiler
|
339 |
->write("public function getTemplateName()\n", "{\n")
|
346 |
;
|
347 |
}
|
348 |
|
349 |
+
protected function compileIsTraitable(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node(array($nodes));
|
368 |
}
|
369 |
|
370 |
foreach ($nodes as $node) {
|
372 |
continue;
|
373 |
}
|
374 |
|
375 |
+
if ($node instanceof Twig_SupTwgSss_Node_Text && ctype_space($node->getAttribute('data'))) {
|
376 |
continue;
|
377 |
}
|
378 |
|
379 |
+
if ($node instanceof Twig_SupTwgSss_Node_BlockReference) {
|
380 |
continue;
|
381 |
}
|
382 |
|
398 |
;
|
399 |
}
|
400 |
|
401 |
+
protected function compileDebugInfo(Twig_SupTwgSss_Compiler $compiler)
|
402 |
{
|
403 |
$compiler
|
404 |
->write("public function getDebugInfo()\n", "{\n")
|
409 |
;
|
410 |
}
|
411 |
|
412 |
+
protected function compileGetSource(Twig_SupTwgSss_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_SupTwgSss_Compiler $compiler)
|
427 |
{
|
428 |
$compiler
|
429 |
->write("public function getSourceContext()\n", "{\n")
|
430 |
->indent()
|
431 |
+
->write('return new Twig_SupTwgSss_Source(')
|
432 |
->string($compiler->getEnvironment()->isDebug() ? $this->source->getCode() : '')
|
433 |
->raw(', ')
|
434 |
->string($this->source->getName())
|
440 |
;
|
441 |
}
|
442 |
|
443 |
+
protected function compileLoadTemplate(Twig_SupTwgSss_Compiler $compiler, $node, $var)
|
444 |
{
|
445 |
+
if ($node instanceof Twig_SupTwgSss_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_SupTwgSss_Node_Print extends Twig_SupTwgSss_Node implements Twig_SupTwgSss_NodeOutputInterface
|
19 |
{
|
20 |
+
public function __construct(Twig_SupTwgSss_Node_Expression $expr, $lineno, $tag = null)
|
21 |
{
|
22 |
parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
|
23 |
}
|
24 |
|
25 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_Sandbox extends Twig_SupTwgSss_Node
|
18 |
{
|
19 |
+
public function __construct(Twig_SupTwgSss_NodeInterface $body, $lineno, $tag = null)
|
20 |
{
|
21 |
parent::__construct(array('body' => $body), array(), $lineno, $tag);
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_SupTwgSss_Compiler $compiler)
|
25 |
{
|
26 |
$compiler
|
27 |
->addDebugInfo($this)
|
28 |
+
->write("\$sandbox = \$this->env->getExtension('Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_SandboxedPrint extends Twig_SupTwgSss_Node_Print
|
23 |
{
|
24 |
+
public function compile(Twig_SupTwgSss_Compiler $compiler)
|
25 |
{
|
26 |
$compiler
|
27 |
->addDebugInfo($this)
|
28 |
+
->write('echo $this->env->getExtension(\'Twig_SupTwgSss_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_SupTwgSss_Node
|
40 |
*/
|
41 |
+
protected function removeNodeFilter(Twig_SupTwgSss_Node $node)
|
42 |
{
|
43 |
+
if ($node instanceof Twig_SupTwgSss_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_SupTwgSss_Node_Set extends Twig_SupTwgSss_Node implements Twig_SupTwgSss_NodeCaptureInterface
|
18 |
{
|
19 |
+
public function __construct($capture, Twig_SupTwgSss_NodeInterface $names, Twig_SupTwgSss_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_SupTwgSss_Markup("foo");
|
27 |
*/
|
28 |
if ($this->getAttribute('capture')) {
|
29 |
$this->setAttribute('safe', true);
|
30 |
|
31 |
$values = $this->getNode('values');
|
32 |
+
if ($values instanceof Twig_SupTwgSss_Node_Text) {
|
33 |
+
$this->setNode('values', new Twig_SupTwgSss_Node_Expression_Constant($values->getAttribute('data'), $values->getTemplateLine()));
|
34 |
$this->setAttribute('capture', false);
|
35 |
}
|
36 |
}
|
37 |
}
|
38 |
|
39 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Markup(\$tmp, \$this->env->getCharset())");
|
65 |
}
|
66 |
}
|
67 |
|
83 |
$compiler
|
84 |
->raw("('' === \$tmp = ")
|
85 |
->subcompile($this->getNode('values'))
|
86 |
+
->raw(") ? '' : new Twig_SupTwgSss_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_SupTwgSss_Node_SetTemp extends Twig_SupTwgSss_Node
|
13 |
{
|
14 |
public function __construct($name, $lineno)
|
15 |
{
|
16 |
parent::__construct(array(), array('name' => $name), $lineno);
|
17 |
}
|
18 |
|
19 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_Spaceless extends Twig_SupTwgSss_Node
|
20 |
{
|
21 |
+
public function __construct(Twig_SupTwgSss_NodeInterface $body, $lineno, $tag = 'spaceless')
|
22 |
{
|
23 |
parent::__construct(array('body' => $body), array(), $lineno, $tag);
|
24 |
}
|
25 |
|
26 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_Text extends Twig_SupTwgSss_Node implements Twig_SupTwgSss_NodeOutputInterface
|
19 |
{
|
20 |
public function __construct($data, $lineno)
|
21 |
{
|
22 |
parent::__construct(array(), array('data' => $data), $lineno);
|
23 |
}
|
24 |
|
25 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Node_With extends Twig_SupTwgSss_Node
|
18 |
{
|
19 |
+
public function __construct(Twig_SupTwgSss_Node $body, Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_NodeInterface extends Countable, IteratorAggregate
|
20 |
{
|
21 |
/**
|
22 |
* Compiles the node to PHP.
|
23 |
*/
|
24 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_NodeTraverser
|
22 |
{
|
23 |
protected $env;
|
24 |
protected $visitors = array();
|
25 |
|
26 |
/**
|
27 |
+
* @param Twig_SupTwgSss_Environment $env
|
28 |
+
* @param Twig_SupTwgSss_NodeVisitorInterface[] $visitors
|
29 |
*/
|
30 |
+
public function __construct(Twig_SupTwgSss_Environment $env, array $visitors = array())
|
31 |
{
|
32 |
$this->env = $env;
|
33 |
foreach ($visitors as $visitor) {
|
35 |
}
|
36 |
}
|
37 |
|
38 |
+
public function addVisitor(Twig_SupTwgSss_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_SupTwgSss_NodeInterface
|
51 |
*/
|
52 |
+
public function traverse(Twig_SupTwgSss_NodeInterface $node)
|
53 |
{
|
54 |
ksort($this->visitors);
|
55 |
foreach ($this->visitors as $visitors) {
|
61 |
return $node;
|
62 |
}
|
63 |
|
64 |
+
protected function traverseForVisitor(Twig_SupTwgSss_NodeVisitorInterface $visitor, Twig_SupTwgSss_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_SupTwgSss_NodeVisitor_Escaper implements output escaping.
|
14 |
*
|
15 |
* @final
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class Twig_SupTwgSss_NodeVisitor_Escaper extends Twig_SupTwgSss_BaseNodeVisitor
|
20 |
{
|
21 |
protected $statusStack = array();
|
22 |
protected $blocks = array();
|
27 |
|
28 |
public function __construct()
|
29 |
{
|
30 |
+
$this->safeAnalysis = new Twig_SupTwgSss_NodeVisitor_SafeAnalysis();
|
31 |
}
|
32 |
|
33 |
+
protected function doEnterNode(Twig_SupTwgSss_Node $node, Twig_SupTwgSss_Environment $env)
|
34 |
{
|
35 |
+
if ($node instanceof Twig_SupTwgSss_Node_Module) {
|
36 |
+
if ($env->hasExtension('Twig_SupTwgSss_Extension_Escaper') && $defaultStrategy = $env->getExtension('Twig_SupTwgSss_Extension_Escaper')->getDefaultStrategy($node->getTemplateName())) {
|
37 |
$this->defaultStrategy = $defaultStrategy;
|
38 |
}
|
39 |
$this->safeVars = array();
|
40 |
$this->blocks = array();
|
41 |
+
} elseif ($node instanceof Twig_SupTwgSss_Node_AutoEscape) {
|
42 |
$this->statusStack[] = $node->getAttribute('value');
|
43 |
+
} elseif ($node instanceof Twig_SupTwgSss_Node_Block) {
|
44 |
$this->statusStack[] = isset($this->blocks[$node->getAttribute('name')]) ? $this->blocks[$node->getAttribute('name')] : $this->needEscaping($env);
|
45 |
+
} elseif ($node instanceof Twig_SupTwgSss_Node_Import) {
|
46 |
$this->safeVars[] = $node->getNode('var')->getAttribute('name');
|
47 |
}
|
48 |
|
49 |
return $node;
|
50 |
}
|
51 |
|
52 |
+
protected function doLeaveNode(Twig_SupTwgSss_Node $node, Twig_SupTwgSss_Environment $env)
|
53 |
{
|
54 |
+
if ($node instanceof Twig_SupTwgSss_Node_Module) {
|
55 |
$this->defaultStrategy = false;
|
56 |
$this->safeVars = array();
|
57 |
$this->blocks = array();
|
58 |
+
} elseif ($node instanceof Twig_SupTwgSss_Node_Expression_Filter) {
|
59 |
return $this->preEscapeFilterNode($node, $env);
|
60 |
+
} elseif ($node instanceof Twig_SupTwgSss_Node_Print) {
|
61 |
return $this->escapePrintNode($node, $env, $this->needEscaping($env));
|
62 |
}
|
63 |
|
64 |
+
if ($node instanceof Twig_SupTwgSss_Node_AutoEscape || $node instanceof Twig_SupTwgSss_Node_Block) {
|
65 |
array_pop($this->statusStack);
|
66 |
+
} elseif ($node instanceof Twig_SupTwgSss_Node_BlockReference) {
|
67 |
$this->blocks[$node->getAttribute('name')] = $this->needEscaping($env);
|
68 |
}
|
69 |
|
70 |
return $node;
|
71 |
}
|
72 |
|
73 |
+
protected function escapePrintNode(Twig_SupTwgSss_Node_Print $node, Twig_SupTwgSss_Environment $env, $type)
|
74 |
{
|
75 |
if (false === $type) {
|
76 |
return $node;
|
90 |
);
|
91 |
}
|
92 |
|
93 |
+
protected function preEscapeFilterNode(Twig_SupTwgSss_Node_Expression_Filter $filter, Twig_SupTwgSss_Environment $env)
|
94 |
{
|
95 |
$name = $filter->getNode('filter')->getAttribute('value');
|
96 |
|
109 |
return $filter;
|
110 |
}
|
111 |
|
112 |
+
protected function isSafeFor($type, Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_NodeInterface $node)
|
140 |
{
|
141 |
$line = $node->getTemplateLine();
|
142 |
+
$name = new Twig_SupTwgSss_Node_Expression_Constant('escape', $line);
|
143 |
+
$args = new Twig_SupTwgSss_Node(array(new Twig_SupTwgSss_Node_Expression_Constant((string) $type, $line), new Twig_SupTwgSss_Node_Expression_Constant(null, $line), new Twig_SupTwgSss_Node_Expression_Constant(true, $line)));
|
144 |
|
145 |
+
return new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_NodeVisitor_Optimizer extends Twig_SupTwgSss_BaseNodeVisitor
|
25 |
{
|
26 |
const OPTIMIZE_ALL = -1;
|
27 |
const OPTIMIZE_NONE = 0;
|
47 |
$this->optimizers = $optimizers;
|
48 |
}
|
49 |
|
50 |
+
protected function doEnterNode(Twig_SupTwgSss_Node $node, Twig_SupTwgSss_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_SupTwgSss_Extension_Sandbox')) {
|
57 |
if ($this->inABody) {
|
58 |
+
if (!$node instanceof Twig_SupTwgSss_Node_Expression) {
|
59 |
+
if (get_class($node) !== 'Twig_SupTwgSss_Node') {
|
60 |
array_unshift($this->prependedNodes, array());
|
61 |
}
|
62 |
} else {
|
63 |
$node = $this->optimizeVariables($node, $env);
|
64 |
}
|
65 |
+
} elseif ($node instanceof Twig_SupTwgSss_Node_Body) {
|
66 |
$this->inABody = true;
|
67 |
}
|
68 |
}
|
70 |
return $node;
|
71 |
}
|
72 |
|
73 |
+
protected function doLeaveNode(Twig_SupTwgSss_Node $node, Twig_SupTwgSss_Environment $env)
|
74 |
{
|
75 |
+
$expression = $node instanceof Twig_SupTwgSss_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_SupTwgSss_Extension_Sandbox')) {
|
88 |
+
if ($node instanceof Twig_SupTwgSss_Node_Body) {
|
89 |
$this->inABody = false;
|
90 |
} elseif ($this->inABody) {
|
91 |
+
if (!$expression && get_class($node) !== 'Twig_SupTwgSss_Node' && $prependedNodes = array_shift($this->prependedNodes)) {
|
92 |
$nodes = array();
|
93 |
foreach (array_unique($prependedNodes) as $name) {
|
94 |
+
$nodes[] = new Twig_SupTwgSss_Node_SetTemp($name, $node->getTemplateLine());
|
95 |
}
|
96 |
|
97 |
$nodes[] = $node;
|
98 |
+
$node = new Twig_SupTwgSss_Node($nodes);
|
99 |
}
|
100 |
}
|
101 |
}
|
103 |
return $node;
|
104 |
}
|
105 |
|
106 |
+
protected function optimizeVariables(Twig_SupTwgSss_NodeInterface $node, Twig_SupTwgSss_Environment $env)
|
107 |
{
|
108 |
+
if ('Twig_SupTwgSss_Node_Expression_Name' === get_class($node) && $node->isSimple()) {
|
109 |
$this->prependedNodes[0][] = $node->getAttribute('name');
|
110 |
|
111 |
+
return new Twig_SupTwgSss_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_SupTwgSss_NodeInterface
|
125 |
*/
|
126 |
+
protected function optimizePrintNode(Twig_SupTwgSss_NodeInterface $node, Twig_SupTwgSss_Environment $env)
|
127 |
{
|
128 |
+
if (!$node instanceof Twig_SupTwgSss_Node_Print) {
|
129 |
return $node;
|
130 |
}
|
131 |
|
132 |
$exprNode = $node->getNode('expr');
|
133 |
if (
|
134 |
+
$exprNode instanceof Twig_SupTwgSss_Node_Expression_BlockReference ||
|
135 |
+
$exprNode instanceof Twig_SupTwgSss_Node_Expression_Parent
|
136 |
) {
|
137 |
$exprNode->setAttribute('output', true);
|
138 |
|
145 |
/**
|
146 |
* Removes "raw" filters.
|
147 |
*
|
148 |
+
* @return Twig_SupTwgSss_NodeInterface
|
149 |
*/
|
150 |
+
protected function optimizeRawFilter(Twig_SupTwgSss_NodeInterface $node, Twig_SupTwgSss_Environment $env)
|
151 |
{
|
152 |
+
if ($node instanceof Twig_SupTwgSss_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_SupTwgSss_NodeInterface $node, Twig_SupTwgSss_Environment $env)
|
163 |
{
|
164 |
+
if ($node instanceof Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_BlockReference || $node instanceof Twig_SupTwgSss_Node_Expression_BlockReference) {
|
190 |
$this->addLoopToCurrent();
|
191 |
}
|
192 |
|
193 |
// include without the only attribute
|
194 |
+
elseif ($node instanceof Twig_SupTwgSss_Node_Include && !$node->getAttribute('only')) {
|
195 |
$this->addLoopToAll();
|
196 |
}
|
197 |
|
198 |
// include function without the with_context=false parameter
|
199 |
+
elseif ($node instanceof Twig_SupTwgSss_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_SupTwgSss_Node_Expression_GetAttr
|
210 |
+
&& (!$node->getNode('attribute') instanceof Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_NodeInterface $node, Twig_SupTwgSss_Environment $env)
|
227 |
{
|
228 |
+
if ($node instanceof Twig_SupTwgSss_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_SupTwgSss_NodeVisitor_SafeAnalysis extends Twig_SupTwgSss_BaseNodeVisitor
|
16 |
{
|
17 |
protected $data = array();
|
18 |
protected $safeVars = array();
|
22 |
$this->safeVars = $safeVars;
|
23 |
}
|
24 |
|
25 |
+
public function getSafe(Twig_SupTwgSss_NodeInterface $node)
|
26 |
{
|
27 |
$hash = spl_object_hash($node);
|
28 |
if (!isset($this->data[$hash])) {
|
42 |
}
|
43 |
}
|
44 |
|
45 |
+
protected function setSafe(Twig_SupTwgSss_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_SupTwgSss_Node $node, Twig_SupTwgSss_Environment $env)
|
64 |
{
|
65 |
return $node;
|
66 |
}
|
67 |
|
68 |
+
protected function doLeaveNode(Twig_SupTwgSss_Node $node, Twig_SupTwgSss_Environment $env)
|
69 |
{
|
70 |
+
if ($node instanceof Twig_SupTwgSss_Node_Expression_Constant) {
|
71 |
// constants are marked safe for all
|
72 |
$this->setSafe($node, array('all'));
|
73 |
+
} elseif ($node instanceof Twig_SupTwgSss_Node_Expression_BlockReference) {
|
74 |
// blocks are safe by definition
|
75 |
$this->setSafe($node, array('all'));
|
76 |
+
} elseif ($node instanceof Twig_SupTwgSss_Node_Expression_Parent) {
|
77 |
// parent block is safe by definition
|
78 |
$this->setSafe($node, array('all'));
|
79 |
+
} elseif ($node instanceof Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_SupTwgSss_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_SupTwgSss_NodeVisitor_Sandbox implements sandboxing.
|
14 |
*
|
15 |
* @final
|
16 |
*
|
17 |
* @author Fabien Potencier <fabien@symfony.com>
|
18 |
*/
|
19 |
+
class Twig_SupTwgSss_NodeVisitor_Sandbox extends Twig_SupTwgSss_BaseNodeVisitor
|
20 |
{
|
21 |
protected $inAModule = false;
|
22 |
protected $tags;
|
23 |
protected $filters;
|
24 |
protected $functions;
|
25 |
|
26 |
+
protected function doEnterNode(Twig_SupTwgSss_Node $node, Twig_SupTwgSss_Environment $env)
|
27 |
{
|
28 |
+
if ($node instanceof Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Print) {
|
53 |
+
return new Twig_SupTwgSss_Node_SandboxedPrint($node->getNode('expr'), $node->getTemplateLine(), $node->getNodeTag());
|
54 |
}
|
55 |
}
|
56 |
|
57 |
return $node;
|
58 |
}
|
59 |
|
60 |
+
protected function doLeaveNode(Twig_SupTwgSss_Node $node, Twig_SupTwgSss_Environment $env)
|
61 |
{
|
62 |
+
if ($node instanceof Twig_SupTwgSss_Node_Module) {
|
63 |
$this->inAModule = false;
|
64 |
|
65 |
+
$node->setNode('display_start', new Twig_SupTwgSss_Node(array(new Twig_SupTwgSss_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_SupTwgSss_NodeVisitorInterface is the interface the all node visitor classes must implement.
|
14 |
*
|
15 |
* @author Fabien Potencier <fabien@symfony.com>
|
16 |
*/
|
17 |
+
interface Twig_SupTwgSss_NodeVisitorInterface
|
18 |
{
|
19 |
/**
|
20 |
* Called before child nodes are visited.
|
21 |
*
|
22 |
+
* @return Twig_SupTwgSss_NodeInterface The modified node
|
23 |
*/
|
24 |
+
public function enterNode(Twig_SupTwgSss_NodeInterface $node, Twig_SupTwgSss_Environment $env);
|
25 |
|
26 |
/**
|
27 |
* Called after child nodes are visited.
|
28 |
*
|
29 |
+
* @return Twig_SupTwgSss_NodeInterface|false The modified node or false if the node must be removed
|
30 |
*/
|
31 |
+
public function leaveNode(Twig_SupTwgSss_NodeInterface $node, Twig_SupTwgSss_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_SupTwgSss_Parser implements Twig_SupTwgSss_ParserInterface
|
19 |
{
|
20 |
protected $stack = array();
|
21 |
protected $stream;
|
32 |
protected $traits;
|
33 |
protected $embeddedTemplates = array();
|
34 |
|
35 |
+
public function __construct(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node();
|
107 |
}
|
108 |
+
} catch (Twig_SupTwgSss_Error_Syntax $e) {
|
109 |
if (!$e->getSourceContext()) {
|
110 |
$e->setSourceContext($this->stream->getSourceContext());
|
111 |
}
|
117 |
throw $e;
|
118 |
}
|
119 |
|
120 |
+
$node = new Twig_SupTwgSss_Node_Module(new Twig_SupTwgSss_Node_Body(array($body)), $this->parent, new Twig_SupTwgSss_Node($this->blocks), new Twig_SupTwgSss_Node($this->macros), new Twig_SupTwgSss_Node($this->traits), $this->embeddedTemplates, $stream->getSourceContext());
|
121 |
|
122 |
+
$traverser = new Twig_SupTwgSss_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_SupTwgSss_Token::TEXT_TYPE:
|
141 |
$token = $this->stream->next();
|
142 |
+
$rv[] = new Twig_SupTwgSss_Node_Text($token->getValue(), $token->getLine());
|
143 |
break;
|
144 |
|
145 |
+
case Twig_SupTwgSss_Token::VAR_START_TYPE:
|
146 |
$token = $this->stream->next();
|
147 |
$expr = $this->expressionParser->parseExpression();
|
148 |
+
$this->stream->expect(Twig_SupTwgSss_Token::VAR_END_TYPE);
|
149 |
+
$rv[] = new Twig_SupTwgSss_Node_Print($expr, $token->getLine());
|
150 |
break;
|
151 |
|
152 |
+
case Twig_SupTwgSss_Token::BLOCK_START_TYPE:
|
153 |
$this->stream->next();
|
154 |
$token = $this->getCurrentToken();
|
155 |
|
156 |
+
if ($token->getType() !== Twig_SupTwgSss_Token::NAME_TYPE) {
|
157 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Block $value)
|
259 |
{
|
260 |
+
$this->blocks[$name] = new Twig_SupTwgSss_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_SupTwgSss_Node_Macro $node)
|
269 |
{
|
270 |
if ($this->isReservedMacroName($name)) {
|
271 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression $node = null)
|
312 |
{
|
313 |
$this->importedSymbols[0][$type][$alias] = array('name' => $name, 'node' => $node);
|
314 |
}
|
338 |
}
|
339 |
|
340 |
/**
|
341 |
+
* @return Twig_SupTwgSss_ExpressionParser
|
342 |
*/
|
343 |
public function getExpressionParser()
|
344 |
{
|
356 |
}
|
357 |
|
358 |
/**
|
359 |
+
* @return Twig_SupTwgSss_TokenStream
|
360 |
*/
|
361 |
public function getStream()
|
362 |
{
|
364 |
}
|
365 |
|
366 |
/**
|
367 |
+
* @return Twig_SupTwgSss_Token
|
368 |
*/
|
369 |
public function getCurrentToken()
|
370 |
{
|
371 |
return $this->stream->getCurrent();
|
372 |
}
|
373 |
|
374 |
+
protected function filterBodyNodes(Twig_SupTwgSss_NodeInterface $node)
|
375 |
{
|
376 |
// check that the body does not contain non-empty output nodes
|
377 |
if (
|
378 |
+
($node instanceof Twig_SupTwgSss_Node_Text && !ctype_space($node->getAttribute('data')))
|
379 |
||
|
380 |
+
(!$node instanceof Twig_SupTwgSss_Node_Text && !$node instanceof Twig_SupTwgSss_Node_BlockReference && $node instanceof Twig_SupTwgSss_NodeOutputInterface)
|
381 |
) {
|
382 |
if (false !== strpos((string) $node, chr(0xEF).chr(0xBB).chr(0xBF))) {
|
383 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_NodeCaptureInterface) {
|
391 |
return $node;
|
392 |
}
|
393 |
|
394 |
+
if ($node instanceof Twig_SupTwgSss_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_SupTwgSss_ParserInterface
|
20 |
{
|
21 |
/**
|
22 |
* Converts a token stream to a node tree.
|
23 |
*
|
24 |
+
* @return Twig_SupTwgSss_Node_Module
|
25 |
*
|
26 |
+
* @throws Twig_SupTwgSss_Error_Syntax When the token stream is syntactically or semantically wrong
|
27 |
*/
|
28 |
+
public function parse(Twig_SupTwgSss_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_SupTwgSss_Profiler_Dumper_Blackfire
|
18 |
{
|
19 |
+
public function dump(Twig_SupTwgSss_Profiler_Profile $profile)
|
20 |
{
|
21 |
$data = array();
|
22 |
$this->dumpProfile('main()', $profile, $data);
|
38 |
return $str;
|
39 |
}
|
40 |
|
41 |
+
private function dumpChildren($parent, Twig_SupTwgSss_Profiler_Profile $profile, &$data)
|
42 |
{
|
43 |
foreach ($profile as $p) {
|
44 |
if ($p->isTemplate()) {
|
51 |
}
|
52 |
}
|
53 |
|
54 |
+
private function dumpProfile($edge, Twig_SupTwgSss_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_SupTwgSss_Profiler_Dumper_Html extends Twig_SupTwgSss_Profiler_Dumper_Text
|
18 |
{
|
19 |
private static $colors = array(
|
20 |
'block' => '#dfd',
|
23 |
'big' => '#d44',
|
24 |
);
|
25 |
|
26 |
+
public function dump(Twig_SupTwgSss_Profiler_Profile $profile)
|
27 |
{
|
28 |
return '<pre>'.parent::dump($profile).'</pre>';
|
29 |
}
|
30 |
|
31 |
+
protected function formatTemplate(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Profiler_Dumper_Text
|
18 |
{
|
19 |
private $root;
|
20 |
|
21 |
+
public function dump(Twig_SupTwgSss_Profiler_Profile $profile)
|
22 |
{
|
23 |
return $this->dumpProfile($profile);
|
24 |
}
|
25 |
|
26 |
+
protected function formatTemplate(Twig_SupTwgSss_Profiler_Profile $profile, $prefix)
|
27 |
{
|
28 |
return sprintf('%s└ %s', $prefix, $profile->getTemplate());
|
29 |
}
|
30 |
|
31 |
+
protected function formatNonTemplate(Twig_SupTwgSss_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_SupTwgSss_Profiler_Profile $profile, $percent)
|
37 |
{
|
38 |
return sprintf('%.2fms/%.0f%%', $profile->getDuration() * 1000, $percent);
|
39 |
}
|
40 |
|
41 |
+
private function dumpProfile(Twig_SupTwgSss_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_SupTwgSss_Profiler_Node_EnterProfile extends Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Profiler_Node_LeaveProfile extends Twig_SupTwgSss_Node
|
18 |
{
|
19 |
public function __construct($varName)
|
20 |
{
|
21 |
parent::__construct(array(), array('var_name' => $varName));
|
22 |
}
|
23 |
|
24 |
+
public function compile(Twig_SupTwgSss_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_SupTwgSss_Profiler_NodeVisitor_Profiler extends Twig_SupTwgSss_BaseNodeVisitor
|
18 |
{
|
19 |
private $extensionName;
|
20 |
|
23 |
$this->extensionName = $extensionName;
|
24 |
}
|
25 |
|
26 |
+
protected function doEnterNode(Twig_SupTwgSss_Node $node, Twig_SupTwgSss_Environment $env)
|
27 |
{
|
28 |
return $node;
|
29 |
}
|
30 |
|
31 |
+
protected function doLeaveNode(Twig_SupTwgSss_Node $node, Twig_SupTwgSss_Environment $env)
|
32 |
{
|
33 |
+
if ($node instanceof Twig_SupTwgSss_Node_Module) {
|
34 |
$varName = $this->getVarName();
|
35 |
+
$node->setNode('display_start', new Twig_SupTwgSss_Node(array(new Twig_SupTwgSss_Profiler_Node_EnterProfile($this->extensionName, Twig_SupTwgSss_Profiler_Profile::TEMPLATE, $node->getTemplateName(), $varName), $node->getNode('display_start'))));
|
36 |
+
$node->setNode('display_end', new Twig_SupTwgSss_Node(array(new Twig_SupTwgSss_Profiler_Node_LeaveProfile($varName), $node->getNode('display_end'))));
|
37 |
+
} elseif ($node instanceof Twig_SupTwgSss_Node_Block) {
|
38 |
$varName = $this->getVarName();
|
39 |
+
$node->setNode('body', new Twig_SupTwgSss_Node_Body(array(
|
40 |
+
new Twig_SupTwgSss_Profiler_Node_EnterProfile($this->extensionName, Twig_SupTwgSss_Profiler_Profile::BLOCK, $node->getAttribute('name'), $varName),
|
41 |
$node->getNode('body'),
|
42 |
+
new Twig_SupTwgSss_Profiler_Node_LeaveProfile($varName),
|
43 |
)));
|
44 |
+
} elseif ($node instanceof Twig_SupTwgSss_Node_Macro) {
|
45 |
$varName = $this->getVarName();
|
46 |
+
$node->setNode('body', new Twig_SupTwgSss_Node_Body(array(
|
47 |
+
new Twig_SupTwgSss_Profiler_Node_EnterProfile($this->extensionName, Twig_SupTwgSss_Profiler_Profile::MACRO, $node->getAttribute('name'), $varName),
|
48 |
$node->getNode('body'),
|
49 |
+
new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Sandbox_SecurityError extends Twig_SupTwgSss_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_SupTwgSss_Sandbox_SecurityNotAllowedFilterError extends Twig_SupTwgSss_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_SupTwgSss_Sandbox_SecurityNotAllowedFunctionError extends Twig_SupTwgSss_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_SupTwgSss_Sandbox_SecurityNotAllowedMethodError extends Twig_SupTwgSss_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_SupTwgSss_Sandbox_SecurityNotAllowedPropertyError extends Twig_SupTwgSss_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_SupTwgSss_Sandbox_SecurityNotAllowedTagError extends Twig_SupTwgSss_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_SupTwgSss_Sandbox_SecurityPolicy implements Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_TemplateInterface || $obj instanceof Twig_SupTwgSss_Markup) {
|
88 |
return true;
|
89 |
}
|
90 |
|
100 |
|
101 |
if (!$allowed) {
|
102 |
$class = get_class($obj);
|
103 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression_Filter',
|
39 |
'deprecated' => false,
|
40 |
'alternative' => null,
|
41 |
), $options);
|
76 |
return $this->options['needs_context'];
|
77 |
}
|
78 |
|
79 |
+
public function getSafe(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node_Expression_Function',
|
37 |
'deprecated' => false,
|
38 |
'alternative' => null,
|
39 |
), $options);
|
74 |
return $this->options['needs_context'];
|
75 |
}
|
76 |
|
77 |
+
public function getSafe(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Source
|
27 |
*
|
28 |
+
* @throws Twig_SupTwgSss_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_SupTwgSss_TemplateWrapper.
|
19 |
*
|
20 |
* @author Fabien Potencier <fabien@symfony.com>
|
21 |
*
|
22 |
* @internal
|
23 |
*/
|
24 |
+
abstract class Twig_SupTwgSss_Template implements Twig_SupTwgSss_TemplateInterface
|
25 |
{
|
26 |
/**
|
27 |
* @internal
|
34 |
protected $blocks = array();
|
35 |
protected $traits = array();
|
36 |
|
37 |
+
public function __construct(Twig_SupTwgSss_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_SupTwgSss_Source
|
87 |
*/
|
88 |
public function getSourceContext()
|
89 |
{
|
90 |
+
return new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Template instance.');
|
211 |
}
|
212 |
|
213 |
if (null !== $template) {
|
214 |
try {
|
215 |
$template->$block($context, $blocks);
|
216 |
+
} catch (Twig_SupTwgSss_Error $e) {
|
217 |
if (!$e->getSourceContext()) {
|
218 |
$e->setSourceContext($template->getSourceContext());
|
219 |
}
|
220 |
|
221 |
+
// this is mostly useful for Twig_SupTwgSss_Error_Loader exceptions
|
222 |
+
// see Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_TemplateWrapper) {
|
363 |
return $template;
|
364 |
}
|
365 |
|
366 |
return $this->env->loadTemplate($template, $index);
|
367 |
+
} catch (Twig_SupTwgSss_Error $e) {
|
368 |
if (!$e->getSourceContext()) {
|
369 |
+
$e->setSourceContext($templateName ? new Twig_SupTwgSss_Source('', $templateName) : $this->getSourceContext());
|
370 |
}
|
371 |
|
372 |
if ($e->getTemplateLine()) {
|
430 |
{
|
431 |
try {
|
432 |
$this->doDisplay($context, $blocks);
|
433 |
+
} catch (Twig_SupTwgSss_Error $e) {
|
434 |
if (!$e->getSourceContext()) {
|
435 |
$e->setSourceContext($this->getSourceContext());
|
436 |
}
|
437 |
|
438 |
+
// this is mostly useful for Twig_SupTwgSss_Error_Loader exceptions
|
439 |
+
// see Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Error_Runtime($message, -1, $this->getSourceContext());
|
576 |
}
|
577 |
|
578 |
// object property
|
579 |
+
if (self::METHOD_CALL !== $type && !$object instanceof self) { // Twig_SupTwgSss_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_SupTwgSss_Extension_Sandbox')) {
|
586 |
+
$this->env->getExtension('Twig_SupTwgSss_Extension_Sandbox')->checkPropertyAllowed($object, $item);
|
587 |
}
|
588 |
|
589 |
return $object->$item;
|
657 |
return;
|
658 |
}
|
659 |
|
660 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_Extension_Sandbox')) {
|
668 |
+
$this->env->getExtension('Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Environment::load() instead).
|
25 |
*
|
26 |
* @internal
|
27 |
*/
|
28 |
+
public function __construct(Twig_SupTwgSss_Environment $env, Twig_SupTwgSss_Template $template)
|
29 |
{
|
30 |
$this->env = $env;
|
31 |
$this->template = $template;
|
122 |
}
|
123 |
|
124 |
/**
|
125 |
+
* @return Twig_SupTwgSss_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_SupTwgSss_Test class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSss_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_SupTwgSss_Test implements Twig_SupTwgSss_TestInterface, Twig_SupTwgSss_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_SupTwgSss_Test_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSss_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_SupTwgSss_Test_Function extends Twig_SupTwgSss_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_SupTwgSss_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
|
19 |
{
|
20 |
/**
|
21 |
* @return string
|
23 |
abstract protected function getFixturesDir();
|
24 |
|
25 |
/**
|
26 |
+
* @return Twig_SupTwgSss_ExtensionInterface[]
|
27 |
*/
|
28 |
protected function getExtensions()
|
29 |
{
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
+
* @return Twig_SupTwgSss_SimpleFilter[]
|
35 |
*/
|
36 |
protected function getTwigFilters()
|
37 |
{
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
+
* @return Twig_SupTwgSss_SimpleFunction[]
|
43 |
*/
|
44 |
protected function getTwigFunctions()
|
45 |
{
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* @return Twig_SupTwgSss_SimpleTest[]
|
51 |
*/
|
52 |
protected function getTwigTests()
|
53 |
{
|
132 |
}
|
133 |
}
|
134 |
|
135 |
+
$loader = new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e);
|
181 |
}
|
182 |
|
183 |
try {
|
189 |
return;
|
190 |
}
|
191 |
|
192 |
+
$e = new Twig_SupTwgSss_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_SupTwgSss_SourceContextLoaderInterface) {
|
211 |
+
$source = new Twig_SupTwgSss_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_SupTwgSss_Test_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SupTwgSss_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_SupTwgSss_Test_Method extends Twig_SupTwgSss_Test
|
22 |
{
|
23 |
protected $extension;
|
24 |
protected $method;
|
25 |
|
26 |
+
public function __construct(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Test_Node extends Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Node $node, Twig_SupTwgSss_Environment $environment = null, $isPattern = false)
|
24 |
{
|
25 |
$compiler = $this->getCompiler($environment);
|
26 |
$compiler->compile($node);
|
32 |
}
|
33 |
}
|
34 |
|
35 |
+
protected function getCompiler(Twig_SupTwgSss_Environment $environment = null)
|
36 |
{
|
37 |
+
return new Twig_SupTwgSss_Compiler(null === $environment ? $this->getEnvironment() : $environment);
|
38 |
}
|
39 |
|
40 |
protected function getEnvironment()
|
41 |
{
|
42 |
+
return new Twig_SupTwgSss_Environment(new Twig_SupTwgSss_Loader_Array(array()));
|
43 |
}
|
44 |
|
45 |
protected function getVariableGetter($name, $line = false)
|
59 |
|
60 |
protected function getAttributeGetter()
|
61 |
{
|
62 |
+
if (function_exists('Twig_SupTwgSss_template_get_attributes')) {
|
63 |
+
return 'Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_TokenParser implements Twig_SupTwgSss_TokenParserInterface
|
18 |
{
|
19 |
/**
|
20 |
+
* @var Twig_SupTwgSss_Parser
|
21 |
*/
|
22 |
protected $parser;
|
23 |
|
24 |
/**
|
25 |
* Sets the parser associated with this token parser.
|
26 |
*/
|
27 |
+
public function setParser(Twig_SupTwgSss_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_SupTwgSss_TokenParser_AutoEscape extends Twig_SupTwgSss_TokenParser
|
33 |
{
|
34 |
+
public function parse(Twig_SupTwgSss_Token $token)
|
35 |
{
|
36 |
$lineno = $token->getLine();
|
37 |
$stream = $this->parser->getStream();
|
38 |
|
39 |
+
if ($stream->test(Twig_SupTwgSss_Token::BLOCK_END_TYPE)) {
|
40 |
$value = 'html';
|
41 |
} else {
|
42 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
43 |
+
if (!$expr instanceof Twig_SupTwgSss_Node_Expression_Constant) {
|
44 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Token::BLOCK_END_TYPE);
|
66 |
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
67 |
+
$stream->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
68 |
|
69 |
+
return new Twig_SupTwgSss_Node_AutoEscape($value, $body, $lineno, $this->getTag());
|
70 |
}
|
71 |
|
72 |
+
public function decideBlockEnd(Twig_SupTwgSss_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_SupTwgSss_TokenParser_Block extends Twig_SupTwgSss_TokenParser
|
26 |
{
|
27 |
+
public function parse(Twig_SupTwgSss_Token $token)
|
28 |
{
|
29 |
$lineno = $token->getLine();
|
30 |
$stream = $this->parser->getStream();
|
31 |
+
$name = $stream->expect(Twig_SupTwgSss_Token::NAME_TYPE)->getValue();
|
32 |
if ($this->parser->hasBlock($name)) {
|
33 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_Node_Block($name, new Twig_SupTwgSss_Node(array()), $lineno));
|
36 |
$this->parser->pushLocalScope();
|
37 |
$this->parser->pushBlockStack($name);
|
38 |
|
39 |
+
if ($stream->nextIf(Twig_SupTwgSss_Token::BLOCK_END_TYPE)) {
|
40 |
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
41 |
+
if ($token = $stream->nextIf(Twig_SupTwgSss_Token::NAME_TYPE)) {
|
42 |
$value = $token->getValue();
|
43 |
|
44 |
if ($value != $name) {
|
45 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_Node(array(
|
50 |
+
new Twig_SupTwgSss_Node_Print($this->parser->getExpressionParser()->parseExpression(), $lineno),
|
51 |
));
|
52 |
}
|
53 |
+
$stream->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
54 |
|
55 |
$block->setNode('body', $body);
|
56 |
$this->parser->popBlockStack();
|
57 |
$this->parser->popLocalScope();
|
58 |
|
59 |
+
return new Twig_SupTwgSss_Node_BlockReference($name, $lineno, $this->getTag());
|
60 |
}
|
61 |
|
62 |
+
public function decideBlockEnd(Twig_SupTwgSss_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_SupTwgSss_TokenParser_Do extends Twig_SupTwgSss_TokenParser
|
18 |
{
|
19 |
+
public function parse(Twig_SupTwgSss_Token $token)
|
20 |
{
|
21 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
22 |
|
23 |
+
$this->parser->getStream()->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
24 |
|
25 |
+
return new Twig_SupTwgSss_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_SupTwgSss_TokenParser_Embed extends Twig_SupTwgSss_TokenParser_Include
|
18 |
{
|
19 |
+
public function parse(Twig_SupTwgSss_Token $token)
|
20 |
{
|
21 |
$stream = $this->parser->getStream();
|
22 |
|
24 |
|
25 |
list($variables, $only, $ignoreMissing) = $this->parseArguments();
|
26 |
|
27 |
+
$parentToken = $fakeParentToken = new Twig_SupTwgSss_Token(Twig_SupTwgSss_Token::STRING_TYPE, '__parent__', $token->getLine());
|
28 |
+
if ($parent instanceof Twig_SupTwgSss_Node_Expression_Constant) {
|
29 |
+
$parentToken = new Twig_SupTwgSss_Token(Twig_SupTwgSss_Token::STRING_TYPE, $parent->getAttribute('value'), $token->getLine());
|
30 |
+
} elseif ($parent instanceof Twig_SupTwgSss_Node_Expression_Name) {
|
31 |
+
$parentToken = new Twig_SupTwgSss_Token(Twig_SupTwgSss_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_SupTwgSss_Token(Twig_SupTwgSss_Token::BLOCK_START_TYPE, '', $token->getLine()),
|
37 |
+
new Twig_SupTwgSss_Token(Twig_SupTwgSss_Token::NAME_TYPE, 'extends', $token->getLine()),
|
38 |
$parentToken,
|
39 |
+
new Twig_SupTwgSss_Token(Twig_SupTwgSss_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_SupTwgSss_Token::BLOCK_END_TYPE);
|
52 |
|
53 |
+
return new Twig_SupTwgSss_Node_Embed($module->getTemplateName(), $module->getAttribute('index'), $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag());
|
54 |
}
|
55 |
|
56 |
+
public function decideBlockEnd(Twig_SupTwgSss_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_SupTwgSss_TokenParser_Extends extends Twig_SupTwgSss_TokenParser
|
23 |
{
|
24 |
+
public function parse(Twig_SupTwgSss_Token $token)
|
25 |
{
|
26 |
$stream = $this->parser->getStream();
|
27 |
|
28 |
if (!$this->parser->isMainScope()) {
|
29 |
+
throw new Twig_SupTwgSss_Error_Syntax('Cannot extend from a block.', $token->getLine(), $stream->getSourceContext());
|
30 |
}
|
31 |
|
32 |
if (null !== $this->parser->getParent()) {
|
33 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_TokenParser_Filter extends Twig_SupTwgSss_TokenParser
|
24 |
{
|
25 |
+
public function parse(Twig_SupTwgSss_Token $token)
|
26 |
{
|
27 |
$name = $this->parser->getVarName();
|
28 |
+
$ref = new Twig_SupTwgSss_Node_Expression_BlockReference(new Twig_SupTwgSss_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_SupTwgSss_Token::BLOCK_END_TYPE);
|
32 |
|
33 |
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
34 |
+
$this->parser->getStream()->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
35 |
|
36 |
+
$block = new Twig_SupTwgSss_Node_Block($name, $body, $token->getLine());
|
37 |
$this->parser->setBlock($name, $block);
|
38 |
|
39 |
+
return new Twig_SupTwgSss_Node_Print($filter, $token->getLine(), $this->getTag());
|
40 |
}
|
41 |
|
42 |
+
public function decideBlockEnd(Twig_SupTwgSss_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_SupTwgSss_TokenParser_Flush extends Twig_SupTwgSss_TokenParser
|
20 |
{
|
21 |
+
public function parse(Twig_SupTwgSss_Token $token)
|
22 |
{
|
23 |
+
$this->parser->getStream()->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
24 |
|
25 |
+
return new Twig_SupTwgSss_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_SupTwgSss_TokenParser_For extends Twig_SupTwgSss_TokenParser
|
27 |
{
|
28 |
+
public function parse(Twig_SupTwgSss_Token $token)
|
29 |
{
|
30 |
$lineno = $token->getLine();
|
31 |
$stream = $this->parser->getStream();
|
32 |
$targets = $this->parser->getExpressionParser()->parseAssignmentExpression();
|
33 |
+
$stream->expect(Twig_SupTwgSss_Token::OPERATOR_TYPE, 'in');
|
34 |
$seq = $this->parser->getExpressionParser()->parseExpression();
|
35 |
|
36 |
$ifexpr = null;
|
37 |
+
if ($stream->nextIf(Twig_SupTwgSss_Token::NAME_TYPE, 'if')) {
|
38 |
$ifexpr = $this->parser->getExpressionParser()->parseExpression();
|
39 |
}
|
40 |
|
41 |
+
$stream->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
42 |
$body = $this->parser->subparse(array($this, 'decideForFork'));
|
43 |
if ($stream->next()->getValue() == 'else') {
|
44 |
+
$stream->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
45 |
$else = $this->parser->subparse(array($this, 'decideForEnd'), true);
|
46 |
} else {
|
47 |
$else = null;
|
48 |
}
|
49 |
+
$stream->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
50 |
|
51 |
if (count($targets) > 1) {
|
52 |
$keyTarget = $targets->getNode(0);
|
53 |
+
$keyTarget = new Twig_SupTwgSss_Node_Expression_AssignName($keyTarget->getAttribute('name'), $keyTarget->getTemplateLine());
|
54 |
$valueTarget = $targets->getNode(1);
|
55 |
+
$valueTarget = new Twig_SupTwgSss_Node_Expression_AssignName($valueTarget->getAttribute('name'), $valueTarget->getTemplateLine());
|
56 |
} else {
|
57 |
+
$keyTarget = new Twig_SupTwgSss_Node_Expression_AssignName('_key', $lineno);
|
58 |
$valueTarget = $targets->getNode(0);
|
59 |
+
$valueTarget = new Twig_SupTwgSss_Node_Expression_AssignName($valueTarget->getAttribute('name'), $valueTarget->getTemplateLine());
|
60 |
}
|
61 |
|
62 |
if ($ifexpr) {
|
64 |
$this->checkLoopUsageBody($stream, $body);
|
65 |
}
|
66 |
|
67 |
+
return new Twig_SupTwgSss_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, $lineno, $this->getTag());
|
68 |
}
|
69 |
|
70 |
+
public function decideForFork(Twig_SupTwgSss_Token $token)
|
71 |
{
|
72 |
return $token->test(array('else', 'endfor'));
|
73 |
}
|
74 |
|
75 |
+
public function decideForEnd(Twig_SupTwgSss_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_SupTwgSss_TokenStream $stream, Twig_SupTwgSss_NodeInterface $node)
|
82 |
{
|
83 |
+
if ($node instanceof Twig_SupTwgSss_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_SupTwgSss_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) {
|
84 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_TokenStream $stream, Twig_SupTwgSss_NodeInterface $node)
|
99 |
{
|
100 |
+
if ($node instanceof Twig_SupTwgSss_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_SupTwgSss_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) {
|
101 |
$attribute = $node->getNode('attribute');
|
102 |
+
if ($attribute instanceof Twig_SupTwgSss_Node_Expression_Constant && in_array($attribute->getAttribute('value'), array('length', 'revindex0', 'revindex', 'last'))) {
|
103 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_TokenParser_From extends Twig_SupTwgSss_TokenParser
|
22 |
{
|
23 |
+
public function parse(Twig_SupTwgSss_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_SupTwgSss_Token::NAME_TYPE)->getValue();
|
32 |
|
33 |
$alias = $name;
|
34 |
if ($stream->nextIf('as')) {
|
35 |
+
$alias = $stream->expect(Twig_SupTwgSss_Token::NAME_TYPE)->getValue();
|
36 |
}
|
37 |
|
38 |
$targets[$name] = $alias;
|
39 |
|
40 |
+
if (!$stream->nextIf(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, ',')) {
|
41 |
break;
|
42 |
}
|
43 |
} while (true);
|
44 |
|
45 |
+
$stream->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
46 |
|
47 |
+
$node = new Twig_SupTwgSss_Node_Import($macro, new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_TokenParser_If extends Twig_SupTwgSss_TokenParser
|
29 |
{
|
30 |
+
public function parse(Twig_SupTwgSss_Token $token)
|
31 |
{
|
32 |
$lineno = $token->getLine();
|
33 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
34 |
$stream = $this->parser->getStream();
|
35 |
+
$stream->expect(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Token::BLOCK_END_TYPE);
|
66 |
|
67 |
+
return new Twig_SupTwgSss_Node_If(new Twig_SupTwgSss_Node($tests), $else, $lineno, $this->getTag());
|
68 |
}
|
69 |
|
70 |
+
public function decideIfFork(Twig_SupTwgSss_Token $token)
|
71 |
{
|
72 |
return $token->test(array('elseif', 'else', 'endif'));
|
73 |
}
|
74 |
|
75 |
+
public function decideIfEnd(Twig_SupTwgSss_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_SupTwgSss_TokenParser_Import extends Twig_SupTwgSss_TokenParser
|
22 |
{
|
23 |
+
public function parse(Twig_SupTwgSss_Token $token)
|
24 |
{
|
25 |
$macro = $this->parser->getExpressionParser()->parseExpression();
|
26 |
$this->parser->getStream()->expect('as');
|
27 |
+
$var = new Twig_SupTwgSss_Node_Expression_AssignName($this->parser->getStream()->expect(Twig_SupTwgSss_Token::NAME_TYPE)->getValue(), $token->getLine());
|
28 |
+
$this->parser->getStream()->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
29 |
|
30 |
$this->parser->addImportedSymbol('template', $var->getAttribute('name'));
|
31 |
|
32 |
+
return new Twig_SupTwgSss_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_SupTwgSss_TokenParser_Include extends Twig_SupTwgSss_TokenParser
|
25 |
{
|
26 |
+
public function parse(Twig_SupTwgSss_Token $token)
|
27 |
{
|
28 |
$expr = $this->parser->getExpressionParser()->parseExpression();
|
29 |
|
30 |
list($variables, $only, $ignoreMissing) = $this->parseArguments();
|
31 |
|
32 |
+
return new Twig_SupTwgSss_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_SupTwgSss_Token::NAME_TYPE, 'ignore')) {
|
41 |
+
$stream->expect(Twig_SupTwgSss_Token::NAME_TYPE, 'missing');
|
42 |
|
43 |
$ignoreMissing = true;
|
44 |
}
|
45 |
|
46 |
$variables = null;
|
47 |
+
if ($stream->nextIf(Twig_SupTwgSss_Token::NAME_TYPE, 'with')) {
|
48 |
$variables = $this->parser->getExpressionParser()->parseExpression();
|
49 |
}
|
50 |
|
51 |
$only = false;
|
52 |
+
if ($stream->nextIf(Twig_SupTwgSss_Token::NAME_TYPE, 'only')) {
|
53 |
$only = true;
|
54 |
}
|
55 |
|
56 |
+
$stream->expect(Twig_SupTwgSss_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_SupTwgSss_TokenParser_Macro extends Twig_SupTwgSss_TokenParser
|
24 |
{
|
25 |
+
public function parse(Twig_SupTwgSss_Token $token)
|
26 |
{
|
27 |
$lineno = $token->getLine();
|
28 |
$stream = $this->parser->getStream();
|
29 |
+
$name = $stream->expect(Twig_SupTwgSss_Token::NAME_TYPE)->getValue();
|
30 |
|
31 |
$arguments = $this->parser->getExpressionParser()->parseArguments(true, true);
|
32 |
|
33 |
+
$stream->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
34 |
$this->parser->pushLocalScope();
|
35 |
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
36 |
+
if ($token = $stream->nextIf(Twig_SupTwgSss_Token::NAME_TYPE)) {
|
37 |
$value = $token->getValue();
|
38 |
|
39 |
if ($value != $name) {
|
40 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_Token::BLOCK_END_TYPE);
|
45 |
|
46 |
+
$this->parser->setMacro($name, new Twig_SupTwgSss_Node_Macro($name, new Twig_SupTwgSss_Node_Body(array($body)), $arguments, $lineno, $this->getTag()));
|
47 |
}
|
48 |
|
49 |
+
public function decideBlockEnd(Twig_SupTwgSss_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_SupTwgSss_TokenParser_Sandbox extends Twig_SupTwgSss_TokenParser
|
26 |
{
|
27 |
+
public function parse(Twig_SupTwgSss_Token $token)
|
28 |
{
|
29 |
$stream = $this->parser->getStream();
|
30 |
+
$stream->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
31 |
$body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
32 |
+
$stream->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
33 |
|
34 |
// in a sandbox tag, only include tags are allowed
|
35 |
+
if (!$body instanceof Twig_SupTwgSss_Node_Include) {
|
36 |
foreach ($body as $node) {
|
37 |
+
if ($node instanceof Twig_SupTwgSss_Node_Text && ctype_space($node->getAttribute('data'))) {
|
38 |
continue;
|
39 |
}
|
40 |
|
41 |
+
if (!$node instanceof Twig_SupTwgSss_Node_Include) {
|
42 |
+
throw new Twig_SupTwgSss_Error_Syntax('Only "include" tags are allowed within a "sandbox" section.', $node->getTemplateLine(), $stream->getSourceContext());
|
43 |
}
|
44 |
}
|
45 |
}
|
46 |
|
47 |
+
return new Twig_SupTwgSss_Node_Sandbox($body, $token->getLine(), $this->getTag());
|
48 |
}
|
49 |
|
50 |
+
public function decideBlockEnd(Twig_SupTwgSss_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_SupTwgSss_TokenParser_Set extends Twig_SupTwgSss_TokenParser
|
32 |
{
|
33 |
+
public function parse(Twig_SupTwgSss_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_SupTwgSss_Token::OPERATOR_TYPE, '=')) {
|
41 |
$values = $this->parser->getExpressionParser()->parseMultitargetExpression();
|
42 |
|
43 |
+
$stream->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
44 |
|
45 |
if (count($names) !== count($values)) {
|
46 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Token::BLOCK_END_TYPE);
|
56 |
|
57 |
$values = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
|
58 |
+
$stream->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
59 |
}
|
60 |
|
61 |
+
return new Twig_SupTwgSss_Node_Set($capture, $names, $values, $lineno, $this->getTag());
|
62 |
}
|
63 |
|
64 |
+
public function decideBlockEnd(Twig_SupTwgSss_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_SupTwgSss_TokenParser_Spaceless extends Twig_SupTwgSss_TokenParser
|
28 |
{
|
29 |
+
public function parse(Twig_SupTwgSss_Token $token)
|
30 |
{
|
31 |
$lineno = $token->getLine();
|
32 |
|
33 |
+
$this->parser->getStream()->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
34 |
$body = $this->parser->subparse(array($this, 'decideSpacelessEnd'), true);
|
35 |
+
$this->parser->getStream()->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
36 |
|
37 |
+
return new Twig_SupTwgSss_Node_Spaceless($body, $lineno, $this->getTag());
|
38 |
}
|
39 |
|
40 |
+
public function decideSpacelessEnd(Twig_SupTwgSss_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_SupTwgSss_TokenParser_Use extends Twig_SupTwgSss_TokenParser
|
29 |
{
|
30 |
+
public function parse(Twig_SupTwgSss_Token $token)
|
31 |
{
|
32 |
$template = $this->parser->getExpressionParser()->parseExpression();
|
33 |
$stream = $this->parser->getStream();
|
34 |
|
35 |
+
if (!$template instanceof Twig_SupTwgSss_Node_Expression_Constant) {
|
36 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_Token::NAME_TYPE)->getValue();
|
43 |
|
44 |
$alias = $name;
|
45 |
if ($stream->nextIf('as')) {
|
46 |
+
$alias = $stream->expect(Twig_SupTwgSss_Token::NAME_TYPE)->getValue();
|
47 |
}
|
48 |
|
49 |
+
$targets[$name] = new Twig_SupTwgSss_Node_Expression_Constant($alias, -1);
|
50 |
|
51 |
+
if (!$stream->nextIf(Twig_SupTwgSss_Token::PUNCTUATION_TYPE, ',')) {
|
52 |
break;
|
53 |
}
|
54 |
} while (true);
|
55 |
}
|
56 |
|
57 |
+
$stream->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
58 |
|
59 |
+
$this->parser->addTrait(new Twig_SupTwgSss_Node(array('template' => $template, 'targets' => new Twig_SupTwgSss_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_SupTwgSss_TokenParser_With extends Twig_SupTwgSss_TokenParser
|
20 |
{
|
21 |
+
public function parse(Twig_SupTwgSss_Token $token)
|
22 |
{
|
23 |
$stream = $this->parser->getStream();
|
24 |
|
25 |
$variables = null;
|
26 |
$only = false;
|
27 |
+
if (!$stream->test(Twig_SupTwgSss_Token::BLOCK_END_TYPE)) {
|
28 |
$variables = $this->parser->getExpressionParser()->parseExpression();
|
29 |
+
$only = $stream->nextIf(Twig_SupTwgSss_Token::NAME_TYPE, 'only');
|
30 |
}
|
31 |
|
32 |
+
$stream->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
33 |
|
34 |
$body = $this->parser->subparse(array($this, 'decideWithEnd'), true);
|
35 |
|
36 |
+
$stream->expect(Twig_SupTwgSss_Token::BLOCK_END_TYPE);
|
37 |
|
38 |
+
return new Twig_SupTwgSss_Node_With($body, $variables, $only, $token->getLine(), $this->getTag());
|
39 |
}
|
40 |
|
41 |
+
public function decideWithEnd(Twig_SupTwgSss_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_SupTwgSss_TokenParserBroker implements Twig_SupTwgSss_TokenParserBrokerInterface
|
21 |
{
|
22 |
protected $parser;
|
23 |
protected $parsers = array();
|
24 |
protected $brokers = array();
|
25 |
|
26 |
/**
|
27 |
+
* @param array|Traversable $parsers A Traversable of Twig_SupTwgSss_TokenParserInterface instances
|
28 |
+
* @param array|Traversable $brokers A Traversable of Twig_SupTwgSss_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_SupTwgSss_TokenParserInterface) {
|
39 |
+
throw new LogicException('$parsers must a an array of Twig_SupTwgSss_TokenParserInterface.');
|
40 |
}
|
41 |
$this->parsers[$parser->getTag()] = $parser;
|
42 |
}
|
43 |
foreach ($brokers as $broker) {
|
44 |
+
if (!$broker instanceof Twig_SupTwgSss_TokenParserBrokerInterface) {
|
45 |
+
throw new LogicException('$brokers must a an array of Twig_SupTwgSss_TokenParserBrokerInterface.');
|
46 |
}
|
47 |
$this->brokers[] = $broker;
|
48 |
}
|
49 |
}
|
50 |
|
51 |
+
public function addTokenParser(Twig_SupTwgSss_TokenParserInterface $parser)
|
52 |
{
|
53 |
$this->parsers[$parser->getTag()] = $parser;
|
54 |
}
|
55 |
|
56 |
+
public function removeTokenParser(Twig_SupTwgSss_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_SupTwgSss_TokenParserBroker $broker)
|
65 |
{
|
66 |
$this->brokers[] = $broker;
|
67 |
}
|
68 |
|
69 |
+
public function removeTokenParserBroker(Twig_SupTwgSss_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_SupTwgSss_TokenParserInterface A Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_TokenParserBrokerInterface
|
23 |
{
|
24 |
/**
|
25 |
* Gets a TokenParser suitable for a tag.
|
26 |
*
|
27 |
* @param string $tag A tag name
|
28 |
*
|
29 |
+
* @return Twig_SupTwgSss_TokenParserInterface|null A Twig_SupTwgSss_TokenParserInterface or null if no suitable TokenParser was found
|
30 |
*/
|
31 |
public function getTokenParser($tag);
|
32 |
|
33 |
/**
|
34 |
+
* Calls Twig_SupTwgSss_TokenParserInterface::setParser on all parsers the implementation knows of.
|
35 |
*/
|
36 |
+
public function setParser(Twig_SupTwgSss_ParserInterface $parser);
|
37 |
|
38 |
/**
|
39 |
+
* Gets the Twig_SupTwgSss_ParserInterface.
|
40 |
*
|
41 |
+
* @return null|Twig_SupTwgSss_ParserInterface A Twig_SupTwgSss_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_SupTwgSss_TokenParserInterface
|
18 |
{
|
19 |
/**
|
20 |
* Sets the parser associated with this token parser.
|
21 |
*/
|
22 |
+
public function setParser(Twig_SupTwgSss_Parser $parser);
|
23 |
|
24 |
/**
|
25 |
* Parses a token and returns a node.
|
26 |
*
|
27 |
+
* @return Twig_SupTwgSss_NodeInterface
|
28 |
*
|
29 |
+
* @throws Twig_SupTwgSss_Error_Syntax
|
30 |
*/
|
31 |
+
public function parse(Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
|
38 |
}
|
39 |
+
$this->source = new Twig_SupTwgSss_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_SupTwgSss_Token
|
64 |
*/
|
65 |
public function next()
|
66 |
{
|
67 |
if (!isset($this->tokens[++$this->current])) {
|
68 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Error_Syntax(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s).',
|
97 |
$message ? $message.'. ' : '',
|
98 |
+
Twig_SupTwgSss_Token::typeToEnglish($token->getType()), $token->getValue(),
|
99 |
+
Twig_SupTwgSss_Token::typeToEnglish($type), $value ? sprintf(' with value "%s"', $value) : ''),
|
100 |
$line,
|
101 |
$this->source
|
102 |
);
|
111 |
*
|
112 |
* @param int $number
|
113 |
*
|
114 |
+
* @return Twig_SupTwgSss_Token
|
115 |
*/
|
116 |
public function look($number = 1)
|
117 |
{
|
118 |
if (!isset($this->tokens[$this->current + $number])) {
|
119 |
+
throw new Twig_SupTwgSss_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_SupTwgSss_Token::EOF_TYPE;
|
143 |
}
|
144 |
|
145 |
/**
|
146 |
+
* @return Twig_SupTwgSss_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_SupTwgSss_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_SupTwgSss_Util_DeprecationCollector
|
18 |
{
|
19 |
private $twig;
|
20 |
private $deprecations;
|
21 |
|
22 |
+
public function __construct(Twig_SupTwgSss_Environment $twig)
|
23 |
{
|
24 |
$this->twig = $twig;
|
25 |
}
|
40 |
), '{'.preg_quote($ext).'$}'
|
41 |
);
|
42 |
|
43 |
+
return $this->collect(new Twig_SupTwgSss_Util_TemplateDirIterator($iterator));
|
44 |
}
|
45 |
|
46 |
/**
|
58 |
|
59 |
foreach ($iterator as $name => $contents) {
|
60 |
try {
|
61 |
+
$this->twig->parse($this->twig->tokenize(new Twig_SupTwgSss_Source($contents, $name)));
|
62 |
+
} catch (Twig_SupTwgSss_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_SupTwgSss_Util_TemplateDirIterator extends IteratorIterator
|
16 |
{
|
17 |
public function current()
|
18 |
{
|