[Fusionforge-commits] r7269 - in trunk/gforge: common/include db www/include www/project/admin www/softwaremap www/themes/css

Alain Peyrat aljeux at libremir.placard.fr.eu.org
Fri Mar 27 22:44:53 CET 2009


Author: aljeux
Date: 2009-03-27 22:44:53 +0100 (Fri, 27 Mar 2009)
New Revision: 7269

Added:
   trunk/gforge/common/include/tag_cloud.php
   trunk/gforge/db/20090327_create_table_project_tags.sql
   trunk/gforge/www/softwaremap/tag_cloud.php
Modified:
   trunk/gforge/common/include/Group.class.php
   trunk/gforge/db/gforge.sql
   trunk/gforge/www/include/features_boxes.php
   trunk/gforge/www/include/project_home.php
   trunk/gforge/www/include/trove.php
   trunk/gforge/www/project/admin/editgroupinfo.php
   trunk/gforge/www/project/admin/index.php
   trunk/gforge/www/softwaremap/full_list.php
   trunk/gforge/www/softwaremap/index.php
   trunk/gforge/www/softwaremap/trove_list.php
   trunk/gforge/www/themes/css/gforge.css
Log:
Add a tag cloud system to classify projects

Modified: trunk/gforge/common/include/Group.class.php
===================================================================
--- trunk/gforge/common/include/Group.class.php	2009-03-27 17:56:00 UTC (rev 7268)
+++ trunk/gforge/common/include/Group.class.php	2009-03-27 21:44:53 UTC (rev 7269)
@@ -465,11 +465,20 @@
 	 *	update - Update number of common properties.
 	 *
 	 *	Unlike updateAdmin(), this function accessible to project admin.
+	 *
+	 *	@param	object	User requesting operation (for access control).
+	 *	@param	bool	Whether group is publicly accessible (0/1).
+	 *	@param	string	Project's license (string ident).
+	 *	@param	int		Group type (1-project, 2-foundry).
+	 *	@param	string	Machine on which group's home directory located.
+	 *	@param	string	Domain which serves group's WWW.
+	 *	@return int	status.
+	 *	@access public.
 	 */
 	function update(&$user, $group_name,$homepage,$short_description,$use_mail,$use_survey,$use_forum,
-			$use_pm,$use_pm_depend_box,$use_scm,$use_news,$use_docman,
-			$new_doc_address,$send_all_docs,$logo_image_id,
-			$use_ftp,$use_tracker,$use_frs,$use_stats,$is_public) {
+		$use_pm,$use_pm_depend_box,$use_scm,$use_news,$use_docman,
+		$new_doc_address,$send_all_docs,$logo_image_id,
+		$use_ftp,$use_tracker,$use_frs,$use_stats,$tags,$is_public) {
 
 		$perm =& $this->getPermission($user);
 
@@ -598,6 +607,11 @@
 			return false;
 		}
 
+		if ($this->setTags($tags) === false) {
+			db_rollback();
+			return false;
+		}
+
 		$hook_params = array ();
 		$hook_params['group'] = $this;
 		$hook_params['group_id'] = $this->getID();
