]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - pgsrc/Help%2FHelloWorldPlugin
major pgsrc restructuring: internal doc into Help/*
[SourceForge/phpwiki.git] / pgsrc / Help%2FHelloWorldPlugin
1 Date: Sun, 4 Jul 2004 01:31:02 -0700
2 Mime-Version: 1.0 (Produced by PhpWiki 1.3.5pre)
3 X-Rcs-Id: $Id: Help%2FHelloWorldPlugin,v 1.1 2005-11-21 22:19:00 rurban Exp $
4 Content-Type: application/x-phpwiki;
5   pagename=Help%2FHelloWorldPlugin;
6   pgsrc_version="2 $Revision: 1.1 $";
7   flags="";
8   markup=2;
9   charset=iso-8859-1
10 Content-Transfer-Encoding: binary
11
12 A simple example plugin.
13
14 <?plugin HelloWorld salutation="Hello," name="WikiUser" ?>
15
16 From the source of this page:
17
18 <verbatim>
19 <?plugin HelloWorld salutation="Hello," name="WikiUser" ?>
20 </verbatim>
21
22 -----
23 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, 
24
25 * either with the predefined HTML classes to create valid XHTML,
26 * or by using templates, which are easier customizable, but generally more a mess to use and easier to create invalid XHTML.
27
28 <?plugin PhpHighlight
29
30 /**
31  * A simple demonstration Help:WikiPlugin.
32  *
33  * Usage:
34  * <?plugin HelloWorld?&gt;
35  * <?plugin HelloWorld
36  *          salutation="Greetings, "
37  *          name=Wikimeister
38  * ? >
39  * <?plugin HelloWorld salutation=Hi ? >
40  * <?plugin HelloWorld name=WabiSabi ? >
41  */
42
43 // Constants are defined before the class.
44 if (!defined('THE_END'))
45     define('THE_END', "!");
46
47 class Help:WikiPlugin_HelloWorld
48 extends Help:WikiPlugin
49 {
50     // Five required functions in a Help:WikiPlugin.
51
52     function getName () {
53         return _("HelloWorld");
54     }
55
56     function getDescription () {
57         return _("Simple Sample Plugin");
58
59     }
60
61     function getVersion() {
62         return preg_replace("/ Help:n : $]/", '',
63                             "\$Revision: 1.1 $");
64     }
65
66     // Establish default values for each of this plugin's arguments.
67     function getDefaultArguments() {
68         return array('salutation' => "Hello,",
69                      'name'       => "World");
70     }
71
72     function run($dbi, $argstr, $request) {
73         extract($this->getArgs($argstr, $request));
74
75         // Any text that is returned will not be further transformed,
76         // so use html where necessary.
77         $html = HTML::tt(fmt('%s: %s', $salutation, WikiLink($name, 'auto')),
78                          THE_END);
79         return $html;
80     }
81 };
82 ?>
83 -------------
84
85 PhpWikiDocumentation Help:WikiPlugin