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;
8 Content-Transfer-Encoding: binary
10 A simple example plugin.
12 <<HelloWorld salutation="Hello," name="Wiki User" >>
14 From the source of this page:
17 <<HelloWorld salutation="Hello," name="Wiki User" >>
21 ~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,
23 * either with the predefined HTML classes to create valid XHTML,
24 * or by using templates, which are easier customizable, but generally more a mess to use and easier to create invalid XHTML.
29 * A simple demonstration WikiPlugin.
34 * salutation="Greetings, "
37 * <<HelloWorld salutation=Hi > >
38 * <<HelloWorld name=WabiSabi > >
41 // Constants are defined before the class.
42 if (!defined('THE_END'))
43 define('THE_END', "!");
45 class WikiPlugin_HelloWorld
48 // Five required functions in a WikiPlugin.
51 return _("HelloWorld");
54 function getDescription () {
55 return _("Simple Sample Plugin");
59 // Establish default values for each of this plugin's arguments.
60 function getDefaultArguments() {
61 return array('salutation' => "Hello,",
65 function run($dbi, $argstr, $request) {
66 extract($this->getArgs($argstr, $request));
68 // Any text that is returned will not be further transformed,
69 // so use html where necessary.
70 $html = HTML::tt(fmt('%s: %s', $salutation, WikiLink($name, 'auto')),
79 [[PhpWikiDocumentation]] [[CategoryWikiPlugin]]