[evolvis-commits] r13627: Add repository browser for CVS and SVN (in an iframe for now)

mirabilos at evolvis.org mirabilos at evolvis.org
Mon Feb 28 02:51:07 CET 2011


Author: mirabilos
Date: 2011-02-28 02:51:06 +0100 (Mon, 28 Feb 2011)
New Revision: 13627

Added:
   trunk/gforge_base/evolvisforge-5.1/gforge/www/scm/browser.php
Modified:
   trunk/gforge_base/evolvisforge-5.1/gforge/common/include/SCMPlugin.class.php
   trunk/gforge_base/evolvisforge-5.1/gforge/plugins/scmbzr/common/BzrPlugin.class.php
   trunk/gforge_base/evolvisforge-5.1/gforge/plugins/scmcpold/common/CpoldPlugin.class.php
   trunk/gforge_base/evolvisforge-5.1/gforge/plugins/scmcvs/common/CVSPlugin.class.php
   trunk/gforge_base/evolvisforge-5.1/gforge/plugins/scmsvn/common/SVNPlugin.class.php
   trunk/gforge_base/evolvisforge-5.1/gforge/www/scm/viewvc.php
Log:
Add repository browser for CVS and SVN (in an iframe for now)

Modified: trunk/gforge_base/evolvisforge-5.1/gforge/common/include/SCMPlugin.class.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/common/include/SCMPlugin.class.php	2011-02-28 01:50:55 UTC (rev 13626)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/common/include/SCMPlugin.class.php	2011-02-28 01:51:06 UTC (rev 13627)
@@ -33,13 +33,14 @@
 		$this->Plugin() ;
 		$this->hooks[] = 'scm_plugin';
 		$this->hooks[] = 'scm_page';
+		$this->hooks[] = 'scm_admin_page';
 		$this->hooks[] = 'scm_admin_update';
-		$this->hooks[] = 'scm_admin_page';
  		$this->hooks[] = 'scm_stats';
 		$this->hooks[] = 'scm_create_repo';
 		# Other common hooks that can be enabled per plugin:
 		# scm_generate_snapshots
 		# scm_gather_stats
