Diff: Help/HelloWorldPlugin

Note: You are viewing an old revision of this page. View the current version.

Differences between version 3 and previous revision of Help/HelloWorldPlugin.

Other diffs: Previous Major Revision, Previous Author

Newer page: version 3 Last edited on 9 September 2007 0:16 by harold Revert
Older page: version 2 Last edited on 22 May 2014 3:01 by harold Revert
@@ -1,51 +1,56 @@
 A simple example plugin. 
  
-<< HelloWorld salutation="Hello," name="Wiki User " >
+<?plugin HelloWorld salutation="Hello," name="WikiUser " ?
  
 From the source of this page: 
  
-{{{  
- <<HelloWorld salutation="Hello," name="Wiki User " > >  
-}}}  
+<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, 
+- ----  
+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. 
  
-<< PhpHighlight 
+<?plugin PhpHighlight 
  
 /** 
- * A simple demonstration WikiPlugin. 
+ * A simple demonstration Help: WikiPlugin. 
 
  * Usage: 
- * << HelloWorld> >  
- * << HelloWorld 
+ * <?plugin HelloWorld?&gt;  
+ * <?plugin HelloWorld 
  * salutation="Greetings, " 
  * name=Wikimeister 
- * > >  
- * << HelloWorld salutation=Hi > >  
- * << HelloWorld name=WabiSabi >
+ * ? >  
+ * <?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 
+class Help: WikiPlugin_HelloWorld  
+extends Help: WikiPlugin 
 
- // Five required functions in a 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() { 
@@ -62,10 +67,8 @@
  THE_END); 
  return $html; 
 
 }; 
->>  
+? >  
+-------------  
  
-<noinclude>  
-----  
-[[ PhpWikiDocumentation]] [[CategoryWikiPlugin]]  
-</noinclude>  
+PhpWikiDocumentation Help:WikiPlugin  

version 3

A simple example plugin.

Hello,, WikiUser!

From the source of this page:

<?plugin HelloWorld salutation="Hello," name="WikiUser" ?>

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.
/**
 * A simple demonstration Help:WikiPlugin.
 *
 * Usage:
 * <?plugin HelloWorld?&gt;
 * <?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'$salutationWikiLink($name'auto')),
                         
THE_END);
        return 
$html;
    }
};

PhpWikiDocumentation Help:WikiPlugin