Diff: Help/HelloWorldPlugin

Differences between current version and predecessor to the previous major change of Help/HelloWorldPlugin.

Other diffs: Previous Revision, Previous Author

Newer page: version 6 Last edited on 17 January 2022 3:00 by harold
Older page: version 5 Last edited on 9 September 2007 0:16 by harold Revert
@@ -1,56 +1,50 @@
 A simple example plugin. 
  
-<?plugin HelloWorld salutation="Hello," name="WikiUser " ?
+<< HelloWorld salutation="Hello," name="Wiki User " >
  
 From the source of this page: 
  
-<verbatim>  
- <?plugin HelloWorld salutation="Hello," name="WikiUser " ? >  
-</verbatim>  
+{{{  
+ <<HelloWorld salutation="Hello," name="Wiki User " > >  
+}}}  
  
-- ----  
-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, 
+----  
+~ 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, dependent 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 
+<< PhpHighlight 
  
 /** 
- * A simple demonstration Help: WikiPlugin. 
+ * A simple demonstration WikiPlugin. 
 
  * Usage: 
- * <?plugin HelloWorld?&gt;  
- * <?plugin HelloWorld 
+ * << HelloWorld> >  
+ * << HelloWorld 
  * salutation="Greetings, " 
  * name=Wikimeister 
- * ? >  
- * <?plugin HelloWorld salutation=Hi ? >  
- * <?plugin HelloWorld name=WabiSabi ?
+ * > >  
+ * << HelloWorld salutation=Hi > >  
+ * << HelloWorld name=WabiSabi >
  */ 
  
 // Constants are defined before the class. 
 if (!defined('THE_END')) 
  define('THE_END', "!"); 
  
-class Help: WikiPlugin_HelloWorld  
-extends Help: WikiPlugin 
+class WikiPlugin_HelloWorld  
+extends WikiPlugin 
 
- // Five required functions in a Help: WikiPlugin. 
+ // Five required functions in a 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() { 
@@ -62,13 +56,15 @@
  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')), 
+ $html = HTML::samp (fmt('%s: %s', $salutation, WikiLink($name, 'auto')), 
  THE_END); 
  return $html; 
 
 }; 
-? >  
--------------  
+>>  
  
-PhpWikiDocumentation Help:WikiPlugin  
+<noinclude>  
+----  
+[[ PhpWikiDocumentation]] [[CategoryWikiPlugin]]  
+</noinclude>  

current version

A simple example plugin.

Hello,, Wiki User!

From the source of this page:

<<HelloWorld salutation="Hello," name="Wiki User" >>

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, dependent 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.
/**
 * A simple demonstration WikiPlugin.
 *
 * Usage:
 * <<HelloWorld> >
 * <<HelloWorld
 *          salutation="Greetings, "
 *          name=Wikimeister
 * > >
 * <<HelloWorld salutation=Hi > >
 * <<HelloWorld name=WabiSabi > >
 */

// Constants are defined before the class.
if (!defined('THE_END'))
    
define('THE_END'"!");

class 
WikiPlugin_HelloWorld
extends WikiPlugin
{
    
// Five required functions in a WikiPlugin.

    
function getName () {
        return 
_("HelloWorld");
    }

    function 
getDescription () {
        return 
_("Simple Sample Plugin");
    }

    
// 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::samp(fmt('%s: %s'$salutationWikiLink($name'auto')),
                         
THE_END);
        return 
$html;
    }
};