Extbase:
authorSebastian Kurfürst <sebastian@typo3.org>
Tue, 31 Mar 2009 11:53:27 +0000 (11:53 +0000)
committerSebastian Kurfürst <sebastian@typo3.org>
Tue, 31 Mar 2009 11:53:27 +0000 (11:53 +0000)
* Moved URIHelper to View
* Did some cleanup

typo3/sysext/extbase/Classes/MVC/Controller/AbstractController.php
typo3/sysext/extbase/Classes/MVC/Request.php
typo3/sysext/extbase/Classes/MVC/View/Helper/URIHelper.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/MVC/Web/RequestBuilder.php
typo3/sysext/extbase/Classes/MVC/Web/URIHelper.php [deleted file]
typo3/sysext/extbase/Classes/Persistence/Hook/TCEMainValueObjectUpdater.php
typo3/sysext/extbase/class.tx_extbase_dispatcher.php

index 63cdd2b..0d8fc04 100755 (executable)
@@ -63,11 +63,6 @@ abstract class Tx_ExtBase_MVC_Controller_AbstractController implements Tx_ExtBas
         * @var array
         */
        protected $nonCachableActions = array();
-       
-       /**
-        * @var Tx_ExtBase_MVC_URIHelper
-        */
-       protected $URIHelper;
 
        /**
         * Constructs the controller.
@@ -78,7 +73,6 @@ abstract class Tx_ExtBase_MVC_Controller_AbstractController implements Tx_ExtBas
        public function __construct() {
                // SK: Set $this->extensionName, could be done the same way as it is done in Fluid
                $this->arguments = t3lib_div::makeInstance('Tx_ExtBase_MVC_Controller_Arguments');
-               $this->URIHelper = t3lib_div::makeInstance('Tx_ExtBase_MVC_Web_URIHelper');
        }
 
        /**
index 94e0100..85487c8 100644 (file)
@@ -69,7 +69,7 @@ class Tx_ExtBase_MVC_Request {
        /**
         * @var ArrayObject The arguments for this request
         */
