Matches the given context to a handler or to one of the central URL methods.

URL methods are handled directly from here, handlers are passed back to midcom_application

URL METHODS

The following URL parameters are recognized and are executed before any component processing is done. They all belong to the domain "midcom", e.g. they are executed like this: midcom-$name-$value.

string substyle

This will set a substyle to the current component, which is appended to the style selected by the component at the moment the component style is loaded. The methods substyle_(append|prepend)'s work on the basis of this value then.

Note, that this first assignment is done between can_handle and handle, so it will serve as a basis for all component-side style switching operations.

The substyle URL switch is most useful in conjunction with midcom_application::dynamic_load().

GUID serveattachmentguid

This method will serve the attachment denoted by the given ID/GUID. It uses the default expiration time of serve_attachment (see there).

GUID permalink

This will resolve the given GUID into the MidCOM NAP tree, relocating to the URL corresponding to the node/leaf. The Permalink can be created by using the key MIDCOM_NAV_PERMALINK of any NAP data array. Upon resolving it, MidCOM will relocate to the automatically computed MIDCOM_NAV_FULLURL.

string exec

Allows you to execute certain php files directly, in full MidCOM context. The argument is the name of the component, which holds the script to be executed. Script files are searched in the subdirectory "exec" of the component. If you use "midcom" as component name, MidCOM core scripts, located in lib/midcom/exec will be accessible. The next argument on the command line must be the name of the script file. Accessing subdirectories is not possible, only a single argument will be taken.

The scripts executed need to do their own permission checks, they will work with the credentials of the current MidCOM instance unconditionally.

Example: http://$host/midcom-exec-midcom/upgrade_metadata.php

The remaining URL arguments are put into the globals $argc/$argv.

string cache

May take one of the following values: "invalidate" will clear the cache of the current site, "nocache" will bypass the cache for the current request by calling midcom::get('cache')->content->no_cache();

package midcom

 Methods

__construct (\midcom_core_context $context)

Parameters

$context

process ()

Matches the current request to a handler if possible

Exceptions

\midcom_error If topic can't be loaded

Returns

mixedHandler or false if there is no match

serve_attachment (\MidgardAttachment $attachment, int $expires)

Deliver a blob to the client.

This is a replacement for mgd_serve_attachment that should work around most of its bugs: It is missing all important HTTP Headers concerning file size, modification date and expiration. It will add the following HTTP Headers:

  • Cache-Control: public max-age=$expires
  • Expires: GMT Date $now+$expires
  • Last-Modified: GMT Date of the last modified timestamp of the Attachment
  • Content-Length: The Length of the Attachment in Bytes
  • Accept-Ranges: none

This should enable caching of browsers for Navigation images and so on. You can influence the expiration of the served attachment with the parameter $expires. It is the time in seconds till the client should refetch the file. The default for this is 24 hours. If you set it to "0" caching will be prohibited by changing the sent headers like this:

  • Pragma: no-cache
  • Cache-Control: no-cache
  • Expires: Current GMT Date

If expires is set to -1, no expires header gets sent.

Parameters

$attachment

\MidgardAttachment&$attachment A reference to the attachment to be delivered.

$expires

intHTTP-Expires timeout in seconds, set this to 0 for uncacheable pages, or to -1 for no Expire header.

_get_remaining_url ($value)

Parameters

$value

_process_cache ($value)

Parameters

$value

_process_exec (string $component)

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.

see \midcom_services_cache_module_content::enable_live_mode()

Parameters

$component

stringThe component to look in ("midcom" uses core scripts)

_process_logout ($value)

Parameters

$value

_process_serveattachmentguid ($value)

Parameters

$value

_process_urlmethods ()

 Properties

 

\midcom_core_context $_context

The context we're working on