public function send() { if (!preg_match('|^https?://|', $this->url)) { if ($this->url == '' || substr($this->url, 0, 1) != "/") { $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); if ($prefix == '') { $prefix = midcom::get()->get_page_prefix(); } $this->url = "{$prefix}{$this->url}"; debug_add("This is a relative URL from the local site, prepending anchor prefix: {$this->url}"); } else { $this->url = midcom::get()->get_host_name() . $this->url; debug_add("This is an absolute URL from the local host, prepending host name: {$this->url}"); } $location = "Location: {$this->url}"; } else { // This is an external URL $location = "Location: {$this->url}"; } midcom::get('cache')->content->no_cache(); midcom::get()->finish(); debug_add("Relocating to {$location}"); midcom::get()->header($location, $this->code); _midcom_stop_request(); }
/** * Sends the response to the client and shuts down the environment */ public function send() { midcom::get()->skip_page_style = true; midcom::get('cache')->content->content_type('application/json'); midcom::get()->header('Content-type: application/json; charset=' . $this->encoding); echo json_encode($this->_data); midcom::get()->finish(); _midcom_stop_request(); }
/** * Sends the response to the client and shuts down the environment */ public function send() { midcom::get()->skip_page_style = true; midcom::get('cache')->content->content_type('text/xml'); midcom::get()->header('Content-type: text/xml; charset=' . $this->encoding); echo '<?xml version="1.0" encoding="' . $this->encoding . '" standalone="yes"?>' . "\n"; echo "<response>\n"; foreach ($this->_data as $field => $value) { echo $this->_render_tag($field, $value); } echo "</response>\n"; midcom::get()->finish(); _midcom_stop_request(); }
<?php midcom::get()->finish(); _midcom_stop_request(); } elseif (isset($_GET['f']) && $_GET['f'] == 'callback') { // the user has authorized us at FE, so now we can pick up our access token + secret if (!$session->exists('auth_state') || $session->get('auth_state') != 'start') { throw new midcom_error("Out of sequence."); } $fireeagle = new FireEagle($fireeagle_consumer_key, $fireeagle_consumer_secret, $session->get('request_token'), $session->get('request_secret')); $access_token = $fireeagle->getAccessToken(); if (!isset($access_token['oauth_token']) || !is_string($access_token['oauth_token']) || !isset($access_token['oauth_token_secret']) || !is_string($access_token['oauth_token_secret'])) { throw new midcom_error("Failed to get FireEagle access token\n"); } $user->set_parameter('net.yahoo.fireeagle', 'access_key', $access_token['oauth_token']); $user->set_parameter('net.yahoo.fireeagle', 'access_secret', $access_token['oauth_token_secret']); midcom::get()->relocate($_SERVER['SCRIPT_NAME']); // This will exit } ?> <p><a href="?f=start">Start Fire Eagle authentication</a></p> <?php midcom::get()->finish(); _midcom_stop_request(); } $fireeagle = org_routamc_positioning_importer::create('fireeagle'); $coordinates = $fireeagle->get_fireeagle_location($user); if ($coordinates) { echo sprintf('According to Fire Eagle your position since %s is %s', strftime('%x %X', $coordinates['date']), org_routamc_positioning_utils::microformat_location($coordinates['latitude'], $coordinates['longitude'])); } else { echo "Failed to get position, last error is {$fireeagle->error} {$fireeagle->error_string}"; }
public function hKit() { // pre-flight checks $pass = true; $required = array('dom_import_simplexml', 'file_get_contents', 'simplexml_load_string'); $missing = array(); foreach ($required as $f) { if (!function_exists($f)) { $pass = false; $missing[] = $f . '()'; } } if (!$pass) { _midcom_stop_request('hKit error: these required functions are not available: <strong>' . implode(', ', $missing) . '</strong>'); } }
/** * @since 1.4 * @access private */ function _redirect($filename) { // attention, heavily-commented-out-area // maybe use this in addition to file time checking //Header("Expires: ".date("r",time()+$this->_timeout)); /* no caching at all, doesn't seem to work as good: Header("Cache-Control: no-cache"); Header("Pragma: no-cache"); */ // HTTP redirect, some feed readers' simple HTTP implementations don't follow it //Header("Location: ".$filename); Header("Content-Type: " . $this->contentType . "; charset=" . $this->encoding . "; filename=" . basename($filename)); if (preg_match("/\\.(kml|gpx)\$/", $filename)) { Header("Content-Disposition: attachment; filename=" . basename($filename)); } else { Header("Content-Disposition: inline; filename=" . basename($filename)); } readfile($filename, "r"); _midcom_stop_request(); }
/** * Adds an item for an existing object */ function add_object_item($identifier) { $object = $this->objects[$identifier]; $this->_controllers[$identifier] = midcom_helper_datamanager2_controller::create('ajax'); if ($this->window_mode) { $this->_controllers[$identifier]->window_mode = $this->window_mode; } if ($this->wide_mode) { $this->_controllers[$identifier]->wide_mode = $this->wide_mode; } $this->_controllers[$identifier]->allow_removal = true; $this->_controllers[$identifier]->schemadb = $this->_schemadb; $this->_controllers[$identifier]->set_storage($object); switch ($this->_controllers[$identifier]->process_ajax(false)) { case 'view': break; case 'ajax_delete': midcom::get('cache')->content->content_type('text/xml'); midcom::get()->header('Content-type: text/xml; charset=utf-8'); echo '<?xml version="1.0" encoding="utf-8" standalone="yes"?>' . "\n"; echo "<deletion id=\"{$identifier}\">\n"; echo ' <status>' . midcom_connection::get_error_string() . "</status>\n"; echo "</deletion>\n"; midcom::get()->finish(); _midcom_stop_request(); case 'ajax_saved': // Notify parent of changes $this->storage->object->update(); default: midcom::get()->finish(); _midcom_stop_request(); } }
public static function init() { /////////////////////////////////// // Try to be smart about the paths: // Define default constants if (!defined('MIDCOM_ROOT')) { define('MIDCOM_ROOT', dirname(__FILE__)); } require MIDCOM_ROOT . '/compat/environment.php'; midcom_compat_environment::initialize(); if (!defined('MIDCOM_STATIC_ROOT')) { $pos = strrpos(MIDCOM_ROOT, '/'); if ($pos === false) { // No slash, this is strange _midcom_stop_request('MIDCOM_ROOT did not contain a slash, this should not happen and is most probably the cause of a configuration error.'); } define('MIDCOM_STATIC_ROOT', substr(MIDCOM_ROOT, 0, $pos) . '/static'); } if (!defined('MIDCOM_STATIC_URL')) { define('MIDCOM_STATIC_URL', '/midcom-static'); } if (!defined('MIDCOM_CONFIG_FILE_BEFORE')) { define('MIDCOM_CONFIG_FILE_BEFORE', '/etc/midgard/midcom.conf'); } if (!defined('MIDCOM_CONFIG_FILE_AFTER')) { define('MIDCOM_CONFIG_FILE_AFTER', '/etc/midgard/midcom-after.conf'); } /////////////////////////////////////// //Constants, Globals and Configuration require MIDCOM_ROOT . '/constants.php'; require MIDCOM_ROOT . '/midcom/connection.php'; require MIDCOM_ROOT . '/midcom/config/midcom_config.php'; ini_set('track_errors', '1'); require MIDCOM_ROOT . '/errors.php'; // Register autoloader so we get all MidCOM classes loaded automatically spl_autoload_register(array('midcom', 'autoload')); if (file_exists(MIDCOM_ROOT . '/../vendor/autoload.php')) { $loader = (require MIDCOM_ROOT . '/../vendor/autoload.php'); $loader->register(); } ///////////////////// // Start the Debugger require MIDCOM_ROOT . '/midcom/debug.php'; debug_add("Start of MidCOM run: {$_SERVER['REQUEST_URI']}"); self::$_services['auth'] = new midcom_services_auth(); self::$_services['auth']->initialize(); /* Load and start up the cache system, this might already end the request * on a content cache hit. Note that the cache check hit depends on the i18n and auth code. */ self::$_services['cache'] = new midcom_services_cache(); ///////////////////////////////////// // Instantiate the MidCOM main class self::$_application = new midcom_application(); if (!empty($GLOBALS['midcom_config']['midcom_use_superglobal'])) { require_once MIDCOM_ROOT . '/compat/superglobal.php'; $_MIDCOM = new midcom_compat_superglobal(); } self::$_application->initialize(); if (file_exists(MIDCOM_CONFIG_FILE_AFTER)) { include MIDCOM_CONFIG_FILE_AFTER; } }
function recaptcha_mailhide_url($pubkey, $privkey, $email) { if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) { _midcom_stop_request("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " . "you can do so at <a href='http://mailhide.recaptcha.net/apikey'>http://mailhide.recaptcha.net/apikey</a>"); } $ky = pack('H*', $privkey); $cryptmail = _recaptcha_aes_encrypt($email, $ky); return "http://mailhide.recaptcha.net/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64($cryptmail); }
/** * Show an error page. * * This function is a small helper, that will display a simple HTML Page reporting * the error described by $httpcode and $message. The $httpcode is also used to * send an appropriate HTTP Response. * * The error pages can be customized by creating style elements named midcom_error_$httpcode. * * For a list of the allowed HTTP codes see the MIDCOM_ERR... constants * * <b>Note:</b> This function will call _midcom_stop_request() after it is finished. * * @link http://www.midgard-project.org/documentation/styling-midcom-error-pages/ Styling MidCOM error pages * @param int $httpcode The error code to send. * @param string $message The message to print. */ public function show($httpcode, $message) { if (!$this->_exception) { debug_add("An error has been generated: Code: {$httpcode}, Message: {$message}"); debug_print_function_stack('Stacktrace:'); } // Send error to special log or recipient as per in configuration. $this->send($httpcode, $message); if (_midcom_headers_sent()) { debug_add("Generate-Error was called after sending the HTTP Headers!", MIDCOM_LOG_ERROR); debug_add("Unexpected Error: {$httpcode} - {$message}", MIDCOM_LOG_ERROR); _midcom_stop_request("Unexpected Error, this should display an HTTP {$httpcode} - " . htmlentities($message)); } switch ($httpcode) { case MIDCOM_ERROK: $header = "HTTP/1.0 200 OK"; $title = "OK"; $code = 200; break; case MIDCOM_ERRNOTFOUND: $header = "HTTP/1.0 404 Not Found"; $title = "Not Found"; $code = 404; break; case MIDCOM_ERRFORBIDDEN: // show access denied $this->access_denied($message); $header = "HTTP/1.0 403 Forbidden"; $title = "Forbidden"; $code = 403; break; case MIDCOM_ERRAUTH: $header = "HTTP/1.0 401 Unauthorized"; $title = "Unauthorized"; $code = 401; break; default: debug_add("Unknown Errorcode {$httpcode} encountered, assuming 500"); // Fall-through // Fall-through case MIDCOM_ERRCRIT: $header = "HTTP/1.0 500 Server Error"; $title = "Server Error"; $code = 500; break; } _midcom_header($header); _midcom_header('Content-Type: text/html'); $style = midcom::get('style'); $style->data['error_title'] = $title; $style->data['error_message'] = $message; $style->data['error_code'] = $code; $style->data['error_exception'] = $this->_exception; $style->data['error_handler'] = $this; if (!$style->show_midcom('midcom_error_' . $code)) { $style->show_midcom('midcom_error'); } debug_add("Error Page output finished, exiting now"); midcom::get('cache')->content->no_cache(); if (midcom::get()) { midcom::get()->finish(); } _midcom_stop_request(); }
/** * This function wraps AJAX processing completely. * * If component wishes to do post-processing after an edit, save or preview * state in this call it must set the <i>exit</i> parameter to <i>false</i>. * <i>view</i> state simply returns processing to component. * * The return values in this processor are: * * - <i>view</i>: user can only view the content, no AJAX functionality available * - <i>ajax_editable</i>: the content is editable via AJAX, highlight * - <i>ajax_edit</i>: User is currently editing the contents via AJAX * - <i>ajax_save</i>: Content has been saved via AJAX * - <i>ajax_preview</i>: User is currently previewing contents via AJAX * * If required, we will here create a form manager instance and save or preview contents */ function process_ajax($exit = true) { $state = 'view'; $this->form_identifier = "dm2_ajax_{$this->datamanager->storage->object->guid}"; if (!$this->_is_ajax_editable()) { return $state; } midcom::get('head')->enable_jquery(); midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . '/midcom.helper.datamanager2/jquery.dm2_ajax_editor.js'); $config = $this->_generate_editor_config(); $script = "jQuery.dm2.ajax_editor.init('{$this->form_identifier}', {$config});"; midcom::get('head')->add_jquery_state_script($script); $this->add_stylesheet(MIDCOM_STATIC_URL . "/midcom.helper.datamanager2/dm2_ajax_editor.css", 'screen'); // Clearer structure than an almost endless chain of if...elseif switch (true) { case array_key_exists("{$this->form_identifier}_edit", $_REQUEST): // User has requested editor $this->formmanager = new midcom_helper_datamanager2_formmanager_ajax($this->datamanager->schema, $this->datamanager->types); $this->formmanager->initialize($this->form_identifier . '_qf'); $this->formmanager->display_form($this->form_identifier); $state = 'ajax_editing'; // TODO: Lock break; case array_key_exists("{$this->form_identifier}_preview", $_REQUEST): // User has requested editor $this->formmanager = new midcom_helper_datamanager2_formmanager_ajax($this->datamanager->schema, $this->datamanager->types); $this->formmanager->initialize($this->form_identifier . '_qf'); $this->formmanager->process_form(); $this->formmanager->display_view($this->form_identifier); $state = 'ajax_preview'; break; case array_key_exists("{$this->form_identifier}_save", $_REQUEST): // User has requested editor $this->formmanager = new midcom_helper_datamanager2_formmanager_ajax($this->datamanager->schema, $this->datamanager->types); $this->formmanager->initialize($this->form_identifier . '_qf'); $exitcode = $this->formmanager->process_form(); if ($exitcode == 'save') { $this->datamanager->save(); $this->formmanager->display_view($this->form_identifier); $state = 'ajax_saved'; } else { $this->formmanager->display_form($this->form_identifier); $state = 'ajax_editing'; } break; case array_key_exists("{$this->form_identifier}_cancel", $_REQUEST): // User has cancelled, display view $this->formmanager = new midcom_helper_datamanager2_formmanager_ajax($this->datamanager->schema, $this->datamanager->types); $this->formmanager->initialize($this->form_identifier . '_qf'); $this->formmanager->display_view($this->form_identifier); $state = 'ajax_cancel'; break; case array_key_exists("{$this->form_identifier}_delete", $_REQUEST): // User has deleted, try to comply $this->datamanager->storage->object->delete(); $state = 'ajax_delete'; if ($exit) { echo midcom_connection::get_error_string(); } break; default: // User isn't yet in editing stage. We must however initialize form manager to load JS dependencies etc $this->formmanager = new midcom_helper_datamanager2_formmanager_ajax($this->datamanager->schema, $this->datamanager->types, 'view'); $this->formmanager->initialize($this->form_identifier . '_qf'); return $state; } if ($exit) { midcom::get()->finish(); _midcom_stop_request(); } // Calling component must exit instead return $state; }
/** * This is a helper to execute any given Script in the current MidCOM * context. All files have to be in $component_dir/exec directly, otherwise * the script will not execute. * * The script's name is taken from the current argv[0]. * * The script file is executed in the cache's live mode to allow for long running * scripts (just produce any output regularly, or Apache will kill you after ~ 2 mins.). * * The remaining arguments will be placed into the globals $argc/argv. * * @param string $component The component to look in ("midcom" uses core scripts) * @see midcom_services_cache_module_content::enable_live_mode() */ private function _process_exec($component) { // Sanity checks if ($this->_context->parser->argc < 1) { throw new midcom_error_notfound("Script exec path invalid, need exactly one argument."); } // Build the path if ($component == 'midcom') { $path = MIDCOM_ROOT . '/midcom/exec/'; } else { $componentloader = midcom::get('componentloader'); if (!$componentloader->is_installed($component)) { throw new midcom_error_notfound('The requested component is not installed'); } $componentloader->load($component); $this->_context->set_key(MIDCOM_CONTEXT_COMPONENT, $component); $path = $componentloader->path_to_snippetpath($component) . '/exec/'; } $path .= $this->_context->parser->argv[0]; if (is_dir($path) && isset($this->_context->parser->argv[1])) { $path .= '/' . $this->_context->parser->argv[1]; } if (is_dir($path)) { throw new midcom_error_notfound("Path is a directory."); } if (!file_exists($path)) { throw new midcom_error_notfound("File not found."); } // collect remaining arguments and put them to global vars. $GLOBALS['argc'] = $this->_context->parser->argc--; $GLOBALS['argv'] = $this->_context->parser->argv; array_shift($GLOBALS['argv']); midcom::get('cache')->content->enable_live_mode(); midcom::get()->set_status(MIDCOM_STATUS_CONTENT); // We seem to be in a valid place. Exec the file with the current permissions. require $path; // Exit midcom::get()->finish(); _midcom_stop_request(''); }
private function _send_reply($message) { $midcom = midcom::get(); $midcom->header('Content-Type: text/html'); $midcom->header('HTTP/1.0 200 OK'); echo $message . ': ' . midcom_connection::get_error_string(); midcom::get('cache')->content->no_cache(); $midcom->finish(); _midcom_stop_request(); }
/** * Process AJAX-style creation requests */ function process_ajax() { $state = 'view'; $this->form_identifier = "dm2_composite_{$this->form_identifier}"; midcom::get('head')->enable_jquery(); // Add the required JavaScript midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . '/midcom.helper.datamanager2/jquery.dm2_ajax_editor.js'); $this->formmanager = new midcom_helper_datamanager2_formmanager_ajax($this->datamanager->schema, $this->datamanager->types); $mode = 'inline'; $creation_mode_enabled = 'true'; if ($this->wide_mode) { $mode = 'wide'; } else { if ($this->window_mode) { $mode = 'window'; } } if ($mode != 'inline') { $creation_mode_enabled = 'false'; } $config = "{mode: '{$mode}'}"; //, allow_creation: {$creation_mode_enabled}}"; $script = "jQuery.dm2.ajax_editor.init('{$this->form_identifier}', {$config}, true);"; midcom::get('head')->add_jquery_state_script($script); $this->add_stylesheet(MIDCOM_STATIC_URL . "/midcom.helper.datamanager2/dm2_ajax_editor.css", 'screen'); switch (true) { case array_key_exists("{$this->form_identifier}_edit", $_REQUEST): // User has requested editor $this->formmanager->initialize($this->form_identifier . '_qf'); $this->formmanager->display_form($this->form_identifier); $state = 'ajax_editing'; midcom::get()->finish(); _midcom_stop_request(); case array_key_exists("{$this->form_identifier}_preview", $_REQUEST): $this->formmanager->initialize($this->form_identifier . '_qf'); $this->formmanager->process_form(); $this->formmanager->display_view($this->form_identifier); $state = 'ajax_preview'; midcom::get()->finish(); _midcom_stop_request(); case array_key_exists("{$this->form_identifier}_save", $_POST): $this->formmanager->initialize($this->form_identifier . '_qf'); // Pre process check for validation etc, we create a new object at this point if everything // looks fine. The change of the storage backend will only be done if we have a clear // save/next result from the QF layer. $result = $this->formmanager->compute_form_result(); if ($result == 'save') { $this->_cast_to_storage_object(); } $exitcode = $this->formmanager->process_form(); if ($exitcode == 'save') { $this->datamanager->save(); $this->formmanager->display_view($this->form_identifier, "midcom_helper_datamanager2_controller_ajax_{$this->datamanager->storage->object->guid}"); $state = 'ajax_created'; } else { $this->formmanager->display_form($this->form_identifier); $state = 'ajax_editing'; } midcom::get()->finish(); _midcom_stop_request(); case array_key_exists("{$this->form_identifier}_cancel", $_REQUEST): $state = 'ajax_editing'; $this->formmanager->initialize($this->form_identifier . '_qf'); $this->formmanager->display_view($this->form_identifier); midcom::get()->finish(); _midcom_stop_request(); } }
/** * This function holds the cache hit check mechanism. It searches the requested * URL in the cache database. If found, it checks, whether the cache page has * expired. If not, the cached page is delivered to the client and processing * ends. In all other cases this method simply returns. * * The midcom-cache URL methods are handled before checking for a cache hit. * * Also, any HTTP POST request will automatically circumvent the cache so that * any component can process the request. It will set no_cache automatically * to avoid any cache pages being overwritten by, for example, search results. * * Note, that HTTP GET is <b>not</b> checked this way, as GET requests can be * safely distinguished by their URL. */ private function _check_hit() { foreach (midcom_connection::get_url('argv') as $arg) { switch ($arg) { case "midcom-cache-invalidate": case "midcom-cache-nocache": case "midcom-cache-stats": // Don't cache these. debug_add("X-MidCOM-cache: " . $arg . " uncached"); return; } } // Check for POST variables, if any is found, go for no_cache. if (count($_POST) > 0) { debug_add('POST variables have been found, setting no_cache and not checking for a hit.'); $this->no_cache(); return; } // Check for uncached operation if ($this->_uncached) { debug_add("Uncached mode"); return; } // Check that we have cache for the identifier $this->_meta_cache->open(); $request_id = $this->generate_request_identifier(0); if (!$this->_meta_cache->exists($request_id)) { debug_add("MISS {$request_id}"); // We have no information about content cached for this request $this->_meta_cache->close(); return; } debug_add("HIT {$request_id}"); // Load metadata for the content identifier connected to current request $content_id = $this->_meta_cache->get($request_id); if (!$this->_meta_cache->exists($content_id)) { debug_add("MISS meta_cache {$content_id}"); // Content cache data is missing $this->_meta_cache->close(); return; } $data = $this->_meta_cache->get($content_id); if (isset($data['expires']) && !is_null($data['expires'])) { if ($data['expires'] < time()) { $this->_meta_cache->close(); debug_add('Current page is in cache, but has expired on ' . gmdate('c', $data['expires']), MIDCOM_LOG_INFO); return; } } $this->_meta_cache->close(); if (!isset($data['last_modified'])) { debug_add('Current page is in cache, but has insufficient information', MIDCOM_LOG_INFO); return; } debug_add("X-MidCOM-meta-cache: HIT {$content_id}"); // Check If-Modified-Since and If-None-Match, do content output only if // we have a not modified match. if (!$this->_check_not_modified($data['last_modified'], $data['etag'], $data['sent_headers'])) { $this->_data_cache->open(); if (!$this->_data_cache->exists($content_id)) { $this->_data_cache->close(); debug_add("Current page is in not in the data cache, possible ghost read.", MIDCOM_LOG_WARN); return; } debug_add("HIT {$content_id}"); $content = $this->_data_cache->get($content_id); $this->_data_cache->close(); foreach ($data['sent_headers'] as $header) { _midcom_header($header); } echo $content; } _midcom_stop_request(); }
/** * This will show a complete login page unconditionally and exit afterwards. * If the current style has an element called <i>midcom_services_auth_login_page</i> * it will be shown instead. The local scope will contain the two variables * $title and $login_warning. $title is the localized string 'login' from the main * MidCOM L10n DB, login_warning is empty unless there was a failed authentication * attempt, in which case it will have a localized warning message enclosed in a * paragraph with the ID 'login_warning'. * * @link http://www.midgard-project.org/midcom-permalink-c5e99db3cfbb779f1108eff19d262a7c further information about how to style these elements. */ function show_login_page() { // Drop any output buffer first midcom::get('cache')->content->disable_ob(); $this->_generate_http_response(); midcom::get('cache')->content->no_cache(); $title = midcom::get('i18n')->get_string('login', 'midcom'); // Determine login warning so that wrong user/pass is shown. $login_warning = ''; if ($this->auth_credentials_found && is_null($this->user)) { $login_warning = midcom::get('i18n')->get_string('login message - user or password wrong', 'midcom'); } // Pass our local but very useful variables on to the style element midcom::get('style')->data['midcom_services_auth_show_login_page_title'] = $title; midcom::get('style')->data['midcom_services_auth_show_login_page_login_warning'] = $login_warning; midcom::get('style')->show_midcom('midcom_services_auth_login_page'); midcom::get()->finish(); _midcom_stop_request(); }
/** * Process the request * * Basically this method will parse the URL and search for a component that can * handle the request. If one is found, it will process the request, if not, it * will report an error, depending on the situation. * * Details: The logic will traverse the node tree and for each node it will load * the component that is responsible for it. This component gets the chance to * accept the request (this is encapsulated in the _can_handle call), which is * basically a call to can_handle. If the component declares to be able to handle * the call, its handle function is executed. Depending if the handle was successful * or not, it will either display an HTTP error page or prepares the content handler * to display the content later on. * * If the parsing process doesn't find any component that declares to be able to * handle the request, an HTTP 404 - Not Found error is triggered. */ private function _process(midcom_core_context $context) { $resolver = new midcom_core_resolver($context); $handler = $resolver->process(); if (false === $handler) { /** * Simple: if current context is not '0' we were called from another context. * If so we should not break application now - just gracefully continue. */ if ($context->id == 0) { // We couldn't fetch a node due to access restrictions if (midcom_connection::get_error() == MGD_ERR_ACCESS_DENIED) { throw new midcom_error_forbidden(midcom::get('i18n')->get_string('access denied', 'midcom')); } else { throw new midcom_error_notfound("This page is not available on this server."); } } $this->_status = MIDCOM_STATUS_ABORT; return false; } $context->run($handler); if ($context->id == 0 && $this->skip_page_style == true) { $this->_status = MIDCOM_STATUS_CONTENT; // Enter Context $oldcontext = $context; midcom_core_context::get(0)->set_current(); midcom::get('style')->enter_context(0); $this->_output(); // Leave Context midcom::get('style')->leave_context(); $oldcontext->set_current(); $this->finish(); _midcom_stop_request(); } else { $this->_status = MIDCOM_STATUS_CONTENT; } }