[!!!][TASK] Fluid (ViewHelpers): Rename widget link ViewHelpers
authorSebastian Kurfürst <sebastian@typo3.org>
Tue, 16 Nov 2010 11:03:19 +0000 (11:03 +0000)
committerSebastian Kurfürst <sebastian@typo3.org>
Tue, 16 Nov 2010 11:03:19 +0000 (11:03 +0000)
Renaming Widget link ViewHelpers from
<f:link.widget> and <f:uri.widget> to
<f:widget.link> and <f:widget.uri>

typo3/sysext/fluid/Classes/Core/Widget/WidgetContext.php
typo3/sysext/fluid/Classes/ViewHelpers/Link/WidgetViewHelper.php [deleted file]
typo3/sysext/fluid/Classes/ViewHelpers/Uri/WidgetViewHelper.php [deleted file]
typo3/sysext/fluid/Classes/ViewHelpers/Widget/LinkViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Classes/ViewHelpers/Widget/UriViewHelper.php [new file with mode: 0644]
typo3/sysext/fluid/Resources/Private/Templates/ViewHelpers/Widget/Autocomplete/Index.html
typo3/sysext/fluid/Resources/Private/Templates/ViewHelpers/Widget/Paginate/Index.html

index 79ff83f..96c9c59 100644 (file)
@@ -26,7 +26,7 @@
  *
  * The WidgetContext can be fetched from the current WidgetRequest, and is thus
  * available throughout the whole sub-request of the widget. It is used internally
