A simple example plugin.
From the source of this page:
<?plugin HelloWorld salutation="Hello," name="WikiUser" ?>
PhpWiki's plugin architecture allows you to add custom page elements to your wiki. All you have to do is extend (subclass) the WikiPlugin class and craft your output via the run() method.
/**
* A simple demonstration WikiPlugin.
*
* Usage:
* <?plugin HelloWorld?>
* <?plugin HelloWorld
* salutation="Greetings, "
* name=Wikimeister
* ? >
* <?plugin HelloWorld salutation=Hi ? >
* <?plugin HelloWorld name=WabiSabi ? >
*/
// Constants are defined before the class.
if (!defined('THE_END'))
define('THE_END', "!");
class WikiPlugin_HelloWorld
extends WikiPlugin
{
// Five required functions in a WikiPlugin.
function getName () {
return _("HelloWorld");
}
function getDescription () {
return _("Simple Sample Plugin");
}
function getVersion() {
return preg_replace("/[Revision: $]/", '',
"\$Revision: 1.1 $");
}
// Establish default values for each of this plugin's arguments.
function getDefaultArguments() {
return array('salutation' => "Hello,",
'name' => "World");
}
function run($dbi, $argstr, $request) {
extract($this->getArgs($argstr, $request));
// Any text that is returned will not be further transformed,
// so use html where necessary.
$html = HTML::tt(fmt('%s: %s', $salutation, WikiLink($name, 'auto')),
THE_END);
return $html;
}
};
Page Execution took real: 4.170, user: 1.490, sys: 0.250 seconds |