Index: t3lib/class.t3lib_pagerenderer.php
===================================================================
--- t3lib/class.t3lib_pagerenderer.php	(revision 10410)
+++ t3lib/class.t3lib_pagerenderer.php	(revision )
@@ -941,22 +941,38 @@
 	/**
 	 * Adds the ExtDirect code
 	 *
+	 * @param array $javascriptNamespaces
 	 * @return void
 	 */
-	public function addExtDirectCode() {
+	public function addExtDirectCode($filterNamespaces = array()) {
 		if ($this->extDirectCodeAdded) {
 			return;
 		}
 		$this->extDirectCodeAdded = TRUE;
-		$token = '';
+
+		if (count($filterNamespaces) === 0) {
+			$filterNamespaces = array('TYPO3');
+		}
+
+			// for ExtDirect we need flash message support
+		$this->addJsFile(t3lib_div::resolveBackPath($this->backPath . '../t3lib/js/extjs/ux/flashmessages.js'));
+
+		$token = $api = '';
 		if (TYPO3_MODE === 'BE') {
 			$formprotection = t3lib_formprotection_Factory::get();
 			$token = $formprotection->generateToken('extDirect');
 		}
 
+		/** @var $extDirect t3lib_extjs_ExtDirectApi */
+		$extDirect = t3lib_div::makeInstance('t3lib_extjs_ExtDirectApi');
+		$api = $extDirect->getApiPhp($filterNamespaces);
+		if ($api) {
+			$this->addJsInlineCode('TYPO3ExtDirectAPI', $api);
+		}
+
 			// Note: we need to iterate thru the object, because the addProvider method
 			// does this only with multiple arguments
-		$this->addExtOnReadyCode('
+		$this->addExtOnReadyCode( '
 			(function() {
 				TYPO3.ExtDirectToken = "' . $token . '";
 				for (var api in Ext.app.ExtDirectAPI) {
Index: typo3/sysext/workspaces/Classes/Controller/PreviewController.php
===================================================================
--- typo3/sysext/workspaces/Classes/Controller/PreviewController.php	(revision 10222)
+++ typo3/sysext/workspaces/Classes/Controller/PreviewController.php	(revision )
@@ -49,12 +49,9 @@
 		$this->pageRenderer->enableExtJsDebug();
 
 			// Load  JavaScript:
-		$this->pageRenderer->addExtDirectCode();
-		$this->pageRenderer->addJsFile(
-			$this->backPath . 'ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.Workspaces&' . TYPO3_version,
-			NULL,
-			FALSE
-		);
+		$this->pageRenderer->addExtDirectCode(array(
+			'TYPO3.Workspaces'
+		));
 
 		$this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/flashmessages.js');
 		$this->pageRenderer->addJsFile($this->backPath . 'js/extjs/iframepanel.js');
@@ -250,4 +247,4 @@
 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Controller/PreviewController.php'])) {
 	include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Controller/PreviewController.php']);
 }
-?>
\ No newline at end of file
+?>
Index: t3lib/stddb/tables.php
===================================================================
--- t3lib/stddb/tables.php	(revision 10394)
+++ t3lib/stddb/tables.php	(revision )
@@ -358,9 +358,7 @@
 );
 
 	// register the pagetree core navigation component
-t3lib_extMgm::addCoreNavigationComponent('web', 'typo3-pagetree', array(
-	'TYPO3.Components.PageTree'
-));
+t3lib_extMgm::addCoreNavigationComponent('web', 'typo3-pagetree');
 
 /**
  * $TBE_STYLES configures backend styles and colors; Basically this contains all the values that can be used to create new skins for TYPO3.
Index: typo3/classes/class.livesearch.php
===================================================================
--- typo3/classes/class.livesearch.php	(revision 10252)
+++ typo3/classes/class.livesearch.php	(revision )
@@ -93,7 +93,6 @@
 	 */
 	protected function addJavascriptToBackend() {
 		$pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
-		$pageRenderer->addJsFile('ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.LiveSearchActions&' . TYPO3_version, 'text/javascript', $compress = FALSE);
 
 		$this->backendReference->addJavascriptFile('js/livesearch.js');
 	}
Index: typo3/sysext/em/classes/class.tx_em_extensionmanager.php
===================================================================
--- typo3/sysext/em/classes/class.tx_em_extensionmanager.php	(revision 10422)
+++ typo3/sysext/em/classes/class.tx_em_extensionmanager.php	(revision )
@@ -125,20 +125,13 @@
 		$this->pageRenderer->enableExtJSQuickTips();
 
 			// Load  JavaScript:
-		$this->pageRenderer->addJsFile($this->parentObject->doc->backPath .
-			'ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.EM',
-			NULL,
-			FALSE
-		);
-		$this->pageRenderer->addJsFile($this->parentObject->doc->backPath .
-			'ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.EMSOAP',
-			NULL,
-			FALSE
-		);
+		$this->pageRenderer->addExtDirectCode(array(
+			'TYPO3.EM',
+			'TYPO3.EMSOAP',
+			'TYPO3.ExtDirectStateProvider'
+		));
 
-		$this->pageRenderer->addExtDirectCode();
 
-
 			// Localization
 		$labels = tx_em_Tools::getArrayFromLocallang(t3lib_extMgm::extPath('em', 'language/locallang.xml'));
 		$labels['yes'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes');
@@ -278,4 +271,4 @@
 	include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/class.tx_em_extensionsmanager.php']);
 }
 
-?>
\ No newline at end of file
+?>
Index: typo3/template.php
===================================================================
--- typo3/template.php	(revision 10317)
+++ typo3/template.php	(revision )
@@ -821,11 +821,6 @@
 		$this->docStyle();
 
 	   if ($this->extDirectStateProvider) {
-			$this->pageRenderer->addJsFile(
-				$this->backPath . 'ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.ExtDirectStateProvider&' . TYPO3_version,
-				NULL,
-				FALSE
-			);
 			$this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ExtDirect.StateProvider.js');
 		}
 
@@ -1637,7 +1632,6 @@
 	protected function loadCshJavascript() {
 		$this->pageRenderer->loadExtJS();
 		$this->pageRenderer->addJsFile($this->backPath .'../t3lib/js/extjs/contexthelp.js');
-		$this->pageRenderer->addJsFile($this->backPath . 'ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.CSH&' . TYPO3_version, NULL, FALSE);
 		$this->pageRenderer->addExtDirectCode();
 	}
 
Index: t3lib/core_autoload.php
===================================================================
--- t3lib/core_autoload.php	(revision 10306)
+++ t3lib/core_autoload.php	(revision )
@@ -167,6 +167,7 @@
 	't3lib_spritemanager_spritebuildinghandler' => PATH_t3lib . 'spritemanager/class.t3lib_spritemanager_spritebuildinghandler.php',
 	't3lib_spritemanager_abstracthandler' => PATH_t3lib . 'spritemanager/class.t3lib_spritemanager_abstracthandler.php',
 	't3lib_extjs_extdirectdebug' => PATH_t3lib . 'extjs/class.t3lib_extjs_extdirectdebug.php',
+	't3lib_extjs_extdirectapi' => PATH_t3lib . 'extjs/class.t3lib_extjs_extdirectapi.php',
 	't3lib_tree_abstracttree' => PATH_t3lib . 'tree/class.t3lib_tree_abstracttree.php',
 	't3lib_tree_abstractdataprovider' => PATH_t3lib . 'tree/class.t3lib_tree_abstractdataprovider.php',
 	't3lib_tree_abstractstateprovider' => PATH_t3lib . 'tree/class.t3lib_tree_abstractstateprovider.php',
Index: typo3/backend.php
===================================================================
--- typo3/backend.php	(revision 10398)
+++ typo3/backend.php	(revision )
@@ -234,18 +234,6 @@
 			$this->pageRenderer->addJsFile($jsFile);
 		}
 
-
-			// TYPO3.Ajax.ExtDirec is used for BE toolbar items and may be later for general services
-		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.Ajax.ExtDirect') !== FALSE) {
-					$this->pageRenderer->addJsFile('ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.Ajax.ExtDirect&' . TYPO3_version, NULL, FALSE);
-					break;
-				}
-			}
-		}
-		$this->pageRenderer->addJsFile('ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.BackendUserSettings&' . TYPO3_version, NULL, FALSE);
-
 		$this->generateJavascript();
 		$this->pageRenderer->addJsInlineCode('BackendInlineJavascript', $this->js);
 
@@ -342,18 +330,8 @@
 			foreach ($jsFiles as $jsFile) {
 				$this->pageRenderer->addJsFile($relativeComponentPath . 'javascript/' . $jsFile);
 			}
-
-			if (is_array($info['extDirectNamespaces']) && count($info['extDirectNamespaces'])) {
-				foreach ($info['extDirectNamespaces'] as $namespace) {
-					$this->pageRenderer->addJsFile(
-						'ajax.php?ajaxID=ExtDirect::getAPI&namespace=' . $namespace . '&' . TYPO3_version,
-						NULL,
-						FALSE
-					);
-				}
-			}
+		}
+	}
-		}
-	}
 
 	/**
 	 * renders the items in the top toolbar
Index: typo3/sysext/workspaces/Classes/Controller/ReviewController.php
===================================================================
--- typo3/sysext/workspaces/Classes/Controller/ReviewController.php	(revision 10222)
+++ typo3/sysext/workspaces/Classes/Controller/ReviewController.php	(revision )
@@ -138,8 +138,9 @@
 		$this->pageRenderer->enableExtJsDebug();
 
 			// Load  JavaScript:
-		$this->pageRenderer->addExtDirectCode();
-		$this->pageRenderer->addJsFile($this->backPath . 'ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.Workspaces&' . TYPO3_version, NULL, FALSE);
+		$this->pageRenderer->addExtDirectCode(array(
+			'TYPO3.Workspaces'
+		));
 
 		$this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/flashmessages.js');
 		$this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.grid.RowExpander.js');
@@ -183,4 +184,4 @@
 	include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Controller/ReviewController.php']);
 }
 
-?>
\ No newline at end of file
+?>
Index: t3lib/class.t3lib_extmgm.php
===================================================================
--- t3lib/class.t3lib_extmgm.php	(revision 10289)
+++ t3lib/class.t3lib_extmgm.php	(revision )
@@ -844,15 +844,13 @@
 	 *
 	 * @param string $module
 	 * @param string $componentId
-	 * @param array $extDirectNamespaces
 	 * @return void
 	 */
