[Fusionforge-commits] r13066 - in trunk/src: common/include plugins/oslc/include plugins/oslc/include/oslc-zend/application/controllers plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact plugins/oslc/www/css plugins/oslc/www/scripts www

Sabri LABBENE labbenes at fusionforge.org
Mon Apr 11 12:31:27 CEST 2011


Author: labbenes
Date: 2011-04-11 12:31:26 +0200 (Mon, 11 Apr 2011)
New Revision: 13066

Added:
   trunk/src/plugins/oslc/include/compactResource.class.php
   trunk/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/_compact_project_xml.php
   trunk/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-project-small.phtml
   trunk/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-project.phtml
   trunk/src/plugins/oslc/www/css/oslcTooltipStyle.css
   trunk/src/plugins/oslc/www/scripts/oslcTooltip.js
Removed:
   trunk/src/plugins/oslc/www/css/userTooltipStyle.css
   trunk/src/plugins/oslc/www/scripts/userTooltip.js
Modified:
   trunk/src/common/include/utils.php
   trunk/src/plugins/oslc/include/oslc-zend/application/controllers/CompactController.php
   trunk/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCompactController.php
   trunk/src/plugins/oslc/include/oslcPlugin.class.php
   trunk/src/www/projects
Log:
Display a project compact preview in oslc tooltips when a project link is hovered.