@@ -1247,6 +1261,60 @@
 	}
 
 	/**
+	 *	getTags - Tags of this project.
+	 *
+	 *	@return	string	List of tags.
+	 */
+	function getTags() {
+		$sql = 'SELECT name FROM project_tags WHERE group_id = $1';
+		$res = db_query_params($sql, array($this->getID()));
+		return join(', ', util_result_column_to_array($res));
+	}
+
+	/**
+	 *	setTags - Set tags of this project.
+	 *
+	 *	@return	string	database result.
+	 */
+	function setTags($tags) {
+		global $Language;
+
+		db_begin();
+		$sql='DELETE FROM project_tags WHERE group_id=$1';
+		$res=db_query_params($sql, array($this->getID()));
+		if (!$res) {
+			$this->setError('Deleting old tags: '.db_error());
+			db_rollback();
+			return false;
+		}
+		$inserted = array();
+		$tags_array = split('[;,]', $tags);
+		foreach ($tags_array as $tag) {
+			$tag = stripslashes($tag);
+			$tag = preg_replace('/[\t\r\n]/', ' ', $tag);
+			// Allowed caracteres: [A-Z][a-z][0-9] -_&'#+.
+			if (preg_match('/[^[:alnum:]| |\-|_|\&|\'|#|\+|\.]/', $tag)) {
+				$this->setError(_('Bad tag name, you only can use the following characters: [A-Z][a-z][0-9]-_&\'#+. and space'));
+				db_rollback();
+				return false;
+			}
+			$tag = trim($tag);
+			$tag = addslashes($tag);
+			if ($tag == '' || array_search($tag, $inserted) !== false) continue;
+			$sql='INSERT INTO project_tags (group_id,name) VALUES ($1, $2)';
+			$res=db_query_params($sql, array($this->getID(), $tag));
+			if (!$res) {
+				$this->setError(_('Setting tags: ').db_error());
+				db_rollback();
+				return false;
+			}
+			$inserted[] = $tag;
+		}
+		db_commit();
+		return true;
+	}
+
+	/**
 	 *	getPermission - Return a Permission for this Group and the specified User.
 	 *
 	 *	@param	object	The user you wish to get permission for (usually the logged in user).

Added: trunk/gforge/common/include/tag_cloud.php
===================================================================
--- trunk/gforge/common/include/tag_cloud.php	                        (rev 0)
+++ trunk/gforge/common/include/tag_cloud.php	2009-03-27 21:44:53 UTC (rev 7269)
@@ -0,0 +1,170 @@
+<?php
+/*
+ * Copyright (C) 2008-2009 Alcatel-Lucent
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge 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.
+ * 
+ * FusionForge 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 FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+/*
+ * Standard Alcatel-Lucent disclaimer for contributing to open source
+ *
+ * "The Tag Cloud ("Contribution") has not been tested and/or
+ * validated for release as or in products, combinations with products or
+ * other commercial use. Any use of the Contribution is entirely made at
+ * the user's own responsibility and the user can not rely on any features,
+ * functionalities or performances Alcatel-Lucent has attributed to the
+ * Contribution.
+ *
+ * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
+ * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
+ * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
+ * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
+ * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
+ * ALONE BASIS."
+ */
+
+$NB_MAX = 20;
+$NB_SIZE = 5;
+$CLASS_PREFIX = 'tag';
+$SELECTED_STYLE = 'style="text-decoration:overline underline;"';
+
+/**
+ * tag_cloud() - This function displays a tag cloug with the tags defined by projects.
+ * 				 The size of each tag depends of its frequency.
+ * 				 Each tag is a link to display a list of projects where the tag is defined.
+ * 				 Delta between two font sizes is constant :
+ * 				 function is F(count) = size = A * count + B
+ * 				 If:
+ * 				 Smin = size min
+ *               Smax = size max
+ *				 Cmin = count min
+ * 				 Cmax = count max
+ * 				 So:
+ * 				 Smin = A * Cmin + B
+ * 				 Smax = A * Cmax + B
+ * 				 A = (Smax - Smin) / (Cmax - Cmin)
+ * 				 B = Smin - A * Cmin
+ * 				 If Smin = 1 then Smax = number of size = N
+ * 				 So:
+ * 				 A = (N - 1) / (Cmax - Cmin)
+ * 				 B = 1 - A * Cmin
+ * 				 F(count) = size = A * count + 1 - A * Cmin
+ * 				 => size = 1 + (count  - Cmin) * A
+ * 
+ * @param		array	selected tag, max tag displayed, number of sizes available,
+ * 						class prefix for css class, style for selected tag
+ */
+function tag_cloud($params = '') {
+	global $NB_SIZE;
+	global $NB_MAX;
+	global $CLASS_PREFIX;
+	global $SELECTED_STYLE;
+
+	if (! is_array($params)) $parames = array();
+	if (! isset($params['selected'])) {
+		$params['selected'] = '';
+	}
+	if (! isset($params['nb_max'])) {
+		$params['nb_max'] = $NB_MAX;
+	}
+	if (! isset($params['nb_size'])) {
+		$params['nb_size'] = $NB_SIZE;
+	}
+	if (! isset($params['class_prefix'])) {
+		$params['class_prefix'] = $CLASS_PREFIX;
+	}
+	if (! isset($params['selected_style'])) {
+		$params['selected_style'] = $SELECTED_STYLE;
+	}
+
+	$return = '';
+
+	$res = db_query("SELECT name,count(*) AS count
+					 FROM project_tags, groups
+					 WHERE project_tags.group_id = groups.group_id
+					 AND status = 'A' AND is_public=1 AND type_id=1 AND register_time > 0
+					 GROUP BY name ORDER BY count DESC");
+	if (db_numrows($res) > 0) {
+		$count_min = 0;
+		$count_max = 0;
+		$nb = 1;
+		// Search upper and lower tag frequencies; stop when maximum tag number to display is reached
+		while ($row = db_fetch_array($res)) {
+			$tag_count[$row['name']] = $row['count'];
+			if ($count_min == 0 || $row['count'] < $count_min) $count_min = $row['count'];
+			if ($row['count'] > $count_max) $count_max = $row['count'];
+			if ($nb >= $params['nb_max']) break;
+			$nb++;
+		}
+
+		// Compute 'A' parameter of the function
+		if ($count_max != $count_min) // else we have a division by zero
+		{
+			$a = ($params['nb_size'] - 1) / ($count_max - $count_min);
+		}
+		else {
+			// Set value 0 for 'A' parameter just for initialised variable
+			// but it's not realy necessary because if $count_max == $count_min
+			// then $count - $count_min = 0 (see below)
+			$a = 0;
+		}
+
+		ksort($tag_count, SORT_STRING);
+		foreach ($tag_count as $name => $count) {
+			$size = intval(1 + ($count - $count_min) * $a);
+			$return .= '<a href="/softwaremap/tag_cloud.php?tag='
+			. urlencode($name)
+			. '" class="' . $params['class_prefix'] . $size . '" '
+			. (($name == $params['selected']) ? $params['selected_style'] : '' )
+			. '>' . htmlspecialchars($name) . '</a> ';
+		}
+	}
+
+	return $return;
+}
+
+/**
+ * list_project_tag() - Returns the list of the tags defined by the project.
+ * 						Each tag is a link to display a list of projects
+ * 						where the tag is defined.
+ *
+ * @param		int		Group ID
+ */
+function list_project_tag($group_id) {
+	$req = 'SELECT name FROM project_tags WHERE group_id = $1';
+	$res = db_query_params($req, array($group_id));
+	$nb_tag = db_numrows($res);
+	$return = '';
+	$idx = 1;
+	if ($nb_tag) {
+		while ($row = db_fetch_array($res)) {
+			$return .= '<a href="/softwaremap/tag_cloud.php?tag='
+					. urlencode($row['name'])
+					. '">' . htmlspecialchars($row['name']) . '</a>' . (($idx < $nb_tag) ? ', ' : '');
+			$idx++;
+		}
+	}
+
+	return $return;
+}
+
+?>


Property changes on: trunk/gforge/common/include/tag_cloud.php
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/gforge/db/20090327_create_table_project_tags.sql
===================================================================
--- trunk/gforge/db/20090327_create_table_project_tags.sql	                        (rev 0)
+++ trunk/gforge/db/20090327_create_table_project_tags.sql	2009-03-27 21:44:53 UTC (rev 7269)
@@ -0,0 +1,10 @@
+--
+-- Create table for project's tags
+--
+
+CREATE TABLE project_tags
+(
+   group_id integer NOT NULL, 
+   name text NOT NULL
+) WITH OIDS;
+

Modified: trunk/gforge/db/gforge.sql
===================================================================
--- trunk/gforge/db/gforge.sql	2009-03-27 17:56:00 UTC (rev 7268)
+++ trunk/gforge/db/gforge.sql	2009-03-27 21:44:53 UTC (rev 7269)
@@ -2731,7 +2731,13 @@
 );
 
 
+CREATE TABLE project_tags
+(
+   group_id integer NOT NULL,
+   name text NOT NULL
+) WITH OIDS;
 
+
 CREATE VIEW activity_vw AS
     (((SELECT agl.group_id, 'trackeropen'::text AS section, agl.group_artifact_id AS ref_id, a.artifact_id AS subref_id, a.summary AS description, a.open_date AS activity_date, u.user_id, u.user_name, u.realname FROM (artifact_group_list agl JOIN artifact a USING (group_artifact_id)), users u WHERE (u.user_id = a.submitted_by) UNION SELECT agl.group_id, 'trackerclose'::text AS section, agl.group_artifact_id AS ref_id, a.artifact_id AS subref_id, a.summary AS description, a.close_date AS activity_date, u.user_id, u.user_name, u.realname FROM (artifact_group_list agl JOIN artifact a USING (group_artifact_id)), users u WHERE ((u.user_id = a.assigned_to) AND (a.close_date > 0))) UNION SELECT agl.group_id, 'commit'::text AS section, agl.group_artifact_id AS ref_id, a.artifact_id AS subref_id, pcdm.log_text AS description, pcdm.cvs_date AS activity_date, u.user_id, u.user_name, u.realname FROM (artifact_group_list agl JOIN artifact a USING (group_artifact_id)), plugin_cvstracker_data_master pcdm, plugin_cvstracker_data_artifact pcda, users u WHERE (((pcdm.holder_id = pcda.id) AND (pcda.group_artifact_id = a.artifact_id)) AND (u.user_name = pcdm.author))) UNION SELECT frsp.group_id, 'frsrelease'::text AS section, frsp.package_id AS ref_id, frsr.release_id AS subref_id, frsr.name AS description, frsr.release_date AS activity_date, u.user_id, u.user_name, u.realname FROM (frs_package frsp JOIN frs_release frsr USING (package_id)), users u WHERE (u.user_id = frsr.released_by)) UNION SELECT fgl.group_id, 'forumpost'::text AS section, fgl.group_forum_id AS ref_id, forum.msg_id AS subref_id, forum.subject AS description, forum.post_date AS activity_date, u.user_id, u.user_name, u.realname FROM (forum_group_list fgl JOIN forum USING (group_forum_id)), users u WHERE (u.user_id = forum.posted_by);
 

Modified: trunk/gforge/www/include/features_boxes.php
===================================================================
--- trunk/gforge/www/include/features_boxes.php	2009-03-27 17:56:00 UTC (rev 7268)
+++ trunk/gforge/www/include/features_boxes.php	2009-03-27 21:44:53 UTC (rev 7269)
@@ -10,12 +10,17 @@
 //require_once('../env.inc.php');
 //require_once('pre.php');
 require_once $gfcommon.'include/FusionForge.class.php';
+require_once $gfcommon.'include/tag_cloud.php';
 
 function show_features_boxes() {
 	GLOBAL $HTML,$sys_use_ratings;
 	
 	$return = '';
-	$return .= $HTML->boxTop(sprintf(_('%1$s Statistics'), $GLOBALS['sys_name']),0);
+	$return .= $HTML->boxTop(_('Tag Cloud'));
+	$return .= '<center>';
+	$return .= tag_cloud();
+	$return .= '</center>';
+	$return .= $HTML->boxMiddle(sprintf(_('%1$s Statistics'), $GLOBALS['sys_name']),0);
 	$return .= show_sitestats();
 	$return .= $HTML->boxMiddle(_('Top Project Downloads'));
 	$return .= show_top_downloads();

Modified: trunk/gforge/www/include/project_home.php
===================================================================
--- trunk/gforge/www/include/project_home.php	2009-03-27 17:56:00 UTC (rev 7268)
+++ trunk/gforge/www/include/project_home.php	2009-03-27 21:44:53 UTC (rev 7269)
@@ -12,6 +12,7 @@
 require_once $gfwww.'news/news_utils.php';
 require_once $gfwww.'include/trove.php';
 require_once $gfwww.'include/project_summary.php';
+require_once $gfcommon.'include/tag_cloud.php';
 
 $title = _('Project Info');
 
@@ -51,6 +52,24 @@
 	print "<p>" . _('This project has not yet submitted a description.') . '</p>';
 }
 