+		# scm_browser_page
 	}
 
 	function CallHook ($hookname, $params) {
@@ -51,16 +52,19 @@
 			$scm_plugins[]=$this->name;
 			break;
 		case 'scm_page':
-			$this->getPage ($params) ;
+			$this->printPage ($params) ;
 			break ;
-		case 'scm_admin_update':
-			$this->AdminUpdate ($params) ;
+		case 'scm_browser_page':
+			$this->printBrowserPage ($params) ;
 			break ;
 		case 'scm_admin_page':
-			$this->getAdminPage ($params) ;
+			$this->printAdminPage ($params) ;
 			break ;
+		case 'scm_admin_update':
+			$this->adminUpdate ($params) ;
+			break ;
 		case 'scm_stats':
-			$this->echoShortStats ($params) ;
+			$this->printShortStats ($params) ;
 			break;
 		case 'scm_create_repo':
 			$this->createOrUpdateRepo ($params) ;
@@ -93,7 +97,7 @@
 
 	abstract function createOrUpdateRepo ($params) ;
 
-	function echoShortStats ($params) {
+	function printShortStats ($params) {
 		$project = $this->checkParams ($params) ;
 		if (!$project) {
 			return false ;
@@ -120,10 +124,10 @@
 		return _('<p>Instructions for snapshot access for unimplemented SCM plugin.</p>');
 	}
 
-	function getBrowserBlock ($project) {
+	function getBrowserLinkBlock ($project) {
 		global $HTML ;
 		$b = $HTML->boxMiddle(_('Repository Browser'));
-		$b = _('<p>Browsing the SCM tree is not yet implemented for this SCM plugin.</p>');
+		$b .= _('<p>Browsing the SCM tree is not yet implemented for this SCM plugin.</p>');
 		$b .= '<p>[' ;
 		$b .= util_make_link ("/scm/?group_id=".$project->getID(),
 				      _('Not implemented yet')
@@ -132,6 +136,13 @@
 		return $b ;
 	}
 
+	function getBrowserBlock ($project) {
+		global $HTML ;
+		$b = $HTML->boxMiddle(_('Repository Browser'));
+		$b .= _('<p>Browsing the SCM tree is not yet implemented for this SCM plugin.</p>');
+		return $b ;
+	}
+
 	function getStatsBlock ($project) {
 		global $HTML ;
 		$b = $HTML->boxMiddle(_('Repository Statistics'));
@@ -139,7 +150,7 @@
 		return $b ;
 	}
 
-	function getPage ($params) {
+	function printPage ($params) {
 		global $HTML, $sys_scm_snapshots_path;
 
 		$project = $this->checkParams ($params) ;
@@ -172,7 +183,7 @@
 			echo _('Data about current and past states of the repository') ;
 			if ($this->browserDisplayable ($project)) {
 				echo $this->getStatsBlock($project) ;
-				echo $this->getBrowserBlock ($project) ;
+				echo $this->getBrowserLinkBlock ($project) ;
 			}
 			
 			echo $HTML->boxBottom();
@@ -180,12 +191,34 @@
 		}
 	}
 
-	function AdminUpdate ($params) {
+	function printBrowserPage ($params) {
+		global $HTML;
+
 		$project = $this->checkParams ($params) ;
 		if (!$project) {
 			return false ;
 		}
 		
+		if ($project->usesPlugin ($this->name)) {
+			if ($this->browserDisplayable ($project)) {
+				// print '<iframe src="'.util_make_url('/scm/browser.php?title='.$group->getUnixName()).'" frameborder="no" width=100% height=700></iframe>' ;
+			}
+		}
+	}
+
+	function printAdminPage ($params) {
+		$group =& group_get_object($params['group_id']);
+		if ( $group->usesPlugin ( $this->name ) && $group->isPublic()) {
+			print '<p><input type="checkbox" name="scm_enable_anonymous" value="1" '.$this->c($group->enableAnonSCM()).' /><strong>'._('Enable Anonymous Access').'</strong></p>';
+		}
+	}
+	
+	function adminUpdate ($params) {
+		$project = $this->checkParams ($params) ;
+		if (!$project) {
+			return false ;
+		}
+		
 		if ($project->usesPlugin ($this->name) ) {
 			if ($params['scm_enable_anonymous']) {
 				$project->SetUsesAnonSCM(true);
@@ -195,13 +228,6 @@
 		}
 	}
 	
-	function getAdminPage ($params) {
-		$group =& group_get_object($params['group_id']);
-		if ( $group->usesPlugin ( $this->name ) && $group->isPublic()) {
-			print '<p><input type="checkbox" name="scm_enable_anonymous" value="1" '.$this->c($group->enableAnonSCM()).' /><strong>'._('Enable Anonymous Access').'</strong></p>';
-		}
-	}
-	
 	function checkParams ($params) {
 		$group_id = $params['group_id'] ;
 		$project =& group_get_object($group_id);

Modified: trunk/gforge_base/evolvisforge-5.1/gforge/plugins/scmbzr/common/BzrPlugin.class.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/plugins/scmbzr/common/BzrPlugin.class.php	2011-02-28 01:50:55 UTC (rev 13626)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/plugins/scmbzr/common/BzrPlugin.class.php	2011-02-28 01:51:06 UTC (rev 13627)
@@ -73,7 +73,7 @@
 		return ;
 	}
 
-	function getBrowserBlock ($project) {
+	function getBrowserLinkBlock ($project) {
 		return ;
 	}
 

Modified: trunk/gforge_base/evolvisforge-5.1/gforge/plugins/scmcpold/common/CpoldPlugin.class.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/plugins/scmcpold/common/CpoldPlugin.class.php	2011-02-28 01:50:55 UTC (rev 13626)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/plugins/scmcpold/common/CpoldPlugin.class.php	2011-02-28 01:51:06 UTC (rev 13627)
@@ -74,7 +74,7 @@
 		return ;
 	}
 
-	function getBrowserBlock ($project) {
+	function getBrowserLinkBlock ($project) {
 		return ;
 	}
 

Modified: trunk/gforge_base/evolvisforge-5.1/gforge/plugins/scmcvs/common/CVSPlugin.class.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/plugins/scmcvs/common/CVSPlugin.class.php	2011-02-28 01:50:55 UTC (rev 13626)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/plugins/scmcvs/common/CVSPlugin.class.php	2011-02-28 01:51:06 UTC (rev 13627)
@@ -29,6 +29,7 @@
 		$this->SCMPlugin () ;
 		$this->name = 'scmcvs';
 		$this->text = 'CVS';
+		$this->hooks[] = 'scm_browser_page';
 		$this->hooks[] = 'scm_generate_snapshots' ;
 		$this->hooks[] = 'scm_gather_stats' ;
 
@@ -51,6 +52,27 @@
 		return $this->default_cvs_server;
 	}
 
+	function printShortStats ($params) {
+		$project = $this->checkParams ($params) ;
+		if (!$project) {
+			return false ;
+		}
+		
+		if ($project->usesPlugin($this->name)) {
+			$result = db_query_params('SELECT sum(commits) AS commits, sum(adds) AS adds FROM stats_cvs_group WHERE group_id=$1',
+						  array ($project->getID())) ;
+			$commit_num = db_result($result,0,'commits');
+			$add_num    = db_result($result,0,'adds');
+			if (!$commit_num) {
+				$commit_num=0;
+			}
+			if (!$add_num) {
+				$add_num=0;
+			}
+			echo ' (CVS: '.sprintf(_('<strong>%1$s</strong> commits, <strong>%2$s</strong> adds'), number_format($commit_num, 0), number_format($add_num, 0)).")";
+		}
+	}
+	
 	function getBlurb () {
 		return _('<p>CVS documentation is available <a href="http://cvsbook.red-bean.com/">here</a>.</p>');
 	}
@@ -90,12 +112,12 @@
 		return $b ;
 	}
 
-	function getBrowserBlock ($project) {
+	function getBrowserLinkBlock ($project) {
 		global $HTML ;
 		$b = $HTML->boxMiddle(_('CVS Repository Browser'));
 		$b .= _('<p>Browsing the CVS tree gives you a view into the current status of this project\'s code. You may also view the complete histories of any file in the repository.</p>');
 		$b .= '<p>[' ;
-		$b .= util_make_link ("/scm/viewvc.php/?root=".$project->getUnixName(),
+		$b .= util_make_link ("/scm/browser.php?group_id=".$project->getID(),
 				      _('Browse CVS Repository')
 			) ;
 		$b .= ']</p>' ;
@@ -144,27 +166,21 @@
 		return $b ;
 	}
 
-	function echoShortStats ($params) {
+	function printBrowserPage ($params) {
+		global $HTML;
+
 		$project = $this->checkParams ($params) ;
 		if (!$project) {
 			return false ;
 		}
 		
-		if ($project->usesPlugin($this->name)) {
-			$result = db_query_params('SELECT sum(commits) AS commits, sum(adds) AS adds FROM stats_cvs_group WHERE group_id=$1',
-						  array ($project->getID())) ;
-			$commit_num = db_result($result,0,'commits');
-			$add_num    = db_result($result,0,'adds');
-			if (!$commit_num) {
-				$commit_num=0;
+		if ($project->usesPlugin ($this->name)) {
+			if ($this->browserDisplayable ($project)) {
+				print '<iframe src="'.util_make_url ("/scm/viewvc.php/?root=".$project->getUnixName()).'" frameborder="no" width=100% height=700></iframe>' ;
 			}
-			if (!$add_num) {
-				$add_num=0;
-			}
-			echo ' (CVS: '.sprintf(_('<strong>%1$s</strong> commits, <strong>%2$s</strong> adds'), number_format($commit_num, 0), number_format($add_num, 0)).")";
 		}
 	}
-	
+
 	function createOrUpdateRepo ($params) {
 		$project = $this->checkParams ($params) ;
 		if (!$project) {

Modified: trunk/gforge_base/evolvisforge-5.1/gforge/plugins/scmsvn/common/SVNPlugin.class.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/plugins/scmsvn/common/SVNPlugin.class.php	2011-02-28 01:50:55 UTC (rev 13626)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/plugins/scmsvn/common/SVNPlugin.class.php	2011-02-28 01:51:06 UTC (rev 13627)
@@ -28,6 +28,7 @@
 		$this->SCMPlugin () ;
 		$this->name = 'scmsvn';
 		$this->text = 'SVN';
+		$this->hooks[] = 'scm_browser_page';
 		$this->hooks[] = 'scm_generate_snapshots' ;
 		$this->hooks[] = 'scm_gather_stats' ;
 
@@ -47,7 +48,7 @@
 		return $this->default_svn_server ;
 	}
 
-	function echoShortStats ($params) {
+	function printShortStats ($params) {
 		$project = $this->checkParams ($params) ;
 		if (!$project) {
 			return false ;
@@ -104,12 +105,12 @@
 		return ;
 	}
 
-	function getBrowserBlock ($project) {
+	function getBrowserLinkBlock ($project) {
 		global $HTML ;
 		$b = $HTML->boxMiddle(_('Subversion Repository Browser'));
 		$b .= _('<p>Browsing the Subversion tree gives you a view into the current status of this project\'s code. You may also view the complete histories of any file in the repository.</p>');
 		$b .= '<p>[' ;
-		$b .= util_make_link ("/scm/viewvc.php/?root=".$project->getUnixName(),
+		$b .= util_make_link ("/scm/browser.php?group_id=".$project->getID(),
 				      _('Browse Subversion Repository')
 			) ;
 		$b .= ']</p>' ;
@@ -119,17 +120,17 @@
 	function getStatsBlock ($project) {
 		global $HTML ;
 		$b = '' ;
-		
+
 		$result = db_query_params('SELECT u.realname, u.user_name, u.user_id, sum(commits) as commits, sum(adds) as adds, sum(adds+commits) as combined FROM stats_cvs_user s, users u WHERE group_id=$1 AND s.user_id=u.user_id AND (commits>0 OR adds >0) GROUP BY u.user_id, realname, user_name, u.user_id ORDER BY combined DESC, realname',
 					  array ($project->getID()));
 		
 		if (db_numrows($result) > 0) {
-			$b .= $HTML->boxMiddle(_('Repository Statistics')) ;
+			$b .= $HTML->boxMiddle(_('Repository Statistics'));
 
 			$tableHeaders = array(
 				_('Name'),
 				_('Adds'),
-				_('Updates')
+				_('Commits')
 				);
 			$b .= $HTML->listTableTop($tableHeaders);
 			
@@ -146,35 +147,10 @@
 				$total['commits'] += $data['commits'];
 				$i++;
 			}
-
-			$res2 = db_query("
-			SELECT SUM(commits) AS commits, SUM(adds) AS adds
-			FROM stats_cvs_group
-			WHERE group_id='$group_id'");
-			$commit_num = db_result($res2,0,0);
-			$add_num = db_result($res2,0,1);
-			if (!$commit_num) {
-				$commit_num=0;
-			}
-			if (!$add_num) {
-				$add_num=0;
-			}
-			if ($commit_num > $total['commits'] ||
-			    $add_num > $total['adds']) {
-				$b .= '<tr '. $HTML->boxGetAltRowStyle($i) .'>';
-				$b .= '<td width="50%">' .
-					_('Unknown') .
-					'</td><td width="25%" align="right">'.
-					($add_num - $total['adds']) . '</td>'.
-					'<td width="25%" align="right">'.
-					($commit_num - $total['commits']) .
-					'</td></tr>';
-				$i++;
-			}
 			$b .= '<tr '. $HTML->boxGetAltRowStyle($i) .'>';
 			$b .= '<td width="50%"><strong>'._('Total').':</strong></td>'.
-				'<td width="25%" align="right"><strong>'.$add_num. '</strong></td>'.
-				'<td width="25%" align="right"><strong>'.$commit_num.'</strong></td>';
+				'<td width="25%" align="right"><strong>'.$total['adds']. '</strong></td>'.
+				'<td width="25%" align="right"><strong>'.$total['commits'].'</strong></td>';
 			$b .= '</tr>';
 			$b .= $HTML->listTableBottom();
 			$b .= '<hr size="1" />';
@@ -183,6 +159,21 @@
 		return $b ;
 	}
 
+	function printBrowserPage ($params) {
+		global $HTML;
+
+		$project = $this->checkParams ($params) ;
+		if (!$project) {
+			return false ;
+		}
+		
+		if ($project->usesPlugin ($this->name)) {
+			if ($this->browserDisplayable ($project)) {
+				print '<iframe src="'.util_make_url ("/scm/viewvc.php/?root=".$project->getUnixName()).'" frameborder="no" width=100% height=700></iframe>' ;
+			}
+		}
+	}
+
 	function createOrUpdateRepo ($params) {
 		$project = $this->checkParams ($params) ;
 		if (!$project) {

Added: trunk/gforge_base/evolvisforge-5.1/gforge/www/scm/browser.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/www/scm/browser.php	                        (rev 0)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/www/scm/browser.php	2011-02-28 01:51:06 UTC (rev 13627)
@@ -0,0 +1,41 @@
+<?php
+/**
+ * GForge SCM Frontend
+ *
+ * Copyright 2004, GForge LLC
+ * Copyright 2004-2009, Roland Mas
+ *
+ * @author Tim Perdue tim at gforge.org
+ * @date 2004-05-19
+ *
+ * This file is part of GForge.
+ *
+ * GForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * GForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+require_once('../env.inc.php');
+require_once $gfwww.'include/pre.php';    
+require_once $gfwww.'scm/include/scm_utils.php';    
+
+$group_id = getIntFromRequest("group_id");
+scm_header(array('title'=>_('SCM Repository'),'group'=>$group_id));
+
+$hook_params = array () ;
+$hook_params['group_id'] = $group_id ;
+plugin_hook ("scm_browser_page", $hook_params) ;
+
+scm_footer(); 
+
+?>

Modified: trunk/gforge_base/evolvisforge-5.1/gforge/www/scm/viewvc.php
===================================================================
--- trunk/gforge_base/evolvisforge-5.1/gforge/www/scm/viewvc.php	2011-02-28 01:50:55 UTC (rev 13626)
+++ trunk/gforge_base/evolvisforge-5.1/gforge/www/scm/viewvc.php	2011-02-28 01:51:06 UTC (rev 13627)
@@ -135,8 +135,7 @@
 			$content = mb_convert_encoding($content, 'UTF-8', $encoding);
 		}
 	}
-	scm_header(array('title'=>_('SCM Repository'),
-		'group'=>$Group->getID()));
+	// scm_header(array('title'=>_('SCM Repository'), 'group'=>$Group->getID()));
 
 	echo $content;
 	scm_footer(array());



More information about the evolvis-commits mailing list