- * by various ViewHelpers (like <f:link.widget>, <f:uri.widget>, <f:widget.renderChildren>),
+ * by various ViewHelpers (like <f:widget.link>, <f:widget.uri>, <f:widget.renderChildren>),
  * to get knowledge over the current widget's configuration.
  *
  * It is a purely internal class which should not be used outside of Fluid.
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Link/WidgetViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Link/WidgetViewHelper.php
deleted file mode 100644 (file)
index c985da8..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-<?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!                         *
- *                                                                        */
-
-/**
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- * @api
- * @scope prototype
- */
-class Tx_Fluid_ViewHelpers_Link_WidgetViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractTagBasedViewHelper {
-
-       /**
-        * @var string
-        */
-       protected $tagName = 'a';
-
-       /**
-        * Initialize arguments
-        *
-        * @return void
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        * @api
-        */
-       public function initializeArguments() {
-               $this->registerUniversalTagAttributes();
-               $this->registerTagAttribute('name', 'string', 'Specifies the name of an anchor');
-               $this->registerTagAttribute('rel', 'string', 'Specifies the relationship between the current document and the linked document');
-               $this->registerTagAttribute('rev', 'string', 'Specifies the relationship between the linked document and the current document');
-               $this->registerTagAttribute('target', 'string', 'Specifies where to open the linked document');
-       }
-
-       /**
-        * Render the link.
-        *
-        * @param string $action Target action
-        * @param array $arguments Arguments
-        * @param string $section The anchor to be added to the URI
-        * @param string $format The requested format, e.g. ".html"
-        * @param boolean $ajax TRUE if the URI should be to an AJAX widget, FALSE otherwise.
-        * @return string The rendered link
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        * @author Bastian Waidelich <bastian@typo3.org>
-        * @api
-        */
-       public function render($action = NULL, $arguments = array(), $section = '', $format = '', $ajax = FALSE) {
-               if ($ajax === TRUE) {
-                       $uri = $this->getAjaxUri();
-               } else {
-                       $uri = $this->getWidgetUri();
-               }
-               $this->tag->addAttribute('href', $uri);
-               $this->tag->setContent($this->renderChildren());
-
-               return $this->tag->render();
-       }
-
-       /**
-        * Get the URI for an AJAX Request.
-        *
-        * @return string the AJAX URI
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        */
-       protected function getAjaxUri() {
-               $action = $this->arguments['action'];
-               $arguments = $this->arguments['arguments'];
-
-               if ($action === NULL) {
-                       $action = $this->controllerContext->getRequest()->getControllerActionName();
-               }
-               $arguments['id'] = $GLOBALS['TSFE']->id;
-               // TODO page type should be configurable
-               $arguments['type'] = 7076;
-               $arguments['fluid-widget-id'] = $this->controllerContext->getRequest()->getWidgetContext()->getAjaxWidgetIdentifier();
-               $arguments['action'] = $action;
-
-               return '?' . http_build_query($arguments, NULL, '&');
-       }
-
-       /**
-        * Get the URI for a non-AJAX Request.
-        *
-        * @return string the Widget URI
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        */
-       protected function getWidgetUri() {
-               $uriBuilder = $this->controllerContext->getUriBuilder();
-
-               $argumentPrefix = $this->controllerContext->getRequest()->getArgumentPrefix();
-               $arguments = $this->arguments->hasArgument('arguments') ? $this->arguments['arguments'] : array();
-               if ($this->arguments->hasArgument('action')) {
-                       $arguments['action'] = $this->arguments['action'];
-               }
-               if ($this->arguments->hasArgument('format') && $this->arguments['format'] !== '') {
-                       $arguments['format'] = $this->arguments['format'];
-               }
-               return $uriBuilder
-                       ->reset()
-                       ->setArguments(array($argumentPrefix => $arguments))
-                       ->setSection($this->arguments['section'])
-                       ->setCreateAbsoluteUri(TRUE)
-                       ->setAddQueryString(TRUE)
-                       ->setArgumentsToBeExcludedFromQueryString(array($argumentPrefix, 'cHash'))
-                       ->setFormat($this->arguments['format'])
-                       ->build();
-       }
-}
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Uri/WidgetViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Uri/WidgetViewHelper.php
deleted file mode 100644 (file)
index 185e97d..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-<?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!                         *
- *                                                                        */
-
-/**
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- * @api
- * @scope prototype
- */
-class Tx_Fluid_ViewHelpers_Uri_WidgetViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
-
-       /**
-        * Render the Uri.
-        *
-        * @param string $action Target action
-        * @param array $arguments Arguments
-        * @param string $section The anchor to be added to the URI
-        * @param string $format The requested format, e.g. ".html"
-        * @param boolean $ajax TRUE if the URI should be to an AJAX widget, FALSE otherwise.
-        * @return string The rendered link
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        * @author Bastian Waidelich <bastian@typo3.org>
-        * @api
-        */
-       public function render($action = NULL, $arguments = array(), $section = '', $format = '', $ajax = FALSE) {
-               if ($ajax === TRUE) {
-                       return $this->getAjaxUri();
-               } else {
-                       return $this->getWidgetUri();
-               }
-       }
-
-       /**
-        * Get the URI for an AJAX Request.
-        *
-        * @return string the AJAX URI
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        */
-       protected function getAjaxUri() {
-               $action = $this->arguments['action'];
-               $arguments = $this->arguments['arguments'];
-
-               if ($action === NULL) {
-                       $action = $this->controllerContext->getRequest()->getControllerActionName();
-               }
-               $arguments['id'] = $GLOBALS['TSFE']->id;
-               // TODO page type should be configurable
-               $arguments['type'] = 7076;
-               $arguments['fluid-widget-id'] = $this->controllerContext->getRequest()->getWidgetContext()->getAjaxWidgetIdentifier();
-               $arguments['action'] = $action;
-
-               return '?' . http_build_query($arguments, NULL, '&');
-       }
-
-       /**
-        * Get the URI for a non-AJAX Request.
-        *
-        * @return string the Widget URI
-        * @author Sebastian Kurfürst <sebastian@typo3.org>
-        */
-       protected function getWidgetUri() {
-               $uriBuilder = $this->controllerContext->getUriBuilder();
-
-               $argumentPrefix = $this->controllerContext->getRequest()->getArgumentPrefix();
-               $arguments = $this->arguments->hasArgument('arguments') ? $this->arguments['arguments'] : array();
-               if ($this->arguments->hasArgument('action')) {
-                       $arguments['action'] = $this->arguments['action'];
-               }
-               if ($this->arguments->hasArgument('format') && $this->arguments['format'] !== '') {
-                       $arguments['format'] = $this->arguments['format'];
-               }
-               return $uriBuilder
-                       ->reset()
-                       ->setArguments(array($argumentPrefix => $arguments))
-                       ->setSection($this->arguments['section'])
-                       ->setCreateAbsoluteUri(TRUE)
-                       ->setAddQueryString(TRUE)
-                       ->setArgumentsToBeExcludedFromQueryString(array($argumentPrefix, 'cHash'))
-                       ->setFormat($this->arguments['format'])
-                       ->build();
-       }
-}
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Widget/LinkViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Widget/LinkViewHelper.php
new file mode 100644 (file)
index 0000000..c99c1fb
--- /dev/null
@@ -0,0 +1,126 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ * @scope prototype
+ */
+class Tx_Fluid_ViewHelpers_Widget_LinkViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractTagBasedViewHelper {
+
+       /**
+        * @var string
+        */
+       protected $tagName = 'a';
+
+       /**
+        * Initialize arguments
+        *
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function initializeArguments() {
+               $this->registerUniversalTagAttributes();
+               $this->registerTagAttribute('name', 'string', 'Specifies the name of an anchor');
+               $this->registerTagAttribute('rel', 'string', 'Specifies the relationship between the current document and the linked document');
+               $this->registerTagAttribute('rev', 'string', 'Specifies the relationship between the linked document and the current document');
+               $this->registerTagAttribute('target', 'string', 'Specifies where to open the linked document');
+       }
+
+       /**
+        * Render the link.
+        *
+        * @param string $action Target action
+        * @param array $arguments Arguments
+        * @param string $section The anchor to be added to the URI
+        * @param string $format The requested format, e.g. ".html"
+        * @param boolean $ajax TRUE if the URI should be to an AJAX widget, FALSE otherwise.
+        * @return string The rendered link
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function render($action = NULL, $arguments = array(), $section = '', $format = '', $ajax = FALSE) {
+               if ($ajax === TRUE) {
+                       $uri = $this->getAjaxUri();
+               } else {
+                       $uri = $this->getWidgetUri();
+               }
+               $this->tag->addAttribute('href', $uri);
+               $this->tag->setContent($this->renderChildren());
+
+               return $this->tag->render();
+       }
+
+       /**
+        * Get the URI for an AJAX Request.
+        *
+        * @return string the AJAX URI
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function getAjaxUri() {
+               $action = $this->arguments['action'];
+               $arguments = $this->arguments['arguments'];
+
+               if ($action === NULL) {
+                       $action = $this->controllerContext->getRequest()->getControllerActionName();
+               }
+               $arguments['id'] = $GLOBALS['TSFE']->id;
+               // TODO page type should be configurable
+               $arguments['type'] = 7076;
+               $arguments['fluid-widget-id'] = $this->controllerContext->getRequest()->getWidgetContext()->getAjaxWidgetIdentifier();
+               $arguments['action'] = $action;
+
+               return '?' . http_build_query($arguments, NULL, '&');
+       }
+
+       /**
+        * Get the URI for a non-AJAX Request.
+        *
+        * @return string the Widget URI
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function getWidgetUri() {
+               $uriBuilder = $this->controllerContext->getUriBuilder();
+
+               $argumentPrefix = $this->controllerContext->getRequest()->getArgumentPrefix();
+               $arguments = $this->arguments->hasArgument('arguments') ? $this->arguments['arguments'] : array();
+               if ($this->arguments->hasArgument('action')) {
+                       $arguments['action'] = $this->arguments['action'];
+               }
+               if ($this->arguments->hasArgument('format') && $this->arguments['format'] !== '') {
+                       $arguments['format'] = $this->arguments['format'];
+               }
+               return $uriBuilder
+                       ->reset()
+                       ->setArguments(array($argumentPrefix => $arguments))
+                       ->setSection($this->arguments['section'])
+                       ->setCreateAbsoluteUri(TRUE)
+                       ->setAddQueryString(TRUE)
+                       ->setArgumentsToBeExcludedFromQueryString(array($argumentPrefix, 'cHash'))
+                       ->setFormat($this->arguments['format'])
+                       ->build();
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Widget/UriViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Widget/UriViewHelper.php
new file mode 100644 (file)
index 0000000..018ec1d
--- /dev/null
@@ -0,0 +1,104 @@
+<?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!                         *
+ *                                                                        */
+
+/**
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @api
+ * @scope prototype
+ */
+class Tx_Fluid_ViewHelpers_Widget_UriViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
+
+       /**
+        * Render the Uri.
+        *
+        * @param string $action Target action
+        * @param array $arguments Arguments
+        * @param string $section The anchor to be added to the URI
+        * @param string $format The requested format, e.g. ".html"
+        * @param boolean $ajax TRUE if the URI should be to an AJAX widget, FALSE otherwise.
+        * @return string The rendered link
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Bastian Waidelich <bastian@typo3.org>
+        * @api
+        */
+       public function render($action = NULL, $arguments = array(), $section = '', $format = '', $ajax = FALSE) {
+               if ($ajax === TRUE) {
+                       return $this->getAjaxUri();
+               } else {
+                       return $this->getWidgetUri();
+               }
+       }
+
+       /**
+        * Get the URI for an AJAX Request.
+        *
+        * @return string the AJAX URI
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function getAjaxUri() {
+               $action = $this->arguments['action'];
+               $arguments = $this->arguments['arguments'];
+
+               if ($action === NULL) {
+                       $action = $this->controllerContext->getRequest()->getControllerActionName();
+               }
+               $arguments['id'] = $GLOBALS['TSFE']->id;
+               // TODO page type should be configurable
+               $arguments['type'] = 7076;
+               $arguments['fluid-widget-id'] = $this->controllerContext->getRequest()->getWidgetContext()->getAjaxWidgetIdentifier();
+               $arguments['action'] = $action;
+
+               return '?' . http_build_query($arguments, NULL, '&');
+       }
+
+       /**
+        * Get the URI for a non-AJAX Request.
+        *
+        * @return string the Widget URI
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        */
+       protected function getWidgetUri() {
+               $uriBuilder = $this->controllerContext->getUriBuilder();
+
+               $argumentPrefix = $this->controllerContext->getRequest()->getArgumentPrefix();
+               $arguments = $this->arguments->hasArgument('arguments') ? $this->arguments['arguments'] : array();
+               if ($this->arguments->hasArgument('action')) {
+                       $arguments['action'] = $this->arguments['action'];
+               }
+               if ($this->arguments->hasArgument('format') && $this->arguments['format'] !== '') {
+                       $arguments['format'] = $this->arguments['format'];
+               }
+               return $uriBuilder
+                       ->reset()
+                       ->setArguments(array($argumentPrefix => $arguments))
+                       ->setSection($this->arguments['section'])
+                       ->setCreateAbsoluteUri(TRUE)
+                       ->setAddQueryString(TRUE)
+                       ->setArgumentsToBeExcludedFromQueryString(array($argumentPrefix, 'cHash'))
+                       ->setFormat($this->arguments['format'])
+                       ->build();
+       }
+}
+
+?>
\ No newline at end of file
index fc56fa9..949c625 100644 (file)
@@ -1,7 +1,7 @@
 <script type="text/javascript">
 jQuery(function() {
        jQuery("#{id}").autocomplete(<![CDATA[{]]>
-               source: "{f:uri.widget(action:'autocomplete', ajax: 1)}",
+               source: "{f:widget.uri(action:'autocomplete', ajax: 1)}",
                minLength: 2
        });
 });
