Add Fluid 1.0.1 to TYPO3core. Do NOT make changes inside! See misc/core_svn_rules...
authorMichael Stucki <michael.stucki@typo3.org>
Wed, 25 Nov 2009 23:08:00 +0000 (23:08 +0000)
committerMichael Stucki <michael.stucki@typo3.org>
Wed, 25 Nov 2009 23:08:00 +0000 (23:08 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@6558 709f56b5-9817-0410-a4d7-c38de5d9e867

180 files changed:
typo3/sysext/fluid/Classes/Compatibility/DocbookGeneratorService.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Compatibility/ObjectFactory.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Compatibility/TemplateParserBuilder.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Exception.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Parser/Exception.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Parser/ParsedTemplateInterface.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Parser/ParsingState.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/AbstractNode.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/ArrayNode.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/ObjectAccessorNode.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/RootNode.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/TextNode.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/ViewHelperNode.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Parser/TemplateParser.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Rendering/HTMLSpecialCharsPostProcessor.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Rendering/ObjectAccessorPostProcessorInterface.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Rendering/RenderingConfiguration.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/Rendering/RenderingContext.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/RuntimeException.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/ViewHelper/ArgumentDefinition.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/ViewHelper/Arguments.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/ViewHelper/Exception.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/ViewHelper/Facets/ChildNodeAccessInterface.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/ViewHelper/Facets/PostParseInterface.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/ViewHelper/TagBasedViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/ViewHelper/TagBuilder.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/ViewHelper/TemplateVariableContainer.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/ViewHelper/ViewHelperInterface.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Core/ViewHelper/ViewHelperVariableContainer.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Exception.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Fluid.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/Service/DocbookGenerator.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/View/Exception.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/View/Exception/InvalidTemplateResource.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/View/TemplateView.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/View/TemplateViewInterface.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/AliasViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/BaseViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Be/AbstractBackendViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Be/Buttons/CshViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Be/Buttons/IconViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Be/Buttons/ShortcutViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Be/ContainerViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Be/Menus/ActionMenuItemViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Be/Menus/ActionMenuViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Be/PageInfoViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Be/PagePathViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Be/TableListViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/CObjectViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/CountViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/CycleViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/DebugViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/ElseViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/ForViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Form/CheckboxViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Form/ErrorsViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Form/HiddenViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Form/PasswordViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Form/RadioViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Form/SelectViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Form/SubmitViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Form/TextareaViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Form/TextboxViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Form/UploadViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Format/CropViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Format/CurrencyViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Format/DateViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Format/HtmlViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Format/Nl2brViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Format/NumberViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Format/PaddingViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Format/PrintfViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/GroupedForViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/IfViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/ImageViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/LayoutViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Link/ActionViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Link/EmailViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Link/ExternalViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Link/PageViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/RenderFlashMessagesViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/RenderViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/SectionViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/ThenViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/TranslateViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Uri/ActionViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Uri/EmailViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Uri/ExternalViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Uri/PageViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Uri/ResourceViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/PostParseFacetViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TemplateParserTestFixture01-shorthand.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TemplateParserTestFixture01.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TemplateParserTestFixture02-shorthand.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TemplateParserTestFixture02.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TemplateParserTestFixture03.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TemplateParserTestFixture04.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TemplateParserTestFixture05.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TemplateParserTestFixture06-shorthand.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TemplateParserTestFixture06.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TemplateParserTestFixture07.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TemplateParserTestFixture08.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TemplateParserTestFixture09.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TemplateParserTestFixture10.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TemplateParserTestFixture11.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TemplateParserTestFixture12_cdata.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TemplateParserTestFixture13_mandatoryInformation.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TemplateParserTestFixture14.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TemplateParserTestPostParseFixture.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Fixtures/TestViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Parser/Fixtures/ChildNodeAccessFacetViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Parser/SyntaxTree/AbstractNodeTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Parser/SyntaxTree/TextNodeTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Parser/SyntaxTree/ViewHelperNodeComparatorTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Parser/SyntaxTree/ViewHelperNodeTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Parser/TemplateParserPatternTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/ParsingStateTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Rendering/HTMLSpecialCharsPostProcessorTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Rendering/RenderingConfigurationTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/Rendering/RenderingContextTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/TagBasedViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/TagBuilderTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/TemplateParserTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/VariableContainerTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/AbstractViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/ArgumentDefinitionTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/TemplateVariableContainerTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/ViewHelperVariableContainerTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/View/Fixtures/LayoutFixture.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/View/Fixtures/TemplateViewFixture.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/View/Fixtures/TemplateViewSectionFixture.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/View/Fixtures/TransparentSyntaxTreeNode.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/View/Fixtures/UnparsedTemplateFixture.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/View/TemplateViewTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/AliasViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/BaseViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/CycleViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/ElseViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Fixtures/ConstraintSyntaxTreeNode.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Fixtures/IfFixture.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Fixtures/IfThenElseFixture.html [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/ForViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/AbstractFormFieldViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/AbstractFormViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/CheckboxViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/ErrorsViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/Fixtures/EmptySyntaxTreeNode.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/Fixtures/Fixture_UserDomainClass.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/HiddenViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/RadioViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/SelectViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/SubmitViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/TextareaViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/TextboxViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/UploadViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Format/CurrencyViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Format/DateViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Format/Nl2brViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Format/NumberViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Format/PaddingViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Format/PrintfViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/GroupedForViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/IfViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Link/ActionViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Link/EmailViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Link/ExternalViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/ThenViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/TranslateViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Uri/ActionViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Uri/EmailViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Uri/ExternalViewHelperTest_testcase.php [new file with mode: 0644]
typo3/sysext/fluid/Tests/Unit/ViewHelpers/ViewHelperBaseTestcase.php [new file with mode: 0644]
typo3/sysext/fluid/ext_autoload.php [new file with mode: 0644]
typo3/sysext/fluid/ext_emconf.php [new file with mode: 0755]
typo3/sysext/fluid/ext_icon.gif [new file with mode: 0644]

diff --git a/typo3/sysext/fluid/Classes/Compatibility/DocbookGeneratorService.php b/typo3/sysext/fluid/Classes/Compatibility/DocbookGeneratorService.php
new file mode 100644 (file)
index 0000000..539b50f
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+
+/*                                                                        *
+ * This script is part of the TYPO3 project - inspiring people to share!  *
+ *                                                                        *
+ * TYPO3 is free software; you can redistribute it and/or modify it under *
+ * the terms of the GNU General Public License version 2 as published by  *
+ * the Free Software Foundation.                                          *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General      *
+ * Public License for more details.                                       *
+ *                                                                        */
+
+/**
+ * @package
+ * @subpackage
+ * @version $Id: DocbookGeneratorService.php 1734 2009-11-25 21:53:57Z stucki $
+ */
+/**
+ * Class extending the docbook generator service for use in typo3 v4.
+ *
+ * Usage in TypoScript:
+ *
+ *
+
+config.disableAllHeaderCode = 1
+page = PAGE
+page.10 = USER_INT
+page.10.userFunc = Tx_Fluid_Compatibility_DocbookGeneratorService->userFunc
+
+ * @internal
+ */
+class Tx_Fluid_Compatibility_DocbookGeneratorService extends Tx_Fluid_Service_DocbookGenerator {
+
+       public function userFunc() {
+               if (!class_exists('Tx_Extbase_Utility_ClassLoader')) {
+                       require(t3lib_extmgm::extPath('extbase') . 'Classes/Utility/ClassLoader.php');
+               }
+
+               $classLoader = new Tx_Extbase_Utility_ClassLoader();
+               spl_autoload_register(array($classLoader, 'loadClass'));
+               return $this->generateDocbook('Tx_Fluid_ViewHelpers');
+       }
+       protected function getClassNamesInNamespace($namespace) {
+               $namespaceParts = explode('_', $namespace);
+               if ($namespaceParts[count($namespaceParts) -1] == '') {
+
+               }
+               $classFilePathAndName = t3lib_extMgm::extPath(t3lib_div::camelCaseToLowerCaseUnderscored($namespaceParts[1])) . 'Classes/';
+               $classFilePathAndName .= implode(array_slice($namespaceParts, 2, -1), '/') . '/';
+               $classNames = array();
+               $this->recursiveClassNameSearch($namespace, $classFilePathAndName, $classNames);
+
+               sort($classNames);
+               return $classNames;
+
+       }
+
+       private function recursiveClassNameSearch($namespace, $directory, &$classNames) {
+               $dh = opendir($directory);
+               while (($file = readdir($dh)) !== false) {
+                       if ($file == '.' || $file == '..' || $file == '.svn') continue;
+
+                       if (is_file($directory . $file)) {
+                               if (substr($file, 0, 8) == 'Abstract') continue;
+
+                               $classNames[] = $namespace . substr($file, 0, -4);
+                       } elseif (is_dir($directory . $file)) {
+                               $this->recursiveClassNameSearch($namespace . $file . '_' , $directory . $file . '/', $classNames);
+                       }
+        }
+        closedir($dh);
+       }
+
+       protected function instanciateViewHelper($className) {
+               $objectFactory = t3lib_div::makeInstance('Tx_Fluid_Compatibility_ObjectFactory');
+               return $objectFactory->create($className);
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Compatibility/ObjectFactory.php b/typo3/sysext/fluid/Classes/Compatibility/ObjectFactory.php
new file mode 100644 (file)
index 0000000..2bae0d1
--- /dev/null
@@ -0,0 +1,91 @@
+<?php
+
+/*                                                                        *
+ * This script is part of the TYPO3 project - inspiring people to share!  *
+ *                                                                        *
+ * TYPO3 is free software; you can redistribute it and/or modify it under *
+ * the terms of the GNU General Public License version 2 as published by  *
+ * the Free Software Foundation.                                          *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General      *
+ * Public License for more details.                                       *
+ *                                                                        */
+
+/**
+ * @package
+ * @subpackage
+ * @version $Id: ObjectFactory.php 1734 2009-11-25 21:53:57Z stucki $
+ */
+/**
+ * Class emulating the object factory for Fluid v4.
+ *
+ * DO NOT USE DIRECTLY!
+ * @internal
+ */
+class Tx_Fluid_Compatibility_ObjectFactory implements t3lib_Singleton {
+
+       protected $injectors = array(
+               'Tx_Fluid_ViewHelpers_Form_AbstractFormViewHelper' => array(
+                       'injectPersistenceManager' => 'Tx_Extbase_Persistence_Manager'
+               ),
+               'Tx_Fluid_Core_ViewHelper_AbstractViewHelper' => array(
+                       'injectReflectionService' => 'Tx_Extbase_Reflection_Service'
+               ),
+               'Tx_Fluid_Core_ViewHelper_TagBasedViewHelper' => array(
+                       'injectTagBuilder' => 'Tx_Fluid_Core_ViewHelper_TagBuilder'
+               ),
+               'Tx_Fluid_Core_Parser_ParsingState' => array(
+                       'injectVariableContainer' => 'Tx_Fluid_Core_ViewHelper_TemplateVariableContainer'
+               ),
+               'Tx_Fluid_Core_Parser_TemplateParser' => array(
+                       'injectObjectFactory' => 'Tx_Fluid_Compatibility_ObjectFactory'
+               ),
+               'Tx_Fluid_Core_Rendering_RenderingContext' => array(
+                       'injectObjectFactory' => 'Tx_Fluid_Compatibility_ObjectFactory'
+               ),
+               'Tx_Extbase_Validation_ValidatorResolver' => array(
+                       'injectObjectManager' => 'Tx_Extbase_Object_Manager'
+               ),
+               'Tx_Fluid_ViewHelpers_FormViewHelper' => array(
+                       'injectRequestHashService' => 'Tx_Extbase_Security_Channel_RequestHashService'
+               )
+       );
+
+       /**
+        * Create a certain object name
+        *
+        * DO NOT USE DIRECTLY!
+        *
+        * @param string $objectName Object name to create
+        * @retrun object Object which was created
+        * @internal
+        */
+       public function create($objectName) {
+               $constructorArguments = func_get_args();
+
+               $object = call_user_func_array(array('t3lib_div', 'makeInstance'), $constructorArguments);
+               $injectObjects = array();
+
+               if (isset($this->injectors[$objectName])) {
+                       $injectObjects = array_merge($injectObjects, $this->injectors[$objectName]);
+               }
+               foreach (class_parents($objectName) as $parentObjectName) {
+                       if (isset($this->injectors[$parentObjectName])) {
+                               $injectObjects = array_merge($injectObjects, $this->injectors[$parentObjectName]);
+                       }
+               }
+               foreach (class_implements($objectName) as $parentObjectName) {
+                       if (isset($this->injectors[$parentObjectName])) {
+                               $injectObjects = array_merge($injectObjects, $this->injectors[$parentObjectName]);
+                       }
+               }
+               foreach ($injectObjects as $injectMethodName => $injectObjectName) {
+                       call_user_func(array($object, $injectMethodName), $this->create($injectObjectName));
+               }
+               return $object;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Compatibility/TemplateParserBuilder.php b/typo3/sysext/fluid/Classes/Compatibility/TemplateParserBuilder.php
new file mode 100644 (file)
index 0000000..ed89084
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+
+
+/*                                                                        *
+ * This script is part of the TYPO3 project - inspiring people to share!  *
+ *                                                                        *
+ * TYPO3 is free software; you can redistribute it and/or modify it under *
+ * the terms of the GNU General Public License version 2 as published by  *
+ * the Free Software Foundation.                                          *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General      *
+ * Public License for more details.                                       *
+ *                                                                        */
+
+/**
+ * @package
+ * @subpackage
+ * @version $Id: TemplateParserBuilder.php 1734 2009-11-25 21:53:57Z stucki $
+ */
+/**
+ * Build a template parser.
+ * Use this class to get a fresh instance of a correctly initialized Fluid template parser.
+ */
+class Tx_Fluid_Compatibility_TemplateParserBuilder {
+       /**
+        * Creates a new TemplateParser which is correctly initialized. This is the correct
+        * way to get a Fluid parser instance.
+        *
+        * @return Tx_Fluid_Core_TemplateParser A correctly initialized Template Parser
+        */
+       static public function build() {
+               $templateParser = t3lib_div::makeInstance('Tx_Fluid_Core_Parser_TemplateParser');
+               $templateParser->injectObjectFactory(t3lib_div::makeInstance('Tx_Fluid_Compatibility_ObjectFactory'));
+               return $templateParser;
+       }
+}
+
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Exception.php b/typo3/sysext/fluid/Classes/Core/Exception.php
new file mode 100644 (file)
index 0000000..9a919a6
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * A generic Fluid Core exception.
+ *
+ * @version $Id: Exception.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ */
+class Tx_Fluid_Core_Exception extends Tx_Fluid_Exception {
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Parser/Exception.php b/typo3/sysext/fluid/Classes/Core/Parser/Exception.php
new file mode 100644 (file)
index 0000000..ef33a3d
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * A Parsing Exception
+ *
+ * @version $Id: Exception.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\Parser
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ */
+class Tx_Fluid_Core_Parser_Exception extends Tx_Fluid_Core_Exception {
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Parser/ParsedTemplateInterface.php b/typo3/sysext/fluid/Classes/Core/Parser/ParsedTemplateInterface.php
new file mode 100644 (file)
index 0000000..94e490f
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * This interface is returned by Tx_Fluid_Core_Parser_TemplateParser->parse()
+ * method and is a parsed template
+ *
+ * @version $Id: ParsedTemplateInterface.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\Parser
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+interface Tx_Fluid_Core_Parser_ParsedTemplateInterface {
+
+       /**
+        * Render the parsed template with rendering context
+        *
+        * @param Tx_Fluid_Core_Rendering_RenderingContext $renderingContext The rendering context to use
+        * @return Rendered string
+        */
+       public function render(Tx_Fluid_Core_Rendering_RenderingContext $renderingContext);
+
+       /**
+        * Returns a variable container used in the PostParse Facet.
+        *
+        * @return Tx_Fluid_Core_ViewHelper_TemplateVariableContainer
+        */
+       // TODO
+       public function getVariableContainer(); // rename to getPostParseVariableContainer -- @internal definitely
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Parser/ParsingState.php b/typo3/sysext/fluid/Classes/Core/Parser/ParsingState.php
new file mode 100644 (file)
index 0000000..33cd90c
--- /dev/null
@@ -0,0 +1,152 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Stores all information relevant for one parsing pass - that is, the root node,
+ * and the current stack of open nodes (nodeStack) and a variable container used
+ * for PostParseFacets.
+ *
+ * @version $Id: ParsingState.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\Parser
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class Tx_Fluid_Core_Parser_ParsingState implements Tx_Fluid_Core_Parser_ParsedTemplateInterface {
+
+       /**
+        * Root node reference
+        * @var Tx_Fluid_Core_Parser_SyntaxTree_RootNode
+        */
+       protected $rootNode;
+
+       /**
+        * Array of node references currently open.
+        * @var array
+        */
+       protected $nodeStack = array();
+
+       /**
+        * Variable container where ViewHelpers implementing the PostParseFacet can
+        * store things in.
+        * @var Tx_Fluid_Core_ViewHelper_TemplateVariableContainer
+        */
+       protected $variableContainer;
+
+       /**
+        * Injects a variable container. ViewHelpers implementing the PostParse
+        * Facet can store information inside this variableContainer.
+        *
+        * @param Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $variableContainer
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function injectVariableContainer(Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $variableContainer) {
+               $this->variableContainer = $variableContainer;
+       }
+
+       /**
+        * Set root node of this parsing state
+        *
+        * @param Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $rootNode
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setRootNode(Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $rootNode) {
+               $this->rootNode = $rootNode;
+       }
+
+       /**
+        * Get root node of this parsing state.
+        *
+        * @return Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode The root node
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getRootNode() {
+               return $this->rootNode;
+       }
+
+       /**
+        * Render the parsed template with rendering context
+        *
+        * @param Tx_Fluid_Core_Rendering_RenderingContext $renderingContext The rendering context to use
+        * @return Rendered string
+        */
+       public function render(Tx_Fluid_Core_Rendering_RenderingContext $renderingContext) {
+               $this->rootNode->setRenderingContext($renderingContext);
+               return $this->rootNode->evaluate();
+       }
+
+       /**
+        * Push a node to the node stack. The node stack holds all currently open
+        * templating tags.
+        *
+        * @param Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $node Node to push to node stack
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function pushNodeToStack(Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $node) {
+               array_push($this->nodeStack, $node);
+       }
+
+       /**
+        * Get the top stack element, without removing it.
+        *
+        * @return Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode the top stack element.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getNodeFromStack() {
+               return $this->nodeStack[count($this->nodeStack)-1];
+       }
+
+       /**
+        * Pop the top stack element (=remove it) and return it back.
+        *
+        * @return Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode the top stack element, which was removed.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function popNodeFromStack() {
+               return array_pop($this->nodeStack);
+       }
+
+       /**
+        * Count the size of the node stack
+        *
+        * @return integer Number of elements on the node stack (i.e. number of currently open Fluid tags)
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function countNodeStack() {
+               return count($this->nodeStack);
+       }
+
+       /**
+        * Returns a variable container which will be then passed to the postParseFacet.
+        *
+        * @return Tx_Fluid_Core_ViewHelper_TemplateVariableContainer The variable container or NULL if none has been set yet
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @todo Rename to getPostParseVariableContainer
+        */
+       public function getVariableContainer() {
+               return $this->variableContainer;
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/AbstractNode.php b/typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/AbstractNode.php
new file mode 100644 (file)
index 0000000..6a7b4a0
--- /dev/null
@@ -0,0 +1,116 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Abstract node in the syntax tree which has been built.
+ *
+ * @version $Id: AbstractNode.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\Parser\SyntaxTree
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+abstract class Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode {
+
+       /**
+        * List of Child Nodes.
+        * @var array<Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode>
+        */
+       protected $childNodes = array();
+
+       /**
+        * The rendering context containing everything to correctly render the subtree
+        * @var Tx_Fluid_Core_Rendering_RenderingContext
+        */
+       protected $renderingContext;
+
+       /**
+        * @param Tx_Fluid_Core_Rendering_RenderingContext $renderingContext Rendering Context to be used for this evaluation
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setRenderingContext(Tx_Fluid_Core_Rendering_RenderingContext $renderingContext) {
+               $this->renderingContext = $renderingContext;
+       }
+
+       /**
+        * Evaluate all child nodes and return the evaluated results.
+        *
+        * @return object Normally, an object is returned - in case it is concatenated with a string, a string is returned.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function evaluateChildNodes() {
+               $output = NULL;
+               foreach ($this->childNodes as $subNode) {
+                       $subNode->setRenderingContext($this->renderingContext);
+
+                       if ($output === NULL) {
+                               $output = $subNode->evaluate();
+                       } else {
+                               if (is_object($output) && !method_exists($output, '__toString')) {
+                                       throw new Tx_Fluid_Core_Parser_Exception('Cannot cast object of type "' . get_class($output) . '" to string.', 1248356140);
+                               }
+                               $output = (string)$output;
+                               $subNodeOutput = $subNode->evaluate();
+                               if (is_object($subNodeOutput) && !method_exists($subNodeOutput, '__toString')) {
+                                       throw new Tx_Fluid_Core_Parser_Exception('Cannot cast object of type "' . get_class($subNodeOutput) . '" to string.', 1248356140);
+                               }
+                               $output .= (string)$subNodeOutput;
+                       }
+               }
+               return $output;
+       }
+
+       /**
+        * Returns all child nodes for a given node.
+        * This is especially needed to implement the boolean expression language.
+        *
+        * @return array Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode A list of nodes
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getChildNodes() {
+               return $this->childNodes;
+       }
+
+       /**
+        * Appends a subnode to this node. Is used inside the parser to append children
+        *
+        * @param Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $childNode The subnode to add
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function addChildNode(Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $childNode) {
+               $this->childNodes[] = $childNode;
+       }
+
+       /**
+        * Evaluates the node - can return not only strings, but arbitary objects.
+        *
+        * @return object Evaluated node
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       abstract public function evaluate();
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/ArrayNode.php b/typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/ArrayNode.php
new file mode 100644 (file)
index 0000000..52a22ee
--- /dev/null
@@ -0,0 +1,75 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Array Syntax Tree Node. Handles JSON-like arrays.
+ *
+ * @version $Id: ArrayNode.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\Parser\SyntaxTree
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class Tx_Fluid_Core_Parser_SyntaxTree_ArrayNode extends Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode {
+
+       /**
+        * An associative array. Each key is a string. Each value is either a literal, or an AbstractNode.
+        * @var array
+        */
+       protected $internalArray = array();
+
+       /**
+        * Constructor.
+        *
+        * @param array $internalArray Array to store
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function __construct($internalArray) {
+               $this->internalArray = $internalArray;
+       }
+
+       /**
+        * Evaluate the array and return an evaluated array
+        *
+        * @return array An associative array with literal values
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function evaluate() {
+               if ($this->renderingContext === NULL) {
+                       throw new RuntimeException('Rendering Context is null in ArrayNode, but necessary. If this error appears, please report a bug!', 1242668976);
+               }
+               $arrayToBuild = array();
+               foreach ($this->internalArray as $key => $value) {
+                       if ($value instanceof Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode) {
+                               $value->setRenderingContext($this->renderingContext);
+                               $arrayToBuild[$key] = $value->evaluate();
+                       } else {
+                               // TODO - this case should not happen!
+                               $arrayToBuild[$key] = $value;
+                       }
+               }
+               return $arrayToBuild;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/ObjectAccessorNode.php b/typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/ObjectAccessorNode.php
new file mode 100644 (file)
index 0000000..812c15d
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * A node which handles object access. This means it handles structures like {object.accessor.bla}
+ *
+ * @version $Id: ObjectAccessorNode.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\Parser\SyntaxTree
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class Tx_Fluid_Core_Parser_SyntaxTree_ObjectAccessorNode extends Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode {
+
+       /**
+        * Object path which will be called. Is a list like "post.name.email"
+        * @var string
+        */
+       protected $objectPath;
+
+       /**
+        * Constructor. Takes an object path as input.
+        *
+        * The first part of the object path has to be a variable in the TemplateVariableContainer.
+        * For the further parts, it is checked if the object has a getObjectname method. If yes, this is called.
+        * If no, it is checked if a property "objectname" exists.
+        * If no, an error is thrown.
+        *
+        * @param string $objectPath An Object Path, like object1.object2.object3
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function __construct($objectPath) {
+               $this->objectPath = $objectPath;
+       }
+
+       /**
+        * Evaluate this node and return the correct object.
+        *
+        * Handles each part (denoted by .) in $this->objectPath in the following order:
+        * - call appropriate getter
+        * - call public property, if exists
+        * - fail
+        *
+        * @return object The evaluated object, can be any object type.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @todo Depending on the context, either fail or not!!!
+        */
+       public function evaluate() {
+               $objectPathParts = explode('.', $this->objectPath);
+               $variableName = array_shift($objectPathParts);
+               if (!$this->renderingContext->getTemplateVariableContainer()->exists($variableName)) {
+                       return NULL;
+               }
+               $currentObject = $this->renderingContext->getTemplateVariableContainer()->get($variableName);
+               if (count($objectPathParts) > 0) {
+                       $output = Tx_Extbase_Reflection_ObjectAccess::getPropertyPath($currentObject, implode('.', $objectPathParts));
+               } else {
+                       $output = $currentObject;
+               }
+
+               $postProcessor = $this->renderingContext->getRenderingConfiguration()->getObjectAccessorPostProcessor();
+               if ($postProcessor !== NULL) {
+                       $output = $postProcessor->process($output, $this->renderingContext->isObjectAccessorPostProcessorEnabled());
+               }
+
+               return $output;
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/RootNode.php b/typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/RootNode.php
new file mode 100644 (file)
index 0000000..02e01ec
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Root node of every syntax tree.
+ *
+ * @version $Id: RootNode.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\Parser\SyntaxTree
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class Tx_Fluid_Core_Parser_SyntaxTree_RootNode extends Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode {
+
+       /**
+        * Evaluate the root node, by evaluating the subtree.
+        *
+        * @return object Evaluated subtree
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function evaluate() {
+               if ($this->renderingContext === NULL) {
+                       throw new RuntimeException('Rendering Context is null in RootNode, but necessary. If this error appears, please report a bug!', 1242669004);
+               }
+               $text = $this->evaluateChildNodes();
+               return $text;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/TextNode.php b/typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/TextNode.php
new file mode 100644 (file)
index 0000000..a63e9cb
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Text Syntax Tree Node - is a container for strings.
+ *
+ * @version $Id: TextNode.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\Parser\SyntaxTree
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class Tx_Fluid_Core_Parser_SyntaxTree_TextNode extends Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode {
+
+       /**
+        * Contents of the text node
+        * @var string
+        */
+       protected $text;
+
+       /**
+        * Constructor.
+        *
+        * @param string $text text to store in this textNode
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function __construct($text) {
+               if (!is_string($text)) {
+                       throw new Tx_Fluid_Core_Parser_Exception('Text node requires an argument of type string, "' . gettype($text) . '" given.');
+               }
+               $this->text = $text;
+       }
+
+       /**
+        * Return the text associated to the syntax tree.
+        *
+        * @return string the text stored in this node.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function evaluate() {
+               return $this->text;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/ViewHelperNode.php b/typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/ViewHelperNode.php
new file mode 100644 (file)
index 0000000..54bcdce
--- /dev/null
@@ -0,0 +1,376 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Node which will call a ViewHelper associated with this node.
+ *
+ * @version $Id: ViewHelperNode.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\Parser\SyntaxTree
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode extends Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode {
+
+       /**
+        * Namespace of view helper
+        * @var string
+        */
+       protected $viewHelperClassName;
+
+       /**
+        * Arguments of view helper - References to RootNodes.
+        * @var array
+        */
+       protected $arguments = array();
+
+       /**
+        * The cached ViewHelper, to make sure every SyntaxTreeNode has exactly one
+        * ViewHelper associated to it.
+        * @var Tx_Fluid_Core_ViewHelper_AbstractViewHelper
+        */
+       protected $cachedViewHelper = NULL;
+
+       /**
+        * Cached argument definitions.
+        * @var array
+        */
+       protected $cachedArgumentDefinitions = NULL;
+
+       /**
+        * List of comparators which are supported in the boolean expression language.
+        *
+        * Make sure that if one string is contained in one another, the longer
+        * string is listed BEFORE the shorter one.
+        * Example: put ">=" before ">"
+        * @var array of comparators
+        */
+       static protected $comparators = array('==', '!=', '%', '>=', '>', '<=', '<');
+
+       /**
+        * A regular expression which checks the text nodes of a boolean expression.
+        * Used to define how the regular expression language should look like.
+        * @var string Regular expression
+        */
+       static protected $booleanExpressionTextNodeCheckerRegularExpression = '/
+               ^                 # Start with first input symbol
+               (?:               # start repeat
+                       COMPARATORS   # We allow all comparators
+                       |\s*          # Arbitary spaces
+                       |[0-9]        # Numbers
+                       |\\.          # And the dot.
+               )*
+               $/x';
+
+       /**
+        * Constructor.
+        *
+        * @param string $viewHelperClassName Fully qualified class name of the view helper
+        * @param array $arguments Arguments of view helper - each value is a RootNode.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function __construct($viewHelperClassName, array $arguments) {
+               $this->viewHelperClassName = $viewHelperClassName;
+               $this->arguments = $arguments;
+       }
+
+       /**
+        * Get class name of view helper
+        *
+        * @return string Class Name of associated view helper
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getViewHelperClassName() {
+               return $this->viewHelperClassName;
+       }
+
+       /**
+        * Call the view helper associated with this object.
+        *
+        * First, it evaluates the arguments of the view helper.
+        *
+        * If the view helper implements Tx_Fluid_Core_ViewHelper_Facets_ChildNodeAccessInterface,
+        * it calls setChildNodes(array childNodes) on the view helper.
+        *
+        * Afterwards, checks that the view helper did not leave a variable lying around.
+        *
+        * @return object evaluated node after the view helper has been called.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function evaluate() {
+               if ($this->renderingContext === NULL) {
+                       throw new RuntimeException('RenderingContext is null in ViewHelperNode, but necessary. If this error appears, please report a bug!', 1242669031);
+               }
+
+                       // Store if the ObjectAccessorPostProcessor has been enabled before this ViewHelper, because we need to re-enable it if needed after this ViewHelper
+               $hasObjectAccessorPostProcessorBeenEnabledBeforeThisViewHelper = $this->renderingContext->isObjectAccessorPostProcessorEnabled();
+
+                       // Caching of ViewHelper and Argument Definitions
+               $objectFactory = $this->renderingContext->getObjectFactory();
+               if ($this->cachedViewHelper !== NULL) {
+                       $viewHelper = $this->cachedViewHelper;
+                       $argumentDefinitions = $this->cachedArgumentDefinitions;
+               } else {
+                       $viewHelper = $objectFactory->create($this->viewHelperClassName);
+                       $argumentDefinitions = $viewHelper->prepareArguments();
+
+                       $this->cachedViewHelper = $viewHelper;
+                       $this->cachedArgumentDefinitions = $argumentDefinitions;
+               }
+               $contextVariables = $this->renderingContext->getTemplateVariableContainer()->getAllIdentifiers();
+
+               $evaluatedArguments = array();
+               $renderMethodParameters = array();
+               $this->renderingContext->setObjectAccessorPostProcessorEnabled(FALSE);
+               if (count($argumentDefinitions)) {
+                       foreach ($argumentDefinitions as $argumentName => $argumentDefinition) {
+                               if (isset($this->arguments[$argumentName])) {
+                                       $argumentValue = $this->arguments[$argumentName];
+                                       $argumentValue->setRenderingContext($this->renderingContext);
+                                       $evaluatedArguments[$argumentName] = $this->convertArgumentValue($argumentValue, $argumentDefinition->getType());
+                               } else {
+                                       $evaluatedArguments[$argumentName] = $argumentDefinition->getDefaultValue();
+                               }
+                               if ($argumentDefinition->isMethodParameter()) {
+                                       $renderMethodParameters[$argumentName] = $evaluatedArguments[$argumentName];
+                               }
+                       }
+               }
+
+               $viewHelperArguments = $objectFactory->create('Tx_Fluid_Core_ViewHelper_Arguments', $evaluatedArguments);
+               $viewHelper->setArguments($viewHelperArguments);
+               $viewHelper->setTemplateVariableContainer($this->renderingContext->getTemplateVariableContainer());
+               if ($this->renderingContext->getControllerContext() !== NULL) {
+                       $viewHelper->setControllerContext($this->renderingContext->getControllerContext());
+               }
+               $viewHelper->setViewHelperVariableContainer($this->renderingContext->getViewHelperVariableContainer());
+               $viewHelper->setViewHelperNode($this);
+
+               if ($viewHelper instanceof Tx_Fluid_Core_ViewHelper_Facets_ChildNodeAccessInterface) {
+                       $viewHelper->setChildNodes($this->childNodes);
+                       $viewHelper->setRenderingContext($this->renderingContext);
+               }
+
+               $viewHelper->validateArguments();
+               $this->renderingContext->setObjectAccessorPostProcessorEnabled($viewHelper->isObjectAccessorPostProcessorEnabled());
+               $viewHelper->initialize();
+               try {
+                       $output = call_user_func_array(array($viewHelper, 'render'), $renderMethodParameters);
+               } catch (Tx_Fluid_Core_ViewHelper_Exception $exception) {
+                       // @todo [BW] rethrow exception, log, ignore.. depending on the current context
+                       $output = $exception->getMessage();
+               }
+
+               $this->renderingContext->setObjectAccessorPostProcessorEnabled($hasObjectAccessorPostProcessorBeenEnabledBeforeThisViewHelper);
+
+               if ($contextVariables != $this->renderingContext->getTemplateVariableContainer()->getAllIdentifiers()) {
+                       $endContextVariables = $this->renderingContext->getTemplateVariableContainer();
+                       $diff = array_intersect($endContextVariables, $contextVariables);
+
+                       throw new RuntimeException('The following context variable has been changed after the view helper "' . $this->viewHelperClassName . '" has been called: ' .implode(', ', $diff), 1236081302);
+               }
+               return $output;
+       }
+
+       /**
+        * Convert argument strings to their equivalents. Needed to handle strings with a boolean meaning.
+        *
+        * @param Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $syntaxTreeNode Value to be converted
+        * @param string $type Target type
+        * @return mixed New value
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       protected function convertArgumentValue(Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $syntaxTreeNode, $type) {
+               if ($type === 'boolean') {
+                       return $this->evaluateBooleanExpression($syntaxTreeNode);
+               }
+               return $syntaxTreeNode->evaluate();
+       }
+
+       /**
+        * Convert boolean expression syntax tree to some meaningful value.
+        * The expression is available as the SyntaxTree of the argument.
+        *
+        * We currently only support expressions of the form:
+        * XX Comparator YY
+        * Where XX and YY can be either:
+        * - a number
+        * - an Object accessor
+        * - an array
+        * - a ViewHelper
+        *
+        * and comparator must be one of the above.
+        *
+        * In case no comparator is found, the fallback of "convertToBoolean" is used.
+        *
+        *
+        * Internal work:
+        * First, we loop through the child syntaxtree nodes, to fill the left side of the comparator,
+        * the right side of the comparator, and the comparator itself.
+        * Then, we evaluate the obtained left and right side using the given comparator. This is done inside the evaluateComparator method.
+        *
+        * @param Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $syntaxTreeNode Value to be converted
+        * @return boolean Evaluated value
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function evaluateBooleanExpression(Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode $syntaxTreeNode) {
+               $childNodes = $syntaxTreeNode->getChildNodes();
+               if (count($childNodes) > 3) {
+                       throw new RuntimeException('The expression "' . $syntaxTreeNode->evaluate() . '" has more than tree parts.', 1244201848);
+               }
+
+               $leftSide = NULL;
+               $rightSide = NULL;
+               $comparator = NULL;
+               foreach ($childNodes as $childNode) {
+                       $childNode->setRenderingContext($this->renderingContext);
+
+                       if ($childNode instanceof Tx_Fluid_Core_Parser_SyntaxTree_TextNode && !preg_match(str_replace('COMPARATORS', implode('|', self::$comparators), self::$booleanExpressionTextNodeCheckerRegularExpression), $childNode->evaluate())) {
+                               $comparator = NULL;
+                               break; // skip loop and fall back to classical to boolean conversion.
+                       }
+
+                       if ($comparator !== NULL) {
+                               // comparator already set, we are evaluating the right side of the comparator
+                               if ($rightSide === NULL) {
+                                       $rightSide = $childNode->evaluate();
+                               } else {
+                                       $rightSide .= $childNode->evaluate();
+                               }
+                       } elseif ($childNode instanceof Tx_Fluid_Core_Parser_SyntaxTree_TextNode
+                               && ($comparator = $this->getComparatorFromString($childNode->evaluate()))) {
+                               // comparator in current string segment
+                               $explodedString = explode($comparator, $childNode->evaluate());
+                               if (isset($explodedString[0]) && trim($explodedString[0]) !== '') {
+                                       $leftSide .= trim($explodedString[0]);
+                               }
+                               if (isset($explodedString[1]) && trim($explodedString[1]) !== '') {
+                                       $rightSide .= trim($explodedString[1]);
+                               }
+                       } else {
+                               // comparator not found yet, on the left side of the comparator
+                               if ($leftSide === NULL) {
+                                       $leftSide = $childNode->evaluate();
+                               } else {
+                                       $leftSide .= $childNode->evaluate();
+                               }
+                       }
+               }
+
+               if ($comparator !== NULL) {
+                       return $this->evaluateComparator($comparator, $leftSide, $rightSide);
+               } else {
+                       $syntaxTreeNode->setRenderingContext($this->renderingContext);
+                       return $this->convertToBoolean($syntaxTreeNode->evaluate());
+               }
+       }
+
+       /**
+        * Do the actual comparison. Compares $leftSide and $rightSide with $comparator and emits a boolean value
+        *
+        * @param string $comparator One of self::$comparators
+        * @param mixed $leftSide Left side to compare
+        * @param mixed $rightSide Right side to compare
+        * @return boolean TRUE if comparison of left and right side using the comparator emit TRUE, false otherwise
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function evaluateComparator($comparator, $leftSide, $rightSide) {
+               switch ($comparator) {
+                       case '==':
+                               return ($leftSide == $rightSide);
+                               break;
+                       case '!=':
+                               return ($leftSide != $rightSide);
+                               break;
+                       case '%':
+                               return (boolean)((int)$leftSide % (int)$rightSide);
+                       case '>':
+                               return ($leftSide > $rightSide);
+                       case '>=':
+                               return ($leftSide >= $rightSide);
+                       case '<':
+                               return ($leftSide < $rightSide);
+                       case '<=':
+                               return ($leftSide <= $rightSide);
+                       default:
+                               throw new RuntimeException('Comparator "' . $comparator . '" was not implemented. Please report a bug.', 1244234398);
+               }
+       }
+
+       /**
+        * Determine if there is a comparator inside $string, and if yes, returns it.
+        *
+        * @param string $string string to check for a comparator inside
+        * @return string The comparator or NULL if none found.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       protected function getComparatorFromString($string) {
+               foreach (self::$comparators as $comparator) {
+                       if (strpos($string, $comparator) !== FALSE) {
+                               return $comparator;
+                       }
+               }
+
+               return NULL;
+       }
+
+       /**
+        * Convert argument strings to their equivalents. Needed to handle strings with a boolean meaning.
+        *
+        * @param mixed $value Value to be converted to boolean
+        * @return mixed New value
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @todo this should be moved to another class
+        */
+       protected function convertToBoolean($value) {
+               if (is_bool($value)) {
+                       return $value;
+               }
+               if (is_string($value)) {
+                       return (strtolower($value) !== 'false' && !empty($value));
+               }
+               if (is_numeric($value)) {
+                       return $value > 0;
+               }
+               if (is_array($value) || (is_object($value) && $value instanceof Countable)) {
+                       return count($value) > 0;
+               }
+               if (is_object($value)) {
+                       return TRUE;
+               }
+               return FALSE;
+       }
+
+       /**
+        * Clean up for serializing.
+        *
+        * @return array
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function __sleep() {
+               return array('viewHelperClassName', 'arguments', 'childNodes');
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Parser/TemplateParser.php b/typo3/sysext/fluid/Classes/Core/Parser/TemplateParser.php
new file mode 100644 (file)
index 0000000..541c3c7
--- /dev/null
@@ -0,0 +1,769 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Template parser building up an object syntax tree
+ *
+ * @version $Id: TemplateParser.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\Parser
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class Tx_Fluid_Core_Parser_TemplateParser {
+
+       public static $SCAN_PATTERN_NAMESPACEDECLARATION = '/(?<!\\\\){namespace\s*([a-zA-Z]+[a-zA-Z0-9]*)\s*=\s*((?:F3|Tx)(?:FLUID_NAMESPACE_SEPARATOR\w+)+)\s*}/m';
+
+       /**
+        * This regular expression splits the input string at all dynamic tags, AND
+        * on all <![CDATA[...]]> sections.
+        *
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public static $SPLIT_PATTERN_TEMPLATE_DYNAMICTAGS = '/
+               (
+                       (?: <\/?                                      # Start dynamic tags
+                                       (?:(?:NAMESPACE):[a-zA-Z0-9\\.]+)     # A tag consists of the namespace prefix and word characters
+                                       (?:                                   # Begin tag arguments
+                                               \s*[a-zA-Z0-9:]+                  # Argument Keys
+                                               =                                 # =
+                                               (?:                               # either...
+                                                       "(?:\\\"|[^"])*"              # a double-quoted string
+                                                       |\'(?:\\\\\'|[^\'])*\'        # or a single quoted string
+                                               )\s*                              #
+                                       )*                                    # Tag arguments can be replaced many times.
+                               \s*
+                               \/?>                                      # Closing tag
+                       )
+                       |(?:                                          # Start match CDATA section
+                               <!\[CDATA\[.*?\]\]>
+                       )
+               )/xs';
+
+       /**
+        * This regular expression scans if the input string is a ViewHelper tag
+        *
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public static $SCAN_PATTERN_TEMPLATE_VIEWHELPERTAG = '/^<(?P<NamespaceIdentifier>NAMESPACE):(?P<MethodIdentifier>[a-zA-Z0-9\\.]+)(?P<Attributes>(?:\s*[a-zA-Z0-9:]+=(?:"(?:\\\"|[^"])*"|\'(?:\\\\\'|[^\'])*\')\s*)*)\s*(?P<Selfclosing>\/?)>$/';
+
+       /**
+        * This regular expression scans if the input string is a closing ViewHelper
+        * tag.
+        *
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public static $SCAN_PATTERN_TEMPLATE_CLOSINGVIEWHELPERTAG = '/^<\/(?P<NamespaceIdentifier>NAMESPACE):(?P<MethodIdentifier>[a-zA-Z0-9\\.]+)\s*>$/';
+
+       /**
+        * This regular expression splits the tag arguments into its parts
+        *
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public static $SPLIT_PATTERN_TAGARGUMENTS = '/(?:\s*(?P<Argument>[a-zA-Z0-9:]+)=(?:"(?P<ValueDoubleQuoted>(?:\\\"|[^"])*)"|\'(?P<ValueSingleQuoted>(?:\\\\\'|[^\'])*)\')\s*)/';
+
+       /**
+        * This pattern detects CDATA sections and outputs the text between opening
+        * and closing CDATA.
+        *
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public static $SCAN_PATTERN_CDATA = '/^<!\[CDATA\[(.*?)\]\]>$/s';
+
+       /**
+        * Pattern which splits the shorthand syntax into different tokens. The
+        * "shorthand syntax" is everything like {...}
+        *
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public static $SPLIT_PATTERN_SHORTHANDSYNTAX = '/
+               (
+                       {                                # Start of shorthand syntax
+                               (?:                          # Shorthand syntax is either composed of...
+                                       [a-zA-Z0-9\->_:,.()]     # Various characters
+                                       |"(?:\\\"|[^"])*"        # Double-quoted strings
+                                       |\'(?:\\\\\'|[^\'])*\'   # Single-quoted strings
+                                       |(?R)                    # Other shorthand syntaxes inside, albeit not in a quoted string
+                                       |\s+                     # Spaces
+                               )+
+                       }                                # End of shorthand syntax
+               )/x';
+
+       /**
+        * Pattern which detects the object accessor syntax:
+        * {object.some.value}, additionally it detects ViewHelpers like
+        * {f:for(param1:bla)} and chaining like
+        * {object.some.value->f:bla.blubb()->f:bla.blubb2()}
+        *
+        * THIS IS ALMOST THE SAME AS IN $SCAN_PATTERN_SHORTHANDSYNTAX_ARRAYS
+        *
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public static $SCAN_PATTERN_SHORTHANDSYNTAX_OBJECTACCESSORS = '/
+               ^{                                                      # Start of shorthand syntax
+                                                                        # A shorthand syntax is either...
+                       (?P<Object>[a-zA-Z0-9\-_.]*)                                     # ... an object accessor
+                       \s*(?P<Delimiter>(?:->)?)\s*
+
+                       (?P<ViewHelper>                                 # ... a ViewHelper
+                               [a-zA-Z0-9]+                                # Namespace prefix of ViewHelper (as in $SCAN_PATTERN_TEMPLATE_VIEWHELPERTAG)
+                               :
+                               [a-zA-Z0-9\\.]+                             # Method Identifier (as in $SCAN_PATTERN_TEMPLATE_VIEWHELPERTAG)
+                               \(                                          # Opening parameter brackets of ViewHelper
+                                       (?P<ViewHelperArguments>                # Start submatch for ViewHelper arguments. This is taken from $SCAN_PATTERN_SHORTHANDSYNTAX_ARRAYS
+                                               (?:
+                                                       \s*[a-zA-Z0-9\-_]+                  # The keys of the array
+                                                       \s*:\s*                             # Key|Value delimiter :
+                                                       (?:                                 # Possible value options:
+                                                               "(?:\\\"|[^"])*"                # Double qouoted string
+                                                               |\'(?:\\\\\'|[^\'])*\'          # Single quoted string
+                                                               |[a-zA-Z0-9\-_.]+               # variable identifiers
+                                                               |{(?P>ViewHelperArguments)}     # Another sub-array
+                                                       )                                   # END possible value options
+                                                       \s*,?                               # There might be a , to seperate different parts of the array
+                                               )*                                  # The above cycle is repeated for all array elements
+                                       )                                       # End ViewHelper Arguments submatch
+                               \)                                          # Closing parameter brackets of ViewHelper
+                       )?
+                       (?P<AdditionalViewHelpers>                      # There can be more than one ViewHelper chained, by adding more -> and the ViewHelper (recursively)
+                               (?:
+                                       \s*->\s*
+                                       (?P>ViewHelper)
+                               )*
+                       )
+               }$/x';
+
+       /**
+        * THIS IS ALMOST THE SAME AS $SCAN_PATTERN_SHORTHANDSYNTAX_OBJECTACCESSORS
+        *
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public static $SPLIT_PATTERN_SHORTHANDSYNTAX_VIEWHELPER = '/
+
+               (?P<NamespaceIdentifier>[a-zA-Z0-9]+)                               # Namespace prefix of ViewHelper (as in $SCAN_PATTERN_TEMPLATE_VIEWHELPERTAG)
+               :
+               (?P<MethodIdentifier>[a-zA-Z0-9\\.]+)
+               \(                                          # Opening parameter brackets of ViewHelper
+                       (?P<ViewHelperArguments>                # Start submatch for ViewHelper arguments. This is taken from $SCAN_PATTERN_SHORTHANDSYNTAX_ARRAYS
+                               (?:
+                                       \s*[a-zA-Z0-9\-_]+                  # The keys of the array
+                                       \s*:\s*                             # Key|Value delimiter :
+                                       (?:                                 # Possible value options:
+                                               "(?:\\\"|[^"])*"                # Double qouoted string
+                                               |\'(?:\\\\\'|[^\'])*\'          # Single quoted string
+                                               |[a-zA-Z0-9\-_.]+               # variable identifiers
+                                               |{(?P>ViewHelperArguments)}     # Another sub-array
+                                       )                                   # END possible value options
+                                       \s*,?                               # There might be a , to seperate different parts of the array
+                               )*                                  # The above cycle is repeated for all array elements
+                       )                                       # End ViewHelper Arguments submatch
+               \)                                          # Closing parameter brackets of ViewHelper
+               /x';
+
+       /**
+        * Pattern which detects the array/object syntax like in JavaScript, so it
+        * detects strings like:
+        * {object: value, object2: {nested: array}, object3: "Some string"}
+        *
+        * THIS IS ALMOST THE SAME AS IN SCAN_PATTERN_SHORTHANDSYNTAX_OBJECTACCESSORS
+        *
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public static $SCAN_PATTERN_SHORTHANDSYNTAX_ARRAYS = '/^
+               (?P<Recursion>                                  # Start the recursive part of the regular expression - describing the array syntax
+                       {                                           # Each array needs to start with {
+                               (?P<Array>                              # Start submatch
+                                       (?:
+                                               \s*[a-zA-Z0-9\-_]+              # The keys of the array
+                                               \s*:\s*                         # Key|Value delimiter :
+                                               (?:                             # Possible value options:
+                                                       "(?:\\\"|[^"])*"            # Double qouoted string
+                                                       |\'(?:\\\\\'|[^\'])*\'      # Single quoted string
+                                                       |[a-zA-Z0-9\-_.]+           # variable identifiers
+                                                       |(?P>Recursion)             # Another sub-array
+                                               )                               # END possible value options
+                                               \s*,?                           # There might be a , to seperate different parts of the array
+                                       )*                                  # The above cycle is repeated for all array elements
+                               )                                       # End array submatch
+                       }                                           # Each array ends with }
+               )$/x';
+
+       /**
+        * This pattern splits an array into its parts. It is quite similar to the
+        * pattern above.
+        *
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public static $SPLIT_PATTERN_SHORTHANDSYNTAX_ARRAY_PARTS = '/
+               (?P<ArrayPart>                                             # Start submatch
+                       (?P<Key>[a-zA-Z0-9\-_]+)                               # The keys of the array
+                       \s*:\s*                                                   # Key|Value delimiter :
+                       (?:                                                       # Possible value options:
+                               "(?P<DoubleQuotedString>(?:\\\"|[^"])*)"              # Double qouoted string
+                               |\'(?P<SingleQuotedString>(?:\\\\\'|[^\'])*)\'        # Single quoted string
+                               |(?P<VariableIdentifier>[a-zA-Z][a-zA-Z0-9\-_.]*)    # variable identifiers have to start with a letter
+                               |(?P<Number>[0-9.]+)                                  # Number
+                               |{\s*(?P<Subarray>(?:(?P>ArrayPart)\s*,?\s*)+)\s*}              # Another sub-array
+                       )                                                         # END possible value options
+               )                                                          # End array part submatch
+       /x';
+
+       /**
+        * Namespace identifiers and their component name prefix (Associative array).
+        * @var array
+        */
+       protected $namespaces = array(
+               'f' => 'Tx_Fluid_ViewHelpers'
+       );
+
+       /**
+        * @var \Tx_Fluid_Compatibility_ObjectFactory
+        */
+       protected $objectFactory;
+
+       /**
+        * Constructor. Preprocesses the $SCAN_PATTERN_NAMESPACEDECLARATION by
+        * inserting the correct namespace separator.
+        *
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function __construct() {
+               self::$SCAN_PATTERN_NAMESPACEDECLARATION = str_replace('FLUID_NAMESPACE_SEPARATOR', preg_quote(Tx_Fluid_Fluid::NAMESPACE_SEPARATOR), self::$SCAN_PATTERN_NAMESPACEDECLARATION);
+       }
+
+       /**
+        * Inject object factory
+        *
+        * @param Tx_Fluid_Compatibility_ObjectFactory $objectFactory
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function injectObjectFactory(Tx_Fluid_Compatibility_ObjectFactory $objectFactory) {
+               $this->objectFactory = $objectFactory;
+       }
+
+       /**
+        * Parses a given template and returns a parsed template object.
+        *
+        * @param string $templateString The template to parse as a string
+        * @return Tx_Fluid_Core_Parser_ParsedTemplateInterface Parsed template
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @todo Refine doc comment
+        */
+       public function parse($templateString) {
+               if (!is_string($templateString)) throw new Tx_Fluid_Core_Parser_Exception('Parse requires a template string as argument, ' . gettype($templateString) . ' given.', 1224237899);
+
+               $this->initialize();
+
+               $templateString = $this->extractNamespaceDefinitions($templateString);
+               $splittedTemplate = $this->splitTemplateAtDynamicTags($templateString);
+               $parsingState = $this->buildMainObjectTree($splittedTemplate);
+
+               return $parsingState;
+       }
+
+       /**
+        * Gets the namespace definitions found.
+        *
+        * @return array Namespace identifiers and their component name prefix
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getNamespaces() {
+               return $this->namespaces;
+       }
+
+       /**
+        * Resets the parser to its default values.
+        *
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function initialize() {
+               $this->namespaces = array(
+                       'f' => 'Tx_Fluid_ViewHelpers'
+               );
+       }
+
+       /**
+        * Extracts namespace definitions out of the given template string and sets
+        * $this->namespaces.
+        *
+        * @param string $templateString Template string to extract the namespaces from
+        * @return string The updated template string without namespace declarations inside
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function extractNamespaceDefinitions($templateString) {
+               $matchedVariables = array();
+               if (preg_match_all(self::$SCAN_PATTERN_NAMESPACEDECLARATION, $templateString, $matchedVariables) > 0) {
+                       foreach (array_keys($matchedVariables[0]) as $index) {
+                               $namespaceIdentifier = $matchedVariables[1][$index];
+                               $fullyQualifiedNamespace = $matchedVariables[2][$index];
+                               if (key_exists($namespaceIdentifier, $this->namespaces)) {
+                                       throw new Tx_Fluid_Core_Parser_Exception('Namespace identifier "' . $namespaceIdentifier . '" is already registered. Do not redeclare namespaces!', 1224241246);
+                               }
+                               $this->namespaces[$namespaceIdentifier] = $fullyQualifiedNamespace;
+                       }
+
+                       $templateString = preg_replace(self::$SCAN_PATTERN_NAMESPACEDECLARATION, '', $templateString);
+               }
+               return $templateString;
+       }
+
+       /**
+        * Splits the template string on all dynamic tags found.
+        *
+        * @param string $templateString Template string to split.
+        * @return array Splitted template
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function splitTemplateAtDynamicTags($templateString) {
+               $regularExpression = $this->prepareTemplateRegularExpression(self::$SPLIT_PATTERN_TEMPLATE_DYNAMICTAGS);
+               return preg_split($regularExpression, $templateString, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
+       }
+
+       /**
+        * Build object tree from the splitted template
+        *
+        * @param array $splittedTemplate The splitted template, so that every tag with a namespace declaration is already a seperate array element.
+        * @return Tx_Fluid_Core_Parser_ParsingState
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function buildMainObjectTree($splittedTemplate) {
+               $regularExpression_openingViewHelperTag = $this->prepareTemplateRegularExpression(self::$SCAN_PATTERN_TEMPLATE_VIEWHELPERTAG);
+               $regularExpression_closingViewHelperTag = $this->prepareTemplateRegularExpression(self::$SCAN_PATTERN_TEMPLATE_CLOSINGVIEWHELPERTAG);
+
+               $state = $this->objectFactory->create('Tx_Fluid_Core_Parser_ParsingState');
+               $rootNode = $this->objectFactory->create('Tx_Fluid_Core_Parser_SyntaxTree_RootNode');
+               $state->setRootNode($rootNode);
+               $state->pushNodeToStack($rootNode);
+
+               foreach ($splittedTemplate as $templateElement) {
+                       $matchedVariables = array();
+                       if (preg_match(self::$SCAN_PATTERN_CDATA, $templateElement, $matchedVariables) > 0) {
+                               $this->textHandler($state, $matchedVariables[1]);
+                       } elseif (preg_match($regularExpression_openingViewHelperTag, $templateElement, $matchedVariables) > 0) {
+                               $namespaceIdentifier = $matchedVariables['NamespaceIdentifier'];
+                               $methodIdentifier = $matchedVariables['MethodIdentifier'];
+                               $selfclosing = $matchedVariables['Selfclosing'] === '' ? FALSE : TRUE;
+                               $arguments = $matchedVariables['Attributes'];
+
+                               $this->openingViewHelperTagHandler($state, $namespaceIdentifier, $methodIdentifier, $arguments, $selfclosing);
+                       } elseif (preg_match($regularExpression_closingViewHelperTag, $templateElement, $matchedVariables) > 0) {
+                               $namespaceIdentifier = $matchedVariables['NamespaceIdentifier'];
+                               $methodIdentifier = $matchedVariables['MethodIdentifier'];
+
+                               $this->closingViewHelperTagHandler($state, $namespaceIdentifier, $methodIdentifier);
+                       } else {
+                               $this->textAndShorthandSyntaxHandler($state, $templateElement);
+                       }
+               }
+
+               if ($state->countNodeStack() !== 1) {
+                       throw new Tx_Fluid_Core_Parser_Exception('Not all tags were closed!', 1238169398);
+               }
+               return $state;
+       }
+
+       /**
+        * Handles an opening or self-closing view helper tag.
+        *
+        * @param Tx_Fluid_Core_Parser_ParsingState $state Current parsing state
+        * @param string $namespaceIdentifier Namespace identifier - being looked up in $this->namespaces
+        * @param string $methodIdentifier Method identifier
+        * @param string $arguments Arguments string, not yet parsed
+        * @param boolean $selfclosing true, if the tag is a self-closing tag.
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function openingViewHelperTagHandler(Tx_Fluid_Core_Parser_ParsingState $state, $namespaceIdentifier, $methodIdentifier, $arguments, $selfclosing) {
+               $argumentsObjectTree = $this->parseArguments($arguments);
+               $this->initializeViewHelperAndAddItToStack($state, $namespaceIdentifier, $methodIdentifier, $argumentsObjectTree);
+
+               if ($selfclosing) {
+                       $state->popNodeFromStack();
+               }
+       }
+
+       /**
+        * Initialize the given ViewHelper and adds it to the current node and to
+        * the stack.
+        *
+        * @param Tx_Fluid_Core_Parser_ParsingState $state Current parsing state
+        * @param string $namespaceIdentifier Namespace identifier - being looked up in $this->namespaces
+        * @param string $methodIdentifier Method identifier
+        * @param array $argumentsObjectTree Arguments object tree
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function initializeViewHelperAndAddItToStack(Tx_Fluid_Core_Parser_ParsingState $state, $namespaceIdentifier, $methodIdentifier, $argumentsObjectTree) {
+               if (!array_key_exists($namespaceIdentifier, $this->namespaces)) {
+                       throw new Tx_Fluid_Core_Parser_Exception('Namespace could not be resolved. This exception should never be thrown!', 1224254792);
+               }
+
+               $viewHelperName = $this->resolveViewHelperName($namespaceIdentifier, $methodIdentifier);
+
+               $viewHelper = $this->objectFactory->create($viewHelperName);
+               $expectedViewHelperArguments = $viewHelper->prepareArguments();
+               $this->abortIfUnregisteredArgumentsExist($expectedViewHelperArguments, $argumentsObjectTree);
+               $this->abortIfRequiredArgumentsAreMissing($expectedViewHelperArguments, $argumentsObjectTree);
+
+               $currentDynamicNode = $this->objectFactory->create('Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode', $viewHelperName, $argumentsObjectTree);
+
+               $state->getNodeFromStack()->addChildNode($currentDynamicNode);
+
+                       // PostParse Facet
+               if (in_array('Tx_Fluid_Core_ViewHelper_Facets_PostParseInterface', class_implements($viewHelperName))) {
+                       call_user_func(array($viewHelperName, 'postParseEvent'), $currentDynamicNode, $argumentsObjectTree, $state->getVariableContainer());
+               }
+
+               $state->pushNodeToStack($currentDynamicNode);
+       }
+
+       /**
+        * Throw a ParsingException if there are arguments which were not registered
+        * before.
+        *
+        * @param array $expectedArguments Array of Tx_Fluid_Core_ViewHelper_ArgumentDefinition of all expected arguments
+        * @param array $actualArguments Actual arguments
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function abortIfUnregisteredArgumentsExist($expectedArguments, $actualArguments) {
+               $expectedArgumentNames = array();
+               foreach ($expectedArguments as $expectedArgument) {
+                       $expectedArgumentNames[] = $expectedArgument->getName();
+               }
+
+               foreach (array_keys($actualArguments) as $argumentName) {
+                       if (!in_array($argumentName, $expectedArgumentNames)) {
+                               throw new Tx_Fluid_Core_Parser_Exception('Argument "' . $argumentName . '" was not registered.', 1237823695);
+                       }
+               }
+       }
+
+       /**
+        * Throw a ParsingException if required arguments are missing
+        *
+        * @param array $expectedArguments Array of Tx_Fluid_Core_ViewHelper_ArgumentDefinition of all expected arguments
+        * @param array $actualArguments Actual arguments
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function abortIfRequiredArgumentsAreMissing($expectedArguments, $actualArguments) {
+               $actualArgumentNames = array_keys($actualArguments);
+               foreach ($expectedArguments as $expectedArgument) {
+                       if ($expectedArgument->isRequired() && !in_array($expectedArgument->getName(), $actualArgumentNames)) {
+                               throw new Tx_Fluid_Core_Parser_Exception('Required argument "' . $expectedArgument->getName() . '" was not supplied.', 1237823699);
+                       }
+               }
+       }
+
+       /**
+        * Resolve a view helper.
+        *
+        * @param string $namespaceIdentifier Namespace identifier for the view helper.
+        * @param string $methodIdentifier Method identifier, might be hierarchical like "link.url"
+        * @return array An Array where the first argument is the object to call the method on, and the second argument is the method name
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function resolveViewHelperName($namespaceIdentifier, $methodIdentifier) {
+               $explodedViewHelperName = explode('.', $methodIdentifier);
+               $className = '';
+               if (count($explodedViewHelperName) > 1) {
+                       $className = implode(Tx_Fluid_Fluid::NAMESPACE_SEPARATOR, array_map('ucfirst', $explodedViewHelperName));
+               } else {
+                       $className = ucfirst($explodedViewHelperName[0]);
+               }
+               $className .= 'ViewHelper';
+
+               $name = $this->namespaces[$namespaceIdentifier] . Tx_Fluid_Fluid::NAMESPACE_SEPARATOR . $className;
+
+               return $name;
+       }
+
+       /**
+        * Handles a closing view helper tag
+        *
+        * @param Tx_Fluid_Core_Parser_ParsingState $state The current parsing state
+        * @param string $namespaceIdentifier Namespace identifier for the closing tag.
+        * @param string $methodIdentifier Method identifier.
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function closingViewHelperTagHandler(Tx_Fluid_Core_Parser_ParsingState $state, $namespaceIdentifier, $methodIdentifier) {
+               if (!array_key_exists($namespaceIdentifier, $this->namespaces)) {
+                       throw new Tx_Fluid_Core_Parser_Exception('Namespace could not be resolved. This exception should never be thrown!', 1224256186);
+               }
+               $lastStackElement = $state->popNodeFromStack();
+               if (!($lastStackElement instanceof Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode)) {
+                       throw new Tx_Fluid_Core_Parser_Exception('You closed a templating tag which you never opened!', 1224485838);
+               }
+               if ($lastStackElement->getViewHelperClassName() != $this->resolveViewHelperName($namespaceIdentifier, $methodIdentifier)) {
+                       throw new Tx_Fluid_Core_Parser_Exception('Templating tags not properly nested. Expected: ' . $lastStackElement->getViewHelperClassName() . '; Actual: ' . $this->resolveViewHelperName($namespaceIdentifier, $methodIdentifier), 1224485398);
+               }
+       }
+
+       /**
+        * Handles the appearance of an object accessor (like {posts.author.email}).
+        * Creates a new instance of Tx_Fluid_ObjectAccessorNode.
+        *
+        * Handles ViewHelpers as well which are in the shorthand syntax.
+        *
+        * @param Tx_Fluid_Core_Parser_ParsingState $state The current parsing state
+        * @param string $objectAccessorString String which identifies which objects to fetch
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function objectAccessorHandler(Tx_Fluid_Core_Parser_ParsingState $state, $objectAccessorString, $delimiter, $viewHelperString, $additionalViewHelpersString) {
+               $viewHelperString .= $additionalViewHelpersString;
+               $numberOfViewHelpers = 0;
+
+                       // The following post-processing handles a case when there is only a ViewHelper, and no Object Accessor.
+                       // Resolves bug #5107.
+               if (strlen($delimiter) === 0 && strlen($viewHelperString) > 0) {
+                       $viewHelperString = $objectAccessorString . $viewHelperString;
+                       $objectAccessorString = '';
+               }
+
+                       // ViewHelpers
+               $matches = array();
+               if (strlen($viewHelperString) > 0 && preg_match_all(self::$SPLIT_PATTERN_SHORTHANDSYNTAX_VIEWHELPER, $viewHelperString, $matches, PREG_SET_ORDER) > 0) {
+                               // The last ViewHelper has to be added first for correct chaining.
+                       $matches = array_reverse($matches);
+                       foreach ($matches as $singleMatch) {
+                               $namespaceIdentifier = $singleMatch['NamespaceIdentifier'];
+                               $methodIdentifier = $singleMatch['MethodIdentifier'];
+                               if (strlen($singleMatch['ViewHelperArguments']) > 0) {
+                                       $arguments = $this->recursiveArrayHandler($singleMatch['ViewHelperArguments']);
+                                       $arguments = $this->postProcessArgumentsForObjectAccessor($arguments);
+                               } else {
+                                       $arguments = array();
+                               }
+                               $this->initializeViewHelperAndAddItToStack($state, $namespaceIdentifier, $methodIdentifier, $arguments);
+                               $numberOfViewHelpers++;
+                       }
+               }
+
+                       // Object Accessor
+               if (strlen($objectAccessorString) > 0) {
+                       $node = $this->objectFactory->create('Tx_Fluid_Core_Parser_SyntaxTree_ObjectAccessorNode', $objectAccessorString);
+                       $state->getNodeFromStack()->addChildNode($node);
+               }
+
+                       // Close ViewHelper Tags if needed.
+               for ($i=0; $i<$numberOfViewHelpers; $i++) {
+                       $state->popNodeFromStack();
+               }
+       }
+
+       /**
+        * Post process the arguments for the ViewHelpers in the object accessor
+        * syntax. We need to convert an array into an array of ViewHelper Nodes
+        *
+        * @param array $arguments The arguments to be processed
+        * @return array the processed array
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @todo This method should become superflous once the rest has been refactored, so that this code is not needed.
+        */
+       protected function postProcessArgumentsForObjectAccessor(array $arguments) {
+               foreach ($arguments as $argumentName => $argumentValue) {
+                       if (!($argumentValue instanceof Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode)) {
+                               $arguments[$argumentName] = $this->objectFactory->create('Tx_Fluid_Core_Parser_SyntaxTree_TextNode', (string)$argumentValue);
+                       }
+               }
+               return $arguments;
+       }
+
+       /**
+        * Parse arguments of a given tag, and build up the Arguments Object Tree
+        * for each argument.
+        * Returns an associative array, where the key is the name of the argument,
+        * and the value is a single Argument Object Tree.
+        *
+        * @param string $argumentsString All arguments as string
+        * @return array An associative array of objects, where the key is the argument name.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function parseArguments($argumentsString) {
+               $argumentsObjectTree = array();
+               $matches = array();
+               if (preg_match_all(self::$SPLIT_PATTERN_TAGARGUMENTS, $argumentsString, $matches, PREG_SET_ORDER) > 0) {
+                       foreach ($matches as $singleMatch) {
+                               $argument = $singleMatch['Argument'];
+                               if (!array_key_exists('ValueSingleQuoted', $singleMatch)) $singleMatch['ValueSingleQuoted'] = '';
+                               if (!array_key_exists('ValueDoubleQuoted', $singleMatch)) $singleMatch['ValueDoubleQuoted'] = '';
+
+                               $value = $this->unquoteArgumentString($singleMatch['ValueSingleQuoted'], $singleMatch['ValueDoubleQuoted']);
+                               $argumentsObjectTree[$argument] = $this->buildArgumentObjectTree($value);
+                       }
+               }
+               return $argumentsObjectTree;
+       }
+
+       /**
+        * Build up an argument object tree for the string in $argumentString.
+        * This builds up the tree for a single argument value.
+        *
+        * This method also does some performance optimizations, so in case
+        * no { or < is found, then we just return a TextNode.
+        *
+        * @param string $argumentString
+        * @return ArgumentObject the corresponding argument object tree.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function buildArgumentObjectTree($argumentString) {
+               if (strstr($argumentString, '{') === FALSE && strstr($argumentString, '<') === FALSE) {
+                       return $this->objectFactory->create('Tx_Fluid_Core_Parser_SyntaxTree_TextNode', $argumentString);
+               }
+               $splittedArgument = $this->splitTemplateAtDynamicTags($argumentString);
+               $rootNode = $this->buildMainObjectTree($splittedArgument)->getRootNode();
+               return $rootNode;
+       }
+
+       /**
+        * Removes escapings from a given argument string. Expects two string
+        * parameters, with one of them being empty.
+        * The first parameter should be non-empty if the argument was quoted by
+        * single quotes, and the second parameter should be non-empty if the
+        * argument was quoted by double quotes.
+        *
+        * This method is meant as a helper for regular expression results.
+        *
+        * @param string $singleQuotedValue Value, if quoted by single quotes
+        * @param string $doubleQuotedValue Value, if quoted by double quotes
+        * @return string Unquoted value
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function unquoteArgumentString($singleQuotedValue, $doubleQuotedValue) {
+               if ($singleQuotedValue != '') {
+                       $value = str_replace("\\'", "'", $singleQuotedValue);
+               } else {
+                       $value = str_replace('\"', '"', $doubleQuotedValue);
+               }
+               return str_replace('\\\\', '\\', $value);
+       }
+
+       /**
+        * Takes a regular expression template and replaces "NAMESPACE" with the
+        * currently registered namespace identifiers. Returns a regular expression
+        * which is ready to use.
+        *
+        * @param string $regularExpression Regular expression template
+        * @return string Regular expression ready to be used
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function prepareTemplateRegularExpression($regularExpression) {
+               return str_replace('NAMESPACE', implode('|', array_keys($this->namespaces)), $regularExpression);
+       }
+
+       /**
+        * Handler for everything which is not a ViewHelperNode.
+        *
+        * This includes Text, array syntax, and object accessor syntax.
+        *
+        * @param Tx_Fluid_Core_Parser_ParsingState $state Current parsing state
+        * @param string $text Text to process
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function textAndShorthandSyntaxHandler(Tx_Fluid_Core_Parser_ParsingState $state, $text) {
+               $sections = preg_split($this->prepareTemplateRegularExpression(self::$SPLIT_PATTERN_SHORTHANDSYNTAX), $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
+
+               foreach ($sections as $section) {
+                       $matchedVariables = array();
+                       if (preg_match(self::$SCAN_PATTERN_SHORTHANDSYNTAX_OBJECTACCESSORS, $section, $matchedVariables) > 0) {
+                               $this->objectAccessorHandler($state, $matchedVariables['Object'], $matchedVariables['Delimiter'], (isset($matchedVariables['ViewHelper'])?$matchedVariables['ViewHelper']:''), (isset($matchedVariables['AdditionalViewHelpers'])?$matchedVariables['AdditionalViewHelpers']:''));
+                       } elseif (preg_match(self::$SCAN_PATTERN_SHORTHANDSYNTAX_ARRAYS, $section, $matchedVariables) > 0) {
+                               $this->arrayHandler($state, $matchedVariables['Array']);
+                       } else {
+                               $this->textHandler($state, $section);
+                       }
+               }
+       }
+
+       /**
+        * Handler for array syntax. This creates the array object recursively and
+        * adds it to the current node.
+        *
+        * @param Tx_Fluid_Core_Parser_ParsingState $state The current parsing state
+        * @param string $arrayText The array as string.
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function arrayHandler(Tx_Fluid_Core_Parser_ParsingState $state, $arrayText) {
+               $node = $this->objectFactory->create('Tx_Fluid_Core_Parser_SyntaxTree_ArrayNode', $this->recursiveArrayHandler($arrayText));
+               $state->getNodeFromStack()->addChildNode($node);
+       }
+
+       /**
+        * Recursive function which takes the string representation of an array and
+        * builds an object tree from it.
+        *
+        * Deals with the following value types:
+        * - Numbers (Integers and Floats)
+        * - Strings
+        * - Variables
+        * - sub-arrays
+        *
+        * @param string $arrayText Array text
+        * @return Tx_Fluid_ArrayNode the array node built up
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function recursiveArrayHandler($arrayText) {
+               $matches = array();
+               if (preg_match_all(self::$SPLIT_PATTERN_SHORTHANDSYNTAX_ARRAY_PARTS, $arrayText, $matches, PREG_SET_ORDER) > 0) {
+                       $arrayToBuild = array();
+                       foreach ($matches as $singleMatch) {
+                               $arrayKey = $singleMatch['Key'];
+                               if (!empty($singleMatch['VariableIdentifier'])) {
+                                       $arrayToBuild[$arrayKey] = $this->objectFactory->create('Tx_Fluid_Core_Parser_SyntaxTree_ObjectAccessorNode', $singleMatch['VariableIdentifier']);
+                               } elseif (array_key_exists('Number', $singleMatch) && ( !empty($singleMatch['Number']) || $singleMatch['Number'] === '0' ) ) {
+                                       $arrayToBuild[$arrayKey] = floatval($singleMatch['Number']);
+                               } elseif ( ( array_key_exists('DoubleQuotedString', $singleMatch) && !empty($singleMatch['DoubleQuotedString']) )
+                                                       || ( array_key_exists('SingleQuotedString', $singleMatch) && !empty($singleMatch['SingleQuotedString']) ) ) {
+                                       if (!array_key_exists('SingleQuotedString', $singleMatch)) $singleMatch['SingleQuotedString'] = '';
+                                       if (!array_key_exists('DoubleQuotedString', $singleMatch)) $singleMatch['DoubleQuotedString'] = '';
+                                       $argumentString = $this->unquoteArgumentString($singleMatch['SingleQuotedString'], $singleMatch['DoubleQuotedString']);
+                                       $arrayToBuild[$arrayKey] = $this->buildArgumentObjectTree($argumentString);
+                               } elseif ( array_key_exists('Subarray', $singleMatch) && !empty($singleMatch['Subarray'])) {
+                                       $arrayToBuild[$arrayKey] = $this->objectFactory->create('Tx_Fluid_Core_Parser_SyntaxTree_ArrayNode', $this->recursiveArrayHandler($singleMatch['Subarray']));
+                               } else {
+                                       throw new Tx_Fluid_Core_Parser_Exception('This exception should never be thrown, as the array value has to be of some type (Value given: "' . var_export($singleMatch, TRUE) . '"). Please post your template to the bugtracker at forge.typo3.org.', 1225136013);
+                               }
+                       }
+                       return $arrayToBuild;
+               } else {
+                       throw new Tx_Fluid_Core_Parser_Exception('This exception should never be thrown, there is most likely some error in the regular expressions. Please post your template to the bugtracker at forge.typo3.org.', 1225136013);
+               }
+       }
+
+       /**
+        * Text node handler
+        *
+        * @param Tx_Fluid_Core_Parser_ParsingState $state
+        * @param string $text
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function textHandler(Tx_Fluid_Core_Parser_ParsingState $state, $text) {
+               $node = $this->objectFactory->create('Tx_Fluid_Core_Parser_SyntaxTree_TextNode', $text);
+               $state->getNodeFromStack()->addChildNode($node);
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Rendering/HTMLSpecialCharsPostProcessor.php b/typo3/sysext/fluid/Classes/Core/Rendering/HTMLSpecialCharsPostProcessor.php
new file mode 100644 (file)
index 0000000..f8fd6a8
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ *
+ *
+ * @version $Id: HTMLSpecialCharsPostProcessor.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\Rendering
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class Tx_Fluid_Core_Rendering_HtmlSpecialCharsPostProcessor implements Tx_Fluid_Core_Rendering_ObjectAccessorPostProcessorInterface {
+
+       /**
+        * Process an Object Accessor by wrapping it into HTML.
+        * NOT part of public API.
+        *
+        * @param mixed $object the object that is currently rendered
+        * @param boolean $enabled TRUE if post processing is currently enabled.
+        * @return mixed $object the original object. If not within arguments and of type string, the value is htmlspecialchar'ed
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function process($object, $enabled) {
+               if ($enabled === TRUE && is_string($object)) {
+                       return htmlspecialchars($object);
+               }
+               return $object;
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Rendering/ObjectAccessorPostProcessorInterface.php b/typo3/sysext/fluid/Classes/Core/Rendering/ObjectAccessorPostProcessorInterface.php
new file mode 100644 (file)
index 0000000..34c54ce
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ *
+ *
+ * @version $Id: ObjectAccessorPostProcessorInterface.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\Rendering
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+interface Tx_Fluid_Core_Rendering_ObjectAccessorPostProcessorInterface {
+
+       /**
+        * Post-Process an Object Accessor
+        *
+        * @param mixed $object the object that is currently rendered
+        * @param boolean $enabled TRUE if post processing is currently enabled.
+        * @return mixed $object the original object. If not within arguments and of type string, the value is htmlspecialchar'ed
+        */
+       public function process($object, $enabled);
+
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Rendering/RenderingConfiguration.php b/typo3/sysext/fluid/Classes/Core/Rendering/RenderingConfiguration.php
new file mode 100644 (file)
index 0000000..69d042b
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * The rendering configuration. Contains all configuration needed to configure the rendering of a SyntaxTree.
+ * This currently contains:
+ * - the active ObjectAccessorPostProcessor, if any
+ *
+ * @version $Id: RenderingConfiguration.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\Rendering
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class Tx_Fluid_Core_Rendering_RenderingConfiguration {
+
+       /**
+        * Object accessor post processor to use
+        * @var Tx_Fluid_Core_Rendering_ObjectAccessorPostProcessorInterface
+        */
+       protected $objectAccessorPostProcessor;
+
+       /**
+        * Set the Object accessor post processor
+        *
+        * @param Tx_Fluid_Core_Rendering_ObjectAccessorPostProcessorInterface $objectAccessorPostProcessor The ObjectAccessorPostProcessor to set
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setObjectAccessorPostProcessor(Tx_Fluid_Core_Rendering_ObjectAccessorPostProcessorInterface $objectAccessorPostProcessor) {
+               $this->objectAccessorPostProcessor = $objectAccessorPostProcessor;
+       }
+
+       /**
+        * Get the currently set ObjectAccessorPostProcessor
+        *
+        * @return Tx_Fluid_Core_Rendering_ObjectAccessorPostProcessorInterface The currently set ObjectAccessorPostProcessor, or NULL if none set.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getObjectAccessorPostProcessor() {
+               return $this->objectAccessorPostProcessor;
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/Rendering/RenderingContext.php b/typo3/sysext/fluid/Classes/Core/Rendering/RenderingContext.php
new file mode 100644 (file)
index 0000000..1c5f169
--- /dev/null
@@ -0,0 +1,195 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ *
+ *
+ * @version $Id: RenderingContext.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\Rendering
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class Tx_Fluid_Core_Rendering_RenderingContext {
+
+       /**
+        * Template Variable Container. Contains all variables available through object accessors in the template
+        * @var Tx_Fluid_Core_ViewHelper_TemplateVariableContainer
+        */
+       protected $templateVariableContainer;
+
+       /**
+        * Object factory which is bubbled through. The ViewHelperNode cannot get an ObjectFactory injected because
+        * the whole syntax tree should be cacheable
+        * @var Tx_Fluid_Compatibility_ObjectFactory
+        */
+       protected $objectFactory;
+
+       /**
+        * Controller context being passed to the ViewHelper
+        * @var Tx_Extbase_MVC_Controller_ControllerContext
+        */
+       protected $controllerContext;
+
+       /**
+        * Rendering Context
+        * @var Tx_Fluid_Core_Rendering_RenderingConfiguration
+        */
+       protected $renderingConfiguration;
+
+       /**
+        * ViewHelper Variable Container
+        * @var Tx_Fluid_Core_ViewHelpers_ViewHelperVariableContainer
+        */
+       protected $viewHelperVariableContainer;
+
+       /**
+        * TRUE if the arguments of a ViewHelper are currently evaluated
+        * @var boolean
+        */
+       protected $objectAccessorPostProcessorEnabled = TRUE;
+
+       /**
+        * Inject the object factory
+        *
+        * @param Tx_Fluid_Compatibility_ObjectFactory $objectFactory
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function injectObjectFactory(Tx_Fluid_Compatibility_ObjectFactory $objectFactory) {
+               $this->objectFactory = $objectFactory;
+       }
+
+       /**
+        * Returns the object factory. Only the ViewHelperNode should do this.
+        *
+        * @param Tx_Fluid_Compatibility_ObjectFactory $objectFactory
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getObjectFactory() {
+               return $this->objectFactory;
+       }
+
+       /**
+        * Sets the template variable container containing all variables available through ObjectAccessors
+        * in the template
+        *
+        * @param Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $templateVariableContainer The template variable container to set
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setTemplateVariableContainer(Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $templateVariableContainer) {
+               $this->templateVariableContainer = $templateVariableContainer;
+       }
+
+       /**
+        * Get the template variable container
+        *
+        * @return Tx_Fluid_Core_ViewHelper_TemplateVariableContainer The Template Variable Container
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getTemplateVariableContainer() {
+               return $this->templateVariableContainer;
+       }
+
+       /**
+        * Set the controller context which will be passed to the ViewHelper
+        *
+        * @param Tx_Extbase_MVC_Controller_ControllerContext $controllerContext The controller context to set
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setControllerContext(Tx_Extbase_MVC_Controller_ControllerContext $controllerContext) {
+               $this->controllerContext = $controllerContext;
+       }
+
+       /**
+        * Get the controller context which will be passed to the ViewHelper
+        *
+        * @return Tx_Extbase_MVC_Controller_ControllerContext The controller context to set
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getControllerContext() {
+               return $this->controllerContext;
+       }
+
+       /**
+        * Set the rendering configuration for the current rendering process
+        *
+        * @param Tx_Fluid_Core_Rendering_RenderingConfiguration $renderingConfiguration The Rendering Configuration to be set
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setRenderingConfiguration(Tx_Fluid_Core_Rendering_RenderingConfiguration $renderingConfiguration) {
+               $this->renderingConfiguration = $renderingConfiguration;
+       }
+
+       /**
+        * Get the current rendering configuration
+        *
+        * @return Tx_Fluid_Core_Rendering_RenderingConfiguration The rendering configuration currently active
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getRenderingConfiguration() {
+               return $this->renderingConfiguration;
+       }
+
+       /**
+        * Set the argument evaluation mode. Should be set to TRUE if the arguments are currently being parsed.
+        * FALSE if we do not parse arguments currently
+        *
+        * @param boolean $objectAccessorPostProcessorEnabled Argument evaluation mode to be set
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setObjectAccessorPostProcessorEnabled($objectAccessorPostProcessorEnabled) {
+               $this->objectAccessorPostProcessorEnabled = (boolean)$objectAccessorPostProcessorEnabled;
+       }
+
+       /**
+        * if TRUE, then we are currently in Argument Evaluation mode. False otherwise.
+        * Is used to make sure that ObjectAccessors are PostProcessed if we are NOT in Argument Evaluation Mode
+        *
+        * @return boolean TRUE if we are currently evaluating arguments, FALSE otherwise
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function isObjectAccessorPostProcessorEnabled() {
+               return $this->objectAccessorPostProcessorEnabled;
+       }
+
+       /**
+        * Set the ViewHelperVariableContainer
+        *
+        * @param Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer $viewHelperVariableContainer
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setViewHelperVariableContainer(Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer $viewHelperVariableContainer) {
+               $this->viewHelperVariableContainer = $viewHelperVariableContainer;
+       }
+
+       /**
+        * Get the ViewHelperVariableContainer
+        *
+        * @return Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getViewHelperVariableContainer() {
+               return $this->viewHelperVariableContainer;
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/RuntimeException.php b/typo3/sysext/fluid/Classes/Core/RuntimeException.php
new file mode 100644 (file)
index 0000000..a025bb4
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * A Runtime Exception
+ *
+ * @version $Id: RuntimeException.php 1734 2009-11-25 21:53:57Z stucki $
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @internal
+ */
+class Tx_Fluid_Core_RuntimeException extends Tx_Fluid_Core_Exception {
+}
+?>
diff --git a/typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractViewHelper.php b/typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractViewHelper.php
new file mode 100644 (file)
index 0000000..b157416
--- /dev/null
@@ -0,0 +1,337 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * The abstract base class for all view helpers.
+ *
+ * @version $Id: AbstractViewHelper.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\ViewHelper
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ * @scope prototype
+ */
+abstract class Tx_Fluid_Core_ViewHelper_AbstractViewHelper implements Tx_Fluid_Core_ViewHelper_ViewHelperInterface {
+
+       /**
+        * TRUE if arguments have already been initialized
+        * @var boolean
+        */
+       private $argumentsInitialized = FALSE;
+
+       /**
+        * Stores all Tx_Fluid_ArgumentDefinition instances
+        * @var array
+        */
+       private $argumentDefinitions = array();
+
+       /**
+        * Current view helper node
+        * @var Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode
+        */
+       private $viewHelperNode;
+
+       /**
+        * Arguments accessor.
+        * @var Tx_Fluid_Core_ViewHelper_Arguments
+        * @api
+        */
+       protected $arguments;
+
+       /**
+        * Current variable container reference.
+        * @var Tx_Fluid_Core_ViewHelper_TemplateVariableContainer
+        * @api
+        */
+       protected $templateVariableContainer;
+
+       /**
+        * Controller Context to use
+        * @var Tx_Extbase_MVC_Controller_ControllerContext
+        * @api
+        */
+       protected $controllerContext;
+
+       /**
+        * ViewHelper Variable Container
+        * @var Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer
+        * @api
+        */
+       protected $viewHelperVariableContainer;
+
+       /**
+        * If the ObjectAccessorPostProcessor should be disabled inside this ViewHelper, then set this value to FALSE.
+        * This is internal and NO part of the API. It is very likely to change.
+        *
+        * @var boolean
+        */
+       protected $objectAccessorPostProcessorEnabled = TRUE;
+
+       /**
+        * Reflection service
+        * @var Tx_Extbase_Reflection_Service
+        */
+       private $reflectionService;
+
+       /**
+        * @param Tx_Fluid_Core_ViewHelper_Arguments $arguments
+        * @return void
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function setArguments(Tx_Fluid_Core_ViewHelper_Arguments $arguments) {
+               $this->arguments = $arguments;
+       }
+
+       /**
+        * @param Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $templateVariableContainer Variable Container to be used for rendering
+        * @return void
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function setTemplateVariableContainer(Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $templateVariableContainer) {
+               $this->templateVariableContainer = $templateVariableContainer;
+       }
+
+       /**
+        * @param Tx_Extbase_MVC_Controller_ControllerContext $controllerContext Controller context which is available inside the view
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setControllerContext(Tx_Extbase_MVC_Controller_ControllerContext $controllerContext) {
+               $this->controllerContext = $controllerContext;
+       }
+
+       /**
+        * @param Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer $viewHelperVariableContainer
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setViewHelperVariableContainer(Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer $viewHelperVariableContainer) {
+               $this->viewHelperVariableContainer = $viewHelperVariableContainer;
+       }
+
+       /**
+        * Inject a Reflection service
+        * @param Tx_Extbase_Reflection_Service $reflectionService Reflection service
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function injectReflectionService(Tx_Extbase_Reflection_Service $reflectionService) {
+               $this->reflectionService = $reflectionService;
+       }
+
+       /**
+        * Returns TRUE if the object accessor post processor should be disabled inside this ViewHelper.
+        * This is internal and NO part of the API. It is very likely to change.
+        *
+        * @return boolean TRUE if Object accessor post processor is enabled, FALSE if disabled
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function isObjectAccessorPostProcessorEnabled() {
+               return $this->objectAccessorPostProcessorEnabled;
+       }
+
+       /**
+        * Register a new argument. Call this method from your ViewHelper subclass
+        * inside the initializeArguments() method.
+        *
+        * @param string $name Name of the argument
+        * @param string $type Type of the argument
+        * @param string $description Description of the argument
+        * @param boolean $required If TRUE, argument is required. Defaults to FALSE.
+        * @param mixed $defaultValue Default value of argument
+        * @return Tx_Fluid_Core_ViewHelper_AbstractViewHelper $this, to allow chaining.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @todo Object Factory usage!
+        * @api
+        */
+       protected function registerArgument($name, $type, $description, $required = FALSE, $defaultValue = NULL) {
+               if (array_key_exists($name, $this->argumentDefinitions)) {
+                       throw new Tx_Fluid_Core_ViewHelper_Exception('Argument "' . $name . '" has already been defined, thus it should not be defined again.', 1253036401);
+               }
+               $this->argumentDefinitions[$name] = new Tx_Fluid_Core_ViewHelper_ArgumentDefinition($name, $type, $description, $required, $defaultValue);
+               return $this;
+       }
+
+       /**
+        * Sets all needed attributes needed for the rendering. Called by the
+        * framework. Populates $this->viewHelperNode.
+        * This is PURELY INTERNAL! Never override this method!!
+        *
+        * @param Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode $node View Helper node to be set.
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setViewHelperNode(Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode $node) {
+               $this->viewHelperNode = $node;
+       }
+
+       /**
+        * Initializes the view helper before invoking the render method.
+        *
+        * Override this method to solve tasks before the view helper content is rendered.
+        *
+        * @return void
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function initialize() {
+       }
+
+       /**
+        * Helper method which triggers the rendering of everything between the
+        * opening and the closing tag.
+        *
+        * @return mixed The finally rendered child nodes.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       protected function renderChildren() {
+               return $this->viewHelperNode->evaluateChildNodes();
+       }
+
+       /**
+        * Initialize all arguments and return them
+        *
+        * @return array Array of Tx_Fluid_Core_ViewHelper_ArgumentDefinition instances.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function prepareArguments() {
+               if (!$this->argumentsInitialized) {
+                       $this->registerRenderMethodArguments();
+                       $this->initializeArguments();
+                       $this->argumentsInitialized = TRUE;
+               }
+               return $this->argumentDefinitions;
+       }
+
+       /**
+        * Register method arguments for "render" by analysing the doc comment above.
+        *
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       private function registerRenderMethodArguments() {
+               $methodParameters = $this->reflectionService->getMethodParameters(get_class($this), 'render');
+               if (count($methodParameters) === 0) {
+                       return;
+               }
+
+               if (Tx_Fluid_Fluid::$debugMode) {
+                       $methodTags = $this->reflectionService->getMethodTagsValues(get_class($this), 'render');
+
+                       $paramAnnotations = array();
+                       if (isset($methodTags['param'])) {
+                               $paramAnnotations = $methodTags['param'];
+                       }
+               }
+
+               $i = 0;
+               foreach ($methodParameters as $parameterName => $parameterInfo) {
+                       $dataType = NULL;
+                       if (isset($parameterInfo['type'])) {
+                               $dataType = $parameterInfo['type'];
+                       } elseif ($parameterInfo['array']) {
+                               $dataType = 'array';
+                       }
+                       if ($dataType === NULL) {
+                               throw new Tx_Fluid_Core_Parser_Exception('could not determine type of argument "' . $parameterName .'" of the render-method in ViewHelper "' . get_class($this) . '". Either the methods docComment is invalid or some PHP optimizer strips off comments.', 1242292003);
+                       }
+
+                       $description = '';
+                       if (Tx_Fluid_Fluid::$debugMode && isset($paramAnnotations[$i])) {
+                               $explodedAnnotation = explode(' ', $paramAnnotations[$i]);
+                               array_shift($explodedAnnotation);
+                               array_shift($explodedAnnotation);
+                               $description = implode(' ', $explodedAnnotation);
+                       }
+                       $defaultValue = NULL;
+                       if (isset($parameterInfo['defaultValue'])) {
+                               $defaultValue = $parameterInfo['defaultValue'];
+                       }
+                       $this->argumentDefinitions[$parameterName] = new Tx_Fluid_Core_ViewHelper_ArgumentDefinition($parameterName, $dataType, $description, ($parameterInfo['optional'] === FALSE), $defaultValue, TRUE);
+                       $i++;
+               }
+       }
+
+       /**
+        * Validate arguments, and throw exception if arguments do not validate.
+        *
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function validateArguments() {
+               $argumentDefinitions = $this->prepareArguments();
+               if (!count($argumentDefinitions)) return;
+
+               foreach ($argumentDefinitions as $argumentName => $registeredArgument) {
+                       if ($this->arguments->offsetExists($argumentName)) {
+                               $type = $registeredArgument->getType();
+                               if ($this->arguments[$argumentName] === $registeredArgument->getDefaultValue()) continue;
+
+                               if ($type === 'array') {
+                                       if (!is_array($this->arguments[$argumentName]) && !$this->arguments[$argumentName] instanceof ArrayAccess && !$this->arguments[$argumentName] instanceof Traversable) {
+                                               throw new RuntimeException('The argument "' . $argumentName . '" was registered with type "array", but is of type "' . gettype($this->arguments[$argumentName]) . '" in view helper "' . get_class($this) . '". Value of argument: "' . strval($this->arguments[$argumentName]) . '"', 1237900529);
+                                       }
+                               } elseif ($type === 'boolean') {
+                                       if (!is_bool($this->arguments[$argumentName])) {
+                                               throw new RuntimeException('The argument "' . $argumentName . '" was registered with type "boolean", but is of type "' . gettype($this->arguments[$argumentName]) . '" in view helper "' . get_class($this) . '".', 1240227732);
+                                       }
+                               } elseif (class_exists($type)) {
+                                       if (! ($this->arguments[$argumentName] instanceof $type)) {
+                                               if (is_object($this->arguments[$argumentName])) {
+                                                       throw new RuntimeException('The argument "' . $argumentName . '" was registered with type "' . $type . '", but is of type "' . get_class($this->arguments[$argumentName]) . '" in view helper "' . get_class($this) . '".', 1256475114);
+                                               } else {
+                                                       throw new RuntimeException('The argument "' . $argumentName . '" was registered with type "' . $type . '", but is of type "' . gettype($this->arguments[$argumentName]) . '" in view helper "' . get_class($this) . '".', 1256475113);
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Initialize all arguments. You need to override this method and call
+        * $this->registerArgument(...) inside this method, to register all your arguments.
+        *
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function initializeArguments() {
+       }
+
+       /**
+        * Render method you need to implement for your custom view helper.
+        * Available objects at this point are $this->arguments, and $this->templateVariableContainer.
+        *
+        * Besides, you often need $this->renderChildren().
+        *
+        * @return string rendered string, view helper specific
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       //abstract public function render();
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/ViewHelper/ArgumentDefinition.php b/typo3/sysext/fluid/Classes/Core/ViewHelper/ArgumentDefinition.php
new file mode 100644 (file)
index 0000000..abb5081
--- /dev/null
@@ -0,0 +1,150 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Argument definition of each view helper argument
+ *
+ * @version $Id: ArgumentDefinition.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\ViewHelper
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class Tx_Fluid_Core_ViewHelper_ArgumentDefinition {
+
+       /**
+        * Name of argument
+        * @var string
+        */
+       protected $name;
+
+       /**
+        * Type of argument
+        * @var string
+        */
+       protected $type;
+
+       /**
+        * Description of argument
+        * @var string
+        */
+       protected $description;
+
+       /**
+        * Is argument required?
+        * @var boolean
+        */
+       protected $required = FALSE;
+
+       /**
+        * Default value for argument
+        * @var mixed
+        */
+       protected $defaultValue = NULL;
+
+       /**
+        * TRUE if it is a method parameter
+        * @var boolean
+        */
+       protected $isMethodParameter = FALSE;
+
+       /**
+        * Constructor for this argument definition.
+        *
+        * @param string $name Name of argument
+        * @param string $type Type of argument
+        * @param string $description Description of argument
+        * @param boolean $required TRUE if argument is required
+        * @param mixed $defaultValue Default value
+        * @param boolean $isMethodParameter TRUE if this argument is a method parameter
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function __construct($name, $type, $description, $required, $defaultValue = NULL, $isMethodParameter = FALSE) {
+               $this->name = $name;
+               $this->type = $type;
+               $this->description = $description;
+               $this->required = $required;
+               $this->defaultValue = $defaultValue;
+               $this->isMethodParameter = $isMethodParameter;
+       }
+
+       /**
+        * Get the name of the argument
+        *
+        * @return string Name of argument
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getName() {
+               return $this->name;
+       }
+
+       /**
+        * Get the type of the argument
+        *
+        * @return string Type of argument
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getType() {
+               return $this->type;
+       }
+
+       /**
+        * Get the description of the argument
+        *
+        * @return string Description of argument
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getDescription() {
+               return $this->description;
+       }
+
+       /**
+        * Get the optionality of the argument
+        *
+        * @return boolean TRUE if argument is optional
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function isRequired() {
+               return $this->required;
+       }
+
+       /**
+        * Get the default value, if set
+        *
+        * @return mixed Default value
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getDefaultValue() {
+               return $this->defaultValue;
+       }
+
+       /**
+        * TRUE if it is a method parameter
+        *
+        * @return boolean TRUE if it's a method parameter
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function isMethodParameter() {
+               return $this->isMethodParameter;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/ViewHelper/Arguments.php b/typo3/sysext/fluid/Classes/Core/ViewHelper/Arguments.php
new file mode 100644 (file)
index 0000000..0c844b6
--- /dev/null
@@ -0,0 +1,112 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Arguments list. Wraps an array, but only allows read-only methods on it.
+ * Is available inside every view helper as $this->arguments - and you use it as if it was an array.
+ * However, you can only read, and not write to it.
+ *
+ * @version $Id: Arguments.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\ViewHelper
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ * @scope prototype
+ */
+class Tx_Fluid_Core_ViewHelper_Arguments implements ArrayAccess {
+
+       /**
+        * Array storing the arguments themselves
+        */
+       protected $arguments = array();
+
+       /**
+        * Constructor.
+        *
+        * @param array $arguments Array of arguments
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function __construct(array $arguments) {
+               $this->arguments = $arguments;
+       }
+
+       /**
+        * Checks if a given key exists in the array
+        *
+        * @param string $key Key to check
+        * @return boolean true if exists
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function offsetExists($key) {
+               return array_key_exists($key, $this->arguments);
+       }
+
+       /**
+        * Returns the value to the given key.
+        *
+        * @param string $key Key to get.
+        * @return object associated value
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function offsetGet($key) {
+               if (!array_key_exists($key, $this->arguments)) {
+                       return NULL;
+               }
+
+               return $this->arguments[$key];
+       }
+
+       /**
+        * Throw exception if you try to set a value.
+        *
+        * @param string $key
+        * @param object $value
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function offsetSet($key, $value) {
+               throw new RuntimeException('Tried to set argument "' . $key . '", but setting arguments is forbidden.', 1236080693);
+       }
+
+       /**
+        * Throw exception if you try to unset a value.
+        *
+        * @param string $key
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function offsetUnset($key) {
+               throw new RuntimeException('Tried to unset argument "' . $key . '", but setting arguments is forbidden.', 1236080702);
+       }
+
+       /**
+        * Checks if an argument with the specified name exists
+        *
+        * @param string $argumentName Name of the argument to check for
+        * @return boolean TRUE if such an argument exists, otherwise FALSE
+        * @see offsetExists()
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function hasArgument($argumentName) {
+               return $this->offsetExists($argumentName) && $this->arguments[$argumentName] !== NULL;
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/ViewHelper/Exception.php b/typo3/sysext/fluid/Classes/Core/ViewHelper/Exception.php
new file mode 100644 (file)
index 0000000..b3947b5
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * A ViewHelper Exception
+ *
+ * @version $Id: Exception.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\ViewHelper
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ */
+class Tx_Fluid_Core_ViewHelper_Exception extends Tx_Fluid_Core_Exception {
+}
+?>
diff --git a/typo3/sysext/fluid/Classes/Core/ViewHelper/Facets/ChildNodeAccessInterface.php b/typo3/sysext/fluid/Classes/Core/ViewHelper/Facets/ChildNodeAccessInterface.php
new file mode 100644 (file)
index 0000000..dc2fee5
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Child Node Access Facet. View Helpers should implement this interface if they
+ * need access to the direct children in the Syntax Tree at rendering-time.
+ * This might happen if you only want to selectively render a part of the syntax
+ * tree depending on some conditions.
+ *
+ * In most cases, you will not need this view helper.
+ *
+ * See Tx_Fluid_ViewHelpers_IfViewHelper for an example how it is used.
+ *
+ * @version $Id: ChildNodeAccessInterface.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\ViewHelper\Facets
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+interface Tx_Fluid_Core_ViewHelper_Facets_ChildNodeAccessInterface {
+
+       /**
+        * Sets the direct child nodes of the current syntax tree node.
+        *
+        * @param array<Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode> $childNodes
+        * @return void
+        */
+       public function setChildNodes(array $childNodes);
+
+       /**
+        * Sets the rendering context which needs to be passed on to child nodes
+        *
+        * @param Tx_Fluid_Core_Rendering_RenderingContext $renderingContext the renderingcontext to use
+        * @return void
+        */
+       public function setRenderingContext(Tx_Fluid_Core_Rendering_RenderingContext $renderingContext);
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/ViewHelper/Facets/PostParseInterface.php b/typo3/sysext/fluid/Classes/Core/ViewHelper/Facets/PostParseInterface.php
new file mode 100644 (file)
index 0000000..18c1088
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Post Parse Facet. Your view helper should implement this if you want a callback
+ * to be called directly after the syntax tree node corresponding to this view
+ * helper has been built.
+ *
+ * In the callback, it is possible to store some variables inside the
+ * parseVariableContainer (which is different from the runtime variable container!).
+ * This implicates that you usually have to adjust the Tx_Fluid_View_TemplateView
+ * in case you implement this facet.
+ *
+ * Normally, this facet is not needed, except in really really rare cases.
+ *
+ * @version $Id: PostParseInterface.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\ViewHelper\Facets
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+interface Tx_Fluid_Core_ViewHelper_Facets_PostParseInterface {
+
+       /**
+        * Callback which is called directly after the corresponding syntax tree
+        * node to this view helper has been built.
+        * This is a parse-time callback, which does not change the rendering of a
+        * view helper.
+        *
+        * You can store some data inside the variableContainer given here, which
+        * can be used f.e. inside the TemplateView.
+        *
+        * @param Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode $syntaxTreeNode The current node in the syntax tree corresponding to this view helper.
+        * @param array $viewHelperArguments View helper arguments as an array of SyntaxTrees. If you really need an argument, make sure to call $viewHelperArguments[$argName]->render(...)!
+        * @param Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $variableContainer Variable container you can use to pass on some variables to the view.
+        * @return void
+        */
+       static public function postParseEvent(Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode $syntaxTreeNode, array $viewHelperArguments, Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $variableContainer);
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/ViewHelper/TagBasedViewHelper.php b/typo3/sysext/fluid/Classes/Core/ViewHelper/TagBasedViewHelper.php
new file mode 100644 (file)
index 0000000..97a9b99
--- /dev/null
@@ -0,0 +1,140 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Tag based view helper.
+ * Sould be used as the base class for all view helpers which output simple tags, as it provides some
+ * convenience methods to register default attributes, ...
+ *
+ * @version $Id: TagBasedViewHelper.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\ViewHelper
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ * @scope prototype
+ */
+abstract class Tx_Fluid_Core_ViewHelper_TagBasedViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
+
+       /**
+        * Names of all registered tag attributes
+        * @var array
+        */
+       protected $tagAttributes = array();
+
+       /**
+        * Tag builder instance
+        *
+        * @var Tx_Fluid_Core_ViewHelper_TagBuilder
+        * @api
+        */
+       protected $tag = NULL;
+
+       /**
+        * name of the tag to be created by this view helper
+        *
+        * @var string
+        * @api
+        */
+       protected $tagName = 'div';
+
+       /**
+        * Inject a TagBuilder
+        *
+        * @param Tx_Fluid_Core_ViewHelper_TagBuilder $tagBuilder Tag builder
+        * @return void
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function injectTagBuilder(Tx_Fluid_Core_ViewHelper_TagBuilder $tagBuilder) {
+               $this->tag = $tagBuilder;
+       }
+
+       /**
+        * Constructor
+        *
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function __construct() {
+               $this->registerArgument('additionalAttributes', 'array', 'Additional tag attributes. They will be added directly to the resulting HTML tag.', FALSE);
+       }
+
+       /**
+        * Sets the tag name to $this->tagName.
+        * Additionally, sets all tag attributes which were registered in
+        * $this->tagAttributes and additionalArguments.
+        *
+        * Will be invoked just before the render method.
+        *
+        * @return void
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function initialize() {
+               parent::initialize();
+               $this->tag->reset();
+               $this->tag->setTagName($this->tagName);
+               if (is_array($this->arguments['additionalAttributes'])) {
+                       $this->tag->addAttributes($this->arguments['additionalAttributes']);
+               }
+               foreach ($this->tagAttributes as $attributeName) {
+                       if ($this->arguments->hasArgument($attributeName) && $this->arguments[$attributeName] !== '') {
+                               $this->tag->addAttribute($attributeName, $this->arguments[$attributeName]);
+                       }
+               }
+       }
+
+       /**
+        * Register a new tag attribute. Tag attributes are all arguments which will be directly appended to a tag if you call $this->initializeTag()
+        *
+        * @param string $name Name of tag attribute
+        * @param strgin $type Type of the tag attribute
+        * @param string $description Description of tag attribute
+        * @param boolean $required set to TRUE if tag attribute is required. Defaults to FALSE.
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       protected function registerTagAttribute($name, $type, $description, $required = FALSE) {
+               $this->registerArgument($name, $type, $description, $required, NULL);
+               $this->tagAttributes[] = $name;
+       }
+
+       /**
+        * Registers all standard HTML universal attributes.
+        * Should be used inside registerArguments();
+        *
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       protected function registerUniversalTagAttributes() {
+               $this->registerTagAttribute('class', 'string', 'CSS class(es) for this element');
+               $this->registerTagAttribute('dir', 'string', 'Text direction for this HTML element. Allowed strings: "ltr" (left to right), "rtl" (right to left)');
+               $this->registerTagAttribute('id', 'string', 'Unique (in this file) identifier for this HTML element.');
+               $this->registerTagAttribute('lang', 'string', 'Language for this element. Use short names specified in RFC 1766');
+               $this->registerTagAttribute('style', 'string', 'Individual CSS styles for this element');
+               $this->registerTagAttribute('title', 'string', 'Tooltip text of element');
+               $this->registerTagAttribute('accesskey', 'string', 'Keyboard shortcut to access this element');
+               $this->registerTagAttribute('tabindex', 'integer', 'Specifies the tab order of this element');
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/ViewHelper/TagBuilder.php b/typo3/sysext/fluid/Classes/Core/ViewHelper/TagBuilder.php
new file mode 100644 (file)
index 0000000..363493d
--- /dev/null
@@ -0,0 +1,230 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Tag builder. Can be easily accessed in TagBasedViewHelper
+ *
+ * @version $Id: TagBuilder.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\ViewHelper
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ * @scope prototype
+ */
+class Tx_Fluid_Core_ViewHelper_TagBuilder {
+
+       /**
+        * Name of the Tag to be rendered
+        *
+        * @var string
+        */
+       protected $tagName = '';
+
+       /**
+        * Content of the tag to be rendered
+        *
+        * @var string
+        */
+       protected $content = '';
+
+       /**
+        * Attributes of the tag to be rendered
+        *
+        * @var array
+        */
+       protected $attributes = array();
+
+       /**
+        * Specifies whether this tag needs a closing tag.
+        * E.g. <textarea> cant be self-closing even if its empty
+        *
+        * @var boolean
+        */
+       protected $forceClosingTag = FALSE;
+
+       /**
+        * Constructor
+        *
+        * @param string $tagName name of the tag to be rendered
+        * @param string $tagContent content of the tag to be rendered
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function __construct($tagName = '', $tagContent = '') {
+               $this->setTagName($tagName);
+               $this->setContent($tagContent);
+       }
+
+       /**
+        * Sets the tag name
+        *
+        * @param string $tagName name of the tag to be rendered
+        * @return void
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function setTagName($tagName) {
+               $this->tagName = $tagName;
+       }
+
+       /**
+        * Gets the tag name
+        *
+        * @return string tag name of the tag to be rendered
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function getTagName() {
+               return $this->tagName;
+       }
+
+       /**
+        * Sets the content of the tag
+        *
+        * @param string $tagContent content of the tag to be rendered
+        * @return void
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function setContent($tagContent) {
+               $this->content = $tagContent;
+       }
+
+       /**
+        * Gets the content of the tag
+        *
+        * @return string content of the tag to be rendered
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function getContent() {
+               return $this->content;
+       }
+
+       /**
+        * Returns TRUE if tag contains content, otherwise FALSE
+        *
+        * @return boolean TRUE if tag contains text, otherwise FALSE
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function hasContent() {
+               if ($this->content === NULL) {
+                       return FALSE;
+               }
+               return $this->content !== '';
+       }
+
+       /**
+        * Set this to TRUE to force a closing tag
+        * E.g. <textarea> cant be self-closing even if its empty
+        *
+        * @param boolean $forceClosingTag
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function forceClosingTag($forceClosingTag) {
+               $this->forceClosingTag = $forceClosingTag;
+       }
+
+       /**
+        * Adds an attribute to the $attributes-collection
+        *
+        * @param string $attributeName name of the attribute to be added to the tag
+        * @param string $attributeValue attribute value
+        * @param boolean $escapeSpecialCharacters apply htmlspecialchars to attribute value
+        * @return void
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function addAttribute($attributeName, $attributeValue, $escapeSpecialCharacters = TRUE) {
+               if ($escapeSpecialCharacters) {
+                       $attributeValue = htmlspecialchars($attributeValue);
+               }
+               $this->attributes[$attributeName] = $attributeValue;
+       }
+
+       /**
+        * Adds attributes to the $attributes-collection
+        *
+        * @param array $attributes collection of attributes to add. key = attribute name, value = attribute value
+        * @param boolean $escapeSpecialCharacters apply htmlspecialchars to attribute values#
+        * @return void
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function addAttributes(array $attributes, $escapeSpecialCharacters = TRUE) {
+               foreach($attributes as $attributeName => $attributeValue) {
+                       $this->addAttribute($attributeName, $attributeValue, $escapeSpecialCharacters);
+               }
+       }
+
+       /**
+        * Removes an attribute from the $attributes-collection
+        *
+        * @param string $attributeName name of the attribute to be removed from the tag
+        * @return void
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function removeAttribute($attributeName) {
+               unset($this->attributes[$attributeName]);
+       }
+
+       /**
+        * Resets the TagBuilder by setting all members to their default value
+        *
+        * @return void
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function reset() {
+               $this->tagName = '';
+               $this->content = '';
+               $this->attributes = array();
+               $this->forceClosingTag = FALSE;
+       }
+
+       /**
+        * Renders and returns the tag
+        *
+        * @return void
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function render() {
+               if (empty($this->tagName)) {
+                       return '';
+               }
+               $output = '<' . $this->tagName;
+               foreach($this->attributes as $attributeName => $attributeValue) {
+                       $output .= ' ' . $attributeName . '="' . $attributeValue . '"';
+               }
+               if ($this->hasContent() || $this->forceClosingTag) {
+                       $output .= '>' . $this->content . '</' . $this->tagName . '>';
+               } else {
+                       $output .= ' />';
+               }
+               return $output;
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/ViewHelper/TemplateVariableContainer.php b/typo3/sysext/fluid/Classes/Core/ViewHelper/TemplateVariableContainer.php
new file mode 100644 (file)
index 0000000..2b5f53b
--- /dev/null
@@ -0,0 +1,137 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * VariableContainer which stores template variables.
+ * Is used in two contexts:
+ *
+ * 1) Holds the current variables in the template
+ * 2) Holds variables being set during Parsing (set in view helpers implementing the PostParse facet)
+ *
+ * @version $Id: TemplateVariableContainer.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\ViewHelper
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ * @scope prototype
+ */
+class Tx_Fluid_Core_ViewHelper_TemplateVariableContainer {
+
+       /**
+        * List of reserved words that can't be used as object identifiers in Fluid templates
+        * @var array
+        */
+       static protected $reservedKeywords = array('true', 'false');
+
+       /**
+        * Objects stored in context
+        * @var array
+        */
+       protected $objects = array();
+
+       /**
+        * Constructor. Can take an array, and initializes the objects with it.
+        *
+        * @param array $objectArray
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function __construct($objectArray = array()) {
+               if (!is_array($objectArray)) throw new RuntimeException('Context has to be initialized with an array, ' . gettype($objectArray) . ' given.', 1224592343);
+               $this->objects = $objectArray;
+       }
+
+       /**
+        * Add an object to the context
+        *
+        * @param string $identifier
+        * @param object $object
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function add($identifier, $object) {
+               if (array_key_exists($identifier, $this->objects)) throw new RuntimeException('Duplicate variable declarations!', 1224479063);
+               if (in_array(strtolower($identifier), self::$reservedKeywords)) throw new RuntimeException('"' . $identifier . '" is a reserved keyword and can\'t be used as variable identifier.', 1256730379);
+               $this->objects[$identifier] = $object;
+       }
+
+       /**
+        * Get an object from the context. Throws exception if object is not found in context.
+        *
+        * @param string $identifier
+        * @return object The object identified by $identifier
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function get($identifier) {
+               if (!array_key_exists($identifier, $this->objects)) throw new RuntimeException('Tried to get a variable "' . $identifier . '" which is not stored in the context!', 1224479370);
+               return $this->objects[$identifier];
+       }
+
+       /**
+        * Remove an object from context. Throws exception if object is not found in context.
+        *
+        * @param string $identifier The identifier to remove
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function remove($identifier) {
+               if (!array_key_exists($identifier, $this->objects)) throw new RuntimeException('Tried to remove a variable "' . $identifier . '" which is not stored in the context!', 1224479372);
+               unset($this->objects[$identifier]);
+       }
+
+       /**
+        * Returns an array of all identifiers available in the context.
+        *
+        * @return array Array of identifier strings
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getAllIdentifiers() {
+               return array_keys($this->objects);
+       }
+
+       /**
+        * Checks if this property exists in the VariableContainer.
+        *
+        * @param string $identifier
+        * @return boolean TRUE if $identifier exists, FALSE otherwise
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function exists($identifier) {
+               return array_key_exists($identifier, $this->objects);
+       }
+
+       /**
+        * Clean up for serializing.
+        *
+        * @return array
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function __sleep() {
+               return array('objects');
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/ViewHelper/ViewHelperInterface.php b/typo3/sysext/fluid/Classes/Core/ViewHelper/ViewHelperInterface.php
new file mode 100644 (file)
index 0000000..adc113f
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * @version $Id: ViewHelperInterface.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\ViewHelper
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+interface Tx_Fluid_Core_ViewHelper_ViewHelperInterface {
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Core/ViewHelper/ViewHelperVariableContainer.php b/typo3/sysext/fluid/Classes/Core/ViewHelper/ViewHelperVariableContainer.php
new file mode 100644 (file)
index 0000000..a813938
--- /dev/null
@@ -0,0 +1,159 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * @version $Id: ViewHelperVariableContainer.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Core\ViewHelper
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ * @scope prototype
+ */
+class Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer {
+
+       /**
+        * Two-dimensional object array storing the values. The first dimension is the fully qualified ViewHelper name,
+        * and the second dimension is the identifier for the data the ViewHelper wants to store.
+        * @var array
+        */
+       protected $objects = array();
+
+       /**
+        *
+        * @var Tx_Extbase_MVC_View_ViewInterface
+        */
+       protected $view;
+
+       /**
+        * Add a variable to the Variable Container. Make sure that $viewHelperName is ALWAYS set
+        * to your fully qualified ViewHelper Class Name
+        * 
+        * In case the value is already inside, an exception is thrown.
+        *
+        * @param string $viewHelperName The ViewHelper Class name (Fully qualified, like Tx_Fluid_ViewHelpers_ForViewHelper)
+        * @param string $key Key of the data
+        * @param object $value The value to store
+        * @return void
+        * @throws RuntimeException if there was no key with the specified name
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function add($viewHelperName, $key, $value) {
+               if ($this->exists($viewHelperName, $key)) throw new RuntimeException('The key "' . $viewHelperName . '->' . $key . '" was already stored and you cannot override it.', 1243352010);
+               $this->addOrUpdate($viewHelperName, $key, $value);
+       }
+
+       /**
+        * Add a variable to the Variable Container. Make sure that $viewHelperName is ALWAYS set
+        * to your fully qualified ViewHelper Class Name.
+        * In case the value is already inside, it is silently overridden.
+        *
+        * @param string $viewHelperName The ViewHelper Class name (Fully qualified, like Tx_Fluid_ViewHelpers_ForViewHelper)
+        * @param string $key Key of the data
+        * @param object $value The value to store
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function addOrUpdate($viewHelperName, $key, $value) {
+               if (!isset($this->objects[$viewHelperName])) {
+                       $this->objects[$viewHelperName] = array();
+               }
+               $this->objects[$viewHelperName][$key] = $value;
+       }
+       
+       /**
+        * Gets a variable which is stored
+        *
+        * @param string $viewHelperName The ViewHelper Class name (Fully qualified, like Tx_Fluid_ViewHelpers_ForViewHelper)
+        * @param string $key Key of the data
+        * @return object The object stored
+        * @throws RuntimeException if there was no key with the specified name
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function get($viewHelperName, $key) {
+               if (!$this->exists($viewHelperName, $key)) throw new RuntimeException('No value found for key "' . $viewHelperName . '->' . $key . '"', 1243325768);
+               return $this->objects[$viewHelperName][$key];
+       }
+
+       /**
+        * Determine whether there is a variable stored for the given key
+        *
+        * @param string $viewHelperName The ViewHelper Class name (Fully qualified, like Tx_Fluid_ViewHelpers_ForViewHelper)
+        * @param string $key Key of the data
+        * @return boolean TRUE if a value for the given ViewHelperName / Key is stored, FALSE otherwise.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function exists($viewHelperName, $key) {
+               return isset($this->objects[$viewHelperName][$key]);
+       }
+
+       /**
+        * Remove a value from the variable container
+        *
+        * @param string $viewHelperName The ViewHelper Class name (Fully qualified, like Tx_Fluid_ViewHelpers_ForViewHelper)
+        * @param string $key Key of the data to remove
+        * @return void
+        * @throws RuntimeException if there was no key with the specified name
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function remove($viewHelperName, $key) {
+               if (!$this->exists($viewHelperName, $key)) throw new RuntimeException('No value found for key "' . $viewHelperName . '->' . $key . '", thus the key cannot be removed.', 1243352249);
+               unset($this->objects[$viewHelperName][$key]);
+       }
+
+       /**
+        * Set the view to pass it to ViewHelpers.
+        *
+        * @param Tx_Extbase_MVC_View_ViewInterface $view View to set
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function setView(Tx_Extbase_MVC_View_ViewInterface $view) {
+               $this->view = $view;
+       }
+
+       /**
+        * Get the view.
+        *
+        * !!! This is NOT a public API and might still change!!!
+        *
+        * @return Tx_Extbase_MVC_View_ViewInterface The View
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function getView() {
+               return $this->view;
+       }
+
+       /**
+        * Clean up for serializing.
+        *
+        * @return array
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function __sleep() {
+               return array('objects');
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Exception.php b/typo3/sysext/fluid/Classes/Exception.php
new file mode 100644 (file)
index 0000000..c10d6d2
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+/*                                                                        *
+ * This script is part of the TYPO3 project - inspiring people to share!  *
+ *                                                                        *
+ * TYPO3 is free software; you can redistribute it and/or modify it under *
+ * the terms of the GNU General Public License version 2 as published by  *
+ * the Free Software Foundation.                                          *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General      *
+ * Public License for more details.                                       *
+ *                                                                        */
+
+/**
+ * @package
+ * @subpackage
+ * @version $Id: Exception.php 1734 2009-11-25 21:53:57Z stucki $
+ */
+class Tx_Fluid_Exception extends Exception {
+
+}
+
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Fluid.php b/typo3/sysext/fluid/Classes/Fluid.php
new file mode 100644 (file)
index 0000000..31bf0cc
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+
+/*                                                                        *
+ * This script is part of the TYPO3 project - inspiring people to share!  *
+ *                                                                        *
+ * TYPO3 is free software; you can redistribute it and/or modify it under *
+ * the terms of the GNU General Public License version 2 as published by  *
+ * the Free Software Foundation.                                          *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General      *
+ * Public License for more details.                                       *
+ *                                                                        */
+
+/**
+ * @package
+ * @subpackage
+ * @version $Id: Fluid.php 1734 2009-11-25 21:53:57Z stucki $
+ */
+class Tx_Fluid_Fluid {
+       const NAMESPACE_SEPARATOR = '_';
+
+       public static $debugMode = FALSE;
+}
+
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/Service/DocbookGenerator.php b/typo3/sysext/fluid/Classes/Service/DocbookGenerator.php
new file mode 100644 (file)
index 0000000..82e2e43
--- /dev/null
@@ -0,0 +1,225 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * XML Schema (XSD) Generator. Will generate an XML schema which can be used for autocompletion
+ * in schema-aware editors like Eclipse XML editor.
+ *
+ * @version $Id: DocbookGenerator.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage Service
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class Tx_Fluid_Service_DocbookGenerator extends Tx_Fluid_Service_AbstractGenerator {
+
+       /**
+        * Generate the XML Schema definition for a given namespace.
+        *
+        * @param string $namespace Namespace identifier to generate the XSD for, without leading Backslash.
+        * @return string XML Schema definition
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function generateDocbook($namespace) {
+               if (substr($namespace, -1) !== Tx_Fluid_Fluid::NAMESPACE_SEPARATOR) {
+                       $namespace .= Tx_Fluid_Fluid::NAMESPACE_SEPARATOR;
+               }
+
+               $classNames = $this->getClassNamesInNamespace($namespace);
+
+               $xmlRootNode = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?>
+<section version="5.0" xmlns="http://docbook.org/ns/docbook"
+         xml:id="fluid.usermanual.standardviewhelpers"
+         xmlns:xl="http://www.w3.org/1999/xlink"
+         xmlns:xi="http://www.w3.org/2001/XInclude"
+         xmlns:xhtml="http://www.w3.org/1999/xhtml"
+         xmlns:svg="http://www.w3.org/2000/svg"
+         xmlns:ns="http://docbook.org/ns/docbook"
+         xmlns:mathml="http://www.w3.org/1998/Math/MathML">
+    <title>Standard View Helper Library</title>
+
+    <para>Should be autogenerated from the tags.</para>
+</section>');
+
+               foreach ($classNames as $className) {
+                       $this->generateXmlForClassName($className, $namespace, $xmlRootNode);
+               }
+
+               return $xmlRootNode->asXML();
+       }
+
+       /**
+        * Generate the XML Schema for a given class name.
+        *
+        * @param string $className Class name to generate the schema for.
+        * @param string $namespace Namespace prefix. Used to split off the first parts of the class name.
+        * @param SimpleXMLElement $xmlRootNode XML root node where the xsd:element is appended.
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function generateXmlForClassName($className, $namespace, SimpleXMLElement $xmlRootNode) {
+               $reflectionClass = new Tx_Extbase_Reflection_ClassReflection($className);
+               if (!$reflectionClass->isSubclassOf($this->abstractViewHelperReflectionClass)) {
+                       return;
+               }
+
+               $tagName = $this->getTagNameForClass($className, $namespace);
+
+               $docbookSection = $xmlRootNode->addChild('section');
+
+               $docbookSection->addChild('title', $tagName);
+               $this->docCommentParser->parseDocComment($reflectionClass->getDocComment());
+               $this->addDocumentation($this->docCommentParser->getDescription(), $docbookSection);
+
+               $argumentsSection = $docbookSection->addChild('section');
+               $argumentsSection->addChild('title', 'Arguments');
+               $this->addArguments($className, $argumentsSection);
+
+               return $docbookSection;
+       }
+
+       /**
+        * Add attribute descriptions to a given tag.
+        * Initializes the view helper and its arguments, and then reads out the list of arguments.
+        *
+        * @param string $className Class name where to add the attribute descriptions
+        * @param SimpleXMLElement $docbookSection DocBook section to add the attributes to.
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function addArguments($className, SimpleXMLElement $docbookSection) {
+               $viewHelper = $this->instanciateViewHelper($className);
+               $argumentDefinitions = $viewHelper->prepareArguments();
+
+               if (count($argumentDefinitions) === 0) {
+                       $docbookSection->addChild('para', 'No arguments defined.');
+                       return;
+               }
+               $argumentsTable = $docbookSection->addChild('table');
+               $argumentsTable->addChild('title', 'Arguments');
+               $tgroup = $argumentsTable->addChild('tgroup');
+               $tgroup['cols'] = 4;
+               $this->addArgumentTableRow($tgroup->addChild('thead'), 'Name', 'Type', 'Required', 'Description', 'Default');
+
+               $tbody = $tgroup->addChild('tbody');
+
+               foreach ($argumentDefinitions as $argumentDefinition) {
+                       $this->addArgumentTableRow($tbody, $argumentDefinition->getName(), $argumentDefinition->getType(), ($argumentDefinition->isRequired()?'yes':'no'), $argumentDefinition->getDescription(), $argumentDefinition->getDefaultValue());
+               }
+       }
+
+       /**
+        * Instantiate a view helper.
+        *
+        * @param string $className
+        * @return object
+        */
+       protected function instanciateViewHelper($className) {
+               return $this->objectManager->getObject($className);
+       }
+
+       /**
+        * @param SimpleXMLElement $parent
+        * @param string $name
+        * @param string $type
+        * @param boolean $required
+        * @param string $description
+        * @param string $default
+        * @return void
+        */
+       private function addArgumentTableRow(SimpleXMLElement $parent, $name, $type, $required, $description, $default) {
+               $row = $parent->addChild('row');
+
+               $row->addChild('entry', $name);
+               $row->addChild('entry', $type);
+               $row->addChild('entry', $required);
+               $row->addChild('entry', $description);
+               $row->addChild('entry', (string)$default);
+       }
+
+       /**
+        * Add documentation XSD to a given XML node
+        *
+        * As Eclipse renders newlines only on new <xsd:documentation> tags, we wrap every line in a new
+        * <xsd:documentation> tag.
+        * Furthermore, eclipse strips out tags - the only way to prevent this is to have every line wrapped in a
+        * CDATA block AND to replace the < and > with their XML entities. (This is IMHO not XML conformant).
+        *
+        * @param string $documentation Documentation string to add.
+        * @param SimpleXMLElement $docbookSection Node to add the documentation to
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function addDocumentation($documentation, SimpleXMLElement $docbookSection) {
+               $splitRegex = '/^\s*(=[^=]+=)$/m';
+               $regex = '/^\s*(=([^=]+)=)$/m';
+
+               $matches = preg_split($splitRegex, $documentation, -1,  PREG_SPLIT_NO_EMPTY  |  PREG_SPLIT_DELIM_CAPTURE );
+
+               $currentSection = $docbookSection;
+               foreach ($matches as $singleMatch) {
+                       if (preg_match($regex, $singleMatch, $tmp)) {
+                               $currentSection = $docbookSection->addChild('section');
+                               $currentSection->addChild('title', trim($tmp[2]));
+                       } else {
+                               $this->addText(trim($singleMatch), $currentSection);
+                       }
+               }
+       }
+
+       /**
+        * @param string $text
+        * @param SimpleXMLElement $parentElement
+        */
+       protected function addText($text, SimpleXMLElement $parentElement) {
+               $splitRegex = '/
+               (<code(?:.*?)>
+                       (?:.*?)
+               <\/code>)/xs';
+
+               $regex = '/
+               <code(.*?)>
+                       (.*?)
+               <\/code>/xs';
+               $matches = preg_split($splitRegex, $text, -1,  PREG_SPLIT_NO_EMPTY  |  PREG_SPLIT_DELIM_CAPTURE );
+               foreach ($matches as $singleMatch) {
+
+                       if (preg_match($regex, $singleMatch, $tmp)) {
+                               preg_match('/title="([^"]+)"/', $tmp[1], $titleMatch);
+
+                               $example = $parentElement->addChild('example');
+                               if (count($titleMatch)) {
+                                       $example->addChild('title', trim($titleMatch[1]));
+                               } else {
+                                       $example->addChild('title', 'Example');
+                               }
+                               $this->addChildWithCData($example, 'programlisting', trim($tmp[2]));
+                       } else {
+                               $textParts = explode("\n", $singleMatch);
+                               foreach ($textParts as $text) {
+                                       if (trim($text) === '') continue;
+                                       $this->addChildWithCData($parentElement, 'para', trim($text));
+                               }
+                       }
+               }
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/View/Exception.php b/typo3/sysext/fluid/Classes/View/Exception.php
new file mode 100644 (file)
index 0000000..bd0cc11
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * A generic Fluid View exception.
+ *
+ * @version $Id: Exception.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage View
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ */
+class Tx_Fluid_View_Exception extends Tx_Fluid_Exception {
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/View/Exception/InvalidTemplateResource.php b/typo3/sysext/fluid/Classes/View/Exception/InvalidTemplateResource.php
new file mode 100644 (file)
index 0000000..6fa72b5
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * An "Invalid Template Resource" exception
+ *
+ * @version $Id: InvalidTemplateResource.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage View\Exception
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ */
+class Tx_Fluid_View_Exception_InvalidTemplateResource extends Tx_Fluid_View_Exception {
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/View/TemplateView.php b/typo3/sysext/fluid/Classes/View/TemplateView.php
new file mode 100644 (file)
index 0000000..f77ef29
--- /dev/null
@@ -0,0 +1,518 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * The main template view. Should be used as view if you want Fluid Templating
+ *
+ * @version $Id: TemplateView.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage View
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ * @scope prototype
+ */
+class Tx_Fluid_View_TemplateView extends Tx_Extbase_MVC_View_AbstractView implements Tx_Fluid_View_TemplateViewInterface {
+
+       /**
+        * Pattern for fetching information from controller object name
+        * @var string
+        */
+       protected $PATTERN_CONTROLLER = '/^TxFLUID_NAMESPACE_SEPARATOR\w*FLUID_NAMESPACE_SEPARATOR(?:(?P<SubpackageName>.*)FLUID_NAMESPACE_SEPARATOR)?ControllerFLUID_NAMESPACE_SEPARATOR(?P<ControllerName>\w*)Controller$/';
+
+       /**
+        * @var Tx_Fluid_Core_Parser_TemplateParser
+        */
+       protected $templateParser;
+
+       /**
+        * Pattern to be resolved for @templateRoot in the other patterns.
+        * @var string
+        */
+       protected $templateRootPathPattern = '@packageResourcesPath/Private/Templates';
+
+       /**
+        * Pattern to be resolved for @partialRoot in the other patterns.
+        * @var string
+        */
+       protected $partialRootPathPattern = '@packageResourcesPath/Private/Partials';
+
+       /**
+        * Pattern to be resolved for @layoutRoot in the other patterns.
+        * @var string
+        */
+       protected $layoutRootPathPattern = '@packageResourcesPath/Private/Layouts';
+
+       /**
+        * Path to the template root. If NULL, then $this->templateRootPathPattern will be used.
+        */
+       protected $templateRootPath = NULL;
+
+       /**
+        * Path to the partial root. If NULL, then $this->partialRootPathPattern will be used.
+        */
+       protected $partialRootPath = NULL;
+
+       /**
+        * Path to the layout root. If NULL, then $this->layoutRootPathPattern will be used.
+        */
+       protected $layoutRootPath = NULL;
+
+       /**
+        * File pattern for resolving the template file
+        * @var string
+        */
+       protected $templatePathAndFilenamePattern = '@templateRoot/@controller/@action.@format';
+
+       /**
+        * Directory pattern for global partials. Not part of the public API, should not be changed for now.
+        * @var string
+        */
+       private $partialPathAndFilenamePattern = '@partialRoot/@partial.@format';
+
+       /**
+        * File pattern for resolving the layout
+        * @var string
+        */
+       protected $layoutPathAndFilenamePattern = '@layoutRoot/@layout.@format';
+
+       /**
+        * Path and filename of the template file. If set,  overrides the templatePathAndFilenamePattern
+        * @var string
+        */
+       protected $templatePathAndFilename = NULL;
+
+       /**
+        * Path and filename of the layout file. If set, overrides the layoutPathAndFilenamePattern
+        * @var string
+        */
+       protected $layoutPathAndFilename = NULL;
+
+       public function __construct() {
+                                               $this->templateParser = Tx_Fluid_Compatibility_TemplateParserBuilder::build();
+                                               $this->objectFactory = t3lib_div::makeInstance('Tx_Fluid_Compatibility_ObjectFactory');
+                                       }
+       // Here, the backporter can insert a constructor method, which is needed for Fluid v4.
+
+       /**
+        * Inject the template parser
+        *
+        * @param Tx_Fluid_Core_Parser_TemplateParser $templateParser The template parser
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       public function injectTemplateParser(Tx_Fluid_Core_Parser_TemplateParser $templateParser) {
+               $this->templateParser = $templateParser;
+       }
+
+       /**
+        * Initialize view
+        *
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function initializeView() {
+       }
+
+       /**
+        * Sets the path and name of of the template file. Effectively overrides the
+        * dynamic resolving of a template file.
+        *
+        * @param string $templatePathAndFilename Template file path
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function setTemplatePathAndFilename($templatePathAndFilename) {
+               $this->templatePathAndFilename = $templatePathAndFilename;
+       }
+
+       /**
+        * Sets the path and name of the layout file. Overrides the dynamic resolving of the layout file.
+        *
+        * @param string $layoutPathAndFilename Path and filename of the layout file
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function setLayoutPathAndFilename($layoutPathAndFilename) {
+               $this->layoutPathAndFilename = $layoutPathAndFilename;
+       }
+
+       /**
+        * Build the rendering context
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function buildRenderingContext($variableContainer = NULL) {
+               if ($variableContainer === NULL) {
+                       $variableContainer = $this->objectFactory->create('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer', $this->viewData);
+               }
+               $renderingConfiguration = $this->objectFactory->create('Tx_Fluid_Core_Rendering_RenderingConfiguration');
+               $renderingConfiguration->setObjectAccessorPostProcessor($this->objectFactory->create('Tx_Fluid_Core_Rendering_HtmlSpecialCharsPostProcessor'));
+
+               $renderingContext = $this->objectFactory->create('Tx_Fluid_Core_Rendering_RenderingContext');
+               $renderingContext->setTemplateVariableContainer($variableContainer);
+               if ($this->controllerContext !== NULL) {
+                       $renderingContext->setControllerContext($this->controllerContext);
+               }
+               $renderingContext->setRenderingConfiguration($renderingConfiguration);
+
+               $viewHelperVariableContainer = $this->objectFactory->create('Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer');
+               $viewHelperVariableContainer->setView($this);
+               $renderingContext->setViewHelperVariableContainer($viewHelperVariableContainer);
+
+               return $renderingContext;
+       }
+
+       /**
+        * Find the XHTML template according to $this->templatePathAndFilenamePattern and render the template.
+        * If "layoutName" is set in a PostParseFacet callback, it will render the file with the given layout.
+        *
+        * @param string $actionName If set, the view of the specified action will be rendered instead. Default is the action specified in the Request object
+        * @return string Rendered Template
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function render($actionName = NULL) {
+               $templatePathAndFilename = $this->resolveTemplatePathAndFilename($actionName);
+
+               $parsedTemplate = $this->parseTemplate($templatePathAndFilename);
+
+               $variableContainer = $parsedTemplate->getVariableContainer();
+               if ($variableContainer !== NULL && $variableContainer->exists('layoutName')) {
+                       return $this->renderWithLayout($variableContainer->get('layoutName'));
+               }
+
+               $renderingContext = $this->buildRenderingContext();
+               return $parsedTemplate->render($renderingContext);
+       }
+
+       /**
+        * Resolve the template path and filename for the given action. If action is null, looks into the current request.
+        *
+        * @param string $actionName Name of the action. If NULL, will be taken from request.
+        * @return string Full path to template
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function resolveTemplatePathAndFilename($actionName = NULL) {
+               if ($this->templatePathAndFilename !== NULL) {
+                       return $this->templatePathAndFilename;
+               }
+
+               $actionName = ($actionName !== NULL ? $actionName : $this->controllerContext->getRequest()->getControllerActionName());
+               $actionName = strtolower($actionName);
+
+               $paths = $this->expandGenericPathPattern($this->templatePathAndFilenamePattern, FALSE, FALSE);
+
+               foreach ($paths as &$path) {
+                       $path = str_replace('@action', $actionName, $path);
+                       if (file_exists($path)) {
+                               return $path;
+                       }
+               }
+               throw new RuntimeException('The template files "' . implode('", "', $paths) . '" could not be loaded.', 1225709595);
+       }
+
+       /**
+        * Renders a given section.
+        *
+        * @param string $sectionName Name of section to render
+        * @return rendered template for the section
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderSection($sectionName) {
+               $parsedTemplate = $this->parseTemplate($this->resolveTemplatePathAndFilename());
+
+               $sections = $parsedTemplate->getVariableContainer()->get('sections');
+               if(!array_key_exists($sectionName, $sections)) {
+                       throw new RuntimeException('The given section does not exist!', 1227108982);
+               }
+               $section = $sections[$sectionName];
+
+               $renderingContext = $this->buildRenderingContext();
+               $section->setRenderingContext($renderingContext);
+               return $section->evaluate();
+       }
+
+       /**
+        * Render a template with a given layout.
+        *
+        * @param string $layoutName Name of layout
+        * @return string rendered HTML
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function renderWithLayout($layoutName) {
+               $parsedTemplate = $this->parseTemplate($this->resolveLayoutPathAndFilename($layoutName));
+
+               $renderingContext = $this->buildRenderingContext();
+               return $parsedTemplate->render($renderingContext);
+       }
+
+       /**
+        * Resolve the path and file name of the layout file, based on
+        * $this->layoutPathAndFilename and $this->layoutPathAndFilenamePattern.
+        *
+        * In case a layout has already been set with setLayoutPathAndFilename(),
+        * this method returns that path, otherwise a path and filename will be
+        * resolved using the layoutPathAndFilenamePattern.
+        *
+        * @param string $layoutName Name of the layout to use. If none given, use "default"
+        * @return string Path and filename of layout file
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function resolveLayoutPathAndFilename($layoutName = 'default') {
+               if ($this->layoutPathAndFilename) {
+                       return $this->layoutPathAndFilename;
+               }
+
+               $paths = $this->expandGenericPathPattern($this->layoutPathAndFilenamePattern, TRUE, TRUE);
+               foreach ($paths as &$path) {
+                       $path = str_replace('@layout', $layoutName, $path);
+                       if (file_exists($path)) {
+                               return $path;
+                       }
+               }
+               throw new RuntimeException('The template files "' . implode('", "', $paths) . '" could not be loaded.', 1225709595);
+       }
+
+       /**
+        * Renders a partial.
+        * SHOULD NOT BE USED BY USERS!
+        *
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @author Robert Lemke <robert@typo3.org>
+        */
+       public function renderPartial($partialName, $sectionToRender, array $variables) {
+               $partial = $this->parseTemplate($this->resolvePartialPathAndFilename($partialName));
+               $variableContainer = $this->objectFactory->create('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer', $variables);
+               $renderingContext = $this->buildRenderingContext($variableContainer);
+               return $partial->render($renderingContext);
+       }
+
+       /**
+        * Figures out which partial to use.
+        *
+        * @param string $partialName The name of the partial
+        * @return string the full path which should be used. The path definitely exists.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function resolvePartialPathAndFilename($partialName) {
+               $paths = $this->expandGenericPathPattern($this->partialPathAndFilenamePattern, TRUE, TRUE);
+               foreach ($paths as &$path) {
+                       $path = str_replace('@partial', $partialName, $path);
+                       if (file_exists($path)) {
+                               return $path;
+                       }
+               }
+               throw new RuntimeException('The template files "' . implode('", "', $paths) . '" could not be loaded.', 1225709595);
+       }
+
+       /**
+        * Checks whether a template can be resolved for the current request context.
+        *
+        * @return boolean
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function hasTemplate() {
+               try {
+                       $this->resolveTemplatePathAndFilename();
+                       return TRUE;
+               } catch (RuntimeException $e) {
+                       return FALSE;
+               }
+       }
+
+       /**
+        * Parse the given template and return it.
+        *
+        * Will cache the results for one call.
+        *
+        * @param string $templatePathAndFilename absolute filename of the template to be parsed
+        * @return Tx_Fluid_Core_Parser_ParsedTemplateInterface the parsed template tree
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function parseTemplate($templatePathAndFilename) {
+               $templateSource = file_get_contents($templatePathAndFilename);
+
+               return $this->templateParser->parse($templateSource);
+       }
+
+       /**
+        * Set the root path to the templates.
+        * If set, overrides the one determined from $this->templateRootPathPattern
+        *
+        * @param string $templateRootPath Root path to the templates. If set, overrides the one determined from $this->templateRootPathPattern
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function setTemplateRootPath($templateRootPath) {
+               $this->templateRootPath = $templateRootPath;
+       }
+
+       /**
+        * Resolves the template root to be used inside other paths.
+        *
+        * @return string Path to template root directory
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function getTemplateRootPath() {
+               if ($this->templateRootPath !== NULL) {
+                       return $this->templateRootPath;
+               } else {
+                       return str_replace('@packageResourcesPath', t3lib_extMgm::extPath($this->controllerContext->getRequest()->getControllerExtensionKey()) . 'Resources/', $this->templateRootPathPattern);
+               }
+       }
+
+       /**
+        * Set the root path to the partials.
+        * If set, overrides the one determined from $this->partialRootPathPattern
+        *
+        * @param string $partialRootPath Root path to the partials. If set, overrides the one determined from $this->partialRootPathPattern
+        * @return void
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function setPartialRootPath($partialRootPath) {
+               $this->partialRootPath = $partialRootPath;
+       }
+
+       /**
+        * Resolves the partial root to be used inside other paths.
+        *
+        * @return string Path to partial root directory
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       protected function getPartialRootPath() {
+               if ($this->partialRootPath !== NULL) {
+                       return $this->partialRootPath;
+               } else {
+                       return str_replace('@packageResourcesPath', t3lib_extMgm::extPath($this->controllerContext->getRequest()->getControllerExtensionKey()) . 'Resources/', $this->partialRootPathPattern);
+               }
+       }
+
+       /**
+        * Set the root path to the layouts.
+        * If set, overrides the one determined from $this->layoutRootPathPattern
+        *
+        * @param string $layoutRootPath Root path to the layouts. If set, overrides the one determined from $this->layoutRootPathPattern
+        * @return void
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function setLayoutRootPath($layoutRootPath) {
+               $this->layoutRootPath = $layoutRootPath;
+       }
+
+       /**
+        * Resolves the layout root to be used inside other paths.
+        *
+        * @return string Path to layout root directory
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       protected function getLayoutRootPath() {
+               if ($this->layoutRootPath !== NULL) {
+                       return $this->layoutRootPath;
+               } else {
+                       return str_replace('@packageResourcesPath', t3lib_extMgm::extPath($this->controllerContext->getRequest()->getControllerExtensionKey()) . 'Resources/', $this->layoutRootPathPattern);
+               }
+       }
+
+       /**
+        * Processes @templateRoot, @subpackage, @controller, and @format placeholders inside $pattern.
+        * This method is used to generate "fallback chains" for file system locations where a certain Partial can reside.
+        *
+        * If $bubbleControllerAndSubpackage is FALSE and $formatIsOptional is FALSE, then the resulting array will only have one element
+        * with all the above placeholders replaced.
+        *
+        * If you set $bubbleControllerAndSubpackage to TRUE, then you will get an array with potentially many elements:
+        * The first element of the array is like above. The second element has the @controller part set to "" (the empty string)
+        * The third element now has the @controller part again stripped off, and has the last subpackage part stripped off as well.
+        * This continues until both @subpackage and @controller are empty.
+        *
+        * Example for $bubbleControllerAndSubpackage is TRUE, we have the Tx_Fluid_MySubPackage_Controller_MyController as Controller Object Name and the current format is "html"
+        * If pattern is @templateRoot/@controller/@action.@format, then the resulting array is:
+        *  - Resources/Private/Templates/MySubPackage/My/@action.html
+        *  - Resources/Private/Templates/MySubPackage/@action.html
+        *  - Resources/Private/Templates/@action.html
+        *
+        * If you set $formatIsOptional to TRUE, then for any of the above arrays, every element will be duplicated  - once with @format
+        * replaced by the current request format, and once with .@format stripped off.
+        *
+        * @param string $pattern Pattern to be resolved
+        * @param boolean $bubbleControllerAndSubpackage if TRUE, then we successively split off parts from @controller and @subpackage until both are empty.
+        * @param boolean $formatIsOptional if TRUE, then half of the resulting strings will have .@format stripped off, and the other half will have it.
+        * @return array unix style path
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function expandGenericPathPattern($pattern, $bubbleControllerAndSubpackage, $formatIsOptional) {
+               $pattern = str_replace('@templateRoot', $this->getTemplateRootPath(), $pattern);
+               $pattern = str_replace('@partialRoot', $this->getPartialRootPath(), $pattern);
+               $pattern = str_replace('@layoutRoot', $this->getLayoutRootPath(), $pattern);
+
+               $matches = array();
+               $this->PATTERN_CONTROLLER = str_replace('FLUID_NAMESPACE_SEPARATOR', preg_quote(Tx_Fluid_Fluid::NAMESPACE_SEPARATOR), $this->PATTERN_CONTROLLER);
+               preg_match($this->PATTERN_CONTROLLER, $this->controllerContext->getRequest()->getControllerObjectName(), $matches);
+
+               $subpackageParts = array();
+               if ($matches['SubpackageName'] !== '') {
+                       $subpackageParts = explode(Tx_Fluid_Fluid::NAMESPACE_SEPARATOR, $matches['SubpackageName']);
+               }
+
+               $controllerName = NULL;
+               if (strpos($pattern, '@controller') !== FALSE) {
+                       $controllerName = $matches['ControllerName'];
+               }
+
+               $results = array();
+
+               if ($controllerName !== NULL) {
+                       $i = -1;
+               } else {
+                       $i = 0;
+               }
+
+               do {
+                       $temporaryPattern = $pattern;
+                       if ($i < 0) {
+                               $temporaryPattern = str_replace('@controller', $controllerName, $temporaryPattern);
+                       } else {
+                               $temporaryPattern = str_replace('//', '/', str_replace('@controller', '', $temporaryPattern));
+                       }
+                       $temporaryPattern = str_replace('@subpackage', implode('/', ($i<0 ? $subpackageParts : array_slice($subpackageParts, $i))), $temporaryPattern);
+
+                       $results[] = t3lib_div::fixWindowsFilePath(str_replace('@format', $this->controllerContext->getRequest()->getFormat(), $temporaryPattern));
+                       if ($formatIsOptional) {
+                               $results[] =  t3lib_div::fixWindowsFilePath(str_replace('.@format', '', $temporaryPattern));
+                       }
+
+               } while($i++ < count($subpackageParts) && $bubbleControllerAndSubpackage);
+
+               return $results;
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/View/TemplateViewInterface.php b/typo3/sysext/fluid/Classes/View/TemplateViewInterface.php
new file mode 100644 (file)
index 0000000..0205ac5
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Interface of Fluids Template view
+ *
+ * @version $Id: TemplateViewInterface.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage View
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ */
+interface Tx_Fluid_View_TemplateViewInterface extends Tx_Extbase_MVC_View_ViewInterface {
+
+       /**
+        * Inject the template parser
+        *
+        * @param Tx_Fluid_Core_Parser_TemplateParser $templateParser The template parser
+        * @return void
+        * @api
+        */
+       public function injectTemplateParser(Tx_Fluid_Core_Parser_TemplateParser $templateParser);
+
+       /**
+        * Sets the path and name of of the template file. Effectively overrides the
+        * dynamic resolving of a template file.
+        *
+        * @param string $templatePathAndFilename Template file path
+        * @return void
+        * @api
+        */
+       public function setTemplatePathAndFilename($templatePathAndFilename);
+
+       /**
+        * Sets the path and name of the layout file. Overrides the dynamic resolving of the layout file.
+        *
+        * @param string $layoutPathAndFilename Path and filename of the layout file
+        * @return void
+        * @api
+        */
+       public function setLayoutPathAndFilename($layoutPathAndFilename);
+
+       /**
+        * Renders a given section.
+        *
+        * @param string $sectionName Name of section to render
+        * @return rendered template for the section
+        * @api
+        */
+       public function renderSection($sectionName);
+
+       /**
+        * Render a template with a given layout.
+        *
+        * @param string $layoutName Name of layout
+        * @return string rendered HTML
+        * @api
+        */
+       public function renderWithLayout($layoutName);
+
+       /**
+        * Checks whether a template can be resolved for the current request context.
+        *
+        * @return boolean
+        * @api
+        */
+       public function hasTemplate();
+
+}
+?>
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/AliasViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/AliasViewHelper.php
new file mode 100644 (file)
index 0000000..ec1f3f2
--- /dev/null
@@ -0,0 +1,77 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Declares new variables which are aliases of other variables.
+ * Takes a "map"-Parameter which is an associative array which defines the shorthand mapping.
+ *
+ * The variables are only declared inside the <f:alias>...</f:alias>-tag. After the
+ * closing tag, all declared variables are removed again.
+ *
+ * = Examples =
+ *
+ * <code title="Single alias">
+ * <f:alias map="{x: 'foo'}">{x}</f:alias>
+ * </code>
+ * <output>
+ * foo
+ * </output>
+ *
+ * <code title="Multiple mappings">
+ * <f:alias map="{x: foo.bar.baz, y: foo.bar.baz.name}">
+ *   {x.name} or {y}
+ * </f:alias>
+ * </code>
+ * <output>
+ * [name] or [name]
+ * depending on {foo.bar.baz}
+ * </output>
+ *
+ * @version $Id: AliasViewHelper.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage ViewHelpers
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ * @scope prototype
+ */
+class Tx_Fluid_ViewHelpers_AliasViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
+
+       /**
+        *
+        * @param array $map 
+        * @return string Rendered string
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function render(array $map) {
+               foreach ($map as $aliasName => $value) {
+                       $this->templateVariableContainer->add($aliasName, $value);
+               }
+               $output = $this->renderChildren();
+               foreach ($map as $aliasName => $value) {
+                       $this->templateVariableContainer->remove($aliasName);
+               }
+               return $output;
+       }
+}
+
+?>
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/BaseViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/BaseViewHelper.php
new file mode 100644 (file)
index 0000000..04deb49
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * View helper which creates a <base href="..."></base> tag. The Base URI
+ * is taken from the current request.
+ * In FLOW3, you should always include this ViewHelper to make the links work.
+ *
+ * = Examples =
+ *
+ * <code title="Example">
+ * <f:base />
+ * </code>
+ * <output>
+ * <base href="http://yourdomain.tld/"></base>
+ * (depending on your domain)
+ * </output>
+ *
+ * @version $Id: BaseViewHelper.php 1734 2009-11-25 21:53:57Z stucki $
+ * @package Fluid
+ * @subpackage ViewHelpers
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ * @scope prototype
+ */
+class Tx_Fluid_ViewHelpers_BaseViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
+
+       /**
+        * Render the "Base" tag by outputting $request->getBaseUri()
+        *
+        * Note: renders as <base></base>, because IE6 will else refuse to display
+        * the page...
+        *
+        * @return string "base"-Tag.
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function render() {
+               $currentRequest = $this->controllerContext->getRequest();
+               return '<base href="' . $currentRequest->getBaseUri() . '"></base>';
+       }
+}
+
+?>
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Be/AbstractBackendViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Be/AbstractBackendViewHelper.php
new file mode 100644 (file)
index 0000000..18be285
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * The abstract base class for all backend view helpers
+ * Note: backend view helpers are still experimental!
+ *
+ * @version $Id:
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ *
+ * @package     Fluid
+ * @subpackage  ViewHelpers\Be
+ * @author      Steffen Kamper <info@sk-typo3.de>
+ * @author      Bastian Waidelich <bastian@typo3.org>
+ * @license     http://www.gnu.org/copyleft/gpl.html
+ * @version     SVN: $Id:
+ *
+ */
+abstract class Tx_Fluid_ViewHelpers_Be_AbstractBackendViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
+
+       /**
+       * Gets instance of template if exists or create a new one.
+       * Saves instance in viewHelperVariableContainer
+       *
+       * @return template $doc
+       */
+       public function getDocInstance() {
+               if (!isset($GLOBALS['SOBE']->doc)) {
+                       $GLOBALS['SOBE']->doc = t3lib_div::makeInstance('template');
+                       $GLOBALS['SOBE']->doc->backPath = $GLOBALS['BACK_PATH'];
+               }
+               return $GLOBALS['SOBE']->doc;
+       }
+
+}
+?>
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Be/Buttons/CshViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Be/Buttons/CshViewHelper.php
new file mode 100644 (file)
index 0000000..8868a5b
--- /dev/null
@@ -0,0 +1,71 @@
+<?php
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * View helper which returns CSH (context sensitive help) button with icon
+ * Note: The CSH button will only work, if the current BE user has
+ * the "Context Sensitive Help mode" set to something else than
+ *  "Display no help information" in the Users settings
+ * Note: This view helper is experimental!
+ *
+ * = Examples =
+ *
+ * <code title="Default">
+ * <f:be.buttons.csh />
+ * </code>
+ *
+ * Output:
+ * CSH button as known from the TYPO3 backend.
+ *
+ *
+ * @package     Fluid
+ * @subpackage  ViewHelpers\Be\Buttons
+ * @author             Steffen Kamper <info@sk-typo3.de>
+ * @author             Bastian Waidelich <bastian@typo3.org>
+ * @license     http://www.gnu.org/copyleft/gpl.html
+ * @version     SVN: $Id:
+ *
+ */
+class Tx_Fluid_ViewHelpers_Be_Buttons_CshViewHelper extends Tx_Fluid_ViewHelpers_Be_AbstractBackendViewHelper {
+
+
+       /**
+        * Render context sensitive help (CSH) for the given table
+        *
+        * @param string $table Table name ('_MOD_'+module name). If not set, the current module name will be used
+        * @param string $field Field name (CSH locallang main key)
+        * @param boolean $iconOnly If set, the full text will never be shown (only icon)
+        * @param string $styleAttributes Additional style-attribute content for wrapping table (full text mode only)
+        * @return string the rendered CSH icon
+        * @see t3lib_BEfunc::cshItem
+        */
+       public function render($table = NULL, $field = '', $iconOnly = FALSE, $styleAttributes = '') {
+               if ($table === NULL) {
+                       $currentRequest = $this->controllerContext->getRequest();
+                       $moduleName = $currentRequest->getPluginName();
+                       $table = '_MOD_' . $moduleName;
+               }
+               $cshButton = t3lib_BEfunc::cshItem($table, $field, $GLOBALS['BACK_PATH'], '', $iconOnly, $styleAttributes);
+
+               return '<div class="docheader-csh">' . $cshButton . '</div>';
+       }
+}
+?>
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Be/Buttons/IconViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Be/Buttons/IconViewHelper.php
new file mode 100644 (file)
index 0000000..652b8c3
--- /dev/null
@@ -0,0 +1,75 @@
+<?php
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * View helper which returns save button with icon
+ * Note: This view helper is experimental!
+ *
+ * = Examples =
+ *
+ * <code title="Default">
+ * <f:be.buttons.icon uri="{f:uri.action()}" />
+ * </code>
+ *
+ * Output:
+ * An icon button as known from the TYPO3 backend, skinned and linked with the default action of the current controller.
+ * Note: By default the "close" icon is used as image
+ *
+ * <code title="Default">
+ * <f:be.buttons.icon uri="{f:uri.action(action='new')}" icon="new_el" title="Create new Foo" />
+ * </code>
+ *
+ * Output:
+ * This time the "new_el" icon is returned, the button has the title attribute set and links to the "new" action of the current controller.
+ *
+ * @package     Fluid
+ * @subpackage  ViewHelpers\Be\Buttons
+ * @author             Steffen Kamper <info@sk-typo3.de>
+ * @author             Bastian Waidelich <bastian@typo3.org>
+ * @license     http://www.gnu.org/copyleft/gpl.html
+ * @version     SVN: $Id:
+ *
+ */
+class Tx_Fluid_ViewHelpers_Be_Buttons_IconViewHelper extends Tx_Fluid_ViewHelpers_Be_AbstractBackendViewHelper {
+
+       /**
+        * @var array allowed icons to be used with this view helper
+        */
+       protected $allowedIcons = array('add', 'add_workspace', 'button_down', 'button_hide', 'button_left', 'button_unhide', 'button_right', 'button_up', 'clear_cache', 'clip_copy', 'clip_cut', 'clip_pasteafter', 'closedok', 'datepicker', 'deletedok', 'edit2', 'helpbubble', 'icon_fatalerror', 'icon_note', 'icon_ok', 'icon_warning', 'new_el', 'options', 'perm', 'refresh_n', 'saveandclosedok', 'savedok', 'savedoknew', 'savedokshow', 'viewdok', 'zoom');
+
+       /**
+        * Renders an icon link as known from the TYPO3 backend
+        *
+        * @param string $uri the target URI for the link. If you want to execute JavaScript here, prefix the URI with "javascript:"
+        * @param string $icon Icon to be used. See self::allowedIcons for a list of allowed icon names
+        * @param string $title Title attribte of the resulting link
+        * @return string the rendered icon link
+        */
+       public function render($uri, $icon = 'closedok', $title = '') {
+               if (!in_array($icon, $this->allowedIcons)) {
+                       throw new Tx_Fluid_Core_ViewHelper_Exception('"' . $icon . '" is no valid icon. Allowed are "' . implode('", "', $this->allowedIcons) .'".', 1253208523);
+               }
+
+               $skinnedIcon = t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/' . $icon . '.gif', '');
+               return '<a href="' . $uri . '"><img' . $skinnedIcon . '" title="' . htmlspecialchars($title) . '" alt="" /></a>';
+       }
+}
+?>
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Be/Buttons/ShortcutViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Be/Buttons/ShortcutViewHelper.php
new file mode 100644 (file)
index 0000000..512cb22
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * View helper which returns shortcut button with icon
+ * Note: This view helper is experimental!
+ *
+ * = Examples =
+ *
+ * <code title="Default">
+ * <f:be.buttons.shortcut />
+ * </code>
+ *
+ * Output:
+ * Shortcut button as known from the TYPO3 backend.
+ * By default the current page id, module name and all module arguments will be stored
+ *
+ * <code title="Explicitly set parameters to be stored in the shortcut">
+ * <f:be.buttons.shortcut getVars="{0: 'M', 1: 'myOwnPrefix'}" setVars="{0: 'function'}" />
+ * </code>
+ *
+ * Output:
+ * Shortcut button as known from the TYPO3 backend.
+ * This time only the specified GET parameters and SET[]-settings will be stored.
+ * Note:
+ * Normally you won't need to set getVars & setVars parameters in Extbase modules
+ *
+ * @package     Fluid
+ * @subpackage  ViewHelpers\Be\Buttons
+ * @author             Steffen Kamper <info@sk-typo3.de>
+ * @author             Bastian Waidelich <bastian@typo3.org>
+ * @license     http://www.gnu.org/copyleft/gpl.html
+ * @version     SVN: $Id:
+ *
+ */
+class Tx_Fluid_ViewHelpers_Be_Buttons_ShortcutViewHelper extends Tx_Fluid_ViewHelpers_Be_AbstractBackendViewHelper {
+
+
+       /**
+        * Renders a shortcut button as known from the TYPO3 backend
+        *
+        * @param array $getVars list of GET variables to store. By default the current id, module and all module arguments will be stored
+        * @param array $setVars list of SET[] variables to store. See template::makeShortcutIcon(). Normally won't be used by Extbase modules
+        * @return string the rendered shortcut button
+        * @see template::makeShortcutIcon()
+        */
+       public function render(array $getVars = array(), array $setVars = array()) {
+               $doc = $this->getDocInstance();
+               $currentRequest = $this->controllerContext->getRequest();
+               $extensionName = $currentRequest->getControllerExtensionName();
+               $moduleName = $currentRequest->getPluginName();
+
+               if (count($getVars) === 0) {
+                       $modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName);
+                       $getVars = array('id', 'M', $modulePrefix);
+               }
+               $getList = implode(',', $getVars);
+               $setList = implode(',', $setVars);
+
+               return $doc->makeShortcutIcon($getList, $setList, $moduleName);
+       }
+}
+?>
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Be/ContainerViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Be/ContainerViewHelper.php
new file mode 100644 (file)
index 0000000..8b3f6b7
--- /dev/null
@@ -0,0 +1,115 @@
+<?php
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * View helper which allows you to create extbase based modules in the style of TYPO3 default modules.
+ * Note: This feature is experimental!
+ *
+ * = Examples =
+ *
+ * <code title="Simple">
+ * <f:be.container>your module content</f:be.container>
+ * </code>
+ *
+ * Output:
+ * "your module content" wrapped with propper head & body tags.
+ * Default backend CSS styles and JavaScript will be included
+ *
+ * <code title="All options">
+ * <f:be.container pageTitle="foo" enableJumpToUrl="false" enableClickMenu="false" loadPrototype="false" loadScriptaculous="false" scriptaculousModule="someModule,someOtherModule" loadExtJs="true" loadExtJsTheme="false" extJsAdapter="jQuery" enableExtJsDebug="true" addCssFile="{f:uri.resource(path:'styles/backend.css')}" addJsFile="{f:uri.resource('scripts/main.js')}">your module content</f:be.container>
+ * </code>
+ *
+ * Output:
+ * "your module content" wrapped with propper head & body tags.
+ * Custom CSS file EXT:your_extension/Resources/Public/styles/backend.css and JavaScript file EXT:your_extension/Resources/Public/scripts/main.js will be loaded
+ *
+ * @package     Fluid
+ * @subpackage  ViewHelpers\Be
+ * @author      Bastian Waidelich <bastian@typo3.org>
+ * @license     http://www.gnu.org/copyleft/gpl.html
+ * @version     SVN: $Id:
+ *
+ */
+class Tx_Fluid_ViewHelpers_Be_ContainerViewHelper extends Tx_Fluid_ViewHelpers_Be_AbstractBackendViewHelper {
+
+       /**
+        * Render start page with template.php and pageTitle
+        *
+        * @param string  $pageTitle title tag of the module. Not required by default, as BE modules are shown in a frame
+        * @param boolean $enableJumpToUrl If TRUE, includes "jumpTpUrl" javascript function required by ActionMenu. Defaults to TRUE
+        * @param boolean $enableClickMenu If TRUE, loads clickmenu.js required by BE context menus. Defaults to TRUE
+        * @param boolean $loadPrototype specifies whether to load prototype library. Defaults to TRUE
+        * @param boolean $loadScriptaculous specifies whether to load scriptaculous libraries. Defaults to FALSE
+        * @param string  $scriptaculousModule additionales modules for scriptaculous
+        * @param boolean $loadExtJs specifies whether to load ExtJS library. Defaults to FALSE
+        * @param boolean $loadExtJsTheme whether to load ExtJS "grey" theme. Defaults to FALSE
+        * @param string  $extJsAdapter load alternative adapter (ext-base is default adapter)
+        * @param boolean $enableExtJsDebug if TRUE, debug version of ExtJS is loaded. Use this for development only
+        * @param string $addCssFile Custom CSS file to be loaded
+        * @param string $addJsFile Custom JavaScript file to be loaded
+        * @return string
+        * @see template
+        * @see t3lib_PageRenderer
+        */
+       public function render($pageTitle = '', $enableJumpToUrl = TRUE, $enableClickMenu = TRUE, $loadPrototype = TRUE, $loadScriptaculous = FALSE, $scriptaculousModule = '', $loadExtJs = FALSE, $loadExtJsTheme = TRUE, $extJsAdapter = '', $enableExtJsDebug = FALSE, $addCssFile = NULL, $addJsFile = NULL) {
+               $doc = $this->getDocInstance();
+               $pageRenderer = $doc->getPageRenderer();
+
+               if ($enableJumpToUrl) {
+                       $doc->JScode .= '
+                               <script language="javascript" type="text/javascript">
+                                       script_ended = 0;
+                                       function jumpToUrl(URL) {
+                                               document.location = URL;
+                                       }
+                                       ' . $doc->redirectUrls() . '
+                               </script>
+                       ';
+               }
+               if ($enableClickMenu) {
+                       $doc->loadJavascriptLib('js/clickmenu.js');
+               }
+               if ($loadPrototype) {
+                       $pageRenderer->loadPrototype();
+               }
+               if ($loadScriptaculous) {
+                       $pageRenderer->loadScriptaculous($scriptaculousModule);
+               }
+               if ($loadExtJs) {
+                       $pageRenderer->loadExtJS(true, $loadExtJsTheme, $extJsAdapter);
+                       if ($enableExtJsDebug) {
+                               $pageRenderer->enableExtJsDebug();
+                       }
+               }
+               if ($addCssFile !== NULL) {
+                       $pageRenderer->addCssFile($addCssFile);
+               }
+               if ($addJsFile !== NULL) {
+                       $pageRenderer->addJsFile($addJsFile);
+               }
+
+               $output = $doc->startPage($pageTitle);
+               $output .= $this->renderChildren();
+               $output .= $doc->endPage();
+               return $output;
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Be/Menus/ActionMenuItemViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Be/Menus/ActionMenuItemViewHelper.php
new file mode 100644 (file)
index 0000000..243ad22
--- /dev/null
@@ -0,0 +1,71 @@
+<?php
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *