예제 #1
0
파일: ajax.lib.php 프로젝트: rhertzog/lcs
 /**
  * Instanciate and register the AJAX remote service for a given module.
  * The remote service must be defined in the connector/ajaxservice.cnr.php
  * file of the module, extends the Ajax_Remote_Module_Service abstract class
  * and, in addition, it's name must follow the pattern "{$moduleLabel}_AjaxRemoteService"
  * @param string $moduleLabel
  * @return Ajax_Remote_Module_Service
  * @throws Exception if the module does not provide an AJAX remote service
  */
 public static function registerModuleServiceInstance($moduleLabel)
 {
     $ajaxHandler = self::getModuleServiceInstance($moduleLabel);
     $ajaxHandler->register(Claroline::ajaxServiceBroker());
     return $ajaxHandler;
 }
예제 #2
0
파일: ajaxbroker.php 프로젝트: rhertzog/lcs
 *  1. Register Ajax remote service in module functions.php
 *      Claroline::ajaxServiceBroker()->register( .... );
 *  2. Execute AJAX requests on get_path('url').'/claroline/backends/ajaxbroker.php'
 *
 * @version     $Revision: 14132 $
 * @copyright   (c) 2001-2011, Universite catholique de Louvain (UCL)
 * @author      Claroline Team <*****@*****.**>
 * @author      Frederic Minne <*****@*****.**>
 * @license     http://www.gnu.org/copyleft/gpl.html
 *              GNU GENERAL PUBLIC LICENSE version 2 or later
 * @package     kernel.utils.ajax
 * @since       Claroline 1.10
 */
try {
    require_once dirname(__FILE__) . '/../inc/claro_init_global.inc.php';
    if (!get_conf('ajaxRemoteServiceBrokerEnabled', false)) {
        $response = new Json_Error("Ajax Remote Service is not available (you can allow it in the " . "claroline configuration advanced settings)");
    } else {
        $moduleLabel = Claro_UserInput::getInstance()->get('moduleLabel', false);
        if ($moduleLabel) {
            Ajax_Remote_Module_Service::registerModuleServiceInstance($moduleLabel);
        }
        $ajaxRequest = Ajax_Request::getRequest(Claro_UserInput::getInstance());
        $response = Claroline::ajaxServiceBroker()->handle($ajaxRequest);
    }
} catch (Exception $e) {
    $response = new Json_Exception($e);
}
header('Content-type: application/json; charset=utf-8');
echo $response->toJson();
exit;