User Tools

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

Site Tools


mantisbt:plugins_sample

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
mantisbt:plugins_sample [2007/11/04 00:27] jreesemantisbt:plugins_sample [2013/06/21 09:54] (current) atrol
Line 1: Line 1:
 ====== Sample Plugins ====== ====== Sample Plugins ======
 +
  
 ===== Super Cow Powers ===== ===== Super Cow Powers =====
Line 9: Line 10:
 mantis/ mantis/
   plugins/   plugins/
-    supercow+    Supercow
-      register.php +      Supercow.php
-      events.php+
 </code> </code>
  
-**''sample/register.php''** +**''plugins/Supercow/Supercow.php''** 
-<code>+<code php> 
 +<?php 
 + 
 +class SupercowPlugin extends MantisPlugin { 
 + 
 +  function register() { 
 +    $this->name        = 'Super Cow Powers'; 
 +    $this->description = 'Gives your Mantis installation super cow powers.'; 
 + 
 +    $this->version     = '1.0'; 
 +    $this->requires    = array( 
 +      'MantisCore'       => '1.2.0', 
 +    ); 
 + 
 +    $this->author      = 'Fred Smith'; 
 +    $this->contact     = 'fredsmith@fredsmith.fsn'; 
 +    $this->url         = 'http://fredsmith.fsn'; 
 +  } 
 + 
 +  function init() { 
 +    plugin_event_hook( 'EVENT_PLUGIN_INIT', 'header' ); 
 +  } 
 + 
 +  /** 
 +   * Handle the EVENT_PLUGIN_INIT callback. 
 +   */ 
 +  function header() { 
 +    header( 'X-Mantis: This Mantis has super cow powers.' ); 
 +  } 
 + 
 +
 +</code> 
 + 
 +===== SVN Links ===== 
 + 
 +This is a plugin that detects svn:123 and hyperlinks it to the ViewVC web page that contains all the details of the changeset. 
 + 
 +**''plugins/svnlinks/register.php''** 
 +<code php>
 <?php <?php
  
Line 22: Line 60:
  * @return array Plugin details  * @return array Plugin details
  */  */
-function plugin_callback_supercow_info() {+function plugin_callback_svnlinks_info() {
   return array(   return array(
-    'name' => 'Super Cow Powers', +    'name' => 'SVN Links', 
-    'description' => 'Gives your Mantis installation super cow powers.',+    'description' => 'Detects references to SVN changesets and hyperlinks them.',
     'version' => '1.0',     'version' => '1.0',
-    'author' => 'John Reese', +    'author' => 'Victor Boctor', 
-    'contact' => 'jreese@leetcode.net', +    'contact' => 'vboctor -at- users.sourceforge.net', 
-    'url' => 'http://leetcode.net',+    'url' => 'http://www.mantisbt.org',
   );   );
 } }
Line 36: Line 74:
  * Intitialize the plugin.  * Intitialize the plugin.
  */  */
-function plugin_callback_supercow_init() { +function plugin_callback_svnlinks_init() { 
-  plugin_event_hook( 'EVENT_PLUGIN_INIT', 'header' );+ plugin_event_hook( 'EVENT_TEXT_LINKS', 'string_display_links' );
 } }
 </code> </code>
  
-**''sample/events.php''** +**''plugins/svnlinks/events.php''** 
-<code>+<code php>
 <?php <?php
 +
 +# Configuration:
 +# $g_plugin_svnlinks_svn_changeset_link = 'http://mantisbt.svn.sourceforge.net/viewvc/mantisbt?view=rev&revision=%s';
  
 /** /**
- * Handle the EVENT_PLUGIN_INIT callback.+ * Handle the EVENT_TEXT_LINKS callback.
  */  */
-function plugin_event_supercow_header() { +function plugin_event_svnlinks_string_display_links$p_event, $p_string ) { 
-  header( 'X-Mantis: This Mantis has super cow powers.' );+ $t_svn_changeset_link_format = config_get( 'plugin_svnlinks_svn_changeset_link', '' ); 
 + if ( is_blank( $t_svn_changeset_link_format ) ) { 
 + return $p_string; 
 +
 +  
 + $t_svn_changeset_link = sprintf( $t_svn_changeset_link_format, '\\1' ); 
 + 
 + $t_replace_with = '<a href="'. $t_svn_changeset_link . '" target="_new">svn:\\1</a>'; 
 + 
 + return preg_replace( '/svn\:([[:digit:]]+)/i', 
 + $t_replace_with, 
 + $p_string );
 } }
 </code> </code>
  
  
mantisbt/plugins_sample.txt · Last modified: 2013/06/21 09:54 by atrol

Driven by DokuWiki