[TASK] Sync CMS Fluid with Flow Fluid 1.1 (part1)
authorTymoteusz Motylewski <t.motylewski@gmail.com>
Sat, 9 Feb 2013 16:54:41 +0000 (17:54 +0100)
committerMarc Bastian Heinrichs <typo3@mbh-software.de>
Sat, 9 Feb 2013 17:59:07 +0000 (18:59 +0100)
This is the first part of a backport fluid from Flow.
It contains small changes, mostly CGL related.

Change-Id: I72ccac5427638f8525e6b9c754dc5eafb5095dc1
Releases: 6.1
Resolves: #44819
Reviewed-on: https://review.typo3.org/17725
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Marc Bastian Heinrichs
Tested-by: Marc Bastian Heinrichs
33 files changed:
typo3/sysext/fluid/Classes/Core/Parser/Configuration.php
typo3/sysext/fluid/Classes/Core/Parser/Interceptor/Escape.php
typo3/sysext/fluid/Classes/Core/Parser/ParsedTemplateInterface.php
typo3/sysext/fluid/Classes/Core/Parser/ParsingState.php
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/AbstractNode.php
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/BooleanNode.php
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/NodeInterface.php
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/ObjectAccessorNode.php
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/RenderingContextAwareInterface.php
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/RootNode.php
typo3/sysext/fluid/Classes/Core/Parser/SyntaxTree/TextNode.php
typo3/sysext/fluid/Classes/Core/Rendering/RenderingContext.php
typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractConditionViewHelper.php
typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractTagBasedViewHelper.php
typo3/sysext/fluid/Classes/Core/ViewHelper/Facets/ChildNodeAccessInterface.php
typo3/sysext/fluid/Classes/Core/ViewHelper/Facets/CompilableInterface.php
typo3/sysext/fluid/Classes/Core/ViewHelper/Facets/PostParseInterface.php
typo3/sysext/fluid/Classes/Core/ViewHelper/TemplateVariableContainer.php
typo3/sysext/fluid/Classes/Fluid.php
typo3/sysext/fluid/Classes/ViewHelpers/CommentViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/CountViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/CycleViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/ElseViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/ButtonViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Format/Nl2brViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Format/NumberViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Format/PaddingViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Format/RawViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Format/StripTagsViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Format/UrlencodeViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Link/ExternalViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Uri/ExternalViewHelper.php
typo3/sysext/fluid/Tests/Unit/Core/Parser/Interceptor/EscapeTest.php

index 3ebbe28..0a70dbe 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\Core\Parser;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * The parser configuration. Contains all configuration needed to configure
  * the building of a SyntaxTree.
