MidCOM URL Methods

From OpenPSA Wiki

Jump to: navigation, search

MidCOM URL Parameters are executed before any component processing is done. They all belong to the domain "midcom" and are executed by adding them at the beginnig of the request URL like this: midcom-$name-$value. Note: The name of the Host and of the Page have to be noted in front of the URL method, the path to the component after it. From the MidCOM API documentation:

Contents

[edit] 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 assignement 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(). See also: Templating in MidCOM

[edit] int serveattachment; GUID serveattachmentguid

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

Note: While MidCOM only requires an ID or GUID, a filename is often appended on this URL Method for Browser compatibility. This filename doesn't have to match the name of the Attachment, as MidCOm identifies it by ID/GUID.

[edit] int servesnippet; GUID servesnippetguid

This pair will serve the code field of a snippet denoted by the given ID/GUID, see serve_snippet for further options. For security purposes, the snippets that may be served using this function MUST have the parameter midcom/allow_serve set to "true". If this is not the case, snippet serving will be aborted with an access denied error. See the serve_snippet method documentation for further details.

[edit] 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 MidCOM Constant MIDCOM_NAV_PERMALINK of any NAP data array. Upon resolving it, MidCOM will relocate to the automatically computed MIDCOM_NAV_FULLURL.

[edit] 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 credencials of the current MidCOM instance unconditionally.

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

See available scripts at MidCOM exec Scripts

[edit] 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 $this->cache->content->no_cache();

[edit] mixed log

Shows the contents of the current debuglog. You have to enable this interface by setting the config option log_tailurl_enable to true. Note, that this method is using the debug log path of the current MidCOM logger automatically, it is not possible to switch to another logfile dynamically due to security reasons. The parameter can be either "all" which will yield the complete log (beware of huge logfiles), or an integer, which is the number of lines counting from the file backwards you want to display (this uses the systems tail command via exec).

NOTE: This function is limited by PHP's memory limit, as the (f)passthru functions are really intelligent and try to load the complete file into memory instead streaming it to the client.

Personal tools