File tree Expand file tree Collapse file tree 4 files changed +24
-14
lines changed Expand file tree Collapse file tree 4 files changed +24
-14
lines changed Original file line number Diff line number Diff line change @@ -416,10 +416,15 @@ function Source_Changeset_Link_Callback( $p_matches ) {
416416 $ t_repo = SourceRepo::load ( $ t_changeset ->repo_id );
417417 $ t_vcs = SourceVCS::repo ( $ t_repo );
418418
419- if ($ t_url_type == "v " ) {
420- $ t_url = $ t_vcs ->url_changeset ( $ t_repo , $ t_changeset );
421- } else {
422- $ t_url = plugin_page ( 'view ' ) . '&id= ' . $ t_changeset ->id ;
419+ switch ( $ t_url_type ) {
420+ case 'v ' :
421+ case 'd ' :
422+ $ t_url = $ t_vcs ->url_changeset ( $ t_repo , $ t_changeset );
423+ break ;
424+ case 'c ' :
425+ case 's ' :
426+ default :
427+ $ t_url = plugin_page ( 'view ' ) . '&id= ' . $ t_changeset ->id ;
423428 }
424429
425430 $ t_name = string_display_line ( $ t_repo ->name . ' ' . $ t_vcs ->show_changeset ( $ t_repo , $ t_changeset ) );
Original file line number Diff line number Diff line change @@ -13,6 +13,15 @@ class SourcePlugin extends MantisPlugin {
1313 static $ framework_version = '0.18 ' ;
1414 static $ cache = array ();
1515
16+ /**
17+ * Changeset link matching pattern
18+ * format: '<type>:<reponame>:<revision>:', where
19+ * <type> = link type, 'c' or 's' for changeset details, 'd' or 'v' for diff
20+ * <repo> = repository name
21+ * <rev> = changeset revision ID (e.g. SVN rev number, GIT SHA, etc.)
22+ */
23+ const CHANGESET_LINKING_REGEX = '/(?:([cdsv]?):([^:\n\t]+):([^:\n\t\s]+):)/i ' ;
24+
1625 function register () {
1726 $ this ->name = plugin_lang_get ( 'title ' );
1827 $ this ->description = plugin_lang_get ( 'description ' );
@@ -147,7 +156,11 @@ function menu_main() {
147156 }
148157
149158 function display_formatted ( $ p_event , $ p_text , $ p_multiline ) {
150- $ p_text = preg_replace_callback ( '/(?:([sv]):([^:\n\t]+):([^:\n\t\s]+):)/i ' , 'Source_Changeset_Link_Callback ' , $ p_text );
159+ $ p_text = preg_replace_callback (
160+ self ::CHANGESET_LINKING_REGEX ,
161+ 'Source_Changeset_Link_Callback ' ,
162+ $ p_text
163+ );
151164 return $ p_text ;
152165 }
153166
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ function register() {
1212 function hooks () {
1313 return array (
1414 'EVENT_VIEW_BUG_EXTRA ' => 'display_bug ' ,
15- 'EVENT_DISPLAY_FORMATTED ' => 'display_formatted ' ,
1615 'EVENT_MENU_ISSUE ' => 'display_changeset_link ' ,
1716
1817 'EVENT_ACCOUNT_PREF_UPDATE_FORM ' => 'account_update_form ' ,
@@ -73,13 +72,6 @@ function display_bug( $p_event, $p_bug_id ) {
7372 collapse_end ( 'Source ' );
7473 } #display_bug
7574
76- function display_formatted ( $ p_event , $ p_string , $ p_multiline ) {
77- $ t_string = $ p_string ;
78- $ t_string = preg_replace_callback ( '/(\s)c?:([\w ]+):([\w]+)\b/ ' , 'Source_Changeset_Link_Callback ' , $ t_string );
79-
80- return $ t_string ;
81- }
82-
8375 /**
8476 * When updating user preferences, allowing the user or admin to specify
8577 * a version control username to be associated with the account.
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ $s_plugin_Source_show_repo_link = 'Repositories';
104104$s_plugin_Source_show_search_link = 'Search';
105105$s_plugin_Source_show_repo_stats = 'Repository Statistics';
106106$s_plugin_Source_enabled_features = 'Enabled Features';
107- $s_plugin_Source_enable_linking = 'Changeset Linking <span class="small">([sv] :<reponame>:<revision>:)</span>';
107+ $s_plugin_Source_enable_linking = 'Changeset Linking <span class="small">(<em><type> :<reponame>:<revision>:</em> where <type> = \'s\' for details, \'v\' for diff )</span>';
108108$s_plugin_Source_enable_mapping = 'Branch Mappings';
109109$s_plugin_Source_enable_resolving = 'Resolve Fixed Issues';
110110$s_plugin_Source_enable_message = 'Bug Fixed Message';
You can’t perform that action at this time.
0 commit comments