getMethod("register_service"); try { // Invoke the static method to kick off the service handler $register_method->invoke(null); } catch (Exception $ex) { // Try to include the control.inc file instead; if the module needs a direct access point (should be REALLY rare... file downloads [that can't be done over XHR], RSS feeds, etc.) $msg = "Uncaught exception from service `{$config["pageIndex"]}`; bailing out. Detail:

".$ex->getMessage(); http_response_code(400); header("HTTP/ 400 $msg"); die($msg); } } } catch(Exception $ex) { $msg = "A request has been made to a service (`{$config["pageIndex"]}`) that produced an error. This should not happen, please check the URL and try again."; error_log("Error loading service: ".$ex->getMessage()); http_response_code(400); header("HTTP/ 400 $msg"); die($msg); } break; // case "module": // // Get the page index to know where to route the ajax request // $config["pageIndex"] = array_shift($config["params"]); // if (!$config["pageIndex"]) die("No request specified."); // // include_once("modules/{$config["pageIndex"]}/model.inc"); // include("modules/{$config["pageIndex"]}/ajax/control.ajax"); // // break; // // case "ajax": // // Get the page index to know where to route the ajax request // $config["pageIndex"] = array_shift($config["params"]); // if (!$config["pageIndex"]) die("No request specified."); // // // By default, a pageIndex URL can be given, and control.ajax will be assumed. For subpages, or other reasons of needing // // multiple .ajax files, add the ajax filename to the end of the /ajax request; i.e., ajax/index/file.ajax // $reqFile = $config["params"][count($config["params"])-1]; // // $controlFile = preg_match("/\.ajax$/i", $reqFile) ? $reqFile : "control.ajax"; // // // Include the model.inc (not required) // @include("pages/{$config["pageIndex"]}/model.inc"); // include("pages/{$config["pageIndex"]}/ajax/$controlFile"); // // break; default: // Default functionality - render a page if it exists, select index if nothing is specified if (!$config["pageIndex"]) $config["pageIndex"] = "index"; // Check that control file exists for a page (last attempt) $controlFile = "pages/{$config["pageIndex"]}/control.inc"; $literalFile = $config["baseAppDir"].substr($_SERVER["REQUEST_URI"], 1); if (file_exists($literalFile) && !is_dir($literalFile)) { // Request for an actual filename that exists in the app directory structure echo @file_get_contents($literalFile); } elseif (file_exists($controlFile)) { // Application page (/pages) // Include the model.inc (not required) @include("pages/{$config["pageIndex"]}/model.inc"); // Include the required Control file include($controlFile); } else { // Page access key is the last element of the URL if (count($config["params"])) $config["pageIndex"] = array_pop($config["params"]); // Scrub it just to be safe $config["pageIndex"] = preg_replace("/[^a-z0-9_\-#]/is", "", $config["pageIndex"]); // TODO: access key build for nested menus (breadcrumbs!) $pageObj = \Proteus\Modules\PageContent\Logic\ContentPage::getByAccessKey($config["pageIndex"]); if (!$pageObj->id) { // Route to 404 page if the page is not found header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); include($config["baseAppDir"]."404.php"); } else { $a = new \Proteus\Modules\PageContent\UI\ContentPage($pageObj); $a->render(); } } } exit(0); ?>