]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - pgsrc/Help%2FHelloWorldPlugin
Add size and mode arguments
[SourceForge/phpwiki.git] / pgsrc / Help%2FHelloWorldPlugin
1 Date: Fri, 10 Sep 2010 13:46:13 +0000
2 Mime-Version: 1.0 (Produced by PhpWiki 1.4.0RC1)
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     // Establish default values for each of this plugin's arguments.
61     function getDefaultArguments() {
62         return array('salutation' => "Hello,",
63                      'name'       => "World");
64     }
65
66     function run($dbi, $argstr, $request) {
67         extract($this->getArgs($argstr, $request));
68
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')),
72                          THE_END);
73         return $html;
74     }
75 };
76 >>
77
78 <noinclude>
79 ----
80 [[PhpWikiDocumentation]] [[CategoryWikiPlugin]]
81 </noinclude>