From 36d14d98df497ffe023b6da040152ee9b6ea5cc2 Mon Sep 17 00:00:00 2001 From: "Bruno O. Notario" Date: Fri, 8 Apr 2022 20:13:41 -0300 Subject: [PATCH] Cleaned old packages Removed non based composer templates --- system/templateEngines/Dwoo/autoload.php | 8 - .../Dwoo/composer/ClassLoader.php | 445 -- system/templateEngines/Dwoo/composer/LICENSE | 21 - .../Dwoo/composer/autoload_classmap.php | 9 - .../Dwoo/composer/autoload_namespaces.php | 9 - .../Dwoo/composer/autoload_psr4.php | 10 - .../Dwoo/composer/autoload_real.php | 52 - .../Dwoo/composer/autoload_static.php | 31 - .../Dwoo/composer/installed.json | 43 - .../templateEngines/Dwoo/dwoo/dwoo/.gitignore | 12 - .../Dwoo/dwoo/dwoo/.gitlab-ci.yml | 77 - .../Dwoo/dwoo/dwoo/.travis.yml | 13 - .../templateEngines/Dwoo/dwoo/dwoo/LICENSE.md | 165 - .../templateEngines/Dwoo/dwoo/dwoo/README.md | 95 - .../Dwoo/dwoo/dwoo/composer.json | 28 - .../Dwoo/dwoo/dwoo/docker-compose.yml | 7 - .../Dwoo/dwoo/dwoo/lib/Dwoo/Block/Plugin.php | 119 - .../dwoo/lib/Dwoo/Compilation/Exception.php | 60 - .../Dwoo/dwoo/dwoo/lib/Dwoo/Compiler.php | 3681 ----------------- .../Dwoo/dwoo/dwoo/lib/Dwoo/Core.php | 1795 -------- .../Dwoo/dwoo/dwoo/lib/Dwoo/Data.php | 264 -- .../Dwoo/dwoo/dwoo/lib/Dwoo/Exception.php | 26 - .../Dwoo/dwoo/dwoo/lib/Dwoo/Filter.php | 52 - .../Dwoo/dwoo/dwoo/lib/Dwoo/ICompilable.php | 31 - .../dwoo/dwoo/lib/Dwoo/ICompilable/Block.php | 27 - .../Dwoo/dwoo/dwoo/lib/Dwoo/ICompiler.php | 59 - .../Dwoo/dwoo/dwoo/lib/Dwoo/IDataProvider.php | 32 - .../Dwoo/dwoo/dwoo/lib/Dwoo/IElseable.php | 30 - .../Dwoo/dwoo/dwoo/lib/Dwoo/ILoader.php | 37 - .../Dwoo/dwoo/dwoo/lib/Dwoo/IPluginProxy.php | 74 - .../Dwoo/dwoo/dwoo/lib/Dwoo/ITemplate.php | 161 - .../Dwoo/dwoo/dwoo/lib/Dwoo/Loader.php | 190 - .../Dwoo/dwoo/dwoo/lib/Dwoo/Plugin.php | 105 - .../dwoo/lib/Dwoo/Plugins/Blocks/PluginA.php | 95 - .../Dwoo/Plugins/Blocks/PluginAutoEscape.php | 98 - .../lib/Dwoo/Plugins/Blocks/PluginBlock.php | 66 - .../lib/Dwoo/Plugins/Blocks/PluginCapture.php | 95 - .../lib/Dwoo/Plugins/Blocks/PluginDynamic.php | 116 - .../lib/Dwoo/Plugins/Blocks/PluginElse.php | 96 - .../lib/Dwoo/Plugins/Blocks/PluginElseif.php | 95 - .../lib/Dwoo/Plugins/Blocks/PluginFor.php | 192 - .../lib/Dwoo/Plugins/Blocks/PluginForeach.php | 201 - .../Dwoo/Plugins/Blocks/PluginForeachelse.php | 73 - .../lib/Dwoo/Plugins/Blocks/PluginForelse.php | 73 - .../dwoo/lib/Dwoo/Plugins/Blocks/PluginIf.php | 274 -- .../lib/Dwoo/Plugins/Blocks/PluginLoop.php | 170 - .../lib/Dwoo/Plugins/Blocks/PluginSection.php | 159 - .../Plugins/Blocks/PluginSmartyinterface.php | 96 - .../lib/Dwoo/Plugins/Blocks/PluginStrip.php | 89 - .../Dwoo/Plugins/Blocks/PluginTemplate.php | 115 - .../Dwoo/Plugins/Blocks/PluginTextformat.php | 119 - .../Plugins/Blocks/PluginTopLevelBlock.php | 60 - .../lib/Dwoo/Plugins/Blocks/PluginWith.php | 99 - .../Dwoo/Plugins/Blocks/PluginWithelse.php | 73 - .../Dwoo/Plugins/Filters/PluginHtmlFormat.php | 190 - .../Dwoo/Plugins/Functions/PluginAssign.php | 46 - .../Plugins/Functions/PluginCapitalize.php | 56 - .../lib/Dwoo/Plugins/Functions/PluginCat.php | 44 - .../Functions/PluginCountCharacters.php | 49 - .../Functions/PluginCountParagraphs.php | 43 - .../Functions/PluginCountSentences.php | 43 - .../Plugins/Functions/PluginCountWords.php | 37 - .../Dwoo/Plugins/Functions/PluginCounter.php | 94 - .../Dwoo/Plugins/Functions/PluginCycle.php | 91 - .../Plugins/Functions/PluginDateFormat.php | 92 - .../Dwoo/Plugins/Functions/PluginDefault.php | 45 - .../lib/Dwoo/Plugins/Functions/PluginDump.php | 210 - .../lib/Dwoo/Plugins/Functions/PluginEol.php | 39 - .../Dwoo/Plugins/Functions/PluginEscape.php | 103 - .../lib/Dwoo/Plugins/Functions/PluginEval.php | 62 - .../Dwoo/Plugins/Functions/PluginExtends.php | 206 - .../Plugins/Functions/PluginExtendsCheck.php | 75 - .../Dwoo/Plugins/Functions/PluginFetch.php | 82 - .../Dwoo/Plugins/Functions/PluginInclude.php | 110 - .../Dwoo/Plugins/Functions/PluginIndent.php | 47 - .../Dwoo/Plugins/Functions/PluginIsset.php | 43 - .../Plugins/Functions/PluginLoadTemplates.php | 99 - .../Dwoo/Plugins/Functions/PluginLower.php | 43 - .../Dwoo/Plugins/Functions/PluginMailto.php | 144 - .../lib/Dwoo/Plugins/Functions/PluginMath.php | 199 - .../Dwoo/Plugins/Functions/PluginNl2br.php | 43 - .../Dwoo/Plugins/Functions/PluginOptional.php | 43 - .../Plugins/Functions/PluginRegexReplace.php | 63 - .../Dwoo/Plugins/Functions/PluginReplace.php | 52 - .../Dwoo/Plugins/Functions/PluginReturn.php | 54 - .../Dwoo/Plugins/Functions/PluginReverse.php | 54 - .../lib/Dwoo/Plugins/Functions/PluginSafe.php | 46 - .../Dwoo/Plugins/Functions/PluginSpacify.php | 45 - .../Plugins/Functions/PluginStringFormat.php | 45 - .../Plugins/Functions/PluginStripTags.php | 55 - .../lib/Dwoo/Plugins/Functions/PluginTif.php | 105 - .../Dwoo/Plugins/Functions/PluginTruncate.php | 69 - .../Dwoo/Plugins/Functions/PluginUpper.php | 43 - .../Plugins/Functions/PluginWhitespace.php | 53 - .../Dwoo/Plugins/Functions/PluginWordwrap.php | 49 - .../lib/Dwoo/Plugins/Helpers/PluginArray.php | 56 - .../Processors/PluginSmartyCompatible.php | 94 - .../Dwoo/dwoo/dwoo/lib/Dwoo/Processor.php | 52 - .../dwoo/dwoo/lib/Dwoo/Security/Exception.php | 28 - .../dwoo/dwoo/lib/Dwoo/Security/Policy.php | 322 -- .../dwoo/dwoo/lib/Dwoo/Smarty/Adapter.php | 698 ---- .../dwoo/lib/Dwoo/Smarty/Filter/Adapter.php | 45 - .../lib/Dwoo/Smarty/Processor/Adapter.php | 45 - .../Dwoo/dwoo/dwoo/lib/Dwoo/Template/File.php | 278 -- .../Dwoo/dwoo/dwoo/lib/Dwoo/Template/Str.php | 535 --- .../Dwoo/dwoo/dwoo/phpcs.xml.dist | 15 - .../Dwoo/dwoo/dwoo/phpunit.xml.dist | 27 - .../Dwoo/extension/PluginTranslate.php | 28 - .../templateEngines/Mustache/Autoloader.php | 88 - system/templateEngines/Mustache/Cache.php | 36 - .../Mustache/Cache/AbstractCache.php | 60 - .../Mustache/Cache/FilesystemCache.php | 161 - .../Mustache/Cache/NoopCache.php | 47 - system/templateEngines/Mustache/Compiler.php | 692 ---- system/templateEngines/Mustache/Context.php | 242 -- system/templateEngines/Mustache/Engine.php | 829 ---- system/templateEngines/Mustache/Exception.php | 18 - .../Exception/InvalidArgumentException.php | 18 - .../Mustache/Exception/LogicException.php | 18 - .../Mustache/Exception/RuntimeException.php | 18 - .../Mustache/Exception/SyntaxException.php | 41 - .../Exception/UnknownFilterException.php | 38 - .../Exception/UnknownHelperException.php | 38 - .../Exception/UnknownTemplateException.php | 38 - .../Mustache/HelperCollection.php | 172 - .../templateEngines/Mustache/LambdaHelper.php | 76 - system/templateEngines/Mustache/Loader.php | 27 - .../Mustache/Loader/ArrayLoader.php | 79 - .../Mustache/Loader/CascadingLoader.php | 69 - .../Mustache/Loader/FilesystemLoader.php | 135 - .../Mustache/Loader/InlineLoader.php | 123 - .../Mustache/Loader/MutableLoader.php | 31 - .../Loader/ProductionFilesystemLoader.php | 86 - .../Mustache/Loader/StringLoader.php | 39 - system/templateEngines/Mustache/Logger.php | 126 - .../Mustache/Logger/AbstractLogger.php | 121 - .../Mustache/Logger/StreamLogger.php | 194 - system/templateEngines/Mustache/Parser.php | 317 -- system/templateEngines/Mustache/Source.php | 40 - .../Mustache/Source/FilesystemSource.php | 77 - system/templateEngines/Mustache/Template.php | 180 - system/templateEngines/Mustache/Tokenizer.php | 342 -- system/templateEngines/Mustache/autoload.php | 4 - .../templateEngines/Twig/Twig3x/autoload.php | 7 - .../Twig/Twig3x/composer/ClassLoader.php | 445 -- .../Twig/Twig3x/composer/LICENSE | 21 - .../Twig3x/composer/autoload_classmap.php | 9 - .../Twig/Twig3x/composer/autoload_files.php | 11 - .../Twig3x/composer/autoload_namespaces.php | 9 - .../Twig/Twig3x/composer/autoload_psr4.php | 12 - .../Twig/Twig3x/composer/autoload_real.php | 70 - .../Twig/Twig3x/composer/autoload_static.php | 49 - .../Twig/Twig3x/composer/installed.json | 187 - .../Twig3x/symfony/polyfill-ctype/Ctype.php | 227 - .../Twig3x/symfony/polyfill-ctype/LICENSE | 19 - .../Twig3x/symfony/polyfill-ctype/README.md | 12 - .../symfony/polyfill-ctype/bootstrap.php | 26 - .../symfony/polyfill-ctype/composer.json | 34 - .../Twig3x/symfony/polyfill-mbstring/LICENSE | 19 - .../symfony/polyfill-mbstring/Mbstring.php | 847 ---- .../symfony/polyfill-mbstring/README.md | 13 - .../Resources/unidata/lowerCase.php | 1096 ----- .../Resources/unidata/titleCaseRegexp.php | 5 - .../Resources/unidata/upperCase.php | 1104 ----- .../symfony/polyfill-mbstring/bootstrap.php | 62 - .../symfony/polyfill-mbstring/composer.json | 34 - .../Twig/Twig3x/twig/twig/.editorconfig | 18 - .../Twig/Twig3x/twig/twig/.gitattributes | 3 - .../Twig/Twig3x/twig/twig/.gitignore | 4 - .../Twig/Twig3x/twig/twig/.php_cs.dist | 20 - .../Twig/Twig3x/twig/twig/.travis.yml | 43 - .../Twig/Twig3x/twig/twig/LICENSE | 29 - .../Twig/Twig3x/twig/twig/README.rst | 24 - .../twig/twig/src/Cache/CacheInterface.php | 46 - .../twig/twig/src/Cache/FilesystemCache.php | 87 - .../Twig3x/twig/twig/src/Cache/NullCache.php | 38 - .../Twig/Twig3x/twig/twig/src/Compiler.php | 214 - .../Twig/Twig3x/twig/twig/src/Environment.php | 816 ---- .../Twig/Twig3x/twig/twig/src/Error/Error.php | 227 - .../twig/twig/src/Error/LoaderError.php | 21 - .../twig/twig/src/Error/RuntimeError.php | 22 - .../twig/twig/src/Error/SyntaxError.php | 46 - .../Twig3x/twig/twig/src/ExpressionParser.php | 807 ---- .../twig/src/Extension/AbstractExtension.php | 45 - .../twig/twig/src/Extension/CoreExtension.php | 1598 ------- .../twig/src/Extension/DebugExtension.php | 64 - .../twig/src/Extension/EscaperExtension.php | 418 -- .../twig/src/Extension/ExtensionInterface.php | 68 - .../twig/src/Extension/GlobalsInterface.php | 25 - .../twig/src/Extension/OptimizerExtension.php | 29 - .../twig/src/Extension/ProfilerExtension.php | 52 - .../Extension/RuntimeExtensionInterface.php | 19 - .../twig/src/Extension/SandboxExtension.php | 123 - .../twig/src/Extension/StagingExtension.php | 100 - .../src/Extension/StringLoaderExtension.php | 42 - .../Twig3x/twig/twig/src/ExtensionSet.php | 438 -- .../src/FileExtensionEscapingStrategy.php | 60 - .../Twig/Twig3x/twig/twig/src/Lexer.php | 497 --- .../twig/twig/src/Loader/ArrayLoader.php | 78 - .../twig/twig/src/Loader/ChainLoader.php | 119 - .../twig/twig/src/Loader/FilesystemLoader.php | 283 -- .../twig/twig/src/Loader/LoaderInterface.php | 49 - .../Twig/Twig3x/twig/twig/src/Markup.php | 44 - .../twig/twig/src/Node/AutoEscapeNode.php | 38 - .../Twig3x/twig/twig/src/Node/BlockNode.php | 44 - .../twig/twig/src/Node/BlockReferenceNode.php | 36 - .../Twig3x/twig/twig/src/Node/BodyNode.php | 21 - .../twig/twig/src/Node/CheckSecurityNode.php | 83 - .../twig/twig/src/Node/CheckToStringNode.php | 45 - .../twig/twig/src/Node/DeprecatedNode.php | 53 - .../Twig/Twig3x/twig/twig/src/Node/DoNode.php | 38 - .../Twig3x/twig/twig/src/Node/EmbedNode.php | 48 - .../Node/Expression/AbstractExpression.php | 24 - .../src/Node/Expression/ArrayExpression.php | 85 - .../Expression/ArrowFunctionExpression.php | 64 - .../Node/Expression/AssignNameExpression.php | 27 - .../Node/Expression/Binary/AbstractBinary.php | 42 - .../src/Node/Expression/Binary/AddBinary.php | 23 - .../src/Node/Expression/Binary/AndBinary.php | 23 - .../Expression/Binary/BitwiseAndBinary.php | 23 - .../Expression/Binary/BitwiseOrBinary.php | 23 - .../Expression/Binary/BitwiseXorBinary.php | 23 - .../Node/Expression/Binary/ConcatBinary.php | 23 - .../src/Node/Expression/Binary/DivBinary.php | 23 - .../Node/Expression/Binary/EndsWithBinary.php | 35 - .../Node/Expression/Binary/EqualBinary.php | 39 - .../Node/Expression/Binary/FloorDivBinary.php | 29 - .../Node/Expression/Binary/GreaterBinary.php | 39 - .../Expression/Binary/GreaterEqualBinary.php | 39 - .../src/Node/Expression/Binary/InBinary.php | 33 - .../src/Node/Expression/Binary/LessBinary.php | 39 - .../Expression/Binary/LessEqualBinary.php | 39 - .../Node/Expression/Binary/MatchesBinary.php | 33 - .../src/Node/Expression/Binary/ModBinary.php | 23 - .../src/Node/Expression/Binary/MulBinary.php | 23 - .../Node/Expression/Binary/NotEqualBinary.php | 39 - .../Node/Expression/Binary/NotInBinary.php | 33 - .../src/Node/Expression/Binary/OrBinary.php | 23 - .../Node/Expression/Binary/PowerBinary.php | 22 - .../Node/Expression/Binary/RangeBinary.php | 33 - .../Expression/Binary/SpaceshipBinary.php | 22 - .../Expression/Binary/StartsWithBinary.php | 35 - .../src/Node/Expression/Binary/SubBinary.php | 23 - .../Expression/BlockReferenceExpression.php | 86 - .../src/Node/Expression/CallExpression.php | 310 -- .../Node/Expression/ConditionalExpression.php | 36 - .../Node/Expression/ConstantExpression.php | 28 - .../Node/Expression/Filter/DefaultFilter.php | 52 - .../src/Node/Expression/FilterExpression.php | 40 - .../Node/Expression/FunctionExpression.php | 43 - .../src/Node/Expression/GetAttrExpression.php | 87 - .../twig/src/Node/Expression/InlinePrint.php | 35 - .../Node/Expression/MethodCallExpression.php | 62 - .../src/Node/Expression/NameExpression.php | 97 - .../Expression/NullCoalesceExpression.php | 60 - .../src/Node/Expression/ParentExpression.php | 46 - .../Node/Expression/TempNameExpression.php | 31 - .../src/Node/Expression/Test/ConstantTest.php | 49 - .../src/Node/Expression/Test/DefinedTest.php | 74 - .../Node/Expression/Test/DivisiblebyTest.php | 36 - .../src/Node/Expression/Test/EvenTest.php | 35 - .../src/Node/Expression/Test/NullTest.php | 34 - .../twig/src/Node/Expression/Test/OddTest.php | 35 - .../src/Node/Expression/Test/SameasTest.php | 34 - .../src/Node/Expression/TestExpression.php | 42 - .../Node/Expression/Unary/AbstractUnary.php | 34 - .../src/Node/Expression/Unary/NegUnary.php | 23 - .../src/Node/Expression/Unary/NotUnary.php | 23 - .../src/Node/Expression/Unary/PosUnary.php | 23 - .../Node/Expression/VariadicExpression.php | 24 - .../Twig3x/twig/twig/src/Node/FlushNode.php | 35 - .../Twig3x/twig/twig/src/Node/ForLoopNode.php | 49 - .../Twig3x/twig/twig/src/Node/ForNode.php | 107 - .../Twig/Twig3x/twig/twig/src/Node/IfNode.php | 70 - .../Twig3x/twig/twig/src/Node/ImportNode.php | 63 - .../Twig3x/twig/twig/src/Node/IncludeNode.php | 106 - .../Twig3x/twig/twig/src/Node/MacroNode.php | 113 - .../Twig3x/twig/twig/src/Node/ModuleNode.php | 464 --- .../Twig/Twig3x/twig/twig/src/Node/Node.php | 175 - .../twig/src/Node/NodeCaptureInterface.php | 21 - .../twig/src/Node/NodeOutputInterface.php | 21 - .../Twig3x/twig/twig/src/Node/PrintNode.php | 39 - .../Twig3x/twig/twig/src/Node/SandboxNode.php | 45 - .../Twig3x/twig/twig/src/Node/SetNode.php | 105 - .../Twig3x/twig/twig/src/Node/TextNode.php | 38 - .../Twig3x/twig/twig/src/Node/WithNode.php | 70 - .../Twig3x/twig/twig/src/NodeTraverser.php | 76 - .../src/NodeVisitor/AbstractNodeVisitor.php | 49 - .../src/NodeVisitor/EscaperNodeVisitor.php | 206 - .../MacroAutoImportNodeVisitor.php | 72 - .../src/NodeVisitor/NodeVisitorInterface.php | 46 - .../src/NodeVisitor/OptimizerNodeVisitor.php | 215 - .../NodeVisitor/SafeAnalysisNodeVisitor.php | 157 - .../src/NodeVisitor/SandboxNodeVisitor.php | 132 - .../Twig/Twig3x/twig/twig/src/Parser.php | 360 -- .../twig/src/Profiler/Dumper/BaseDumper.php | 63 - .../src/Profiler/Dumper/BlackfireDumper.php | 72 - .../twig/src/Profiler/Dumper/HtmlDumper.php | 47 - .../twig/src/Profiler/Dumper/TextDumper.php | 35 - .../src/Profiler/Node/EnterProfileNode.php | 42 - .../src/Profiler/Node/LeaveProfileNode.php | 36 - .../NodeVisitor/ProfilerNodeVisitor.php | 76 - .../Twig3x/twig/twig/src/Profiler/Profile.php | 181 - .../RuntimeLoader/ContainerRuntimeLoader.php | 37 - .../RuntimeLoader/FactoryRuntimeLoader.php | 41 - .../RuntimeLoader/RuntimeLoaderInterface.php | 27 - .../twig/twig/src/Sandbox/SecurityError.php | 23 - .../Sandbox/SecurityNotAllowedFilterError.php | 33 - .../SecurityNotAllowedFunctionError.php | 33 - .../Sandbox/SecurityNotAllowedMethodError.php | 40 - .../SecurityNotAllowedPropertyError.php | 40 - .../Sandbox/SecurityNotAllowedTagError.php | 33 - .../twig/twig/src/Sandbox/SecurityPolicy.php | 126 - .../src/Sandbox/SecurityPolicyInterface.php | 35 - .../Twig/Twig3x/twig/twig/src/Source.php | 51 - .../Twig/Twig3x/twig/twig/src/Template.php | 424 -- .../Twig3x/twig/twig/src/TemplateWrapper.php | 109 - .../twig/src/Test/IntegrationTestCase.php | 265 -- .../twig/twig/src/Test/NodeTestCase.php | 65 - .../Twig/Twig3x/twig/twig/src/Token.php | 178 - .../src/TokenParser/AbstractTokenParser.php | 32 - .../twig/src/TokenParser/ApplyTokenParser.php | 58 - .../src/TokenParser/AutoEscapeTokenParser.php | 56 - .../twig/src/TokenParser/BlockTokenParser.php | 76 - .../src/TokenParser/DeprecatedTokenParser.php | 41 - .../twig/src/TokenParser/DoTokenParser.php | 36 - .../twig/src/TokenParser/EmbedTokenParser.php | 71 - .../src/TokenParser/ExtendsTokenParser.php | 50 - .../twig/src/TokenParser/FlushTokenParser.php | 36 - .../twig/src/TokenParser/ForTokenParser.php | 77 - .../twig/src/TokenParser/FromTokenParser.php | 64 - .../twig/src/TokenParser/IfTokenParser.php | 87 - .../src/TokenParser/ImportTokenParser.php | 42 - .../src/TokenParser/IncludeTokenParser.php | 67 - .../twig/src/TokenParser/MacroTokenParser.php | 64 - .../src/TokenParser/SandboxTokenParser.php | 64 - .../twig/src/TokenParser/SetTokenParser.php | 71 - .../src/TokenParser/TokenParserInterface.php | 46 - .../twig/src/TokenParser/UseTokenParser.php | 71 - .../twig/src/TokenParser/WithTokenParser.php | 54 - .../Twig/Twig3x/twig/twig/src/TokenStream.php | 132 - .../Twig/Twig3x/twig/twig/src/TwigFilter.php | 134 - .../Twig3x/twig/twig/src/TwigFunction.php | 122 - .../Twig/Twig3x/twig/twig/src/TwigTest.php | 94 - .../twig/src/Util/DeprecationCollector.php | 77 - .../twig/src/Util/TemplateDirIterator.php | 28 - system/templateEngines/smarty/Autoloader.php | 110 - .../templateEngines/smarty/Smarty.class.php | 1425 ------- .../templateEngines/smarty/SmartyBC.class.php | 477 --- system/templateEngines/smarty/autoload.php | 12 - system/templateEngines/smarty/bootstrap.php | 16 - system/templateEngines/smarty/debug.tpl | 160 - .../smarty/plugins/block.textformat.php | 121 - .../smarty/plugins/function.counter.php | 62 - .../smarty/plugins/function.cycle.php | 92 - .../smarty/plugins/function.fetch.php | 204 - .../plugins/function.html_checkboxes.php | 286 -- .../smarty/plugins/function.html_image.php | 158 - .../smarty/plugins/function.html_options.php | 230 - .../smarty/plugins/function.html_radios.php | 266 -- .../plugins/function.html_select_date.php | 388 -- .../plugins/function.html_select_time.php | 354 -- .../smarty/plugins/function.html_table.php | 164 - .../smarty/plugins/function.mailto.php | 137 - .../smarty/plugins/function.math.php | 112 - .../smarty/plugins/modifier.capitalize.php | 145 - .../smarty/plugins/modifier.date_format.php | 85 - .../plugins/modifier.debug_print_var.php | 103 - .../smarty/plugins/modifier.escape.php | 255 -- .../smarty/plugins/modifier.mb_wordwrap.php | 71 - .../smarty/plugins/modifier.regex_replace.php | 55 - .../smarty/plugins/modifier.replace.php | 37 - .../smarty/plugins/modifier.spacify.php | 26 - .../smarty/plugins/modifier.truncate.php | 62 - .../smarty/plugins/modifiercompiler.cat.php | 28 - .../modifiercompiler.count_characters.php | 32 - .../modifiercompiler.count_paragraphs.php | 26 - .../modifiercompiler.count_sentences.php | 26 - .../plugins/modifiercompiler.count_words.php | 31 - .../plugins/modifiercompiler.default.php | 32 - .../plugins/modifiercompiler.escape.php | 112 - .../plugins/modifiercompiler.from_charset.php | 30 - .../plugins/modifiercompiler.indent.php | 30 - .../smarty/plugins/modifiercompiler.lower.php | 29 - .../plugins/modifiercompiler.noprint.php | 20 - .../modifiercompiler.string_format.php | 24 - .../smarty/plugins/modifiercompiler.strip.php | 30 - .../plugins/modifiercompiler.strip_tags.php | 28 - .../plugins/modifiercompiler.to_charset.php | 30 - .../plugins/modifiercompiler.unescape.php | 44 - .../smarty/plugins/modifiercompiler.upper.php | 28 - .../plugins/modifiercompiler.wordwrap.php | 39 - .../plugins/outputfilter.trimwhitespace.php | 89 - .../plugins/shared.escape_special_chars.php | 32 - .../plugins/shared.literal_compiler_param.php | 35 - .../smarty/plugins/shared.make_timestamp.php | 49 - .../smarty/plugins/shared.mb_str_replace.php | 53 - .../smarty/plugins/shared.mb_unicode.php | 51 - .../variablefilter.htmlspecialchars.php | 19 - .../sysplugins/smarty_cacheresource.php | 219 - .../smarty_cacheresource_custom.php | 297 -- .../smarty_cacheresource_keyvaluestore.php | 538 --- .../smarty/sysplugins/smarty_data.php | 68 - .../sysplugins/smarty_internal_block.php | 90 - .../smarty_internal_cacheresource_file.php | 239 -- .../smarty_internal_compile_append.php | 52 - .../smarty_internal_compile_assign.php | 96 - .../smarty_internal_compile_block.php | 189 - .../smarty_internal_compile_block_child.php | 24 - .../smarty_internal_compile_block_parent.php | 31 - .../smarty_internal_compile_break.php | 117 - .../smarty_internal_compile_call.php | 89 - .../smarty_internal_compile_capture.php | 105 - .../smarty_internal_compile_child.php | 79 - .../smarty_internal_compile_config_load.php | 96 - .../smarty_internal_compile_continue.php | 25 - .../smarty_internal_compile_debug.php | 40 - .../smarty_internal_compile_eval.php | 70 - .../smarty_internal_compile_extends.php | 158 - .../smarty_internal_compile_for.php | 164 - .../smarty_internal_compile_foreach.php | 345 -- .../smarty_internal_compile_function.php | 231 -- .../sysplugins/smarty_internal_compile_if.php | 207 - .../smarty_internal_compile_include.php | 347 -- .../smarty_internal_compile_include_php.php | 110 - .../smarty_internal_compile_insert.php | 157 - .../smarty_internal_compile_ldelim.php | 37 - .../smarty_internal_compile_make_nocache.php | 62 - .../smarty_internal_compile_nocache.php | 73 - .../smarty_internal_compile_parent.php | 31 - ..._internal_compile_private_block_plugin.php | 124 - ...nternal_compile_private_foreachsection.php | 228 - ...ternal_compile_private_function_plugin.php | 78 - ...arty_internal_compile_private_modifier.php | 158 - ..._compile_private_object_block_function.php | 42 - ...ternal_compile_private_object_function.php | 85 - .../smarty_internal_compile_private_php.php | 253 -- ...ernal_compile_private_print_expression.php | 161 - ...ernal_compile_private_registered_block.php | 72 - ...al_compile_private_registered_function.php | 91 - ...ernal_compile_private_special_variable.php | 126 - .../smarty_internal_compile_rdelim.php | 34 - .../smarty_internal_compile_section.php | 462 --- .../smarty_internal_compile_setfilter.php | 68 - ...ty_internal_compile_shared_inheritance.php | 49 - .../smarty_internal_compile_while.php | 100 - .../smarty_internal_compilebase.php | 203 - .../smarty_internal_config_file_compiler.php | 209 - .../smarty_internal_configfilelexer.php | 739 ---- .../smarty_internal_configfileparser.php | 1046 ----- .../sysplugins/smarty_internal_data.php | 292 -- .../sysplugins/smarty_internal_debug.php | 425 -- .../smarty_internal_errorhandler.php | 113 - .../smarty_internal_extension_handler.php | 197 - ...rty_internal_method_addautoloadfilters.php | 53 - ...ty_internal_method_adddefaultmodifiers.php | 42 - .../smarty_internal_method_append.php | 74 - .../smarty_internal_method_appendbyref.php | 49 - .../smarty_internal_method_assignbyref.php | 36 - .../smarty_internal_method_assignglobal.php | 44 - .../smarty_internal_method_clearallassign.php | 36 - .../smarty_internal_method_clearallcache.php | 41 - .../smarty_internal_method_clearassign.php | 43 - .../smarty_internal_method_clearcache.php | 50 - ..._internal_method_clearcompiledtemplate.php | 131 - .../smarty_internal_method_clearconfig.php | 41 - ...marty_internal_method_compileallconfig.php | 36 - ...ty_internal_method_compilealltemplates.php | 130 - .../smarty_internal_method_configload.php | 182 - .../smarty_internal_method_createdata.php | 44 - ...rty_internal_method_getautoloadfilters.php | 37 - ...arty_internal_method_getconfigvariable.php | 34 - .../smarty_internal_method_getconfigvars.php | 58 - ...marty_internal_method_getdebugtemplate.php | 35 - ...ty_internal_method_getdefaultmodifiers.php | 35 - .../smarty_internal_method_getglobal.php | 47 - ...ty_internal_method_getregisteredobject.php | 44 - ...arty_internal_method_getstreamvariable.php | 50 - .../smarty_internal_method_gettags.php | 63 - ...smarty_internal_method_gettemplatevars.php | 119 - .../smarty_internal_method_literals.php | 100 - .../smarty_internal_method_loadfilter.php | 77 - .../smarty_internal_method_loadplugin.php | 111 - .../smarty_internal_method_mustcompile.php | 50 - ..._internal_method_registercacheresource.php | 42 - .../smarty_internal_method_registerclass.php | 46 - ...al_method_registerdefaultconfighandler.php | 42 - ...al_method_registerdefaultpluginhandler.php | 43 - ..._method_registerdefaulttemplatehandler.php | 88 - .../smarty_internal_method_registerfilter.php | 87 - .../smarty_internal_method_registerobject.php | 84 - .../smarty_internal_method_registerplugin.php | 56 - ...marty_internal_method_registerresource.php | 46 - ...rty_internal_method_setautoloadfilters.php | 72 - ...marty_internal_method_setdebugtemplate.php | 41 - ...ty_internal_method_setdefaultmodifiers.php | 38 - .../smarty_internal_method_unloadfilter.php | 43 - ...nternal_method_unregistercacheresource.php | 40 - ...marty_internal_method_unregisterfilter.php | 43 - ...marty_internal_method_unregisterobject.php | 40 - ...marty_internal_method_unregisterplugin.php | 41 - ...rty_internal_method_unregisterresource.php | 40 - .../smarty_internal_nocache_insert.php | 51 - .../sysplugins/smarty_internal_parsetree.php | 50 - .../smarty_internal_parsetree_code.php | 42 - .../smarty_internal_parsetree_dq.php | 95 - .../smarty_internal_parsetree_dqcontent.php | 42 - .../smarty_internal_parsetree_tag.php | 67 - .../smarty_internal_parsetree_template.php | 129 - .../smarty_internal_parsetree_text.php | 40 - .../smarty_internal_resource_eval.php | 94 - .../smarty_internal_resource_extends.php | 126 - .../smarty_internal_resource_file.php | 180 - .../smarty_internal_resource_php.php | 116 - .../smarty_internal_resource_registered.php | 101 - .../smarty_internal_resource_stream.php | 78 - .../smarty_internal_resource_string.php | 108 - .../smarty_internal_runtime_cachemodify.php | 68 - ...rty_internal_runtime_cacheresourcefile.php | 139 - .../smarty_internal_runtime_capture.php | 174 - .../smarty_internal_runtime_codeframe.php | 100 - .../smarty_internal_runtime_filterhandler.php | 69 - .../smarty_internal_runtime_foreach.php | 162 - ...smarty_internal_runtime_getincludepath.php | 181 - .../smarty_internal_runtime_inheritance.php | 251 -- .../smarty_internal_runtime_make_nocache.php | 54 - .../smarty_internal_runtime_tplfunction.php | 177 - .../smarty_internal_runtime_updatecache.php | 183 - .../smarty_internal_runtime_updatescope.php | 115 - .../smarty_internal_runtime_writefile.php | 100 - ...smarty_internal_smartytemplatecompiler.php | 184 - .../sysplugins/smarty_internal_template.php | 740 ---- .../smarty_internal_templatebase.php | 386 -- .../smarty_internal_templatecompilerbase.php | 1756 -------- .../smarty_internal_templatelexer.php | 1095 ----- .../smarty_internal_templateparser.php | 3618 ---------------- .../smarty_internal_testinstall.php | 609 --- .../sysplugins/smarty_internal_undefined.php | 67 - .../smarty/sysplugins/smarty_resource.php | 262 -- .../sysplugins/smarty_resource_custom.php | 93 - .../sysplugins/smarty_resource_recompiled.php | 94 - .../sysplugins/smarty_resource_uncompiled.php | 49 - .../smarty/sysplugins/smarty_security.php | 721 ---- .../sysplugins/smarty_template_cached.php | 257 -- .../sysplugins/smarty_template_compiled.php | 257 -- .../sysplugins/smarty_template_config.php | 100 - .../smarty_template_resource_base.php | 152 - .../sysplugins/smarty_template_source.php | 213 - .../sysplugins/smarty_undefined_variable.php | 33 - .../smarty/sysplugins/smarty_variable.php | 47 - .../sysplugins/smartycompilerexception.php | 45 - .../smarty/sysplugins/smartyexception.php | 19 - 552 files changed, 73709 deletions(-) delete mode 100644 system/templateEngines/Dwoo/autoload.php delete mode 100644 system/templateEngines/Dwoo/composer/ClassLoader.php delete mode 100644 system/templateEngines/Dwoo/composer/LICENSE delete mode 100644 system/templateEngines/Dwoo/composer/autoload_classmap.php delete mode 100644 system/templateEngines/Dwoo/composer/autoload_namespaces.php delete mode 100644 system/templateEngines/Dwoo/composer/autoload_psr4.php delete mode 100644 system/templateEngines/Dwoo/composer/autoload_real.php delete mode 100644 system/templateEngines/Dwoo/composer/autoload_static.php delete mode 100644 system/templateEngines/Dwoo/composer/installed.json delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/.gitignore delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/.gitlab-ci.yml delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/.travis.yml delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/LICENSE.md delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/README.md delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/composer.json delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/docker-compose.yml delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Block/Plugin.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Compilation/Exception.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Compiler.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Core.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Data.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Exception.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Filter.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ICompilable.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ICompilable/Block.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ICompiler.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/IDataProvider.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/IElseable.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ILoader.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/IPluginProxy.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ITemplate.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Loader.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugin.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginA.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginAutoEscape.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginBlock.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginCapture.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginDynamic.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginElse.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginElseif.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginFor.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginForeach.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginForeachelse.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginForelse.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginIf.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginLoop.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginSection.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginSmartyinterface.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginStrip.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginTemplate.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginTextformat.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginTopLevelBlock.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginWith.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginWithelse.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Filters/PluginHtmlFormat.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginAssign.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginCapitalize.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginCat.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginCountCharacters.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginCountParagraphs.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginCountSentences.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginCountWords.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginCounter.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginCycle.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginDateFormat.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginDefault.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginDump.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginEol.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginEscape.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginEval.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginExtends.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginExtendsCheck.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginFetch.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginInclude.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginIndent.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginIsset.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginLoadTemplates.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginLower.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginMailto.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginMath.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginNl2br.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginOptional.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginRegexReplace.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginReplace.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginReturn.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginReverse.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginSafe.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginSpacify.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginStringFormat.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginStripTags.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginTif.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginTruncate.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginUpper.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginWhitespace.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Functions/PluginWordwrap.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Helpers/PluginArray.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Processors/PluginSmartyCompatible.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Processor.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Security/Exception.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Security/Policy.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Smarty/Adapter.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Smarty/Filter/Adapter.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Smarty/Processor/Adapter.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Template/File.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Template/Str.php delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/phpcs.xml.dist delete mode 100644 system/templateEngines/Dwoo/dwoo/dwoo/phpunit.xml.dist delete mode 100644 system/templateEngines/Dwoo/extension/PluginTranslate.php delete mode 100644 system/templateEngines/Mustache/Autoloader.php delete mode 100644 system/templateEngines/Mustache/Cache.php delete mode 100644 system/templateEngines/Mustache/Cache/AbstractCache.php delete mode 100644 system/templateEngines/Mustache/Cache/FilesystemCache.php delete mode 100644 system/templateEngines/Mustache/Cache/NoopCache.php delete mode 100644 system/templateEngines/Mustache/Compiler.php delete mode 100644 system/templateEngines/Mustache/Context.php delete mode 100644 system/templateEngines/Mustache/Engine.php delete mode 100644 system/templateEngines/Mustache/Exception.php delete mode 100644 system/templateEngines/Mustache/Exception/InvalidArgumentException.php delete mode 100644 system/templateEngines/Mustache/Exception/LogicException.php delete mode 100644 system/templateEngines/Mustache/Exception/RuntimeException.php delete mode 100644 system/templateEngines/Mustache/Exception/SyntaxException.php delete mode 100644 system/templateEngines/Mustache/Exception/UnknownFilterException.php delete mode 100644 system/templateEngines/Mustache/Exception/UnknownHelperException.php delete mode 100644 system/templateEngines/Mustache/Exception/UnknownTemplateException.php delete mode 100644 system/templateEngines/Mustache/HelperCollection.php delete mode 100644 system/templateEngines/Mustache/LambdaHelper.php delete mode 100644 system/templateEngines/Mustache/Loader.php delete mode 100644 system/templateEngines/Mustache/Loader/ArrayLoader.php delete mode 100644 system/templateEngines/Mustache/Loader/CascadingLoader.php delete mode 100644 system/templateEngines/Mustache/Loader/FilesystemLoader.php delete mode 100644 system/templateEngines/Mustache/Loader/InlineLoader.php delete mode 100644 system/templateEngines/Mustache/Loader/MutableLoader.php delete mode 100644 system/templateEngines/Mustache/Loader/ProductionFilesystemLoader.php delete mode 100644 system/templateEngines/Mustache/Loader/StringLoader.php delete mode 100644 system/templateEngines/Mustache/Logger.php delete mode 100644 system/templateEngines/Mustache/Logger/AbstractLogger.php delete mode 100644 system/templateEngines/Mustache/Logger/StreamLogger.php delete mode 100644 system/templateEngines/Mustache/Parser.php delete mode 100644 system/templateEngines/Mustache/Source.php delete mode 100644 system/templateEngines/Mustache/Source/FilesystemSource.php delete mode 100644 system/templateEngines/Mustache/Template.php delete mode 100644 system/templateEngines/Mustache/Tokenizer.php delete mode 100644 system/templateEngines/Mustache/autoload.php delete mode 100644 system/templateEngines/Twig/Twig3x/autoload.php delete mode 100644 system/templateEngines/Twig/Twig3x/composer/ClassLoader.php delete mode 100644 system/templateEngines/Twig/Twig3x/composer/LICENSE delete mode 100644 system/templateEngines/Twig/Twig3x/composer/autoload_classmap.php delete mode 100644 system/templateEngines/Twig/Twig3x/composer/autoload_files.php delete mode 100644 system/templateEngines/Twig/Twig3x/composer/autoload_namespaces.php delete mode 100644 system/templateEngines/Twig/Twig3x/composer/autoload_psr4.php delete mode 100644 system/templateEngines/Twig/Twig3x/composer/autoload_real.php delete mode 100644 system/templateEngines/Twig/Twig3x/composer/autoload_static.php delete mode 100644 system/templateEngines/Twig/Twig3x/composer/installed.json delete mode 100644 system/templateEngines/Twig/Twig3x/symfony/polyfill-ctype/Ctype.php delete mode 100644 system/templateEngines/Twig/Twig3x/symfony/polyfill-ctype/LICENSE delete mode 100644 system/templateEngines/Twig/Twig3x/symfony/polyfill-ctype/README.md delete mode 100644 system/templateEngines/Twig/Twig3x/symfony/polyfill-ctype/bootstrap.php delete mode 100644 system/templateEngines/Twig/Twig3x/symfony/polyfill-ctype/composer.json delete mode 100644 system/templateEngines/Twig/Twig3x/symfony/polyfill-mbstring/LICENSE delete mode 100644 system/templateEngines/Twig/Twig3x/symfony/polyfill-mbstring/Mbstring.php delete mode 100644 system/templateEngines/Twig/Twig3x/symfony/polyfill-mbstring/README.md delete mode 100644 system/templateEngines/Twig/Twig3x/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php delete mode 100644 system/templateEngines/Twig/Twig3x/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php delete mode 100644 system/templateEngines/Twig/Twig3x/symfony/polyfill-mbstring/Resources/unidata/upperCase.php delete mode 100644 system/templateEngines/Twig/Twig3x/symfony/polyfill-mbstring/bootstrap.php delete mode 100644 system/templateEngines/Twig/Twig3x/symfony/polyfill-mbstring/composer.json delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/.editorconfig delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/.gitattributes delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/.gitignore delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/.php_cs.dist delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/.travis.yml delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/LICENSE delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/README.rst delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Cache/CacheInterface.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Cache/FilesystemCache.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Cache/NullCache.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Compiler.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Environment.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Error/Error.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Error/LoaderError.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Error/RuntimeError.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Error/SyntaxError.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/ExpressionParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Extension/AbstractExtension.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Extension/CoreExtension.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Extension/DebugExtension.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Extension/EscaperExtension.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Extension/ExtensionInterface.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Extension/GlobalsInterface.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Extension/OptimizerExtension.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Extension/ProfilerExtension.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Extension/RuntimeExtensionInterface.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Extension/SandboxExtension.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Extension/StagingExtension.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Extension/StringLoaderExtension.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/ExtensionSet.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/FileExtensionEscapingStrategy.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Lexer.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Loader/ArrayLoader.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Loader/ChainLoader.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Loader/FilesystemLoader.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Loader/LoaderInterface.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Markup.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/AutoEscapeNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/BlockNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/BlockReferenceNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/BodyNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/CheckSecurityNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/CheckToStringNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/DeprecatedNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/DoNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/EmbedNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/AbstractExpression.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/ArrayExpression.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/ArrowFunctionExpression.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/AssignNameExpression.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/AbstractBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/AddBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/AndBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/BitwiseAndBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/BitwiseOrBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/BitwiseXorBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/ConcatBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/DivBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/EndsWithBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/EqualBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/FloorDivBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/GreaterBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/GreaterEqualBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/InBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/LessBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/LessEqualBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/MatchesBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/ModBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/MulBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/NotEqualBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/NotInBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/OrBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/PowerBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/RangeBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/SpaceshipBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/StartsWithBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Binary/SubBinary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/BlockReferenceExpression.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/CallExpression.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/ConditionalExpression.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/ConstantExpression.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Filter/DefaultFilter.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/FilterExpression.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/FunctionExpression.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/GetAttrExpression.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/InlinePrint.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/MethodCallExpression.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/NameExpression.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/NullCoalesceExpression.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/ParentExpression.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/TempNameExpression.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Test/ConstantTest.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Test/DefinedTest.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Test/DivisiblebyTest.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Test/EvenTest.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Test/NullTest.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Test/OddTest.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Test/SameasTest.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/TestExpression.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Unary/AbstractUnary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Unary/NegUnary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Unary/NotUnary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/Unary/PosUnary.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Expression/VariadicExpression.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/FlushNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/ForLoopNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/ForNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/IfNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/ImportNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/IncludeNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/MacroNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/ModuleNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/Node.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/NodeCaptureInterface.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/NodeOutputInterface.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/PrintNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/SandboxNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/SetNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/TextNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Node/WithNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/NodeTraverser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/NodeVisitor/AbstractNodeVisitor.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/NodeVisitor/EscaperNodeVisitor.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/NodeVisitor/MacroAutoImportNodeVisitor.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/NodeVisitor/NodeVisitorInterface.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/NodeVisitor/OptimizerNodeVisitor.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/NodeVisitor/SafeAnalysisNodeVisitor.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/NodeVisitor/SandboxNodeVisitor.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Parser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Profiler/Dumper/BaseDumper.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Profiler/Dumper/BlackfireDumper.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Profiler/Dumper/HtmlDumper.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Profiler/Dumper/TextDumper.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Profiler/Node/EnterProfileNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Profiler/Node/LeaveProfileNode.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Profiler/NodeVisitor/ProfilerNodeVisitor.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Profiler/Profile.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/RuntimeLoader/ContainerRuntimeLoader.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/RuntimeLoader/FactoryRuntimeLoader.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/RuntimeLoader/RuntimeLoaderInterface.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Sandbox/SecurityError.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Sandbox/SecurityNotAllowedFilterError.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Sandbox/SecurityNotAllowedFunctionError.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Sandbox/SecurityNotAllowedMethodError.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Sandbox/SecurityNotAllowedPropertyError.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Sandbox/SecurityNotAllowedTagError.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Sandbox/SecurityPolicy.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Sandbox/SecurityPolicyInterface.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Source.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Template.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TemplateWrapper.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Test/IntegrationTestCase.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Test/NodeTestCase.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Token.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/AbstractTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/ApplyTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/AutoEscapeTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/BlockTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/DeprecatedTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/DoTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/EmbedTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/ExtendsTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/FlushTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/ForTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/FromTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/IfTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/ImportTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/IncludeTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/MacroTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/SandboxTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/SetTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/TokenParserInterface.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/UseTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenParser/WithTokenParser.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TokenStream.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TwigFilter.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TwigFunction.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/TwigTest.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Util/DeprecationCollector.php delete mode 100644 system/templateEngines/Twig/Twig3x/twig/twig/src/Util/TemplateDirIterator.php delete mode 100644 system/templateEngines/smarty/Autoloader.php delete mode 100644 system/templateEngines/smarty/Smarty.class.php delete mode 100644 system/templateEngines/smarty/SmartyBC.class.php delete mode 100644 system/templateEngines/smarty/autoload.php delete mode 100644 system/templateEngines/smarty/bootstrap.php delete mode 100644 system/templateEngines/smarty/debug.tpl delete mode 100644 system/templateEngines/smarty/plugins/block.textformat.php delete mode 100644 system/templateEngines/smarty/plugins/function.counter.php delete mode 100644 system/templateEngines/smarty/plugins/function.cycle.php delete mode 100644 system/templateEngines/smarty/plugins/function.fetch.php delete mode 100644 system/templateEngines/smarty/plugins/function.html_checkboxes.php delete mode 100644 system/templateEngines/smarty/plugins/function.html_image.php delete mode 100644 system/templateEngines/smarty/plugins/function.html_options.php delete mode 100644 system/templateEngines/smarty/plugins/function.html_radios.php delete mode 100644 system/templateEngines/smarty/plugins/function.html_select_date.php delete mode 100644 system/templateEngines/smarty/plugins/function.html_select_time.php delete mode 100644 system/templateEngines/smarty/plugins/function.html_table.php delete mode 100644 system/templateEngines/smarty/plugins/function.mailto.php delete mode 100644 system/templateEngines/smarty/plugins/function.math.php delete mode 100644 system/templateEngines/smarty/plugins/modifier.capitalize.php delete mode 100644 system/templateEngines/smarty/plugins/modifier.date_format.php delete mode 100644 system/templateEngines/smarty/plugins/modifier.debug_print_var.php delete mode 100644 system/templateEngines/smarty/plugins/modifier.escape.php delete mode 100644 system/templateEngines/smarty/plugins/modifier.mb_wordwrap.php delete mode 100644 system/templateEngines/smarty/plugins/modifier.regex_replace.php delete mode 100644 system/templateEngines/smarty/plugins/modifier.replace.php delete mode 100644 system/templateEngines/smarty/plugins/modifier.spacify.php delete mode 100644 system/templateEngines/smarty/plugins/modifier.truncate.php delete mode 100644 system/templateEngines/smarty/plugins/modifiercompiler.cat.php delete mode 100644 system/templateEngines/smarty/plugins/modifiercompiler.count_characters.php delete mode 100644 system/templateEngines/smarty/plugins/modifiercompiler.count_paragraphs.php delete mode 100644 system/templateEngines/smarty/plugins/modifiercompiler.count_sentences.php delete mode 100644 system/templateEngines/smarty/plugins/modifiercompiler.count_words.php delete mode 100644 system/templateEngines/smarty/plugins/modifiercompiler.default.php delete mode 100644 system/templateEngines/smarty/plugins/modifiercompiler.escape.php delete mode 100644 system/templateEngines/smarty/plugins/modifiercompiler.from_charset.php delete mode 100644 system/templateEngines/smarty/plugins/modifiercompiler.indent.php delete mode 100644 system/templateEngines/smarty/plugins/modifiercompiler.lower.php delete mode 100644 system/templateEngines/smarty/plugins/modifiercompiler.noprint.php delete mode 100644 system/templateEngines/smarty/plugins/modifiercompiler.string_format.php delete mode 100644 system/templateEngines/smarty/plugins/modifiercompiler.strip.php delete mode 100644 system/templateEngines/smarty/plugins/modifiercompiler.strip_tags.php delete mode 100644 system/templateEngines/smarty/plugins/modifiercompiler.to_charset.php delete mode 100644 system/templateEngines/smarty/plugins/modifiercompiler.unescape.php delete mode 100644 system/templateEngines/smarty/plugins/modifiercompiler.upper.php delete mode 100644 system/templateEngines/smarty/plugins/modifiercompiler.wordwrap.php delete mode 100644 system/templateEngines/smarty/plugins/outputfilter.trimwhitespace.php delete mode 100644 system/templateEngines/smarty/plugins/shared.escape_special_chars.php delete mode 100644 system/templateEngines/smarty/plugins/shared.literal_compiler_param.php delete mode 100644 system/templateEngines/smarty/plugins/shared.make_timestamp.php delete mode 100644 system/templateEngines/smarty/plugins/shared.mb_str_replace.php delete mode 100644 system/templateEngines/smarty/plugins/shared.mb_unicode.php delete mode 100644 system/templateEngines/smarty/plugins/variablefilter.htmlspecialchars.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_cacheresource.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_cacheresource_custom.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_cacheresource_keyvaluestore.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_data.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_block.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_cacheresource_file.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_append.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_assign.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_block.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_block_child.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_block_parent.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_break.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_call.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_capture.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_child.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_config_load.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_continue.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_debug.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_eval.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_extends.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_for.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_foreach.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_function.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_if.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_include.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_include_php.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_insert.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_ldelim.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_make_nocache.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_nocache.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_parent.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_private_block_plugin.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_private_foreachsection.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_private_function_plugin.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_private_modifier.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_private_object_block_function.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_private_object_function.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_private_php.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_private_print_expression.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_private_registered_block.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_private_registered_function.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_private_special_variable.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_rdelim.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_section.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_setfilter.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_shared_inheritance.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compile_while.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_compilebase.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_config_file_compiler.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_configfilelexer.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_configfileparser.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_data.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_debug.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_errorhandler.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_extension_handler.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_addautoloadfilters.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_adddefaultmodifiers.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_append.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_appendbyref.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_assignbyref.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_assignglobal.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_clearallassign.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_clearallcache.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_clearassign.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_clearcache.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_clearcompiledtemplate.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_clearconfig.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_compileallconfig.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_compilealltemplates.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_configload.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_createdata.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_getautoloadfilters.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_getconfigvariable.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_getconfigvars.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_getdebugtemplate.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_getdefaultmodifiers.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_getglobal.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_getregisteredobject.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_getstreamvariable.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_gettags.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_gettemplatevars.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_literals.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_loadfilter.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_loadplugin.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_mustcompile.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_registercacheresource.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_registerclass.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_registerdefaultconfighandler.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_registerdefaultpluginhandler.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_registerfilter.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_registerobject.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_registerplugin.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_registerresource.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_setautoloadfilters.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_setdebugtemplate.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_setdefaultmodifiers.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_unloadfilter.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_unregistercacheresource.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_unregisterfilter.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_unregisterobject.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_unregisterplugin.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_method_unregisterresource.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_nocache_insert.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_parsetree.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_parsetree_code.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_parsetree_dq.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_parsetree_dqcontent.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_parsetree_tag.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_parsetree_template.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_parsetree_text.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_resource_eval.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_resource_extends.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_resource_file.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_resource_php.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_resource_registered.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_resource_stream.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_resource_string.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_runtime_cachemodify.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_runtime_cacheresourcefile.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_runtime_capture.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_runtime_codeframe.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_runtime_filterhandler.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_runtime_foreach.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_runtime_getincludepath.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_runtime_inheritance.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_runtime_make_nocache.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_runtime_tplfunction.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_runtime_updatecache.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_runtime_updatescope.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_runtime_writefile.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_smartytemplatecompiler.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_template.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_templatebase.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_templatecompilerbase.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_templatelexer.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_templateparser.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_testinstall.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_internal_undefined.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_resource.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_resource_custom.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_resource_recompiled.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_resource_uncompiled.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_security.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_template_cached.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_template_compiled.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_template_config.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_template_resource_base.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_template_source.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_undefined_variable.php delete mode 100644 system/templateEngines/smarty/sysplugins/smarty_variable.php delete mode 100644 system/templateEngines/smarty/sysplugins/smartycompilerexception.php delete mode 100644 system/templateEngines/smarty/sysplugins/smartyexception.php diff --git a/system/templateEngines/Dwoo/autoload.php b/system/templateEngines/Dwoo/autoload.php deleted file mode 100644 index bcdae55..0000000 --- a/system/templateEngines/Dwoo/autoload.php +++ /dev/null @@ -1,8 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Autoload; - -/** - * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. - * - * $loader = new \Composer\Autoload\ClassLoader(); - * - * // register classes with namespaces - * $loader->add('Symfony\Component', __DIR__.'/component'); - * $loader->add('Symfony', __DIR__.'/framework'); - * - * // activate the autoloader - * $loader->register(); - * - * // to enable searching the include path (eg. for PEAR packages) - * $loader->setUseIncludePath(true); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * This class is loosely based on the Symfony UniversalClassLoader. - * - * @author Fabien Potencier - * @author Jordi Boggiano - * @see http://www.php-fig.org/psr/psr-0/ - * @see http://www.php-fig.org/psr/psr-4/ - */ -class ClassLoader -{ - // PSR-4 - private $prefixLengthsPsr4 = array(); - private $prefixDirsPsr4 = array(); - private $fallbackDirsPsr4 = array(); - - // PSR-0 - private $prefixesPsr0 = array(); - private $fallbackDirsPsr0 = array(); - - private $useIncludePath = false; - private $classMap = array(); - private $classMapAuthoritative = false; - private $missingClasses = array(); - private $apcuPrefix; - - public function getPrefixes() - { - if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); - } - - return array(); - } - - public function getPrefixesPsr4() - { - return $this->prefixDirsPsr4; - } - - public function getFallbackDirs() - { - return $this->fallbackDirsPsr0; - } - - public function getFallbackDirsPsr4() - { - return $this->fallbackDirsPsr4; - } - - public function getClassMap() - { - return $this->classMap; - } - - /** - * @param array $classMap Class to filename map - */ - public function addClassMap(array $classMap) - { - if ($this->classMap) { - $this->classMap = array_merge($this->classMap, $classMap); - } else { - $this->classMap = $classMap; - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, either - * appending or prepending to the ones previously set for this prefix. - * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories - */ - public function add($prefix, $paths, $prepend = false) - { - if (!$prefix) { - if ($prepend) { - $this->fallbackDirsPsr0 = array_merge( - (array) $paths, - $this->fallbackDirsPsr0 - ); - } else { - $this->fallbackDirsPsr0 = array_merge( - $this->fallbackDirsPsr0, - (array) $paths - ); - } - - return; - } - - $first = $prefix[0]; - if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; - - return; - } - if ($prepend) { - $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, - $this->prefixesPsr0[$first][$prefix] - ); - } else { - $this->prefixesPsr0[$first][$prefix] = array_merge( - $this->prefixesPsr0[$first][$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, either - * appending or prepending to the ones previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories - * - * @throws \InvalidArgumentException - */ - public function addPsr4($prefix, $paths, $prepend = false) - { - if (!$prefix) { - // Register directories for the root namespace. - if ($prepend) { - $this->fallbackDirsPsr4 = array_merge( - (array) $paths, - $this->fallbackDirsPsr4 - ); - } else { - $this->fallbackDirsPsr4 = array_merge( - $this->fallbackDirsPsr4, - (array) $paths - ); - } - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { - // Register directories for a new namespace. - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } elseif ($prepend) { - // Prepend directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, - $this->prefixDirsPsr4[$prefix] - ); - } else { - // Append directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - $this->prefixDirsPsr4[$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, - * replacing any others previously set for this prefix. - * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 base directories - */ - public function set($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr0 = (array) $paths; - } else { - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, - * replacing any others previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories - * - * @throws \InvalidArgumentException - */ - public function setPsr4($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr4 = (array) $paths; - } else { - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } - } - - /** - * Turns on searching the include path for class files. - * - * @param bool $useIncludePath - */ - public function setUseIncludePath($useIncludePath) - { - $this->useIncludePath = $useIncludePath; - } - - /** - * Can be used to check if the autoloader uses the include path to check - * for classes. - * - * @return bool - */ - public function getUseIncludePath() - { - return $this->useIncludePath; - } - - /** - * Turns off searching the prefix and fallback directories for classes - * that have not been registered with the class map. - * - * @param bool $classMapAuthoritative - */ - public function setClassMapAuthoritative($classMapAuthoritative) - { - $this->classMapAuthoritative = $classMapAuthoritative; - } - - /** - * Should class lookup fail if not found in the current class map? - * - * @return bool - */ - public function isClassMapAuthoritative() - { - return $this->classMapAuthoritative; - } - - /** - * APCu prefix to use to cache found/not-found classes, if the extension is enabled. - * - * @param string|null $apcuPrefix - */ - public function setApcuPrefix($apcuPrefix) - { - $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; - } - - /** - * The APCu prefix in use, or null if APCu caching is not enabled. - * - * @return string|null - */ - public function getApcuPrefix() - { - return $this->apcuPrefix; - } - - /** - * Registers this instance as an autoloader. - * - * @param bool $prepend Whether to prepend the autoloader or not - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - } - - /** - * Unregisters this instance as an autoloader. - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return bool|null True if loaded, null otherwise - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - includeFile($file); - - return true; - } - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|false The path if found, false otherwise - */ - public function findFile($class) - { - // class map lookup - if (isset($this->classMap[$class])) { - return $this->classMap[$class]; - } - if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { - return false; - } - if (null !== $this->apcuPrefix) { - $file = apcu_fetch($this->apcuPrefix.$class, $hit); - if ($hit) { - return $file; - } - } - - $file = $this->findFileWithExtension($class, '.php'); - - // Search for Hack files if we are running on HHVM - if (false === $file && defined('HHVM_VERSION')) { - $file = $this->findFileWithExtension($class, '.hh'); - } - - if (null !== $this->apcuPrefix) { - apcu_add($this->apcuPrefix.$class, $file); - } - - if (false === $file) { - // Remember that this class does not exist. - $this->missingClasses[$class] = true; - } - - return $file; - } - - private function findFileWithExtension($class, $ext) - { - // PSR-4 lookup - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; - - $first = $class[0]; - if (isset($this->prefixLengthsPsr4[$first])) { - $subPath = $class; - while (false !== $lastPos = strrpos($subPath, '\\')) { - $subPath = substr($subPath, 0, $lastPos); - $search = $subPath.'\\'; - if (isset($this->prefixDirsPsr4[$search])) { - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); - foreach ($this->prefixDirsPsr4[$search] as $dir) { - if (file_exists($file = $dir . $pathEnd)) { - return $file; - } - } - } - } - } - - // PSR-4 fallback dirs - foreach ($this->fallbackDirsPsr4 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { - return $file; - } - } - - // PSR-0 lookup - if (false !== $pos = strrpos($class, '\\')) { - // namespaced class name - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); - } else { - // PEAR-like class name - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; - } - - if (isset($this->prefixesPsr0[$first])) { - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - } - } - } - - // PSR-0 fallback dirs - foreach ($this->fallbackDirsPsr0 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - - // PSR-0 include paths. - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { - return $file; - } - - return false; - } -} - -/** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - */ -function includeFile($file) -{ - include $file; -} diff --git a/system/templateEngines/Dwoo/composer/LICENSE b/system/templateEngines/Dwoo/composer/LICENSE deleted file mode 100644 index f27399a..0000000 --- a/system/templateEngines/Dwoo/composer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - -Copyright (c) Nils Adermann, Jordi Boggiano - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - diff --git a/system/templateEngines/Dwoo/composer/autoload_classmap.php b/system/templateEngines/Dwoo/composer/autoload_classmap.php deleted file mode 100644 index 7a91153..0000000 --- a/system/templateEngines/Dwoo/composer/autoload_classmap.php +++ /dev/null @@ -1,9 +0,0 @@ - array($vendorDir . '/dwoo/dwoo/lib/Dwoo'), -); diff --git a/system/templateEngines/Dwoo/composer/autoload_real.php b/system/templateEngines/Dwoo/composer/autoload_real.php deleted file mode 100644 index ddf32cc..0000000 --- a/system/templateEngines/Dwoo/composer/autoload_real.php +++ /dev/null @@ -1,52 +0,0 @@ -= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require_once __DIR__ . '/autoload_static.php'; - - call_user_func(\Composer\Autoload\ComposerStaticInit301ac16403f2b6bfc7e114ab0baaa05c::getInitializer($loader)); - } else { - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - } - - $loader->register(true); - - return $loader; - } -} diff --git a/system/templateEngines/Dwoo/composer/autoload_static.php b/system/templateEngines/Dwoo/composer/autoload_static.php deleted file mode 100644 index 5ae368f..0000000 --- a/system/templateEngines/Dwoo/composer/autoload_static.php +++ /dev/null @@ -1,31 +0,0 @@ - - array ( - 'Dwoo\\' => 5, - ), - ); - - public static $prefixDirsPsr4 = array ( - 'Dwoo\\' => - array ( - 0 => __DIR__ . '/..' . '/dwoo/dwoo/lib/Dwoo', - ), - ); - - public static function getInitializer(ClassLoader $loader) - { - return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit301ac16403f2b6bfc7e114ab0baaa05c::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit301ac16403f2b6bfc7e114ab0baaa05c::$prefixDirsPsr4; - - }, null, ClassLoader::class); - } -} diff --git a/system/templateEngines/Dwoo/composer/installed.json b/system/templateEngines/Dwoo/composer/installed.json deleted file mode 100644 index 48ae1e9..0000000 --- a/system/templateEngines/Dwoo/composer/installed.json +++ /dev/null @@ -1,43 +0,0 @@ -[ - { - "name": "dwoo/dwoo", - "version": "1.3.7", - "version_normalized": "1.3.7.0", - "source": { - "type": "git", - "url": "https://github.com/dwoo-project/dwoo.git", - "reference": "30592b34b38b1d50e3c7a88b8a5ce315d40ea96e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/dwoo-project/dwoo/zipball/30592b34b38b1d50e3c7a88b8a5ce315d40ea96e", - "reference": "30592b34b38b1d50e3c7a88b8a5ce315d40ea96e", - "shasum": "" - }, - "require": { - "php": "^5.3|^7.0" - }, - "require-dev": { - "phpunit/phpunit": "4.8.27" - }, - "time": "2018-04-18T14:25:28+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "Dwoo\\": "lib/Dwoo/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-3.0-only" - ], - "authors": [ - { - "name": "David Sanchez", - "email": "david38sanchez@gmail.com" - } - ], - "description": "Dwoo is a PHP5/PHP7 template engine which is (almost) fully compatible with Smarty templates and plugins, but is written from scratch for PHP5, and adds many features." - } -] diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/.gitignore b/system/templateEngines/Dwoo/dwoo/dwoo/.gitignore deleted file mode 100644 index a61249c..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ - -### Composer template -composer.phar -/vendor/ - -# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file -# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file -composer.lock - -### PHPUnit Tests -/tests/temp/cache/ -/tests/temp/compiled/ \ No newline at end of file diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/.gitlab-ci.yml b/system/templateEngines/Dwoo/dwoo/dwoo/.gitlab-ci.yml deleted file mode 100644 index 07c923a..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/.gitlab-ci.yml +++ /dev/null @@ -1,77 +0,0 @@ -# Before Script -before_script: - - apt-get update -yqq - - apt-get install git -yqq - -# Stages -stages: - - test - -# Image from https://github.com/splitbrain/docker-phpfarm -image: splitbrain/phpfarm:jessie - -# PHP5.3 -php:5.3: - stage: test - script: - - echo "Running PHPUnit Tests on PHP5.3" - - wget https://getcomposer.org/composer.phar -O composer - - php-5.3 composer install - - wget https://phar.phpunit.de/phpunit-old.phar -O phpunit - - php-5.3 phpunit -d memory_limit=512M --colors --debug --coverage-text - -# PHP5.4 -php:5.4: - stage: test - script: - - echo "Running PHPUnit Tests on PHP5.4" - - wget https://getcomposer.org/composer.phar -O composer - - php-5.4 composer install - - wget https://phar.phpunit.de/phpunit-old.phar -O phpunit - - php-5.4 phpunit -d memory_limit=512M --colors --debug --coverage-text - -# PHP5.5 -php:5.5: - stage: test - script: - - echo "Running PHPUnit Tests on PHP5.5" - - wget https://getcomposer.org/composer.phar -O composer - - php-5.5 composer install - - wget https://phar.phpunit.de/phpunit-old.phar -O phpunit - - php-5.5 phpunit -d memory_limit=512M --colors --debug --coverage-text - -# PHP5.6 -php:5.6: - image: php:5.6 - script: - - curl -sS https://getcomposer.org/installer | php - - php composer.phar install - - echo "Running PHPUnit Tests on PHP5.6" - - php vendor/bin/phpunit --colors --debug --coverage-text - -# PHP7.0 -php:7.0: - image: php:7.0 - script: - - curl -sS https://getcomposer.org/installer | php - - php composer.phar install - - echo "Running PHPUnit Tests on PHP7.0" - - php vendor/bin/phpunit --colors --debug --coverage-text - -# PHP7.1 -php:7.1: - image: php:7.1 - script: - - curl -sS https://getcomposer.org/installer | php - - php composer.phar install - - echo "Running PHPUnit Tests on PHP7.1" - - php vendor/bin/phpunit --colors --debug --coverage-text - -# PHP7.2 -php:7.2: - image: php:7.2 - script: - - curl -sS https://getcomposer.org/installer | php - - php composer.phar install - - echo "Running PHPUnit Tests on PHP7.2" - - php vendor/bin/phpunit --colors --debug --coverage-text \ No newline at end of file diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/.travis.yml b/system/templateEngines/Dwoo/dwoo/dwoo/.travis.yml deleted file mode 100644 index f262fb0..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: php - -php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - 7.2 - -before_script: - - composer install diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/LICENSE.md b/system/templateEngines/Dwoo/dwoo/dwoo/LICENSE.md deleted file mode 100644 index 02bbb60..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/LICENSE.md +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. \ No newline at end of file diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/README.md b/system/templateEngines/Dwoo/dwoo/dwoo/README.md deleted file mode 100644 index 63786a9..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/README.md +++ /dev/null @@ -1,95 +0,0 @@ -Dwoo -==== -[![Latest Stable Version](https://poser.pugx.org/dwoo/dwoo/v/stable?format=flat-square)](https://packagist.org/packages/dwoo/dwoo) -[![Total Downloads](https://poser.pugx.org/dwoo/dwoo/downloads?format=flat-square)](https://packagist.org/packages/dwoo/dwoo) -[![License](https://poser.pugx.org/dwoo/dwoo/license?format=flat-square)](https://packagist.org/packages/dwoo/dwoo) -[![Build Status](https://travis-ci.org/dwoo-project/dwoo.svg?branch=master)](https://travis-ci.org/dwoo-project/dwoo) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/dwoo-project/dwoo/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/dwoo-project/dwoo/?branch=master) -[![Gitter](https://badges.gitter.im/dwoo_project/support.svg)](https://gitter.im/dwoo_project/support?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) - -Dwoo is a PHP5/PHP7 Template Engine that was started in early 2008. The idea came -from the fact that Smarty, a well known template engine, is getting older and -older. It carries the weight of it's age, having old features that are -inconsistent compared to newer ones, being written for PHP4 its Object -Oriented aspect doesn't take advantage of PHP5's more advanced features in -the area, etc. Hence Dwoo was born, hoping to provide a more up to date and -stronger engine. - -So far it has proven to be faster than Smarty in many areas, and it provides -a compatibility layer to allow developers that have been using Smarty for -years to switch their application over to Dwoo progressively. - -> Dwoo **1.3.x** is compatible from **PHP 5.3.x** to **PHP 7.x** - -Documentation -============= -Dwoo's website to get the latest version is at http://dwoo.org/ -The wiki/documentation pages are available at http://dwoo.org/documentation/ - -Requirements ------------- -* PHP >= **5.3** -* PHP >= **7.0** -* [Multibyte String](http://php.net/manual/en/book.mbstring.php) - -License -======= -Dwoo is released under the [GNU LESSER GENERAL PUBLIC LICENSE V3](./LICENSE.md) license. - -Quick start - Running Dwoo -========================== - -Basic Example -------------- -```php -get() -$data = new Dwoo\Data(); -// Fill it with some data -$data->assign('foo', 'BAR'); -$data->assign('bar', 'BAZ'); - -// Outputs the result ... -echo $dwoo->get($tpl, $data); -// ... or get it to use it somewhere else -$dwoo->get($tpl, $data); -``` - -Loop Example ------------- -```php -assign('title', $article['title']); - $data->assign('content', $article['content']); - $pageContent .= $dwoo->get($tpl, $data); - - // Or use the article directly (which is a lot easier in this case) - $pageContent .= $dwoo->get($tpl, $article); -} -``` \ No newline at end of file diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/composer.json b/system/templateEngines/Dwoo/dwoo/dwoo/composer.json deleted file mode 100644 index 466ad41..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/composer.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "dwoo/dwoo", - "license": "LGPL-3.0-only", - "type": "library", - "description": "Dwoo is a PHP5/PHP7 template engine which is (almost) fully compatible with Smarty templates and plugins, but is written from scratch for PHP5, and adds many features.", - "authors": [ - { - "name": "David Sanchez", - "email": "david38sanchez@gmail.com" - } - ], - "autoload": { - "psr-4": { - "Dwoo\\": "lib/Dwoo/" - } - }, - "autoload-dev": { - "psr-4": { - "Dwoo\\Tests\\": "tests/" - } - }, - "require": { - "php": "^5.3|^7.0" - }, - "require-dev": { - "phpunit/phpunit": "4.8.27" - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/docker-compose.yml b/system/templateEngines/Dwoo/dwoo/dwoo/docker-compose.yml deleted file mode 100644 index 3800bd6..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/docker-compose.yml +++ /dev/null @@ -1,7 +0,0 @@ -version: '2' -services: - phpfarm: - container_name: dwoo - image: splitbrain/phpfarm:jessie - volumes: - - ./:/usr/src/dwoo diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Block/Plugin.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Block/Plugin.php deleted file mode 100644 index b05447c..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Block/Plugin.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-23 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Block; - -use Dwoo\Plugin as DwooPlugin; -use Dwoo\Compiler as DwooCompiler; - -/** - * Base class for block plugins. - * you have to implement the init() method, it will receive the parameters that - * are in the template code and is called when the block starts - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -abstract class Plugin extends DwooPlugin -{ - /** - * Stores the contents of the block while it runs. - * - * @var string - */ - protected $buffer = ''; - - /** - * Buffers input, override only if necessary. - * - * @var string the content that must be buffered - */ - public function buffer($input) - { - $this->buffer .= $input; - } - - // initialization code, receives the parameters from {block param1 param2} - // public function init($arg, $arg, ...); - - /** - * Called when the block ends, this is most of the time followed right away by a call - * of process() but not always, so this should be used to do any shutdown operations on the - * block object, if required. - */ - public function end() - { - } - - /** - * Called when the block output is required by a parent block. - * this must read $this->buffer and return it processed - * - * @return string - */ - public function process() - { - return $this->buffer; - } - - /** - * Called at compile time to define what the block should output in the compiled template code, happens when the - * block is declared basically this will replace the {block arg arg arg} tag in the template. - * - * @param DwooCompiler $compiler the compiler instance that calls this function - * @param array $params an array containing original and compiled parameters - * @param string $prepend that is just meant to allow a child class to call - * parent::postProcessing($compiler, $params, "foo();") to add a command before the - * default commands are executed parent::postProcessing($compiler, $params, "foo();") - * to add a command before the default commands are executed - * @param string $append that is just meant to allow a child class to call - * parent::postProcessing($compiler, $params, null, "foo();") to add a command after - * the default commands are executed parent::postProcessing($compiler, $params, null, - * "foo();") to add a command after the default commands are executed - * @param string $type the type is the plugin class name used - * - * @return string - */ - public static function preProcessing(DwooCompiler $compiler, array $params, $prepend, $append, $type) - { - return DwooCompiler::PHP_OPEN . $prepend . '$this->addStack("' . $type . '", array(' . DwooCompiler::implode_r($compiler->getCompiledParams($params)) . '));' . $append . DwooCompiler::PHP_CLOSE; - } - - /** - * Called at compile time to define what the block should output in the compiled template code, happens when the - * block is ended basically this will replace the {/block} tag in the template. - * - * @see preProcessing - * - * @param DwooCompiler $compiler the compiler instance that calls this function - * @param array $params an array containing original and compiled parameters, see preProcessing() for more - * details more details - * @param string $prepend that is just meant to allow a child class to call - * parent::postProcessing($compiler, $params, "foo();") to add a command before the - * default commands are executed parent::postProcessing($compiler, $params, "foo();") - * to add a command before the default commands are executed - * @param string $append that is just meant to allow a child class to call - * parent::postProcessing($compiler, $params, null, "foo();") to add a command after - * the default commands are executed parent::postProcessing($compiler, $params, null, - * "foo();") to add a command after the default commands are executed - * @param string $content the entire content of the block being closed - * - * @return string - */ - public static function postProcessing(DwooCompiler $compiler, array $params, $prepend, $append, $content) - { - return $content . DwooCompiler::PHP_OPEN . $prepend . '$this->delStack();' . $append . DwooCompiler::PHP_CLOSE; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Compilation/Exception.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Compilation/Exception.php deleted file mode 100644 index 732a8d4..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Compilation/Exception.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2017 David Sanchez - * @license http://dwoo.org/LICENSE LGPLv3 - * @version 1.3.6 - * @date 2017-03-21 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Compilation; - -use Dwoo\Exception as DwooException; -use Dwoo\Compiler as DwooCompiler; - -/** - * Dwoo compilation exception class. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class Exception extends DwooException -{ - protected $compiler; - protected $template; - - /** - * Exception constructor. - * - * @param DwooCompiler $compiler - * @param int $message - */ - public function __construct(DwooCompiler $compiler, $message) - { - $this->compiler = $compiler; - $this->template = $compiler->getCore()->getTemplate(); - parent::__construct('Compilation error at line ' . $compiler->getLine() . ' in "' . $this->template->getResourceName() . ':' . $this->template->getResourceIdentifier() . '" : ' . $message); - } - - /** - * @return DwooCompiler - */ - public function getCompiler() - { - return $this->compiler; - } - - /** - * @return \Dwoo\ITemplate|null - */ - public function getTemplate() - { - return $this->template; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Compiler.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Compiler.php deleted file mode 100644 index 9595bb7..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Compiler.php +++ /dev/null @@ -1,3681 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2017 David Sanchez - * @license http://dwoo.org/LICENSE LGPLv3 - * @version 1.3.6 - * @date 2017-03-22 - * @link http://dwoo.org/ - */ - -namespace Dwoo; - -use Closure; -use Dwoo\Plugins\Blocks\PluginIf; -use Dwoo\Security\Exception as SecurityException; -use Dwoo\Security\Policy as SecurityPolicy; -use Dwoo\Compilation\Exception as CompilationException; -use ReflectionFunction; -use ReflectionMethod; - -/** - * Default dwoo compiler class, compiles dwoo templates into php. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class Compiler implements ICompiler -{ - /** - * Constant that represents a php opening tag. - * use it in case it needs to be adjusted - * - * @var string - */ - const PHP_OPEN = ''; - - /** - * Boolean flag to enable or disable debugging output. - * - * @var bool - */ - public $debug = false; - - /** - * Left script delimiter. - * - * @var string - */ - protected $ld = '{'; - - /** - * Left script delimiter with escaped regex meta characters. - * - * @var string - */ - protected $ldr = '\\{'; - - /** - * Right script delimiter. - * - * @var string - */ - protected $rd = '}'; - - /** - * Right script delimiter with escaped regex meta characters. - * - * @var string - */ - protected $rdr = '\\}'; - - /** - * Defines whether the nested comments should be parsed as nested or not. - * defaults to false (classic block comment parsing as in all languages) - * - * @var bool - */ - protected $allowNestedComments = false; - - /** - * Defines whether opening and closing tags can contain spaces before valid data or not. - * turn to true if you want to be sloppy with the syntax, but when set to false it allows - * to skip javascript and css tags as long as they are in the form "{ something", which is - * nice. default is false. - * - * @var bool - */ - protected $allowLooseOpenings = false; - - /** - * Defines whether the compiler will automatically html-escape variables or not. - * default is false - * - * @var bool - */ - protected $autoEscape = false; - - /** - * Security policy object. - * - * @var SecurityPolicy - */ - protected $securityPolicy; - - /** - * Stores the custom plugins registered with this compiler. - * - * @var array - */ - protected $customPlugins = array(); - - /** - * Stores the template plugins registered with this compiler. - * - * @var array - */ - protected $templatePlugins = array(); - - /** - * Stores the pre- and post-processors callbacks. - * - * @var array - */ - protected $processors = array('pre' => array(), 'post' => array()); - - /** - * Stores a list of plugins that are used in the currently compiled - * template, and that are not compilable. these plugins will be loaded - * during the template's runtime if required. - * it is a 1D array formatted as key:pluginName value:pluginType - * - * @var array - */ - protected $usedPlugins; - - /** - * Stores the template undergoing compilation. - * - * @var string - */ - protected $template; - - /** - * Stores the current pointer position inside the template. - * - * @var int - */ - protected $pointer; - - /** - * Stores the current line count inside the template for debugging purposes. - * - * @var int - */ - protected $line; - - /** - * Stores the current template source while compiling it. - * - * @var string - */ - protected $templateSource; - - /** - * Stores the data within which the scope moves. - * - * @var array - */ - protected $data; - - /** - * Variable scope of the compiler, set to null if - * it can not be resolved to a static string (i.e. if some - * plugin defines a new scope based on a variable array key). - * - * @var mixed - */ - protected $scope; - - /** - * Variable scope tree, that allows to rebuild the current - * scope if required, i.e. when going to a parent level. - * - * @var array - */ - protected $scopeTree; - - /** - * Block plugins stack, accessible through some methods. - * - * @see findBlock - * @see getCurrentBlock - * @see addBlock - * @see addCustomBlock - * @see injectBlock - * @see removeBlock - * @see removeTopBlock - * @var array - */ - protected $stack = array(); - - /** - * Current block at the top of the block plugins stack, - * accessible through getCurrentBlock. - * - * @see getCurrentBlock - * @var array - */ - protected $curBlock; - - /** - * Current dwoo object that uses this compiler, or null. - * - * @var Core - */ - public $core; - - /** - * Holds an instance of this class, used by getInstance when you don't - * provide a custom compiler in order to save resources. - * - * @var Compiler - */ - protected static $instance; - - /** - * Token types. - * - * @var int - */ - const T_UNQUOTED_STRING = 1; - const T_NUMERIC = 2; - const T_NULL = 4; - const T_BOOL = 8; - const T_MATH = 16; - const T_BREAKCHAR = 32; - - /** - * Compiler constructor. - * saves the created instance so that child templates get the same one - */ - public function __construct() - { - self::$instance = $this; - } - - /** - * Sets the delimiters to use in the templates. - * delimiters can be multi-character strings but should not be one of those as they will - * make it very hard to work with templates or might even break the compiler entirely : "\", "$", "|", ":" and - * finally "#" only if you intend to use config-vars with the #var# syntax. - * - * @param string $left left delimiter - * @param string $right right delimiter - */ - public function setDelimiters($left, $right) - { - $this->ld = $left; - $this->rd = $right; - $this->ldr = preg_quote($left, '/'); - $this->rdr = preg_quote($right, '/'); - } - - /** - * Returns the left and right template delimiters. - * - * @return array containing the left and the right delimiters - */ - public function getDelimiters() - { - return array($this->ld, $this->rd); - } - - /** - * Sets the way to handle nested comments, if set to true - * {* foo {* some other *} comment *} will be stripped correctly. - * if false it will remove {* foo {* some other *} and leave "comment *}" alone, - * this is the default behavior - * - * @param bool $allow allow nested comments or not, defaults to true (but the default internal value is false) - */ - public function setNestedCommentsHandling($allow = true) - { - $this->allowNestedComments = (bool)$allow; - } - - /** - * Returns the nested comments handling setting. - * - * @see setNestedCommentsHandling - * @return bool true if nested comments are allowed - */ - public function getNestedCommentsHandling() - { - return $this->allowNestedComments; - } - - /** - * Sets the tag openings handling strictness, if set to true, template tags can - * contain spaces before the first function/string/variable such as { $foo} is valid. - * if set to false (default setting), { $foo} is invalid but that is however a good thing - * as it allows css (i.e. #foo { color:red; }) to be parsed silently without triggering - * an error, same goes for javascript. - * - * @param bool $allow true to allow loose handling, false to restore default setting - */ - public function setLooseOpeningHandling($allow = false) - { - $this->allowLooseOpenings = (bool)$allow; - } - - /** - * Returns the tag openings handling strictness setting. - * - * @see setLooseOpeningHandling - * @return bool true if loose tags are allowed - */ - public function getLooseOpeningHandling() - { - return $this->allowLooseOpenings; - } - - /** - * Changes the auto escape setting. - * if enabled, the compiler will automatically html-escape variables, - * unless they are passed through the safe function such as {$var|safe} - * or {safe $var} - * default setting is disabled/false - * - * @param bool $enabled set to true to enable, false to disable - */ - public function setAutoEscape($enabled) - { - $this->autoEscape = (bool)$enabled; - } - - /** - * Returns the auto escape setting. - * default setting is disabled/false - * - * @return bool - */ - public function getAutoEscape() - { - return $this->autoEscape; - } - - /** - * Adds a preprocessor to the compiler, it will be called - * before the template is compiled. - * - * @param mixed $callback either a valid callback to the preprocessor or a simple name if the autoload is set to - * true - * @param bool $autoload if set to true, the preprocessor is auto-loaded from one of the plugin directories, else - * you must provide a valid callback - */ - public function addPreProcessor($callback, $autoload = false) - { - if ($autoload) { - $name = str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', Core::toCamelCase($callback)); - $class = Core::NAMESPACE_PLUGINS_PROCESSORS . $name; - - if (class_exists($class)) { - $callback = array(new $class($this), 'process'); - } elseif (function_exists($class)) { - $callback = $class; - } else { - $callback = array('autoload' => true, 'class' => $class, 'name' => $name); - } - - $this->processors['pre'][] = $callback; - } else { - $this->processors['pre'][] = $callback; - } - } - - /** - * Removes a preprocessor from the compiler. - * - * @param mixed $callback either a valid callback to the preprocessor or a simple name if it was autoloaded - */ - public function removePreProcessor($callback) - { - if (($index = array_search($callback, $this->processors['pre'], true)) !== false) { - unset($this->processors['pre'][$index]); - } elseif (($index = array_search(Core::NAMESPACE_PLUGINS_PROCESSORS . str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', - $callback), - $this->processors['pre'], true)) !== false) { - unset($this->processors['pre'][$index]); - } else { - $class = Core::NAMESPACE_PLUGINS_PROCESSORS . str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', $callback); - foreach ($this->processors['pre'] as $index => $proc) { - if (is_array($proc) && ($proc[0] instanceof $class) || (isset($proc['class']) && $proc['class'] == $class)) { - unset($this->processors['pre'][$index]); - break; - } - } - } - } - - /** - * Adds a postprocessor to the compiler, it will be called - * before the template is compiled. - * - * @param mixed $callback either a valid callback to the postprocessor or a simple name if the autoload is set to - * true - * @param bool $autoload if set to true, the postprocessor is auto-loaded from one of the plugin directories, else - * you must provide a valid callback - */ - public function addPostProcessor($callback, $autoload = false) - { - if ($autoload) { - $name = str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', $callback); - $class = Core::NAMESPACE_PLUGINS_PROCESSORS . Core::toCamelCase($name); - - if (class_exists($class)) { - $callback = array(new $class($this), 'process'); - } elseif (function_exists($class)) { - $callback = $class; - } else { - $callback = array('autoload' => true, 'class' => $class, 'name' => $name); - } - - $this->processors['post'][] = $callback; - } else { - $this->processors['post'][] = $callback; - } - } - - /** - * Removes a postprocessor from the compiler. - * - * @param mixed $callback either a valid callback to the postprocessor or a simple name if it was autoloaded - */ - public function removePostProcessor($callback) - { - if (($index = array_search($callback, $this->processors['post'], true)) !== false) { - unset($this->processors['post'][$index]); - } elseif (($index = array_search(Core::NAMESPACE_PLUGINS_PROCESSORS . str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', - $callback), - $this->processors['post'], true)) !== false) { - unset($this->processors['post'][$index]); - } else { - $class = Core::NAMESPACE_PLUGINS_PROCESSORS . str_replace(Core::NAMESPACE_PLUGINS_PROCESSORS, '', $callback); - foreach ($this->processors['post'] as $index => $proc) { - if (is_array($proc) && ($proc[0] instanceof $class) || (isset($proc['class']) && $proc['class'] == $class)) { - unset($this->processors['post'][$index]); - break; - } - } - } - } - - /** - * Internal function to autoload processors at runtime if required. - * - * @param string $class the class/function name - * @param string $name the plugin name (without Dwoo_Plugin_ prefix) - * - * @return array|string - * @throws Exception - */ - protected function loadProcessor($class, $name) - { - if (!class_exists($class) && !function_exists($class)) { - try { - $this->getCore()->getLoader()->loadPlugin($name); - } - catch (Exception $e) { - throw new Exception('Processor ' . $name . ' could not be found in your plugin directories, please ensure it is in a file named ' . $name . '.php in the plugin directory'); - } - } - - if (class_exists($class)) { - return array(new $class($this), 'process'); - } - - if (function_exists($class)) { - return $class; - } - - throw new Exception('Wrong processor name, when using autoload the processor must be in one of your plugin dir as "name.php" containg a class or function named "Dwoo_Processor_name"'); - } - - /** - * Adds an used plugin, this is reserved for use by the {template} plugin. - * this is required so that plugin loading bubbles up from loaded - * template files to the current one - * - * @private - * - * @param string $name function name - * @param int $type plugin type (Core::*_PLUGIN) - */ - public function addUsedPlugin($name, $type) - { - $this->usedPlugins[$name] = $type; - } - - /** - * Returns all the plugins this template uses. - * - * @private - * @return array the list of used plugins in the parsed template - */ - public function getUsedPlugins() - { - return $this->usedPlugins; - } - - /** - * Adds a template plugin, this is reserved for use by the {template} plugin. - * this is required because the template functions are not declared yet - * during compilation, so we must have a way of validating their argument - * signature without using the reflection api - * - * @private - * - * @param string $name function name - * @param array $params parameter array to help validate the function call - * @param string $uuid unique id of the function - * @param string $body function php code - */ - public function addTemplatePlugin($name, array $params, $uuid, $body = null) - { - $this->templatePlugins[$name] = array('params' => $params, 'body' => $body, 'uuid' => $uuid); - } - - /** - * Returns all the parsed sub-templates. - * - * @private - * @return array the parsed sub-templates - */ - public function getTemplatePlugins() - { - return $this->templatePlugins; - } - - /** - * Marks a template plugin as being called, which means its source must be included in the compiled template. - * - * @param string $name function name - */ - public function useTemplatePlugin($name) - { - $this->templatePlugins[$name]['called'] = true; - } - - /** - * Adds the custom plugins loaded into Dwoo to the compiler so it can load them. - * - * @see Core::addPlugin - * - * @param array $customPlugins an array of custom plugins - */ - public function setCustomPlugins(array $customPlugins) - { - $this->customPlugins = $customPlugins; - } - - /** - * Sets the security policy object to enforce some php security settings. - * use this if untrusted persons can modify templates, - * set it on the Dwoo object as it will be passed onto the compiler automatically - * - * @param SecurityPolicy $policy the security policy object - */ - public function setSecurityPolicy(SecurityPolicy $policy = null) - { - $this->securityPolicy = $policy; - } - - /** - * Returns the current security policy object or null by default. - * - * @return SecurityPolicy|null the security policy object if any - */ - public function getSecurityPolicy() - { - return $this->securityPolicy; - } - - /** - * Sets the pointer position. - * - * @param int $position the new pointer position - * @param bool $isOffset if set to true, the position acts as an offset and not an absolute position - */ - public function setPointer($position, $isOffset = false) - { - if ($isOffset) { - $this->pointer += $position; - } else { - $this->pointer = $position; - } - } - - /** - * Returns the current pointer position, only available during compilation of a template. - * - * @return int - */ - public function getPointer() - { - return $this->pointer; - } - - /** - * Sets the line number. - * - * @param int $number the new line number - * @param bool $isOffset if set to true, the position acts as an offset and not an absolute position - */ - public function setLine($number, $isOffset = false) - { - if ($isOffset) { - $this->line += $number; - } else { - $this->line = $number; - } - } - - /** - * Returns the current line number, only available during compilation of a template. - * - * @return int - */ - public function getLine() - { - return $this->line; - } - - /** - * Returns the dwoo object that initiated this template compilation, only available during compilation of a - * template. - * - * @return Core - */ - public function getCore() - { - return $this->core; - } - - /** - * Overwrites the template that is being compiled. - * - * @param string $newSource the template source that must replace the current one - * @param bool $fromPointer if set to true, only the source from the current pointer position is replaced - * - * @return void - */ - public function setTemplateSource($newSource, $fromPointer = false) - { - if ($fromPointer === true) { - $this->templateSource = substr($this->templateSource, 0, $this->pointer) . $newSource; - } else { - $this->templateSource = $newSource; - } - } - - /** - * Returns the template that is being compiled. - * - * @param mixed $fromPointer if set to true, only the source from the current pointer - * position is returned, if a number is given it overrides the current pointer - * - * @return string the template or partial template - */ - public function getTemplateSource($fromPointer = false) - { - if ($fromPointer === true) { - return substr($this->templateSource, $this->pointer); - } elseif (is_numeric($fromPointer)) { - return substr($this->templateSource, $fromPointer); - } else { - return $this->templateSource; - } - } - - /** - * Resets the compilation pointer, effectively restarting the compilation process. - * this is useful if a plugin modifies the template source since it might need to be recompiled - */ - public function recompile() - { - $this->setPointer(0); - } - - /** - * Compiles the provided string down to php code. - * - * @param Core $core - * @param ITemplate $template the template to compile - * - * @return string a compiled php string - * @throws CompilationException - */ - public function compile(Core $core, ITemplate $template) - { - // init vars - // $compiled = ''; - $tpl = $template->getSource(); - $ptr = 0; - $this->core = $core; - $this->template = $template; - $this->templateSource = &$tpl; - $this->pointer = &$ptr; - - while (true) { - // if pointer is at the beginning, reset everything, that allows a plugin to externally reset the compiler if everything must be reparsed - if ($ptr === 0) { - // resets variables - $this->usedPlugins = array(); - $this->data = array(); - $this->scope = &$this->data; - $this->scopeTree = array(); - $this->stack = array(); - $this->line = 1; - $this->templatePlugins = array(); - // add top level block - $compiled = $this->addBlock('TopLevelBlock', array(), 0); - $this->stack[0]['buffer'] = ''; - - if ($this->debug) { - echo "\n"; - echo 'COMPILER INIT' . "\n"; - } - - if ($this->debug) { - echo 'PROCESSING PREPROCESSORS (' . count($this->processors['pre']) . ')' . "\n"; - } - - // runs preprocessors - foreach ($this->processors['pre'] as $preProc) { - if (is_array($preProc) && isset($preProc['autoload'])) { - $preProc = $this->loadProcessor($preProc['class'], $preProc['name']); - } - if (is_array($preProc) && $preProc[0] instanceof Processor) { - $tpl = call_user_func($preProc, $tpl); - } else { - $tpl = call_user_func($preProc, $this, $tpl); - } - } - unset($preProc); - - // show template source if debug - if ($this->debug) { - echo '
'.print_r(htmlentities($tpl), true).'
'."\n"; - } - - // strips php tags if required by the security policy - if ($this->securityPolicy !== null) { - $search = array('{<\?php.*?\?>}'); - if (ini_get('short_open_tags')) { - $search = array('{<\?.*?\?>}', '{<%.*?%>}'); - } - switch ($this->securityPolicy->getPhpHandling()) { - case SecurityPolicy::PHP_ALLOW: - break; - case SecurityPolicy::PHP_ENCODE: - $tpl = preg_replace_callback($search, array($this, 'phpTagEncodingHelper'), $tpl); - break; - case SecurityPolicy::PHP_REMOVE: - $tpl = preg_replace($search, '', $tpl); - } - } - } - - $pos = strpos($tpl, $this->ld, $ptr); - - if ($pos === false) { - $this->push(substr($tpl, $ptr), 0); - break; - } elseif (substr($tpl, $pos - 1, 1) === '\\' && substr($tpl, $pos - 2, 1) !== '\\') { - $this->push(substr($tpl, $ptr, $pos - $ptr - 1) . $this->ld); - $ptr = $pos + strlen($this->ld); - } elseif (preg_match('/^' . $this->ldr . ($this->allowLooseOpenings ? '\s*' : '') . 'literal' . ($this->allowLooseOpenings ? '\s*' : '') . $this->rdr . '/s', substr($tpl, $pos), $litOpen)) { - if (!preg_match('/' . $this->ldr . ($this->allowLooseOpenings ? '\s*' : '') . '\/literal' . ($this->allowLooseOpenings ? '\s*' : '') . $this->rdr . '/s', $tpl, $litClose, PREG_OFFSET_CAPTURE, $pos)) { - throw new CompilationException($this, 'The {literal} blocks must be closed explicitly with {/literal}'); - } - $endpos = $litClose[0][1]; - $this->push(substr($tpl, $ptr, $pos - $ptr) . substr($tpl, $pos + strlen($litOpen[0]), $endpos - $pos - strlen($litOpen[0]))); - $ptr = $endpos + strlen($litClose[0][0]); - } else { - if (substr($tpl, $pos - 2, 1) === '\\' && substr($tpl, $pos - 1, 1) === '\\') { - $this->push(substr($tpl, $ptr, $pos - $ptr - 1)); - $ptr = $pos; - } - - $this->push(substr($tpl, $ptr, $pos - $ptr)); - $ptr = $pos; - - $pos += strlen($this->ld); - if ($this->allowLooseOpenings) { - while (substr($tpl, $pos, 1) === ' ') { - $pos += 1; - } - } else { - if (substr($tpl, $pos, 1) === ' ' || substr($tpl, $pos, 1) === "\r" || substr($tpl, $pos, 1) === "\n" || substr($tpl, $pos, 1) === "\t") { - $ptr = $pos; - $this->push($this->ld); - continue; - } - } - - // check that there is an end tag present - if (strpos($tpl, $this->rd, $pos) === false) { - throw new CompilationException($this, 'A template tag was not closed, started with "' . substr($tpl, $ptr, 30) . '"'); - } - - $ptr += strlen($this->ld); - $subptr = $ptr; - - while (true) { - $parsed = $this->parse($tpl, $subptr, null, false, 'root', $subptr); - - // reload loop if the compiler was reset - if ($ptr === 0) { - continue 2; - } - - $len = $subptr - $ptr; - $this->push($parsed, substr_count(substr($tpl, $ptr, $len), "\n")); - $ptr += $len; - - if ($parsed === false) { - break; - } - } - } - } - - $compiled .= $this->removeBlock('TopLevelBlock'); - - if ($this->debug) { - echo 'PROCESSING POSTPROCESSORS' . "\n"; - } - - foreach ($this->processors['post'] as $postProc) { - if (is_array($postProc) && isset($postProc['autoload'])) { - $postProc = $this->loadProcessor($postProc['class'], $postProc['name']); - } - if (is_array($postProc) && $postProc[0] instanceof Processor) { - $compiled = call_user_func($postProc, $compiled); - } else { - $compiled = call_user_func($postProc, $this, $compiled); - } - } - unset($postProc); - - if ($this->debug) { - echo 'COMPILATION COMPLETE : MEM USAGE : ' . memory_get_usage() . "\n"; - } - - $output = "getUsedPlugins() as $plugin => $type) { - if ($type & Core::CUSTOM_PLUGIN) { - continue; - } - - switch ($type) { - case Core::CLASS_PLUGIN: - case Core::CLASS_PLUGIN + Core::BLOCK_PLUGIN: - if (class_exists('Plugin' . $plugin) !== false) { - $output .= "if (class_exists('" . "Plugin" . $plugin . "')===false)". - "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n"; - } else { - $output .= "if (class_exists('" . Core::NAMESPACE_PLUGINS_BLOCKS . "Plugin" . $plugin . "')===false)". - "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n"; - } - break; - case Core::CLASS_PLUGIN + Core::FUNC_PLUGIN: - if (class_exists('Plugin' . $plugin) !== false) { - $output .= "if (class_exists('" . "Plugin" . $plugin . "')===false)". - "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n"; - } else { - $output .= "if (class_exists('" . Core::NAMESPACE_PLUGINS_FUNCTIONS . "Plugin" . $plugin . "')===false)". - "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n"; - } - break; - case Core::FUNC_PLUGIN: - if (function_exists('Plugin' . $plugin) !== false) { - $output .= "if (function_exists('" . "Plugin" . $plugin . "')===false)". - "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n"; - } else { - $output .= "if (function_exists('" . Core::NAMESPACE_PLUGINS_FUNCTIONS . "Plugin" . $plugin . "')===false)". - "\n\t\$this->getLoader()->loadPlugin('Plugin$plugin');\n"; - } - break; - case Core::SMARTY_MODIFIER: - $output .= "if (function_exists('smarty_modifier_$plugin')===false)". - "\n\t\$this->getLoader()->loadPlugin('$plugin');\n"; - break; - case Core::SMARTY_FUNCTION: - $output .= "if (function_exists('smarty_function_$plugin')===false)". - "\n\t\$this->getLoader()->loadPlugin('$plugin');\n"; - break; - case Core::SMARTY_BLOCK: - $output .= "if (function_exists('smarty_block_$plugin')===false)". - "\n\t\$this->getLoader()->loadPlugin('$plugin');\n"; - break; - case Core::PROXY_PLUGIN: - $output .= $this->getCore()->getPluginProxy()->getLoader($plugin); - break; - default: - throw new CompilationException($this, 'Type error for ' . $plugin . ' with type' . $type); - } - } - - foreach ($this->templatePlugins as $function => $attr) { - if (isset($attr['called']) && $attr['called'] === true && !isset($attr['checked'])) { - $this->resolveSubTemplateDependencies($function); - } - } - foreach ($this->templatePlugins as $function) { - if (isset($function['called']) && $function['called'] === true) { - $output .= $function['body'] . PHP_EOL; - } - } - - $output .= $compiled . "\n?>"; - - $output = preg_replace('/(?\s*)<\?xml#is', '$1', $output); - - // add another line break after PHP closing tags that have a line break following, - // as we do not know whether it's intended, and PHP will strip it otherwise - $output = preg_replace('/(?\n/', '$0' . "\n", $output); - - if ($this->debug) { - echo '=============================================================================================' . "\n"; - $lines = preg_split('{\r\n|\n|
}', $output); - array_shift($lines); - foreach ($lines as $i => $line) { - echo ($i + 1) . '. ' . $line . "\r\n"; - } - echo '=============================================================================================' . "\n"; - } - - $this->template = $this->dwoo = null; - $tpl = null; - - return $output; - } - - /** - * Checks what sub-templates are used in every sub-template so that we're sure they are all compiled. - * - * @param string $function the sub-template name - */ - protected function resolveSubTemplateDependencies($function) - { - if ($this->debug) { - echo 'Compiler::' . __FUNCTION__ . "\n"; - } - - $body = $this->templatePlugins[$function]['body']; - foreach ($this->templatePlugins as $func => $attr) { - if ($func !== $function && !isset($attr['called']) && strpos($body, Core::NAMESPACE_PLUGINS_FUNCTIONS . - 'Plugin' . Core::toCamelCase($func)) !== false) { - $this->templatePlugins[$func]['called'] = true; - $this->resolveSubTemplateDependencies($func); - } - } - $this->templatePlugins[$function]['checked'] = true; - } - - /** - * Adds compiled content to the current block. - * - * @param string $content the content to push - * @param int $lineCount newlines count in content, optional - * - * @throws CompilationException - */ - public function push($content, $lineCount = null) - { - if ($lineCount === null) { - $lineCount = substr_count($content, "\n"); - } - - if ($this->curBlock['buffer'] === null && count($this->stack) > 1) { - // buffer is not initialized yet (the block has just been created) - $this->stack[count($this->stack) - 2]['buffer'] .= (string)$content; - $this->curBlock['buffer'] = ''; - } else { - if (!isset($this->curBlock['buffer'])) { - throw new CompilationException($this, 'The template has been closed too early, you probably have an extra block-closing tag somewhere'); - } - // append current content to current block's buffer - $this->curBlock['buffer'] .= (string)$content; - } - $this->line += $lineCount; - } - - /** - * Sets the scope. - * set to null if the scope becomes "unstable" (i.e. too variable or unknown) so that - * variables are compiled in a more evaluative way than just $this->scope['key'] - * - * @param mixed $scope a string i.e. "level1.level2" or an array i.e. array("level1", "level2") - * @param bool $absolute if true, the scope is set from the top level scope and not from the current scope - * - * @return array the current scope tree - */ - public function setScope($scope, $absolute = false) - { - $old = $this->scopeTree; - - if ($scope === null) { - unset($this->scope); - $this->scope = null; - } - - if (is_array($scope) === false) { - $scope = explode('.', $scope); - } - - if ($absolute === true) { - $this->scope = &$this->data; - $this->scopeTree = array(); - } - - while (($bit = array_shift($scope)) !== null) { - if ($bit === '_parent' || $bit === '_') { - array_pop($this->scopeTree); - reset($this->scopeTree); - $this->scope = &$this->data; - $cnt = count($this->scopeTree); - for ($i = 0; $i < $cnt; ++ $i) { - $this->scope = &$this->scope[$this->scopeTree[$i]]; - } - } elseif ($bit === '_root' || $bit === '__') { - $this->scope = &$this->data; - $this->scopeTree = array(); - } elseif (isset($this->scope[$bit])) { - $this->scope = &$this->scope[$bit]; - $this->scopeTree[] = $bit; - } else { - $this->scope[$bit] = array(); - $this->scope = &$this->scope[$bit]; - $this->scopeTree[] = $bit; - } - } - - return $old; - } - - /** - * Adds a block to the top of the block stack. - * - * @param string $type block type (name) - * @param array $params the parameters array - * @param int $paramtype the parameters type (see mapParams), 0, 1 or 2 - * - * @return string the preProcessing() method's output - */ - public function addBlock($type, array $params, $paramtype) - { - if ($this->debug) { - echo 'Compiler::' . __FUNCTION__ . "\n"; - } - - $class = current(array_filter([ - 'Plugin' . Core::toCamelCase($type), - Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($type) - ], 'class_exists')); - if (false === $class) { - $this->getCore()->getLoader()->loadPlugin($type); - } - $params = $this->mapParams($params, array($class, 'init'), $paramtype); - - $this->stack[] = array( - 'type' => $type, - 'params' => $params, - 'custom' => false, - 'class' => $class, - 'buffer' => null - ); - $this->curBlock = &$this->stack[count($this->stack) - 1]; - - return call_user_func(array($class, 'preProcessing'), $this, $params, '', '', $type); - } - - /** - * Adds a custom block to the top of the block stack. - * - * @param string $type block type (name) - * @param array $params the parameters array - * @param int $paramtype the parameters type (see mapParams), 0, 1 or 2 - * - * @return string the preProcessing() method's output - */ - public function addCustomBlock($type, array $params, $paramtype) - { - $callback = $this->customPlugins[$type]['callback']; - if (is_array($callback)) { - $class = is_object($callback[0]) ? get_class($callback[0]) : $callback[0]; - } else { - $class = $callback; - } - - $params = $this->mapParams($params, array($class, 'init'), $paramtype); - - $this->stack[] = array( - 'type' => $type, - 'params' => $params, - 'custom' => true, - 'class' => $class, - 'buffer' => null - ); - $this->curBlock = &$this->stack[count($this->stack) - 1]; - - return call_user_func(array($class, 'preProcessing'), $this, $params, '', '', $type); - } - - /** - * Injects a block at the top of the plugin stack without calling its preProcessing method. - * used by {else} blocks to re-add themselves after having closed everything up to their parent - * - * @param string $type block type (name) - * @param array $params parameters array - */ - public function injectBlock($type, array $params) - { - if ($this->debug) { - echo 'Compiler::' . __FUNCTION__ . "\n"; - } - - $class = Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($type); - if (class_exists($class) === false) { - $this->getCore()->getLoader()->loadPlugin($type); - } - $this->stack[] = array( - 'type' => $type, - 'params' => $params, - 'custom' => false, - 'class' => $class, - 'buffer' => null - ); - $this->curBlock = &$this->stack[count($this->stack) - 1]; - } - - /** - * Removes the closest-to-top block of the given type and all other - * blocks encountered while going down the block stack. - * - * @param string $type block type (name) - * - * @return string the output of all postProcessing() method's return values of the closed blocks - * @throws CompilationException - */ - public function removeBlock($type) - { - if ($this->debug) { - echo 'Compiler::' . __FUNCTION__ . "\n"; - } - - $output = ''; - - $pluginType = $this->getPluginType($type); - if ($pluginType & Core::SMARTY_BLOCK) { - $type = 'Smartyinterface'; - } - while (true) { - while ($top = array_pop($this->stack)) { - if ($top['custom']) { - $class = $top['class']; - } else { - $class = current(array_filter([ - 'Plugin' . Core::toCamelCase($top['type']), - Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($top['type']) - ], 'class_exists')); - } - if (count($this->stack)) { - $this->curBlock = &$this->stack[count($this->stack) - 1]; - $this->push(call_user_func(array( - $class, - 'postProcessing' - ), $this, $top['params'], '', '', $top['buffer']), 0); - } else { - $null = null; - $this->curBlock = &$null; - $output = call_user_func( - array( - $class, - 'postProcessing' - ), $this, $top['params'], '', '', $top['buffer'] - ); - } - - if ($top['type'] === $type) { - break 2; - } - } - - throw new CompilationException($this, 'Syntax malformation, a block of type "' . $type . '" was closed but was not opened'); - } - - return $output; - } - - /** - * Returns a reference to the first block of the given type encountered and - * optionally closes all blocks until it finds it - * this is mainly used by {else} plugins to close everything that was opened - * between their parent and themselves. - * - * @param string $type the block type (name) - * @param bool $closeAlong whether to close all blocks encountered while going down the block stack or not - * - * @return mixed &array the array is as such: array('type'=>pluginName, 'params'=>parameter array, - * 'custom'=>bool defining whether it's a custom plugin or not, for internal use) - * @throws CompilationException - */ - public function &findBlock($type, $closeAlong = false) - { - if ($closeAlong === true) { - while ($b = end($this->stack)) { - if ($b['type'] === $type) { - return $this->stack[key($this->stack)]; - } - $this->push($this->removeTopBlock(), 0); - } - } else { - end($this->stack); - while ($b = current($this->stack)) { - if ($b['type'] === $type) { - return $this->stack[key($this->stack)]; - } - prev($this->stack); - } - } - - throw new CompilationException($this, 'A parent block of type "' . $type . '" is required and can not be found'); - } - - /** - * Returns a reference to the current block array. - * - * @return array the array is as such: array('type'=>pluginName, 'params'=>parameter array, - * 'custom'=>bool defining whether it's a custom plugin or not, for internal use) - */ - public function &getCurrentBlock() - { - return $this->curBlock; - } - - /** - * Removes the block at the top of the stack and calls its postProcessing() method. - * - * @return string the postProcessing() method's output - * @throws CompilationException - */ - public function removeTopBlock() - { - if ($this->debug) { - echo 'Compiler::' . __FUNCTION__ . "\n"; - } - - $o = array_pop($this->stack); - if ($o === null) { - throw new CompilationException($this, 'Syntax malformation, a block of unknown type was closed but was not opened.'); - } - if ($o['custom']) { - $class = $o['class']; - } else { - $class = Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($o['type']); - } - - $this->curBlock = &$this->stack[count($this->stack) - 1]; - - return call_user_func(array($class, 'postProcessing'), $this, $o['params'], '', '', $o['buffer']); - } - - /** - * Returns the compiled parameters (for example a variable's compiled parameter will be "$this->scope['key']") out - * of the given parameter array. - * - * @param array $params parameter array - * - * @return array filtered parameters - */ - public function getCompiledParams(array $params) - { - foreach ($params as $k => $p) { - if (is_array($p)) { - $params[$k] = $p[0]; - } - } - - return $params; - } - - /** - * Returns the real parameters (for example a variable's real parameter will be its key, etc) out of the given - * parameter array. - * - * @param array $params parameter array - * - * @return array filtered parameters - */ - public function getRealParams(array $params) - { - foreach ($params as $k => $p) { - if (is_array($p)) { - $params[$k] = $p[1]; - } - } - - return $params; - } - - /** - * Returns the token of each parameter out of the given parameter array. - * - * @param array $params parameter array - * - * @return array tokens - */ - public function getParamTokens(array $params) - { - foreach ($params as $k => $p) { - if (is_array($p)) { - $params[$k] = isset($p[2]) ? $p[2] : 0; - } - } - - return $params; - } - - /** - * Entry point of the parser, it redirects calls to other parse* functions. - * - * @param string $in the string within which we must parse something - * @param int $from the starting offset of the parsed area - * @param int $to the ending offset of the parsed area - * @param mixed $parsingParams must be an array if we are parsing a function or modifier's parameters, or false by - * default - * @param string $curBlock the current parser-block being processed - * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed, - * or null by default - * - * @return string parsed values - * @throws CompilationException - */ - protected function parse($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null) - { - if ($this->debug) { - echo 'Compiler::' . __FUNCTION__ . "\n"; - } - - if ($to === null) { - $to = strlen($in); - } - $first = substr($in, $from, 1); - - if ($first === false) { - throw new CompilationException($this, 'Unexpected EOF, a template tag was not closed'); - } - - while ($first === ' ' || $first === "\n" || $first === "\t" || $first === "\r") { - if ($curBlock === 'root' && substr($in, $from, strlen($this->rd)) === $this->rd) { - // end template tag - $pointer += strlen($this->rd); - if ($this->debug) { - echo 'TEMPLATE PARSING ENDED' . "\n"; - } - - return false; - } - ++ $from; - if ($pointer !== null) { - ++ $pointer; - } - if ($from >= $to) { - if (is_array($parsingParams)) { - return $parsingParams; - } else { - return ''; - } - } - $first = $in[$from]; - } - - $substr = substr($in, $from, $to - $from); - - if ($this->debug) { - echo 'PARSE CALL : PARSING "' . htmlentities(substr($in, $from, min($to - $from, 50))) . (($to - $from) > 50 ? '...' : '') . '" @ ' . $from . ':' . $to . ' in ' . $curBlock . ' : pointer=' . $pointer . "\n"; - } - $parsed = ''; - - if ($curBlock === 'root' && $first === '*') { - $src = $this->getTemplateSource(); - $startpos = $this->getPointer() - strlen($this->ld); - if (substr($src, $startpos, strlen($this->ld)) === $this->ld) { - if ($startpos > 0) { - do { - $char = substr($src, -- $startpos, 1); - if ($char == "\n") { - ++ $startpos; - $whitespaceStart = true; - break; - } - } - while ($startpos > 0 && ($char == ' ' || $char == "\t")); - } - - if (!isset($whitespaceStart)) { - $startpos = $this->getPointer(); - } else { - $pointer -= $this->getPointer() - $startpos; - } - - if ($this->allowNestedComments && strpos($src, $this->ld . '*', $this->getPointer()) !== false) { - $comOpen = $this->ld . '*'; - $comClose = '*' . $this->rd; - $level = 1; - $ptr = $this->getPointer(); - - while ($level > 0 && $ptr < strlen($src)) { - $open = strpos($src, $comOpen, $ptr); - $close = strpos($src, $comClose, $ptr); - - if ($open !== false && $close !== false) { - if ($open < $close) { - $ptr = $open + strlen($comOpen); - ++ $level; - } else { - $ptr = $close + strlen($comClose); - -- $level; - } - } elseif ($open !== false) { - $ptr = $open + strlen($comOpen); - ++ $level; - } elseif ($close !== false) { - $ptr = $close + strlen($comClose); - -- $level; - } else { - $ptr = strlen($src); - } - } - $endpos = $ptr - strlen('*' . $this->rd); - } else { - $endpos = strpos($src, '*' . $this->rd, $startpos); - if ($endpos == false) { - throw new CompilationException($this, 'Un-ended comment'); - } - } - $pointer += $endpos - $startpos + strlen('*' . $this->rd); - if (isset($whitespaceStart) && preg_match('#^[\t ]*\r?\n#', substr($src, $endpos + strlen('*' . $this->rd)), $m)) { - $pointer += strlen($m[0]); - $this->curBlock['buffer'] = substr($this->curBlock['buffer'], 0, strlen($this->curBlock['buffer']) - ($this->getPointer() - $startpos - strlen($this->ld))); - } - - return false; - } - } - - if ($first === '$') { - // var - $out = $this->parseVar($in, $from, $to, $parsingParams, $curBlock, $pointer); - $parsed = 'var'; - } elseif ($first === '%' && preg_match('#^%[a-z_\\\\]#i', $substr)) { - // Short constant - $out = $this->parseConst($in, $from, $to, $parsingParams, $curBlock, $pointer); - } elseif (($first === '"' || $first === "'") && !(is_array($parsingParams) && preg_match('#^([\'"])[a-z0-9_]+\1\s*=>?(?:\s+|[^=])#i', $substr))) { - // string - $out = $this->parseString($in, $from, $to, $parsingParams, $curBlock, $pointer); - } elseif (preg_match('/^\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*(?:::[a-z_][a-z0-9_]*)?(' . (is_array($parsingParams) || $curBlock != 'root' ? '' : '\s+[^(]|') . '\s*\(|\s*' . $this->rdr . '|\s*;)/i', $substr)) { - // func - $out = $this->parseFunction($in, $from, $to, $parsingParams, $curBlock, $pointer); - $parsed = 'func'; - } elseif ($first === ';') { - // instruction end - if ($this->debug) { - echo 'END OF INSTRUCTION' . "\n"; - } - if ($pointer !== null) { - ++ $pointer; - } - - return $this->parse($in, $from + 1, $to, false, 'root', $pointer); - } elseif ($curBlock === 'root' && preg_match('#^/([a-z_][a-z0-9_]*)?#i', $substr, $match)) { - // close block - if (!empty($match[1]) && $match[1] == 'else') { - throw new CompilationException($this, 'Else blocks must not be closed explicitly, they are automatically closed when their parent block is closed'); - } - if (!empty($match[1]) && $match[1] == 'elseif') { - throw new CompilationException($this, 'Elseif blocks must not be closed explicitly, they are automatically closed when their parent block is closed or a new else/elseif block is declared after them'); - } - if ($pointer !== null) { - $pointer += strlen($match[0]); - } - if (empty($match[1])) { - if ($this->curBlock['type'] == 'else' || $this->curBlock['type'] == 'elseif') { - $pointer -= strlen($match[0]); - } - if ($this->debug) { - echo 'TOP BLOCK CLOSED' . "\n"; - } - - return $this->removeTopBlock(); - } else { - if ($this->debug) { - echo 'BLOCK OF TYPE ' . $match[1] . ' CLOSED' . "\n"; - } - - return $this->removeBlock($match[1]); - } - } elseif ($curBlock === 'root' && substr($substr, 0, strlen($this->rd)) === $this->rd) { - // end template tag - if ($this->debug) { - echo 'TAG PARSING ENDED' . "\n"; - } - $pointer += strlen($this->rd); - - return false; - } elseif (is_array($parsingParams) && preg_match('#^(([\'"]?)[a-z0-9_]+\2\s*=' . ($curBlock === 'array' ? '>?' : '') . ')(?:\s+|[^=]).*#i', $substr, $match)) { - // named parameter - if ($this->debug) { - echo 'NAMED PARAM FOUND' . "\n"; - } - $len = strlen($match[1]); - while (substr($in, $from + $len, 1) === ' ') { - ++ $len; - } - if ($pointer !== null) { - $pointer += $len; - } - - $output = array( - trim($match[1], " \t\r\n=>'\""), - $this->parse($in, $from + $len, $to, false, 'namedparam', $pointer) - ); - - $parsingParams[] = $output; - - return $parsingParams; - } elseif (preg_match('#^(\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*::\$[a-z0-9_]+)#i', $substr, $match)) { - // static member access - $parsed = 'var'; - if (is_array($parsingParams)) { - $parsingParams[] = array($match[1], $match[1]); - $out = $parsingParams; - } else { - $out = $match[1]; - } - $pointer += strlen($match[1]); - } elseif ($substr !== '' && (is_array($parsingParams) || $curBlock === 'namedparam' || $curBlock === 'condition' || $curBlock === 'expression')) { - // unquoted string, bool or number - $out = $this->parseOthers($in, $from, $to, $parsingParams, $curBlock, $pointer); - } else { - // parse error - throw new CompilationException($this, 'Parse error in "' . substr($in, $from, $to - $from) . '"'); - } - - if (empty($out)) { - return ''; - } - - $substr = substr($in, $pointer, $to - $pointer); - - // var parsed, check if any var-extension applies - if ($parsed === 'var') { - if (preg_match('#^\s*([/%+*-])\s*([a-z0-9]|\$)#i', $substr, $match)) { - if ($this->debug) { - echo 'PARSING POST-VAR EXPRESSION ' . $substr . "\n"; - } - // parse expressions - $pointer += strlen($match[0]) - 1; - if (is_array($parsingParams)) { - if ($match[2] == '$') { - $expr = $this->parseVar($in, $pointer, $to, array(), $curBlock, $pointer); - } else { - $expr = $this->parse($in, $pointer, $to, array(), 'expression', $pointer); - } - $out[count($out) - 1][0] .= $match[1] . $expr[0][0]; - $out[count($out) - 1][1] .= $match[1] . $expr[0][1]; - } else { - if ($match[2] == '$') { - $expr = $this->parseVar($in, $pointer, $to, false, $curBlock, $pointer); - } else { - $expr = $this->parse($in, $pointer, $to, false, 'expression', $pointer); - } - if (is_array($out) && is_array($expr)) { - $out[0] .= $match[1] . $expr[0]; - $out[1] .= $match[1] . $expr[1]; - } elseif (is_array($out)) { - $out[0] .= $match[1] . $expr; - $out[1] .= $match[1] . $expr; - } elseif (is_array($expr)) { - $out .= $match[1] . $expr[0]; - } else { - $out .= $match[1] . $expr; - } - } - } elseif ($curBlock === 'root' && preg_match('#^(\s*(?:[+/*%-.]=|=|\+\+|--)\s*)(.*)#s', $substr, $match)) { - if ($this->debug) { - echo 'PARSING POST-VAR ASSIGNMENT ' . $substr . "\n"; - } - // parse assignment - $value = $match[2]; - $operator = trim($match[1]); - if (substr($value, 0, 1) == '=') { - throw new CompilationException($this, 'Unexpected "=" in ' . $substr . ''); - } - - if ($pointer !== null) { - $pointer += strlen($match[1]); - } - - if ($operator !== '++' && $operator !== '--') { - $parts = array(); - $ptr = 0; - $parts = $this->parse($value, 0, strlen($value), $parts, 'condition', $ptr); - $pointer += $ptr; - - // load if plugin - try { - $this->getPluginType('if'); - } - catch (Exception $e) { - throw new CompilationException($this, 'Assignments require the "if" plugin to be accessible'); - } - - $parts = $this->mapParams($parts, array(Core::NAMESPACE_PLUGINS_BLOCKS . 'PluginIf', 'init'), 1); - $tokens = $this->getParamTokens($parts); - $parts = $this->getCompiledParams($parts); - - $value = PluginIf::replaceKeywords($parts['*'], $tokens['*'], $this); - $echo = ''; - } else { - $value = array(); - $echo = 'echo '; - } - - if ($this->autoEscape) { - $out = preg_replace('#\(is_string\(\$tmp=(.+?)\) \? htmlspecialchars\(\$tmp, ENT_QUOTES, \$this->charset\) : \$tmp\)#', '$1', $out); - } - $out = self::PHP_OPEN . $echo . $out . $operator . implode(' ', $value) . self::PHP_CLOSE; - } elseif ($curBlock === 'array' && is_array($parsingParams) && preg_match('#^(\s*=>?\s*)#', $substr, $match)) { - // parse namedparam with var as name (only for array) - if ($this->debug) { - echo 'VARIABLE NAMED PARAM (FOR ARRAY) FOUND' . "\n"; - } - $len = strlen($match[1]); - $var = $out[count($out) - 1]; - $pointer += $len; - - $output = array($var[0], $this->parse($substr, $len, null, false, 'namedparam', $pointer)); - - $parsingParams[] = $output; - - return $parsingParams; - } - } - - if ($curBlock !== 'modifier' && ($parsed === 'func' || $parsed === 'var') && preg_match('#^(\|@?[a-z0-9_]+(:.*)?)+#i', $substr, $match)) { - // parse modifier on funcs or vars - $srcPointer = $pointer; - if (is_array($parsingParams)) { - $tmp = $this->replaceModifiers( - array( - null, - null, - $out[count($out) - 1][0], - $match[0] - ), $curBlock, $pointer - ); - $out[count($out) - 1][0] = $tmp; - $out[count($out) - 1][1] .= substr($substr, $srcPointer, $srcPointer - $pointer); - } else { - $out = $this->replaceModifiers(array(null, null, $out, $match[0]), $curBlock, $pointer); - } - } - - // func parsed, check if any func-extension applies - if ($parsed === 'func' && preg_match('#^->[a-z0-9_]+(\s*\(.+|->[a-z_].*)?#is', $substr, $match)) { - // parse method call or property read - $ptr = 0; - - if (is_array($parsingParams)) { - $output = $this->parseMethodCall($out[count($out) - 1][1], $match[0], $curBlock, $ptr); - - $out[count($out) - 1][0] = $output; - $out[count($out) - 1][1] .= substr($match[0], 0, $ptr); - } else { - $out = $this->parseMethodCall($out, $match[0], $curBlock, $ptr); - } - - $pointer += $ptr; - } - - if ($curBlock === 'root' && substr($out, 0, strlen(self::PHP_OPEN)) !== self::PHP_OPEN) { - return self::PHP_OPEN . 'echo ' . $out . ';' . self::PHP_CLOSE; - } - - return $out; - } - - /** - * Parses a function call. - * - * @param string $in the string within which we must parse something - * @param int $from the starting offset of the parsed area - * @param int $to the ending offset of the parsed area - * @param mixed $parsingParams must be an array if we are parsing a function or modifier's parameters, or false by - * default - * @param string $curBlock the current parser-block being processed - * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed, - * or null by default - * - * @return string parsed values - * @throws CompilationException - * @throws Exception - * @throws SecurityException - */ - protected function parseFunction($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null) - { - $output = ''; - $cmdstr = substr($in, $from, $to - $from); - preg_match('/^(\\\\?[a-z_](?:\\\\?[a-z0-9_]+)*(?:::[a-z_][a-z0-9_]*)?)(\s*' . $this->rdr . '|\s*;)?/i', $cmdstr, $match); - - if (empty($match[1])) { - throw new CompilationException($this, 'Parse error, invalid function name : ' . substr($cmdstr, 0, 15)); - } - - $func = $match[1]; - - if (!empty($match[2])) { - $cmdstr = $match[1]; - } - - if ($this->debug) { - echo 'FUNC FOUND (' . $func . ')' . "\n"; - } - - $paramsep = ''; - - if (is_array($parsingParams) || $curBlock != 'root') { - $paramspos = strpos($cmdstr, '('); - $paramsep = ')'; - } elseif (preg_match_all('#^\s*[\\\\:a-z0-9_]+(\s*\(|\s+[^(])#i', $cmdstr, $match, PREG_OFFSET_CAPTURE)) { - $paramspos = $match[1][0][1]; - $paramsep = substr($match[1][0][0], - 1) === '(' ? ')' : ''; - if ($paramsep === ')') { - $paramspos += strlen($match[1][0][0]) - 1; - if (substr($cmdstr, 0, 2) === 'if' || substr($cmdstr, 0, 6) === 'elseif') { - $paramsep = ''; - if (strlen($match[1][0][0]) > 1) { - -- $paramspos; - } - } - } - } else { - $paramspos = false; - } - - $state = 0; - - if ($paramspos === false) { - $params = array(); - - if ($curBlock !== 'root') { - return $this->parseOthers($in, $from, $to, $parsingParams, $curBlock, $pointer); - } - } else { - if ($curBlock === 'condition') { - // load if plugin - $this->getPluginType('if'); - - if (PluginIf::replaceKeywords(array($func), array(self::T_UNQUOTED_STRING), $this) !== array($func)) { - return $this->parseOthers($in, $from, $to, $parsingParams, $curBlock, $pointer); - } - } - $whitespace = strlen(substr($cmdstr, strlen($func), $paramspos - strlen($func))); - $paramstr = substr($cmdstr, $paramspos + 1); - if (substr($paramstr, - 1, 1) === $paramsep) { - $paramstr = substr($paramstr, 0, - 1); - } - - if (strlen($paramstr) === 0) { - $params = array(); - $paramstr = ''; - } else { - $ptr = 0; - $params = array(); - if ($func === 'empty') { - $params = $this->parseVar($paramstr, $ptr, strlen($paramstr), $params, 'root', $ptr); - } else { - while ($ptr < strlen($paramstr)) { - while (true) { - if ($ptr >= strlen($paramstr)) { - break 2; - } - - if ($func !== 'if' && $func !== 'elseif' && $paramstr[$ptr] === ')') { - if ($this->debug) { - echo 'PARAM PARSING ENDED, ")" FOUND, POINTER AT ' . $ptr . "\n"; - } - break 2; - } elseif ($paramstr[$ptr] === ';') { - ++ $ptr; - if ($this->debug) { - echo 'PARAM PARSING ENDED, ";" FOUND, POINTER AT ' . $ptr . "\n"; - } - break 2; - } elseif ($func !== 'if' && $func !== 'elseif' && $paramstr[$ptr] === '/') { - if ($this->debug) { - echo 'PARAM PARSING ENDED, "/" FOUND, POINTER AT ' . $ptr . "\n"; - } - break 2; - } elseif (substr($paramstr, $ptr, strlen($this->rd)) === $this->rd) { - if ($this->debug) { - echo 'PARAM PARSING ENDED, RIGHT DELIMITER FOUND, POINTER AT ' . $ptr . "\n"; - } - break 2; - } - - if ($paramstr[$ptr] === ' ' || $paramstr[$ptr] === ',' || $paramstr[$ptr] === "\r" || $paramstr[$ptr] === "\n" || $paramstr[$ptr] === "\t") { - ++ $ptr; - } else { - break; - } - } - - if ($this->debug) { - echo 'FUNC START PARAM PARSING WITH POINTER AT ' . $ptr . "\n"; - } - - if ($func === 'if' || $func === 'elseif' || $func === 'tif') { - $params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'condition', $ptr); - } elseif ($func === 'array') { - $params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'array', $ptr); - } else { - $params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'function', $ptr); - } - - if ($this->debug) { - echo 'PARAM PARSED, POINTER AT ' . $ptr . ' (' . substr($paramstr, $ptr - 1, 3) . ')' . "\n"; - } - } - } - $paramstr = substr($paramstr, 0, $ptr); - $state = 0; - foreach ($params as $k => $p) { - if (is_array($p) && is_array($p[1])) { - $state |= 2; - } else { - if (($state & 2) && preg_match('#^(["\'])(.+?)\1$#', $p[0], $m) && $func !== 'array') { - $params[$k] = array($m[2], array('true', 'true')); - } else { - if ($state & 2 && $func !== 'array') { - throw new CompilationException($this, 'You can not use an unnamed parameter after a named one'); - } - $state |= 1; - } - } - } - } - } - - if ($pointer !== null) { - $pointer += (isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1)) + strlen($func) + (isset($whitespace) ? $whitespace : 0); - if ($this->debug) { - echo 'FUNC ADDS ' . ((isset($paramstr) ? strlen($paramstr) : 0) + (')' === $paramsep ? 2 : ($paramspos === false ? 0 : 1)) + strlen($func)) . ' TO POINTER' . "\n"; - } - } - - if ($curBlock === 'method' || $func === 'do' || strstr($func, '::') !== false) { - // handle static method calls with security policy - if (strstr($func, '::') !== false && $this->securityPolicy !== null && $this->securityPolicy->isMethodAllowed(explode('::', strtolower($func))) !== true) { - throw new SecurityException('Call to a disallowed php function : ' . $func); - } - $pluginType = Core::NATIVE_PLUGIN; - } else { - $pluginType = $this->getPluginType($func); - } - - // Blocks plugin - if ($pluginType & Core::BLOCK_PLUGIN) { - if ($curBlock !== 'root' || is_array($parsingParams)) { - throw new CompilationException($this, 'Block plugins can not be used as other plugin\'s arguments'); - } - if ($pluginType & Core::CUSTOM_PLUGIN) { - return $this->addCustomBlock($func, $params, $state); - } else { - return $this->addBlock($func, $params, $state); - } - } elseif ($pluginType & Core::SMARTY_BLOCK) { - if ($curBlock !== 'root' || is_array($parsingParams)) { - throw new CompilationException($this, 'Block plugins can not be used as other plugin\'s arguments'); - } - - if ($state & 2) { - array_unshift($params, array('__functype', array($pluginType, $pluginType))); - array_unshift($params, array('__funcname', array($func, $func))); - } else { - array_unshift($params, array($pluginType, $pluginType)); - array_unshift($params, array($func, $func)); - } - - return $this->addBlock('smartyinterface', $params, $state); - } - - // Native & Smarty plugins - if ($pluginType & Core::NATIVE_PLUGIN || $pluginType & Core::SMARTY_FUNCTION || $pluginType & Core::SMARTY_BLOCK) { - $params = $this->mapParams($params, null, $state); - } // PHP class plugin - elseif ($pluginType & Core::CLASS_PLUGIN) { - if ($pluginType & Core::CUSTOM_PLUGIN) { - $params = $this->mapParams( - $params, array( - $this->customPlugins[$func]['class'], - $this->customPlugins[$func]['function'] - ), $state); - } else { - if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) { - $params = $this->mapParams($params, array( - 'Plugin' . Core::toCamelCase($func), - ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process' - ), $state); - } elseif (class_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func)) !== false) { - $params = $this->mapParams($params, array( - Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func), - ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process' - ), $state); - } else { - $params = $this->mapParams($params, array( - Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func), - ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process' - ), $state); - } - } - } // PHP function plugin - elseif ($pluginType & Core::FUNC_PLUGIN) { - if ($pluginType & Core::CUSTOM_PLUGIN) { - $params = $this->mapParams($params, $this->customPlugins[$func]['callback'], $state); - } else { - // Custom plugin - if (function_exists('Plugin' . Core::toCamelCase($func) . (($pluginType & Core::COMPILABLE_PLUGIN) ? - 'Compile' : '')) !== false) { - $params = $this->mapParams($params, 'Plugin' . Core::toCamelCase($func) . (($pluginType & - Core::COMPILABLE_PLUGIN) ? 'Compile' : ''), $state); - } // Builtin helper plugin - elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func) . ( - ($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : '')) !== false) { - $params = $this->mapParams($params, Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase - ($func) . (($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : ''), $state); - } // Builtin function plugin - else { - $params = $this->mapParams($params, Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase - ($func) . (($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : ''), $state); - } - } - } // Smarty modifier - elseif ($pluginType & Core::SMARTY_MODIFIER) { - $output = 'smarty_modifier_' . $func . '(' . implode(', ', $params) . ')'; - } // Proxy plugin - elseif ($pluginType & Core::PROXY_PLUGIN) { - $params = $this->mapParams($params, $this->getCore()->getPluginProxy()->getCallback($func), $state); - } // Template plugin - elseif ($pluginType & Core::TEMPLATE_PLUGIN) { - // transforms the parameter array from (x=>array('paramname'=>array(values))) to (paramname=>array(values)) - $map = array(); - foreach ($this->templatePlugins[$func]['params'] as $param => $defValue) { - if ($param == 'rest') { - $param = '*'; - } - $hasDefault = $defValue !== null; - if ($defValue === 'null') { - $defValue = null; - } elseif ($defValue === 'false') { - $defValue = false; - } elseif ($defValue === 'true') { - $defValue = true; - } elseif (preg_match('#^([\'"]).*?\1$#', $defValue)) { - $defValue = substr($defValue, 1, - 1); - } - $map[] = array($param, $hasDefault, $defValue); - } - - $params = $this->mapParams($params, null, $state, $map); - } - - // only keep php-syntax-safe values for non-block plugins - $tokens = array(); - foreach ($params as $k => $p) { - $tokens[$k] = isset($p[2]) ? $p[2] : 0; - $params[$k] = $p[0]; - } - - // Native plugin - if ($pluginType & Core::NATIVE_PLUGIN) { - if ($func === 'do') { - $output = ''; - if (isset($params['*'])) { - $output = implode(';', $params['*']) . ';'; - } - - if (is_array($parsingParams) || $curBlock !== 'root') { - throw new CompilationException($this, 'Do can not be used inside another function or block'); - } - - return self::PHP_OPEN . $output . self::PHP_CLOSE; - } else { - if (isset($params['*'])) { - $output = $func . '(' . implode(', ', $params['*']) . ')'; - } else { - $output = $func . '()'; - } - } - } // Block class OR Function class - elseif ($pluginType & Core::CLASS_PLUGIN || ($pluginType & Core::FUNC_PLUGIN && $pluginType & Core::CLASS_PLUGIN)) { - if ($pluginType & Core::COMPILABLE_PLUGIN) { - if ($pluginType & Core::CUSTOM_PLUGIN) { - $callback = $this->customPlugins[$func]['callback']; - if (!is_array($callback)) { - if (!method_exists($callback, 'compile')) { - throw new Exception('Custom plugin ' . $func . ' must implement the "compile" method to be compilable, or you should provide a full callback to the method to use'); - } - if (($ref = new ReflectionMethod($callback, 'compile')) && $ref->isStatic()) { - $funcCompiler = array($callback, 'compile'); - } else { - $funcCompiler = array(new $callback(), 'compile'); - } - } else { - $funcCompiler = $callback; - } - } else { - if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) { - $funcCompiler = array('Plugin' . Core::toCamelCase($func), 'compile'); - } elseif (class_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func)) !== false) { - $funcCompiler = array(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func), 'compile'); - } else { - $funcCompiler = array( - Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func), - 'compile' - ); - } - array_unshift($params, $this); - } - // @TODO: Is it a real fix ? - if ($func === 'tif') { - $params[] = $tokens; - } - $output = call_user_func_array($funcCompiler, $params); - } else { - $params = self::implode_r($params); - if ($pluginType & Core::CUSTOM_PLUGIN) { - $callback = $this->customPlugins[$func]['callback']; - if (!is_array($callback)) { - if (!method_exists($callback, 'process')) { - throw new Exception('Custom plugin ' . $func . ' must implement the "process" method to be usable, or you should provide a full callback to the method to use'); - } - if (is_object($callback)) { - $callback = get_class($callback); - } - if (($ref = new ReflectionMethod($callback, 'process')) && $ref->isStatic()) { - $output = 'call_user_func(array(\'' . $callback . '\', \'process\'), ' . $params . ')'; - } else { - $output = 'call_user_func(array($this->getObjectPlugin(\'' . $callback . '\'), \'process\'), ' . $params . ')'; - } - } elseif (is_object($callback[0])) { - $output = 'call_user_func(array($this->plugins[\'' . $func . '\'][\'callback\'][0], \'' . $callback[1] . '\'), ' . $params . ')'; - } elseif (($ref = new ReflectionMethod($callback[0], $callback[1])) && $ref->isStatic()) { - $output = 'call_user_func(array(\'' . $callback[0] . '\', \'' . $callback[1] . '\'), ' . $params . ')'; - } else { - $output = 'call_user_func(array($this->getObjectPlugin(\'' . $callback[0] . '\'), \'' . $callback[1] . '\'), ' . $params . ')'; - } - if (empty($params)) { - $output = substr($output, 0, - 3) . ')'; - } - } else { - if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) { - $output = '$this->classCall(\'Plugin' . $func . '\', array(' . $params . '))'; - } elseif (class_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func)) !== false) { - $output = '$this->classCall(\'' . Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . $func . '\', - array(' . $params . '))'; - } else { - $output = '$this->classCall(\'' . $func . '\', array(' . $params . '))'; - } - } - } - } // Function plugin only (cannot be a class) - elseif ($pluginType & Core::FUNC_PLUGIN) { - if ($pluginType & Core::COMPILABLE_PLUGIN) { - if ($pluginType & Core::CUSTOM_PLUGIN) { - $funcCompiler = $this->customPlugins[$func]['callback']; - } else { - // Custom plugin - if (function_exists('Plugin' . Core::toCamelCase($func) . 'Compile') !== false) { - $funcCompiler = 'Plugin' . Core::toCamelCase($func) . 'Compile'; - } // Builtin helper plugin - elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func) . 'Compile') !== false) { - $funcCompiler = Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func) . - 'Compile'; - } // Builtin function plugin - else { - $funcCompiler = Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func) . - 'Compile'; - } - } - array_unshift($params, $this); - // @TODO: Is it a real fix ? - if ($func === 'tif') { - $params[] = $tokens; - } - $output = call_user_func_array($funcCompiler, $params); - } else { - array_unshift($params, '$this'); - $params = self::implode_r($params); - if ($pluginType & Core::CUSTOM_PLUGIN) { - $callback = $this->customPlugins[$func]['callback']; - if ($callback instanceof Closure) { - $output = 'call_user_func($this->getCustomPlugin(\'' . $func . '\'), ' . $params . ')'; - } else { - $output = 'call_user_func(\'' . $callback . '\', ' . $params . ')'; - } - } else { - // Custom plugin - if (function_exists('Plugin' . Core::toCamelCase($func)) !== false) { - $output = 'Plugin' . Core::toCamelCase($func) . '(' . $params . - ')'; - } // Builtin helper plugin - elseif(function_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func)) !== - false) { - $output = Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($func) . '(' . - $params . ')'; - } // Builtin function plugin - else { - $output = Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func) . '(' . - $params . ')'; - } - } - } - } // Proxy plugin - elseif ($pluginType & Core::PROXY_PLUGIN) { - $output = call_user_func(array($this->getCore()->getPluginProxy(), 'getCode'), $func, $params); - } // Smarty function (@deprecated) - elseif ($pluginType & Core::SMARTY_FUNCTION) { - $params = ''; - if (isset($params['*'])) { - $params = self::implode_r($params['*'], true); - } - - if ($pluginType & Core::CUSTOM_PLUGIN) { - $callback = $this->customPlugins[$func]['callback']; - if (is_array($callback)) { - if (is_object($callback[0])) { - $output = 'call_user_func_array(array($this->getCustomPlugin(\'' . $func . '\'), \'' . $callback[1] . '\'), array(array(' . $params . '), $this))'; - } else { - $output = 'call_user_func_array(array(\'' . $callback[0] . '\', \'' . $callback[1] . '\'), array(array(' . $params . '), $this))'; - } - } else { - $output = $callback . '(array(' . $params . '), $this)'; - } - } else { - $output = 'smarty_function_' . $func . '(array(' . $params . '), $this)'; - } - } // Template plugin - elseif ($pluginType & Core::TEMPLATE_PLUGIN) { - array_unshift($params, '$this'); - $params = self::implode_r($params); - $output = 'Plugin' . Core::toCamelCase($func) . - $this->templatePlugins[$func]['uuid'] . '(' . $params . ')'; - $this->templatePlugins[$func]['called'] = true; - } - - if (is_array($parsingParams)) { - $parsingParams[] = array($output, $output); - - return $parsingParams; - } elseif ($curBlock === 'namedparam') { - return array($output, $output); - } - - return $output; - } - - /** - * Parses a string. - * - * @param string $in the string within which we must parse something - * @param int $from the starting offset of the parsed area - * @param int $to the ending offset of the parsed area - * @param mixed $parsingParams must be an array if we are parsing a function or modifier's parameters, or false by - * default - * @param string $curBlock the current parser-block being processed - * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed, - * or null by default - * - * @return string parsed values - * @throws CompilationException - */ - protected function parseString($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null) - { - $substr = substr($in, $from, $to - $from); - $first = $substr[0]; - - if ($this->debug) { - echo 'STRING FOUND (in ' . htmlentities(substr($in, $from, min($to - $from, 50))) . (($to - $from) > 50 ? '...' : '') . ')' . "\n"; - } - $strend = false; - $o = $from + 1; - while ($strend === false) { - $strend = strpos($in, $first, $o); - if ($strend === false) { - throw new CompilationException($this, 'Unfinished string, started with ' . substr($in, $from, $to - $from)); - } - if (substr($in, $strend - 1, 1) === '\\') { - $o = $strend + 1; - $strend = false; - } - } - if ($this->debug) { - echo 'STRING DELIMITED: ' . substr($in, $from, $strend + 1 - $from) . "\n"; - } - - $srcOutput = substr($in, $from, $strend + 1 - $from); - - if ($pointer !== null) { - $pointer += strlen($srcOutput); - } - - $output = $this->replaceStringVars($srcOutput, $first); - - // handle modifiers - if ($curBlock !== 'modifier' && preg_match('#^((?:\|(?:@?[a-z0-9_]+(?::.*)*))+)#i', substr($substr, $strend + 1 - $from), $match)) { - $modstr = $match[1]; - - if ($curBlock === 'root' && substr($modstr, - 1) === '}') { - $modstr = substr($modstr, 0, - 1); - } - $modstr = str_replace('\\' . $first, $first, $modstr); - $ptr = 0; - $output = $this->replaceModifiers(array(null, null, $output, $modstr), 'string', $ptr); - - $strend += $ptr; - if ($pointer !== null) { - $pointer += $ptr; - } - $srcOutput .= substr($substr, $strend + 1 - $from, $ptr); - } - - if (is_array($parsingParams)) { - $parsingParams[] = array($output, substr($srcOutput, 1, - 1)); - - return $parsingParams; - } elseif ($curBlock === 'namedparam') { - return array($output, substr($srcOutput, 1, - 1)); - } - - return $output; - } - - /** - * Parses a constant. - * - * @param string $in the string within which we must parse something - * @param int $from the starting offset of the parsed area - * @param int $to the ending offset of the parsed area - * @param mixed $parsingParams must be an array if we are parsing a function or modifier's parameters, or false by - * default - * @param string $curBlock the current parser-block being processed - * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed, - * or null by default - * - * @return string parsed values - * @throws CompilationException - */ - protected function parseConst($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null) - { - $substr = substr($in, $from, $to - $from); - - if ($this->debug) { - echo 'CONST FOUND : ' . $substr . "\n"; - } - - if (!preg_match('#^%([\\\\a-z0-9_:]+)#i', $substr, $m)) { - throw new CompilationException($this, 'Invalid constant'); - } - - if ($pointer !== null) { - $pointer += strlen($m[0]); - } - - $output = $this->parseConstKey($m[1], $curBlock); - - if (is_array($parsingParams)) { - $parsingParams[] = array($output, $m[1]); - - return $parsingParams; - } elseif ($curBlock === 'namedparam') { - return array($output, $m[1]); - } - - return $output; - } - - /** - * Parses a constant. - * - * @param string $key the constant to parse - * @param string $curBlock the current parser-block being processed - * - * @return string parsed constant - */ - protected function parseConstKey($key, $curBlock) - { - $key = str_replace('\\\\', '\\', $key); - - if ($this->securityPolicy !== null && $this->securityPolicy->getConstantHandling() === SecurityPolicy::CONST_DISALLOW) { - return 'null'; - } - - if ($curBlock !== 'root') { - return '(defined("' . $key . '") ? ' . $key . ' : null)'; - } - - return $key; - } - - /** - * Parses a variable. - * - * @param string $in the string within which we must parse something - * @param int $from the starting offset of the parsed area - * @param int $to the ending offset of the parsed area - * @param mixed $parsingParams must be an array if we are parsing a function or modifier's parameters, or false by - * default - * @param string $curBlock the current parser-block being processed - * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed, - * or null by default - * - * @return string parsed values - * @throws CompilationException - */ - protected function parseVar($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null) - { - $substr = substr($in, $from, $to - $from); - - // var key - $varRegex = '(\\$?\\.?[a-z0-9\\\\_:]*(?:(?:(?:\\.|->)(?:[a-z0-9\\\\_:]+|(?R))|\\[(?:[a-z0-9\\\\_:]+|(?R)|(["\'])[^\\2]*?\\2)\\]))*)'; - // method call - $methodCall = ($curBlock === 'root' || $curBlock === 'function' || $curBlock === 'namedparam' || $curBlock === 'condition' || $curBlock === 'variable' || $curBlock === 'expression' || $curBlock === 'delimited_string' ? '(\(.*)?' : '()'); - // simple math expressions - $simpleMathExpressions = ($curBlock === 'root' || $curBlock === 'function' || $curBlock === 'namedparam' || $curBlock === 'condition' || $curBlock === 'variable' || $curBlock === 'delimited_string' ? '((?:(?:[+\/*%=-])(?:(?_:-]+(?:\([^)]*\))?|(?'))); - $key = substr($match[1], 1, strrpos($match[1], '->') - 1); - $methodCall = substr($match[1], strrpos($match[1], '->')) . $match[3]; - } - - if ($hasModifiers) { - $matchedLength -= strlen($match[5]); - } - - if ($pointer !== null) { - $pointer += $matchedLength; - } - - // replace useless brackets by dot accessed vars and strip enclosing quotes if present - $key = preg_replace('#\[(["\']?)([^$%\[.>-]+)\1\]#', '.$2', $key); - - if ($this->debug) { - if ($hasMethodCall) { - echo 'METHOD CALL FOUND : $' . $key . substr($methodCall, 0, 30) . "\n"; - } else { - echo 'VAR FOUND : $' . $key . "\n"; - } - } - - $key = str_replace('"', '\\"', $key); - - $cnt = substr_count($key, '$'); - if ($cnt > 0) { - $uid = 0; - $parsed = array($uid => ''); - $current = &$parsed; - $curTxt = &$parsed[$uid ++]; - $tree = array(); - $chars = str_split($key, 1); - $inSplittedVar = false; - $bracketCount = 0; - - while (($char = array_shift($chars)) !== null) { - if ($char === '[') { - if (count($tree) > 0) { - ++ $bracketCount; - } else { - $tree[] = &$current; - $current[$uid] = array($uid + 1 => ''); - $current = &$current[$uid ++]; - $curTxt = &$current[$uid ++]; - continue; - } - } elseif ($char === ']') { - if ($bracketCount > 0) { - -- $bracketCount; - } else { - $current = &$tree[count($tree) - 1]; - array_pop($tree); - if (current($chars) !== '[' && current($chars) !== false && current($chars) !== ']') { - $current[$uid] = ''; - $curTxt = &$current[$uid ++]; - } - continue; - } - } elseif ($char === '$') { - if (count($tree) == 0) { - $curTxt = &$current[$uid ++]; - $inSplittedVar = true; - } - } elseif (($char === '.' || $char === '-') && count($tree) == 0 && $inSplittedVar) { - $curTxt = &$current[$uid ++]; - $inSplittedVar = false; - } - - $curTxt .= $char; - } - unset($uid, $current, $curTxt, $tree, $chars); - - if ($this->debug) { - echo 'RECURSIVE VAR REPLACEMENT : ' . $key . "\n"; - } - - $key = $this->flattenVarTree($parsed); - - if ($this->debug) { - echo 'RECURSIVE VAR REPLACEMENT DONE : ' . $key . "\n"; - } - - $output = preg_replace('#(^""\.|""\.|\.""$|(\()""\.|\.""(\)))#', '$2$3', '$this->readVar("' . $key . '")'); - } else { - $output = $this->parseVarKey($key, $hasModifiers ? 'modifier' : $curBlock); - } - - - // methods - if ($hasMethodCall) { - $ptr = 0; - - $output = $this->parseMethodCall($output, $methodCall, $curBlock, $ptr); - - if ($pointer !== null) { - $pointer += $ptr; - } - $matchedLength += $ptr; - } - - if ($hasExpression) { - // expressions - preg_match_all('#(?:([+/*%=-])(=?-?[%$][a-z0-9\\\\.[\]>_:-]+(?:\([^)]*\))?|=?-?[0-9.,]+|\1))#i', $match[4], $expMatch); - foreach ($expMatch[1] as $k => $operator) { - if (substr($expMatch[2][$k], 0, 1) === '=') { - $assign = true; - if ($operator === '=') { - throw new CompilationException($this, 'Invalid expression ' . $substr . ', can not use "==" in expressions'); - } - if ($curBlock !== 'root') { - throw new CompilationException($this, 'Invalid expression ' . $substr . ', assignments can only be used in top level expressions like {$foo+=3} or {$foo="bar"}'); - } - $operator .= '='; - $expMatch[2][$k] = substr($expMatch[2][$k], 1); - } - - if (substr($expMatch[2][$k], 0, 1) === '-' && strlen($expMatch[2][$k]) > 1) { - $operator .= '-'; - $expMatch[2][$k] = substr($expMatch[2][$k], 1); - } - if (($operator === '+' || $operator === '-') && $expMatch[2][$k] === $operator) { - $output = '(' . $output . $operator . $operator . ')'; - break; - } elseif (substr($expMatch[2][$k], 0, 1) === '$') { - $output = '(' . $output . ' ' . $operator . ' ' . $this->parseVar($expMatch[2][$k], 0, strlen($expMatch[2][$k]), false, 'expression') . ')'; - } elseif (substr($expMatch[2][$k], 0, 1) === '%') { - $output = '(' . $output . ' ' . $operator . ' ' . $this->parseConst($expMatch[2][$k], 0, strlen($expMatch[2][$k]), false, 'expression') . ')'; - } elseif (!empty($expMatch[2][$k])) { - $output = '(' . $output . ' ' . $operator . ' ' . str_replace(',', '.', $expMatch[2][$k]) . ')'; - } else { - throw new CompilationException($this, 'Unfinished expression ' . $substr . ', missing var or number after math operator'); - } - } - } - - if ($this->autoEscape === true && $curBlock !== 'condition') { - $output = '(is_string($tmp=' . $output . ') ? htmlspecialchars($tmp, ENT_QUOTES, $this->charset) : $tmp)'; - } - - // handle modifiers - if ($curBlock !== 'modifier' && $hasModifiers) { - $ptr = 0; - $output = $this->replaceModifiers(array(null, null, $output, $match[5]), 'var', $ptr); - if ($pointer !== null) { - $pointer += $ptr; - } - $matchedLength += $ptr; - } - - if (is_array($parsingParams)) { - $parsingParams[] = array($output, $key); - - return $parsingParams; - } elseif ($curBlock === 'namedparam') { - return array($output, $key); - } elseif ($curBlock === 'string' || $curBlock === 'delimited_string') { - return array($matchedLength, $output); - } elseif ($curBlock === 'expression' || $curBlock === 'variable') { - return $output; - } elseif (isset($assign)) { - return self::PHP_OPEN . $output . ';' . self::PHP_CLOSE; - } - - return $output; - } else { - if ($curBlock === 'string' || $curBlock === 'delimited_string') { - return array(0, ''); - } - throw new CompilationException($this, 'Invalid variable name ' . $substr . ''); - } - } - - /** - * Parses any number of chained method calls/property reads. - * - * @param string $output the variable or whatever upon which the method are called - * @param string $methodCall method call source, starting at "->" - * @param string $curBlock the current parser-block being processed - * @param int $pointer a reference to a pointer that will be increased by the amount of characters parsed - * - * @return string parsed call(s)/read(s) - */ - protected function parseMethodCall($output, $methodCall, $curBlock, &$pointer) - { - $ptr = 0; - $len = strlen($methodCall); - - while ($ptr < $len) { - if (strpos($methodCall, '->', $ptr) === $ptr) { - $ptr += 2; - } - - if (in_array( - $methodCall[$ptr], array( - ';', - ',', - '/', - ' ', - "\t", - "\r", - "\n", - ')', - '+', - '*', - '%', - '=', - '-', - '|' - ) - ) || substr($methodCall, $ptr, strlen($this->rd)) === $this->rd - ) { - // break char found - break; - } - - if (!preg_match('/^([a-z0-9_]+)(\(.*?\))?/i', substr($methodCall, $ptr), $methMatch)) { - break; - } - - if (empty($methMatch[2])) { - // property - if ($curBlock === 'root') { - $output .= '->' . $methMatch[1]; - } else { - $output = '(($tmp = ' . $output . ') ? $tmp->' . $methMatch[1] . ' : null)'; - } - $ptr += strlen($methMatch[1]); - } else { - // method - if (substr($methMatch[2], 0, 2) === '()') { - $parsedCall = $methMatch[1] . '()'; - $ptr += strlen($methMatch[1]) + 2; - } else { - $parsedCall = $this->parseFunction($methodCall, $ptr, strlen($methodCall), false, 'method', $ptr); - } - if ($this->securityPolicy !== null) { - $argPos = strpos($parsedCall, '('); - $method = strtolower(substr($parsedCall, 0, $argPos)); - $args = substr($parsedCall, $argPos); - if ($curBlock === 'root') { - $output = '$this->getSecurityPolicy()->callMethod($this, ' . $output . ', ' . var_export($method, true) . ', array' . $args . ')'; - } else { - $output = '(($tmp = ' . $output . ') ? $this->getSecurityPolicy()->callMethod($this, $tmp, ' . var_export($method, true) . ', array' . $args . ') : null)'; - } - } else { - if ($curBlock === 'root') { - $output .= '->' . $parsedCall; - } else { - $output = '(($tmp = ' . $output . ') ? $tmp->' . $parsedCall . ' : null)'; - } - } - } - } - - $pointer += $ptr; - - return $output; - } - - /** - * Parses a constant variable (a variable that doesn't contain another variable) and preprocesses it to save - * runtime processing time. - * - * @param string $key the variable to parse - * @param string $curBlock the current parser-block being processed - * - * @return string parsed variable - */ - protected function parseVarKey($key, $curBlock) - { - if ($key === '') { - return '$this->scope'; - } - if (substr($key, 0, 1) === '.') { - $key = 'dwoo' . $key; - } - if (preg_match('#dwoo\.(get|post|server|cookies|session|env|request)((?:\.[a-z0-9_-]+)+)#i', $key, $m)) { - $global = strtoupper($m[1]); - if ($global === 'COOKIES') { - $global = 'COOKIE'; - } - $key = '$_' . $global; - foreach (explode('.', ltrim($m[2], '.')) as $part) { - $key .= '[' . var_export($part, true) . ']'; - } - if ($curBlock === 'root') { - $output = $key; - } else { - $output = '(isset(' . $key . ')?' . $key . ':null)'; - } - } elseif (preg_match('#dwoo\\.const\\.([a-z0-9\\\\_:]+)#i', $key, $m)) { - return $this->parseConstKey($m[1], $curBlock); - } elseif ($this->scope !== null) { - if (strstr($key, '.') === false && strstr($key, '[') === false && strstr($key, '->') === false) { - if ($key === 'dwoo') { - $output = '$this->globals'; - } elseif ($key === '_root' || $key === '__') { - $output = '$this->data'; - } elseif ($key === '_parent' || $key === '_') { - $output = '$this->readParentVar(1)'; - } elseif ($key === '_key') { - $output = '$tmp_key'; - } else { - if ($curBlock === 'root') { - $output = '$this->scope["' . $key . '"]'; - } else { - $output = '(isset($this->scope["' . $key . '"]) ? $this->scope["' . $key . '"] : null)'; - } - } - } else { - preg_match_all('#(\[|->|\.)?((?:[a-z0-9_]|-(?!>))+|(\\\?[\'"])[^\3]*?\3)\]?#i', $key, $m); - - $i = $m[2][0]; - if ($i === '_parent' || $i === '_') { - $parentCnt = 0; - - while (true) { - ++ $parentCnt; - array_shift($m[2]); - array_shift($m[1]); - if (current($m[2]) === '_parent') { - continue; - } - break; - } - - $output = '$this->readParentVar(' . $parentCnt . ')'; - } else { - if ($i === 'dwoo') { - $output = '$this->globals'; - array_shift($m[2]); - array_shift($m[1]); - } elseif ($i === '_root' || $i === '__') { - // $output = '$this->data'; - $output = '$this->getData()'; - array_shift($m[2]); - array_shift($m[1]); - } elseif ($i === '_key') { - $output = '$tmp_key'; - } else { - $output = '$this->scope'; - } - - while (count($m[1]) && $m[1][0] !== '->') { - $m[2][0] = preg_replace('/(^\\\([\'"])|\\\([\'"])$)/x', '$2$3', $m[2][0]); - if (substr($m[2][0], 0, 1) == '"' || substr($m[2][0], 0, 1) == "'") { - $output .= '[' . $m[2][0] . ']'; - } else { - $output .= '["' . $m[2][0] . '"]'; - } - array_shift($m[2]); - array_shift($m[1]); - } - - if ($curBlock !== 'root') { - $output = '(isset(' . $output . ') ? ' . $output . ':null)'; - } - } - - if (count($m[2])) { - unset($m[0]); - $output = '$this->readVarInto(' . str_replace("\n", '', var_export($m, true)) . ', ' . $output . ', ' . ($curBlock == 'root' ? 'false' : 'true') . ')'; - } - } - } else { - preg_match_all('#(\[|->|\.)?((?:[a-z0-9_]|-(?!>))+)\]?#i', $key, $m); - unset($m[0]); - $output = '$this->readVar(' . str_replace("\n", '', var_export($m, true)) . ')'; - } - - return $output; - } - - /** - * Flattens a variable tree, this helps in parsing very complex variables such as $var.foo[$foo.bar->baz].baz, - * it computes the contents of the brackets first and works out from there. - * - * @param array $tree the variable tree parsed by he parseVar() method that must be flattened - * @param bool $recursed leave that to false by default, it is only for internal use - * - * @return string flattened tree - */ - protected function flattenVarTree(array $tree, $recursed = false) - { - $out = $recursed ? '".$this->readVarInto(' : ''; - foreach ($tree as $bit) { - if (is_array($bit)) { - $out .= '.' . $this->flattenVarTree($bit, false); - } else { - $key = str_replace('"', '\\"', $bit); - - if (substr($key, 0, 1) === '$') { - $out .= '".' . $this->parseVar($key, 0, strlen($key), false, 'variable') . '."'; - } else { - $cnt = substr_count($key, '$'); - - if ($this->debug) { - echo 'PARSING SUBVARS IN : ' . $key . "\n"; - } - if ($cnt > 0) { - while (-- $cnt >= 0) { - if (isset($last)) { - $last = strrpos($key, '$', - (strlen($key) - $last + 1)); - } else { - $last = strrpos($key, '$'); - } - preg_match('#\$[a-z0-9_]+((?:(?:\.|->)(?:[a-z0-9_]+|(?R))|\[(?:[a-z0-9_]+|(?R))\]))*' . '((?:(?:[+/*%-])(?:\$[a-z0-9.[\]>_:-]+(?:\([^)]*\))?|[0-9.,]*))*)#i', substr($key, $last), $submatch); - - $len = strlen($submatch[0]); - $key = substr_replace( - $key, preg_replace_callback( - '#(\$[a-z0-9_]+((?:(?:\.|->)(?:[a-z0-9_]+|(?R))|\[(?:[a-z0-9_]+|(?R))\]))*)' . '((?:(?:[+/*%-])(?:\$[a-z0-9.[\]>_:-]+(?:\([^)]*\))?|[0-9.,]*))*)#i', array( - $this, - 'replaceVarKeyHelper' - ), substr($key, $last, $len) - ), $last, $len - ); - if ($this->debug) { - echo 'RECURSIVE VAR REPLACEMENT DONE : ' . $key . "\n"; - } - } - unset($last); - - $out .= $key; - } else { - $out .= $key; - } - } - } - } - $out .= $recursed ? ', true)."' : ''; - - return $out; - } - - /** - * Helper function that parses a variable. - * - * @param array $match the matched variable, array(1=>"string match") - * - * @return string parsed variable - */ - protected function replaceVarKeyHelper($match) - { - return '".' . $this->parseVar($match[0], 0, strlen($match[0]), false, 'variable') . '."'; - } - - /** - * Parses various constants, operators or non-quoted strings. - * - * @param string $in the string within which we must parse something - * @param int $from the starting offset of the parsed area - * @param int $to the ending offset of the parsed area - * @param mixed $parsingParams must be an array if we are parsing a function or modifier's parameters, or false by - * default - * @param string $curBlock the current parser-block being processed - * @param mixed $pointer a reference to a pointer that will be increased by the amount of characters parsed, - * or null by default - * - * @return string parsed values - * @throws Exception - */ - protected function parseOthers($in, $from, $to, $parsingParams = false, $curBlock = '', &$pointer = null) - { - $substr = substr($in, $from, $to - $from); - - $end = strlen($substr); - - if ($curBlock === 'condition') { - $breakChars = array( - '(', - ')', - ' ', - '||', - '&&', - '|', - '&', - '>=', - '<=', - '===', - '==', - '=', - '!==', - '!=', - '<<', - '<', - '>>', - '>', - '^', - '~', - ',', - '+', - '-', - '*', - '/', - '%', - '!', - '?', - ':', - $this->rd, - ';' - ); - } elseif ($curBlock === 'modifier') { - $breakChars = array(' ', ',', ')', ':', '|', "\r", "\n", "\t", ';', $this->rd); - } elseif ($curBlock === 'expression') { - $breakChars = array('/', '%', '+', '-', '*', ' ', ',', ')', "\r", "\n", "\t", ';', $this->rd); - } else { - $breakChars = array(' ', ',', ')', "\r", "\n", "\t", ';', $this->rd); - } - - $breaker = false; - foreach ($breakChars as $k => $char) { - $test = strpos($substr, $char); - if ($test !== false && $test < $end) { - $end = $test; - $breaker = $k; - } - } - - if ($curBlock === 'condition') { - if ($end === 0 && $breaker !== false) { - $end = strlen($breakChars[$breaker]); - } - } - - if ($end !== false) { - $substr = substr($substr, 0, $end); - } - - if ($pointer !== null) { - $pointer += strlen($substr); - } - - $src = $substr; - $substr = trim($substr); - - if (strtolower($substr) === 'false' || strtolower($substr) === 'no' || strtolower($substr) === 'off') { - if ($this->debug) { - echo 'BOOLEAN(FALSE) PARSED' . "\n"; - } - $substr = 'false'; - $type = self::T_BOOL; - } elseif (strtolower($substr) === 'true' || strtolower($substr) === 'yes' || strtolower($substr) === 'on') { - if ($this->debug) { - echo 'BOOLEAN(TRUE) PARSED' . "\n"; - } - $substr = 'true'; - $type = self::T_BOOL; - } elseif ($substr === 'null' || $substr === 'NULL') { - if ($this->debug) { - echo 'NULL PARSED' . "\n"; - } - $substr = 'null'; - $type = self::T_NULL; - } elseif (is_numeric($substr)) { - $substr = (float)$substr; - if ((int)$substr == $substr) { - $substr = (int)$substr; - } - $type = self::T_NUMERIC; - if ($this->debug) { - echo 'NUMBER (' . $substr . ') PARSED' . "\n"; - } - } elseif (preg_match('{^-?(\d+|\d*(\.\d+))\s*([/*%+-]\s*-?(\d+|\d*(\.\d+)))+$}', $substr)) { - if ($this->debug) { - echo 'SIMPLE MATH PARSED . "\n"'; - } - $type = self::T_MATH; - $substr = '(' . $substr . ')'; - } elseif ($curBlock === 'condition' && array_search($substr, $breakChars, true) !== false) { - if ($this->debug) { - echo 'BREAKCHAR (' . $substr . ') PARSED' . "\n"; - } - $type = self::T_BREAKCHAR; - //$substr = '"'.$substr.'"'; - } else { - $substr = $this->replaceStringVars('\'' . str_replace('\'', '\\\'', $substr) . '\'', '\'', $curBlock); - $type = self::T_UNQUOTED_STRING; - if ($this->debug) { - echo 'BLABBER (' . $substr . ') CASTED AS STRING' . "\n"; - } - } - - if (is_array($parsingParams)) { - $parsingParams[] = array($substr, $src, $type); - - return $parsingParams; - } elseif ($curBlock === 'namedparam') { - return array($substr, $src, $type); - } elseif ($curBlock === 'expression') { - return $substr; - } else { - throw new Exception('Something went wrong'); - } - } - - /** - * Replaces variables within a parsed string. - * - * @param string $string the parsed string - * @param string $first the first character parsed in the string, which is the string delimiter (' or ") - * @param string $curBlock the current parser-block being processed - * - * @return string the original string with variables replaced - */ - protected function replaceStringVars($string, $first, $curBlock = '') - { - $pos = 0; - if ($this->debug) { - echo 'STRING VAR REPLACEMENT : ' . $string . "\n"; - } - // replace vars - while (($pos = strpos($string, '$', $pos)) !== false) { - $prev = substr($string, $pos - 1, 1); - if ($prev === '\\') { - ++ $pos; - continue; - } - - $var = $this->parse($string, $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string' : 'string'))); - $len = $var[0]; - $var = $this->parse(str_replace('\\' . $first, $first, $string), $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string' : 'string'))); - - if ($prev === '`' && substr($string, $pos + $len, 1) === '`') { - $string = substr_replace($string, $first . '.' . $var[1] . '.' . $first, $pos - 1, $len + 2); - } else { - $string = substr_replace($string, $first . '.' . $var[1] . '.' . $first, $pos, $len); - } - $pos += strlen($var[1]) + 2; - if ($this->debug) { - echo 'STRING VAR REPLACEMENT DONE : ' . $string . "\n"; - } - } - - // handle modifiers - // TODO Obsolete? - $string = preg_replace_callback( - '#("|\')\.(.+?)\.\1((?:\|(?:@?[a-z0-9_]+(?:(?::("|\').+?\4|:[^`]*))*))+)#i', array( - $this, - 'replaceModifiers' - ), $string - ); - - // replace escaped dollar operators by unescaped ones if required - if ($first === "'") { - $string = str_replace('\\$', '$', $string); - } - - return $string; - } - - /** - * Replaces the modifiers applied to a string or a variable. - * - * @param array $m the regex matches that must be array(1=>"double or single quotes enclosing a string, - * when applicable", 2=>"the string or var", 3=>"the modifiers matched") - * @param string $curBlock the current parser-block being processed - * @param null $pointer - * - * @return string the input enclosed with various function calls according to the modifiers found - * @throws CompilationException - * @throws Exception - */ - protected function replaceModifiers(array $m, $curBlock = null, &$pointer = null) - { - if ($this->debug) { - echo 'PARSING MODIFIERS : ' . $m[3] . "\n"; - } - - if ($pointer !== null) { - $pointer += strlen($m[3]); - } - // remove first pipe - $cmdstrsrc = substr($m[3], 1); - // remove last quote if present - if (substr($cmdstrsrc, - 1, 1) === $m[1]) { - $cmdstrsrc = substr($cmdstrsrc, 0, - 1); - $add = $m[1]; - } - - $output = $m[2]; - - $continue = true; - while (strlen($cmdstrsrc) > 0 && $continue) { - if ($cmdstrsrc[0] === '|') { - $cmdstrsrc = substr($cmdstrsrc, 1); - continue; - } - if ($cmdstrsrc[0] === ' ' || $cmdstrsrc[0] === ';' || substr($cmdstrsrc, 0, strlen($this->rd)) === $this->rd) { - if ($this->debug) { - echo 'MODIFIER PARSING ENDED, RIGHT DELIMITER or ";" FOUND' . "\n"; - } - $continue = false; - if ($pointer !== null) { - $pointer -= strlen($cmdstrsrc); - } - break; - } - $cmdstr = $cmdstrsrc; - $paramsep = ':'; - if (!preg_match('/^(@{0,2}[a-z_][a-z0-9_]*)(:)?/i', $cmdstr, $match)) { - throw new CompilationException($this, 'Invalid modifier name, started with : ' . substr($cmdstr, 0, 10)); - } - $paramspos = !empty($match[2]) ? strlen($match[1]) : false; - $func = $match[1]; - - $state = 0; - if ($paramspos === false) { - $cmdstrsrc = substr($cmdstrsrc, strlen($func)); - $params = array(); - if ($this->debug) { - echo 'MODIFIER (' . $func . ') CALLED WITH NO PARAMS' . "\n"; - } - } else { - $paramstr = substr($cmdstr, $paramspos + 1); - if (substr($paramstr, - 1, 1) === $paramsep) { - $paramstr = substr($paramstr, 0, - 1); - } - - $ptr = 0; - $params = array(); - while ($ptr < strlen($paramstr)) { - if ($this->debug) { - echo 'MODIFIER (' . $func . ') START PARAM PARSING WITH POINTER AT ' . $ptr . "\n"; - } - if ($this->debug) { - echo $paramstr . '--' . $ptr . '--' . strlen($paramstr) . '--modifier' . "\n"; - } - $params = $this->parse($paramstr, $ptr, strlen($paramstr), $params, 'modifier', $ptr); - if ($this->debug) { - echo 'PARAM PARSED, POINTER AT ' . $ptr . "\n"; - } - - if ($ptr >= strlen($paramstr)) { - if ($this->debug) { - echo 'PARAM PARSING ENDED, PARAM STRING CONSUMED' . "\n"; - } - break; - } - - if ($paramstr[$ptr] === ' ' || $paramstr[$ptr] === '|' || $paramstr[$ptr] === ';' || substr($paramstr, $ptr, strlen($this->rd)) === $this->rd) { - if ($this->debug) { - echo 'PARAM PARSING ENDED, " ", "|", RIGHT DELIMITER or ";" FOUND, POINTER AT ' . $ptr . "\n"; - } - if ($paramstr[$ptr] !== '|') { - $continue = false; - if ($pointer !== null) { - $pointer -= strlen($paramstr) - $ptr; - } - } - ++ $ptr; - break; - } - if ($ptr < strlen($paramstr) && $paramstr[$ptr] === ':') { - ++ $ptr; - } - } - $cmdstrsrc = substr($cmdstrsrc, strlen($func) + 1 + $ptr); - foreach ($params as $k => $p) { - if (is_array($p) && is_array($p[1])) { - $state |= 2; - } else { - if (($state & 2) && preg_match('#^(["\'])(.+?)\1$#', $p[0], $m)) { - $params[$k] = array($m[2], array('true', 'true')); - } else { - if ($state & 2) { - throw new CompilationException($this, 'You can not use an unnamed parameter after a named one'); - } - $state |= 1; - } - } - } - } - - // check if we must use array_map with this plugin or not - $mapped = false; - if (substr($func, 0, 1) === '@') { - $func = substr($func, 1); - $mapped = true; - } - - $pluginType = $this->getPluginType($func); - - if ($state & 2) { - array_unshift($params, array('value', is_array($output) ? $output : array($output, $output))); - } else { - array_unshift($params, is_array($output) ? $output : array($output, $output)); - } - - if ($pluginType & Core::NATIVE_PLUGIN) { - $params = $this->mapParams($params, null, $state); - - $params = $params['*'][0]; - - $params = self::implode_r($params); - - if ($mapped) { - $output = '$this->arrayMap(\'' . $func . '\', array(' . $params . '))'; - } else { - $output = $func . '(' . $params . ')'; - } - } elseif ($pluginType & Core::PROXY_PLUGIN) { - $params = $this->mapParams($params, $this->getCore()->getPluginProxy()->getCallback($func), $state); - foreach ($params as &$p) { - $p = $p[0]; - } - $output = call_user_func(array($this->getCore()->getPluginProxy(), 'getCode'), $func, $params); - } elseif ($pluginType & Core::SMARTY_MODIFIER) { - $params = $this->mapParams($params, null, $state); - $params = $params['*'][0]; - - $params = self::implode_r($params); - - if ($pluginType & Core::CUSTOM_PLUGIN) { - $callback = $this->customPlugins[$func]['callback']; - if (is_array($callback)) { - if (is_object($callback[0])) { - $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array($this->getCustomPlugin(\'' . $func . '\'), \'' . $callback[1] . '\'), array(' . $params . '))'; - } else { - $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array(\'' . $callback[0] . '\', \'' . $callback[1] . '\'), array(' . $params . '))'; - } - } elseif ($mapped) { - $output = '$this->arrayMap(\'' . $callback . '\', array(' . $params . '))'; - } else { - $output = $callback . '(' . $params . ')'; - } - } elseif ($mapped) { - $output = '$this->arrayMap(\'smarty_modifier_' . $func . '\', array(' . $params . '))'; - } else { - $output = 'smarty_modifier_' . $func . '(' . $params . ')'; - } - } else { - if ($pluginType & Core::CUSTOM_PLUGIN) { - $pluginName = $callback = $this->customPlugins[$func]['callback']; - if (($pluginType & Core::CLASS_PLUGIN) && !is_array($callback)) { - $pluginName = $this->customPlugins[$func]['callback']; - $callback = array($pluginName, ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process'); - } - } else { - if (class_exists('Plugin' . Core::toCamelCase($func)) !== false || function_exists('Plugin' . - Core::toCamelCase($func) . (($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : '')) - !== false) { - $pluginName = 'Plugin' . Core::toCamelCase($func); - } else { - $pluginName = Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func); - } - if ($pluginType & Core::CLASS_PLUGIN) { - $callback = array($pluginName, ($pluginType & Core::COMPILABLE_PLUGIN) ? 'compile' : 'process'); - } else { - $callback = $pluginName . (($pluginType & Core::COMPILABLE_PLUGIN) ? 'Compile' : ''); - } - } - $params = $this->mapParams($params, $callback, $state); - - foreach ($params as &$p) { - $p = $p[0]; - } - - // Only for PHP function, who is not a PHP class - if ($pluginType & Core::FUNC_PLUGIN && !($pluginType & Core::CLASS_PLUGIN)) { - if ($pluginType & Core::COMPILABLE_PLUGIN) { - if ($mapped) { - throw new CompilationException($this, 'The @ operator can not be used on compiled plugins.'); - } - if ($pluginType & Core::CUSTOM_PLUGIN) { - $funcCompiler = $this->customPlugins[$func]['callback']; - } else { - if (function_exists('Plugin' . Core::toCamelCase($func) . 'Compile') !== false) { - $funcCompiler = 'Plugin' . Core::toCamelCase($func) . 'Compile'; - } else { - $funcCompiler = Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func) . - 'Compile'; - } - } - array_unshift($params, $this); - $output = call_user_func_array($funcCompiler, $params); - } else { - array_unshift($params, '$this'); - - $params = self::implode_r($params); - if ($mapped) { - $output = '$this->arrayMap(\'' . $pluginName . '\', array(' . $params . '))'; - } else { - $output = $pluginName . '(' . $params . ')'; - } - } - } else { - if ($pluginType & Core::COMPILABLE_PLUGIN) { - if ($mapped) { - throw new CompilationException($this, 'The @ operator can not be used on compiled plugins.'); - } - if ($pluginType & Core::CUSTOM_PLUGIN) { - $callback = $this->customPlugins[$func]['callback']; - if (!is_array($callback)) { - if (!method_exists($callback, 'compile')) { - throw new Exception('Custom plugin ' . $func . ' must implement the "compile" method to be compilable, or you should provide a full callback to the method to use'); - } - if (($ref = new ReflectionMethod($callback, 'compile')) && $ref->isStatic()) { - $funcCompiler = array($callback, 'compile'); - } else { - $funcCompiler = array(new $callback(), 'compile'); - } - } else { - $funcCompiler = $callback; - } - } else { - if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) { - $funcCompiler = array('Plugin' . Core::toCamelCase($func), 'compile'); - } else { - $funcCompiler = array(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func), 'compile'); - } - array_unshift($params, $this); - } - $output = call_user_func_array($funcCompiler, $params); - } else { - $params = self::implode_r($params); - - if ($pluginType & Core::CUSTOM_PLUGIN) { - if (is_object($callback[0])) { - if (is_array($this->getCore()->getCustomPlugin($func))) { - $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array($this->plugins[\'' . $func . '\'][\'callback\'][0], \'' . $callback[1] . '\'), array(' . $params . '))'; - } else { - $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array($this->getCustomPlugin(\'' . $func . '\'), \'' . $callback[1] . '\'), array(' . $params . '))'; - } - } else { - $output = ($mapped ? '$this->arrayMap' : 'call_user_func_array') . '(array(\'' . $callback[0] . '\', \'' . $callback[1] . '\'), array(' . $params . '))'; - } - } elseif ($mapped) { - $output = '$this->arrayMap(array($this->getObjectPlugin(\''. - Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func) . '\'), - \'process\'), array(' . $params . '))'; - } else { - if (class_exists('Plugin' . Core::toCamelCase($func)) !== false) { - $output = '$this->classCall(\'Plugin' . Core::toCamelCase($func) . '\', array(' . $params . '))'; - } elseif (class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($func)) !== false) { - $output = '$this->classCall(\'' . Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . $func . '\', array(' . $params . '))'; - } elseif (class_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($func)) !== false) { - $output = '$this->classCall(\'' . Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . $func . '\', array(' . $params . '))'; - } else { - $output = '$this->classCall(\'' . $func . '\', array(' . $params . '))'; - } - } - } - } - } - } - - if ($curBlock === 'namedparam') { - return array($output, $output); - } elseif ($curBlock === 'var' || $m[1] === null) { - return $output; - } elseif ($curBlock === 'string' || $curBlock === 'root') { - return $m[1] . '.' . $output . '.' . $m[1] . (isset($add) ? $add : null); - } - - return ''; - } - - /** - * Recursively implodes an array in a similar manner as var_export() does but with some tweaks - * to handle pre-compiled values and the fact that we do not need to enclose everything with - * "array" and do not require top-level keys to be displayed. - * - * @param array $params the array to implode - * @param bool $recursiveCall if set to true, the function outputs key names for the top level - * - * @return string the imploded array - */ - public static function implode_r(array $params, $recursiveCall = false) - { - $out = ''; - foreach ($params as $k => $p) { - if (is_array($p)) { - $out2 = 'array('; - foreach ($p as $k2 => $v) { - $out2 .= var_export($k2, true) . ' => ' . (is_array($v) ? 'array(' . self::implode_r($v, true) . ')' : $v) . ', '; - } - $p = rtrim($out2, ', ') . ')'; - } - if ($recursiveCall) { - $out .= var_export($k, true) . ' => ' . $p . ', '; - } else { - $out .= $p . ', '; - } - } - - return rtrim($out, ', '); - } - - /** - * Returns the plugin type of a plugin and adds it to the used plugins array if required. - * - * @param string $name plugin name, as found in the template - * - * @return int type as a multi bit flag composed of the Dwoo plugin types constants - * @throws Exception - * @throws SecurityException - * @throws Exception - */ - protected function getPluginType($name) - { - $pluginType = - 1; - - if (($this->securityPolicy === null && (function_exists($name) || strtolower($name) === 'isset' || strtolower($name) === 'empty')) || ($this->securityPolicy !== null && array_key_exists(strtolower($name), $this->securityPolicy->getAllowedPhpFunctions()) !== false)) { - $phpFunc = true; - } elseif ($this->securityPolicy !== null && function_exists($name) && array_key_exists(strtolower($name), $this->securityPolicy->getAllowedPhpFunctions()) === false) { - throw new SecurityException('Call to a disallowed php function : ' . $name); - } - - while ($pluginType <= 0) { - // Template plugin compilable - if (isset($this->templatePlugins[$name])) { - $pluginType = Core::TEMPLATE_PLUGIN | Core::COMPILABLE_PLUGIN; - } // Custom plugin - elseif (isset($this->customPlugins[$name])) { - $pluginType = $this->customPlugins[$name]['type'] | Core::CUSTOM_PLUGIN; - } // Class blocks plugin - elseif (class_exists(Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($name)) !== false) { - $pluginType = Core::CLASS_PLUGIN; - if (is_subclass_of(Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($name), 'Dwoo\Block\Plugin')) { - $pluginType += Core::BLOCK_PLUGIN; - } - $interfaces = class_implements(Core::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . Core::toCamelCase($name)); - if (in_array('Dwoo\ICompilable', $interfaces) !== false || in_array('Dwoo\ICompilable\Block', $interfaces) !== false) { - $pluginType |= Core::COMPILABLE_PLUGIN; - } - } // Class functions plugin - elseif (class_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($name)) !== false) { - $pluginType = Core::FUNC_PLUGIN + Core::CLASS_PLUGIN; - $interfaces = class_implements(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($name)); - if (in_array('Dwoo\ICompilable', $interfaces) !== false || in_array('Dwoo\ICompilable\Block', $interfaces) !== false) { - $pluginType |= Core::COMPILABLE_PLUGIN; - } - } // Class without namespace - elseif (class_exists('Plugin' . Core::toCamelCase($name)) !== false) { - $pluginType = Core::CLASS_PLUGIN; - if (is_subclass_of('Plugin' . Core::toCamelCase($name), 'Dwoo\Block\Plugin')) { - $pluginType += Core::BLOCK_PLUGIN; - } - $interfaces = class_implements('Plugin' . Core::toCamelCase($name)); - if (in_array('Dwoo\ICompilable', $interfaces) !== false || in_array('Dwoo\ICompilable\Block', $interfaces) !== false) { - $pluginType |= Core::COMPILABLE_PLUGIN; - } - } // Function plugin (with/without namespaces) - elseif (function_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase ($name)) !== - false || function_exists('Plugin' . Core::toCamelCase($name)) !== false) { - $pluginType = Core::FUNC_PLUGIN; - } // Function plugin compile (with/without namespaces) - elseif (function_exists(Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin' . Core::toCamelCase($name) . - 'Compile') !== false || function_exists('Plugin' . Core::toCamelCase($name) . 'Compile') !== - false) { - $pluginType = Core::FUNC_PLUGIN | Core::COMPILABLE_PLUGIN; - } // Helper plugin class compile - elseif (class_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($name)) !== false) { - $pluginType = Core::CLASS_PLUGIN | Core::COMPILABLE_PLUGIN; - } // Helper plugin function compile - elseif (function_exists(Core::NAMESPACE_PLUGINS_HELPERS . 'Plugin' . Core::toCamelCase($name) . 'Compile') !== false) { - $pluginType = Core::FUNC_PLUGIN | Core::COMPILABLE_PLUGIN; - } // Smarty modifier - elseif (function_exists('smarty_modifier_' . $name) !== false) { - $pluginType = Core::SMARTY_MODIFIER; - } // Smarty function - elseif (function_exists('smarty_function_' . $name) !== false) { - $pluginType = Core::SMARTY_FUNCTION; - } // Smarty block - elseif (function_exists('smarty_block_' . $name) !== false) { - $pluginType = Core::SMARTY_BLOCK; - } // Everything else - else { - if ($pluginType === - 1) { - try { - $this->getCore()->getLoader()->loadPlugin('Plugin' . Core::toCamelCase($name)); - } - catch (Exception $e) { - if (isset($phpFunc)) { - $pluginType = Core::NATIVE_PLUGIN; - } elseif (is_object($this->getCore()->getPluginProxy()) && $this->getCore()->getPluginProxy()->handles($name)) { - $pluginType = Core::PROXY_PLUGIN; - break; - } else { - throw $e; - } - } - } else { - throw new Exception('Plugin "' . $name . '" could not be found, type:' . $pluginType); - } - ++ $pluginType; - } - } - - if (($pluginType & Core::COMPILABLE_PLUGIN) === 0 && ($pluginType & Core::NATIVE_PLUGIN) === 0 && ($pluginType & Core::PROXY_PLUGIN) === 0) { - $this->addUsedPlugin(Core::toCamelCase($name), $pluginType); - } - - return $pluginType; - } - - /** - * Allows a plugin to load another one at compile time, this will also mark - * it as used by this template so it will be loaded at runtime (which can be - * useful for compiled plugins that rely on another plugin when their compiled - * code runs). - * - * @param string $name the plugin name - * - * @return void - */ - public function loadPlugin($name) - { - $this->getPluginType($name); - } - - /** - * Runs htmlentities over the matched blocks when the security policy enforces that. - * - * @param array $match matched php block - * - * @return string the htmlentities-converted string - */ - protected function phpTagEncodingHelper($match) - { - return htmlspecialchars($match[0]); - } - - /** - * Maps the parameters received from the template onto the parameters required by the given callback. - * - * @param array $params the array of parameters - * @param callback $callback the function or method to reflect on to find out the required parameters - * @param int $callType the type of call in the template, 0 = no params, 1 = php-style call, 2 = named - * parameters call - * @param array $map the parameter map to use, if not provided it will be built from the callback - * - * @return array parameters sorted in the correct order with missing optional parameters filled - * @throws CompilationException - */ - protected function mapParams(array $params, $callback, $callType = 2, $map = null) - { - if (!$map) { - $map = $this->getParamMap($callback); - } - - $paramlist = array(); - - // transforms the parameter array from (x=>array('paramname'=>array(values))) to (paramname=>array(values)) - $ps = array(); - foreach ($params as $p) { - if (is_array($p[1])) { - $ps[$p[0]] = $p[1]; - } else { - $ps[] = $p; - } - } - - // loops over the param map and assigns values from the template or default value for unset optional params - foreach ($map as $k => $v){ - if ($v[0] === '*') { - // "rest" array parameter, fill every remaining params in it and then break - if (count($ps) === 0) { - if ($v[1] === false) { - throw new CompilationException( - $this, 'Rest argument missing for ' . str_replace( - array( - Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin', - 'Compile' - ), '', (is_array($callback) ? $callback[0] : $callback) - ) - ); - } else { - break; - } - } - $tmp = array(); - $tmp2 = array(); - $tmp3 = array(); - foreach ($ps as $i => $p) { - $tmp[$i] = $p[0]; - $tmp2[$i] = $p[1]; - $tmp3[$i] = isset($p[2]) ? $p[2] : 0; - unset($ps[$i]); - } - $paramlist[$v[0]] = array($tmp, $tmp2, $tmp3); - unset($tmp, $tmp2, $i, $p); - break; - } elseif (isset($ps[$v[0]])) { - // parameter is defined as named param - $paramlist[$v[0]] = $ps[$v[0]]; - unset($ps[$v[0]]); - } elseif (isset($ps[$k])) { - // parameter is defined as ordered param - $paramlist[$v[0]] = $ps[$k]; - unset($ps[$k]); - } elseif ($v[1] === false) { - // parameter is not defined and not optional, throw error - if (is_array($callback)) { - if (is_object($callback[0])) { - $name = get_class($callback[0]) . '::' . $callback[1]; - } else { - $name = $callback[0]; - } - } else { - $name = $callback; - } - - throw new CompilationException( - $this, 'Argument ' . $k . '/' . $v[0] . ' missing for ' . str_replace( - array( - Core::NAMESPACE_PLUGINS_FUNCTIONS . 'Plugin', - 'Compile' - ), '', $name - ) - ); - } elseif ($v[2] === null) { - // enforce lowercased null if default value is null (php outputs NULL with var export) - $paramlist[$v[0]] = array('null', null, self::T_NULL); - } else { - // outputs default value with var_export - $paramlist[$v[0]] = array(var_export($v[2], true), $v[2]); - } - } - - if (count($ps)) { - foreach ($ps as $i => $p) { - array_push($paramlist, $p); - } - } - - return $paramlist; - } - - /** - * Returns the parameter map of the given callback, it filters out entries typed as Dwoo and Compiler and turns the - * rest parameter into a "*". - * - * @param callback $callback the function/method to reflect on - * - * @return array processed parameter map - */ - protected function getParamMap($callback) - { - if (is_null($callback)) { - return array(array('*', true)); - } - if (is_array($callback)) { - $ref = new ReflectionMethod($callback[0], $callback[1]); - } else { - $ref = new ReflectionFunction($callback); - } - - $out = array(); - foreach ($ref->getParameters() as $param) { - if (($class = $param->getClass()) !== null && $class->name === 'Dwoo\Core') { - continue; - } - if (($class = $param->getClass()) !== null && $class->name === 'Dwoo\Compiler') { - continue; - } - if ($param->getName() === 'rest' && $param->isArray() === true) { - $out[] = array('*', $param->isOptional(), null); - continue; - } - $out[] = array( - $param->getName(), - $param->isOptional(), - $param->isOptional() ? $param->getDefaultValue() : null - ); - } - - return $out; - } - - /** - * Returns a default instance of this compiler, used by default by all Dwoo templates that do not have a - * specific compiler assigned and when you do not override the default compiler factory function. - * - * @see Core::setDefaultCompilerFactory() - * @return Compiler - */ - public static function compilerFactory() - { - if (self::$instance === null) { - self::$instance = new self(); - } - - return self::$instance; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Core.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Core.php deleted file mode 100644 index 26a6a38..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Core.php +++ /dev/null @@ -1,1795 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2017 David Sanchez - * @license http://dwoo.org/LICENSE LGPLv3 - * @version 1.3.6 - * @date 2017-03-23 - * @link http://dwoo.org/ - */ - -namespace Dwoo; - -use ArrayAccess; -use Closure; -use Countable; -use Dwoo\Plugins\Blocks\PluginDynamic; -use Dwoo\Security\Policy as SecurityPolicy; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\Template\File as TemplateFile; -use Iterator; -use stdClass; -use Traversable; - -/** - * Main dwoo class, allows communication between the compiler, template and data classes. - *
- * requirements :
- *  php 5.3.0 or above (might work below, it's a rough estimate)
- *  SPL and PCRE extensions (for php versions prior to 5.3.0)
- *  mbstring extension for some string manipulation plugins (especially if you intend to use UTF-8)
- * recommended :
- *  hash extension (for Dwoo\Template\Str - minor performance boost)
- * project created :
- *  2008-01-05
- * 
- * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class Core -{ - /** - * Current version number. - * - * @var string - */ - const VERSION = '1.3.6'; - - /** - * Unique number of this dwoo release, based on version number. - * this can be used by templates classes to check whether the compiled template - * has been compiled before this release or not, so that old templates are - * recompiled automatically when Dwoo is updated - */ - const RELEASE_TAG = 136; - - /** - * Constants that represents all plugin types - * these are bitwise-operation-safe values to allow multiple types - * on a single plugin - * - * @var int - */ - const CLASS_PLUGIN = 1; - const FUNC_PLUGIN = 2; - const NATIVE_PLUGIN = 4; - const BLOCK_PLUGIN = 8; - const COMPILABLE_PLUGIN = 16; - const CUSTOM_PLUGIN = 32; - const SMARTY_MODIFIER = 64; - const SMARTY_BLOCK = 128; - const SMARTY_FUNCTION = 256; - const PROXY_PLUGIN = 512; - const TEMPLATE_PLUGIN = 1024; - - /** - * Constant to default namespaces of builtin plugins - * - * @var string - */ - const NAMESPACE_PLUGINS_BLOCKS = 'Dwoo\Plugins\Blocks\\'; - const NAMESPACE_PLUGINS_FILTERS = 'Dwoo\Plugins\Filters\\'; - const NAMESPACE_PLUGINS_FUNCTIONS = 'Dwoo\Plugins\Functions\\'; - const NAMESPACE_PLUGINS_HELPERS = 'Dwoo\Plugins\Helpers\\'; - const NAMESPACE_PLUGINS_PROCESSORS = 'Dwoo\Plugins\Processors\\'; - - /** - * Character set of the template, used by string manipulation plugins. - * it must be lowercase, but setCharset() will take care of that - * - * @see setCharset - * @see getCharset - * @var string - */ - protected $charset = 'UTF-8'; - - /** - * Global variables that are accessible through $dwoo.* in the templates. - * default values include: - * $dwoo.version - current version number - * $dwoo.ad - a Powered by Dwoo link pointing to dwoo.org - * $dwoo.now - the current time - * $dwoo.template - the current template filename - * $dwoo.charset - the character set used by the template - * on top of that, foreach and other plugins can store special values in there, - * see their documentation for more details. - * - * @var array - */ - protected $globals = array(); - - /** - * Directory where the compiled templates are stored. - * defaults to DWOO_COMPILEDIR (= dwoo_dir/compiled by default) - * - * @var string - */ - protected $compileDir; - - /** - * Directory where the cached templates are stored. - * defaults to DWOO_CACHEDIR (= dwoo_dir/cache by default) - * - * @var string - */ - protected $cacheDir; - - /** - * Directory where the template files are stored - * - * @var array - */ - protected $templateDir = array(); - - /** - * Defines how long (in seconds) the cached files must remain valid. - * can be overridden on a per-template basis - * -1 = never delete - * 0 = disabled - * >0 = duration in seconds - * - * @var int - */ - protected $cacheTime = 0; - - /** - * Security policy object. - * - * @var SecurityPolicy - */ - protected $securityPolicy = null; - - /** - * Stores the custom plugins callbacks. - * - * @see addPlugin - * @see removePlugin - * @var array - */ - protected $plugins = array(); - - /** - * Stores the filter callbacks. - * - * @see addFilter - * @see removeFilter - * @var array - */ - protected $filters = array(); - - /** - * Stores the resource types and associated - * classes / compiler classes. - * - * @var array - */ - protected $resources = array( - 'file' => array( - 'class' => 'Dwoo\Template\File', - 'compiler' => null, - ), - 'string' => array( - 'class' => 'Dwoo\Template\Str', - 'compiler' => null, - ), - ); - - /** - * The dwoo loader object used to load plugins by this dwoo instance. - * - * @var ILoader - */ - protected $loader = null; - - /** - * Currently rendered template, set to null when not-rendering. - * - * @var ITemplate - */ - protected $template = null; - - /** - * Stores the instances of the class plugins during template runtime. - * - * @var array - */ - protected $runtimePlugins = array(); - - /** - * Stores the returned values during template runtime. - * - * @var array - */ - protected $returnData = array(); - - /** - * Stores the data during template runtime. - * - * @var array - */ - protected $data = array(); - - /** - * Stores the current scope during template runtime. - * this should ideally not be accessed directly from outside template code - * - * @var mixed - */ - public $scope; - - /** - * Stores the scope tree during template runtime. - * - * @var array - */ - protected $scopeTree = array(); - - /** - * Stores the block plugins stack during template runtime. - * - * @var array - */ - protected $stack = array(); - - /** - * Stores the current block plugin at the top of the stack during template runtime. - * - * @var BlockPlugin - */ - protected $curBlock; - - /** - * Stores the output buffer during template runtime. - * - * @var string - */ - protected $buffer; - - /** - * Stores plugin proxy. - * - * @var IPluginProxy - */ - protected $pluginProxy; - - /** - * Constructor, sets the cache and compile dir to the default values if not provided. - * - * @param string $compileDir path to the compiled directory, defaults to lib/compiled - * @param string $cacheDir path to the cache directory, defaults to lib/cache - */ - public function __construct($compileDir = null, $cacheDir = null) - { - if ($compileDir !== null) { - $this->setCompileDir($compileDir); - } - if ($cacheDir !== null) { - $this->setCacheDir($cacheDir); - } - $this->initGlobals(); - } - - /** - * Resets some runtime variables to allow a cloned object to be used to render sub-templates. - * - * @return void - */ - public function __clone() - { - $this->template = null; - unset($this->data); - unset($this->returnData); - } - - /** - * Returns the given template rendered using the provided data and optional compiler. - * - * @param mixed $_tpl template, can either be a ITemplate object (i.e. TemplateFile), a - * valid path to a template, or a template as a string it is recommended to - * provide a ITemplate as it will probably make things faster, especially if - * you render a template multiple times - * @param mixed $data the data to use, can either be a IDataProvider object (i.e. Data) or - * an associative array. if you're rendering the template from cache, it can be - * left null - * @param ICompiler $_compiler the compiler that must be used to compile the template, if left empty a default - * Compiler will be used - * - * @return string|void or the template output if $output is false - * @throws Exception - */ - public function get($_tpl, $data = array(), $_compiler = null) - { - // a render call came from within a template, so we need a new dwoo instance in order to avoid breaking this one - if ($this->template instanceof ITemplate) { - $clone = clone $this; - - return $clone->get($_tpl, $data, $_compiler); - } - - // auto-create template if required - if ($_tpl instanceof ITemplate) { - // valid, skip - } elseif (is_string($_tpl)) { - $_tpl = new TemplateFile($_tpl); - $_tpl->setIncludePath($this->getTemplateDir()); - } else { - throw new Exception('Dwoo->get\'s first argument must be a ITemplate (i.e. TemplateFile) or a valid path to a template file', E_USER_NOTICE); - } - - // save the current template, enters render mode at the same time - // if another rendering is requested it will be proxied to a new Core(instance - $this->template = $_tpl; - - // load data - if ($data instanceof IDataProvider) { - $this->data = $data->getData(); - } elseif (is_array($data)) { - $this->data = $data; - } elseif ($data instanceof ArrayAccess) { - $this->data = $data; - } else { - throw new Exception('Dwoo->get/Dwoo->output\'s data argument must be a IDataProvider object (i.e. Data) or an associative array', E_USER_NOTICE); - } - - $this->addGlobal('template', $_tpl->getName()); - $this->initRuntimeVars($_tpl); - - // try to get cached template - $file = $_tpl->getCachedTemplate($this); - $doCache = $file === true; - $cacheLoaded = is_string($file); - - if ($cacheLoaded === true) { - // cache is present, run it - ob_start(); - include $file; - $this->template = null; - - return ob_get_clean(); - } else { - $dynamicId = uniqid(); - - // render template - $compiledTemplate = $_tpl->getCompiledTemplate($this, $_compiler); - $out = include $compiledTemplate; - - // template returned false so it needs to be recompiled - if ($out === false) { - $_tpl->forceCompilation(); - $compiledTemplate = $_tpl->getCompiledTemplate($this, $_compiler); - $out = include $compiledTemplate; - } - - if ($doCache === true) { - $out = preg_replace('/(<%|%>|<\?php|<\?|\?>)/', '', $out); - if (!class_exists(self::NAMESPACE_PLUGINS_BLOCKS . 'PluginDynamic')) { - $this->getLoader()->loadPlugin('PluginDynamic'); - } - $out = PluginDynamic::unescape($out, $dynamicId, $compiledTemplate); - } - - // process filters - foreach ($this->filters as $filter) { - if (is_array($filter) && $filter[0] instanceof Filter) { - $out = call_user_func($filter, $out); - } else { - $out = call_user_func($filter, $this, $out); - } - } - - if ($doCache === true) { - // building cache - $file = $_tpl->cache($this, $out); - - // run it from the cache to be sure dynamics are rendered - ob_start(); - include $file; - // exit render mode - $this->template = null; - - return ob_get_clean(); - } else { - // no need to build cache - // exit render mode - $this->template = null; - - return $out; - } - } - } - - /** - * Registers a Global. - * New globals can be added before compiling or rendering a template - * but after, you can only update existing globals. - * - * @param string $name - * @param mixed $value - * - * @return $this - * @throws Exception - */ - public function addGlobal($name, $value) - { - if (null === $this->globals) { - $this->initGlobals(); - } - - $this->globals[$name] = $value; - - return $this; - } - - /** - * Gets the registered Globals. - * - * @return array - */ - public function getGlobals() - { - return $this->globals; - } - - /** - * Re-initializes the globals array before each template run. - * this method is only callede once when the Dwoo object is created - * - * @return void - */ - protected function initGlobals() - { - $this->globals = array( - 'version' => self::VERSION, - 'ad' => 'Powered by Dwoo', - 'now' => $_SERVER['REQUEST_TIME'], - 'charset' => $this->getCharset(), - ); - } - - /** - * Re-initializes the runtime variables before each template run. - * override this method to inject data in the globals array if needed, this - * method is called before each template execution - * - * @param ITemplate $tpl the template that is going to be rendered - * - * @return void - */ - protected function initRuntimeVars(ITemplate $tpl) - { - $this->runtimePlugins = array(); - $this->scope = &$this->data; - $this->scopeTree = array(); - $this->stack = array(); - $this->curBlock = null; - $this->buffer = ''; - $this->returnData = array(); - } - - /** - * Adds a custom plugin that is not in one of the plugin directories. - * - * @param string $name the plugin name to be used in the templates - * @param callback $callback the plugin callback, either a function name, - * a class name or an array containing an object - * or class name and a method name - * @param bool $compilable if set to true, the plugin is assumed to be compilable - * - * @return void - * @throws Exception - */ - public function addPlugin($name, $callback, $compilable = false) - { - $compilable = $compilable ? self::COMPILABLE_PLUGIN : 0; - if (is_array($callback)) { - if (is_subclass_of(is_object($callback[0]) ? get_class($callback[0]) : $callback[0], 'Dwoo\Block\Plugin')) { - $this->plugins[$name] = array( - 'type' => self::BLOCK_PLUGIN | $compilable, - 'callback' => $callback, - 'class' => (is_object($callback[0]) ? get_class($callback[0]) : $callback[0]) - ); - } else { - $this->plugins[$name] = array( - 'type' => self::CLASS_PLUGIN | $compilable, - 'callback' => $callback, - 'class' => (is_object($callback[0]) ? get_class($callback[0]) : $callback[0]), - 'function' => $callback[1] - ); - } - } elseif (is_string($callback)) { - if (class_exists($callback)) { - if (is_subclass_of($callback, 'Dwoo\Block\Plugin')) { - $this->plugins[$name] = array( - 'type' => self::BLOCK_PLUGIN | $compilable, - 'callback' => $callback, - 'class' => $callback - ); - } else { - $this->plugins[$name] = array( - 'type' => self::CLASS_PLUGIN | $compilable, - 'callback' => $callback, - 'class' => $callback, - 'function' => ($compilable ? 'compile' : 'process') - ); - } - } elseif (function_exists($callback)) { - $this->plugins[$name] = array( - 'type' => self::FUNC_PLUGIN | $compilable, - 'callback' => $callback - ); - } else { - throw new Exception('Callback could not be processed correctly, please check that the function/class you used exists'); - } - } elseif ($callback instanceof Closure) { - $this->plugins[$name] = array( - 'type' => self::FUNC_PLUGIN | $compilable, - 'callback' => $callback - ); - } elseif (is_object($callback)) { - if (is_subclass_of($callback, 'Dwoo\Block\Plugin')) { - $this->plugins[$name] = array( - 'type' => self::BLOCK_PLUGIN | $compilable, - 'callback' => get_class($callback), - 'class' => $callback - ); - } else { - $this->plugins[$name] = array( - 'type' => self::CLASS_PLUGIN | $compilable, - 'callback' => $callback, - 'class' => $callback, - 'function' => ($compilable ? 'compile' : 'process') - ); - } - } else { - throw new Exception('Callback could not be processed correctly, please check that the function/class you used exists'); - } - } - - /** - * Removes a custom plugin. - * - * @param string $name the plugin name - * - * @return void - */ - public function removePlugin($name) - { - if (isset($this->plugins[$name])) { - unset($this->plugins[$name]); - } - } - - /** - * Adds a filter to this Dwoo instance, it will be used to filter the output of all the templates rendered by this - * instance. - * - * @param mixed $callback a callback or a filter name if it is autoloaded from a plugin directory - * @param bool $autoload if true, the first parameter must be a filter name from one of the plugin directories - * - * @return void - * @throws Exception - */ - public function addFilter($callback, $autoload = false) - { - if ($autoload) { - $class = self::NAMESPACE_PLUGINS_FILTERS . self::toCamelCase($callback); - if (!class_exists($class) && !function_exists($class)) { - try { - $this->getLoader()->loadPlugin($callback); - } - catch (Exception $e) { - if (strstr($callback, self::NAMESPACE_PLUGINS_FILTERS)) { - throw new Exception('Wrong filter name : ' . $callback . ', the "Filter" prefix should not be used, please only use "' . str_replace('Filter', '', $callback) . '"'); - } else { - throw new Exception('Wrong filter name : ' . $callback . ', when using autoload the filter must be in one of your plugin dir as "name.php" containig a class or function named "Filter"'); - } - } - } - - if (class_exists($class)) { - $callback = array(new $class($this), 'process'); - } elseif (function_exists($class)) { - $callback = $class; - } else { - throw new Exception('Wrong filter name : ' . $callback . ', when using autoload the filter must be in one of your plugin dir as "name.php" containig a class or function named "Filter"'); - } - - $this->filters[] = $callback; - } else { - $this->filters[] = $callback; - } - } - - /** - * Removes a filter. - * - * @param mixed $callback callback or filter name if it was autoloaded - * - * @return void - */ - public function removeFilter($callback) - { - if (($index = array_search(self::NAMESPACE_PLUGINS_FILTERS. 'Filter' . self::toCamelCase($callback), $this->filters, - true)) !== - false) { - unset($this->filters[$index]); - } elseif (($index = array_search($callback, $this->filters, true)) !== false) { - unset($this->filters[$index]); - } else { - $class = self::NAMESPACE_PLUGINS_FILTERS . 'Filter' . $callback; - foreach ($this->filters as $index => $filter) { - if (is_array($filter) && $filter[0] instanceof $class) { - unset($this->filters[$index]); - break; - } - } - } - } - - /** - * Adds a resource or overrides a default one. - * - * @param string $name the resource name - * @param string $class the resource class (which must implement ITemplate) - * @param callback $compilerFactory the compiler factory callback, a function that must return a compiler instance - * used to compile this resource, if none is provided. by default it will produce - * a Compiler object - * - * @return void - * @throws Exception - */ - public function addResource($name, $class, $compilerFactory = null) - { - if (strlen($name) < 2) { - throw new Exception('Resource names must be at least two-character long to avoid conflicts with Windows paths'); - } - - if (!class_exists($class)) { - throw new Exception(sprintf('Resource class %s does not exist', $class)); - } - - $interfaces = class_implements($class); - if (in_array('Dwoo\ITemplate', $interfaces) === false) { - throw new Exception('Resource class must implement ITemplate'); - } - - $this->resources[$name] = array( - 'class' => $class, - 'compiler' => $compilerFactory - ); - } - - /** - * Removes a custom resource. - * - * @param string $name the resource name - * - * @return void - */ - public function removeResource($name) - { - unset($this->resources[$name]); - if ($name === 'file') { - $this->resources['file'] = array( - 'class' => 'Dwoo\Template\File', - 'compiler' => null - ); - } - } - - /** - * Sets the loader object to use to load plugins. - * - * @param ILoader $loader loader - * - * @return void - */ - public function setLoader(ILoader $loader) - { - $this->loader = $loader; - } - - /** - * Returns the current loader object or a default one if none is currently found. - * - * @return ILoader|Loader - */ - public function getLoader() - { - if ($this->loader === null) { - $this->loader = new Loader($this->getCompileDir()); - } - - return $this->loader; - } - - /** - * Returns the custom plugins loaded. - * Used by the ITemplate classes to pass the custom plugins to their ICompiler instance. - * - * @return array - */ - public function getCustomPlugins() - { - return $this->plugins; - } - - /** - * Return a specified custom plugin loaded by his name. - * Used by the compiler, for executing a Closure. - * - * @param string $name - * - * @return mixed|null - */ - public function getCustomPlugin($name) - { - if (isset($this->plugins[$name])) { - return $this->plugins[$name]['callback']; - } - - return null; - } - - /** - * Returns the cache directory with a trailing DIRECTORY_SEPARATOR. - * - * @return string - */ - public function getCacheDir() - { - if ($this->cacheDir === null) { - $this->setCacheDir(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR); - } - - return $this->cacheDir; - } - - /** - * Sets the cache directory and automatically appends a DIRECTORY_SEPARATOR. - * - * @param string $dir the cache directory - * - * @return void - * @throws Exception - */ - public function setCacheDir($dir) - { - $this->cacheDir = rtrim($dir, '/\\') . DIRECTORY_SEPARATOR; - if (!file_exists($this->cacheDir)) { - mkdir($this->cacheDir, 0777, true); - } - if (is_writable($this->cacheDir) === false) { - throw new Exception('The cache directory must be writable, chmod "' . $this->cacheDir . '" to make it writable'); - } - } - - /** - * Returns the compile directory with a trailing DIRECTORY_SEPARATOR. - * - * @return string - */ - public function getCompileDir() - { - if ($this->compileDir === null) { - $this->setCompileDir(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'compiled' . DIRECTORY_SEPARATOR); - } - - return $this->compileDir; - } - - /** - * Sets the compile directory and automatically appends a DIRECTORY_SEPARATOR. - * - * @param string $dir the compile directory - * - * @return void - * @throws Exception - */ - public function setCompileDir($dir) - { - $this->compileDir = rtrim($dir, '/\\') . DIRECTORY_SEPARATOR; - if (!file_exists($this->compileDir)) { - mkdir($this->compileDir, 0777, true); - } - if (is_writable($this->compileDir) === false) { - throw new Exception('The compile directory must be writable, chmod "' . $this->compileDir . '" to make it writable'); - } - } - - /** - * Returns an array of the template directory with a trailing DIRECTORY_SEPARATOR - * - * @return array - */ - public function getTemplateDir() - { - return $this->templateDir; - } - - /** - * sets the template directory and automatically appends a DIRECTORY_SEPARATOR - * template directory is stored in an array - * - * @param string $dir - * - * @throws Exception - */ - public function setTemplateDir($dir) - { - $tmpDir = rtrim($dir, '/\\') . DIRECTORY_SEPARATOR; - if (is_dir($tmpDir) === false) { - throw new Exception('The template directory: "' . $tmpDir . '" does not exists, create the directory or specify an other location !'); - } - $this->templateDir[] = $tmpDir; - } - - /** - * Returns the default cache time that is used with templates that do not have a cache time set. - * - * @return int the duration in seconds - */ - public function getCacheTime() - { - return $this->cacheTime; - } - - /** - * Sets the default cache time to use with templates that do not have a cache time set. - * - * @param int $seconds the duration in seconds - * - * @return void - */ - public function setCacheTime($seconds) - { - $this->cacheTime = (int)$seconds; - } - - /** - * Returns the character set used by the string manipulation plugins. - * the charset is automatically lowercased - * - * @return string - */ - public function getCharset() - { - return $this->charset; - } - - /** - * Sets the character set used by the string manipulation plugins. - * the charset will be automatically lowercased - * - * @param string $charset the character set - * - * @return void - */ - public function setCharset($charset) - { - $this->charset = strtolower((string)$charset); - } - - /** - * Returns the current template being rendered, when applicable, or null. - * - * @return ITemplate|null - */ - public function getTemplate() - { - return $this->template; - } - - /** - * Sets the current template being rendered. - * - * @param ITemplate $tpl template object - * - * @return void - */ - public function setTemplate(ITemplate $tpl) - { - $this->template = $tpl; - } - - /** - * Sets the default compiler factory function for the given resource name. - * a compiler factory must return a ICompiler object pre-configured to fit your needs - * - * @param string $resourceName the resource name (i.e. file, string) - * @param callback $compilerFactory the compiler factory callback - * - * @return void - */ - public function setDefaultCompilerFactory($resourceName, $compilerFactory) - { - $this->resources[$resourceName]['compiler'] = $compilerFactory; - } - - /** - * Returns the default compiler factory function for the given resource name. - * - * @param string $resourceName the resource name - * - * @return callback the compiler factory callback - */ - public function getDefaultCompilerFactory($resourceName) - { - return $this->resources[$resourceName]['compiler']; - } - - /** - * Sets the security policy object to enforce some php security settings. - * use this if untrusted persons can modify templates - * - * @param SecurityPolicy $policy the security policy object - * - * @return void - */ - public function setSecurityPolicy(SecurityPolicy $policy = null) - { - $this->securityPolicy = $policy; - } - - /** - * Returns the current security policy object or null by default. - * - * @return SecurityPolicy|null the security policy object if any - */ - public function getSecurityPolicy() - { - return $this->securityPolicy; - } - - /** - * Sets the object that must be used as a plugin proxy when plugin can't be found - * by dwoo's loader. - * - * @param IPluginProxy $pluginProxy the proxy object - * - * @return void - */ - public function setPluginProxy(IPluginProxy $pluginProxy) - { - $this->pluginProxy = $pluginProxy; - } - - /** - * Returns the current plugin proxy object or null by default. - * - * @return IPluginProxy - */ - public function getPluginProxy() - { - return $this->pluginProxy; - } - - /** - * Checks whether the given template is cached or not. - * - * @param ITemplate $tpl the template object - * - * @return bool - */ - public function isCached(ITemplate $tpl) - { - return is_string($tpl->getCachedTemplate($this)); - } - - /** - * Clear templates inside the compiled directory. - * - * @return int - */ - public function clearCompiled() - { - $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->getCompileDir()), \RecursiveIteratorIterator::SELF_FIRST); - $count = 0; - foreach ($iterator as $file) { - if ($file->isFile()) { - $count += unlink($file->__toString()) ? 1 : 0; - } - } - - return $count; - } - - /** - * Clears the cached templates if they are older than the given time. - * - * @param int $olderThan minimum time (in seconds) required for a cached template to be cleared - * - * @return int the amount of templates cleared - */ - public function clearCache($olderThan = - 1) - { - $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->getCacheDir()), \RecursiveIteratorIterator::SELF_FIRST); - $expired = time() - $olderThan; - $count = 0; - foreach ($iterator as $file) { - if ($file->isFile() && $file->getCTime() < $expired) { - $count += unlink((string)$file) ? 1 : 0; - } - } - - return $count; - } - - /** - * Fetches a template object of the given resource. - * - * @param string $resourceName the resource name (i.e. file, string) - * @param string $resourceId the resource identifier (i.e. file path) - * @param int $cacheTime the cache time setting for this resource - * @param string $cacheId the unique cache identifier - * @param string $compileId the unique compiler identifier - * @param ITemplate $parentTemplate the parent template - * - * @return ITemplate - * @throws Exception - */ - public function templateFactory($resourceName, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, ITemplate $parentTemplate = null) - { - if (isset($this->resources[$resourceName])) { - /** - * Interface ITemplate - * - * @var ITemplate $class - */ - $class = $this->resources[$resourceName]['class']; - - return $class::templateFactory($this, $resourceId, $cacheTime, $cacheId, $compileId, $parentTemplate); - } - - throw new Exception('Unknown resource type : ' . $resourceName); - } - - /** - * Checks if the input is an array or arrayaccess object, optionally it can also check if it's - * empty. - * - * @param mixed $value the variable to check - * @param bool $checkIsEmpty if true, the function will also check if the array|arrayaccess is empty, - * and return true only if it's not empty - * - * @return int|bool true if it's an array|arrayaccess (or the item count if $checkIsEmpty is true) or false if it's - * not an array|arrayaccess (or 0 if $checkIsEmpty is true) - */ - public function isArray($value, $checkIsEmpty = false) - { - if (is_array($value) === true || $value instanceof ArrayAccess) { - if ($checkIsEmpty === false) { - return true; - } - - return $this->count($value); - } - - return false; - } - - /** - * Checks if the input is an array or a traversable object, optionally it can also check if it's - * empty. - * - * @param mixed $value the variable to check - * @param bool $checkIsEmpty if true, the function will also check if the array|traversable is empty, - * and return true only if it's not empty - * - * @return int|bool true if it's an array|traversable (or the item count if $checkIsEmpty is true) or false if it's - * not an array|traversable (or 0 if $checkIsEmpty is true) - */ - public function isTraversable($value, $checkIsEmpty = false) - { - if (is_array($value) === true) { - if ($checkIsEmpty === false) { - return true; - } else { - return count($value) > 0; - } - } elseif ($value instanceof Traversable) { - if ($checkIsEmpty === false) { - return true; - } else { - return $this->count($value); - } - } - - return false; - } - - /** - * Counts an array or arrayaccess/traversable object. - * - * @param mixed $value the value to count - * - * @return int|bool the count for arrays and objects that implement countable, true for other objects that don't, - * and 0 for empty elements - */ - public function count($value) - { - if (is_array($value) === true || $value instanceof Countable) { - return count($value); - } elseif ($value instanceof ArrayAccess) { - if ($value->offsetExists(0)) { - return true; - } - } elseif ($value instanceof Iterator) { - $value->rewind(); - if ($value->valid()) { - return true; - } - } elseif ($value instanceof Traversable) { - foreach ($value as $dummy) { - return true; - } - } - - return 0; - } - - /** - * Triggers a dwoo error. - * - * @param string $message the error message - * @param int $level the error level, one of the PHP's E_* constants - * - * @return void - */ - public function triggerError($message, $level = E_USER_NOTICE) - { - if (!($tplIdentifier = $this->template->getResourceIdentifier())) { - $tplIdentifier = $this->template->getResourceName(); - } - trigger_error('Dwoo error (in ' . $tplIdentifier . ') : ' . $message, $level); - } - - /** - * Adds a block to the block stack. - * - * @param string $blockName the block name (without `Plugin` prefix) - * @param array $args the arguments to be passed to the block's init() function - * - * @return BlockPlugin the newly created block - */ - public function addStack($blockName, array $args = array()) - { - if (isset($this->plugins[$blockName])) { - $class = $this->plugins[$blockName]['class']; - } else { - $class = current(array_filter([ - 'Plugin' . self::toCamelCase($blockName), - self::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . self::toCamelCase($blockName) - ], 'class_exists')); - } - - if ($this->curBlock !== null) { - $this->curBlock->buffer(ob_get_contents()); - ob_clean(); - } else { - $this->buffer .= ob_get_contents(); - ob_clean(); - } - - $block = new $class($this); - - call_user_func_array(array($block, 'init'), $args); - - $this->stack[] = $this->curBlock = $block; - - return $block; - } - - /** - * Removes the plugin at the top of the block stack. - * Calls the block buffer() function, followed by a call to end() and finally a call to process() - * - * @return void - */ - public function delStack() - { - $args = func_get_args(); - - $this->curBlock->buffer(ob_get_contents()); - ob_clean(); - - call_user_func_array(array($this->curBlock, 'end'), $args); - - $tmp = array_pop($this->stack); - - if (count($this->stack) > 0) { - $this->curBlock = end($this->stack); - $this->curBlock->buffer($tmp->process()); - } else { - if ($this->buffer !== '') { - echo $this->buffer; - $this->buffer = ''; - } - $this->curBlock = null; - echo $tmp->process(); - } - - unset($tmp); - } - - /** - * Returns the parent block of the given block. - * - * @param BlockPlugin $block the block class plugin - * - * @return BlockPlugin|false if the given block isn't in the stack - */ - public function getParentBlock(BlockPlugin $block) - { - $index = array_search($block, $this->stack, true); - if ($index !== false && $index > 0) { - return $this->stack[$index - 1]; - } - - return false; - } - - /** - * Finds the closest block of the given type, starting at the top of the stack. - * - * @param string $type the type of plugin you want to find - * - * @return BlockPlugin|false if no plugin of such type is in the stack - */ - public function findBlock($type) - { - if (isset($this->plugins[$type])) { - $type = $this->plugins[$type]['class']; - } else { - $type = self::NAMESPACE_PLUGINS_BLOCKS . 'Plugin_' . str_replace(self::NAMESPACE_PLUGINS_BLOCKS.'Plugin', - '', $type); - } - - $keys = array_keys($this->stack); - while (($key = array_pop($keys)) !== false) { - if ($this->stack[$key] instanceof $type) { - return $this->stack[$key]; - } - } - - return false; - } - - /** - * Returns a Plugin of the given class. - * this is so a single instance of every class plugin is created at each template run, - * allowing class plugins to have "per-template-run" static variables - * - * @param string $class the class name - * - * @return mixed an object of the given class - */ - public function getObjectPlugin($class) - { - if (isset($this->runtimePlugins[$class])) { - return $this->runtimePlugins[$class]; - } - - return $this->runtimePlugins[$class] = new $class($this); - } - - /** - * Calls the process() method of the given class-plugin name. - * - * @param string $plugName the class plugin name (without `Plugin` prefix) - * @param array $params an array of parameters to send to the process() method - * - * @return string the process() return value - */ - public function classCall($plugName, array $params = array()) - { - $class = self::toCamelCase($plugName); - $plugin = $this->getObjectPlugin($class); - - return call_user_func_array(array($plugin, 'process'), $params); - } - - /** - * Calls a php function. - * - * @param string $callback the function to call - * @param array $params an array of parameters to send to the function - * - * @return mixed the return value of the called function - */ - public function arrayMap($callback, array $params) - { - if ($params[0] === $this) { - $addThis = true; - array_shift($params); - } - if ((is_array($params[0]) || ($params[0] instanceof Iterator && $params[0] instanceof ArrayAccess))) { - if (empty($params[0])) { - return $params[0]; - } - - // array map - $out = array(); - $cnt = count($params); - - if (isset($addThis)) { - array_unshift($params, $this); - $items = $params[1]; - $keys = array_keys($items); - - if (is_string($callback) === false) { - while (($i = array_shift($keys)) !== null) { - $out[] = call_user_func_array($callback, array(1 => $items[$i]) + $params); - } - } elseif ($cnt === 1) { - while (($i = array_shift($keys)) !== null) { - $out[] = $callback($this, $items[$i]); - } - } elseif ($cnt === 2) { - while (($i = array_shift($keys)) !== null) { - $out[] = $callback($this, $items[$i], $params[2]); - } - } elseif ($cnt === 3) { - while (($i = array_shift($keys)) !== null) { - $out[] = $callback($this, $items[$i], $params[2], $params[3]); - } - } else { - while (($i = array_shift($keys)) !== null) { - $out[] = call_user_func_array($callback, array(1 => $items[$i]) + $params); - } - } - } else { - $items = $params[0]; - $keys = array_keys($items); - - if (is_string($callback) === false) { - while (($i = array_shift($keys)) !== null) { - $out[] = call_user_func_array($callback, array($items[$i]) + $params); - } - } elseif ($cnt === 1) { - while (($i = array_shift($keys)) !== null) { - $out[] = $callback($items[$i]); - } - } elseif ($cnt === 2) { - while (($i = array_shift($keys)) !== null) { - $out[] = $callback($items[$i], $params[1]); - } - } elseif ($cnt === 3) { - while (($i = array_shift($keys)) !== null) { - $out[] = $callback($items[$i], $params[1], $params[2]); - } - } elseif ($cnt === 4) { - while (($i = array_shift($keys)) !== null) { - $out[] = $callback($items[$i], $params[1], $params[2], $params[3]); - } - } else { - while (($i = array_shift($keys)) !== null) { - $out[] = call_user_func_array($callback, array($items[$i]) + $params); - } - } - } - - return $out; - } else { - return $params[0]; - } - } - - /** - * Reads a variable into the given data array. - * - * @param string $varstr the variable string, using dwoo variable syntax (i.e. "var.subvar[subsubvar]->property") - * @param mixed $data the data array or object to read from - * @param bool $safeRead if true, the function will check whether the index exists to prevent any notices from - * being output - * - * @return mixed - */ - public function readVarInto($varstr, $data, $safeRead = false) - { - if ($data === null) { - return null; - } - - if (is_array($varstr) === false) { - preg_match_all('#(\[|->|\.)?((?:[^.[\]-]|-(?!>))+)\]?#i', $varstr, $m); - } else { - $m = $varstr; - } - unset($varstr); - - foreach ($m[1] as $k => $sep) { - if ($sep === '.' || $sep === '[' || $sep === '') { - // strip enclosing quotes if present - $m[2][$k] = preg_replace('#^(["\']?)(.*?)\1$#', '$2', $m[2][$k]); - - if ((is_array($data) || $data instanceof ArrayAccess) && ($safeRead === false || isset($data[$m[2][$k]]))) { - $data = $data[$m[2][$k]]; - } else { - return null; - } - } else { - if (is_object($data) && ($safeRead === false || isset($data->{$m[2][$k]}))) { - $data = $data->{$m[2][$k]}; - } else { - return null; - } - } - } - - return $data; - } - - /** - * Reads a variable into the parent scope. - * - * @param int $parentLevels the amount of parent levels to go from the current scope - * @param string $varstr the variable string, using dwoo variable syntax (i.e. - * "var.subvar[subsubvar]->property") - * - * @return mixed - */ - public function readParentVar($parentLevels, $varstr = null) - { - $tree = $this->scopeTree; - $cur = $this->data; - - while ($parentLevels -- !== 0) { - array_pop($tree); - } - - while (($i = array_shift($tree)) !== null) { - if (is_object($cur)) { - $cur = $cur->{$i}; - } else { - $cur = $cur[$i]; - } - } - - if ($varstr !== null) { - return $this->readVarInto($varstr, $cur); - } else { - return $cur; - } - } - - /** - * Reads a variable into the current scope. - * - * @param string $varstr the variable string, using dwoo variable syntax (i.e. "var.subvar[subsubvar]->property") - * - * @return mixed - */ - public function readVar($varstr) - { - if (is_array($varstr) === true) { - $m = $varstr; - unset($varstr); - } else { - if (strstr($varstr, '.') === false && strstr($varstr, '[') === false && strstr($varstr, '->') === false) { - if ($varstr === 'dwoo') { - return $this->getGlobals(); - } elseif ($varstr === '__' || $varstr === '_root') { - return $this->data; - } elseif ($varstr === '_' || $varstr === '_parent') { - $varstr = '.' . $varstr; - $tree = $this->scopeTree; - $cur = $this->data; - array_pop($tree); - - while (($i = array_shift($tree)) !== null) { - if (is_object($cur)) { - $cur = $cur->{$i}; - } else { - $cur = $cur[$i]; - } - } - - return $cur; - } - - $cur = $this->scope; - - if (isset($cur[$varstr])) { - return $cur[$varstr]; - } else { - return null; - } - } - - if (substr($varstr, 0, 1) === '.') { - $varstr = 'dwoo' . $varstr; - } - - preg_match_all('#(\[|->|\.)?((?:[^.[\]-]|-(?!>))+)\]?#i', $varstr, $m); - } - - $i = $m[2][0]; - if ($i === 'dwoo') { - $cur = $this->getGlobals(); - array_shift($m[2]); - array_shift($m[1]); - switch ($m[2][0]) { - case 'get': - $cur = $_GET; - break; - case 'post': - $cur = $_POST; - break; - case 'session': - $cur = $_SESSION; - break; - case 'cookies': - case 'cookie': - $cur = $_COOKIE; - break; - case 'server': - $cur = $_SERVER; - break; - case 'env': - $cur = $_ENV; - break; - case 'request': - $cur = $_REQUEST; - break; - case 'const': - array_shift($m[2]); - if (defined($m[2][0])) { - return constant($m[2][0]); - } else { - return null; - } - } - if ($cur !== $this->getGlobals()) { - array_shift($m[2]); - array_shift($m[1]); - } - } elseif ($i === '__' || $i === '_root') { - $cur = $this->data; - array_shift($m[2]); - array_shift($m[1]); - } elseif ($i === '_' || $i === '_parent') { - $tree = $this->scopeTree; - $cur = $this->data; - - while (true) { - array_pop($tree); - array_shift($m[2]); - array_shift($m[1]); - if (current($m[2]) === '_' || current($m[2]) === '_parent') { - continue; - } - - while (($i = array_shift($tree)) !== null) { - if (is_object($cur)) { - $cur = $cur->{$i}; - } else { - $cur = $cur[$i]; - } - } - break; - } - } else { - $cur = $this->scope; - } - - foreach ($m[1] as $k => $sep) { - if ($sep === '.' || $sep === '[' || $sep === '') { - if ((is_array($cur) || $cur instanceof ArrayAccess) && isset($cur[$m[2][$k]])) { - $cur = $cur[$m[2][$k]]; - } else { - return null; - } - } elseif ($sep === '->') { - if (is_object($cur)) { - $cur = $cur->{$m[2][$k]}; - } else { - return null; - } - } else { - return null; - } - } - - return $cur; - } - - /** - * Assign the value to the given variable. - * - * @param mixed $value the value to assign - * @param string $scope the variable string, using dwoo variable syntax (i.e. "var.subvar[subsubvar]->property") - * - * @return bool true if assigned correctly or false if a problem occured while parsing the var string - */ - public function assignInScope($value, $scope) - { - if (!is_string($scope)) { - $this->triggerError('Assignments must be done into strings, (' . gettype($scope) . ') ' . var_export($scope, true) . ' given', E_USER_ERROR); - } - if (strstr($scope, '.') === false && strstr($scope, '->') === false) { - $this->scope[$scope] = $value; - } else { - // TODO handle _root/_parent scopes ? - preg_match_all('#(\[|->|\.)?([^.[\]-]+)\]?#i', $scope, $m); - - $cur = &$this->scope; - $last = array( - array_pop($m[1]), - array_pop($m[2]) - ); - - foreach ($m[1] as $k => $sep) { - if ($sep === '.' || $sep === '[' || $sep === '') { - if (is_array($cur) === false) { - $cur = array(); - } - $cur = &$cur[$m[2][$k]]; - } elseif ($sep === '->') { - if (is_object($cur) === false) { - $cur = new stdClass(); - } - $cur = &$cur->{$m[2][$k]}; - } else { - return false; - } - } - - if ($last[0] === '.' || $last[0] === '[' || $last[0] === '') { - if (is_array($cur) === false) { - $cur = array(); - } - $cur[$last[1]] = $value; - } elseif ($last[0] === '->') { - if (is_object($cur) === false) { - $cur = new stdClass(); - } - $cur->{$last[1]} = $value; - } else { - return false; - } - } - } - - /** - * Sets the scope to the given scope string or array. - * - * @param mixed $scope a string i.e. "level1.level2" or an array i.e. array("level1", "level2") - * @param bool $absolute if true, the scope is set from the top level scope and not from the current scope - * - * @return array the current scope tree - */ - public function setScope($scope, $absolute = false) - { - $old = $this->scopeTree; - - if (is_string($scope) === true) { - $scope = explode('.', $scope); - } - - if ($absolute === true) { - $this->scope = &$this->data; - $this->scopeTree = array(); - } - - while (($bit = array_shift($scope)) !== null) { - if ($bit === '_' || $bit === '_parent') { - array_pop($this->scopeTree); - $this->scope = &$this->data; - $cnt = count($this->scopeTree); - for ($i = 0; $i < $cnt; ++ $i) { - $this->scope = &$this->scope[$this->scopeTree[$i]]; - } - } elseif ($bit === '__' || $bit === '_root') { - $this->scope = &$this->data; - $this->scopeTree = array(); - } elseif (isset($this->scope[$bit])) { - if ($this->scope instanceof ArrayAccess) { - $tmp = $this->scope[$bit]; - $this->scope = &$tmp; - } else { - $this->scope = &$this->scope[$bit]; - } - $this->scopeTree[] = $bit; - } else { - unset($this->scope); - $this->scope = null; - } - } - - return $old; - } - - /** - * Returns the entire data array. - * - * @return array - */ - public function getData() - { - return $this->data; - } - - /** - * Sets a return value for the currently running template. - * - * @param string $name var name - * @param mixed $value var value - * - * @return void - */ - public function setReturnValue($name, $value) - { - $this->returnData[$name] = $value; - } - - /** - * Retrieves the return values set by the template. - * - * @return array - */ - public function getReturnValues() - { - return $this->returnData; - } - - /** - * Returns a reference to the current scope. - * - * @return mixed - */ - public function &getScope() - { - return $this->scope; - } - - /** - * Redirects all calls to unexisting to plugin proxy. - * - * @param string $method the method name - * @param array $args array of arguments - * - * @return mixed - * @throws Exception - */ - public function __call($method, $args) - { - $proxy = $this->getPluginProxy(); - if (!$proxy) { - throw new Exception('Call to undefined method ' . __CLASS__ . '::' . $method . '()'); - } - - return call_user_func_array($proxy->getCallback($method), $args); - } - - /** - * Convert plugin name from `auto_escape` to `AutoEscape`. - * @param string $input - * @param string $separator - * - * @return mixed - */ - public static function toCamelCase($input, $separator = '_') - { - return join(array_map('ucfirst', explode($separator, $input))); - - // TODO >= PHP5.4.32 - //return str_replace($separator, '', ucwords($input, $separator)); - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Data.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Data.php deleted file mode 100644 index 85226e7..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Data.php +++ /dev/null @@ -1,264 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2017 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.4 - * @date 2017-03-01 - * @link http://dwoo.org/ - */ - -namespace Dwoo; - -/** - * Dwoo data object, use it for complex data assignments or if you want to easily pass it - * around multiple functions to avoid passing an array by reference. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class Data implements IDataProvider -{ - /** - * Data array. - * - * @var array - */ - protected $data = array(); - - /** - * Returns the data array. - * - * @return array - */ - public function getData() - { - return $this->data; - } - - /** - * Clears a the entire data or only the given key. - * - * @param array|string $name clears only one value if you give a name, multiple values if - * you give an array of names, or the entire data if left null - */ - public function clear($name = null) - { - if ($name === null) { - $this->data = array(); - } elseif (is_array($name)) { - foreach ($name as $index) { - unset($this->data[$index]); - } - } else { - unset($this->data[$name]); - } - } - - /** - * Overwrites the entire data with the given array. - * - * @param array $data the new data array to use - */ - public function setData(array $data) - { - $this->data = $data; - } - - /** - * merges the given array(s) with the current data with array_merge. - * - * @param array $data the array to merge - */ - public function mergeData(array $data) - { - $args = func_get_args(); - foreach ($args as $key => $v) { - if (is_array($v)) { - $this->data = array_merge($this->data, $v); - } - } - } - - /** - * Assigns a value or an array of values to the data object. - * - * @param array|string $name an associative array of multiple (index=>value) or a string - * that is the index to use, i.e. a value assigned to "foo" will be - * accessible in the template through {$foo} - * @param mixed $val the value to assign, or null if $name was an array - */ - public function assign($name, $val = null) - { - if (is_array($name)) { - reset($name); - foreach ($name as $k => $v){ - $this->data[$k] = $v; - } - } else { - $this->data[$name] = $val; - } - } - - /** - * Allows to assign variables using the object syntax. - * - * @param string $name the variable name - * @param string $value the value to assign to it - */ - public function __set($name, $value) - { - $this->assign($name, $value); - } - - /** - * Assigns a value by reference to the data object. - * - * @param string $name the index to use, i.e. a value assigned to "foo" will be - * accessible in the template through {$foo} - * @param mixed $val the value to assign by reference - */ - public function assignByRef($name, &$val) - { - $this->data[$name] = &$val; - } - - /** - * Appends values or an array of values to the data object. - * - * @param array|string $name an associative array of multiple (index=>value) or a string - * that is the index to use, i.e. a value assigned to "foo" will be - * accessible in the template through {$foo} - * @param mixed $val the value to assign, or null if $name was an array - * @param bool $merge true to merge data or false to append, defaults to false - */ - public function append($name, $val = null, $merge = false) - { - if (is_array($name)) { - foreach ($name as $key => $val) { - if (isset($this->data[$key]) && !is_array($this->data[$key])) { - settype($this->data[$key], 'array'); - } - - if ($merge === true && is_array($val)) { - $this->data[$key] = $val + $this->data[$key]; - } else { - $this->data[$key][] = $val; - } - } - } elseif ($val !== null) { - if (isset($this->data[$name]) && !is_array($this->data[$name])) { - settype($this->data[$name], 'array'); - } elseif (!isset($this->data[$name])) { - $this->data[$name] = array(); - } - - if ($merge === true && is_array($val)) { - $this->data[$name] = $val + $this->data[$name]; - } else { - $this->data[$name][] = $val; - } - } - } - - /** - * Appends a value by reference to the data object. - * - * @param string $name the index to use, i.e. a value assigned to "foo" will be - * accessible in the template through {$foo} - * @param mixed $val the value to append by reference - * @param bool $merge true to merge data or false to append, defaults to false - */ - public function appendByRef($name, &$val, $merge = false) - { - if (isset($this->data[$name]) && !is_array($this->data[$name])) { - settype($this->data[$name], 'array'); - } - - if ($merge === true && is_array($val)) { - foreach ($val as $key => &$value) { - $this->data[$name][$key] = &$value; - } - } else { - $this->data[$name][] = &$val; - } - } - - /** - * Returns true if the variable has been assigned already, false otherwise. - * - * @param string $name the variable name - * - * @return bool - */ - public function isAssigned($name) - { - return isset($this->data[$name]); - } - - /** - * Supports calls to isset($dwoo->var). - * - * @param string $name the variable name - * - * @return bool - */ - public function __isset($name) - { - return isset($this->data[$name]); - } - - /** - * Unassigns/removes a variable. - * - * @param string $name the variable name - */ - public function unassign($name) - { - unset($this->data[$name]); - } - - /** - * Supports unsetting variables using the object syntax. - * - * @param string $name the variable name - */ - public function __unset($name) - { - unset($this->data[$name]); - } - - /** - * Returns a variable if it was assigned. - * - * @param string $name the variable name - * - * @return mixed - */ - public function get($name) - { - return $this->__get($name); - } - - /** - * Allows to read variables using the object syntax. - * - * @param string $name the variable name - * - * @return mixed - * @throws Exception - */ - public function __get($name) - { - if (isset($this->data[$name])) { - return $this->data[$name]; - } else { - throw new Exception('Tried to read a value that was not assigned yet : "' . $name . '"'); - } - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Exception.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Exception.php deleted file mode 100644 index f61795f..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Exception.php +++ /dev/null @@ -1,26 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo; - -/** - * Main dwoo exception class. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class Exception extends \Exception -{ -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Filter.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Filter.php deleted file mode 100644 index 5fdb4ed..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Filter.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo; - -/** - * Base class for filters. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -abstract class Filter -{ - /** - * The dwoo instance that runs this filter. - * - * @var Core - */ - protected $dwoo; - - /** - * Constructor, if you override it, call parent::__construct($dwoo); or assign - * the dwoo instance yourself if you need it. - * - * @param Core $dwoo the dwoo instance that runs this plugin - */ - public function __construct(Core $dwoo) - { - $this->dwoo = $dwoo; - } - - /** - * Processes the input and returns it filtered. - * - * @param string $input the template to process - * - * @return string - */ - abstract public function process($input); -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ICompilable.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ICompilable.php deleted file mode 100644 index 40e1155..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ICompilable.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-23 - * @link http://dwoo.org/ - */ - -namespace Dwoo; - -/** - * Interface that represents a compilable plugin. - * implement this to notify the compiler that this plugin does not need to be loaded at runtime. - * to implement it right, you must implement public static function compile(Compiler $compiler, $arg, $arg, - * ...), which replaces the process() method (that means compile() should have all arguments it - * requires). This software is provided 'as-is', without any express or implied warranty. In no event will the authors - * be held liable for any damages arising from the use of this software. - */ -interface ICompilable -{ - // this replaces the process function - //public static function compile(Compiler $compiler, $arg, $arg, ...); -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ICompilable/Block.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ICompilable/Block.php deleted file mode 100644 index 241db4e..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ICompilable/Block.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\ICompilable; - -/** - * Interface that represents a compilable block plugin. - * implement this to notify the compiler that this plugin does not need to be loaded at runtime. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -interface Block -{ -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ICompiler.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ICompiler.php deleted file mode 100644 index 619aaab..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ICompiler.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2017 David Sanchez - * @license http://dwoo.org/LICENSE LGPLv3 - * @version 1.3.6 - * @date 2017-03-21 - * @link http://dwoo.org/ - */ - -namespace Dwoo; - -use Dwoo\Security\Policy as SecurityPolicy; - -/** - * Interface that represents a dwoo compiler. - * while implementing this is enough to interact with Dwoo/Templates, it is not - * sufficient to interact with Dwoo/Plugins, however the main purpose of creating a - * new compiler would be to interact with other/different plugins, that is why this - * interface has been left with the minimum requirements. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -interface ICompiler -{ - /** - * Compiles the provided string down to php code. - * - * @param Core $core - * @param ITemplate $template the template to compile - * - * @return string a compiled php code string - */ - public function compile(Core $core, ITemplate $template); - - /** - * Adds the custom plugins loaded into Dwoo to the compiler so it can load them. - * - * @see Core::addPlugin - * - * @param array $customPlugins an array of custom plugins - */ - public function setCustomPlugins(array $customPlugins); - - /** - * Sets the security policy object to enforce some php security settings. - * use this if untrusted persons can modify templates, - * set it on the Dwoo object as it will be passed onto the compiler automatically - * - * @param SecurityPolicy $policy the security policy object - */ - public function setSecurityPolicy(SecurityPolicy $policy = null); -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/IDataProvider.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/IDataProvider.php deleted file mode 100644 index 9392b2d..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/IDataProvider.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-23 - * @link http://dwoo.org/ - */ - -namespace Dwoo; - -/** - * Interface that represents a dwoo data object. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -interface IDataProvider -{ - /** - * Returns the data as an associative array that will be used in the template. - * - * @return array - */ - public function getData(); -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/IElseable.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/IElseable.php deleted file mode 100644 index b8f3483..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/IElseable.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo; - -/** - * Interface that represents a block plugin that supports the else functionality. - * the else block will enter an "hasElse" parameter inside the parameters array - * of the closest parent implementing this interface, the hasElse parameter contains - * the else output that should be appended to the block's content (see foreach or other - * block for examples) - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -interface IElseable -{ -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ILoader.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ILoader.php deleted file mode 100644 index febf202..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ILoader.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-23 - * @link http://dwoo.org/ - */ - -namespace Dwoo; - -/** - * Interface for dwoo plugin loaders. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -interface ILoader -{ - /** - * Loads a plugin file. - * the second parameter is used to avoid permanent rehashing when using php functions, - * however this means that if you have add a plugin that overrides a php function you have - * to delete the classpath.cache file(s) by hand to force a rehash of the plugins - * - * @param string $class the plugin name, without the `Plugin` prefix - * @param bool $forceRehash if true, the class path caches will be rebuilt if the plugin is not found, in case it - * has just been added, defaults to true - */ - public function loadPlugin($class, $forceRehash = true); -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/IPluginProxy.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/IPluginProxy.php deleted file mode 100644 index d20f3f7..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/IPluginProxy.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-23 - * @link http://dwoo.org/ - */ - -namespace Dwoo; - -/** - * Interface that represents a dwoo plugin proxy. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -interface IPluginProxy -{ - /** - * Returns true or false to say whether the given plugin is handled by this proxy or not. - * - * @param string $name the plugin name - * - * @return bool true if the plugin is known and usable, otherwise false - */ - public function handles($name); - - /** - * Returns the code (as a string) to call the plugin - * (this will be executed at runtime inside the Dwoo class). - * - * @param string $name the plugin name - * @param array $params a parameter array, array key "*" is the rest array - * - * @return string - */ - public function getCode($name, $params); - - /** - * Returns a callback to the plugin, this is used with the reflection API to - * find out about the plugin's parameter names etc. - * should you need a rest array without the possibility to edit the - * plugin's code, you can provide a callback to some - * other function with the correct parameter signature, i.e. : - * - * return array($this, "callbackHelper"); - * // and callbackHelper would be as such: - * public function callbackHelper(array $rest=array()){} - * - * - * @param string $name the plugin name - * - * @return callback - */ - public function getCallback($name); - - /** - * Returns some code that will check if the plugin is loaded and if not load it - * this is optional, if your plugins are autoloaded or whatever, just return an - * empty string. - * - * @param string $name the plugin name - * - * @return string - */ - public function getLoader($name); -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ITemplate.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ITemplate.php deleted file mode 100644 index 6fa65f3..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/ITemplate.php +++ /dev/null @@ -1,161 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2017 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.4 - * @date 2017-03-07 - * @link http://dwoo.org/ - */ - -namespace Dwoo; - -/** - * Interface that represents a dwoo template. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -interface ITemplate -{ - /** - * Returns the cache duration for this template. - * defaults to null if it was not provided - * - * @return int|null - */ - public function getCacheTime(); - - /** - * Sets the cache duration for this template. - * can be used to set it after the object is created if you did not provide - * it in the constructor - * - * @param int $seconds duration of the cache validity for this template, if - * null it defaults to the Dwoo instance's cache time. 0 = disable and - * -1 = infinite cache - */ - public function setCacheTime($seconds = null); - - /** - * Returns the cached template output file name, true if it's cache-able but not cached - * or false if it's not cached. - * - * @param Core $core the dwoo instance that requests it - * - * @return string|bool - */ - public function getCachedTemplate(Core $core); - - /** - * Caches the provided output into the cache file. - * - * @param Core $core the dwoo instance that requests it - * @param string $output the template output - * - * @return mixed full path of the cached file or false upon failure - */ - public function cache(Core $core, $output); - - /** - * Clears the cached template if it's older than the given time. - * - * @param Core $core the dwoo instance that was used to cache that template - * @param int $olderThan minimum time (in seconds) required for the cache to be cleared - * - * @return bool true if the cache was not present or if it was deleted, false if it remains there - */ - public function clearCache(Core $core, $olderThan = - 1); - - /** - * Returns the compiled template file name. - * - * @param Core $core the dwoo instance that requests it - * @param ICompiler $compiler the compiler that must be used - * - * @return string - */ - public function getCompiledTemplate(Core $core, ICompiler $compiler = null); - - /** - * Returns the template name. - * - * @return string - */ - public function getName(); - - /** - * Returns the resource name for this template class. - * - * @return string - */ - public function getResourceName(); - - /** - * Returns the resource identifier for this template or false if it has no identifier. - * - * @return string|false - */ - public function getResourceIdentifier(); - - /** - * Returns the template source of this template. - * - * @return string - */ - public function getSource(); - - /** - * Returns an unique string identifying the current version of this template, - * for example a timestamp of the last modified date or a hash of the template source. - * - * @return string - */ - public function getUid(); - - /** - * Returns the compiler used by this template, if it was just compiled, or null. - * - * @return ICompiler - */ - public function getCompiler(); - - /** - * Returns some php code that will check if this template has been modified or not. - * if the function returns null, the template will be instanciated and then the Uid checked - * - * @return string - */ - public function getIsModifiedCode(); - - /** - * Returns a new template object from the given resource identifier, null if no include is - * possible (resource not found), or false if include is not permitted by this resource type. - * this method should also check if $dwoo->getSecurityPolicy() is null or not and do the - * necessary permission checks if required, if the security policy prevents the template - * generation it should throw a new Security\Exception with a relevant message - * - * @param Core $core - * @param mixed $resourceId the resource identifier - * @param int $cacheTime duration of the cache validity for this template, if null it defaults to the - * Dwoo instance that will render this template if null it defaults to the Dwoo - * instance that will render this template - * @param string $cacheId the unique cache identifier of this page or anything else that makes this - * template's content unique, if null it defaults to the current url makes this - * template's content unique, if null it defaults to the current url - * @param string $compileId the unique compiled identifier, which is used to distinguish this template from - * others, if null it defaults to the filename+bits of the path template from - * others, if null it defaults to the filename+bits of the path - * @param ITemplate $parentTemplate the template that is requesting a new template object (through an include, - * extends or any other plugin) an include, extends or any other plugin) - * - * @return ITemplate|false|null - */ - public static function templateFactory(Core $core, $resourceId, $cacheTime = null, $cacheId = null, - $compileId = null, ITemplate $parentTemplate = null); -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Loader.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Loader.php deleted file mode 100644 index 7dde76e..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Loader.php +++ /dev/null @@ -1,190 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2017 David Sanchez - * @license http://dwoo.org/LICENSE LGPLv3 - * @version 1.4.0 - * @date 2017-03-16 - * @link http://dwoo.org/ - */ - -namespace Dwoo; - -/** - * Handles plugin loading and caching of plugins names/paths relationships. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class Loader implements ILoader -{ - /** - * Stores the plugin directories. - * - * @see addDirectory - * @var array - */ - protected $paths = array(); - - /** - * Stores the plugins names/paths relationships - * don't edit this on your own, use addDirectory. - * - * @see addDirectory - * @var array - */ - protected $classPath = array(); - - /** - * Path where class paths cache files are written. - * - * @var string - */ - protected $cacheDir; - - /** - * Path where builtin plugins are stored. - * - * @var string - */ - protected $corePluginDir; - - /** - * Loader constructor. - * - * @param $cacheDir - */ - public function __construct($cacheDir) - { - $this->corePluginDir = __DIR__ . DIRECTORY_SEPARATOR . 'Plugins'; - $this->cacheDir = rtrim($cacheDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; - - // include class paths or rebuild paths if the cache file isn't there - $cacheFile = $this->cacheDir . 'classpath.cache.d' . Core::RELEASE_TAG . '.php'; - - $chachedClassPath = null; - - if (file_exists($cacheFile)) { - - $chachedClassPath = unserialize(file_get_contents($cacheFile)); - - if (is_array($chachedClassPath)) { - $this->classPath = $chachedClassPath + $this->classPath; - } - } - - if (!is_array($chachedClassPath)) { - $this->rebuildClassPathCache($this->corePluginDir, $cacheFile); - } - } - - /** - * Rebuilds class paths, scans the given directory recursively and saves all paths in the given file. - * - * @param string $path the plugin path to scan - * @param string|boolean $cacheFile the file where to store the plugin paths cache, it will be overwritten - * - * @throws Exception - */ - protected function rebuildClassPathCache($path, $cacheFile) - { - $tmp = array(); - if ($cacheFile !== false) { - $tmp = $this->classPath; - $this->classPath = array(); - } - - // iterates over all files/folders - foreach (new \DirectoryIterator($path) as $fileInfo) { - if (!$fileInfo->isDot()) { - if ($fileInfo->isDir()) { - $this->rebuildClassPathCache($fileInfo->getPathname(), false); - } else { - $this->classPath[$fileInfo->getBasename('.php')] = $fileInfo->getPathname(); - } - } - } - - // save in file if it's the first call (not recursed) - if ($cacheFile !== false) { - if (!file_put_contents($cacheFile, serialize($this->classPath), LOCK_EX)) { - throw new Exception('Could not write into ' . $cacheFile . ', either because the folder is not there (create it) or because of the chmod configuration (please ensure this directory is writable by php), alternatively you can change the directory used with $dwoo->setCompileDir() or provide a custom loader object with $dwoo->setLoader()'); - } - $this->classPath += $tmp; - } - } - - /** - * Loads a plugin file. - * - * @param string $class the plugin name, without the `Plugin` prefix - * @param bool $forceRehash if true, the class path caches will be rebuilt if the plugin is not found, in case it - * has just been added, defaults to true - * - * @throws Exception - */ - public function loadPlugin($class, $forceRehash = true) - { - /** - * An unknown class was requested (maybe newly added) or the - * include failed so we rebuild the cache. include() will fail - * with an uncatchable error if the file doesn't exist, which - * usually means that the cache is stale and must be rebuilt, - * so we check for that before trying to include() the plugin. - */ - if ((!isset($this->classPath[$class]) || !is_readable($this->classPath[$class])) || (!isset - ($this->classPath[$class . 'Compile']) || !is_readable($this->classPath[$class . 'Compile']))) { - if ($forceRehash) { - $this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir . 'classpath.cache.d' . - Core::RELEASE_TAG . '.php'); - foreach ($this->paths as $path => $file) { - $this->rebuildClassPathCache($path, $file); - } - if (isset($this->classPath[$class])) { - include_once $this->classPath[$class]; - } elseif (isset($this->classPath[$class . 'Compile'])) { - include_once $this->classPath[$class . 'Compile']; - } else { - throw new Exception('Plugin "' . $class . '" can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE); - } - } else { - throw new Exception('Plugin "' . $class . '" can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE); - } - } - } - - /** - * Adds a plugin directory, the plugins found in the new plugin directory - * will take precedence over the other directories (including the default - * dwoo plugin directory), you can use this for example to override plugins - * in a specific directory for a specific application while keeping all your - * usual plugins in the same place for all applications. - * TOCOM don't forget that php functions overrides are not rehashed so you - * need to clear the classpath caches by hand when adding those. - * - * @param string $pluginDirectory the plugin path to scan - * - * @throws Exception - */ - public function addDirectory($pluginDirectory) - { - $pluginDir = realpath($pluginDirectory); - if (!$pluginDir) { - throw new Exception('Plugin directory does not exist or can not be read : ' . $pluginDirectory); - } - $cacheFile = $this->cacheDir . 'classpath-' . substr(strtr($pluginDir, '/\\:' . PATH_SEPARATOR, '----'), - strlen($pluginDir) > 80 ? - 80 : 0) . '.d' . Core::RELEASE_TAG . '.php'; - $this->paths[$pluginDir] = $cacheFile; - if (file_exists($cacheFile)) { - $classpath = file_get_contents($cacheFile); - $this->classPath = unserialize($classpath) + $this->classPath; - } else { - $this->rebuildClassPathCache($pluginDir, $cacheFile); - } - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugin.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugin.php deleted file mode 100644 index c607806..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugin.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-23 - * @link http://dwoo.org/ - */ - -namespace Dwoo; - -/** - * Base plugin class. - * you have to implement the process() method, it will receive the parameters that - * are in the template code - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -abstract class Plugin -{ - /** - * The dwoo instance that runs this plugin. - * - * @var Core - */ - protected $core; - - /** - * Constructor, if you override it, call parent::__construct($core); or assign - * the dwoo instance yourself if you need it. - * - * @param Core $core the dwoo instance that runs this plugin - */ - public function __construct(Core $core) - { - $this->core = $core; - } - - // plugins should always implement : - // public function process($arg, $arg, ...) - // or for block plugins : - // public function init($arg, $arg, ...) - - // this could be enforced with : - // abstract public function process(...); - // if my feature request gets enough interest one day - // see => http://bugs.php.net/bug.php?id=44043 - - /** - * Utility function that converts an array of compiled parameters (or rest array) to a string of xml/html tag - * attributes. this is to be used in preProcessing or postProcessing functions, example : - * $p = $compiler->getCompiledParams($params); - * // get only the rest array as attributes - * $attributes = Plugin::paramsToAttributes($p['*']); - * // get all the parameters as attributes (if there is a rest array, it will be included) - * $attributes = Plugin::paramsToAttributes($p); - * - * @param array $params an array of attributeName=>value items that will be compiled to be ready for inclusion in a php string - * inclusion in a php string - * @param string $delim the string delimiter you want to use (defaults to ') - * @param Compiler $compiler the compiler instance (optional for BC, but recommended to pass it for proper escaping behavior) - * escaping behavior) - * - * @return string - */ - public static function paramsToAttributes(array $params, $delim = '\'', Compiler $compiler = null) - { - if (isset($params['*'])) { - $params = array_merge($params, $params['*']); - unset($params['*']); - } - - $out = ''; - foreach ($params as $attr => $val) { - $out .= ' ' . $attr . '='; - if (trim($val, '"\'') == '' || $val == 'null') { - $out .= str_replace($delim, '\\' . $delim, '""'); - } elseif (substr($val, 0, 1) === $delim && substr($val, - 1) === $delim) { - $out .= str_replace($delim, '\\' . $delim, '"' . substr($val, 1, - 1) . '"'); - } else { - if (!$compiler) { - // disable double encoding since it can not be determined if it was encoded - $escapedVal = '.(is_string($tmp2=' . $val . ') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset, false) : $tmp2).'; - } elseif (!$compiler->getAutoEscape() || false === strpos($val, 'isset($this->scope')) { - // escape if auto escaping is disabled, or there was no variable in the string - $escapedVal = '.(is_string($tmp2=' . $val . ') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset) : $tmp2).'; - } else { - // print as is - $escapedVal = '.' . $val . '.'; - } - - $out .= str_replace($delim, '\\' . $delim, '"') . $delim . $escapedVal . $delim . str_replace($delim, '\\' . $delim, '"'); - } - } - - return ltrim($out); - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginA.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginA.php deleted file mode 100644 index 6210d84..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginA.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Compiler; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; - -/** - * Outputs a html <a> tag - *
- *  * href : the target URI where the link must point
- *  * rest : any other attributes you want to add to the tag can be added as named parameters
- * 
. - * Example : - * - * {* Create a simple link out of an url variable and add a special class attribute: *} - * {a $url class="external" /} - * {* Mark a link as active depending on some other variable : *} - * {a $link.url class=tif($link.active "active"); $link.title /} - * {* This is similar to: {$link.title} *} - * - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginA extends BlockPlugin implements ICompilableBlock -{ - /** - * @param $href - * @param array $rest - */ - public function init($href, array $rest = array()) - { - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - $p = $compiler->getCompiledParams($params); - - $out = Compiler::PHP_OPEN . 'echo \'\';' . Compiler::PHP_CLOSE; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - $p = $compiler->getCompiledParams($params); - - // no content was provided so use the url as display text - if ($content == '') { - // merge into the href if href is a string - if (substr($p['href'], - 1) === '"' || substr($p['href'], - 1) === '\'') { - return Compiler::PHP_OPEN . 'echo ' . substr($p['href'], 0, - 1) . '' . substr($p['href'], - 1) . ';' . Compiler::PHP_CLOSE; - } - - // otherwise append - return Compiler::PHP_OPEN . 'echo ' . $p['href'] . '.\'\';' . Compiler::PHP_CLOSE; - } - - // return content - return $content . ''; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginAutoEscape.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginAutoEscape.php deleted file mode 100644 index 7b45ec9..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginAutoEscape.php +++ /dev/null @@ -1,98 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Compiler; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; -use Dwoo\Compilation\Exception as CompilationException; - -/** - * Overrides the compiler auto-escape setting within the block - *
- *  * enabled : if set to "on", "enable", true or 1 then the compiler autoescaping is enabled inside this block. set to
- *  "off", "disable", false or 0 to disable it
- * 
- * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginAutoEscape extends BlockPlugin implements ICompilableBlock -{ - protected static $stack = array(); - - /** - * @param $enabled - */ - public function init($enabled) - { - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - * @throws CompilationException - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - $params = $compiler->getCompiledParams($params); - switch (strtolower(trim((string)$params['enabled'], '"\''))) { - - case 'on': - case 'true': - case 'enabled': - case 'enable': - case '1': - $enable = true; - break; - case 'off': - case 'false': - case 'disabled': - case 'disable': - case '0': - $enable = false; - break; - default: - throw new CompilationException($compiler, 'Auto_Escape : Invalid parameter (' . $params['enabled'] . '), valid parameters are "enable"/true or "disable"/false'); - } - - self::$stack[] = $compiler->getAutoEscape(); - $compiler->setAutoEscape($enable); - - return ''; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - $compiler->setAutoEscape(array_pop(self::$stack)); - - return $content; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginBlock.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginBlock.php deleted file mode 100644 index 7e66182..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginBlock.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Compiler; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; - -/** - * This is used only when rendering a template that has blocks but is not extending anything, - * it doesn't do anything by itself and should not be used outside of template inheritance context, - * see {@link http://wiki.dwoo.org/index.php/TemplateInheritance} to read more about it. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginBlock extends BlockPlugin implements ICompilableBlock -{ - /** - * @param string $name - */ - public function init($name = '') - { - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - return ''; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - return $content; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginCapture.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginCapture.php deleted file mode 100644 index f8c9c03..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginCapture.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Compiler; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; - -/** - * Captures all the output within this block and saves it into {$.capture.default} by default, - * or {$.capture.name} if you provide another name. - *
- *  * name : capture name, used to read the value afterwards
- *  * assign : if set, the value is also saved in the given variable
- *  * cat : if true, the value is appended to the previous one (if any) instead of overwriting it
- * 
- * If the cat parameter is true, the content - * will be appended to the existing content. - * Example : - * - * {capture "foo"} - * Anything in here won't show, it will be saved for later use.. - * {/capture} - * Output was : {$.capture.foo} - * - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginCapture extends BlockPlugin implements ICompilableBlock -{ - /** - * @param string $name - * @param null $assign - * @param bool $cat - * @param bool $trim - */ - public function init($name = 'default', $assign = null, $cat = false, $trim = false) - { - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - return Compiler::PHP_OPEN . $prepend . 'ob_start();' . $append . Compiler::PHP_CLOSE; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - $params = $compiler->getCompiledParams($params); - - $out = $content . Compiler::PHP_OPEN . $prepend . "\n" . '$tmp = ob_get_clean();'; - if ($params['trim'] !== 'false' && $params['trim'] !== 0) { - $out .= "\n" . '$tmp = trim($tmp);'; - } - if ($params['cat'] === 'true' || $params['cat'] === 1) { - $out .= "\n" . '$tmp = $this->readVar(\'dwoo.capture.\'.' . $params['name'] . ') . $tmp;'; - } - if ($params['assign'] !== 'null') { - $out .= "\n" . '$this->scope[' . $params['assign'] . '] = $tmp;'; - } - - return $out . "\n" . '$this->globals[\'capture\'][' . $params['name'] . '] = $tmp;' . $append . Compiler::PHP_CLOSE; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginDynamic.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginDynamic.php deleted file mode 100644 index 3b1f61a..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginDynamic.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Compiler; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; -use Dwoo\Compilation\Exception as CompilationException; - -/** - * Marks the contents of the block as dynamic. Which means that it will not be cached. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginDynamic extends BlockPlugin implements ICompilableBlock -{ - /** - * - */ - public function init() - { - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - return ''; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - try { - $compiler->findBlock('dynamic'); - - return $content; - } - catch (CompilationException $e) { - } - $output = Compiler::PHP_OPEN . 'if($doCache) {' . "\n\t" . 'echo \'' . str_replace('\'', '\\\'', $content) . '\';' . "\n} else {\n\t"; - if (substr($content, 0, strlen(Compiler::PHP_OPEN)) == Compiler::PHP_OPEN) { - $output .= substr($content, strlen(Compiler::PHP_OPEN)); - } else { - $output .= Compiler::PHP_CLOSE . $content; - } - if (substr($output, - strlen(Compiler::PHP_CLOSE)) == Compiler::PHP_CLOSE) { - $output = substr($output, 0, - strlen(Compiler::PHP_CLOSE)); - } else { - $output .= Compiler::PHP_OPEN; - } - $output .= "\n}" . Compiler::PHP_CLOSE; - - return $output; - } - - /** - * @param $output - * @param $dynamicId - * @param $compiledFile - * - * @return mixed|string - */ - public static function unescape($output, $dynamicId, $compiledFile) - { - $output = preg_replace_callback('/(.+?)<\/dwoo:dynamic_' . $dynamicId . '>/s', array( - 'self', - 'unescapePhp' - ), $output, - 1, $count); - // re-add the includes on top of the file - if ($count && preg_match('#/\* template head \*/(.+?)/\* end template head \*/#s', file_get_contents($compiledFile), $m)) { - $output = '' . $output; - } - - return $output; - } - - /** - * @param $match - * - * @return mixed - */ - public static function unescapePhp($match) - { - return preg_replace('{<\?php /\*' . $match[1] . '\*/ echo \'(.+?)\'; \?>}s', '$1', $match[2]); - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginElse.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginElse.php deleted file mode 100644 index 14143a2..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginElse.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Compiler; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; -use Dwoo\Compilation\Exception as CompilationException; - -/** - * Generic else block, it supports all builtin optional-display blocks which are if/for/foreach/loop/with. - * If any of those block contains an else statement, the content between {else} and {/block} (you do not - * need to close the else block) will be shown if the block's condition has no been met - * Example : - * - * {foreach $array val} - * $array is not empty so we display it's values : {$val} - * {else} - * if this shows, it means that $array is empty or doesn't exist. - * {/foreach} - * - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginElse extends BlockPlugin implements ICompilableBlock -{ - public function init() - { - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - * @throws CompilationException - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - $preContent = ''; - while (true) { - $preContent .= $compiler->removeTopBlock(); - $block = &$compiler->getCurrentBlock(); - if (!$block) { - throw new CompilationException($compiler, 'An else block was found but it was not preceded by an if or other else-able construct'); - } - $interfaces = class_implements($block['class']); - if (in_array('Dwoo\IElseable', $interfaces) !== false) { - break; - } - } - - $params['initialized'] = true; - $compiler->injectBlock($type, $params); - - return $preContent; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - if (!isset($params['initialized'])) { - return ''; - } - - $block = &$compiler->getCurrentBlock(); - $block['params']['hasElse'] = Compiler::PHP_OPEN . "else {\n" . Compiler::PHP_CLOSE . $content . Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE; - - return ''; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginElseif.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginElseif.php deleted file mode 100644 index 033aa59..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginElseif.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Compiler; -use Dwoo\IElseable; -use Dwoo\ICompilable\Block as ICompilableBlock; - -/** - * Acts as a php elseif block, allowing you to add one more condition - * if the previous one(s) didn't match. See the {if} plugin for syntax details. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginElseif extends PluginIf implements ICompilableBlock, IElseable -{ - /** - * @param array $rest - */ - public function init(array $rest) - { - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - $preContent = ''; - while (true) { - $preContent .= $compiler->removeTopBlock(); - $block = &$compiler->getCurrentBlock(); - $interfaces = class_implements($block['class']); - if (in_array('Dwoo\IElseable', $interfaces) !== false) { - break; - } - } - - $params['initialized'] = true; - $compiler->injectBlock($type, $params); - - return $preContent; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - if (!isset($params['initialized'])) { - return ''; - } - - $tokens = $compiler->getParamTokens($params); - $params = $compiler->getCompiledParams($params); - - $pre = Compiler::PHP_OPEN . 'elseif (' . implode(' ', self::replaceKeywords($params['*'], $tokens['*'], $compiler)) . ") {\n" . Compiler::PHP_CLOSE; - $post = Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE; - - if (isset($params['hasElse'])) { - $post .= $params['hasElse']; - } - - $block = &$compiler->getCurrentBlock(); - $block['params']['hasElse'] = $pre . $content . $post; - - return ''; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginFor.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginFor.php deleted file mode 100644 index b696094..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginFor.php +++ /dev/null @@ -1,192 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Compiler; -use Dwoo\IElseable; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; - -/** - * Similar to the php for block - *
- *  * name : for name to access it's iterator variables through {$.for.name.var} see {@link
- *  http://wiki.dwoo.org/index.php/IteratorVariables} for details
- *  * from : array to iterate from (which equals 0) or a number as a start value
- *  * to : value to stop iterating at (equals count($array) by default if you set an array in from)
- *  * step : defines the incrementation of the pointer at each iteration
- * 
- * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginFor extends BlockPlugin implements ICompilableBlock, IElseable -{ - public static $cnt = 0; - - /** - * @param $name - * @param $from - * @param null $to - * @param int $step - * @param int $skip - */ - public function init($name, $from, $to = null, $step = 1, $skip = 0) - { - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - // get block params and save the current template pointer to use it in the postProcessing method - $currentBlock = &$compiler->getCurrentBlock(); - $currentBlock['params']['tplPointer'] = $compiler->getPointer(); - - return ''; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - $params = $compiler->getCompiledParams($params); - $tpl = $compiler->getTemplateSource($params['tplPointer']); - - // assigns params - $from = $params['from']; - $name = $params['name']; - $step = $params['step']; - $to = $params['to']; - - // evaluates which global variables have to be computed - $varName = '$dwoo.for.' . trim($name, '"\'') . '.'; - $shortVarName = '$.for.' . trim($name, '"\'') . '.'; - $usesAny = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false; - $usesFirst = strpos($tpl, $varName . 'first') !== false || strpos($tpl, $shortVarName . 'first') !== false; - $usesLast = strpos($tpl, $varName . 'last') !== false || strpos($tpl, $shortVarName . 'last') !== false; - $usesIndex = strpos($tpl, $varName . 'index') !== false || strpos($tpl, $shortVarName . 'index') !== false; - $usesIteration = $usesFirst || $usesLast || strpos($tpl, $varName . 'iteration') !== false || strpos($tpl, $shortVarName . 'iteration') !== false; - $usesShow = strpos($tpl, $varName . 'show') !== false || strpos($tpl, $shortVarName . 'show') !== false; - $usesTotal = $usesLast || strpos($tpl, $varName . 'total') !== false || strpos($tpl, $shortVarName . 'total') !== false; - - if (strpos($name, '$this->scope[') !== false) { - $usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true; - } - - // gets foreach id - $cnt = self::$cnt ++; - - // builds pre processing output for - $out = Compiler::PHP_OPEN . "\n" . '$_for' . $cnt . '_from = ' . $from . ';' . "\n" . '$_for' . $cnt . '_to = ' . $to . ';' . "\n" . '$_for' . $cnt . '_step = abs(' . $step . ');' . "\n" . 'if (is_numeric($_for' . $cnt . '_from) && !is_numeric($_for' . $cnt . '_to)) { $this->triggerError(\'For requires the to parameter when using a numerical from\'); }' . "\n" . '$tmp_shows = $this->isArray($_for' . $cnt . '_from, true) || (is_numeric($_for' . $cnt . '_from) && (abs(($_for' . $cnt . '_from - $_for' . $cnt . '_to)/$_for' . $cnt . '_step) !== 0 || $_for' . $cnt . '_from == $_for' . $cnt . '_to));'; - // adds for properties - if ($usesAny) { - $out .= "\n" . '$this->globals["for"][' . $name . '] = array' . "\n("; - if ($usesIndex) { - $out .= "\n\t" . '"index" => 0,'; - } - if ($usesIteration) { - $out .= "\n\t" . '"iteration" => 1,'; - } - if ($usesFirst) { - $out .= "\n\t" . '"first" => null,'; - } - if ($usesLast) { - $out .= "\n\t" . '"last" => null,'; - } - if ($usesShow) { - $out .= "\n\t" . '"show" => $tmp_shows,'; - } - if ($usesTotal) { - $out .= "\n\t" . '"total" => $this->isArray($_for' . $cnt . '_from) ? floor($this->count($_for' . $cnt . '_from) / $_for' . $cnt . '_step) : (is_numeric($_for' . $cnt . '_from) ? abs(($_for' . $cnt . '_to + 1 - $_for' . $cnt . '_from)/$_for' . $cnt . '_step) : 0),'; - } - $out .= "\n);\n" . '$_for' . $cnt . '_glob =& $this->globals["for"][' . $name . '];'; - } - // checks if for must be looped - $out .= "\n" . 'if ($tmp_shows)' . "\n{"; - // set from/to to correct values if an array was given - $out .= "\n\t" . 'if ($this->isArray($_for' . $cnt . '_from' . (isset($params['hasElse']) ? ', true' : '') . ') == true) { - $_for' . $cnt . '_to = is_numeric($_for' . $cnt . '_to) ? $_for' . $cnt . '_to - $_for' . $cnt . '_step : $this->count($_for' . $cnt . '_from) - 1; - $_for' . $cnt . '_from = 0; - }'; - - // if input are pure numbers it shouldn't reorder them, if it's variables it gets too messy though so in that case a counter should be used - $reverse = false; - $condition = '<='; - $incrementer = '+'; - - if (preg_match('{^(["\']?)([0-9]+)\1$}', $from, $mN1) && preg_match('{^(["\']?)([0-9]+)\1$}', $to, $mN2)) { - $from = (int)$mN1[2]; - $to = (int)$mN2[2]; - if ($from > $to) { - $reverse = true; - $condition = '>='; - $incrementer = '-'; - } - } - - // reverse from and to if needed - if (!$reverse) { - $out .= "\n\t" . 'if ($_for' . $cnt . '_from > $_for' . $cnt . '_to) { - $tmp = $_for' . $cnt . '_from; - $_for' . $cnt . '_from = $_for' . $cnt . '_to; - $_for' . $cnt . '_to = $tmp; - }'; - } - - $out .= "\n\t" . 'for ($this->scope[' . $name . '] = $_for' . $cnt . '_from; $this->scope[' . $name . '] ' . $condition . ' $_for' . $cnt . '_to; $this->scope[' . $name . '] ' . $incrementer . '= $_for' . $cnt . '_step)' . "\n\t{"; - // updates properties - if ($usesIndex) { - $out .= "\n\t\t" . '$_for' . $cnt . '_glob["index"] = $this->scope[' . $name . '];'; - } - if ($usesFirst) { - $out .= "\n\t\t" . '$_for' . $cnt . '_glob["first"] = (string) ($_for' . $cnt . '_glob["iteration"] === 1);'; - } - if ($usesLast) { - $out .= "\n\t\t" . '$_for' . $cnt . '_glob["last"] = (string) ($_for' . $cnt . '_glob["iteration"] === $_for' . $cnt . '_glob["total"]);'; - } - $out .= "\n/* -- for start output */\n" . Compiler::PHP_CLOSE; - - // build post processing output and cache it - $postOut = Compiler::PHP_OPEN . '/* -- for end output */'; - // update properties - if ($usesIteration) { - $postOut .= "\n\t\t" . '$_for' . $cnt . '_glob["iteration"]+=1;'; - } - // end loop - $postOut .= "\n\t}\n}\n" . Compiler::PHP_CLOSE; - - if (isset($params['hasElse'])) { - $postOut .= $params['hasElse']; - } - - return $out . $content . $postOut; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginForeach.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginForeach.php deleted file mode 100644 index 3817d7f..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginForeach.php +++ /dev/null @@ -1,201 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Compiler; -use Dwoo\IElseable; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; -use Dwoo\Compilation\Exception as CompilationException; - -/** - * Similar to the php foreach block, loops over an array. - * Note that if you don't provide the item parameter, the key will act as item - *
- *  * from : the array that you want to iterate over
- *  * key : variable name for the key (or for the item if item is not defined)
- *  * item : variable name for each item
- *  * name : foreach name to access it's iterator variables through {$.foreach.name.var} see {@link
- *  http://wiki.dwoo.org/index.php/IteratorVariables} for details
- * 
- * Example : - * - * {foreach $array val} - * {$val.something} - * {/foreach} - * - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginForeach extends BlockPlugin implements ICompilableBlock, IElseable -{ - public static $cnt = 0; - - /** - * @param $from - * @param null $key - * @param null $item - * @param string $name - * @param null $implode - */ - public function init($from, $key = null, $item = null, $name = 'default', $implode = null) - { - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - // get block params and save the current template pointer to use it in the postProcessing method - $currentBlock = &$compiler->getCurrentBlock(); - $currentBlock['params']['tplPointer'] = $compiler->getPointer(); - - return ''; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string - * @throws CompilationException - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - $params = $compiler->getCompiledParams($params); - $tpl = $compiler->getTemplateSource($params['tplPointer']); - - // assigns params - $src = $params['from']; - - if ($params['item'] !== 'null') { - if ($params['key'] !== 'null') { - $key = $params['key']; - } - $val = $params['item']; - } elseif ($params['key'] !== 'null') { - $val = $params['key']; - } else { - throw new CompilationException($compiler, 'Foreach item parameter missing'); - } - $name = $params['name']; - - if (substr($val, 0, 1) !== '"' && substr($val, 0, 1) !== '\'') { - throw new CompilationException($compiler, 'Foreach item parameter must be of type string'); - } - if (isset($key) && substr($val, 0, 1) !== '"' && substr($val, 0, 1) !== '\'') { - throw new CompilationException($compiler, 'Foreach key parameter must be of type string'); - } - - // evaluates which global variables have to be computed - $varName = '$dwoo.foreach.' . trim($name, '"\'') . '.'; - $shortVarName = '$.foreach.' . trim($name, '"\'') . '.'; - $usesAny = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false; - $usesFirst = strpos($tpl, $varName . 'first') !== false || strpos($tpl, $shortVarName . 'first') !== false; - $usesLast = strpos($tpl, $varName . 'last') !== false || strpos($tpl, $shortVarName . 'last') !== false; - $usesIndex = $usesFirst || strpos($tpl, $varName . 'index') !== false || strpos($tpl, $shortVarName . 'index') !== false; - $usesIteration = $usesLast || strpos($tpl, $varName . 'iteration') !== false || strpos($tpl, $shortVarName . 'iteration') !== false; - $usesShow = strpos($tpl, $varName . 'show') !== false || strpos($tpl, $shortVarName . 'show') !== false; - $usesTotal = $usesLast || strpos($tpl, $varName . 'total') !== false || strpos($tpl, $shortVarName . 'total') !== false; - - if (strpos($name, '$this->scope[') !== false) { - $usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true; - } - - // override globals vars if implode is used - if ($params['implode'] !== 'null') { - $implode = $params['implode']; - $usesAny = true; - $usesLast = true; - $usesIteration = true; - $usesTotal = true; - } - - // gets foreach id - $cnt = self::$cnt ++; - - // build pre content output - $pre = Compiler::PHP_OPEN . "\n" . '$_fh' . $cnt . '_data = ' . $src . ';'; - // adds foreach properties - if ($usesAny) { - $pre .= "\n" . '$this->globals["foreach"][' . $name . '] = array' . "\n("; - if ($usesIndex) { - $pre .= "\n\t" . '"index" => 0,'; - } - if ($usesIteration) { - $pre .= "\n\t" . '"iteration" => 1,'; - } - if ($usesFirst) { - $pre .= "\n\t" . '"first" => null,'; - } - if ($usesLast) { - $pre .= "\n\t" . '"last" => null,'; - } - if ($usesShow) { - $pre .= "\n\t" . '"show" => $this->isArray($_fh' . $cnt . '_data, true),'; - } - if ($usesTotal) { - $pre .= "\n\t" . '"total" => $this->count($_fh' . $cnt . '_data),'; - } - $pre .= "\n);\n" . '$_fh' . $cnt . '_glob =& $this->globals["foreach"][' . $name . '];'; - } - // checks if foreach must be looped - $pre .= "\n" . 'if ($this->isTraversable($_fh' . $cnt . '_data' . (isset($params['hasElse']) ? ', true' : '') . ') == true)' . "\n{"; - // iterates over keys - $pre .= "\n\t" . 'foreach ($_fh' . $cnt . '_data as ' . (isset($key) ? '$this->scope[' . $key . ']=>' : '') . '$this->scope[' . $val . '])' . "\n\t{"; - // updates properties - if ($usesFirst) { - $pre .= "\n\t\t" . '$_fh' . $cnt . '_glob["first"] = (string) ($_fh' . $cnt . '_glob["index"] === 0);'; - } - if ($usesLast) { - $pre .= "\n\t\t" . '$_fh' . $cnt . '_glob["last"] = (string) ($_fh' . $cnt . '_glob["iteration"] === $_fh' . $cnt . '_glob["total"]);'; - } - $pre .= "\n/* -- foreach start output */\n" . Compiler::PHP_CLOSE; - - // build post content output - $post = Compiler::PHP_OPEN . "\n"; - - if (isset($implode)) { - $post .= '/* -- implode */' . "\n" . 'if (!$_fh' . $cnt . '_glob["last"]) {' . "\n\t" . 'echo ' . $implode . ";\n}\n"; - } - $post .= '/* -- foreach end output */'; - // update properties - if ($usesIndex) { - $post .= "\n\t\t" . '$_fh' . $cnt . '_glob["index"]+=1;'; - } - if ($usesIteration) { - $post .= "\n\t\t" . '$_fh' . $cnt . '_glob["iteration"]+=1;'; - } - // end loop - $post .= "\n\t}\n}" . Compiler::PHP_CLOSE; - if (isset($params['hasElse'])) { - $post .= $params['hasElse']; - } - - return $pre . $content . $post; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginForeachelse.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginForeachelse.php deleted file mode 100644 index 5a09327..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginForeachelse.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Compiler; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; - -/** - * This plugin serves as a {else} block specifically for the {foreach} plugin. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginForeachelse extends BlockPlugin implements ICompilableBlock -{ - public function init() - { - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - $with = &$compiler->findBlock('foreach', true); - - $params['initialized'] = true; - $compiler->injectBlock($type, $params); - - return ''; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - if (!isset($params['initialized'])) { - return ''; - } - - $block = &$compiler->getCurrentBlock(); - $block['params']['hasElse'] = Compiler::PHP_OPEN . "else {\n" . Compiler::PHP_CLOSE . $content . Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE; - - return ''; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginForelse.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginForelse.php deleted file mode 100644 index 4d4a588..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginForelse.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Compiler; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; - -/** - * This plugin serves as a {else} block specifically for the {for} plugin. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginForelse extends BlockPlugin implements ICompilableBlock -{ - public function init() - { - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - $with = &$compiler->findBlock('for', true); - - $params['initialized'] = true; - $compiler->injectBlock($type, $params); - - return ''; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - if (!isset($params['initialized'])) { - return ''; - } - - $block = &$compiler->getCurrentBlock(); - $block['params']['hasElse'] = Compiler::PHP_OPEN . "else {\n" . Compiler::PHP_CLOSE . $content . Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE; - - return ''; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginIf.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginIf.php deleted file mode 100644 index d982327..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginIf.php +++ /dev/null @@ -1,274 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Compiler; -use Dwoo\IElseable; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; -use Dwoo\Compilation\Exception as CompilationException; - -/** - * Conditional block, the syntax is very similar to the php one, allowing () || && and - * other php operators. Additional operators and their equivalent php syntax are as follow :. - * eq -> == - * neq or ne -> != - * gte or ge -> >= - * lte or le -> <= - * gt -> > - * lt -> < - * mod -> % - * not -> ! - * X is [not] div by Y -> (X % Y) == 0 - * X is [not] even [by Y] -> (X % 2) == 0 or ((X/Y) % 2) == 0 - * X is [not] odd [by Y] -> (X % 2) != 0 or ((X/Y) % 2) != 0 - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginIf extends BlockPlugin implements ICompilableBlock, IElseable -{ - /** - * @param array $rest - */ - public function init(array $rest) - { - } - - /** - * @param array $params - * @param array $tokens - * @param Compiler $compiler - * - * @return array - * @throws CompilationException - */ - public static function replaceKeywords(array $params, array $tokens, Compiler $compiler) - { - $p = array(); - - reset($params); - while (list($k, $v) = each($params)) { - $v = (string)$v; - if (substr($v, 0, 1) === '"' || substr($v, 0, 1) === '\'') { - $vmod = strtolower(substr($v, 1, - 1)); - } else { - $vmod = strtolower($v); - } - switch ($vmod) { - - case 'and': - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { - $p[] = '&&'; - } else { - $p[] = $v; - } - break; - case 'or': - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { - $p[] = '||'; - } else { - $p[] = $v; - } - break; - case 'xor': - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { - $p[] = '^'; - } else { - $p[] = $v; - } - break; - case 'eq': - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { - $p[] = '=='; - } else { - $p[] = $v; - } - break; - case 'ne': - case 'neq': - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { - $p[] = '!='; - } else { - $p[] = $v; - } - break; - case 'gte': - case 'ge': - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { - $p[] = '>='; - } else { - $p[] = $v; - } - break; - case 'lte': - case 'le': - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { - $p[] = '<='; - } else { - $p[] = $v; - } - break; - case 'gt': - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { - $p[] = '>'; - } else { - $p[] = $v; - } - break; - case 'lt': - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { - $p[] = '<'; - } else { - $p[] = $v; - } - break; - case 'mod': - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { - $p[] = '%'; - } else { - $p[] = $v; - } - break; - case 'not': - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { - $p[] = '!'; - } else { - $p[] = $v; - } - break; - case '<>': - $p[] = '!='; - break; - case '==': - case '!=': - case '>=': - case '<=': - case '>': - case '<': - case '===': - case '!==': - case '%': - case '!': - case '^': - $p[] = $vmod; - break; - case 'is': - if ($tokens[$k] !== Compiler::T_UNQUOTED_STRING) { - $p[] = $v; - break; - } - if (isset($params[$k + 1]) && strtolower(trim($params[$k + 1], '"\'')) === 'not' && $tokens[$k + 1] === Compiler::T_UNQUOTED_STRING) { - $negate = true; - next($params); - } else { - $negate = false; - } - $ptr = 1 + (int)$negate; - if ($tokens[$k + $ptr] !== Compiler::T_UNQUOTED_STRING) { - break; - } - if (!isset($params[$k + $ptr])) { - $params[$k + $ptr] = ''; - } else { - $params[$k + $ptr] = trim($params[$k + $ptr], '"\''); - } - switch ($params[$k + $ptr]) { - - case 'div': - if (isset($params[$k + $ptr + 1]) && strtolower(trim($params[$k + $ptr + 1], '"\'')) === 'by') { - $p[] = ' % ' . $params[$k + $ptr + 2] . ' ' . ($negate ? '!' : '=') . '== 0'; - next($params); - next($params); - next($params); - } else { - throw new CompilationException($compiler, 'If : Syntax error : syntax should be "if $a is [not] div by $b", found ' . $params[$k - 1] . ' is ' . ($negate ? 'not ' : '') . 'div ' . $params[$k + $ptr + 1] . ' ' . $params[$k + $ptr + 2]); - } - break; - case 'even': - $a = array_pop($p); - if (isset($params[$k + $ptr + 1]) && strtolower(trim($params[$k + $ptr + 1], '"\'')) === 'by') { - $b = $params[$k + $ptr + 2]; - $p[] = '(' . $a . ' / ' . $b . ') % 2 ' . ($negate ? '!' : '=') . '== 0'; - next($params); - next($params); - } else { - $p[] = $a . ' % 2 ' . ($negate ? '!' : '=') . '== 0'; - } - next($params); - break; - case 'odd': - $a = array_pop($p); - if (isset($params[$k + $ptr + 1]) && strtolower(trim($params[$k + $ptr + 1], '"\'')) === 'by') { - $b = $params[$k + $ptr + 2]; - $p[] = '(' . $a . ' / ' . $b . ') % 2 ' . ($negate ? '=' : '!') . '== 0'; - next($params); - next($params); - } else { - $p[] = $a . ' % 2 ' . ($negate ? '=' : '!') . '== 0'; - } - next($params); - break; - default: - throw new CompilationException($compiler, 'If : Syntax error : syntax should be "if $a is [not] (div|even|odd) [by $b]", found ' . $params[$k - 1] . ' is ' . $params[$k + $ptr + 1]); - } - break; - default: - $p[] = $v; - } - } - - return $p; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - return ''; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - $tokens = $compiler->getParamTokens($params); - $params = $compiler->getCompiledParams($params); - $pre = Compiler::PHP_OPEN . 'if (' . implode(' ', self::replaceKeywords($params['*'], $tokens['*'], $compiler)) . ") {\n" . Compiler::PHP_CLOSE; - - $post = Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE; - - if (isset($params['hasElse'])) { - $post .= $params['hasElse']; - } - - return $pre . $content . $post; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginLoop.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginLoop.php deleted file mode 100644 index 5efbf43..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginLoop.php +++ /dev/null @@ -1,170 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Compiler; -use Dwoo\IElseable; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; - -/** - * Loops over an array and moves the scope into each value, allowing for shorter loop constructs. - * Note that to access the array key within a loop block, you have to use the {$_key} variable, - * you can not specify it yourself. - *
- *  * from : the array that you want to iterate over
- *  * name : loop name to access it's iterator variables through {$.loop.name.var} see {@link
- *  http://wiki.dwoo.org/index.php/IteratorVariables} for details
- * 
- * Example : - * instead of a foreach block such as : - * - * {foreach $variable value} - * {$value.foo} {$value.bar} - * {/foreach} - * - * you can do : - * - * {loop $variable} - * {$foo} {$bar} - * {/loop} - * - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginLoop extends BlockPlugin implements ICompilableBlock, IElseable -{ - public static $cnt = 0; - - /** - * @param $from - * @param string $name - */ - public function init($from, $name = 'default') - { - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - // get block params and save the current template pointer to use it in the postProcessing method - $currentBlock = &$compiler->getCurrentBlock(); - $currentBlock['params']['tplPointer'] = $compiler->getPointer(); - - return ''; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - $params = $compiler->getCompiledParams($params); - $tpl = $compiler->getTemplateSource($params['tplPointer']); - - // assigns params - $src = $params['from']; - $name = $params['name']; - - // evaluates which global variables have to be computed - $varName = '$dwoo.loop.' . trim($name, '"\'') . '.'; - $shortVarName = '$.loop.' . trim($name, '"\'') . '.'; - $usesAny = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false; - $usesFirst = strpos($tpl, $varName . 'first') !== false || strpos($tpl, $shortVarName . 'first') !== false; - $usesLast = strpos($tpl, $varName . 'last') !== false || strpos($tpl, $shortVarName . 'last') !== false; - $usesIndex = $usesFirst || strpos($tpl, $varName . 'index') !== false || strpos($tpl, $shortVarName . 'index') !== false; - $usesIteration = $usesLast || strpos($tpl, $varName . 'iteration') !== false || strpos($tpl, $shortVarName . 'iteration') !== false; - $usesShow = strpos($tpl, $varName . 'show') !== false || strpos($tpl, $shortVarName . 'show') !== false; - $usesTotal = $usesLast || strpos($tpl, $varName . 'total') !== false || strpos($tpl, $shortVarName . 'total') !== false; - - if (strpos($name, '$this->scope[') !== false) { - $usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true; - } - - // gets foreach id - $cnt = self::$cnt ++; - - // builds pre processing output - $pre = Compiler::PHP_OPEN . "\n" . '$_loop' . $cnt . '_data = ' . $src . ';'; - // adds foreach properties - if ($usesAny) { - $pre .= "\n" . '$this->globals["loop"][' . $name . '] = array' . "\n("; - if ($usesIndex) { - $pre .= "\n\t" . '"index" => 0,'; - } - if ($usesIteration) { - $pre .= "\n\t" . '"iteration" => 1,'; - } - if ($usesFirst) { - $pre .= "\n\t" . '"first" => null,'; - } - if ($usesLast) { - $pre .= "\n\t" . '"last" => null,'; - } - if ($usesShow) { - $pre .= "\n\t" . '"show" => $this->isTraversable($_loop' . $cnt . '_data, true),'; - } - if ($usesTotal) { - $pre .= "\n\t" . '"total" => $this->count($_loop' . $cnt . '_data),'; - } - $pre .= "\n);\n" . '$_loop' . $cnt . '_glob =& $this->globals["loop"][' . $name . '];'; - } - // checks if the loop must be looped - $pre .= "\n" . 'if ($this->isTraversable($_loop' . $cnt . '_data' . (isset($params['hasElse']) ? ', true' : '') . ') == true)' . "\n{"; - // iterates over keys - $pre .= "\n\t" . 'foreach ($_loop' . $cnt . '_data as $tmp_key => $this->scope["-loop-"])' . "\n\t{"; - // updates properties - if ($usesFirst) { - $pre .= "\n\t\t" . '$_loop' . $cnt . '_glob["first"] = (string) ($_loop' . $cnt . '_glob["index"] === 0);'; - } - if ($usesLast) { - $pre .= "\n\t\t" . '$_loop' . $cnt . '_glob["last"] = (string) ($_loop' . $cnt . '_glob["iteration"] === $_loop' . $cnt . '_glob["total"]);'; - } - $pre .= "\n\t\t" . '$_loop' . $cnt . '_scope = $this->setScope(array("-loop-"));' . "\n/* -- loop start output */\n" . Compiler::PHP_CLOSE; - - // build post processing output and cache it - $post = Compiler::PHP_OPEN . "\n" . '/* -- loop end output */' . "\n\t\t" . '$this->setScope($_loop' . $cnt . '_scope, true);'; - // update properties - if ($usesIndex) { - $post .= "\n\t\t" . '$_loop' . $cnt . '_glob["index"]+=1;'; - } - if ($usesIteration) { - $post .= "\n\t\t" . '$_loop' . $cnt . '_glob["iteration"]+=1;'; - } - // end loop - $post .= "\n\t}\n}\n" . Compiler::PHP_CLOSE; - if (isset($params['hasElse'])) { - $post .= $params['hasElse']; - } - - return $pre . $content . $post; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginSection.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginSection.php deleted file mode 100644 index 4f75b26..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginSection.php +++ /dev/null @@ -1,159 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Compiler; -use Dwoo\IElseable; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; - -/** - * Compatibility plugin for smarty templates, do not use otherwise, this is deprecated. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginSection extends BlockPlugin implements ICompilableBlock, IElseable -{ - public static $cnt = 0; - - /** - * @param $name - * @param $loop - * @param null $start - * @param null $step - * @param null $max - * @param bool $show - */ - public function init($name, $loop, $start = null, $step = null, $max = null, $show = true) - { - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - return ''; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - $output = Compiler::PHP_OPEN; - $params = $compiler->getCompiledParams($params); - - // assigns params - $loop = $params['loop']; - $start = $params['start']; - $max = $params['max']; - $name = $params['name']; - $step = $params['step']; - $show = $params['show']; - - // gets unique id - $cnt = self::$cnt ++; - - $output .= '$this->globals[\'section\'][' . $name . '] = array();' . "\n" . '$_section' . $cnt . ' =& $this->globals[\'section\'][' . $name . '];' . "\n"; - - if ($loop !== 'null') { - $output .= '$_section' . $cnt . '[\'loop\'] = is_array($tmp = ' . $loop . ') ? count($tmp) : max(0, (int) $tmp);' . "\n"; - } else { - $output .= '$_section' . $cnt . '[\'loop\'] = 1;' . "\n"; - } - - if ($show !== 'null') { - $output .= '$_section' . $cnt . '[\'show\'] = ' . $show . ";\n"; - } else { - $output .= '$_section' . $cnt . '[\'show\'] = true;' . "\n"; - } - - if ($name !== 'null') { - $output .= '$_section' . $cnt . '[\'name\'] = ' . $name . ";\n"; - } else { - $output .= '$_section' . $cnt . '[\'name\'] = true;' . "\n"; - } - - if ($max !== 'null') { - $output .= '$_section' . $cnt . '[\'max\'] = (int)' . $max . ";\n" . 'if($_section' . $cnt . '[\'max\'] < 0) { $_section' . $cnt . '[\'max\'] = $_section' . $cnt . '[\'loop\']; }' . "\n"; - } else { - $output .= '$_section' . $cnt . '[\'max\'] = $_section' . $cnt . '[\'loop\'];' . "\n"; - } - - if ($step !== 'null') { - $output .= '$_section' . $cnt . '[\'step\'] = (int)' . $step . ' == 0 ? 1 : (int) ' . $step . ";\n"; - } else { - $output .= '$_section' . $cnt . '[\'step\'] = 1;' . "\n"; - } - - if ($start !== 'null') { - $output .= '$_section' . $cnt . '[\'start\'] = (int)' . $start . ";\n"; - } else { - $output .= '$_section' . $cnt . '[\'start\'] = $_section' . $cnt . '[\'step\'] > 0 ? 0 : $_section' . $cnt . '[\'loop\'] - 1;' . "\n" . 'if ($_section' . $cnt . '[\'start\'] < 0) { $_section' . $cnt . '[\'start\'] = max($_section' . $cnt . '[\'step\'] > 0 ? 0 : -1, $_section' . $cnt . '[\'loop\'] + $_section' . $cnt . '[\'start\']); } ' . "\n" . 'else { $_section' . $cnt . '[\'start\'] = min($_section' . $cnt . '[\'start\'], $_section' . $cnt . '[\'step\'] > 0 ? $_section' . $cnt . '[\'loop\'] : $_section' . $cnt . '[\'loop\'] -1); }' . "\n"; - } - - /* if ($usesAny) { - $output .= "\n".'$this->globals["section"]['.$name.'] = array'."\n("; - if ($usesIndex) $output .="\n\t".'"index" => 0,'; - if ($usesIteration) $output .="\n\t".'"iteration" => 1,'; - if ($usesFirst) $output .="\n\t".'"first" => null,'; - if ($usesLast) $output .="\n\t".'"last" => null,'; - if ($usesShow) $output .="\n\t".'"show" => ($this->isArray($_for'.$cnt.'_from, true)) || (is_numeric($_for'.$cnt.'_from) && $_for'.$cnt.'_from != $_for'.$cnt.'_to),'; - if ($usesTotal) $output .="\n\t".'"total" => $this->isArray($_for'.$cnt.'_from) ? $this->count($_for'.$cnt.'_from) - $_for'.$cnt.'_skip : (is_numeric($_for'.$cnt.'_from) ? abs(($_for'.$cnt.'_to + 1 - $_for'.$cnt.'_from)/$_for'.$cnt.'_step) : 0),'; - $out.="\n);\n".'$_section'.$cnt.'[\'glob\'] =& $this->globals["section"]['.$name.'];'."\n\n"; - } - */ - - $output .= 'if ($_section' . $cnt . '[\'show\']) {' . "\n"; - if ($start === 'null' && $step === 'null' && $max === 'null') { - $output .= ' $_section' . $cnt . '[\'total\'] = $_section' . $cnt . '[\'loop\'];' . "\n"; - } else { - $output .= ' $_section' . $cnt . '[\'total\'] = min(ceil(($_section' . $cnt . '[\'step\'] > 0 ? $_section' . $cnt . '[\'loop\'] - $_section' . $cnt . '[\'start\'] : $_section' . $cnt . '[\'start\'] + 1) / abs($_section' . $cnt . '[\'step\'])), $_section' . $cnt . '[\'max\']);' . "\n"; - } - $output .= ' if ($_section' . $cnt . '[\'total\'] == 0) {' . "\n" . ' $_section' . $cnt . '[\'show\'] = false;' . "\n" . ' }' . "\n" . '} else {' . "\n" . ' $_section' . $cnt . '[\'total\'] = 0;' . "\n}\n"; - $output .= 'if ($_section' . $cnt . '[\'show\']) {' . "\n"; - $output .= "\t" . 'for ($this->scope[' . $name . '] = $_section' . $cnt . '[\'start\'], $_section' . $cnt . '[\'iteration\'] = 1; ' . '$_section' . $cnt . '[\'iteration\'] <= $_section' . $cnt . '[\'total\']; ' . '$this->scope[' . $name . '] += $_section' . $cnt . '[\'step\'], $_section' . $cnt . '[\'iteration\']++) {' . "\n"; - $output .= "\t\t" . '$_section' . $cnt . '[\'rownum\'] = $_section' . $cnt . '[\'iteration\'];' . "\n"; - $output .= "\t\t" . '$_section' . $cnt . '[\'index_prev\'] = $this->scope[' . $name . '] - $_section' . $cnt . '[\'step\'];' . "\n"; - $output .= "\t\t" . '$_section' . $cnt . '[\'index_next\'] = $this->scope[' . $name . '] + $_section' . $cnt . '[\'step\'];' . "\n"; - $output .= "\t\t" . '$_section' . $cnt . '[\'first\'] = ($_section' . $cnt . '[\'iteration\'] == 1);' . "\n"; - $output .= "\t\t" . '$_section' . $cnt . '[\'last\'] = ($_section' . $cnt . '[\'iteration\'] == $_section' . $cnt . '[\'total\']);' . "\n"; - - $output .= Compiler::PHP_CLOSE . $content . Compiler::PHP_OPEN; - - $output .= "\n\t}\n} " . Compiler::PHP_CLOSE; - - if (isset($params['hasElse'])) { - $output .= $params['hasElse']; - } - - return $output; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginSmartyinterface.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginSmartyinterface.php deleted file mode 100644 index 14211e1..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginSmartyinterface.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2017 David Sanchez - * @license http://dwoo.org/LICENSE LGPLv3 - * @version 1.3.6 - * @date 2017-03-21 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Core; -use Dwoo\Compiler; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; - -/** - * Smarty compatibility layer for block plugins, this is used internally and you should not call it. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginSmartyinterface extends BlockPlugin implements ICompilableBlock -{ - /** - * @param $__funcname - * @param $__functype - * @param array $rest - */ - public function init($__funcname, $__functype, array $rest = array()) - { - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - $params = $compiler->getCompiledParams($params); - $func = $params['__funcname']; - $pluginType = $params['__functype']; - $params = $params['*']; - - if ($pluginType & Core::CUSTOM_PLUGIN) { - $customPlugins = $compiler->getCore()->getCustomPlugins(); - $callback = $customPlugins[$func]['callback']; - if (is_array($callback)) { - if (is_object($callback[0])) { - $callback = '$this->customPlugins[\'' . $func . '\'][0]->' . $callback[1] . '('; - } else { - $callback = '' . $callback[0] . '::' . $callback[1] . '('; - } - } else { - $callback = $callback . '('; - } - } else { - $callback = 'smarty_block_' . $func . '('; - } - - $paramsOut = ''; - foreach ($params as $i => $p) { - $paramsOut .= var_export($i, true) . ' => ' . $p . ','; - } - - $curBlock = &$compiler->getCurrentBlock(); - $curBlock['params']['postOut'] = Compiler::PHP_OPEN . ' $_block_content = ob_get_clean(); $_block_repeat=false; echo ' . $callback . '$_tag_stack[count($_tag_stack)-1], $_block_content, $this, $_block_repeat); } array_pop($_tag_stack);' . Compiler::PHP_CLOSE; - - return Compiler::PHP_OPEN . $prepend . ' if (!isset($_tag_stack)){ $_tag_stack = array(); } $_tag_stack[] = array(' . $paramsOut . '); $_block_repeat=true; ' . $callback . '$_tag_stack[count($_tag_stack)-1], null, $this, $_block_repeat); while ($_block_repeat) { ob_start();' . Compiler::PHP_CLOSE; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - return $content . $params['postOut']; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginStrip.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginStrip.php deleted file mode 100644 index 5ee726d..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginStrip.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Compiler; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; - -/** - * Strips the spaces at the beginning and end of each line and also the line breaks - *
- *  * mode : sets the content being stripped, available mode are 'default' or 'js'
- *    for javascript, which strips the comments to prevent syntax errors
- * 
. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginStrip extends BlockPlugin implements ICompilableBlock -{ - /** - * @param string $mode - */ - public function init($mode = 'default') - { - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - return ''; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return mixed|string - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - $params = $compiler->getCompiledParams($params); - - $mode = trim($params['mode'], '"\''); - switch ($mode) { - case 'js': - case 'javascript': - $content = preg_replace('#(? - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-20 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Core; -use Dwoo\Compiler; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; -use Dwoo\Compilation\Exception as CompilationException; - -/** - * Defines a sub-template that can then be called (even recursively) with the defined arguments - *
- *  * name : template name
- *  * rest : list of arguments and optional default values
- * 
- * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginTemplate extends BlockPlugin implements ICompilableBlock -{ - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - * @throws CompilationException - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - $params = $compiler->getCompiledParams($params); - $parsedParams = array(); - if (!isset($params['*'])) { - $params['*'] = array(); - } - foreach ($params['*'] as $param => $defValue) { - if (is_numeric($param)) { - $param = $defValue; - $defValue = null; - } - $param = trim($param, '\'"'); - if (!preg_match('#^[a-z0-9_]+$#i', $param)) { - throw new CompilationException($compiler, 'Function : parameter names must contain only A-Z, 0-9 or _'); - } - $parsedParams[$param] = $defValue; - } - $params['name'] = substr($params['name'], 1, - 1); - $params['*'] = $parsedParams; - $params['uuid'] = uniqid(); - $compiler->addTemplatePlugin($params['name'], $parsedParams, $params['uuid']); - $currentBlock = &$compiler->getCurrentBlock(); - $currentBlock['params'] = $params; - - return ''; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string|void - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - $paramstr = 'Dwoo\Core $dwoo'; - $init = 'static $_callCnt = 0;' . "\n" . '$dwoo->scope[\' ' . $params['uuid'] . '\'.$_callCnt] = array();' . "\n" . '$_scope = $dwoo->setScope(array(\' ' . $params['uuid'] . '\'.($_callCnt++)));' . "\n"; - $cleanup = '/* -- template end output */ $dwoo->setScope($_scope, true);'; - foreach ($params['*'] as $param => $defValue) { - if ($defValue === null) { - $paramstr .= ', $' . $param; - } else { - $paramstr .= ', $' . $param . ' = ' . $defValue; - } - $init .= '$dwoo->scope[\'' . $param . '\'] = $' . $param . ";\n"; - } - $init .= '/* -- template start output */'; - - $funcName = 'Plugin' . Core::toCamelCase($params['name']) . Core::toCamelCase($params['uuid']); - - $search = array('$this->charset', '$this->', '$this,',); - $replacement = array('$dwoo->getCharset()', '$dwoo->', '$dwoo,',); - $content = str_replace($search, $replacement, $content); - - $body = 'if (!function_exists(\'' . $funcName . "')) {\nfunction " . $funcName . '(' . $paramstr . ') {' . "\n$init" . Compiler::PHP_CLOSE . $prepend . $content . $append . Compiler::PHP_OPEN . $cleanup . "\n}\n}"; - $compiler->addTemplatePlugin($params['name'], $params['*'], $params['uuid'], $body); - } - - /** - * @param $name - * @param array $rest - */ - public function init($name, array $rest = array()) - { - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginTextformat.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginTextformat.php deleted file mode 100644 index 09fc056..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginTextformat.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Block\Plugin as BlockPlugin; - -/** - * Formats a string to the given format, you can wrap lines at a certain - * length and indent them - *
- *  * wrap : maximum line length
- *  * wrap_char : the character(s) to use to break the line
- *  * wrap_cut : if true, the words that are longer than $wrap are cut instead of overflowing
- *  * indent : amount of $indent_char to insert before every line
- *  * indent_char : character(s) to insert before every line
- *  * indent_first : amount of additional $indent_char to insert before the first line of each paragraphs
- *  * style : some predefined formatting styles that set up every required variables, can be "email" or "html"
- *  * assign : if set, the formatted text is assigned to that variable instead of being output
- * 
- * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginTextformat extends BlockPlugin -{ - protected $wrap; - protected $wrapChar; - protected $wrapCut; - protected $indent; - protected $indChar; - protected $indFirst; - protected $assign; - - /** - * @param int $wrap - * @param string $wrap_char - * @param bool $wrap_cut - * @param int $indent - * @param string $indent_char - * @param int $indent_first - * @param string $style - * @param string $assign - */ - public function init($wrap = 80, $wrap_char = "\r\n", $wrap_cut = false, $indent = 0, $indent_char = ' ', $indent_first = 0, $style = '', $assign = '') - { - if ($indent_char === 'tab') { - $indent_char = "\t"; - } - - switch ($style) { - - case 'email': - $wrap = 72; - $indent_first = 0; - break; - case 'html': - $wrap_char = '
'; - $indent_char = $indent_char == "\t" ? '    ' : ' '; - break; - } - - $this->wrap = (int)$wrap; - $this->wrapChar = (string)$wrap_char; - $this->wrapCut = (bool)$wrap_cut; - $this->indent = (int)$indent; - $this->indChar = (string)$indent_char; - $this->indFirst = (int)$indent_first + $this->indent; - $this->assign = (string)$assign; - } - - /** - * @return string - */ - public function process() - { - // gets paragraphs - $pgs = explode("\n", str_replace(array( - "\r\n", - "\r" - ), "\n", $this->buffer)); - - while (list($i) = each($pgs)) { - if (empty($pgs[$i])) { - continue; - } - - // removes line breaks and extensive white space - $pgs[$i] = preg_replace(array( - '#\s+#', - '#^\s*(.+?)\s*$#m' - ), array( - ' ', - '$1' - ), str_replace("\n", '', $pgs[$i])); - - // wordwraps + indents lines - $pgs[$i] = str_repeat($this->indChar, $this->indFirst) . wordwrap($pgs[$i], max($this->wrap - $this->indent, 1), $this->wrapChar . str_repeat($this->indChar, $this->indent), $this->wrapCut); - } - - if ($this->assign !== '') { - $this->core->assignInScope(implode($this->wrapChar . $this->wrapChar, $pgs), $this->assign); - } else { - return implode($this->wrapChar . $this->wrapChar, $pgs); - } - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginTopLevelBlock.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginTopLevelBlock.php deleted file mode 100644 index 2694be2..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginTopLevelBlock.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Compiler; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; - -/** - * Internal plugin used to wrap the template output, do not use in your templates as it will break them. - * This software is provided 'as-is', without any express or implied warranty. - */ -final class PluginTopLevelBlock extends BlockPlugin implements ICompilableBlock -{ - public function init() - { - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - return '/* end template head */ ob_start(); /* template body */ ' . Compiler::PHP_CLOSE; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - return $content . Compiler::PHP_OPEN . ' /* end template body */' . "\n" . 'return $this->buffer . ob_get_clean();'; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginWith.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginWith.php deleted file mode 100644 index f5e94fc..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginWith.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\IElseable; -use Dwoo\Compiler; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; - -/** - * Moves the scope down into the provided variable, allowing you to use shorter - * variable names if you repeatedly access values into a single array. - * The with block won't display anything at all if the provided scope is empty, - * so in effect it acts as {if $var}*content*{/if} - *
- *  * var : the variable name to move into
- * 
- * Example : - * instead of the following : - * - * {if $long.boring.prefix} - * {$long.boring.prefix.val} - {$long.boring.prefix.secondVal} - {$long.boring.prefix.thirdVal} - * {/if} - * - * you can use : - * - * {with $long.boring.prefix} - * {$val} - {$secondVal} - {$thirdVal} - * {/with} - * - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginWith extends BlockPlugin implements ICompilableBlock, IElseable -{ - protected static $cnt = 0; - - /** - * @param $var - */ - public function init($var) - { - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - return ''; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - $rparams = $compiler->getRealParams($params); - $cparams = $compiler->getCompiledParams($params); - - $compiler->setScope($rparams['var']); - - $pre = Compiler::PHP_OPEN . 'if (' . $cparams['var'] . ')' . "\n{\n" . '$_with' . (self::$cnt) . ' = $this->setScope("' . $rparams['var'] . '");' . "\n/* -- start with output */\n" . Compiler::PHP_CLOSE; - - $post = Compiler::PHP_OPEN . "\n/* -- end with output */\n" . '$this->setScope($_with' . (self::$cnt ++) . ', true);' . "\n}\n" . Compiler::PHP_CLOSE; - - if (isset($params['hasElse'])) { - $post .= $params['hasElse']; - } - - return $pre . $content . $post; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginWithelse.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginWithelse.php deleted file mode 100644 index a614322..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Blocks/PluginWithelse.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-19 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Blocks; - -use Dwoo\Compiler; -use Dwoo\Block\Plugin as BlockPlugin; -use Dwoo\ICompilable\Block as ICompilableBlock; - -/** - * This plugin serves as a {else} block specifically for the {with} plugin. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginWithelse extends BlockPlugin implements ICompilableBlock -{ - public function init() - { - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $type - * - * @return string - */ - public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) - { - $with = &$compiler->findBlock('with', true); - - $params['initialized'] = true; - $compiler->injectBlock($type, $params); - - return ''; - } - - /** - * @param Compiler $compiler - * @param array $params - * @param string $prepend - * @param string $append - * @param string $content - * - * @return string - */ - public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) - { - if (!isset($params['initialized'])) { - return ''; - } - - $block = &$compiler->getCurrentBlock(); - $block['params']['hasElse'] = Compiler::PHP_OPEN . "else {\n" . Compiler::PHP_CLOSE . $content . Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE; - - return ''; - } -} diff --git a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Filters/PluginHtmlFormat.php b/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Filters/PluginHtmlFormat.php deleted file mode 100644 index f923de4..0000000 --- a/system/templateEngines/Dwoo/dwoo/dwoo/lib/Dwoo/Plugins/Filters/PluginHtmlFormat.php +++ /dev/null @@ -1,190 +0,0 @@ - - * @author David Sanchez - * @copyright 2008-2013 Jordi Boggiano - * @copyright 2013-2016 David Sanchez - * @license http://dwoo.org/LICENSE Modified BSD License - * @version 1.3.0 - * @date 2016-09-18 - * @link http://dwoo.org/ - */ - -namespace Dwoo\Plugins\Filters; - -use Dwoo\Filter; - -/** - * Formats any html output (must be valid xml where every tag opened is closed) - * using a single tab for indenting. 'pre' and other whitespace sensitive - * tags should not be affected. - * It is not recommended to use this on every template if you render multiple - * templates per page, you should only use it once on the main page template so that - * everything is formatted in one pass. - * This software is provided 'as-is', without any express or implied warranty. - * In no event will the authors be held liable for any damages arising from the use of this software. - */ -class PluginHtmlFormat extends Filter -{ - /** - * tab count to auto-indent the source. - * - * @var int - */ - protected static $tabCount = - 1; - - /** - * stores the additional data (following a tag) of the last call to open/close/singleTag. - * - * @var string - */ - protected static $lastCallAdd = ''; - - /** - * formats the input using the singleTag/closeTag/openTag functions. - * It is auto indenting the whole code, excluding