1 Date: Wed, 19 May 2010 10:52:28 +0000
2 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415)
4 Content-Type: application/x-phpwiki;
5 pagename=Help%2FHelloWorldPlugin;
6 flags=PAGE_LOCKED%2CEXTERNAL_PAGE;
9 Content-Transfer-Encoding: binary
11 A simple example plugin.
13 <<HelloWorld salutation="Hello," name="Wiki User" >>
15 From the source of this page:
18 <<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.
35 * salutation="Greetings, "
38 * <<HelloWorld salutation=Hi > >
39 * <<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 // Establish default values for each of this plugin's arguments.
61 function getDefaultArguments() {
62 return array('salutation' => "Hello,",
66 function run($dbi, $argstr, $request) {
67 extract($this->getArgs($argstr, $request));
69 // Any text that is returned will not be further transformed,
70 // so use html where necessary.
71 $html = HTML::tt(fmt('%s: %s', $salutation, WikiLink($name, 'auto')),
80 [[PhpWikiDocumentation]] [[CategoryWikiPlugin]]