View Source:
Help/HelloWorldPlugin
A simple example plugin. <?plugin HelloWorld salutation="Hello," name="WikiUser" ?> From the source of this page: <verbatim> <?plugin HelloWorld salutation="Hello," name="WikiUser" ?> </verbatim> ----- 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, * either with the predefined HTML classes to create valid XHTML, * or by using templates, which are easier customizable, but generally more a mess to use and easier to create invalid XHTML. <?plugin PhpHighlight /** * A simple demonstration Help:WikiPlugin. * * Usage: * <?plugin HelloWorld?> * <?plugin HelloWorld * salutation="Greetings, " * name=Wikimeister * ? > * <?plugin HelloWorld salutation=Hi ? > * <?plugin HelloWorld name=WabiSabi ? > */ // Constants are defined before the class. if (!defined('THE_END')) define('THE_END', "!"); class Help:WikiPlugin_HelloWorld extends Help:WikiPlugin { // Five required functions in a Help:WikiPlugin. function getName () { return _("HelloWorld"); } function getDescription () { return _("Simple Sample Plugin"); } function getVersion() { return preg_replace("/ Help:n : $]/", '', "\$Revision: 1.1 $"); } // Establish default values for each of this plugin's arguments. function getDefaultArguments() { return array('salutation' => "Hello,", 'name' => "World"); } function run($dbi, $argstr, $request) { extract($this->getArgs($argstr, $request)); // Any text that is returned will not be further transformed, // so use html where necessary. $html = HTML::tt(fmt('%s: %s', $salutation, WikiLink($name, 'auto')), THE_END); return $html; } }; ?> ------------- PhpWikiDocumentation Help:WikiPlugin
KcprAlumni
HomePage
How to use this Wiki
Adding Pages
List all Categories
Main Categories
CategoryWikiPlugin
CategoryActionPage
Search
Toolbox
Recent Changes
Recent New Pages
What links here
All pages
Recent Changes
RecentChanges
HomePage
Favorite Categories
InterWiki
(14)
InterWiki
(14)
View Page
View Source
History
Diff
Sign In