Modified: trunk/src/common/include/utils.php
===================================================================
--- trunk/src/common/include/utils.php	2011-04-08 20:52:31 UTC (rev 13065)
+++ trunk/src/common/include/utils.php	2011-04-11 10:31:26 UTC (rev 13066)
@@ -1145,7 +1145,8 @@
  * @return string
  */
 function util_display_user($username, $user_id,$text, $size='xs') {
-        $hook_params = array();
+	$hook_params = array();
+	$hook_params['resource_type'] = 'user';
         $hook_params['username'] = $username;
         $hook_params['user_id'] = $user_id;
         $hook_params['user_link'] = '';
@@ -1185,8 +1186,19 @@
  * @param string $text
  * @return string
  */
-function util_make_link_g ($groupame, $group_id,$text) {
-	return '<a href="' . util_make_url_g ($groupame, $group_id) . '">' . $text . '</a>' ;
+function util_make_link_g ($groupname, $group_id,$text) {
+	$hook_params =array();
+	$hook_params['resource_type']  = 'group';
+        $hook_params['group_name'] = $groupname;
+	$hook_params['group_id'] = $group_id;
+	$hook_params['link_text'] = $text;
+        $hook_params['group_link'] = '';
+        plugin_hook_by_reference('project_link_with_tooltip', $hook_params);
+        if($hook_params['group_link'] != '') {
+                return $hook_params['group_link'];
+        }
+
+	return '<a href="' . util_make_url_g ($groupname, $group_id) . '">' . $text . '</a>' ;
 }
 
 /**

Added: trunk/src/plugins/oslc/include/compactResource.class.php
===================================================================
--- trunk/src/plugins/oslc/include/compactResource.class.php	                        (rev 0)
+++ trunk/src/plugins/oslc/include/compactResource.class.php	2011-04-11 10:31:26 UTC (rev 13066)
@@ -0,0 +1,60 @@
+<?php 
+/**
+ * This file is (c) Copyright 2011 by Sabri LABBENE, Institut TELECOM
+ *
+ * This file is part of FusionForge.
+ *
+ * This program 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.
+ * 
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * This program has been developed in the frame of the HELIOS
+ * project with financial support of its funders.
+ *
+ */
+
+class compactResource {
+	public $params;
+	
+	public function __construct($params) {
+		$this->params = $params;
+	}
+	
+	public function getResourceLink() {
+		if($this->params['resource_type'] == 'user') {
+			return $this->getUserLink($this->params['username'], $this->params['user_id']);
+		} elseif($this->params['resource_type'] == 'group') {
+			return $this->getProjectLink($this->params['group_name'], $this->params['group_id'], $this->params['link_text']);
+		} elseif($this->params['resource_type'] == 'artifact') {
+			return $this->getArtifactLink();
+		} else {
+			return 'Unknown resource type !';
+		}
+	}
+	
+	public function getUserLink($username, $user_id) {
+		return '<a class="personPopupTrigger" href="'. util_make_url_u ($username, $user_id) .
+				'" rel="user,' . $username . '">'. $username . '</a>';
+	}	
+	
+	public function getProjectLink($group_name, $group_id, $link_text) {
+		return '<a class="personPopupTrigger" href="'. util_make_url_g ($group_name, $group_id) .
+				'" rel="project,' . $group_name . '">'. $link_text . '</a>';
+	}
+	
+	public function getArtifactLink() {
+		// TBD.
+	}
+} 
+
+?>
\ No newline at end of file

Modified: trunk/src/plugins/oslc/include/oslc-zend/application/controllers/CompactController.php
===================================================================
--- trunk/src/plugins/oslc/include/oslc-zend/application/controllers/CompactController.php	2011-04-08 20:52:31 UTC (rev 13065)
+++ trunk/src/plugins/oslc/include/oslc-zend/application/controllers/CompactController.php	2011-04-11 10:31:26 UTC (rev 13066)
@@ -33,7 +33,7 @@
 		'oslccompactuser' => array(
 			'application/x-oslc-compact+xml' => 'xml'
 		),
-		'oslccompactusersmall' => array(
+		'oslccompactproject' => array(
 			'application/x-oslc-compact+xml' => 'xml'
 		)
 	);

Modified: trunk/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCompactController.php
===================================================================
--- trunk/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCompactController.php	2011-04-08 20:52:31 UTC (rev 13065)
+++ trunk/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCompactController.php	2011-04-11 10:31:26 UTC (rev 13066)
@@ -87,6 +87,14 @@
 			$this->_forward('oslcCompactUser');
 			return;
 		}
+		if(isset($params['project']) && isset($params['type']) && $params['type'] == "small") {
+			$this->_forward('oslcCompactProjectSmall');
+			return;
+		}
+		if(isset($params['project']) && !isset($params['type'])) {
+			$this->_forward('oslcCompactProject');
+			return;
+		}
 	}
 	
 	/**
@@ -108,6 +116,24 @@
 	}
 	
 	/**
+	 * Enter description here ...
+	 */
+	public function oslccompactprojectAction() {
+		if (! isset($this->actionMimeType)) {
+			$this->_forward('UnknownAcceptType','error');
+			return;
+		}
+
+		$req = $this->getRequest();
+		$params = $req->getParams();
+		
+		$group_obj = group_get_object_by_name($params['project']);
+		$this->view->project = $group_obj;
+		
+		$this->getResponse()->setHeader('Content-Type', 'application/x-oslc-compact+xml');
+	}
+	
+	/**
 	 * TODO: Enter description here ...
 	 */
 	public function oslccompactusersmallAction() {
@@ -124,5 +150,20 @@
 
 		$this->getResponse()->setHeader('Content-Type', $this->actionMimeType);
 	}
+	
+	public function oslccompactprojectsmallAction() {
+		if (! isset($this->actionMimeType)) {
+			$this->_forward('UnknownAcceptType','error');
+			return;
+		}
+
+		$req = $this->getRequest();
+		$params = $req->getParams();
+		
+		$group_obj = group_get_object_by_name($params['project']);
+		$this->view->project = $group_obj;
+		
+		$this->getResponse()->setHeader('Content-Type', $this->actionMimeType);
+	}
 }
 ?>
\ No newline at end of file

