]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - pgsrc/Help%2FHelloWorldPlugin
Harmonize documentation
[SourceForge/phpwiki.git] / pgsrc / Help%2FHelloWorldPlugin
1 Date: Wed, 28 May 2008 19:06:42 +0200
2 Mime-Version: 1.0 (Produced by PhpWiki 1.3.14-20080124)
3 Content-Type: application/x-phpwiki;
4   pagename=Help%2FHelloWorldPlugin;
5   flags="";
6   markup=2;
7   charset=iso-8859-1
8 Content-Transfer-Encoding: binary
9
10 A simple example plugin.
11
12 <?plugin HelloWorld salutation="Hello," name="WikiUser" ?>
13
14 From the source of this page:
15
16 <verbatim>
17 <?plugin HelloWorld salutation="Hello," name="WikiUser" ?>
18 </verbatim>
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 <?plugin PhpHighlight
27
28 /**
29  * A simple demonstration WikiPlugin.
30  *
31  * Usage:
32  * <?plugin HelloWorld?&gt;
33  * <?plugin HelloWorld
34  *          salutation="Greetings, "
35  *          name=Wikimeister
36  * ? >
37  * <?plugin HelloWorld salutation=Hi ? >
38  * <?plugin 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     function getVersion() {
60         return preg_replace("/ Help:n : $]/", '',
61                             "\$Revision: 1.2 $");
62     }
63
64     // Establish default values for each of this plugin's arguments.
65     function getDefaultArguments() {
66         return array('salutation' => "Hello,",
67                      'name'       => "World");
68     }
69
70     function run($dbi, $argstr, $request) {
71         extract($this->getArgs($argstr, $request));
72
73         // Any text that is returned will not be further transformed,
74         // so use html where necessary.
75         $html = HTML::tt(fmt('%s: %s', $salutation, WikiLink($name, 'auto')),
76                          THE_END);
77         return $html;
78     }
79 };
80 ?>
81 -------------
82
83 [PhpWikiDocumentation] [WikiPlugin|Help:WikiPlugin]