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 00:27] – jreese | 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 36: | 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.1194150448.txt.gz · Last modified: (external edit)
