diff --git a/Source/Source.API.php b/Source/Source.API.php index c75f207..7654e72 100644 --- a/Source/Source.API.php +++ b/Source/Source.API.php @@ -370,9 +370,9 @@ * preg_replace_callback function for working with VCS links. */ function Source_Changeset_Link_Callback( $p_matches ) { + $t_url_type = strtolower($p_matches[1]); $t_repo_name = $p_matches[2]; $t_revision = $p_matches[3]; - $t_string = $p_matches[2] . ':' . $p_matches[3]; $t_repo_table = plugin_table( 'repository', 'Source' ); $t_changeset_table = plugin_table( 'changeset', 'Source' ); @@ -382,25 +382,33 @@ JOIN $t_repo_table AS r ON r.id=c.repo_id WHERE c.revision LIKE " . db_param() . ' AND r.name LIKE ' . db_param(); - $t_result = db_query_bound( $t_query, array( '%' . $t_revision . '%', '%' . $t_repo_name . '%' ), 1 ); + $t_result = db_query_bound( $t_query, array( $t_revision . '%', $t_repo_name . '%' ), 1 ); if ( db_num_rows( $t_result ) > 0 ) { $t_row = db_fetch_array( $t_result ); - $t_changeset = new SourceChangeset( $t_row['repo_id'], $t_row['revision'], $t_row['timestamp'], $t_row['author'], $t_row['message'], $t_row['user_id'] ); + $t_changeset = new SourceChangeset( $t_row['repo_id'], $t_row['revision'], $t_row['branch'], $t_row['timestamp'], $t_row['author'], $t_row['message'], $t_row['user_id'] ); $t_changeset->id = $t_row['id']; $t_repo = SourceRepo::load( $t_changeset->repo_id ); + $t_vcs = SourceVCS::repo( $t_repo ); - $t_url = $t_vcs->url_changeset( $t_repo, $t_changeset ); - $t_name = $t_vcs->show_changeset( $t_repo, $t_changeset ); + if ($t_url_type == "v") { + $t_url = $t_vcs->url_changeset( $t_repo, $t_changeset ); + } else { + $t_url = plugin_page( 'view' ) . '&id=' . $t_changeset->id; + } + + $t_name = string_display_line( $t_repo->name . ' ' . $t_vcs->show_changeset( $t_repo, $t_changeset ) ); if ( !is_blank( $t_url ) ) { - $t_string = '' . $t_name . ''; + return '' . $t_name . ''; } + + return $t_name; } - return $p_matches[1] . $t_string; + return $p_matches[0]; } /** diff --git a/Source/Source.php b/Source/Source.php index b8a9e79..b8b4b1c 100644 --- a/Source/Source.php +++ b/Source/Source.php @@ -42,6 +42,7 @@ 'manage_threshold' => ADMINISTRATOR, 'username_threshold' => DEVELOPER, + 'enable_linking' => ON, 'enable_mapping' => OFF, 'enable_porting' => OFF, 'enable_resolving' => OFF, @@ -92,6 +93,10 @@ require_once( 'SourceIntegration.php' ); plugin_child( 'SourceIntegration' ); + + if ( plugin_config_get( 'enable_linking' ) ) { + plugin_event_hook( 'EVENT_DISPLAY_FORMATTED', 'display_formatted' ); + } } /** @@ -127,6 +132,11 @@ return $t_links; } + function display_formatted( $p_event, $p_text, $p_multiline ) { + $p_text = preg_replace_callback( '/(?:([sv]):([^:\n\t]+):([^:\n\t\s]+):)/i', 'Source_Changeset_Link_Callback', $p_text ); + return $p_text; + } + function schema() { return array( array( 'CreateTableSQL', array( plugin_table( 'repository' ), " diff --git a/Source/lang/strings_english.txt b/Source/lang/strings_english.txt index de1c534..821d5e1 100644 --- a/Source/lang/strings_english.txt +++ b/Source/lang/strings_english.txt @@ -6,7 +6,7 @@ $s_plugin_Source_ = ''; $s_plugin_Source_title = 'Source Control Integration'; $s_plugin_Source_description = 'Source control integration using an abstract API to support any source control software.'; -$s_plugin_Source_version = '0.14'; +$s_plugin_Source_version = '0.15'; $s_plugin_Source_repository = 'Repository'; $s_plugin_Source_repositories = 'Repositories'; @@ -98,6 +98,7 @@ $s_plugin_Source_show_search_link = 'Search'; $s_plugin_Source_show_repo_stats = 'Repository Statistics'; $s_plugin_Source_enabled_features = 'Enabled Features'; +$s_plugin_Source_enable_linking = 'Changeset Linking ([sv]:<reponame>:<revision>:)'; $s_plugin_Source_enable_mapping = 'Branch Mappings'; $s_plugin_Source_enable_resolving = 'Resolve Fixed Issues'; $s_plugin_Source_enable_message = 'Bug Fixed Message'; diff --git a/Source/pages/manage_config.php b/Source/pages/manage_config.php index 097e1e4..2e96bb2 100644 --- a/Source/pages/manage_config.php +++ b/Source/pages/manage_config.php @@ -16,6 +16,7 @@ $f_show_search_link = gpc_get_bool( 'show_search_link', OFF ); $f_show_repo_stats = gpc_get_bool( 'show_repo_stats', OFF ); +$f_enable_linking = gpc_get_bool( 'enable_linking', OFF ); $f_enable_mapping = gpc_get_bool( 'enable_mapping', OFF ); $f_enable_resolving = gpc_get_bool( 'enable_resolving', OFF ); $f_enable_message = gpc_get_bool( 'enable_message', OFF ); @@ -75,6 +76,7 @@ maybe_set_option( 'show_search_link', $f_show_search_link ); maybe_set_option( 'show_repo_stats', $f_show_repo_stats ); +maybe_set_option( 'enable_linking', $f_enable_linking ); maybe_set_option( 'enable_mapping', $f_enable_mapping ); maybe_set_option( 'enable_resolving', $f_enable_resolving ); maybe_set_option( 'enable_message', $f_enable_message ); diff --git a/Source/pages/manage_config_page.php b/Source/pages/manage_config_page.php index 20ead4f..fea9d25 100644 --- a/Source/pages/manage_config_page.php +++ b/Source/pages/manage_config_page.php @@ -63,6 +63,8 @@