Product SiteDocumentation Site

Chapter 4. Plugin System

4.1. General Concepts
4.2. Building a Plugin
4.2.1. Plugin Structure
4.2.2. Properties
4.2.3. Pages and Files
4.2.4. Events
4.2.5. Configuration
4.2.6. Language and Localization
4.3. Example Plugin Source Listing
4.3.1. Example/Example.php
4.3.2. Example/files/foo.css
4.3.3. Example/lang/strings_english.txt
4.3.4. Example/page/config_page.php
4.3.5. Example/pages/config_update.php
4.3.6. Example/page/foo.php
4.4. API Usage

4.1. General Concepts

The plugin system for MantisBT is designed as a lightweight extension to the standard MantisBT API, allowing for simple and flexible addition of new features and customization of core operations. It takes advantage of the new Event System (see Chapter 3, Event System) to offer developers rapid creation and testing of extensions, without the need to modify core files.
Plugins are defined as implementations, or subclasses, of the MantisPlugin class as defined in core/classes/MantisPlugin.php. Each plugin may define information about itself, as well as a list of conflicts and dependencies upon other plugins. There are many methods defined in the MantisPlugin class that may be used as convenient places to define extra behaviors, such as configuration options, event declarations, event hooks, errors, and database schemas. Outside a plugin's core class, there is a standard method of handling language strings, content pages, and files.
At page load, the core MantisBT API will find and process any conforming plugins. Plugins will be checked for minimal information, such as its name, version, and dependencies. Plugins that meet requirements will then be initialized. At this point, MantisBT will interact with the plugins when appropriate.
The plugin system includes a special set of API functions that provide convenience wrappers around the more useful MantisBT API calls, including configuration, language strings, and link generation. This API allows plugins to use core API's in "sandboxed" fashions to aid interoperation with other plugins, and simplification of common functionality.