phpSitemapNG plugin functions

This page describes the API of the phpSitemapNG plugin class
The Plugin class is a php class without implementation - also something like an interface. :)
All plugins have to extend this class - but they shouldn't do this directly but extend one of the main plugin classes: Input, Output, Compute.
These classes don't add new functions but are necessary to distinguish between the main plugin types.

The plugin class has the following functions:

UML description of the phpSitemapNG Plugin class

  • Plugin() - is invoked when an object of the class is created
  • getInfo() - returns an array with the following content:
    • name: name of the plugin
    • short_description: a short description (max. 100 chars) that will be displayed at the overview page
    • long_description: a longer description (not used at the moment)
    • url: the url where the plugin can be downloaded and more information are available
    • version: the current version of this plugin
    • author: name or organisation who created this plugin
  • getSetupHtml() - returns a string that contains formular information. You can add input and textarea fields there, BUT you have to name them this way:
    PSNG_PLUGIN_INIT_SETTINGS['name_of_setting'] where PSNG_PLUGIN_INIT_SETTINGS is a global constant that will be set by the phpSitemapNG program and name_of_setting is the internal name of this settings value inside of the plugin. But make shure that the value of the constant can be interpreted by the PHP  engine - you shouldn't encode this with ' ' or " ". The code of the sample plugin does this correct.
  • init($setupInformation) - where $setupInformation is an array that contains the following entries
    • PSNG_PLUGIN_INIT_SETTINGS: this contains the formular input of the user
    • PSNG_PLUGIN_INIT_STORAGE: this contains a reference to the storage object where you have to add your urls to. More details will follow at the example plugin page.
    This method will always be invoked after an instance of this class has been created. You should intitialize your internal variables here.
  •  run() - in this method the real computation is done (add urls for an input plugin, change/update values for compute plugins, generate files and other output for output plugins
  • tearDown() - this will be invoked when phpSitemapNG is shutting down and/or after the execution of the plugin.
Next step: create your first phpSitemapNG plugin

Google Adsense