From: Carsten K. <car...@us...> - 2002-01-07 04:14:23
|
Update of /cvsroot/phpwiki/phpwiki/lib/plugin In directory usw-pr-cvs1:/tmp/cvs-serv10563 Modified Files: HelloWorld.php Log Message: minor update to sample plugin: added a few examples, comments and notes, spiffed up the output. Index: HelloWorld.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/plugin/HelloWorld.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** HelloWorld.php 2001/12/16 18:33:25 1.4 --- HelloWorld.php 2002/01/07 04:14:20 1.5 *************** *** 3,10 **** --- 3,23 ---- /** * A simple demonstration 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 WikiPlugin_HelloWorld extends WikiPlugin { + // Four required functions in a WikiPlugin. + function getName () { return _("HelloWorld"); *************** *** 13,18 **** function getDescription () { return _("Simple Sample Plugin"); } ! function getDefaultArguments() { return array('salutation' => "Hello,", --- 26,32 ---- function getDescription () { return _("Simple Sample Plugin"); + } ! // Establish default values for each of this plugin's arguments. function getDefaultArguments() { return array('salutation' => "Hello,", *************** *** 22,27 **** function run($dbi, $argstr, $request) { extract($this->getArgs($argstr, $request)); ! ! return sprintf("<tt>%s %s</tt>", $salutation, $name); } }; --- 36,45 ---- 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 = Element('tt', __sprintf("%s %s" .THE_END, $salutation, ! do_transform($name, 'LinkTransform'))); ! return $html; } }; |