Plugin
Plugin
MyPlugin

Abstract class for plugins.  Plugins can inherit from this class to get default configuration functionality.  They can also override the configuration methods to do custom configuration.  Inherits: LnBlogObject

Properties
plugin_desc

A short description of the plugin.

plugin_version

The version number of the plugin.  This should be in "1.2.3" format.

member_list

An associative array of arrays, with the form member=>settings, where member is the name of a member variable of your class and settings is an associative array of the configuration data for that member.  This array is used by the default configuration show/save methods.

The following is a list of possible configuration settings for a member variable.  If a setting is not given for a particular control, then the default value will be used.

description

A descriptive string for the variable.  This will be displayed on the configuration screen when the user modifies the setting for this variable.  This element is required.

control

The type of control used to display this variable on the configuration screen.  For the most part, these map directly to HTML input element types.  The currently recognized values are "text", "checkbox", "radio", "select", "file".  The default is "text".

default

The default value for this variable.  This value will be used if the user does not specify a setting.  Also, if the user modifies other settings, no configuration entry will be saved for this variable if the value is still the default.  This is important because of pre-blog overriding.  The default is the empty string.

options

An array of the form value=>description, where the value keys are control values and the descriptions describe each choice for the user.  These are used only for radio button and selection box controls, with each array element representing an option for the user to select .

Functions
addOption
public function addOption(
$name,
$description,
$default,
$control"text",
$optionsfalse
)

A short-hand way to add configuration options.  Adds the necessary values to member_list all in one shot.

Parameters
name

The name of the option.

description

A short description for the user to see.

default

The default value.

control

Optional control to use.  The default is "text".

options

An array of options for radio and select controls.

addNoEventOption
public function addNoEventOption()

Add an option to turn off event output handlers.

registerNoEventOutputHandler
public function registerNoEventOutputHandler(
$target,
$function_name
)

Register a handler to do output in the case that "no event" is turned off.

registerNoEventOutputCompleteHandler
public function registerNoEventOutputCompleteHandler(
$target,
$function_name
)

Register a handler to do output in the case that "no event" is turned off.

showConfig
public function showConfig(
$page,
$csrf_token
)

Displays the plugin configuration in an HTML form.  You must make sure to initialize the member_list for this to work.

Parameters
page

A reference to the page which will display the configuration.  This is useful for configs that need to add linked-in stylesheets or external Javascript files.

Returns

Optionally returns the form markup as a string.

updateConfig
public function updateConfig()

Retrieves configuration data for the plugin from an HTTP POST and stores the data in the relevant files.

Note that this also handles uploaded files.  If run from a blog, the file is uploaded to the blog root.  Otherwise, it goes to the userdata directory.

Returns

True on success, false on failure.

getConfig
public function getConfig()

Reads the configuration data for the plugin from a file and stores it in class variables.