Warning : this page has been slighly updated but better information is available in the doxygen documentation. See page Plugin howto.
How to make a plugin
You first have to decide which kind of plugin you want to create.
- Is it an admin plugin ?
- Is it a site wide plugin ?
Admin plugin
Admin plugin are located inside admin/tools.
To create a new plugin, simply
- create a new directory inside admin/tools. For example, create admin/tools/my_plugin
- create a file desc.conf inside admin/tools/my_plugin
- create a file index.php inside admin/tools/my_plugin
desc.conf file
This file has the same syntax as the lang file located into i18n directories.
You must have 4 different entries :
- Name : the name of the plugin
- Author : who is the author
- Description : a description of the plugin
- Icon : which file to use in the plugin directory as an icon
Example :
[Name] UTF8 conversion tool [Author] David Jobet [Description] A tool to convert your wiki to UTF8 [Icon] icon.png
index.php file
This is the code that will get called when the plugin is activated. Code it as if you were directly called.
You can of course include wiclear classes if they are not already included.
Take a look at utf8conversion plugin given in the main distribution.
Site wide plugin
As admin plugins, you should put them inside a tools directory .
To register, the plugin simply has to declare its callback functions using the PluginManager. There are 3 different kinds of callback available :
- contentBoxHandle : called to output something in the web page. Signature void -> string.
- userActionHandle : called to handle an incoming request before anything is outputed in the web page. Signature void->void.
- browserTitlePageHandl : called to customize the title of the browser when handling a contentBoxHandle page
Example : (file tools/trackback/hooks.inc.php)
global $pluginManager;
$pluginManager->addContentBoxHandle("trackback_add_ping", "addPing");
$pluginManager->addUserActionHandle("trackback_discover", "onTrackbackDiscover");
$pluginManager->addUserActionHandle("trackback_do_ping", "onTrackbackPing");
$pluginManager->addUserActionHandle("trackback_del", "onTrackbackDelete");
$pluginManager->addBrowserTitlePageHandle("trackback_add_ping", "browserAddTrackback");
Which means that when wiclear will get an incoming request, it will decode the "mode" _GET variable and use the registered function defined in these two map to handle the request.


No comments yet