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