-       protected $arguments;
+       protected $arguments = array();
 
        /**
         * @var string The requested representation format
@@ -86,7 +86,6 @@ class Tx_ExtBase_MVC_Request {
         *
         */
        public function __construct() {
-               $this->arguments = new ArrayObject;
        }
 
        /**
diff --git a/typo3/sysext/extbase/Classes/MVC/View/Helper/URIHelper.php b/typo3/sysext/extbase/Classes/MVC/View/Helper/URIHelper.php
new file mode 100644 (file)
index 0000000..3ee060a
--- /dev/null
@@ -0,0 +1,85 @@
+<?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
index da8506d..5ca8bc2 100755 (executable)
@@ -49,7 +49,7 @@ class Tx_ExtBase_MVC_Web_RequestBuilder {
                $defaultActionName = (!empty($defaultControllerActions[0])) ? $defaultControllerActions[0] : 'index';
                $allowedControllerActions = array();
                foreach ($controllerConfigurations as $controllerConfiguration) {
-                       $controllerActions = t3lib_div::trimExplode(',', $controllerConfiguration['actions']);                  
+                       $controllerActions = t3lib_div::trimExplode(',', $controllerConfiguration['actions']);
                        foreach ($controllerActions as $actionName) {
                                $allowedControllerActions[$controllerConfiguration['controllerName']][] = $actionName;
                        }
@@ -60,15 +60,16 @@ class Tx_ExtBase_MVC_Web_RequestBuilder {
                } elseif ($defaultControllerConfiguration['controllerName'] !== NULL) {
                        $controllerName = $defaultControllerName;
                }
-               
+
                $allowedActions = $allowedControllerActions[$controllerName];
+
                if (is_string($parameters['action']) && is_array($allowedActions) && in_array($parameters['action'], $allowedActions)) {
                        $actionName = filter_var($parameters['action'], FILTER_SANITIZE_STRING);
                } elseif (is_string($defaultControllerConfiguration['actions'])) {;
                        $actions = t3lib_div::trimExplode(',', $defaultControllerConfiguration['actions']);
                        $actionName = $actions[0];
                }
-               
+
                $request = t3lib_div::makeInstance('Tx_ExtBase_MVC_Web_Request');
                $request->setPluginKey($pluginKey);
                $request->setExtensionName($extensionName);
diff --git a/typo3/sysext/extbase/Classes/MVC/Web/URIHelper.php b/typo3/sysext/extbase/Classes/MVC/Web/URIHelper.php
deleted file mode 100644 (file)
index 5459b51..0000000
+++ /dev/null
@@ -1,85 +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_Web_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
index e92ccc5..11f14d6 100644 (file)
@@ -4,13 +4,30 @@ class tx_ExtBase_Persistence_Hook_TCEMainValueObjectUpdater {
        public function processDatamap_preProcessFieldArray(&$incomingFieldArray, $table, &$id, $tcemain) {
                global $TCA;
                if (isset($TCA[$table]['ctrl']['objectType']) && $TCA[$table]['ctrl']['objectType'] === 'ValueObject') {
+                       $isNewRecord = !t3lib_div::testInt($id);
+
                        $uid = $this->findUid($incomingFieldArray, $table);
                        if ($uid !== NULL) {
+                               // FOUND a UID.
+
+                               var_dump($uid, $id);
+                               var_dump($incomingFieldArray);
+                               if ($isNewRecord) {
+                                       // re-map the insertion to an update!
+                                       $tcemain->substNEWwitIDs[$id] = (int)$uid;
+                                       $id = (int)$uid;
+                                       unset($incomingFieldArray['pid']);
+                               }
                                //var_dump($incomingFieldArray, $table, $id, $uid);
-                               $id = (int)$uid;
-                               $incomingFieldArray['uid'] = $uid;
+                               //
+                               //$incomingFieldArray['uid'] = $uid;
                        } else {
-                               // $id = 'NEW' . $uid;
+                               // We did not find an already existing entry with the same values in the DB
+                               // Thus, the entry can safely be created if $isNewRecord.
+                               // if record is not new, and we did not find any of these values in the DB, we can just leave the record as is.
+                               if (!$isNewRecord) {
+
+                               }
                        }
 
                }
index 1956d41..fab7c7c 100644 (file)
@@ -23,7 +23,7 @@
 ***************************************************************/
 
 /**
- * Creates a request an dispatches it to the controller which was specified 
+ * Creates a request an dispatches it to the controller which was specified
  * by TS Setup, Flexform and returns the content to the v4 framework.
  *
  * @package TYPO3
@@ -72,14 +72,14 @@ class Tx_ExtBase_Dispatcher {
                        $GLOBALS['TSFE']->additionalHeaderData[$request->getExtensionName()] = implode("\n", $response->getAdditionalHeaderData());
                }
                // TODO Handle $response->getStatus()
-               $response->sendHeaders();       
+               $response->sendHeaders();
                return $response->getContent();
        }
-       
+
        /**
         * Builds and returns a controller
         *
-        * @param Tx_ExtBase_MVC_Web_Request $request 
+        * @param Tx_ExtBase_MVC_Web_Request $request
         * @return Tx_ExtBase_MVC_Controller_ControllerInterface The prepared controller
         */
        protected function getPreparedController(Tx_ExtBase_MVC_Web_Request $request) {
@@ -91,12 +91,12 @@ class Tx_ExtBase_Dispatcher {
                $controller->injectSettings($this->getSettings($request));
                return $controller;
        }
-       
+
        /**
         * Builds the settings by overlaying TS Setup with FlexForm values of the extension
         * and returns them as a plain array (with no trailing dots).
         *
-        * @param Tx_ExtBase_MVC_Web_Request $request 
+        * @param Tx_ExtBase_MVC_Web_Request $request
         * @return array The settings array
         */
        protected function getSettings(Tx_ExtBase_MVC_Web_Request $request) {
@@ -112,7 +112,7 @@ class Tx_ExtBase_Dispatcher {
                $configurationManager->loadGlobalSettings($extensionName);
                return $configurationManager->getSettings($extensionName);
        }
-       
+
        /**
         * Loads php files containing classes or interfaces found in the classes directory of
         * an extension.