1 Date: Fri, 10 Sep 2010 13:46:13 +0000
2 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0)
3 Content-Type: application/x-phpwiki;
4 pagename=Help%2FHelloWorldPlugin;
5 flags=PAGE_LOCKED%2CEXTERNAL_PAGE;
7 Content-Transfer-Encoding: binary
9 A simple example plugin.
11 <<HelloWorld salutation="Hello," name="Wiki User" >>
13 From the source of this page:
16 <<HelloWorld salutation="Hello," name="Wiki User" >>
20 ~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,
22 * either with the predefined HTML classes to create valid XHTML,
23 * or by using templates, which are easier customizable, but generally more a mess to use and easier to create invalid XHTML.
28 * A simple demonstration WikiPlugin.
33 * salutation="Greetings, "
36 * <<HelloWorld salutation=Hi > >
37 * <<HelloWorld name=WabiSabi > >
40 // Constants are defined before the class.
41 if (!defined('THE_END'))
42 define('THE_END', "!");
44 class WikiPlugin_HelloWorld
47 // Five required functions in a WikiPlugin.
50 return _("HelloWorld");
53 function getDescription () {
54 return _("Simple Sample Plugin");
58 // Establish default values for each of this plugin's arguments.
59 function getDefaultArguments() {
60 return array('salutation' => "Hello,",
64 function run($dbi, $argstr, $request) {
65 extract($this->getArgs($argstr, $request));
67 // Any text that is returned will not be further transformed,
68 // so use html where necessary.
69 $html = HTML::tt(fmt('%s: %s', $salutation, WikiLink($name, 'auto')),
78 [[PhpWikiDocumentation]] [[CategoryWikiPlugin]]