Project

General

Profile

Bug #22809 » 14618_v4.diff

Administrator Admin, 2010-06-09 16:11

View differences:

t3lib/extjs/class.t3lib_extjs_extdirectapi.php (working copy)
public function getAPI($ajaxParams, TYPO3AJAX $ajaxObj) {
$filterNamespace = t3lib_div::_GET('namespace');
// look up into the cache
// 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 . 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") {
......
$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);
}
');
}
}
......
$numberOfParameters = $reflectionMethod->getNumberOfParameters();
$docHeader = $reflectionMethod->getDocComment();
$formHandler = (strpos($docHeader, '@formHandler') !== FALSE);
$javascriptNamespaces[$javascriptNamespace]['actions'][$javascriptObjectName][] = array(
'name' => $methodName,
'len' => $numberOfParameters,
typo3/backend.php (working copy)
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);
typo3/sysext/lang/locallang_core.xml (working copy)
<label index="donateWindow.button_donate">Donate now</label>
<label index="donateWindow.button_disable">Never show again</label>
<label index="donateWindow.button_postpone">Remind me later</label>
<label index="ExtDirect.namespaceError">Ext Direct error in &quot;%s&quot; with namespace: &quot;%s&quot;\n
Try to clear the TYPO3 cache and / or use paramater no_cache=1 as parameter in URL typo3/ajax.php\n\n
Check also the following points:\n
- configuration in ext_localconf.php: registration key should be like &quot;TYPO3.MyExtension.Sample&quot;\n
- URL typo3/ajax.php: namespace parameter should be like: &quot;TYPO3.MyExtension&quot;\n
- javascript: method\'s name should be like: &quot;TYPO3.MyExtension.Sample.myMethod&quot;\n</label>
<label index="ExtDirect.noNamespace">Ext Direct error in &quot;%s&quot;: no namespace has been found.</label>
</languageKey>
</data>
</T3locallang>
(3-3/3)