/** * Services handler - turns request over to the registered handler * If no handler is found, this returns a 404 error * * @param string $handler Handler name * @param array $request Request string * * @return void * @access private */ function service_handler($handler, $request) { global $CONFIG; elgg_set_context('api'); $request = explode('/', $request); // after the handler, the first identifier is response format // ex) http://example.org/services/api/rest/json/?method=test $response_format = array_shift($request); // Which view - xml, json, ... if ($response_format && elgg_is_valid_view_type($response_format)) { elgg_set_viewtype($response_format); } else { // default to json elgg_set_viewtype("json"); } if (!isset($CONFIG->servicehandler) || empty($handler)) { // no handlers set or bad url header("HTTP/1.0 404 Not Found"); exit; } else { if (isset($CONFIG->servicehandler[$handler]) && is_callable($CONFIG->servicehandler[$handler])) { $function = $CONFIG->servicehandler[$handler]; call_user_func($function, $request, $handler); } else { // no handler for this web service header("HTTP/1.0 404 Not Found"); exit; } } }
$msg = "Could not load {$file}"; throw new InstallationException($msg); } } // include subsite manager require_once dirname(dirname(__FILE__)) . "/mod/subsite_manager/system.php"; // Connect to database, load language files, load configuration, init session // Plugins can't use this event because they haven't been loaded yet. elgg_trigger_event('boot', 'system'); // needs to be set for links in html head $viewtype = get_input('view', 'default'); $site_guid = elgg_get_site_entity()->getGUID(); // Subsite Manager - simple cache prefix $lastcached = datalist_get("sc_lastcached_" . $viewtype . "_" . $site_guid); $CONFIG->lastcache = $lastcached; // Load the plugins that are active elgg_load_plugins(); // @todo move loading plugins into a single boot function that replaces 'boot', 'system' event // and then move this code in there. // This validates the view type - first opportunity to do it is after plugins load. $view_type = elgg_get_viewtype(); if (!elgg_is_valid_view_type($view_type)) { elgg_set_viewtype('default'); } // @todo deprecate as plugins can use 'init', 'system' event elgg_trigger_event('plugins_boot', 'system'); // Complete the boot process for both engine and plugins elgg_trigger_event('init', 'system'); $CONFIG->boot_complete = true; // System loaded and ready elgg_trigger_event('ready', 'system');