Added: trunk/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/_compact_project_xml.php
===================================================================
--- trunk/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/_compact_project_xml.php	                        (rev 0)
+++ trunk/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/_compact_project_xml.php	2011-04-11 10:31:26 UTC (rev 13066)
@@ -0,0 +1,57 @@
+<?php 
+/**
+ * This file is (c) Copyright 2010 by Sabri LABBENE, Institut
+ * TELECOM
+ *
+ * This program 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.
+ * 
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * This program has been developed in the frame of the HELIOS
+ * project with financial support of its funders.
+ *
+ */
+$doc = new DOMDocument();
+$doc->formatOutput = true;
+
+$root = $doc->createElementNS("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf:RDF");
+$root = $doc->appendChild($root);
+$root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:dcterms', 'http://purl.org/dc/terms/');
+$root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:oslc', 'http://open-services.net/ns/core#');
+
+// oslc:Compact
+$Compact = $doc->createElement('oslc:Compact');
+$Compact->setAttribute("rdf:about", $this->serverUrl().'/plugins/oslc/compact/project/'. $this->project->getUnixName());
+
+$titlenode = $doc->createElement('dcterms:title', $this->project->getPublicName());
+$Compact->appendChild($titlenode);
+
+$short_title_node = $doc->createElement('oslc:shortTitle', $this->project->getUnixName());
+$Compact->appendChild($short_title_node);
+
+$smallPreview = $doc->createElement('oslc:smallPreview');
+$Preview = $doc->createElement('oslc:Preview');
+$Doc = $doc->createElement('oslc:document');
+$Doc->setAttribute('rdf:ressource', $this->serverUrl().'/plugins/oslc/compact/project/'. $this->project->getUnixName().'/type/small'); 
+$hintW = $doc->createElement('oslc:hintWidth', '500px');
+$hintH = $doc->createElement('oslc:hintHeight', '150px');
+$Preview->appendChild($Doc);
+$Preview->appendChild($hintW);
+$Preview->appendChild($hintH);
+$smallPreview->appendChild($Preview);
+$Compact->appendChild($smallPreview);
+
+$root->appendChild($Compact);
+echo $doc->saveXML();
+
+?>
\ No newline at end of file

Added: trunk/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-project-small.phtml
===================================================================
--- trunk/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-project-small.phtml	                        (rev 0)
+++ trunk/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-project-small.phtml	2011-04-11 10:31:26 UTC (rev 13066)
@@ -0,0 +1,94 @@
+<?php 
+/**
+ * This file is (c) Copyright 2010 by Sabri LABBENE, Institut
+ * TELECOM
+ *
+ * This program 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.
+ * 
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * This program has been developed in the frame of the HELIOS
+ * project with financial support of its funders.
+ *
+ */
+$public_name = $this->project->getPublicName();
+$unix_name = $this->project->getUnixName();
+$id = $this->project->getID();
+$home_page = $this->serverUrl(). '/projects/'. $unix_name;
+$description = $this->project->getDescription();
+$start_date = $this->project->getStartDate();
+$status = $this->project->getStatus();
+switch ($status){
+	case 'A':
+		$project_status = 'Active';
+		break;
+	case 'H':
+		$project_status = 'Hold';
+		break;
+	case 'P':
+		$project_status = 'Pending';
+		break;
+	case 'I':
+		$project_status = 'Incomplete';
+		break;
+	default:
+		break; 
+}
+if ($this->project->isPublic()) {
+	$public = 'Yes';
+} else {
+	$ublic = 'No';
+}
+
+
+?>
+
+<html>
+<head>
+<title>Project: <?php echo $public_name;?> (<?php echo $unix_name;?>)</title>
+</head>
+<body>
+<table>
+
+<tr>
+	<td colspan="2"><i>Project Compact Preview</i></td>
+</tr>
+<tr>
+	<td rowspan="8"><img src="/plugins/oslc/images/userTooltip/oslc.png" /> </td>
+	<td><b>Project name:</b> <?php echo $public_name;?></td>
+</tr>
+<tr>
+	<td><b>Project short name:</b> <?php echo $unix_name;?></td>
+</tr>
+<tr>
+	<td><b>Identifier:</b>  <?php echo $id;?></td>
+</tr>
+<tr>
+	<td><b>Started since:</b> <?php print date(_('Y-m-d H:i'), $start_date); ?></td>
+</tr>
+<tr>
+	<td><b>Status:</b>  <?php echo $project_status; ?></td>
+</tr>
+<tr>
+	<td><b>Is Public:</b>  <?php echo $public; ?></td>
+</tr>
+<tr>
+	<td><b>Description:</b>  <?php echo $description; ?></td>
+</tr>
+<tr>
+	<td><small><b>Home Page:</b> <a href="<?php echo $home_page;?>"><?php echo $home_page;?></a></small></td>
+</tr>
+
+</table>
+</body>
+</html>
\ No newline at end of file