+print "<br />\n";
+
+// Tag list
+$list_tag = list_project_tag($group_id);
+if ($list_tag) {
+	print '<p>' . _('Tags').':&nbsp;'. $list_tag . '</p>';
+}
+else {
+	$project =& group_get_object($group_id);
+	$perm =& $project->getPermission(session_get_user());
+	if ($perm->isAdmin()) {
+		print '<p><a href="/project/admin/editgroupinfo.php?group_id=' . $group_id . '" >' . _('No tag defined for this project') . '</a>.</p>';
+	}
+	else {
+		print '<p>' . _('No tag defined for this project') . '</p>';
+	}
+}
+
 if($GLOBALS['sys_use_trove']) {
 	print "<br />\n";
 	print stripslashes(trove_getcatlisting($group_id,0,1,1));

Modified: trunk/gforge/www/include/trove.php
===================================================================
--- trunk/gforge/www/include/trove.php	2009-03-27 17:56:00 UTC (rev 7268)
+++ trunk/gforge/www/include/trove.php	2009-03-27 21:44:53 UTC (rev 7269)
@@ -220,6 +220,7 @@
  * @param		int		The group ID
  * @param		bool	Whether filters have already been applied
  * @param		bool	Whether to print category links
+ * @param		bool	???
  */
 function trove_getcatlisting($group_id,$a_filter,$a_cats,$a_complete) {
 	global $discrim_url;

Modified: trunk/gforge/www/project/admin/editgroupinfo.php
===================================================================
--- trunk/gforge/www/project/admin/editgroupinfo.php	2009-03-27 17:56:00 UTC (rev 7268)
+++ trunk/gforge/www/project/admin/editgroupinfo.php	2009-03-27 21:44:53 UTC (rev 7269)
@@ -57,7 +57,8 @@
 	$use_tracker = getStringFromRequest('use_tracker');
 	$use_frs = getStringFromRequest('use_frs');
 	$use_stats = getStringFromRequest('use_stats');
-	$is_public = getStringFromRequest('is_public');
+	$tags = getStringFromRequest('form_tags');
+	$is_public = getIntFromRequest('is_public');
 	$new_doc_address = getStringFromRequest('new_doc_address');
 	$send_all_docs = getStringFromRequest('send_all_docs');
   
@@ -81,6 +82,7 @@
 		$use_tracker,
 		$use_frs,
 		$use_stats,
+		$tags,
 		$is_public
 	);
 	
@@ -124,12 +126,17 @@
 
 <p>
 <?php echo _('Short Description (255 Character Max, HTML will be stripped from this description)') ?>:<br />
-<textarea cols="80" rows="3" wrap="virtual" name="form_shortdesc">
+<textarea cols="80" rows="3" name="form_shortdesc">
 <?php echo $group->getDescription(); ?>
 </textarea>
 </p>
 
 <p>
+<?php echo _('Tags') ?>:<br />
+<input type="text" name="form_tags" size="100" value="<?php echo $group->getTags(); ?>" />
+</p>
+
+<p>
 <?php echo _('Homepage Link') ?>:<br />
 <tt>http://</tt><input type="text" name="form_homepage" size="40" value="<?php echo $group->getHomePage(); ?>" />
 </p>

Modified: trunk/gforge/www/project/admin/index.php
===================================================================
--- trunk/gforge/www/project/admin/index.php	2009-03-27 17:56:00 UTC (rev 7268)
+++ trunk/gforge/www/project/admin/index.php	2009-03-27 21:44:53 UTC (rev 7269)
@@ -198,7 +198,11 @@
 	<p>[ <?php echo util_make_link ('/tarballs.php?group_id='.$group_id,_('Download Your Nightly SCM Tree Tarball')) ?> ]</p>
 <?php	} ?>
 
