]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - pgsrc/Help%2FHelloWorldPlugin
Wikicreole syntax for links
[SourceForge/phpwiki.git] / pgsrc / Help%2FHelloWorldPlugin
1 Date: Sat, 24 Jan 2009 20:18:24 +0100
2 Mime-Version: 1.0 (Produced by PhpWiki 1.3.14-20080124)
3 X-Rcs-Id: $Id$
4 Content-Type: application/x-phpwiki;
5   pagename=Help%2FHelloWorldPlugin;
6   flags=PAGE_LOCKED;
7   markup=2;
8   charset=iso-8859-1
9 Content-Transfer-Encoding: binary
10
11 A simple example plugin.
12
13 <?plugin HelloWorld salutation="Hello," name="Wiki User" ?>
14
15 From the source of this page:
16
17 <verbatim>
18 <?plugin HelloWorld salutation="Hello," name="Wiki User" ?>
19 </verbatim>
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 <?plugin PhpHighlight
28
29 /**
30  * A simple demonstration WikiPlugin.
31  *
32  * Usage:
33  * <?plugin HelloWorld?&gt;
34  * <?plugin HelloWorld
35  *          salutation="Greetings, "
36  *          name=Wikimeister
37  * ? >
38  * <?plugin HelloWorld salutation=Hi ? >
39  * <?plugin 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 ----
84 [[PhpWikiDocumentation]] [[CategoryWikiPlugin]]