This file describes how to write a basic plug-in for WIKINDX.
Example:/**************************** **** Plug-in module example **** **** index.php **** *****************************/ class example_MODULE { // constructor function example_MODULE($db, $vars, $menuInit = FALSE) { if($menuInit) { $this->menus = array( "wikindx" => array("Module" => "example"), "help" => array("Module Help" => "helpMe"), ); return; // Need do nothing more as this is simply menu initialisation. } $this->db = $db; $this->vars = $vars; // Load the template module include_once("core/template/TEMPLATE.php"); $this->template = new TEMPLATE('content'); } function example() { $title = "Module Example"; $this->template->setVar('heading', $title); if(array_key_exists('method', $this->vars)) $string = "The method is " . $this->vars['method'] . '.'; else $string = "No method was input."; $this->template->setVar('body', $string); return $this->template->process(); } function helpMe() { include_once("core/html/MISC.php"); $title = "Module HELP"; $this->template->setVar('heading', $title); $link = MISC::a("link", "this module", htmlentities("index.php?action=example_example&method=helpMePlease!")); $string = "No help here, try $link"; $this->template->setVar('body', $string); return $this->template->process(); } }
The constructor parameters $db and $vars are the database object (see the SQL class) and an array of all input values from the web browser form or query string. These are set to FALSE if the constructor is initialised from the MENU system in which case $menuInit will be TRUE.
To get your plug-ins working, a few conditions are required:
So, in the above example, an item Module is inserted in the wikindx menu with the action example and an item Module Help is inserted in the help menu with the action helpMe. In your class, there must exist the methods example() and helpMe().
You must use the templating system that WIKINDX uses and return the template string to the calling process as shown in the above example. Furthermore, in the interests of compatibility and future WIKINDX upgrades, you should use the WIKINDX functions where possible and as explained in the rest of this documentation.
If you write a module that you think may be of interest to other WIKINDX users, please consider releasing it under the GPL at Sourceforge -- contact sirfragalot@users.sourceforge.net for details on how to do this.