Added: trunk/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-project.phtml
===================================================================
--- trunk/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-project.phtml	                        (rev 0)
+++ trunk/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-project.phtml	2011-04-11 10:31:26 UTC (rev 13066)
@@ -0,0 +1,25 @@
+<?php 
+/**
+ * This file is (c) Copyright 2010 by Sabri LABBENE, Institut
+ * TELECOM
+ *
+ * This program 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.
+ * 
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * This program has been developed in the frame of the HELIOS
+ * project with financial support of its funders.
+ *
+ */
+require_once '_compact_project_xml.php';
+?>
\ No newline at end of file

Modified: trunk/src/plugins/oslc/include/oslcPlugin.class.php
===================================================================
--- trunk/src/plugins/oslc/include/oslcPlugin.class.php	2011-04-08 20:52:31 UTC (rev 13065)
+++ trunk/src/plugins/oslc/include/oslcPlugin.class.php	2011-04-11 10:31:26 UTC (rev 13066)
@@ -35,10 +35,12 @@
 		$this->_addHook("userisactivecheckboxpost"); //
 		$this->_addHook("project_admin_plugins"); // to show up in the admin page fro group
 		$this->_addHook("user_link_with_tooltip"); 
+		$this->_addHook("project_link_with_tooltip");
 		$this->_addHook("javascript_file"); // Add js files for oslc plugin
 		$this->_addHook("cssfile");
 		$this->_addHook("script_accepted_types");
-		$this->_addHook("content_negociated_user_home");		
+		$this->_addHook("content_negociated_user_home");
+		$this->_addHook("content_negociated_project_home");		
 	}
 
 	function CallHook ($hookname, &$params) {
@@ -156,19 +158,25 @@
 			}
 		}
 		elseif ($hookname == "user_link_with_tooltip"){
-			$params['user_link'] = '<a class="personPopupTrigger" href="'. util_make_url_u ($params['username'], $params['user_id']) .
-				'" rel="' . $params['username'] . '">'. $params['username'] . '</a>';
+			require_once dirname( __FILE__ ) . '/compactResource.class.php';
+			$cR = new compactResource($params);
+			$params['user_link'] = $cR->getResourceLink();
 		}
+		elseif ($hookname == "project_link_with_tooltip") {
+			require_once dirname( __FILE__ ) . '/compactResource.class.php';
+			$cR = new compactResource($params);
+			$params['group_link'] = $cR->getResourceLink();			
+		}
 		elseif ($hookname == "javascript_file") {
 			use_javascript('/scripts/jquery/jquery.js');
-			use_javascript('/plugins/oslc/scripts/userTooltip.js');
+			use_javascript('/plugins/oslc/scripts/oslcTooltip.js');
 		}
 		elseif ($hookname == "cssfile") {
-			use_stylesheet('/plugins/oslc/css/userTooltipStyle.css');
+			use_stylesheet('/plugins/oslc/css/oslcTooltipStyle.css');
 		}
 		elseif($hookname == "script_accepted_types"){
 			$script = $params['script']; 
-			if ($script == 'user_home') { 
+			if ($script == 'user_home' || $script == 'project_home') { 
 				$params['accepted_types'][] = 'application/x-oslc-compact+xml'; 
 			} 
 		}
@@ -179,6 +187,13 @@
 				$params['return'] = '/plugins/oslc/compact/user/'.$username;
 			}
 		}
