35 $rawPostData = file_get_contents(
'php://input');
40 $isValidRequest = TRUE;
41 if (!empty($postParameters[
'extAction'])) {
43 $isUpload = $postParameters[
'extUpload'] ===
'true';
44 $request = new \stdClass();
45 $request->action = $postParameters[
'extAction'];
46 $request->method = $postParameters[
'extMethod'];
47 $request->tid = $postParameters[
'extTID'];
48 unset($_POST[
'securityToken']);
49 $request->data = array($_POST + $_FILES);
50 $request->data[] = $postParameters[
'securityToken'];
51 } elseif (!empty($rawPostData)) {
52 $request = json_decode($rawPostData);
55 'type' =>
'exception',
56 'message' =>
'Something went wrong with an ExtDirect call!',
59 $isValidRequest = FALSE;
61 if (!is_array($request)) {
62 $request = array($request);
64 if ($isValidRequest) {
67 foreach ($request as $index => $singleRequest) {
68 $response[$index] = array(
69 'tid' => $singleRequest->tid,
70 'action' => $singleRequest->action,
71 'method' => $singleRequest->method
73 $token = array_pop($singleRequest->data);
81 throw new \TYPO3\CMS\Core\FormProtection\Exception(
'ExtDirect: Invalid Security Token!');
83 $response[$index][
'type'] =
'rpc';
84 $response[$index][
'result'] = $this->
processRpc($singleRequest, $namespace);
85 $response[$index][
'debug'] =
$GLOBALS[
'error']->toString();
87 $response[$index][
'type'] =
'exception';
88 $response[$index][
'message'] = $exception->getMessage();
89 $response[$index][
'code'] =
'router';
93 if ($isForm && $isUpload) {
94 $ajaxObj->setContentFormat(
'plain');
95 $response = json_encode($response);
96 $response = preg_replace(
'/"/',
'\\"', $response);
98 '<html><body><textarea>' . $response .
'</textarea></body></html>' 101 $ajaxObj->setContentFormat(
'jsonbody');
103 $ajaxObj->setContent($response);
117 $endpointName = $namespace .
'.' . $singleRequest->action;
118 if (!isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ExtDirect'][$endpointName])) {
119 throw new \UnexpectedValueException(
'ExtDirect: Call to undefined endpoint: ' . $endpointName, 1294586450);
121 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ExtDirect'][$endpointName])) {
122 if (!isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ExtDirect'][$endpointName][
'callbackClass'])) {
123 throw new \UnexpectedValueException(
'ExtDirect: Call to undefined endpoint: ' . $endpointName, 1294586451);
125 $callbackClass =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ExtDirect'][$endpointName][
'callbackClass'];
126 $configuration =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ExtDirect'][$endpointName];
127 if (!is_null($configuration[
'moduleName']) && !is_null($configuration[
'accessLevel'])) {
128 $GLOBALS[
'BE_USER']->modAccess(array(
129 'name' => $configuration[
'moduleName'],
130 'access' => $configuration[
'accessLevel']
135 return call_user_func_array(array($endpointObject, $singleRequest->method), is_array($singleRequest->data) ? $singleRequest->data : array());
static getUserObj($classRef, $checkPrefix='', $silent=FALSE)
static makeInstance($className)
processRpc($singleRequest, $namespace)
route($ajaxParams, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
if($ajaxRegistryEntry !==NULL) $ajaxObj