Plugin Hola Mundo


Un ejemplo simple de plugin.

Hola,: WikiUser!

El fuente de esta página es:

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

La arquitectura de plugins de PhpWiki le permite añadir elementos personalizados a las páginas de su wiki. Todo lo que tiene que hacer es extender (subclass) la clase WikiPlugin y mostrar el resultado con la función run().

<?php
/**
 * A simple demonstration 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 
WikiPlugin_HelloWorld
extends WikiPlugin
{
    
// Five required functions in a WikiPlugin.

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

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

    }

    function 
getVersion() {
        return 
preg_replace("/[Revision: $]/"'',
                            
"\$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;
    }
};

lib/DbSession/SQL.php:97: Notice: Only variables should be assigned by reference

lib/CachedMarkup.php (In template 'browse' < 'body' < 'html'):491: Notice: Only variables should be assigned by reference

lib/CachedMarkup.php (In template 'body' < 'html'):491: Notice: Only variables should be assigned by reference