Zomp Development. Here's The Action.


Zomplog

Information for plugin-developers

The best way to learn how to make a plugin yourself, is to look how other plugins are setup. I tried to make the plugin-architecture as simple and straightforward as possible, so it should be fairly easy.

To explain how a plugin works, it's easiest to describe through an example. Each version of Zomplog comes with a plugin called "spamwords", which is developed by eazys and can be found in the plugins-folder.

The folder contains a few files: an admin.php file - this is the user interface of your plugin
an install.php file - this file installs the necessary tables
a file called plugin.php - this is the main code of the plugin

Naming conventions

A plugin has a few naming conventions, which should be adhered:

* the user interface for your plugin should be called admin.php

* The installer file should be called install.php

* The plugin itself (which contains the hooks) should be called plugin.php

Plug into Zomplog through the use of hooks

The Zomplog plugin-system uses hooks to plug into the main architecture of Zomplog.

A hook usually looks like this:

// insert plugin hook $hook = "spamwordslist"; // name of hook include("admin/loadplugins.php");

The loadplugins.php file contains a list of available plugins, and the script will browse through plugin.php in the folder of your plugin, to see if the plugin calls a hook.

Calling a hook is easy:

in plugin.php add the following lines:

if ($hook == "name_of_hook"){ // your code }

So as soon as a hook is called by a plugin, you can insert your own code into that hook in the system.

For a list of current hooks, see ListOfPluginHooks

Upgradeable plugins

When your plugin uses tables (for settings or data), sooner or later you may want to change their structure.

When you want to change from an older plugin version to a newer, with changed table structure, the old settings/data must be saved, the old table(s) must be removed, new table(s) must be set up and the old data must be put into the apropriate fields of the new table(s).
Also the record for your plugin in the zomplog_plugins table must be removed, in order to install the new version of your plugin via the plugins-screen.
That means going straight into de database, which is tricky and certainly not according to the Spirit of Zomplog (everything should be easy, remember?).

Now there is a template which makes it possible for your plugin to do all these things automatically.
Download it from http://www.frankma.nl/download/upgradeinstruction.zip.
In the current release of this template the settings of the plugin will be saved en recycled. The data will be left alone. In order to upgrade a data table associated with your plugin, you'll have to write extra coding yourself.
In a future release the data table may be updated too.