mantisbt:plugins_sample
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
mantisbt:plugins_sample [2007/11/04 13:39] – Added 'page' and 'requires' fields to the plugin info. vboctor | mantisbt: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/ | ||
- | | + | |
- | | + | |
- | events.php | + | |
</ | </ | ||
- | **'' | + | **'' |
- | < | + | <code php> |
+ | <?php | ||
+ | |||
+ | class SupercowPlugin extends MantisPlugin { | ||
+ | |||
+ | function register() { | ||
+ | $this-> | ||
+ | $this-> | ||
+ | |||
+ | $this-> | ||
+ | $this-> | ||
+ | ' | ||
+ | ); | ||
+ | |||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | } | ||
+ | |||
+ | function init() { | ||
+ | plugin_event_hook( ' | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Handle the EVENT_PLUGIN_INIT callback. | ||
+ | */ | ||
+ | function header() { | ||
+ | header( ' | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== 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. | ||
+ | |||
+ | **'' | ||
+ | < | ||
<?php | <?php | ||
Line 22: | Line 60: | ||
* @return array Plugin details | * @return array Plugin details | ||
*/ | */ | ||
- | function | + | function |
return array( | return array( | ||
- | ' | + | ' |
- | ' | + | ' |
' | ' | ||
- | ' | + | ' |
- | ' | + | ' |
- | ' | + | ' |
- | ' | + | |
- | ' | + | |
); | ); | ||
} | } | ||
Line 38: | Line 74: | ||
* Intitialize the plugin. | * Intitialize the plugin. | ||
*/ | */ | ||
- | function | + | function |
- | plugin_event_hook( 'EVENT_PLUGIN_INIT', 'header' ); | + | plugin_event_hook( 'EVENT_TEXT_LINKS', 'string_display_links' ); |
} | } | ||
</ | </ | ||
- | **'' | + | **'' |
- | < | + | < |
<?php | <?php | ||
+ | |||
+ | # Configuration: | ||
+ | # $g_plugin_svnlinks_svn_changeset_link = ' | ||
/** | /** | ||
- | * Handle the EVENT_PLUGIN_INIT | + | * Handle the EVENT_TEXT_LINKS |
*/ | */ | ||
- | function | + | function |
- | | + | $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, | ||
+ | |||
+ | $t_replace_with = '<a href="' | ||
+ | |||
+ | return preg_replace( '/ | ||
+ | $t_replace_with, | ||
+ | $p_string | ||
} | } | ||
</ | </ | ||
mantisbt/plugins_sample.1194201581.txt.gz · Last modified: 2008/10/29 04:31 (external edit)