Index: t3lib/extjs/class.t3lib_extjs_extdirectapi.php =================================================================== --- t3lib/extjs/class.t3lib_extjs_extdirectapi.php (revision 7796) +++ t3lib/extjs/class.t3lib_extjs_extdirectapi.php (working copy) @@ -64,24 +64,30 @@ public function getAPI($ajaxParams, TYPO3AJAX $ajaxObj) { $filterNamespace = t3lib_div::_GET('namespace'); - // look up into the cache + // Check GET-parameter no_cache and extCache setting + $noCache = t3lib_div::_GET('no_cache') ? TRUE : ($GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] === '0'); + + // look up into the cache $cacheIdentifier = 'ExtDirectApi'; $cacheHash = md5($cacheIdentifier . $filterNamespace . serialize($this->settings)); - $cacheContent = t3lib_pageSelect::getHash($cacheHash); + // with no_cache always generate the javascript content + $cacheContent = $noCache ? '' : t3lib_pageSelect::getHash($cacheHash); - // generate the javascript content if it wasn't found inside the cache and cache it! + // generate the javascript content if it wasn't found inside the cache and cache it! if (!$cacheContent) { $javascriptNamespaces = $this->generateAPI($filterNamespace); - t3lib_pageSelect::storeHash( - $cacheHash, - serialize($javascriptNamespaces), - $cacheIdentifier - ); + if (!empty($javascriptNamespaces)) { + t3lib_pageSelect::storeHash( + $cacheHash, + serialize($javascriptNamespaces), + $cacheIdentifier + ); + } } else { $javascriptNamespaces = unserialize($cacheContent); } - // return the generated javascript API configuration + // return the generated javascript API configuration if (count($javascriptNamespaces)) { $setup = ' if (typeof Ext.app.ExtDirectAPI !== "object") { @@ -103,6 +109,36 @@ $ajaxObj->setJavascriptCallbackWrap( $setup . 'Ext.app.ExtDirectAPI = Object.extend(Ext.app.ExtDirectAPI, |);' ); + } else { + if ($filterNamespace) { + // namespace error + $errorMessage = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:ExtDirect.namespaceError'), + __CLASS__, $filterNamespace + ); + } + else { + // no namespace given + $errorMessage = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:ExtDirect.noNamespace'), + __CLASS__ + ); + } + // make js multiline message + $msg = t3lib_div::trimExplode(LF, str_replace('"', '\"', $errorMessage), TRUE); + $errorMessage = ''; + foreach ($msg as $line) { + $errorMessage .= '"' . $line . '" + ' . LF; + } + $errorMessage = substr(trim($errorMessage), 0, -1); + //generate the javascript + $ajaxObj->setContentFormat('javascript'); + $ajaxObj->setJavascriptCallbackWrap(' + errorMessage = ' . $errorMessage . '; + if (typeof console == "object") { + console.log(errorMessage); + } else { + alert(errorMessage); + } + '); } } @@ -142,7 +178,7 @@ $numberOfParameters = $reflectionMethod->getNumberOfParameters(); $docHeader = $reflectionMethod->getDocComment(); $formHandler = (strpos($docHeader, '@formHandler') !== FALSE); - + $javascriptNamespaces[$javascriptNamespace]['actions'][$javascriptObjectName][] = array( 'name' => $methodName, 'len' => $numberOfParameters, Index: typo3/backend.php =================================================================== --- typo3/backend.php (revision 7796) +++ typo3/backend.php (working copy) @@ -247,9 +247,21 @@ foreach ($this->jsFiles as $jsFile) { $this->pageRenderer->addJsFile($jsFile); } - // we mustn't compress this file - $this->pageRenderer->addJsFile('ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.Backend', NULL, FALSE); + // Those lines can be removed once we have at least one official ExtDirect router within the backend. + $hasExtDirectRouter = FALSE; + if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect'])) { + foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect'] as $key => $value) { + if (strpos($key, 'TYPO3.Backend') !== FALSE) { + $hasExtDirectRouter = TRUE; + break; + } + } + } + if ($hasExtDirectRouter) { + $this->pageRenderer->addJsFile('ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.Backend', NULL, FALSE); + } + $this->generateJavascript(); $this->pageRenderer->addJsInlineCode('BackendInlineJavascript', $this->js); Index: typo3/sysext/lang/locallang_core.xml =================================================================== --- typo3/sysext/lang/locallang_core.xml (revision 7796) +++ typo3/sysext/lang/locallang_core.xml (working copy) @@ -272,6 +272,13 @@ + +