diff --git a/SourceGithub/SourceGithub.php b/SourceGithub/SourceGithub.php index 71ca2c6..b8d8121 100644 --- a/SourceGithub/SourceGithub.php +++ b/SourceGithub/SourceGithub.php @@ -18,7 +18,7 @@ require_once( config_get( 'core_path' ) . 'json_api.php' ); class SourceGithubPlugin extends MantisSourcePlugin { - function register() { + public function register() { $this->name = plugin_lang_get( 'title' ); $this->description = plugin_lang_get( 'description' ); @@ -34,40 +34,24 @@ $this->url = 'http://leetcode.net'; } - function get_types( $p_event ) { - return array( 'github' => plugin_lang_get( 'github' ) ); + public $type = 'github'; + + public function show_type() { + return plugin_lang_get( 'github' ); } - function show_type( $p_event, $p_type ) { - if ( 'github' == $p_type ) { - return plugin_lang_get( 'github' ); - } - } - - function show_changeset( $p_event, $p_repo, $p_changeset ) { - if ( 'github' != $p_repo->type ) { - return; - } - + public function show_changeset( $p_repo, $p_changeset ) { $t_ref = substr( $p_changeset->revision, 0, 8 ); $t_branch = $p_changeset->branch; return "$t_branch $t_ref"; } - function show_file( $p_event, $p_repo, $p_changeset, $p_file ) { - if ( 'github' != $p_repo->type ) { - return; - } - + public function show_file( $p_repo, $p_changeset, $p_file ) { return "$p_file->action - $p_file->filename"; } - function url_repo( $p_event, $p_repo, $t_changeset=null ) { - if ( 'github' != $p_repo->type ) { - return; - } - + public function url_repo( $p_repo, $t_changeset=null ) { $t_username = $p_repo->info['hub_username']; $t_reponame = $p_repo->info['hub_reponame']; @@ -78,11 +62,7 @@ return "http://github.com/$t_username/$t_reponame/tree$t_ref"; } - function url_changeset( $p_event, $p_repo, $p_changeset ) { - if ( 'github' != $p_repo->type ) { - return; - } - + public function url_changeset( $p_repo, $p_changeset ) { $t_username = $p_repo->info['hub_username']; $t_reponame = $p_repo->info['hub_reponame']; $t_ref = $p_changeset->revision; @@ -90,11 +70,7 @@ return "http://github.com/$t_username/$t_reponame/commit/$t_ref"; } - function url_file( $p_event, $p_repo, $p_changeset, $p_file ) { - if ( 'github' != $p_repo->type ) { - return; - } - + public function url_file( $p_repo, $p_changeset, $p_file ) { $t_username = $p_repo->info['hub_username']; $t_reponame = $p_repo->info['hub_reponame']; $t_ref = $p_changeset->revision; @@ -103,11 +79,7 @@ return "http://github.com/$t_username/$t_reponame/tree/$t_ref/$t_filename"; } - function url_diff( $p_event, $p_repo, $p_changeset, $p_file ) { - if ( 'github' != $p_repo->type ) { - return; - } - + public function url_diff( $p_repo, $p_changeset, $p_file ) { $t_username = $p_repo->info['hub_username']; $t_reponame = $p_repo->info['hub_reponame']; $t_ref = $p_changeset->revision; @@ -116,11 +88,7 @@ return "http://github.com/$t_username/$t_reponame/commit/$t_ref"; } - function update_repo_form( $p_event, $p_repo ) { - if ( 'github' != $p_repo->type ) { - return; - } - + public function update_repo_form( $p_repo ) { $t_hub_username = null; $t_hub_reponame = null; @@ -153,11 +121,7 @@ type ) { - return; - } - + public function update_repo( $p_repo ) { $f_hub_username = gpc_get_string( 'hub_username' ); $f_hub_reponame = gpc_get_string( 'hub_reponame' ); $f_master_branch = gpc_get_string( 'master_branch' ); @@ -174,7 +138,7 @@ return $p_repo; } - function uri_base( $p_repo ) { + private function uri_base( $p_repo ) { $t_uri_base = 'http://github.com/api/v1/json/' . urlencode( $p_repo->info['hub_username'] ) . '/' . urlencode( $p_repo->info['hub_reponame'] ) . '/'; @@ -182,7 +146,7 @@ return $t_uri_base; } - function precommit( $p_event ) { + public function precommit() { $f_payload = gpc_get_string( 'payload', null ); if ( is_null( $f_payload ) ) { return; @@ -216,11 +180,7 @@ return; } - function commit( $p_event, $p_repo, $p_data ) { - if ( 'github' != $p_repo->type ) { - return; - } - + public function commit( $p_repo, $p_data ) { $t_commits = array(); foreach( $p_data['commits'] as $t_commit ) { @@ -235,10 +195,7 @@ return $this->import_commits( $p_repo, $this->uri_base( $p_repo ), $t_commits, $t_branch ); } - function import_full( $p_event, $p_repo ) { - if ( 'github' != $p_repo->type ) { - return; - } + public function import_full( $p_repo ) { echo '
';
 
 		$t_branch = $p_repo->info['master_branch'];
@@ -276,11 +233,11 @@
 		return $t_changesets;
 	}
 
-	function import_latest( $p_event, $p_repo ) {
-		return $this->import_full( $p_event, $p_repo );
+	public function import_latest( $p_repo ) {
+		return $this->import_full( $p_repo );
 	}
 
-	function import_commits( $p_repo, $p_uri_base, $p_commit_ids, $p_branch='' ) {
+	public function import_commits( $p_repo, $p_uri_base, $p_commit_ids, $p_branch='' ) {
 		static $s_parents = array();
 		static $s_counter = 0;
 
@@ -316,7 +273,7 @@
 		return $t_changesets;
 	}
 
-	function json_commit_changeset( $p_repo, $p_json, $p_branch='' ) {
+	private function json_commit_changeset( $p_repo, $p_json, $p_branch='' ) {
 
 		echo "processing $p_json->id ... ";
 		if ( !SourceChangeset::exists( $p_repo->id, $p_json->id ) ) {
diff --git a/SourceSFSVN/SourceSFSVN.php b/SourceSFSVN/SourceSFSVN.php
index f6fb46d..11b2ada 100644
--- a/SourceSFSVN/SourceSFSVN.php
+++ b/SourceSFSVN/SourceSFSVN.php
@@ -16,7 +16,7 @@
 }
 
 class SourceSFSVNPlugin extends MantisSourcePlugin {
-	function register() {
+	public function register() {
 		$this->name = lang_get( 'plugin_SourceSFSVN_title' );
 		$this->description = lang_get( 'plugin_SourceSFSVN_description' );
 		$this->page = 'config_page';
@@ -32,87 +32,67 @@
 		$this->url = 'http://leetcode.net';
 	}
 
-	function config() {
+	public function config() {
 		return array(
 			'svnpath' => '',
 		);
 	}
 
-	function errors() {
+	public function errors() {
 		return array(
 			'SVNPathInvalid' => 'Path to Subversion binary invalid or inaccessible',
 		);
 	}
 
-	function get_types( $p_event ) {
-		return array( 'sfsvn' => lang_get( 'plugin_SourceSFSVN_svn' ) );
+	public $type = 'sfsvn';
+
+	public function show_type() {
+		return lang_get( 'plugin_SourceSFSVN_svn' );
 	}
 
-	function show_type( $p_event, $p_type ) {
-		if ( 'sfsvn' == $p_type ) {
-			return lang_get( 'plugin_SourceSFSVN_svn' );
-		}
+	public function show_changeset( $p_repo, $p_changeset ) {
+		return "$p_changeset->branch r$p_changeset->revision";
 	}
 
-	function show_changeset( $p_event, $p_repo, $p_changeset ) {
-		if ( 'sfsvn' == $p_repo->type ) {
-			return "$p_changeset->branch r$p_changeset->revision";
-		}
+	public function show_file( $p_repo, $p_changeset, $p_file ) {
+		return $p_file->action . ' - ' . $p_file->filename;
 	}
 
-	function show_file( $p_event, $p_repo, $p_changeset, $p_file ) {
-		if ( 'sfsvn' == $p_repo->type ) {
-			return $p_file->action . ' - ' . $p_file->filename;
-		}
-	}
-
-	function sf_url( $p_repo ) {
+	private function sf_url( $p_repo ) {
 		$t_project = urlencode( $p_repo->info['sf_project'] );
 		return "http://$t_project.svn.sourceforge.net/viewvc/$t_project";
 	}
 
-	function url_repo( $p_event, $p_repo, $p_changeset=null ) {
-		if ( 'sfsvn' == $p_repo->type ) {
-			if ( !is_null( $p_changeset ) ) {
-				$t_rev = '?pathrev=' . urlencode( $p_changeset->revision );
-			}
-			return $this->sf_url( $p_repo ) . "/$t_rev";
+	public function url_repo( $p_repo, $p_changeset=null ) {
+		if ( !is_null( $p_changeset ) ) {
+			$t_rev = '?pathrev=' . urlencode( $p_changeset->revision );
 		}
+		return $this->sf_url( $p_repo ) . "/$t_rev";
 	}
 
-	function url_changeset( $p_event, $p_repo, $p_changeset ) {
-		if ( 'sfsvn' == $p_repo->type ) {
-			$t_rev = '&revision=' . urlencode( $p_changeset->revision );
-			return $this->sf_url( $p_repo ) . "?view=rev$t_rev";
-		}
+	public function url_changeset( $p_repo, $p_changeset ) {
+		$t_rev = '&revision=' . urlencode( $p_changeset->revision );
+		return $this->sf_url( $p_repo ) . "?view=rev$t_rev";
 	}
 
-	function url_file( $p_event, $p_repo, $p_changeset, $p_file ) {
-		if ( 'sfsvn' == $p_repo->type ) {
-			if ( $p_file->action == 'D' ) {
-				return '';
-			}
-			return $this->sf_url( $p_repo ) . urlencode( $p_file->filename ) .
-				'?view=markup&pathrev=' . urlencode( $p_changeset->revision );
+	public function url_file( $p_repo, $p_changeset, $p_file ) {
+		if ( $p_file->action == 'D' ) {
+			return '';
 		}
+		return $this->sf_url( $p_repo ) . urlencode( $p_file->filename ) .
+			'?view=markup&pathrev=' . urlencode( $p_changeset->revision );
 	}
 
-	function url_diff( $p_event, $p_repo, $p_changeset, $p_file ) {
-		if ( 'sfsvn' == $p_repo->type ) {
-			if ( $p_file->action == 'D' || $p_file->action == 'A' ) {
-				return '';
-			}
-			$t_diff = '?r1=' . urlencode( $p_changeset->revision ) . '&r2=' . urlencode( $p_changeset->revision - 1 );
-			return $this->sf_url( $p_repo ) . urlencode( $p_file->filename ) . $t_diff .
-				'&pathrev=' . urlencode( $p_changeset->revision );
+	public function url_diff( $p_repo, $p_changeset, $p_file ) {
+		if ( $p_file->action == 'D' || $p_file->action == 'A' ) {
+			return '';
 		}
+		$t_diff = '?r1=' . urlencode( $p_changeset->revision ) . '&r2=' . urlencode( $p_changeset->revision - 1 );
+		return $this->sf_url( $p_repo ) . urlencode( $p_file->filename ) . $t_diff .
+			'&pathrev=' . urlencode( $p_changeset->revision );
 	}
 
-	function update_repo_form( $p_event, $p_repo ) {
-		if ( 'sfsvn' != $p_repo->type ) {
-			return;
-		}
-
+	public function update_repo_form( $p_repo ) {
 		$t_svn_username = isset( $p_repo->info['svn_username'] ) ? $p_repo->info['svn_username'] : '';
 		$t_svn_password = isset( $p_repo->info['svn_password'] ) ? $p_repo->info['svn_password'] : '';
 		$t_sf_project = isset( $p_repo->info['sf_project'] ) ? $p_repo->info['sf_project'] : '';
@@ -158,7 +138,7 @@
 type ) {
 			return;
 		}
@@ -175,11 +155,7 @@
 		return $p_repo;
 	}
 
-	function commit( $p_event, $p_repo, $p_data ) {
-		if ( 'sfsvn' != $p_repo->type ) {
-			return null;
-		}
-
+	public function commit( $p_repo, $p_data ) {
 		if ( preg_match( '/(\d+)/', $p_data, $p_matches ) ) {
 			$svn = $this->svn_call( $p_repo );
 
@@ -196,11 +172,7 @@
 		}
 	}
 
-	function import_full( $p_event, $p_repo ) {
-		if ( 'sfsvn' != $p_repo->type ) {
-			return;
-		}
-
+	public function import_full( $p_repo ) {
 		$this->check_svn();
 		$svn = $this->svn_call( $p_repo );
 
@@ -230,15 +202,11 @@
 		}
 	}
 
-	function import_latest( $p_event, $p_repo ) {
-		if ( 'sfsvn' != $p_repo->type ) {
-			return;
-		}
-
-		return $this->import_full( $p_event, $p_repo );
+	public function import_latest( $p_repo ) {
+		return $this->import_full( $p_repo );
 	}
 
-	function check_svn() {
+	private function check_svn() {
 		$svn = $this->svn_call();
 
 		if ( is_blank( shell_exec( "$svn help" ) ) ) {
@@ -246,7 +214,7 @@
 		}
 	}
 
-	function svn_call( $p_repo=null ) {
+	private function svn_call( $p_repo=null ) {
 		static $s_call;
 
 		# Generate, validate, and cache the SVN binary path
@@ -285,7 +253,7 @@
 		return $t_call;
 	}
 
-	function process_svn_log( $p_repo, $p_svnlog ) {
+	private function process_svn_log( $p_repo, $p_svnlog ) {
 		$t_state = 0;
 		$t_svnline = str_pad( '', 72, '-' );
 
diff --git a/SourceWebSVN/SourceWebSVN.php b/SourceWebSVN/SourceWebSVN.php
index 50a807d..8908571 100644
--- a/SourceWebSVN/SourceWebSVN.php
+++ b/SourceWebSVN/SourceWebSVN.php
@@ -16,7 +16,7 @@
 }
 
 class SourceWebSVNPlugin extends MantisSourcePlugin {
-	function register() {
+	public function register() {
 		$this->name = lang_get( 'plugin_SourceWebSVN_title' );
 		$this->description = lang_get( 'plugin_SourceWebSVN_description' );
 		$this->page = 'config_page';
@@ -32,86 +32,66 @@
 		$this->url = 'http://leetcode.net';
 	}
 
-	function config() {
+	public function config() {
 		return array(
 			'svnpath' => '',
 		);
 	}
 
-	function errors() {
+	public function errors() {
 		return array(
 			'SVNPathInvalid' => 'Path to Subversion binary invalid or inaccessible',
 		);
 	}
 
-	function get_types( $p_event ) {
-		return array( 'svn' => lang_get( 'plugin_SourceWebSVN_svn' ) );
+	public $type = 'svn';
+
+	public function show_type() {
+		return lang_get( 'plugin_SourceWebSVN_svn' );
 	}
 
-	function show_type( $p_event, $p_type ) {
-		if ( 'svn' == $p_type ) {
-			return lang_get( 'plugin_SourceWebSVN_svn' );
-		}
+	public function show_changeset( $p_repo, $p_changeset ) {
+		return "$p_changeset->branch r$p_changeset->revision";
 	}
 
-	function show_changeset( $p_event, $p_repo, $p_changeset ) {
-		if ( 'svn' == $p_repo->type ) {
-			return "$p_changeset->branch r$p_changeset->revision";
-		}
+	public function show_file( $p_repo, $p_changeset, $p_file ) {
+		return $p_file->action . ' - ' . $p_file->filename;
 	}
 
-	function show_file( $p_event, $p_repo, $p_changeset, $p_file ) {
-		if ( 'svn' == $p_repo->type ) {
-			return $p_file->action . ' - ' . $p_file->filename;
+	public function url_repo( $p_repo, $p_changeset=null ) {
+		$t_rev = '';
+		$t_path = '';
+
+		if ( !is_null( $p_changeset ) ) {
+			$t_rev = '&rev=' . urlencode( $p_changeset->revision );
 		}
+		if ( !is_blank( $p_repo->info['websvn_path'] ) ) {
+			$t_path = '&path=' . urlencode( $p_repo->info['websvn_path'] );
+		}
+		return $p_repo->info['websvn_url'] . 'listing.php?repname=' . urlencode( $p_repo->info['websvn_name'] ) . "$t_path$t_rev&sc=1";
 	}
 
-	function url_repo( $p_event, $p_repo, $p_changeset=null ) {
-		if ( 'svn' == $p_repo->type ) {
-			$t_rev = '';
-			$t_path = '';
-
-			if ( !is_null( $p_changeset ) ) {
-				$t_rev = '&rev=' . urlencode( $p_changeset->revision );
-			}
-			if ( !is_blank( $p_repo->info['websvn_path'] ) ) {
-				$t_path = '&path=' . urlencode( $p_repo->info['websvn_path'] );
-			}
-			return $p_repo->info['websvn_url'] . 'listing.php?repname=' . urlencode( $p_repo->info['websvn_name'] ) . "$t_path$t_rev&sc=1";
-		}
+	public function url_changeset( $p_repo, $p_changeset ) {
+		return $this->url_repo( $p_repo, $p_changeset );
 	}
 
-	function url_changeset( $p_event, $p_repo, $p_changeset ) {
-		if ( 'svn' == $p_repo->type ) {
-			return $this->url_repo( $p_event, $p_repo, $p_changeset );
+	public function url_file( $p_repo, $p_changeset, $p_file ) {
+		if ( $p_file->action == 'D' ) {
+			return '';
 		}
+		return $p_repo->info['websvn_url'] . 'filedetails.php?repname=' . urlencode( $p_repo->info['websvn_name'] ) .
+			'&rev=' . urlencode( $p_changeset->revision ) . '&path=' . urlencode( $p_file->filename ) . '&sc=1';
 	}
 
-	function url_file( $p_event, $p_repo, $p_changeset, $p_file ) {
-		if ( 'svn' == $p_repo->type ) {
-			if ( $p_file->action == 'D' ) {
-				return '';
-			}
-			return $p_repo->info['websvn_url'] . 'filedetails.php?repname=' . urlencode( $p_repo->info['websvn_name'] ) .
-				'&rev=' . urlencode( $p_changeset->revision ) . '&path=' . urlencode( $p_file->filename ) . '&sc=1';
+	public function url_diff( $p_repo, $p_changeset, $p_file ) {
+		if ( $p_file->action == 'D' || $p_file->action == 'A' ) {
+			return '';
 		}
+		return $p_repo->info['websvn_url'] . 'diff.php?repname=' . urlencode( $p_repo->info['websvn_name'] ) .
+			'&rev=' . urlencode( $p_changeset->revision ) . '&path=' . urlencode( $p_file->filename ) . '&sc=1';
 	}
 
-	function url_diff( $p_event, $p_repo, $p_changeset, $p_file ) {
-		if ( 'svn' == $p_repo->type ) {
-			if ( $p_file->action == 'D' || $p_file->action == 'A' ) {
-				return '';
-			}
-			return $p_repo->info['websvn_url'] . 'diff.php?repname=' . urlencode( $p_repo->info['websvn_name'] ) .
-				'&rev=' . urlencode( $p_changeset->revision ) . '&path=' . urlencode( $p_file->filename ) . '&sc=1';
-		}
-	}
-
-	function update_repo_form( $p_event, $p_repo ) {
-		if ( 'svn' != $p_repo->type ) {
-			return;
-		}
-
+	public function update_repo_form( $p_repo ) {
 		$t_svn_username = isset( $p_repo->info['svn_username'] ) ? $p_repo->info['svn_username'] : '';
 		$t_svn_password = isset( $p_repo->info['svn_password'] ) ? $p_repo->info['svn_password'] : '';
 		$t_url = isset( $p_repo->info['websvn_url'] ) ? $p_repo->info['websvn_url'] : '';
@@ -167,7 +147,7 @@
 type ) {
 			return;
 		}
@@ -186,11 +166,7 @@
 		return $p_repo;
 	}
 
-	function commit( $p_event, $p_repo, $p_data ) {
-		if ( 'svn' != $p_repo->type ) {
-			return null;
-		}
-
+	public function commit( $p_repo, $p_data ) {
 		if ( preg_match( '/(\d+)/', $p_data, $p_matches ) ) {
 			$svn = $this->svn_call( $p_repo );
 
@@ -207,11 +183,7 @@
 		}
 	}
 
-	function import_full( $p_event, $p_repo ) {
-		if ( 'svn' != $p_repo->type ) {
-			return;
-		}
-
+	public function import_full( $p_repo ) {
 		$this->check_svn();
 		$svn = $this->svn_call( $p_repo );
 
@@ -241,15 +213,11 @@
 		}
 	}
 
-	function import_latest( $p_event, $p_repo ) {
-		if ( 'svn' != $p_repo->type ) {
-			return;
-		}
-
-		return $this->import_full( $p_event, $p_repo );
+	public function import_latest( $p_repo ) {
+		return $this->import_full( $p_repo );
 	}
 
-	function check_svn() {
+	private function check_svn() {
 		$svn = $this->svn_call();
 
 		if ( is_blank( shell_exec( "$svn help" ) ) ) {
@@ -257,7 +225,7 @@
 		}
 	}
 
-	function svn_call( $p_repo=null ) {
+	private function svn_call( $p_repo=null ) {
 		static $s_call;
 
 		# Generate, validate, and cache the SVN binary path
@@ -296,7 +264,7 @@
 		return $t_call;
 	}
 
-	function process_svn_log( $p_repo, $p_svnlog ) {
+	private function process_svn_log( $p_repo, $p_svnlog ) {
 		$t_state = 0;
 		$t_svnline = str_pad( '', 72, '-' );