-	public static function addNavigationComponent($module, $componentId, $extDirectNamespaces = array()) {
+	public static function addNavigationComponent($module, $componentId) {
 		$GLOBALS['TBE_MODULES']['_navigationComponents'][$module] = array(
 			'componentId' => $componentId,
 			'extKey' => $GLOBALS['_EXTKEY'],
 			'isCoreComponent' => FALSE,
-			'extDirectNamespaces' => $extDirectNamespaces
 		);
 	}
 
@@ -864,8 +862,8 @@
 	 * @param array $extDirectNamespaces
 	 * @return void
 	 */
-	public static function addCoreNavigationComponent($module, $componentId, $extDirectNamespaces = array()) {
-		self::addNavigationComponent($module, $componentId, $extDirectNamespaces);
+	public static function addCoreNavigationComponent($module, $componentId) {
+		self::addNavigationComponent($module, $componentId);
 		$GLOBALS['TBE_MODULES']['_navigationComponents'][$module]['isCoreComponent'] = TRUE;
 	}
 
Index: t3lib/extjs/class.t3lib_extjs_extdirectapi.php
===================================================================
--- t3lib/extjs/class.t3lib_extjs_extdirectapi.php	(revision 10185)
+++ t3lib/extjs/class.t3lib_extjs_extdirectapi.php	(revision )
@@ -62,106 +62,45 @@
 	 * @return void
 	 */
 	public function getAPI($ajaxParams, TYPO3AJAX $ajaxObj) {
-		$filterNamespace = t3lib_div::_GET('namespace');
-
-			// Check GET-parameter no_cache and extCache setting
-		$extCache = isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache']) && (
-				$GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] === 0 ||
-				$GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] === '0'
-		);
-		$noCache = t3lib_div::_GET('no_cache') ? TRUE : $extCache;
-
-			// look up into the cache
-		$cacheIdentifier = 'ExtDirectApi';
-		$cacheHash = md5($cacheIdentifier . $filterNamespace . t3lib_div::getIndpEnv('TYPO3_SSL') .
-			 serialize($this->settings) . TYPO3_MODE . t3lib_div::getIndpEnv('HTTP_HOST'));
-
-			// 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!
-		if (!$cacheContent) {
-			$javascriptNamespaces = $this->generateAPI($filterNamespace);
-			if (!empty($javascriptNamespaces)) {
-				t3lib_pageSelect::storeHash(
-					$cacheHash,
-					serialize($javascriptNamespaces),
-					$cacheIdentifier
-				);
+		$ajaxObj->setContent(array());
-			}
+	}
-		} else {
-			$javascriptNamespaces = unserialize($cacheContent);
-		}
 
