[Fusionforge-commits] r14429 - in trunk/src/plugins/compactpreview: include www

Olivier Berger olberger at fusionforge.org
Mon Sep 19 10:00:56 CEST 2011


Author: olberger
Date: 2011-09-19 10:00:56 +0200 (Mon, 19 Sep 2011)
New Revision: 14429

Modified:
   trunk/src/plugins/compactpreview/include/CompactPreviewPlugin.class.php
   trunk/src/plugins/compactpreview/include/CompactResource.class.php
   trunk/src/plugins/compactpreview/www/project.php
Log:
Complete support for local compact preview

Modified: trunk/src/plugins/compactpreview/include/CompactPreviewPlugin.class.php
===================================================================
--- trunk/src/plugins/compactpreview/include/CompactPreviewPlugin.class.php	2011-09-19 08:00:50 UTC (rev 14428)
+++ trunk/src/plugins/compactpreview/include/CompactPreviewPlugin.class.php	2011-09-19 08:00:56 UTC (rev 14429)
@@ -91,10 +91,11 @@
 	}
 	
 	function display_user_html_compact_preview($username) {
-
+		global $gfwww;
+		
 		require_once $gfwww.'include/user_profile.php';
 		
-		$user_obj = user_get_object_by_name($user);
+		$user_obj = user_get_object_by_name($username);
 
 		
 		$user_real_name = $user_obj->getRealName();
@@ -114,6 +115,113 @@
 				
 	}
 	
+	function display_project_html_compact_preview($project) {
+		
+		$project_obj = group_get_object_by_name($project);
+		
+		$public_name = $project_obj->getPublicName();
+		$unix_name = $project_obj->getUnixName();
+		$id = $project_obj->getID();
+		$home_page = util_make_url ("/projects/$unix_name/");
+		$description = $project_obj->getDescription();
+		$start_date = $project_obj->getStartDate();
+		$status = $project_obj->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 ($project_obj->isPublic()) {
+			$public = 'Yes';
+		} else {
+			$public = 'No';
+		}
+		
+		$html='<html>
+		<head>
+		<title>Project: '. $public_name .' ('. $unix_name .')</title>
+		</head>
+		<body>
+			<table>
+		
+				<tr>
+					<td colspan="2"><i>Project Compact Preview</i></td>
+				</tr>
+				<tr>
+					'/* <td rowspan="8"><img src="/plugins/compactpreview/images/userTooltip/oslc.png" />
+					</td>*/.'
+					<td><b>Project name:</b>
+					
+					
+					
+					 '. $public_name .'</td>
+				</tr>
+				<tr>
+					<td><b>Project short name:</b>
+					
+					
+					
+					 '. $unix_name .'</td>
+				</tr>
+				<tr>
+					<td><b>Identifier:</b>
+					
+					
+					
+					  '. $id .'</td>
+				</tr>
+				<tr>
+					<td><b>Started since:</b>
+					
+					
+					
+					 '. date(_('Y-m-d H:i'), $start_date) .'</td>
+				</tr>
+				<tr>
+					<td><b>Status:</b>
+					
+					
+					
+					  '. $project_status .'</td>
+				</tr>
+				<tr>
+					<td><b>Is Public:</b>
+					
+					
+					
+					  '. $public .'</td>
+				</tr>
+				<tr>
+					<td><b>Description:</b>
+					
+					
+					
+					  '. $description .'</td>
+				</tr>
+				<tr>
+					<td><small><b>Home Page:</b> <a href="'. $home_page .'">'. $home_page .'
+						</a> </small></td>
+				</tr>
+		
+			</table>
+		</body>
+		</html>';
+	
+		return $html;
+				
+	}
+	
 	function content_negociated_user_home (&$params) {
 
 		$username = $params['username'];
@@ -143,7 +251,7 @@
 			// if want direct compact-preview rendering
 			case 'application/x-fusionforge-compact+html' : {
 				$params['content_type'] = 'text/html';
-				$params['content'] = display_user_html_compact_preview($username);
+				$params['content'] = $this->display_user_html_compact_preview($username);
 				break;
 			}
 		}
@@ -153,26 +261,34 @@
 
 		$projectname = $params['groupname'];
 		$accept = $params['accept'];
