Extension:UnknownActionHandler
From MediaWiki.org
|
UnknownActionHandler Release status: stable |
|
|---|---|
| Implementation | Page action |
| Description | Enables customized handling of non-native MediaWiki web requests (aka 'actions') through the used of stored PHP page code. |
| Author(s) | jldupont Talk |
| Version | 1.0 |
| MediaWiki | tested 1.8.2,1.9.3 |
| Download | Extension:UnknownActionHandler/Code |
| Hooks used | |
Contents |
[edit] Description
MediaWiki pages have an action query parameter that is used to determine the "mode" of the page: e.g. view, edit, etc. (see Manual:Parameters to index.php for more information). In addition to the built-in values for the action query parameter, you can also define your own. This extension associates each custom action with a MediaWiki article that stores the php code to handle that action.
The processing code is fetched from a specified MediaWiki stored page. The said page can also contain GeSHi compatible tags to wrap the PHP code. Finally, wikitext can also be present on the page alongside the PHP code but this latter one will not take part in the Unknown Action handling.
[edit] Features
- Secure
- Composite Page capability: page which contains the 'handler' can also have the following contents:
- PHP code (enclosed in <php> tagged section)
- Javascript code (enclosed in <javascript> tagged section)
- Wikitext (anywhere else on the page)
[edit] Security
This extension is secure: the page containing the PHP code can only be executed if the page is restricted on 'edit'. This functionality is provided by Extension:RunPHP Class.
[edit] Function
Extension that provides a new hook "UnknownAction".
This hook is triggered after a non-native action is requested to Mediawiki. A custom [Action][Handler] associative array is used to load a configured article page containing processing code to handle the request.
[edit] Example Usage
A special page for editing a page's attributes made available through the "PageAttributes" extension.
[edit] IMPORTANT USAGE NOTE
The MediaWiki page that stores the PHP code processor for the handler must be structured in the following way:
<php>
function XYZ( &$article )
{ some code here }
return "XYZ";
</php>
The extension leverages PHP's eval method capability to provide a return code in order to get access to the method name to call.
[edit] Dependancy
Requires the Extension:RunPHP Class to operate.
[edit] Installation
In LocalSettings.php:
require('extensions/RunPHP Class.php'); require('extensions/UnknownActionHandler.php'); $uaObj->setHandler('actionXYZ', 'PageNameWhichContainsHandlerForActionXYZ' ); ... add more here...
[edit] History
- V1.0 Initial availability.
- V1.1 Integration with "RunPHP Class"
- V1.2 Added Javascript integration
- V1.3 Changed to "silent" behavior when no handler present for an action.