-<hr />
+<p>
+<?php echo _('Tags') ?>:&nbsp;
+<?php echo $group->getTags(); ?>
+</p>
+
 <?php	if($sys_use_trove) { ?>
 <p>
 <h4><?php echo _('Trove Categorization:&nbsp;') ?><?php echo util_make_link ('/project/admin/group_trove.php?group_id='. $group->getID(),'['._('Edit').']'); ?></h4>

Modified: trunk/gforge/www/softwaremap/full_list.php
===================================================================
--- trunk/gforge/www/softwaremap/full_list.php	2009-03-27 17:56:00 UTC (rev 7268)
+++ trunk/gforge/www/softwaremap/full_list.php	2009-03-27 21:44:53 UTC (rev 7269)
@@ -54,10 +54,12 @@
 
 echo ($HTML->subMenu(
 		array(
+			_('Tag cloud'),
 			_('Project Tree'),
 			_('Project List')
 		),
 		array(
+			'/softwaremap/tag_cloud.php',
 			'/softwaremap/trove_list.php',
 			'/softwaremap/full_list.php'
 		)
@@ -138,7 +140,7 @@
 		// extra description
 		print '</td></tr><tr valign="top"><td>';
 		// list all trove categories
-		print trove_getcatlisting($row_grp['group_id'],0,1);
+		print trove_getcatlisting($row_grp['group_id'],0,1,0);
 		print '</td>';
 		print '<td align="right"><br />Register Date: <strong>'.date(_('Y-m-d H:i'),$row_grp['register_time']).'</strong></td>';
 		print '</tr>';

Modified: trunk/gforge/www/softwaremap/index.php
===================================================================
--- trunk/gforge/www/softwaremap/index.php	2009-03-27 17:56:00 UTC (rev 7268)
+++ trunk/gforge/www/softwaremap/index.php	2009-03-27 21:44:53 UTC (rev 7269)
@@ -9,6 +9,6 @@
   *
   */
 
-header('Location: trove_list.php');
+header('Location: tag_cloud.php');
 
 ?>

Added: trunk/gforge/www/softwaremap/tag_cloud.php
===================================================================
--- trunk/gforge/www/softwaremap/tag_cloud.php	                        (rev 0)
+++ trunk/gforge/www/softwaremap/tag_cloud.php	2009-03-27 21:44:53 UTC (rev 7269)
@@ -0,0 +1,191 @@
+<?php
+/*
+ * Copyright (C) 2008-2009 Alcatel-Lucent
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge 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.
+ *
+ * FusionForge 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
+*/
+
+/*
+ * Standard Alcatel-Lucent disclaimer for contributing to open source
+ *
+ * "The Tag Cloud ("Contribution") has not been tested and/or
+ * validated for release as or in products, combinations with products or
+ * other commercial use. Any use of the Contribution is entirely made at
+ * the user's own responsibility and the user can not rely on any features,
+ * functionalities or performances Alcatel-Lucent has attributed to the
+ * Contribution.
+ *
+ * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
+ * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
+ * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
+ * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
+ * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
+ * ALONE BASIS."
+ */
+
+require_once('../env.inc.php');
+require_once $gfwww.'include/pre.php';
+require_once $gfwww.'include/trove.php';
+require_once $gfcommon.'include/tag_cloud.php';
+
+$HTML->header(array('title'=>_('Software Map'),'pagename'=>'softwaremap'));
+
+echo ($HTML->subMenu(
+	array(
+		_('Tag cloud'),
+		_('Project Tree'),
+		_('Project List')
+		),
+	array(
+		'/softwaremap/tag_cloud.php',
+		'/softwaremap/trove_list.php',
+		'/softwaremap/full_list.php'
+		)
+	));
+
+$selected_tag = getStringFromRequest('tag');
+$page = getIntFromRequest('page', 1);
+
+echo '<br /><center>' . tag_cloud(array('selected' => $selected_tag, 'nb_max' => 100)) . '</center><br /><br />';
+
+if ($selected_tag) {
+
+	$cond_rq = '';
+	$res_grp = db_query_params('
+		SELECT groups.group_id, group_name, unix_group_name, short_description, register_time
+		FROM project_tags, groups
+		WHERE name = $1
+		AND project_tags.group_id = groups.group_id
+		AND status = $2 AND is_public=1 AND type_id=1 AND register_time > 0
+		ORDER BY group_name ASC', 
+		array($selected_tag, 'A'), $TROVE_HARDQUERYLIMIT);
+	$querytotalcount = db_numrows($res_grp);
+	if ($querytotalcount > 0) {
+		while ($group = db_fetch_array($res_grp)) {
+			$groups[] = "'" . $group['group_id'] . "'";
+		}
+		$cond_rq = ' AND group_id IN (' . join(',', $groups) . ') ';
+		db_reset_result($res_grp);
+	}
+
+	echo db_error();
+
+	// #################################################################
+	// limit/offset display
+
+	// store this as a var so it can be printed later as well
+	$html_limit = '';
+	if ($querytotalcount == $TROVE_HARDQUERYLIMIT){
+		$html_limit .= sprintf(_('More than <strong>%1$s</strong> projects have <strong>%2$s</strong> as tag.'), $TROVE_HARDQUERYLIMIT, htmlspecialchars($selected_tag));
+	}
+	else {
+		$html_limit .= sprintf(_('<strong>%1$s</strong> projects in result set.'), $querytotalcount, htmlspecialchars($selected_tag));
+	}
+
+	// only display pages stuff if there is more to display
+	if ($querytotalcount > $TROVE_BROWSELIMIT) {
+		$html_limit .= ' Displaying '.$TROVE_BROWSELIMIT.' per page. Projects sorted by alphabetical order.<br />';
+
+		// display all the numbers
+		for ($i=1;$i<=ceil($querytotalcount/$TROVE_BROWSELIMIT);$i++) {
+			$html_limit .= ' ';
+			if ($page != $i) {
+				$html_limit .= '<a href="'.$_SERVER['PHP_SELF'];
+				$html_limit .= '?page='.$i;
+				$html_limit .= '">';
+			} else $html_limit .= '<strong>';
+			$html_limit .= '&lt;'.$i.'&gt;';
+			if ($page != $i) {
+				$html_limit .= '</a>';
+			} else $html_limit .= '</strong>';
+			$html_limit .= ' ';
+		}
+	}
+
+	print $html_limit."<hr />\n";
+
+	// #################################################################
+	// print actual project listings
+	// note that the for loop starts at 1, not 0
+	for ($i_proj=1;$i_proj<=$querytotalcount;$i_proj++) {
+		$row_grp = db_fetch_array($res_grp);
+
+		// check to see if row is in page range
+		if (($i_proj > (($page-1)*$TROVE_BROWSELIMIT)) && ($i_proj <= ($page*$TROVE_BROWSELIMIT))) {
+			$viewthisrow = 1;
+		} else {
+			$viewthisrow = 0;
+		}
+
+		if ($row_grp && $viewthisrow) {
+			print '<table border="0" cellpadding="0" width="100%">';
+			print '<tr valign="top"><td colspan="2">';
+			print "<a href=\"/projects/". strtolower($row_grp['unix_group_name']) ."/\"><strong>"
+			.$row_grp['group_name']."</strong></a> ";
+
+			if ($row_grp['short_description']) {
+				print "- " . $row_grp['short_description'];
+			}
+
+			// extra description
+			print '</td></tr>';
+			print '<tr valign="top"><td colspan="2">';
+			print _('Tags'). ':&nbsp;' . list_project_tag($row_grp['group_id']);
+			print '</td></tr>';
+			print '<tr valign="top"><td>';
+			// list all trove categories
+			print trove_getcatlisting($row_grp['group_id'],0,1,0);
+			print '</td>'."\n".'<td align="right">'; // now the right side of the display
+			$res = db_query_params('SELECT percentile, ranking
+					FROM project_weekly_metric
+					WHERE group_id=$1', array($row_grp['group_id']));
+			$nb_line = db_numrows($res);
+			if (! $nb_line) {
+				$percentile = 'N/A';
+				$ranking = 'N/A';
+			}
+			else {
+				$percentile = number_format(db_result($res, 0, 'percentile'));
+				$ranking = number_format(db_result($res, 0, 'ranking'));
+			}
+			print 'Activity Percentile: <strong>'. $percentile .'</strong>';
+			print '<br />Activity Ranking: <strong>'. $ranking .'</strong>';
+			print '<br />'._('Registered:&nbsp;').' <strong>'.date(_('Y-m-d H:i'),$row_grp['register_time']).'</strong>';
+			print '</td></tr>';
+			/*
+			 if ($row_grp['jobs_count']) {
+			 print '<tr><td colspan="2" align="center">'
+			 .'<a href="/people/?group_id='.$row_grp['group_id'].'">[This project needs help]</a></td></td>';
+			 }
+			 */
+			print '</table>';
+			print '<hr />';
+		} // end if for row and range chacking
+	}
+
+	// print bottom navigation if there are more projects to display
+	if ($querytotalcount > $TROVE_BROWSELIMIT) {
+		print $html_limit;
+	}
+}
+
+$HTML->footer(array());
+?>

Modified: trunk/gforge/www/softwaremap/trove_list.php
===================================================================
--- trunk/gforge/www/softwaremap/trove_list.php	2009-03-27 17:56:00 UTC (rev 7268)
+++ trunk/gforge/www/softwaremap/trove_list.php	2009-03-27 21:44:53 UTC (rev 7269)
@@ -22,8 +22,10 @@
 	exit_disabled();
 }
 
-$form_cat = intval(getIntFromRequest('form_cat'));
+$form_cat = getIntFromRequest('form_cat');
+$page = getIntFromRequest('page',1);
 
+
 // assign default. 18 is 'topic'
 if (!$form_cat) {
 	$form_cat = $default_trove_cat;
@@ -46,10 +48,12 @@
 
 echo ($HTML->subMenu(
 		array(
+			_('Tag cloud'),
 			_('Project Tree'),
 			_('Project List')
 		),
 		array(
+			'/softwaremap/tag_cloud.php',
 			'/softwaremap/trove_list.php',
 			'/softwaremap/full_list.php'
 		)
@@ -238,14 +242,6 @@
 // #################################################################
 // limit/offset display
 
-// no funny stuff with get vars
-
-$page = getStringFromRequest('page');
-
-if (!is_numeric($page)) {
-	$page = 1;
-}
-
 // store this as a var so it can be printed later as well
 $html_limit = '';
 if ($querytotalcount == $TROVE_HARDQUERYLIMIT){

Modified: trunk/gforge/www/themes/css/gforge.css
===================================================================
--- trunk/gforge/www/themes/css/gforge.css	2009-03-27 17:56:00 UTC (rev 7268)
+++ trunk/gforge/www/themes/css/gforge.css	2009-03-27 21:44:53 UTC (rev 7269)
@@ -367,5 +367,43 @@
 A.lnkutility:active { COLOR: #ffffff }
 A.lnkutility:hover { COLOR: #ffffff }
 
+/* For tag cloud */
+.tag1 {
+ outline-style: none;
+ font-size: 10px;
+ margin-left: 0.3em;
+ margin-right: 0.3em;
+}
 
+.tag2 {
+ outline-style: none;
+ font-size: 12px;
+ margin-left: 0.3em;
+ margin-right: 0.3em;
+}
 
+.tag3 {
+ outline-style: none;
+ font-size: 14px;
+ margin-left: 0.3em;
+ margin-right: 0.3em;
+}
+
+.tag4 {
+ outline-style: none;
+ font-size: 16px;
+ margin-left: 0.3em;
+ margin-right: 0.3em;
+}
+
+.tag5 {
+ outline-style: none;
+ font-size: 18px;
+ margin-left: 0.3em;
+ margin-right: 0.3em;
+}
+
+.develtitle {
+ font-weight: bold;
+}
+




More information about the Fusionforge-commits mailing list