-			// enable caching
-		$expireDate = date('r', $GLOBALS['EXEC_TIME'] + 3600 * 24 * 30);
-		header('Expires: ' . $expireDate);
-		header('Cache-control: public');
-		header('Pragma:');
-
+	/**
+	 * Get the API for a given nameapace
+	 *
+	 * @throws t3lib_exception
+	 * @param  array $filterNamespaces
+	 * @return string
+	 */
+	public function getApiPhp(array $filterNamespaces) {
+		$javascriptNamespaces = $this->getExtDirectApi($filterNamespaces);
 			// return the generated javascript API configuration
 		if (count($javascriptNamespaces)) {
-			$setup = '
-				if (typeof Ext.app.ExtDirectAPI !== "object") {
+			return '
+				if (!Ext.isObject(Ext.app.ExtDirectAPI)) {
 					Ext.app.ExtDirectAPI = {};
 				}
-
-				if (typeof Object.extend !== "function") {
-					Object.extend = function(destination, source) {
-						for (var property in source) {
-							destination[property] = source[property];
-						}
-						return destination;
-					};
-				}
+				Ext.apply(Ext.app.ExtDirectAPI, ' .
+					json_encode($javascriptNamespaces) . ');
 			';
-
-			$ajaxObj->setContent($javascriptNamespaces);
-			$ajaxObj->setContentFormat('javascript');
-			$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
+			$errorMessage = $this->getNamespaceError($filterNamespaces);
+			throw new InvalidArgumentException(
+				$errorMessage,
+				1297645190
-				);
-			}
+			);
+		}
-			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);
-				}
-			');
-		}
-	}
 