-		if($accept == 'application/x-oslc-compact+xml') {
-			$params['content_type'] = 'application/x-oslc-compact+xml';
-			$params['content'] = '<?xml version="1.0"?>
-<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:oslc="http://open-services.net/ns/core#">
-  <oslc:Compact rdf:about="/plugins/oslc/compact/project/'. $projectname .'">
-    <dcterms:title>'. $projectname . '</dcterms:title>
-    <oslc:shortTitle>'. $projectname . '</oslc:shortTitle>
-    <oslc:smallPreview>
-      <oslc:Preview>
-        <oslc:document rdf:ressource="/plugins/'.$this->name.'/project.php?project='. $projectname .'"/>
-        <oslc:hintWidth>500px</oslc:hintWidth>
-        <oslc:hintHeight>150px</oslc:hintHeight>
-      </oslc:Preview>
-    </oslc:smallPreview>
-  </oslc:Compact>
-</rdf:RDF>';
+		switch ($accept) {
+			// if want some OSLC compact-preview, provide the document pointing to the compact-preview
+			case 'application/x-oslc-compact+xml' : {
+				$params['content_type'] = 'application/x-oslc-compact+xml';
+				$params['content'] = '<?xml version="1.0"?>
+					<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:oslc="http://open-services.net/ns/core#">
+  						<oslc:Compact rdf:about="/plugins/oslc/compact/project/'. $projectname .'">
+    						<dcterms:title>'. $projectname . '</dcterms:title>
+    						<oslc:shortTitle>'. $projectname . '</oslc:shortTitle>
+    						<oslc:smallPreview>
+      							<oslc:Preview>
+        							<oslc:document rdf:ressource="/plugins/'.$this->name.'/project.php?project='. $projectname .'"/>
+        							<oslc:hintWidth>500px</oslc:hintWidth>
+        							<oslc:hintHeight>150px</oslc:hintHeight>
+      							</oslc:Preview>
+    						</oslc:smallPreview>
+  						</oslc:Compact>
+					</rdf:RDF>';
+				break;
+			}
+			// if want direct compact-preview rendering
+			case 'application/x-fusionforge-compact+html' : {
+				$params['content_type'] = 'text/html';
+				$params['content'] = $this->display_project_html_compact_preview($projectname);
+				break;
+			}
 		}
 	}
-
-
 }
 
 // Local Variables:

Modified: trunk/src/plugins/compactpreview/include/CompactResource.class.php
===================================================================
--- trunk/src/plugins/compactpreview/include/CompactResource.class.php	2011-09-19 08:00:50 UTC (rev 14428)
+++ trunk/src/plugins/compactpreview/include/CompactResource.class.php	2011-09-19 08:00:56 UTC (rev 14429)
@@ -57,7 +57,7 @@
 				return new LocalUserCompactResource($params);
 				break;
 			case 'group' :
-				return new GroupCompactResource($params);
+				return new LocalGroupCompactResource($params);
 				break;
 			case 'artifact' :
 				return new CompatResource($params);
@@ -98,8 +98,8 @@
         //				'" rel="'. $resource_url .'">'. $username . '</a>';
 		$css_class = $this->getCssClass();
 		
-        $url = '<a class="'. $css_class .'" href="'. $resource_url .
-                				'">'. $username . '</a>';
+        $url = '<a class="'. $css_class .
+        		'" href="'. $resource_url .'">'. $username .'</a>';
         if ($logo_params['content']) {
         	$html = $logo_params['content'] . $url .'<div class="new_line"></div>';
         }
@@ -134,8 +134,13 @@
 	protected function getCssClass() {
 	// TBD
 	}
-	
-	
+
+}
+
+class LocalGroupCompactResource extends GroupCompactResource {
+	protected function getCssClass() {
+		return 'resourceLocalPopupTrigger';
+	}
 	public function getResourceLink() {
 		$group_name = $this->params['group_name'];
 		$group_id = $this->params['group_id'];
@@ -143,21 +148,21 @@
 		$resource_url = util_make_url_g ($group_name, $group_id);
 		$css_class = $this->getCssClass();
 		return '<a class="'.$css_class .'" href="'. $resource_url .
-				'" rel="' . $resource_url . '">'. $link_text . '</a>';
+					'">'. $link_text . '</a>';
 	}
-
 }
 
-class LocalGroupCompactResource extends GroupCompactResource {
-	protected function getCssClass() {
-		return 'resourceLocalPopupTrigger';
-	}
-}
-
 class OslcGroupCompactResource extends GroupCompactResource {
 	protected function getCssClass() {
 		return 'resourceOslcPopupTrigger';
 	}
+	public function getResourceLink() {
+		$name = $this->params['name'];
+		$resource_url = $this->params['url'];
+		$css_class = $this->getCssClass();
+		return '<a class="'.$css_class .'" href="'. $resource_url .
+					'">'. $name . '</a>';
+	}
 }
 
 ?>

Modified: trunk/src/plugins/compactpreview/www/project.php
===================================================================
--- trunk/src/plugins/compactpreview/www/project.php	2011-09-19 08:00:50 UTC (rev 14428)
+++ trunk/src/plugins/compactpreview/www/project.php	2011-09-19 08:00:56 UTC (rev 14429)
@@ -27,114 +27,15 @@
 require_once $gfwww.'include/pre.php';
 
 
-$project = getStringFromRequest('project');
 
-$project_obj = group_get_object_by_name($project);
 
-$public_name = $project_obj->getPublicName();
-$unix_name = $project_obj->getUnixName();
-$id = $project_obj->getID();
-$home_page = util_make_url ("/projects/$unix_name/");
-$description = $project_obj->getDescription();
-$start_date = $project_obj->getStartDate();
-$status = $project_obj->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 ($project_obj->isPublic()) {
-	$public = 'Yes';
-} else {
-	$public = 'No';
-}
+global $pluginCompatPreview;
+$pluginCompactPreview = plugin_get_object('compactpreview');
 
+$project = getStringFromRequest('project');
 
-?>
+echo $pluginCompatPreview->display_project_html_compact_preview($project);
 
-<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/compactpreview/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>
-
-<?php
-
 // Local Variables:
 // mode: php
 // c-file-style: "bsd"




More information about the Fusionforge-commits mailing list