+		elseif($hookname == "content_negociated_project_home") {
+			$projectname = $params['groupname'];
+			$accept = $params['accept'];
+			if($accept == 'application/x-oslc-compact+xml') {
+				$params['return'] = '/plugins/oslc/compact/project/'.$projectname;
+			}
+		}
 		elseif ($hookname == "blahblahblah") {
 			// ...
 		} 

Copied: trunk/src/plugins/oslc/www/css/oslcTooltipStyle.css (from rev 13065, trunk/src/plugins/oslc/www/css/userTooltipStyle.css)
===================================================================
--- trunk/src/plugins/oslc/www/css/oslcTooltipStyle.css	                        (rev 0)
+++ trunk/src/plugins/oslc/www/css/oslcTooltipStyle.css	2011-04-11 10:31:26 UTC (rev 13066)
@@ -0,0 +1,64 @@
+#personPopupContainer
+{
+	position:absolute;
+	left:0;
+	top:0;
+	display:none;
+	z-index: 20000;
+}
+
+.personPopupPopup {
+}
+
+.personPopupResult {
+	background: #FFF;
+}
+
+#personPopupContent {
+	background: #FFF;
+	min-width: 175px;
+	min-height: 50px;
+}
+
+.personPopupPopup .personPopupImage {
+	margin: 5px;
+	margin-right: 15px;
+}
+
+.personPopupPopup .corner{
+	width: 19px;
+	height: 15px;
+}
+
+.personPopupPopup .topLeft {
+	background: url(/plugins/oslc/images/userTooltip/balloon_topLeft.png) no-repeat right;
+}
+
+.personPopupPopup .bottomLeft {
+	background: url(/plugins/oslc/images/userTooltip/balloon_bottomLeft.png) no-repeat right top;
+}
+
+.personPopupPopup .left {
+	background: url(/plugins/oslc/images/userTooltip/balloon_left.png) repeat-y right;
+}
+
+.personPopupPopup .right {
+	background: url(/plugins/oslc/images/userTooltip/balloon_right.png) repeat-y;
+}
+
+.personPopupPopup .topRight {
+	background: url(/plugins/oslc/images/userTooltip/balloon_topRight.png) no-repeat left;
+}
+
+.personPopupPopup .bottomRight {
+	background: url(/plugins/oslc/images/userTooltip/balloon_bottomRight.png) no-repeat;
+}  
+
+.personPopupPopup .top {
+	background: url(/plugins/oslc/images/userTooltip/balloon_top.png) repeat-x bottom;
+}
+
+.personPopupPopup .bottom {
+	background: url(/plugins/oslc/images/userTooltip/balloon_bottom.png) repeat-x;
+	text-align: center;  
+}
\ No newline at end of file

Deleted: trunk/src/plugins/oslc/www/css/userTooltipStyle.css
===================================================================
--- trunk/src/plugins/oslc/www/css/userTooltipStyle.css	2011-04-08 20:52:31 UTC (rev 13065)
+++ trunk/src/plugins/oslc/www/css/userTooltipStyle.css	2011-04-11 10:31:26 UTC (rev 13066)
@@ -1,64 +0,0 @@
-#personPopupContainer
-{
-	position:absolute;
-	left:0;
-	top:0;
-	display:none;
-	z-index: 20000;
-}
-
-.personPopupPopup {
-}
-
-.personPopupResult {
-	background: #FFF;
-}
-
-#personPopupContent {
-	background: #FFF;
-	min-width: 175px;
-	min-height: 50px;
-}
-
-.personPopupPopup .personPopupImage {
-	margin: 5px;
-	margin-right: 15px;
-}
-
-.personPopupPopup .corner{
-	width: 19px;
-	height: 15px;
-}
-
-.personPopupPopup .topLeft {
-	background: url(/plugins/oslc/images/userTooltip/balloon_topLeft.png) no-repeat right;
-}
-
-.personPopupPopup .bottomLeft {
-	background: url(/plugins/oslc/images/userTooltip/balloon_bottomLeft.png) no-repeat right top;
-}
-
-.personPopupPopup .left {
-	background: url(/plugins/oslc/images/userTooltip/balloon_left.png) repeat-y right;
-}
-
-.personPopupPopup .right {
-	background: url(/plugins/oslc/images/userTooltip/balloon_right.png) repeat-y;
-}
-
-.personPopupPopup .topRight {
-	background: url(/plugins/oslc/images/userTooltip/balloon_topRight.png) no-repeat;
-}
-
-.personPopupPopup .bottomRight {
-	background: url(/plugins/oslc/images/userTooltip/balloon_bottomRight.png) no-repeat;
-}  
-
-.personPopupPopup .top {
-	background: url(/plugins/oslc/images/userTooltip/balloon_top.png) repeat-x;
-}
-
-.personPopupPopup .bottom {
-	background: url(/plugins/oslc/images/userTooltip/balloon_bottom.png) repeat-x;
-	text-align: center;  
-}
\ No newline at end of file

