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 revision Previous revision
Next revision
Previous revision
mantisbt:dynamic_plugin_requirements [2007/10/29 00:20]
jreese
mantisbt:dynamic_plugin_requirements [2008/10/29 04:25] (current)
Line 26: Line 26:
  
 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. 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 ====  ==== Event Types ==== 
Line 42: Line 43:
   * No return value   * No return value
   * Includes EVENT_PAGE_TOP and EVENT_PAGE_BOTTOM   * Includes EVENT_PAGE_TOP and EVENT_PAGE_BOTTOM
-** Process ​event **+** Chain event **
   * Event allowing a plugin to process an input string and return a modified version to the originator.   * Event allowing a plugin to process an input string and return a modified version to the originator.
   * Parameters:   * Parameters:
Line 81: Line 82:
   * Send EVENT_PLUGIN_INIT signal   * Send EVENT_PLUGIN_INIT signal
   * Execute normal page contents with events as necessary   * Execute normal page contents with events as necessary
 +
  
 ==== Event Execution ==== ==== Event Execution ====
Line 89: Line 91:
   * For each registered callback:   * For each registered callback:
     * Include ''​plugins/<​basename>/​events.php''​     * Include ''​plugins/<​basename>/​events.php''​
-    * Call ''​plugin_event_callback_<​basename>​_<​function_name>​()''​+    * Call ''​plugin_event_<​basename>​_<​function_name>​()''​
     * Alter parameters for next callback if necessary     * Alter parameters for next callback if necessary
   * Output content if necessary   * Output content if necessary
   * Return callback values to event originator if necessary   * Return callback values to event originator if necessary
 +
 +
  
 ===== Plugin Hierarchy ===== ===== Plugin Hierarchy =====
Line 112: Line 116:
   * ''​register.php''​ is the only file required for a plugin to be valid. ​ It must contain two callbacks for plugin information and event registrations. ​ This file should only have the following callbacks, but may include additional functions or callbacks for more complex plugins.  ​   * ''​register.php''​ is the only file required for a plugin to be valid. ​ It must contain two callbacks for plugin information and event registrations. ​ This file should only have the following callbacks, but may include additional functions or callbacks for more complex plugins.  ​
     * ''​plugin_callback_<​basename>​_info()''​ - This function must return an array of plugin information,​ including name, version, ad dependencies.  ​     * ''​plugin_callback_<​basename>​_info()''​ - This function must return an array of plugin information,​ including name, version, ad dependencies.  ​
-    * ''​plugin_callback_<​basename>​_register()''​ - This function must return an array of event names and corresponding function callbacks.+    * ''​plugin_callback_<​basename>​_init()''​ - This function must set up the plugin, ​and hook any events needed.
     * ''​plugin_callback_<​basename>​_schema()''​ - This function is only required if the plugin needs to maintain changes or additions to the Mantis schema. ​ It must return an array of schema upgrades in the same format as the ''​admin/​schema.php''​ upgrade script.     * ''​plugin_callback_<​basename>​_schema()''​ - This function is only required if the plugin needs to maintain changes or additions to the Mantis schema. ​ It must return an array of schema upgrades in the same format as the ''​admin/​schema.php''​ upgrade script.
   * ''​events.php''​ is required for using event hooks. ​ It should contain all the event callback functions, or include additional scripts with the necessary callbacks. ​ All event callback functions must be named as ''​plugin_event_callback_<​basename>​_<​name>​()''​. ​ This script will only be loaded if the plugin has registered for an event.   * ''​events.php''​ is required for using event hooks. ​ It should contain all the event callback functions, or include additional scripts with the necessary callbacks. ​ All event callback functions must be named as ''​plugin_event_callback_<​basename>​_<​name>​()''​. ​ This script will only be loaded if the plugin has registered for an event.
   * ''​lang/''​ is only required if the plugin needs to use language strings that don't appear in the standard language files. ​ These files will only be loaded if the requested strings cannot be found otherwise.   * ''​lang/''​ is only required if the plugin needs to use language strings that don't appear in the standard language files. ​ These files will only be loaded if the requested strings cannot be found otherwise.
   * ''​pages/''​ is only required if a plugin needs to have its own pages. ​ They can be accessed by linking a url returned by the ''​plugin_page()''​ function. ​ These pages need not load the core libraries, as it will already be loaded for them.   * ''​pages/''​ is only required if a plugin needs to have its own pages. ​ They can be accessed by linking a url returned by the ''​plugin_page()''​ function. ​ These pages need not load the core libraries, as it will already be loaded for them.
 +
 +
 +
  
 ==== Sample Plugin (Super Cow Powers) ==== ==== Sample Plugin (Super Cow Powers) ====
Line 151: Line 158:
  
 /** /**
- ​* ​Register callback methods for any events necessary.+ ​* ​Intitialize the plugin.
  */  */
-function ​plugin_callback_supercow_register() { +function ​plugin_callback_supercow_init() { 
-  ​plugin_register( '​EVENT_PLUGIN_INIT',​ '​header'​ );+  ​plugin_event_hook( '​EVENT_PLUGIN_INIT',​ '​header'​ );
 } }
 </​code>​ </​code>​
Line 165: Line 172:
  * Handle the EVENT_PLUGIN_INIT callback.  * Handle the EVENT_PLUGIN_INIT callback.
  */  */
-function ​plugin_event_callback_supercow_header() {+function ​plugin_event_supercow_header() {
   header( '​X-Mantis:​ This Mantis has super cow powers.'​ );   header( '​X-Mantis:​ This Mantis has super cow powers.'​ );
 } }
 </​code>​ </​code>​
 +
  
  
Line 195: Line 203:
   * (vboctor): It should be easy to develop features like Twitter notifications as plug-ins. ​ Once we do that, then the community can have plugins for all similar services like SMS, Jaiku, Pownce, etc.   * (vboctor): It should be easy to develop features like Twitter notifications as plug-ins. ​ Once we do that, then the community can have plugins for all similar services like SMS, Jaiku, Pownce, etc.
     * (jreese) Once again, this comes down to picking appropriate and useful events.     * (jreese) Once again, this comes down to picking appropriate and useful events.
 +  * (DGtlRift): In the above explanation and examples should ''​plugin_callback_<​basename>​_register()''​ be ''​plugin_callback_<​basename>​_init()''?​
mantisbt/dynamic_plugin_requirements.1193631658.txt.gz · Last modified: 2008/10/29 04:31 (external edit)