Fixed bug #13811: Missing formHandler in ExtDirect API (Thanks to Stefan Galinski)
authorSteffen Kamper <info@sk-typo3.de>
Tue, 23 Mar 2010 20:42:26 +0000 (20:42 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Tue, 23 Mar 2010 20:42:26 +0000 (20:42 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@7150 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/extjs/class.t3lib_extjs_extdirectapi.php
t3lib/extjs/class.t3lib_extjs_extdirectrouter.php

index f56d40e..2c2ef1f 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-03-23  Steffen Kamper  <info@sk-typo3.de>
+
+       * Fixed bug #13811: Missing formHandler in ExtDirect API (Thanks to Stefan Galinski)
+
 2010-03-23  Dmitry Dulepov  <dmitry.dulepov@gmail.com>
 
        * Fixed bug #9229: indexing of records containing HTML leads to concatenated words
index 59b2ca1..c94d789 100644 (file)
@@ -140,10 +140,13 @@ class t3lib_extjs_ExtDirectApi {
                                foreach (get_class_methods($serverObject) as $methodName) {
                                        $reflectionMethod = new ReflectionMethod($serverObject, $methodName);
                                        $numberOfParameters = $reflectionMethod->getNumberOfParameters();
-
+                                       $docHeader = $reflectionMethod->getDocComment();
+                                       $formHandler = (strpos($docHeader, '@formHandler') !== FALSE);
+                                       
                                        $javascriptNamespaces[$javascriptNamespace]['actions'][$javascriptObjectName][] = array(
                                                'name' => $methodName,
-                                               'len' => $numberOfParameters
+                                               'len' => $numberOfParameters,
+                                               'formHandler' => $formHandler
                                        );
                                }
                        }
index 26240b2..9b91b58 100644 (file)
@@ -42,19 +42,27 @@ class t3lib_extjs_ExtDirectRouter {
         */
        public function route($ajaxParams, TYPO3AJAX $ajaxObj) {
                try {
-                       $isForm = false;
-                       $isUpload = false;
+                       $isForm = FALSE;
+                       $isUpload = FALSE;
                        $rawPostData = file_get_contents('php://input');
+                       $postParameters = t3lib_div::_POST();
                        $namespace = t3lib_div::_GET('namespace');
 
-                       if (!empty($rawPostData)) {
-                               $ajaxObj->setContentFormat('jsonbody');
+                       if (!empty($postParameters['extAction'])) {
+                               $isForm = TRUE;
+                               $isUpload = $postParameters['extUpload'] === 'true';
+
+                               $request->action = $postParameters['extAction'];
+                               $request->method = $postParameters['extMethod'];
+                               $request->tid = $postParameters['extTID'];
+                               $request->data = array($_POST + $_FILES);
+                       } elseif (!empty($rawPostData)) {
                                $request = json_decode($rawPostData);
                        } else {
                                throw new t3lib_error_Exception('ExtDirect: Missing Parameters!');
                        }
 
-                       $response = null;
+                       $response = NULL;
                        if (is_array($request)) {
                                $response = array();
                                foreach ($request as $singleRequest) {
@@ -64,6 +72,19 @@ class t3lib_extjs_ExtDirectRouter {
                                $response = $this->processRpc($request, $namespace);
                        }
 
+                       if ($isForm && $isUpload) {
+                               $ajaxObj->setContentFormat('plain');
+                               $response = json_encode($response);
+                               $response = preg_replace('/&quot;/', '\\&quot;', $response);
+
+                               $response = array(
+                                       '<html><body><textarea>' .
+                                       $response .
+                                       '</textarea></body></html>'
+                               );
+                       } else {
+                               $ajaxObj->setContentFormat('jsonbody');
+                       }
                } catch (t3lib_error_Exception $exception) {
                        $response = array(
                                'type' => 'exception',
@@ -113,11 +134,7 @@ class t3lib_extjs_ExtDirectRouter {
                        );
 
                } catch (t3lib_error_Exception $exception) {
-                       $response = array(
-                               'type' => 'exception',
-                               'message' => $exception->getMessage(),
-                               'where' => $exception->getTraceAsString()
-                       );
+                       throw $exception;
                }
 
                return $response;