index 52b9431..f98c018 100644 (file)
                        <li class="previous">
                                <f:if condition="{pagination.previousPage} > 1">
                                        <f:then>
-                                               <f:link.widget arguments="{currentPage: pagination.previousPage}">previous</f:link.widget>
+                                               <f:widget.link arguments="{currentPage: pagination.previousPage}">previous</f:widget.link>
                                        </f:then>
                                        <f:else>
-                                               <f:link.widget>previous</f:link.widget>
+                                               <f:widget.link>previous</f:widget.link>
                                        </f:else>
                                </f:if>
                        </li>
                                        <li>
                                                <f:if condition="{page.number} > 1">
                                                        <f:then>
-                                                               <f:link.widget arguments="{currentPage: page.number}">{page.number}</f:link.widget>
+                                                               <f:widget.link arguments="{currentPage: page.number}">{page.number}</f:widget.link>
                                                        </f:then>
                                                        <f:else>
-                                                               <f:link.widget>{page.number}</f:link.widget>
+                                                               <f:widget.link>{page.number}</f:widget.link>
                                                        </f:else>
                                                </f:if>
                                        </li>
@@ -45,7 +45,7 @@
                </f:for>
                <f:if condition="{pagination.nextPage}">
                        <li class="next">
-                               <f:link.widget arguments="{currentPage: pagination.nextPage}">next</f:link.widget>
+                               <f:widget.link arguments="{currentPage: pagination.nextPage}">next</f:widget.link>
                        </li>
                </f:if>
        </ul>