|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2007-2011 Benjamin Mack 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 /** 00028 * AJAX dispatcher 00029 * @author Benjamin Mack <mack@xnos.org> 00030 * @package TYPO3 00031 */ 00032 00033 $TYPO3_AJAX = true; 00034 00035 // include t3lib_div at this time to get the GET/POST methods it provides 00036 require_once('../t3lib/class.t3lib_div.php'); 00037 00038 // first get the ajaxID 00039 $ajaxID = (string)t3lib_div::_GP('ajaxID'); 00040 00041 // this is a list of requests that don't necessarily need a valid BE user 00042 $noUserAjaxIDs = array( 00043 'BackendLogin::login', 00044 'BackendLogin::logout', 00045 'BackendLogin::refreshLogin', 00046 'BackendLogin::isTimedOut', 00047 'BackendLogin::getChallenge', 00048 ); 00049 00050 // if we're trying to do an ajax login, don't require a user. 00051 if(in_array($ajaxID, $noUserAjaxIDs)) { 00052 define('TYPO3_PROCEED_IF_NO_USER', 2); 00053 } 00054 00055 require('init.php'); 00056 require('classes/class.typo3ajax.php'); 00057 00058 // finding the script path from the variable 00059 $ajaxScript = $TYPO3_CONF_VARS['BE']['AJAX'][$ajaxID]; 00060 00061 00062 // instantiating the AJAX object 00063 $ajaxObj = t3lib_div::makeInstance('TYPO3AJAX', $ajaxID); 00064 $ajaxParams = array(); 00065 00066 00067 // evaluating the arguments and calling the AJAX method/function 00068 if (empty($ajaxID)) { 00069 $ajaxObj->setError('No valid ajaxID parameter given.'); 00070 } else if (empty($ajaxScript)) { 00071 $ajaxObj->setError('No backend function registered for ajaxID "'.$ajaxID.'".'); 00072 } else { 00073 $ret = t3lib_div::callUserFunction($ajaxScript, $ajaxParams, $ajaxObj, false, true); 00074 if ($ret === false) { 00075 $ajaxObj->setError('Registered backend function for ajaxID "'.$ajaxID.'" was not found.'); 00076 } 00077 } 00078 00079 // outputting the content (and setting the X-JSON-Header) 00080 $ajaxObj->render(); 00081 00082 ?>
1.8.0