1 Date: Sat, 24 Jan 2009 20:18:24 +0100
2 Mime-Version: 1.0 (Produced by PhpWiki 1.3.14-20080124)
4 Content-Type: application/x-phpwiki;
5 pagename=Help%2FHelloWorldPlugin;
9 Content-Transfer-Encoding: binary
11 A simple example plugin.
13 <?plugin HelloWorld salutation="Hello," name="Wiki User" ?>
15 From the source of this page:
18 <?plugin HelloWorld salutation="Hello," name="Wiki User" ?>
22 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 create your output via the run() method, dependend on the Wiki- or Request arguments,
24 * either with the predefined HTML classes to create valid XHTML,
25 * or by using templates, which are easier customizable, but generally more a mess to use and easier to create invalid XHTML.
30 * A simple demonstration WikiPlugin.
33 * <?plugin HelloWorld?>
35 * salutation="Greetings, "
38 * <?plugin HelloWorld salutation=Hi ? >
39 * <?plugin HelloWorld name=WabiSabi ? >
42 // Constants are defined before the class.
43 if (!defined('THE_END'))
44 define('THE_END', "!");
46 class WikiPlugin_HelloWorld
49 // Five required functions in a WikiPlugin.
52 return _("HelloWorld");
55 function getDescription () {
56 return _("Simple Sample Plugin");
60 function getVersion() {
61 return preg_replace("/[Revision: $]/", '',
65 // Establish default values for each of this plugin's arguments.
66 function getDefaultArguments() {
67 return array('salutation' => "Hello,",
71 function run($dbi, $argstr, $request) {
72 extract($this->getArgs($argstr, $request));
74 // Any text that is returned will not be further transformed,
75 // so use html where necessary.
76 $html = HTML::tt(fmt('%s: %s', $salutation, WikiLink($name, 'auto')),
84 [[PhpWikiDocumentation]] [[CategoryWikiPlugin]]