]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - pgsrc/Help%2FHelloWorldPlugin
Wikicreole syntax
[SourceForge/phpwiki.git] / pgsrc / Help%2FHelloWorldPlugin
1 Date: Thu, 15 Apr 2010 16:32:58 +0000
2 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC-20100415)
3 X-Rcs-Id: $Id$
4 Content-Type: application/x-phpwiki;
5   pagename=Help%2FHelloWorldPlugin;
6   flags=PAGE_LOCKED%2CEXTERNAL_PAGE;
7   markup=2;
8   charset=UTF-8
9 Content-Transfer-Encoding: binary
10
11 A simple example plugin.
12
13 <<HelloWorld salutation="Hello," name="Wiki User" >>
14
15 From the source of this page:
16
17 {{{
18 <<HelloWorld salutation="Hello," name="Wiki User" >>
19 }}}
20
21 ----
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,
23
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.
26
27 <<PhpHighlight
28
29 /**
30  * A simple demonstration WikiPlugin.
31  *
32  * Usage:
33  * <<HelloWorld> >
34  * <<HelloWorld
35  *          salutation="Greetings, "
36  *          name=Wikimeister
37  * > >
38  * <<HelloWorld salutation=Hi > >
39  * <<HelloWorld name=WabiSabi > >
40  */
41
42 // Constants are defined before the class.
43 if (!defined('THE_END'))
44     define('THE_END', "!");
45
46 class WikiPlugin_HelloWorld
47 extends WikiPlugin
48 {
49     // Five required functions in a WikiPlugin.
50
51     function getName () {
52         return _("HelloWorld");
53     }
54
55     function getDescription () {
56         return _("Simple Sample Plugin");
57
58     }
59
60     function getVersion() {
61         return preg_replace("/[Revision: $]/", '',
62                             "\$Revision: 1.5 $");
63     }
64
65     // Establish default values for each of this plugin's arguments.
66     function getDefaultArguments() {
67         return array('salutation' => "Hello,",
68                      'name'       => "World");
69     }
70
71     function run($dbi, $argstr, $request) {
72         extract($this->getArgs($argstr, $request));
73
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')),
77                          THE_END);
78         return $html;
79     }
80 };
81 >>
82
83 <noinclude>
84 ----
85 [[PhpWikiDocumentation]] [[CategoryWikiPlugin]]
86 </noinclude>