+
 	/**
 	 * Generates the API that is configured inside the ExtDirect configuration
 	 * array "$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect']".
 	 *
-	 * @param string $filerNamespace namespace that should be loaded like TYPO3.Backend
+	 * @param array $filerNamespace namespace that should be loaded like array('TYPO3.Backend')
 	 * @return array javascript API configuration
 	 */
-	protected function generateAPI($filterNamespace) {
+	protected function generateAPI(array $filterNamespaces) {
 		$javascriptNamespaces = array();
 		if (is_array($this->settings)) {
 			foreach ($this->settings as $javascriptName => $className) {
@@ -170,7 +109,7 @@
 				$javascriptNamespace = implode('.', $splittedJavascriptName);
 
 					// only items inside the wanted namespace
-				if (strpos($javascriptNamespace, $filterNamespace) !== 0) {
+				if (!$this->findNamespace($javascriptNamespace, $filterNamespaces)) {
 					continue;
 				}
 
@@ -220,10 +159,94 @@
 
 		return $url;
 	}
+
+	/**
+	 * Generates the API or reads it from cache
+	 *
+	 * @param  array $filterNamespaces
+	 * @param bool $checkGetParam
+	 * @return string $javascriptNamespaces
+	 */
+	protected function getExtDirectApi(array $filterNamespaces) {
+			// Check GET-parameter no_cache and extCache setting
+		$noCache = isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache']) && (
+				$GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] === 0 ||
+				$GLOBALS['TYPO3_CONF_VARS']['SYS']['extCache'] === '0'
+		);
+		$noCache = t3lib_div::_GET('no_cache') ? TRUE : $noCache;
+
+			// look up into the cache
+		$cacheIdentifier = 'ExtDirectApi';
+		$cacheHash = md5($cacheIdentifier . implode(',', $filterNamespaces) . t3lib_div::getIndpEnv('TYPO3_SSL') .
+			 serialize($this->settings) . TYPO3_MODE . t3lib_div::getIndpEnv('HTTP_HOST'));
+
+			// 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!
+		if (!$cacheContent) {
+			$javascriptNamespaces = $this->generateAPI($filterNamespaces);
+			if (count($javascriptNamespaces)) {
+				t3lib_pageSelect::storeHash(
+					$cacheHash,
+					serialize($javascriptNamespaces),
+					$cacheIdentifier
+				);
-}
+			}
+		} else {
+			$javascriptNamespaces = unserialize($cacheContent);
+		}
 
+		return $javascriptNamespaces;
+	}
+
+	/**
+	 * Generates the error message
+	 *
+	 * @param  array $filterNamespaces
+	 * @return string $errorMessage
+	 */
+	protected function getNamespaceError(array $filterNamespaces) {
+		if (count($filterNamespaces)) {
+				// namespace error
+			$errorMessage = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:ExtDirect.namespaceError'),
+									__CLASS__, implode(',', $filterNamespaces)
+			);
+		}
+		else {
+				// no namespace given
+			$errorMessage = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:ExtDirect.noNamespace'),
+									__CLASS__
+			);
+		}
+
+		return $errorMessage;
+	}
+
+	/**
+	 * Looks if the given namespace is present in $filterNamespaces
+	 *
+	 * @param  string $namespace
+	 * @param array $filterNamespaces
+	 * @return bool
+	 */
+	protected function findNamespace($namespace, array $filterNamespaces) {
+		if ($filterNamespaces === array('TYPO3')) {
+			return TRUE;
+		}
+		$found = FALSE;
+		foreach ($filterNamespaces as $filter) {
+			if (t3lib_div::isFirstPartOfStr($filter, $namespace)) {
+				$found = TRUE;
+				break;
+			}
+		}
+		return $found;
+	}
+}
+
 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/extjs/class.t3lib_extjs_extdirectapi.php'])) {
 	include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/extjs/class.t3lib_extjs_extdirectapi.php']);
 }
 
-?>
\ No newline at end of file
+?>
