Extension:Foxway

Revision as of 16:21, 23 December 2013 by Pastakhov (talk | contribs) (fix description)
MediaWiki extensions manual
Foxway
Release status: experimental
Implementation Tag , Parser function
Description Adds in the wikitext parser that can interpret and execute PHP code
Author(s) Pavel Astakhov (pastakhovtalk)
Latest version 0.5.1 (2013-07-02)
MediaWiki
PHP 5.3+
Database changes No
License GNU General Public License 2.0 or later
Download
сhangelog
Example test.foxway.org
  • $wgFoxwayFunctions
  • $wgNamespacesWithFoxway
  • $wgFoxway_max_execution_time
  • $wgFoxway_max_execution_time_for_scope
foxway
Translate the Foxway extension if it is available at translatewiki.net

The Foxway extension can interpret and execute PHP code in wiki page.

Usage

The <foxway> tag is used to embed blocks of PHP code into wikitext, which are then executed. The standard PHP functions echo may be used to pass output back to the parser.

<foxway>
$foo = 'hello world';
echo ucfirst( $foo . "!!!\n" );
</foxway>

It will display:

Hello world!!! 

example

Variable scope

  • All variables declarations persist from one block/expression to the next, throughout the page.
  • Any variable used inside a page is by default limited to the local page scope.
  • You can declare a global variables, are they also will be available through a special variable $GLOBALS
  • You can declare a static variable, are they exists only in a local page scope, but it does not lose its value when program execution leaves this scope

example

Parameters

$argv — Array of arguments passed to a page when it is transcluded

example

Functions

Implemented support for most of the functions PHP (array, Math, Regular expression, String and Variable handling Functions)

examples

Features

Easy to install
No additional libraries
Easy to use
Syntax is similar to PHP
Powerful
Has many functions for work with variables, strings, arrays, regular expressions
Customizable
You can specify the namespaces and functions, which is available for use with this extension
Integrated Debugger
Debug toolbar shows the step by step execution of operations and the values of variables

Download

The extension can be retrieved directly from Git [?]:

  • Browse code
  • Some extensions have tags for stable releases.
  • Each branch is associated with a past MediaWiki release. There is also a "master" branch containing the latest alpha version (might require an alpha version of MediaWiki).

Extract the snapshot and place it in the extensions/Foxway/ directory of your MediaWiki installation.

If you are familiar with Git and have shell access to your server, you can also obtain the extension as follows:

cd extensions/ git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Foxway.git

Installation

  • Download and move the extracted Foxway folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Foxway
  • Add the following code at the bottom of your LocalSettings.php file:
    require_once "$IP/extensions/Foxway/Foxway.php";
    
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.


Configuration parameters

$wgFoxwayFunctions
Contains an array of implemented functions, which is available to users. You can disable any of the functions are at your discretion.
$wgNamespacesWithFoxway
For specifying the namespaces in which is allowed to use the extension Foxway.
$wgFoxway_max_execution_time
The maximum time that is allocated foxway (it is not CPU time, it is real time).
$wgFoxway_max_execution_time_for_scope
The maximum time that is allocated to each foxway scope (each of the included page)

See also