Copied: trunk/src/plugins/oslc/www/scripts/oslcTooltip.js (from rev 13065, trunk/src/plugins/oslc/www/scripts/userTooltip.js)
===================================================================
--- trunk/src/plugins/oslc/www/scripts/oslcTooltip.js	                        (rev 0)
+++ trunk/src/plugins/oslc/www/scripts/oslcTooltip.js	2011-04-11 10:31:26 UTC (rev 13066)
@@ -0,0 +1,133 @@
+/**
+ * This file is (c) Copyright 2011 by Sabri LABBENE, Institut TELECOM
+ *
+ * This file is part of FusionForge.
+ *
+ * This program 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.
+ * 
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ * This program has been developed in the frame of the HELIOS
+ * project with financial support of its funders.
+ *
+ */
+
+jQuery(function(){  
+	var hideDelay = 500;    
+	var hideTimer = null;  
+
+	// One instance that's reused to show info for the current person  
+	var container = $('<div id="personPopupContainer">'  
+			+ '<table width="" border="0" cellspacing="0" cellpadding="0" class="personPopupPopup">'  
+			+ '<tr>'  
+			+ '   <td class="corner topLeft"></td>'  
+			+ '   <td class="top"></td>'  
+			+ '   <td class="corner topRight"></td>'  
+			+ '</tr>'  
+			+ '<tr>'  
+			+ '   <td class="left"> </td>'
+			+ '   <td class="personPopupResult"><div id="personPopupContent"></div></td>'  
+			+ '   <td class="right"> </td>'  
+			+ '</tr>'  
+			+ '<tr>'  
+			+ '   <td class="corner bottomLeft"> </td>'  
+			+ '   <td class="bottom"> </td>'  
+			+ '   <td class="corner bottomRight"></td>'  
+			+ '</tr>'  
+			+ '</table>'  
+			+ '</div>'
+	);  
+
+	jQuery('body').append(container);
+	
+	jQuery('.personPopupTrigger').live('mouseover', function() {
+		var params = jQuery(this).attr('rel').split(',');
+		var resourceType = params[0];
+		var resourceId = params[1];
+
+		if(resourceType == 'user') {
+			resource = 'users';
+		}
+		if(resourceType == 'project'){
+			resource = 'projects';
+		}
+
+		if (hideTimer) {
+			clearTimeout(hideTimer);  
+		}
+		var pos = jQuery(this).offset();
+		var width = jQuery(this).width();
+		container.css({  
+			left: (pos.left + width) + 'px',  
+			top: pos.top - 5 + 'px'  
+		});
+
+		jQuery('#personPopupContent').html(' ');
+
+		jQuery.ajax({  
+			type: 'GET',
+			url: '/'+ resource +'/' + resourceId + '/',
+			dataType: 'xml',
+			beforeSend: function(xhr) {
+				xhr.setRequestHeader("Accept","application/x-oslc-compact+xml");
+			},
+			success: function(data) { 
+				var smPreview = data.documentElement.getElementsByTagName('oslc:smallPreview')[0];
+				if( smPreview ) {
+					var Preview = smPreview.getElementsByTagName('oslc:Preview')[0];
+					if(Preview){
+						var oslcDoc = Preview.getElementsByTagName('oslc:document')[0];
+						if( oslcDoc ) {
+							var prevDocUrl = oslcDoc.getAttribute('rdf:ressource');
+							if( prevDocUrl ) {
+								jQuery('#personPopupContent').load(prevDocUrl);
+							}
+						}
+					}
+				}
+			}  
+		});  
+
+		container.css('display', 'block');  
+	});  
+
+	jQuery('.personPopupTrigger').live('mouseout', function() { 
+		if (hideTimer) { 
+			clearTimeout(hideTimer);
+		}
+		hideTimer = setTimeout(function() {  
+			container.css('display', 'none');  
+			}, 
+			hideDelay
+		);  
+	});
+
+	// Allow mouse over of details without hiding details  
+	jQuery('#personPopupContainer').mouseover(function() {  
+		if (hideTimer) { 
+			clearTimeout(hideTimer);
+		}
+	});  
+
+	// Hide after mouseout  
+	jQuery('#personPopupContainer').mouseout(function() {  
+		if (hideTimer){  
+			clearTimeout(hideTimer);
+		}
+		hideTimer = setTimeout(function() {  
+				container.css('display', 'none');  
+			},
+			hideDelay
+		);  
+	});  
+}); 
\ No newline at end of file