@@ -43,8 +44,8 @@ class Configuration {
        /**
         * Returns all interceptors for a given Interception Point.
         *
-        * @param integer $interceptionPoint one of the Tx_Fluid_Core_Parser_InterceptorInterface::INTERCEPT_* constants,
-        * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<Tx_Fluid_Core_Parser_InterceptorInterface>
+        * @param integer $interceptionPoint one of the \TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface::INTERCEPT_* constants,
+        * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface>
         */
        public function getInterceptors($interceptionPoint) {
                if (isset($this->interceptors[$interceptionPoint]) && $this->interceptors[$interceptionPoint] instanceof \TYPO3\CMS\Extbase\Persistence\ObjectStorage) {
index 725f5c9..00a1a55 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\Core\Parser\Interceptor;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * An interceptor adding the escape viewhelper to the suitable places.
  */
@@ -26,7 +27,7 @@ class Escape implements \TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface {
         * A stack of ViewHelperNodes which currently disable the interceptor.
         * Needed to enable the interceptor again.
         *
-        * @var array<Tx_Fluid_Core_Parser_SyntaxTree_NodeInterface>
+        * @var array<\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NodeInterface>
         */
        protected $viewHelperNodesWhichDisableTheInterceptor = array();
 
@@ -69,7 +70,11 @@ class Escape implements \TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface {
                        }
                } elseif ($this->interceptorEnabled && $node instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ObjectAccessorNode) {
                        $escapeViewHelper = $this->objectManager->get('TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\HtmlspecialcharsViewHelper');
-                       $node = $this->objectManager->create('TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\ViewHelperNode', $escapeViewHelper, array('value' => $node));
+                       $node = $this->objectManager->get(
+                               'TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\ViewHelperNode',
+                               $escapeViewHelper,
+                               array('value' => $node)
+                       );
                }
                return $node;
        }
index 129a795..56381b0 100644 (file)
@@ -10,8 +10,9 @@ namespace TYPO3\CMS\Fluid\Core\Parser;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
- * This interface is returned by Tx_Fluid_Core_Parser_TemplateParser->parse()
+ * This interface is returned by \TYPO3\CMS\Fluid\Core\Parser\TemplateParser->parse()
  * method and is a parsed template
  */
 interface ParsedTemplateInterface {
@@ -26,8 +27,8 @@ interface ParsedTemplateInterface {
 
        /**
         * Returns a variable container used in the PostParse Facet.
-        * TODO: remove
         *
+        * @todo remove
         * @return \TYPO3\CMS\Fluid\Core\ViewHelper\TemplateVariableContainer
         */
        public function getVariableContainer();
index 6ab9d12..de0cb73 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\Core\Parser;
  *                                                                        *
  * 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
@@ -131,9 +132,9 @@ class ParsingState implements \TYPO3\CMS\Fluid\Core\Parser\ParsedTemplateInterfa
 
        /**
         * Returns a variable container which will be then passed to the postParseFacet.
-        * TODO: Rename to getPostParseVariableContainer
         *
         * @return \TYPO3\CMS\Fluid\Core\ViewHelper\TemplateVariableContainer The variable container or NULL if none has been set yet
+        * @todo Rename to getPostParseVariableContainer
         */
        public function getVariableContainer() {
                return $this->variableContainer;
@@ -170,8 +171,8 @@ class ParsingState implements \TYPO3\CMS\Fluid\Core\Parser\ParsedTemplateInterfa
         * This requires the current rendering context in order to be able to evaluate the layout name
         *
         * @param \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
-        * @throws \TYPO3\CMS\Fluid\View\Exception
         * @return string
+        * @throws \TYPO3\CMS\Fluid\View\Exception
         */
        public function getLayoutName(\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext) {
                if (!$this->hasLayout()) {
index 88c5b4d..0a6fd86 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\Core\Parser\SyntaxTree;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * Abstract node in the syntax tree which has been built.
  */
@@ -18,7 +19,7 @@ abstract class AbstractNode implements \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\N
        /**
         * List of Child Nodes.
         *
-        * @var array<Tx_Fluid_Core_Parser_SyntaxTree_NodeInterface>
+        * @var array<\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NodeInterface>
         */
        protected $childNodes = array();
 
@@ -27,6 +28,7 @@ abstract class AbstractNode implements \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\N
         *
         * @param \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
         * @return mixed Normally, an object is returned - in case it is concatenated with a string, a string is returned.
+        * @throws \TYPO3\CMS\Fluid\Core\Parser\Exception
         */
        public function evaluateChildNodes(\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext) {
                $output = NULL;
@@ -43,6 +45,7 @@ abstract class AbstractNode implements \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\N
                                        $output = (string) $output;
                                }
                                $subNodeOutput = $subNode->evaluate($renderingContext);
+
                                if (is_object($subNodeOutput)) {
                                        if (!method_exists($subNodeOutput, '__toString')) {
                                                throw new \TYPO3\CMS\Fluid\Core\Parser\Exception('Cannot cast object of type "' . get_class($subNodeOutput) . '" to string.', 1273753083);
@@ -60,7 +63,7 @@ abstract class AbstractNode implements \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\N
         * 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_NodeInterface> A list of nodes
+        * @return array<\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NodeInterface> A list of nodes
         */
        public function getChildNodes() {
                return $this->childNodes;
index 2c8225a..367b74b 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\Core\Parser\SyntaxTree;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * A node which is used inside boolean arguments
  */
@@ -103,6 +104,7 @@ class BooleanNode extends \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode {
                        // is a text node with a literal comparison like "1 == 1"
                        $childNodes = array($syntaxTreeNode);
                }
+
                $this->leftSide = new \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\RootNode();
                $this->rightSide = new \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\RootNode();
                $this->comparator = NULL;
@@ -113,10 +115,12 @@ class BooleanNode extends \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode {
                                // skip loop and fall back to classical to boolean conversion.
                                break;
                        }
+
                        if ($this->comparator !== NULL) {
                                // comparator already set, we are evaluating the right side of the comparator
                                $this->rightSide->addChildNode($childNode);
-                       } elseif ($childNode instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\TextNode && ($this->comparator = $this->getComparatorFromString($childNode->getText()))) {
+                       } elseif ($childNode instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\TextNode
+                               && ($this->comparator = $this->getComparatorFromString($childNode->getText()))) {
                                // comparator in current string segment
                                $explodedString = explode($this->comparator, $childNode->getText());
                                if (isset($explodedString[0]) && trim($explodedString[0]) !== '') {
@@ -140,6 +144,7 @@ class BooleanNode extends \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode {
                                $this->leftSide->addChildNode($childNode);
                        }
                }
+
                if ($this->comparator === NULL) {
                        // No Comparator found, we need to evaluate the given syntax tree node manually
                        $this->syntaxTreeNode = $syntaxTreeNode;
@@ -196,35 +201,35 @@ class BooleanNode extends \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode {
         *
         * Some special rules apply:
         * - The == and != operators are comparing the Object Identity using === and !==, when one of the two
-        * operands are objects.
+        *   operands are objects.
         * - For arithmetic comparisons (%, >, >=, <, <=), some special rules apply:
-        * - arrays are only comparable with arrays, else the comparison yields FALSE
-        * - objects are only comparable with objects, else the comparison yields FALSE
-        * - the comparison is FALSE when two types are not comparable according to the table
-        * "Comparison with various types" on http://php.net/manual/en/language.operators.comparison.php
+        *   - arrays are only comparable with arrays, else the comparison yields FALSE
+        *   - objects are only comparable with objects, else the comparison yields FALSE
+        *   - the comparison is FALSE when two types are not comparable according to the table
+        *     "Comparison with various types" on http://php.net/manual/en/language.operators.comparison.php
         *
         * This function must be static public, as it is also directly called from cached templates.
         *
         * @param string $comparator
         * @param mixed $evaluatedLeftSide
         * @param mixed $evaluatedRightSide
-        * @throws \TYPO3\CMS\Fluid\Core\Parser\Exception
         * @return boolean TRUE if comparison of left and right side using the comparator emit TRUE, false otherwise
+        * @throws \TYPO3\CMS\Fluid\Core\Parser\Exception
         */
        static public function evaluateComparator($comparator, $evaluatedLeftSide, $evaluatedRightSide) {
                switch ($comparator) {
                        case '==':
                                if (is_object($evaluatedLeftSide) || is_object($evaluatedRightSide)) {
-                                       return $evaluatedLeftSide === $evaluatedRightSide;
+                                       return ($evaluatedLeftSide === $evaluatedRightSide);
                                } else {
-                                       return $evaluatedLeftSide == $evaluatedRightSide;
+                                       return ($evaluatedLeftSide == $evaluatedRightSide);
                                }
                                break;
                        case '!=':
                                if (is_object($evaluatedLeftSide) || is_object($evaluatedRightSide)) {
-                                       return $evaluatedLeftSide !== $evaluatedRightSide;
+                                       return ($evaluatedLeftSide !== $evaluatedRightSide);
                                } else {
-                                       return $evaluatedLeftSide != $evaluatedRightSide;
+                                       return ($evaluatedLeftSide != $evaluatedRightSide);
                                }
                                break;
                        case '%':
@@ -268,7 +273,8 @@ class BooleanNode extends \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode {
         * @return boolean TRUE if the operands can be compared using arithmetic operators, FALSE otherwise.
         */
        static protected function isComparable($evaluatedLeftSide, $evaluatedRightSide) {
-               if ((is_null($evaluatedLeftSide) || is_string($evaluatedLeftSide)) && is_string($evaluatedRightSide)) {
+               if ((is_null($evaluatedLeftSide) || is_string($evaluatedLeftSide))
+                       && is_string($evaluatedRightSide)) {
                        return TRUE;
                }
                if (is_bool($evaluatedLeftSide) || is_null($evaluatedLeftSide)) {
@@ -277,7 +283,8 @@ class BooleanNode extends \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode {
                if (is_object($evaluatedLeftSide) && is_object($evaluatedRightSide)) {
                        return TRUE;
                }
-               if ((is_string($evaluatedLeftSide) || is_resource($evaluatedLeftSide) || is_numeric($evaluatedLeftSide)) && (is_string($evaluatedRightSide) || is_resource($evaluatedRightSide) || is_numeric($evaluatedRightSide))) {
+               if ((is_string($evaluatedLeftSide) || is_resource($evaluatedLeftSide) || is_numeric($evaluatedLeftSide))
+                       && (is_string($evaluatedRightSide) || is_resource($evaluatedRightSide) || is_numeric($evaluatedRightSide))) {
                        return TRUE;
                }
                if (is_array($evaluatedLeftSide) && is_array($evaluatedRightSide)) {
@@ -317,9 +324,9 @@ class BooleanNode extends \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode {
                        return $value > 0;
                }
                if (is_string($value)) {
-                       return !empty($value) && strtolower($value) !== 'false';
+                       return (!empty($value) && strtolower($value) !== 'false');
                }
-               if (is_array($value) || is_object($value) && $value instanceof \Countable) {
+               if (is_array($value) || (is_object($value) && $value instanceof \Countable)) {
                        return count($value) > 0;
                }
                if (is_object($value)) {
@@ -329,4 +336,4 @@ class BooleanNode extends \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode {
        }
 }
 
-?>
\ No newline at end of file
+?>
index e601713..918a542 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\Core\Parser\SyntaxTree;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * Node in the syntax tree.
  */
@@ -26,7 +27,7 @@ interface NodeInterface {
        /**
         * Returns all child nodes for a given node.
         *
-        * @return array<Tx_Fluid_Core_Parser_SyntaxTree_NodeInterface> A list of nodes
+        * @return array<\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\NodeInterface> A list of nodes
         */
        public function getChildNodes();
 
index 7b43ab3..93b2de8 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\Core\Parser\SyntaxTree;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * A node which handles object access. This means it handles structures like {object.accessor.bla}
  */
@@ -85,6 +86,7 @@ class ObjectAccessorNode extends \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\Abstrac
                        } else {
                                $subject = $propertyValue;
                        }
+
                        if ($subject instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\RenderingContextAwareInterface) {
                                $subject->setRenderingContext($renderingContext);
                        }
index d45ce5c..45ee403 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\Core\Parser\SyntaxTree;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * Interface for objects which are aware of Fluid's rendering context. All objects
  * marked with this interface will get the current rendering context injected
@@ -24,6 +25,7 @@ interface RenderingContextAwareInterface {
         * @return void
         */
        public function setRenderingContext(\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext);
+
 }
 
 ?>
\ No newline at end of file
index 3923f66..8786e3d 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\Core\Parser\SyntaxTree;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * Root node of every syntax tree.
  */
index c8aaa58..c4dad2f 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\Core\Parser\SyntaxTree;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * Text Syntax Tree Node - is a container for strings.
  */
@@ -26,6 +27,7 @@ class TextNode extends \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode {
         * Constructor.
         *
         * @param string $text text to store in this textNode
+        * @throws \TYPO3\CMS\Fluid\Core\Parser\Exception
         */
        public function __construct($text) {
                if (!is_string($text)) {
index 8c546e7..d7872bc 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\Core\Rendering;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 class RenderingContext implements \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface {
 
        /**
@@ -52,6 +53,8 @@ class RenderingContext implements \TYPO3\CMS\Fluid\Core\Rendering\RenderingConte
 
        /**
         * Returns the object manager. Only the ViewHelperNode should do this.
+        *
+        * @return \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
         */
        public function getObjectManager() {
                return $this->objectManager;
@@ -114,4 +117,4 @@ class RenderingContext implements \TYPO3\CMS\Fluid\Core\Rendering\RenderingConte
        }
 }
 
-?>
\ No newline at end of file
+?>
index 4708c82..03ed306 100644 (file)
@@ -10,19 +10,33 @@ namespace TYPO3\CMS\Fluid\Core\ViewHelper;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * This view helper is an abstract ViewHelper which implements an if/else condition.
+ * @see TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode::convertArgumentValue() to find see how boolean arguments are evaluated
+ *
+ * = Usage =
+ *
+ * To create a custom Condition ViewHelper, you need to subclass this class, and
+ * implement your own render() method. Inside there, you should call $this->renderThenChild()
+ * if the condition evaluated to TRUE, and $this->renderElseChild() if the condition evaluated
+ * to FALSE.
+ *
+ * Every Condition ViewHelper has a "then" and "else" argument, so it can be used like:
+ * <[aConditionViewHelperName] .... then="condition true" else="condition false" />,
+ * or as well use the "then" and "else" child nodes.
+ *
+ * @see TYPO3\CMS\Fluid\ViewHelpers\IfViewHelper for a more detailed explanation and a simple usage example.
+ * Make sure to NOT OVERRIDE the constructor.
  *
- * @see Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode::convertArgumentValue() to find see how boolean arguments are evaluated
- * @see Tx_Fluid_ViewHelpers_IfViewHelper for a more detailed explanation and a simple usage example.
  * @api
  */
 abstract class AbstractConditionViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper implements \TYPO3\CMS\Fluid\Core\ViewHelper\Facets\ChildNodeAccessInterface, \TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface {
 
        /**
-        * An array of Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode
+        * An array containing child nodes
         *
-        * @var array
+        * @var array<\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode>
         */
        private $childNodes = array();
 
@@ -62,16 +76,20 @@ abstract class AbstractConditionViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHel
                } elseif ($this->hasArgument('__elseClosure') || $this->hasArgument('else')) {
                        return '';
                }
+
                $elseViewHelperEncountered = FALSE;
                foreach ($this->childNodes as $childNode) {
-                       if ($childNode instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode && $childNode->getViewHelperClassName() === 'TYPO3\\CMS\\Fluid\\ViewHelpers\\ThenViewHelper') {
+                       if ($childNode instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode
+                               && $childNode->getViewHelperClassName() === 'TYPO3\\CMS\\Fluid\\ViewHelpers\\ThenViewHelper') {
                                $data = $childNode->evaluate($this->renderingContext);
                                return $data;
                        }
-                       if ($childNode instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode && $childNode->getViewHelperClassName() === 'TYPO3\\CMS\\Fluid\\ViewHelpers\\ElseViewHelper') {
+                       if ($childNode instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode
+                               && $childNode->getViewHelperClassName() === 'TYPO3\\CMS\\Fluid\\ViewHelpers\\ElseViewHelper') {
                                $elseViewHelperEncountered = TRUE;
                        }
                }
+
                if ($elseViewHelperEncountered) {
                        return '';
                } else {
@@ -96,10 +114,12 @@ abstract class AbstractConditionViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHel
                        return $elseClosure();
                }
                foreach ($this->childNodes as $childNode) {
-                       if ($childNode instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode && $childNode->getViewHelperClassName() === 'TYPO3\\CMS\\Fluid\\ViewHelpers\\ElseViewHelper') {
+                       if ($childNode instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode
+                               && $childNode->getViewHelperClassName() === 'TYPO3\\CMS\\Fluid\\ViewHelpers\\ElseViewHelper') {
                                return $childNode->evaluate($this->renderingContext);
                        }
                }
+
                return '';
        }
 
@@ -117,11 +137,15 @@ abstract class AbstractConditionViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHel
         */
        public function compile($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode, \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler) {
                foreach ($syntaxTreeNode->getChildNodes() as $childNode) {
-                       if ($childNode instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode && $childNode->getViewHelperClassName() === 'TYPO3\\CMS\\Fluid\\ViewHelpers\\ThenViewHelper') {
+                       if ($childNode instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode
+                               && $childNode->getViewHelperClassName() === 'TYPO3\\CMS\\Fluid\\ViewHelpers\\ThenViewHelper') {
+
                                $childNodesAsClosure = $templateCompiler->wrapChildNodesInClosure($childNode);
                                $initializationPhpCode .= sprintf('%s[\'__thenClosure\'] = %s;', $argumentsVariableName, $childNodesAsClosure) . chr(10);
                        }
-                       if ($childNode instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode && $childNode->getViewHelperClassName() === 'TYPO3\\CMS\\Fluid\\ViewHelpers\\ElseViewHelper') {
+                       if ($childNode instanceof \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode
+                               && $childNode->getViewHelperClassName() === 'TYPO3\\CMS\\Fluid\\ViewHelpers\\ElseViewHelper') {
+
                                $childNodesAsClosure = $templateCompiler->wrapChildNodesInClosure($childNode);
                                $initializationPhpCode .= sprintf('%s[\'__elseClosure\'] = %s;', $argumentsVariableName, $childNodesAsClosure) . chr(10);
                        }
index c43348e..53b9901 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\Core\ViewHelper;
  *                                                                        *
  * 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
@@ -78,6 +79,7 @@ abstract class AbstractTagBasedViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelp
                if ($this->hasArgument('additionalAttributes') && is_array($this->arguments['additionalAttributes'])) {
                        $this->tag->addAttributes($this->arguments['additionalAttributes']);
                }
+
                if (isset(self::$tagAttributes[get_class($this)])) {
                        foreach (self::$tagAttributes[get_class($this)] as $attributeName) {
                                if ($this->hasArgument($attributeName) && $this->arguments[$attributeName] !== '') {
index d28a0af..fcaabce 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\Core\ViewHelper\Facets;
  *                                                                        *
  * 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.
@@ -18,16 +19,15 @@ namespace TYPO3\CMS\Fluid\Core\ViewHelper\Facets;
  * To render subnodes, you can fetch the RenderingContext via $this->renderingContext.
  *
  * In most cases, you will not need this facet, and it is NO PUBLIC API!
- * Right now it is only used internally for conditions, so by subclassing Tx_Fluid_Core_ViewHelpers_AbstractConditionViewHelper, this should be all you need.
+ * Right now it is only used internally for conditions, so by subclassing TYPO3\CMS\Fluid\Core\ViewHelpers\AbstractConditionViewHelper, this should be all you need.
  *
- * See Tx_Fluid_ViewHelpers_IfViewHelper for an example how it is used.
+ * See \TYPO3\CMS\Fluid\ViewHelpers\IfViewHelper for an example how it is used.
  */
 interface ChildNodeAccessInterface {
-
        /**
         * Sets the direct child nodes of the current syntax tree node.
         *
-        * @param array<Tx_Fluid_Core_Parser_SyntaxTree_AbstractNode> $childNodes
+        * @param array<\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode> $childNodes
         * @return void
         */
        public function setChildNodes(array $childNodes);
index 2ba693f..fb51dda 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\Core\ViewHelper\Facets;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * If a ViewHelper implements CompilableInterface, it can directly influence the way
  * the syntax tree is compiled to a static PHP file.
@@ -60,9 +61,9 @@ interface CompilableInterface {
         * $renderingContext contains references to the TemplateVariableContainer, the
         * ViewHelperVariableContainer and the ControllerContext.
         *
-        * @var array $arguments
-        * @var \Closure $renderChildrenClosure
-        * @var \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
+        * @param array $arguments
+        * @param \Closure $renderChildrenClosure
+        * @param \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
         * @return string the resulting string which is directly shown
         */
        static public function renderStatic(array $arguments, \Closure $renderChildrenClosure, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext);
@@ -85,7 +86,7 @@ interface CompilableInterface {
         * Return Value
         * ============
         * Besides returning a single string, it can also return the constant
-        * Tx_Fluid_Core_Compiler_TemplateCompiler::SHOULD_GENERATE_VIEWHELPER_INVOCATION
+        * \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler::SHOULD_GENERATE_VIEWHELPER_INVOCATION
         * which means that after the $initializationPhpCode, the ViewHelper invocation
         * is built as normal. This is especially needed if you want to build new arguments
         * at run-time, as it is done for the AbstractConditionViewHelper.
index 38728c7..64ddb7b 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\Core\ViewHelper\Facets;
  *                                                                        *
  * 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
@@ -17,7 +18,7 @@ namespace TYPO3\CMS\Fluid\Core\ViewHelper\Facets;
  *
  * 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
+ * This implicates that you usually have to adjust the \TYPO3\CMS\Fluid\View\TemplateView
  * in case you implement this facet.
  *
  * Normally, this facet is not needed, except in really really rare cases.
@@ -39,6 +40,7 @@ interface PostParseInterface {
         * @return void
         */
        static public function postParseEvent(\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode $syntaxTreeNode, array $viewHelperArguments, \TYPO3\CMS\Fluid\Core\ViewHelper\TemplateVariableContainer $variableContainer);
+
 }
 
 ?>
\ No newline at end of file
index 027375b..dcdb09e 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\Core\ViewHelper;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * VariableContainer which stores template variables.
  * Is used in two contexts:
@@ -50,16 +51,16 @@ class TemplateVariableContainer implements \ArrayAccess {
         *
         * @param string $identifier Identifier of the variable to add
         * @param mixed $value The variable's value
-        * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException
         * @return void
+        * @throws Exception\InvalidVariableException
         * @api
         */
        public function add($identifier, $value) {
                if (array_key_exists($identifier, $this->variables)) {
-                       throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException('Duplicate variable declarations!', 1224479063);
+                       throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException('Duplicate variable declaration, "' . $identifier . '" already set!', 1224479063);
                }
                if (in_array(strtolower($identifier), self::$reservedVariableNames)) {
-                       throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException('"' . $identifier . '" is a reserved variable name and can\'t be used as variable identifier.', 1256730379);
+                       throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException('"' . $identifier . '" is a reserved variable name and cannot be used as variable identifier.', 1256730379);
                }
                $this->variables[$identifier] = $value;
        }
@@ -67,9 +68,11 @@ class TemplateVariableContainer implements \ArrayAccess {
        /**
         * Get a variable from the context. Throws exception if variable is not found in context.
         *
+        * If "_all" is given as identifier, all variables are returned in an array.
+        *
         * @param string $identifier
-        * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException
-        * @return mixed The variable identified by $identifier
+        * @return mixed The variable value identified by $identifier
+        * @throws Exception\InvalidVariableException
         * @api
         */
        public function get($identifier) {
@@ -86,8 +89,8 @@ class TemplateVariableContainer implements \ArrayAccess {
         * Remove a variable from context. Throws exception if variable is not found in context.
         *
         * @param string $identifier The identifier to remove
-        * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException
         * @return void
+        * @throws Exception\InvalidVariableException
         * @api
         */
        public function remove($identifier) {
@@ -126,6 +129,7 @@ class TemplateVariableContainer implements \ArrayAccess {
                if ($identifier === '_all') {
                        return TRUE;
                }
+
                return array_key_exists($identifier, $this->variables);
        }
 
@@ -146,7 +150,7 @@ class TemplateVariableContainer implements \ArrayAccess {
         * @return void
         */
        public function offsetSet($identifier, $value) {
-               return $this->add($identifier, $value);
+               $this->add($identifier, $value);
        }
 
        /**
@@ -156,7 +160,7 @@ class TemplateVariableContainer implements \ArrayAccess {
         * @return void
         */
        public function offsetUnset($identifier) {
-               return $this->remove($identifier);
+               $this->remove($identifier);
        }
 
        /**
index 21f7a22..5625acb 100644 (file)
@@ -18,6 +18,17 @@ class Fluid {
        const LEGACY_NAMESPACE_SEPARATOR = '_';
        const NAMESPACE_SEPARATOR = '\\';
 
+       /**
+        * Can be used to enable the verbose mode of Fluid.
+        *
+        * This enables the following things:
+        * - ViewHelper argument descriptions are being parsed from the PHPDoc
+        *
+        * This is NO PUBLIC API and the way this mode is enabled might change without
+        * notice in the future.
+        *
+        * @var boolean
+        */
        static public $debugMode = FALSE;
 }
 
index 6424a59..adfa480 100644 (file)
@@ -10,9 +10,10 @@ namespace TYPO3\CMS\Fluid\ViewHelpers;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * This ViewHelper prevents rendering of any content inside the tag
- * Note: Contents of the comment will still be *parsed* thus throwing an
+ * Note: Contents of the comment will still be **parsed** thus throwing an
  * Exception if it contains syntax errors. You can put child nodes in
  * CDATA tags to avoid this.
  *
@@ -21,8 +22,8 @@ namespace TYPO3\CMS\Fluid\ViewHelpers;
  * <code title="Commenting out fluid code">
  * Before
  * <f:comment>
- * This is completely hidden.
- * <f:debug>This does not get parsed</f:debug>
+ *   This is completely hidden.
+ *   <f:debug>This does not get parsed</f:debug>
  * </f:comment>
  * After
  * </code>
@@ -33,7 +34,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers;
  *
  * <code title="Prevent parsing">
  * <f:comment><![CDATA[
- * <f:some.invalid.syntax />
+ *  <f:some.invalid.syntax />
  * ]]></f:comment>
  * </code>
  * <output>
index cba64dd..31da33b 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * This ViewHelper counts elements of the specified array or countable object.
  *
@@ -41,8 +42,9 @@ class CountViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelpe
        /**
         * Counts the items of a given property.
         *
-        * @param array $subject The array or Countable to be counted
+        * @param array $subject The array or \Countable to be counted
         * @return integer The number of elements
+        * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
         * @api
         */
        public function render($subject = NULL) {
@@ -50,7 +52,7 @@ class CountViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelpe
                        $subject = $this->renderChildren();
                }
                if (is_object($subject) && !$subject instanceof \Countable) {
-                       throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception('CountViewHelper only supports arrays and objects implementing Countable interface. Given: "' . get_class($subject) . '"', 1279808078);
+                       throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception('CountViewHelper only supports arrays and objects implementing \Countable interface. Given: "' . get_class($subject) . '"', 1279808078);
                }
                return count($subject);
        }
index 0922ea4..73fc773 100644 (file)
@@ -10,10 +10,11 @@ namespace TYPO3\CMS\Fluid\ViewHelpers;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * This ViewHelper cycles through the specified values.
  * This can be often used to specify CSS classes for example.
- * Note:** To achieve the "zebra class" effect in a loop you can also use the "iteration" argument of the **for** ViewHelper.
+ * **Note:** To achieve the "zebra class" effect in a loop you can also use the "iteration" argument of the **for** ViewHelper.
  *
  * = Examples =
  *
@@ -26,19 +27,19 @@ namespace TYPO3\CMS\Fluid\ViewHelpers;
  *
  * <code title="Alternating CSS class">
  * <ul>
- * <f:for each="{0:1, 1:2, 2:3, 3:4}" as="foo">
- * <f:cycle values="{0: 'odd', 1: 'even'}" as="zebraClass">
- * <li class="{zebraClass}">{foo}</li>
- * </f:cycle>
- * </f:for>
+ *   <f:for each="{0:1, 1:2, 2:3, 3:4}" as="foo">
+ *     <f:cycle values="{0: 'odd', 1: 'even'}" as="zebraClass">
+ *       <li class="{zebraClass}">{foo}</li>
+ *     </f:cycle>
+ *   </f:for>
  * </ul>
  * </code>
  * <output>
  * <ul>
- * <li class="odd">1</li>
- * <li class="even">2</li>
- * <li class="odd">3</li>
- * <li class="even">4</li>
+ *   <li class="odd">1</li>
+ *   <li class="even">2</li>
+ *   <li class="odd">3</li>
+ *   <li class="even">4</li>
  * </ul>
  * </output>
  *
@@ -61,7 +62,7 @@ class CycleViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelpe
        protected $currentCycleIndex = NULL;
 
        /**
-        * @param array $values The array or object implementing ArrayAccess (for example \TYPO3\CMS\Extbase\Persistence\ObjectStorage) to iterated over
+        * @param array $values The array or object implementing \ArrayAccess (for example \TYPO3\CMS\Extbase\Persistence\ObjectStorage) to iterated over
         * @param string $as The name of the iteration variable
         * @return string Rendered result
         * @api
@@ -76,25 +77,28 @@ class CycleViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelpe
                if ($this->currentCycleIndex === NULL || $this->currentCycleIndex >= count($this->values)) {
                        $this->currentCycleIndex = 0;
                }
+
                $currentValue = isset($this->values[$this->currentCycleIndex]) ? $this->values[$this->currentCycleIndex] : NULL;
                $this->templateVariableContainer->add($as, $currentValue);
                $output = $this->renderChildren();
                $this->templateVariableContainer->remove($as);
-               $this->currentCycleIndex++;
+
+               $this->currentCycleIndex ++;
+
                return $output;
        }
 
        /**
         * Sets this->values to the current values argument and resets $this->currentCycleIndex.
         *
-        * @param array $values The array or \TYPO3\CMS\Extbase\Persistence\ObjectStorage to be stored in $this->values
-        * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
+        * @param array|\Traversable $values The array or \TYPO3\CMS\Extbase\Persistence\ObjectStorage to be stored in $this->values
         * @return void
+        * @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
         */
        protected function initializeValues($values) {
                if (is_object($values)) {
                        if (!$values instanceof \Traversable) {
-                               throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception('CycleViewHelper only supports arrays and objects implementing Traversable interface', 1248728393);
+                               throw new \TYPO3\CMS\Fluid\Core\ViewHelper\Exception('CycleViewHelper only supports arrays and objects implementing \Traversable interface' , 1248728393);
                        }
                        $this->values = iterator_to_array($values, FALSE);
                } else {
index 7f2a00a..adc11b5 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * Else-Branch of a condition. Only has an effect inside of "If". See the If-ViewHelper for documentation.
  *
@@ -17,9 +18,9 @@ namespace TYPO3\CMS\Fluid\ViewHelpers;
  *
  * <code title="Output content if condition is not met">
  * <f:if condition="{someCondition}">
- * <f:else>
- * condition was not true
- * </f:else>
+ *   <f:else>
+ *     condition was not true
+ *   </f:else>
  * </f:if>
  * </code>
  * <output>
@@ -27,7 +28,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers;
  * Otherwise nothing is outputted in this example.
  * </output>
  *
- * @see Tx_Fluid_ViewHelpers_IfViewHelper
+ * @see TYPO3\CMS\Fluid\ViewHelpers\IfViewHelper
  * @api
  */
 class ElseViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/ButtonViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/ButtonViewHelper.php
new file mode 100644 (file)
index 0000000..a3cfc6f
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+namespace TYPO3\CMS\Fluid\ViewHelpers\Form;
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "TYPO3.Fluid".                *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License, either version 3   *
+ *  of the License, or (at your option) any later version.                *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Creates a button.
+ *
+ * = Examples =
+ *
+ * <code title="Defaults">
+ * <f:form.button>Send Mail</f:form.button>
+ * </code>
+ * <output>
+ * <button type="submit" name="" value="">Send Mail</button>
+ * </output>
+ *
+ * <code title="Disabled cancel button with some HTML5 attributes">
+ * <f:form.button type="reset" name="buttonName" value="buttonValue" disabled="disabled" formmethod="post" formnovalidate="formnovalidate">Cancel</f:form.button>
+ * </code>
+ * <output>
+ * <button disabled="disabled" formmethod="post" formnovalidate="formnovalidate" type="reset" name="myForm[buttonName]" value="buttonValue">Cancel</button>
+ * </output>
+ *
+ * @api
+ */
+class ButtonViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper {
+
+       /**
+        * @var string
+        */
+       protected $tagName = 'button';
+
+       /**
+        * Initialize the arguments.
+        *
+        * @return void
+        * @api
+        */
+       public function initializeArguments() {
+               parent::initializeArguments();
+               $this->registerTagAttribute('autofocus', 'string', 'Specifies that a button should automatically get focus when the page loads');
+               $this->registerTagAttribute('disabled', 'string', 'Specifies that the input element should be disabled when the page loads');
+               $this->registerTagAttribute('form', 'string', 'Specifies one or more forms the button belongs to');
+               $this->registerTagAttribute('formaction', 'string', 'Specifies where to send the form-data when a form is submitted. Only for type="submit"');
+               $this->registerTagAttribute('formenctype', 'string', 'Specifies how form-data should be encoded before sending it to a server. Only for type="submit" (e.g. "application/x-www-form-urlencoded", "multipart/form-data" or "text/plain")');
+               $this->registerTagAttribute('formmethod', 'string', 'Specifies how to send the form-data (which HTTP method to use). Only for type="submit" (e.g. "get" or "post")');
+               $this->registerTagAttribute('formnovalidate', 'string', 'Specifies that the form-data should not be validated on submission. Only for type="submit"');
+               $this->registerTagAttribute('formtarget', 'string', 'Specifies where to display the response after submitting the form. Only for type="submit" (e.g. "_blank", "_self", "_parent", "_top", "framename")');
+               $this->registerUniversalTagAttributes();
+       }
+
+       /**
+        * Renders the button.
+        *
+        * @param string $type Specifies the type of button (e.g. "button", "reset" or "submit")
+        * @return string
+        * @api
+        */
+       public function render($type = 'submit') {
+               $name = $this->getName();
+               $this->registerFieldNameForFormTokenGeneration($name);
+
+               $this->tag->addAttribute('type', $type);
+               $this->tag->addAttribute('name', $name);
+               $this->tag->addAttribute('value', $this->getValue());
+               $this->tag->setContent($this->renderChildren());
+
+               return $this->tag->render();
+       }
+}
+
+?>
\ No newline at end of file
index 6dbe4b3..ad4423d 100644 (file)
@@ -10,10 +10,27 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Format;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * Wrapper for PHPs nl2br function.
- *
  * @see http://www.php.net/manual/en/function.nl2br.php
+ *
+ * = Examples =
+ *
+ * <code title="Example">
+ * <f:format.nl2br>{text_with_linebreaks}</f:format.nl2br>
+ * </code>
+ * <output>
+ * text with line breaks replaced by <br />
+ * </output>
+ *
+ * <code title="Inline notation">
+ * {text_with_linebreaks -> f:format.nl2br()}
+ * </code>
+ * <output>
+ * text with line breaks replaced by <br />
+ * </output>
+ *
  * @api
  */
 class Nl2brViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
index 65d6e4a..52b6313 100644 (file)
@@ -10,10 +10,27 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Format;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * Formats a number with custom precision, decimal point and grouped thousands.
- *
  * @see http://www.php.net/manual/en/function.number-format.php
+ *
+ * = Examples =
+ *
+ * <code title="Defaults">
+ * <f:format.number>423423.234</f:format.number>
+ * </code>
+ * <output>
+ * 423,423.20
+ * </output>
+ *
+ * <code title="With all parameters">
+ * <f:format.number decimals="1" decimalSeparator="," thousandsSeparator=".">423423.234</f:format.number>
+ * </code>
+ * <output>
+ * 423.423,2
+ * </output>
+ *
  * @api
  */
 class NumberViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
index 62e3403..2e08dab 100644 (file)
@@ -10,10 +10,34 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Format;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * Formats a string using PHPs str_pad function.
- *
  * @see http://www.php.net/manual/en/function.str_pad.php
+ *
+ * = Examples =
+ *
+ * <code title="Defaults">
+ * <f:format.padding padLength="10">TYPO3</f:format.padding>
+ * </code>
+ * <output>
+ * TYPO3     (note the trailing whitespace)
+ * <output>
+ *
+ * <code title="Specify padding string">
+ * <f:format.padding padLength="10" padString="-=">TYPO3</f:format.padding>
+ * </code>
+ * <output>
+ * TYPO3-=-=-
+ * </output>
+ *
+ * <code title="Specify padding type">
+ * <f:format.padding padLength="10" padString="-" padType="both">TYPO3</f:format.padding>
+ * </code>
+ * <output>
+ * --TYPO3---
+ * </output>
+ *
  * @api
  */
 class PaddingViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
index 1828291..3cf5c82 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Format;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * Outputs an argument/value without any escaping. Is normally used to output
  * an ObjectAccessor which should not be escaped, but output as-is.
index 2d41714..ad85cf3 100644 (file)
@@ -10,10 +10,28 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Format;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * Removes tags from the given string (applying PHPs strip_tags() function)
  *
  * @see http://www.php.net/manual/function.strip-tags.php
+ *
+ * = Examples =
+ *
+ * <code title="default notation">
+ * <f:format.stripTags>Some Text with <b>Tags</b> and an &Uuml;mlaut.</f:format.stripTags>
+ * </code>
+ * <output>
+ * Some Text with Tags and an &Uuml;mlaut. (strip_tags() applied. Note: encoded entities are not decoded)
+ * </output>
+ *
+ * <code title="inline notation">
+ * {text -> f:format.stripTags()}
+ * </code>
+ * <output>
+ * Text without tags (strip_tags() applied)
+ * </output>
+ *
  * @api
  */
 class StripTagsViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
@@ -30,6 +48,7 @@ class StripTagsViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewH
         * Escapes special characters with their escaped counterparts as needed using PHPs strip_tags() function.
         *
         * @param string $value string to format
+        * @return mixed
         * @see http://www.php.net/manual/function.strip-tags.php
         * @api
         */
index 101c1cd..76af74c 100644 (file)
@@ -10,10 +10,27 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Format;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * Encodes the given string according to http://www.faqs.org/rfcs/rfc3986.html (applying PHPs rawurlencode() function)
- *
  * @see http://www.php.net/manual/function.rawurlencode.php
+ *
+ * = Examples =
+ *
+ * <code title="default notation">
+ * <f:format.rawurlencode>foo @+%/</f:format.rawurlencode>
+ * </code>
+ * <output>
+ * foo%20%40%2B%25%2F (rawurlencode() applied)
+ * </output>
+ *
+ * <code title="inline notation">
+ * {text -> f:format.urlencode()}
+ * </code>
+ * <output>
+ * Url encoded text (rawurlencode() applied)
+ * </output>
+ *
  * @api
  */
 class UrlencodeViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
@@ -30,6 +47,7 @@ class UrlencodeViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewH
         * Escapes special characters with their escaped counterparts as needed using PHPs rawurlencode() function.
         *
         * @param string $value string to format
+        * @return mixed
         * @see http://www.php.net/manual/function.rawurlencode.php
         * @api
         */
index 32a475b..5372e9d 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Link;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * A view helper for creating links to external targets.
  *
@@ -66,6 +67,7 @@ class ExternalViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBas
                $this->tag->addAttribute('href', $uri);
                $this->tag->setContent($this->renderChildren());
                $this->tag->forceClosingTag(TRUE);
+
                return $this->tag->render();
        }
 }
index 7b2b2e8..94255ee 100644 (file)
@@ -10,6 +10,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Uri;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 /**
  * A view helper for creating URIs to external targets.
  * Currently the specified URI is simply passed through.
index 4909fb7..e715c13 100644 (file)
@@ -86,7 +86,7 @@ class EscapeTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockEscapeViewHelper = $this->getMock('TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\HtmlspecialcharsViewHelper');
                $mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
                $mockObjectManager->expects($this->at(0))->method('get')->with('TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\HtmlspecialcharsViewHelper')->will($this->returnValue($mockEscapeViewHelper));
-               $mockObjectManager->expects($this->at(1))->method('create')->with('TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\ViewHelperNode', $mockEscapeViewHelper, array('value' => $mockNode))->will($this->returnValue($this->mockNode));
+               $mockObjectManager->expects($this->at(1))->method('get')->with('TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\ViewHelperNode', $mockEscapeViewHelper, array('value' => $mockNode))->will($this->returnValue($this->mockNode));
                $this->escapeInterceptor->injectObjectManager($mockObjectManager);
                $actualResult = $this->escapeInterceptor->process($mockNode, $interceptorPosition, $this->mockParsingState);
                $this->assertSame($this->mockNode, $actualResult);