Extbase:
authorJochen Rau <j.rau@web.de>
Thu, 30 Apr 2009 14:28:54 +0000 (14:28 +0000)
committerJochen Rau <j.rau@web.de>
Thu, 30 Apr 2009 14:28:54 +0000 (14:28 +0000)
* Rename URIHelper to UriHelper (1st step)

typo3/sysext/extbase/Classes/MVC/View/Helper/URIHelper.php [deleted file]
typo3/sysext/extbase/Classes/MVC/View/Helper/UriHelperRenamed.php [new file with mode: 0644]

diff --git a/typo3/sysext/extbase/Classes/MVC/View/Helper/URIHelper.php b/typo3/sysext/extbase/Classes/MVC/View/Helper/URIHelper.php
deleted file mode 100644 (file)
index 232f557..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-<?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.                                       *
- *                                                                        */
-
-require_once(PATH_t3lib . 'interfaces/interface.t3lib_singleton.php');
-require_once(PATH_tslib . 'class.tslib_content.php');
-
-/**
- * @package
- * @subpackage
- * @version $Id:$
- */
-class Tx_Extbase_MVC_View_Helper_URIHelper implements t3lib_Singleton {
-
-       /**
-        * An instance of tslib_cObj
-        *
-        * @var tslib_cObj
-        */
-       protected $contentObject;
-
-       public function __construct(array $arguments = array()) {
-               $this->contentObject = t3lib_div::makeInstance('tslib_cObj');
-       }
-
-       /**
-        * Get an URI for a controller / action / extension on a specific page within the scope
-        * of the current request.
-        * @return The URI
-        */
-       public function URIFor($request, $actionName = '', $arguments = array(), $controllerName = '', $page = '', $extensionKey = '', $anchor = '', $useCacheHash = TRUE) {
-               $prefixedExtensionKey = 'tx_' . strtolower($request->getExtensionName()) . '_' . strtolower($request->getPluginKey());
-
-               $arguments['action'] = $actionName;
-               $arguments['controller'] = ($controllerName !== '') ? $controllerName : $request->getControllerName();
-               $prefixedArguments = array();
-               foreach ($arguments as $argumentName => $argumentValue) {
-                       $key = $prefixedExtensionKey . '[' . $argumentName . ']';
-                       $prefixedArguments[$key] = $argumentValue;
-               }
-
-               return $this->typolinkURI($page, $anchor, $useCacheHash, $prefixedArguments);
-       }
-
-       /**
-        * Get an URI from typolink
-        * @return The URI
-        */
-       public function typolinkURI($page = '', $anchor = '', $useCacheHash = TRUE, $arguments = array()) {
-               if ($page === '') {
-                       $page = $GLOBALS['TSFE']->id;
-               }
-
-               $typolinkConfiguration = array(
-                       'parameter' => $page
-               );
-
-               if (count($arguments) > 0) {
-                       foreach ($arguments as $argumentNameSpace => $argument) {
-                               $typolinkConfiguration['additionalParams'] .= '&' . $argumentNameSpace . '=' . rawurlencode($argument);
-                       }
-               }
-               if ($anchor) {
-                       $typolinkConfiguration['section'] = $anchor;
-               }
-               if ($useCacheHash) {
-                       $typolinkConfiguration['useCacheHash'] = 1;
-               } else {
-                       $typolinkConfiguration['useCacheHash'] = 0;
-               }
-
-               return $this->contentObject->typoLink_URL($typolinkConfiguration);
-       }
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/MVC/View/Helper/UriHelperRenamed.php b/typo3/sysext/extbase/Classes/MVC/View/Helper/UriHelperRenamed.php
new file mode 100644 (file)
index 0000000..5fa5c21
--- /dev/null
@@ -0,0 +1,95 @@
+<?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.                                       *
+ *                                                                        */
+
+require_once(PATH_t3lib . 'interfaces/interface.t3lib_singleton.php');
+require_once(PATH_tslib . 'class.tslib_content.php');
+
+/**
+ * @package
+ * @subpackage
+ * @version $Id:$
+ */
+// TODO Rename file name URIHelper to UriHelper
+class Tx_Extbase_MVC_View_Helper_UriHelper extends Tx_Extbase_MVC_View_Helper_AbstractHelper implements t3lib_Singleton {
+
+       /**
+        * An instance of tslib_cObj
+        *
+        * @var tslib_cObj
+        */
+       protected $contentObject;
+
+       /**
+        * Constructs this URI Helper
+        */
+       public function __construct(array $arguments = array()) {
+               $this->contentObject = t3lib_div::makeInstance('tslib_cObj');
+       }
+
+       /**
+        * Creates an URI by making use of the typolink mechanism.
+        *
+        * @param string $actionName Name of the action to be called
+        * @param array $arguments Additional arguments
+        * @param string $controllerName Name of the target controller. If not set, current controller is used
+        * @param string $pageUid 
+        * @param array $options Further options
+        * @return string the HTML code for the generated link
+        * @author Bastian Waidelich <bastian@typo3.org>
+        */
+       public function uriFor($actionName, $arguments = array(), $controllerName = '', $parameter = 0, $anchor = '', $useCacheHash = TRUE) {
+               $prefixedExtensionKey = 'tx_' . strtolower($this->request->getControllerExtensionKey()) . '_' . strtolower($this->request->getPluginKey());
+
+               $arguments['action'] = $actionName;
+               $arguments['controller'] = ($controllerName !== '') ? $controllerName : $this->request->getControllerName();
+               $prefixedArguments = array();
+               foreach ($arguments as $argumentName => $argumentValue) {
+                       $key = $prefixedExtensionKey . '[' . $argumentName . ']';
+                       $prefixedArguments[$key] = $argumentValue;
+               }
+
+               return $this->typolinkUri($pageUid, $anchor, $useCacheHash, $prefixedArguments);
+       }
+
+       /**
+        * Get an URI from typolink
+        * @return The URI
+        */
+       public function typolinkUri($pageUid = 0, $anchor = '', $useCacheHash = TRUE, $arguments = array()) {
+               if ($pageUid === 0) {
+                       $pageUid = $GLOBALS['TSFE']->id;
+               }
+
+               $typolinkConfiguration = array(
+                       'parameter' => $pageUid
+               );
+
+               if (count($arguments) > 0) {
+                       foreach ($arguments as $argumentNameSpace => $argument) {
+                               $typolinkConfiguration['additionalParams'] .= '&' . $argumentNameSpace . '=' . rawurlencode($argument);
+                       }
+               }
+               if (!empty($anchor)) {
+                       $typolinkConfiguration['section'] = $anchor;
+               }
+               if ($useCacheHash === TRUE) {
+                       $typolinkConfiguration['useCacheHash'] = 1;
+               } else {
+                       $typolinkConfiguration['useCacheHash'] = 0;
+               }
+
+               return $this->contentObject->typoLink_URL($typolinkConfiguration);
+       }
+}
+?>
\ No newline at end of file