Deleted: trunk/src/plugins/oslc/www/scripts/userTooltip.js
===================================================================
--- trunk/src/plugins/oslc/www/scripts/userTooltip.js	2011-04-08 20:52:31 UTC (rev 13065)
+++ trunk/src/plugins/oslc/www/scripts/userTooltip.js	2011-04-11 10:31:26 UTC (rev 13066)
@@ -1,124 +0,0 @@
-/**
- * This file is (c) Copyright 2011 by Sabri LABBENE, Institut TELECOM
- *
- * This file is part of FusionForge.
- *
- * This program 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.
- * 
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- * This program has been developed in the frame of the HELIOS
- * project with financial support of its funders.
- *
- */
-
-jQuery(function(){  
-	var hideDelay = 500;    
-	var hideTimer = null;  
-
-	// One instance that's reused to show info for the current person  
-	var container = $('<div id="personPopupContainer">'  
-			+ '<table width="" border="0" cellspacing="0" cellpadding="0" class="personPopupPopup">'  
-			+ '<tr>'  
-			+ '   <td class="corner topLeft"></td>'  
-			+ '   <td class="top"></td>'  
-			+ '   <td class="corner topRight"></td>'  
-			+ '</tr>'  
-			+ '<tr>'  
-			+ '   <td class="left"> </td>'
-			+ '   <td class="personPopupResult"><div id="personPopupContent"></div></td>'  
-			+ '   <td class="right"> </td>'  
-			+ '</tr>'  
-			+ '<tr>'  
-			+ '   <td class="corner bottomLeft"> </td>'  
-			+ '   <td class="bottom"> </td>'  
-			+ '   <td class="corner bottomRight"></td>'  
-			+ '</tr>'  
-			+ '</table>'  
-			+ '</div>'
-	);  
-
-	jQuery('body').append(container);
-	
-	jQuery('.personPopupTrigger').live('mouseover', function() {  
-		var username = jQuery(this).attr('rel');
-
-		if (hideTimer) {
-			clearTimeout(hideTimer);  
-		}
-		var pos = jQuery(this).offset();
-		var width = jQuery(this).width();
-		container.css({  
-			left: (pos.left + width) + 'px',  
-			top: pos.top - 5 + 'px'  
-		});
-
-		jQuery('#personPopupContent').html(' ');  
-
-		jQuery.ajax({  
-			type: 'GET',
-			url: '/users/' + username,
-			dataType: 'xml',
-			beforeSend: function(xhr) {
-				xhr.setRequestHeader("Accept","application/x-oslc-compact+xml");
-			},
-			success: function(data) { 
-				var smPreview = data.documentElement.getElementsByTagName('oslc:smallPreview')[0];
-				if( smPreview ) {
-					var Preview = smPreview.getElementsByTagName('oslc:Preview')[0];
-					if(Preview){
-						var oslcDoc = Preview.getElementsByTagName('oslc:document')[0];
-						if( oslcDoc ) {
-							var prevDocUrl = oslcDoc.getAttribute('rdf:ressource');
-							if( prevDocUrl ) {
-								jQuery('#personPopupContent').load(prevDocUrl);
-							}
-						}
-					}
-				}
-			}  
-		});  
-
-		container.css('display', 'block');  
-	});  
-
-	jQuery('.personPopupTrigger').live('mouseout', function() { 
-		if (hideTimer) { 
-			clearTimeout(hideTimer);
-		}
-		hideTimer = setTimeout(function() {  
-			container.css('display', 'none');  
-			}, 
-			hideDelay
-		);  
-	});
-
-	// Allow mouse over of details without hiding details  
-	jQuery('#personPopupContainer').mouseover(function() {  
-		if (hideTimer) { 
-			clearTimeout(hideTimer);
-		}
-	});  
-
-	// Hide after mouseout  
-	jQuery('#personPopupContainer').mouseout(function() {  
-		if (hideTimer){  
-			clearTimeout(hideTimer);
-		}
-		hideTimer = setTimeout(function() {  
-				container.css('display', 'none');  
-			},
-			hideDelay
-		);  
-	});  
-}); 
\ No newline at end of file

