User Tools

  • Logged in as: anonymous (anonymous)
  • Log Out

Site Tools


mantisbt:dynamic_plugin_requirements

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
mantisbt:dynamic_plugin_requirements [2007/10/27 13:45] jreesemantisbt:dynamic_plugin_requirements [2008/01/03 16:49] DGtlRift
Line 1: Line 1:
-====== Dynamic Plugin Requirements ====== 
  
-**Author**: John Reese 
- 
-**Status**: In progress 
- 
- 
- 
-===== Introduction ===== 
- 
-This is a proposal for a very lightweight method of including a plugin/hook system for Mantis.  It should be able to handle not only minor enhancements for areas such as outputting text, but adding new pages, menu items, and entire features to the application.  It should be very simple, but very powerful. 
- 
-This feature is meant as a counter point to the [[addson_requirements|Add-Ons Support Requirements]] by offering a much simpler and easier to use plugin system without sacrificing flexibility or power. 
- 
- 
- 
- 
-===== Proposed Approach ===== 
- 
-Plugins will be very simple packages, extracted into the Mantis/plugins directory and enabled through the Management interface.  There will be a simple event system that will handle hooking functionality in various forms, including data processing, list retrieval, and output.  Events will be called at various points in the normal flow of Mantis, and the plugin API will handle calling any necessary plugin functions. 
- 
-When a plugin is loaded at runtime, it will register basic information about itself to Mantis, including its name, author, description, version, and dependencies (Mantis version, other plugins).  It will then register a callback function for each event that it would like to handle.  When an event occurs, any plugin callbacks will be called in the order they are registered.  The event type will determine how callback parameters and return values are processed.   
- 
-New content pages will be added by creating scripts in a special directory of the plugin, and links to that page will be created with an API call to simplify the task.  Plugin pages will not need to load the Mantis core, but will need to call the html_page_top() or html_page_bottom() functions as necessary. 
- 
-==== Language Files ==== 
- 
-To simplify the usage of language files, plugins will simply need to supply a ''lang/'' directory with appropriate strings files.  The language API will search for strings in the main language files first, and only load the current plugin's language files if a needed string is not found elsewhere.   
- 
-==== Database Schema ==== 
- 
-There will need to be a simple and unified method for plugins to maintain their database schema, otherwise plugins will get released without proper upgrade paths for users.  The plugin manager should provide an automated schema upgrade mechanism that works the same as the Mantis upgrade mechanism.  For performance reasons, the schema for plugins should only be checked when the plugin management screens are accessed, where it should notify the user of the need to upgrade the schema. 
- 
-==== Event Types ====  
- 
-These should be the basic event types, from which all (or most) events can be formed. 
- 
-** Execute event ** 
-  * Simplest type of event. 
-  * No parameters 
-  * No return value 
-  * Includes EVENT_PLUGIN_INIT 
-** Output event ** 
-  * Event giving plugins a chance to output content.  Strings returned from callback are cleaned for display and appended back to back with a separator string. 
-  * Parameters: 
-    * separator string to output between plugins 
-  * No return value 
-  * Includes EVENT_PAGE_TOP and EVENT_PAGE_BOTTOM 
-** Process event ** 
-  * Event allowing a plugin to process an input string and return a modified version to the originator. 
-  * Parameters: 
-    * Input string 
-  * Return value: 
-    * Modified input string 
-  * Includes EVENT_TEXT_GENERAL for bug links, bugnote links, wiki links, and other markup options. 
-** Arbitrary event ** 
-  * Can be used for everything else. 
-  * Parameters 
-    * Array of key/value pairs as direct parameters to the callback 
-  * Return value 
-    * Array of key/value pairs directly from the callback 
- 
- 
- 
-===== Database Changes ===== 
- 
-  * Create table ''mantis_plugin_table'' 
-    * **basename varchar(40)** primary key, the directory name for the plugin 
-    * **enabled boolean** index 
- 
- 
-===== Configuration Changes ===== 
- 
-  * ''plugins_enabled'' (default ON) 
-  * ''manage_plugin_threshold'' (default ADMINISTRATOR) 
- 
-===== Sample Event Flows ===== 
- 
-==== Plugin Execution ==== 
- 
-This flow of action should occur during normal Mantis execution.  It should be possible to bypass this by either disabling plugins from ''config_inc.php'' or by a page declaring a special flag before including ''core.php''. 
- 
-  * List of enabled plugins is retrieved from database. 
-  * For each enabled plugin: 
-    * Include ''plugins/<basename>/register.php'' 
-    * Call ''plugin_callback_<basename>_register()'' function 
-  * Send EVENT_PLUGIN_INIT signal 
-  * Execute normal page contents with events as necessary 
- 
-==== Event Execution ==== 
- 
-This flow of action should occur whenever an event is signaled, assuming plugins are enabled. 
- 
-  * Prepare parameters from event origin 
-  * For each registered callback: 
-    * Include ''plugins/<basename>/events.php'' 
-    * Call ''plugin_event_<basename>_<function_name>()'' 
-    * Alter parameters for next callback if necessary 
-  * Output content if necessary 
-  * Return callback values to event originator if necessary 
- 
- 
- 
- 
-===== Plugin Example ===== 
- 
-Skeleton content for a valid sample plugin. 
- 
-**Directory Structure** 
-<code> 
-mantis/ 
-  plugins/ 
-    sample/ 
-      register.php 
-      events.php 
-</code> 
- 
-**''sample/register.php''** 
-<code> 
-<?php 
- 
-/** 
- * Return plugin details to the API. 
- * @return array Plugin details 
- */ 
-function plugin_callback_sample_info() { 
-  return array( 
-    'name' => 'Sample', 
-    'description' => 'Very minimal plugin with no real effect.', 
-    'version' => '0.1', 
-    'depends' => array(), 
-    'author' => 'John Reese', 
-    'url' => 'http://leetcode.net', 
-  ); 
-} 
- 
-/** 
- * Register callback methods for any events necessary. 
- */ 
-function plugin_callback_sample_register() { 
-  plugin_register( 'EVENT_PLUGIN_INIT', 'header' ); 
-} 
-</code> 
- 
-**''sample/events.php''** 
-<code> 
-<?php 
- 
-/** 
- * Handle the EVENT_PLUGIN_INIT callback. 
- */ 
-function plugin_event_sample_header() { 
-  header( 'X-Mantis: This Mantis has super cow powers.' ); 
-} 
-</code> 
- 
-===== Feedback =====  
- 
-Please hold your feedback until this page is completed. 
mantisbt/dynamic_plugin_requirements.txt · Last modified: 2008/10/29 04:25 by 127.0.0.1

Driven by DokuWiki