Modified: trunk/src/www/projects
===================================================================
--- trunk/src/www/projects	2011-04-08 20:52:31 UTC (rev 13065)
+++ trunk/src/www/projects	2011-04-11 10:31:26 UTC (rev 13066)
@@ -37,6 +37,32 @@
 //
 //	test to see if the logger was successful in setting up the objects
 //
+
+$default_content_type = 'text/html';
+
+// Invoke plugins' hooks 'script_accepted_types' to discover which alternate content types they would accept for /users/...
+$hook_params = array();
+$hook_params['script'] = 'project_home';
+$hook_params['accepted_types'] = array();
+plugin_hook_by_reference('script_accepted_types', $hook_params);
+if(isset($hook_params['accepted_types'])){
+        // By default, text/html is accepted
+        $accepted_types = array($default_content_type);
+        $new_accepted_types = $hook_params['accepted_types'];
+        $accepted_types = array_merge($accepted_types, $new_accepted_types);
+        
+        // PEAR::HTTP (for negotiateMimeType())
+        require_once('HTTP.php');
+
+        // negociate accepted content-type depending on the preferred ones declared by client
+        $http=new HTTP();
+        $content_type = $http->negotiateMimeType($accepted_types,'text/html');
+}
+else {
+        $content_type = $default_content_type;
+}
+
+
 if (!$group_id || !$project) {
 	exit_no_group();
 } else {
@@ -54,8 +80,21 @@
 		header("Location: ".account_group_cvsweb_url($project->getUnixName()));
 		exit();
 	} else {
-		//show the project summary page
-		include $gfwww.'include/project_home.php';
+		// if a custom content-type is selected, then redirect to plugin's rendering
+		if($content_type != $default_content_type) {
+			$hook_params = array();
+			$hook_params['groupname'] = $project->getUnixName();
+			$hook_params['accept'] = $content_type;
+			$hook_params['return'] = '';
+			plugin_hook_by_reference('content_negociated_project_home', $hook_params);
+			if($hook_params['return'] != ''){
+				$uri = $hook_params['return'];
+				session_redirect($uri);
+			}
+		} else {
+			//show the project summary page
+			include $gfwww.'include/project_home.php';
+		}
 	}
 }
 




More information about the Fusionforge-commits mailing list