[Fusionforge-commits] r12636 - in branches/Branch_5_1/src/plugins/oslc: include include/oslc-zend/application/controllers include/oslc-zend/application/views/scripts include/oslc-zend/application/views/scripts/fusionforgecompact www www/scripts

Sabri LABBENE labbenes at fusionforge.org
Thu Mar 10 16:54:02 CET 2011


Author: labbenes
Date: 2011-03-10 16:54:01 +0100 (Thu, 10 Mar 2011)
New Revision: 12636

Added:
   branches/Branch_5_1/src/plugins/oslc/include/CompactRessource.class.php
   branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/CompactController.php
   branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCompactController.php
   branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/
   branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/_compact_user_xml.php
   branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-user-small.phtml
   branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-user.phtml
   branches/Branch_5_1/src/plugins/oslc/www/CompactRessourceView.class.php
   branches/Branch_5_1/src/plugins/oslc/www/scripts/
   branches/Branch_5_1/src/plugins/oslc/www/scripts/pluginOSLCHoverScripts.js
Log:
Add code that generates a compact view of fusionforge users when mouse over their links.

Added: branches/Branch_5_1/src/plugins/oslc/include/CompactRessource.class.php
===================================================================
--- branches/Branch_5_1/src/plugins/oslc/include/CompactRessource.class.php	                        (rev 0)
+++ branches/Branch_5_1/src/plugins/oslc/include/CompactRessource.class.php	2011-03-10 15:54:01 UTC (rev 12636)
@@ -0,0 +1,81 @@
+<?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.
+ *
+ */
+
+require_once dirname(dirname(__FILE__)).'/www/CompactRessourceView.class.php';
+require_once 'utils.php';
+
+class CompactRessource {
+	
+	private $view = null;
+	
+	public function __construct($params){
+		$this->params = $params;
+		/*if (isset($params['username'])) {
+			//$this->ressource_type = $params['ressourceType'];
+			$this->ressource_uri = $this->serverUrl().'/users/'.$params['username'];
+			//$this->username = $params['username'];
+			//$this->user_link = $params['user_link'];
+		}*/
+
+		$this->view = new CompactRessourceView();
+	}
+	
+	public function compactUserLink($username, $user_id) {
+		$ressource_uri = util_make_url('/plugins/oslc/compact/user/'.$username);
+		$url = '<a href="'. util_make_url_u ($username, $user_id) . '"' .
+		' onmouseover="hover(\''. $ressource_uri . '\', \'compact_user_' . $username . '\');" onmouseout="closeHover();">' . 
+		$username . '</a>';
+		// Add div that will contain the popup
+		$url .= '<div id="compact_user_'.$username.'"></div>';
+		return $url;
+	}
+	
+	public function CompactUser() {
+		$params['userUri'] = util_make_url_u ($this->params['user']->getUnixName(), $this->params['user']->getID());
+		$params['userCompactUri'] = util_make_url('/plugins/oslc/compact/user/'.$this->params['user']->getUnixName());
+		// full name
+		$user_title = $this->params['user']->getTitle();
+		$params['title'] = ($user_title ? $user_title .' ' :''). $this->params['user']->getRealName();
+		// login name
+		$params['shortTitle'] = $this->params['user']->getUnixName();
+		
+		$params['iconUrl'] = "";
+		
+		return $this->view->CompactUserView($params);
+	}
+	
+	public function CompactChangeRequest(){
+		$params['ressourceUri'] = "";
+		$params['title'] = "";
+		$params['shortTitle'] = "";
+		$params['iconUrl'] = "";
+		$params['smUrl'] = "";
+		$params['lgUrl'] = "";
+		
+		return $this->view->CompactChangeRequestView($params);
+	}
+	
+}
+?>
\ No newline at end of file

Added: branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/CompactController.php
===================================================================
--- branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/CompactController.php	                        (rev 0)
+++ branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/CompactController.php	2011-03-10 15:54:01 UTC (rev 12636)
@@ -0,0 +1,110 @@
+<?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.
+ */
+require_once('HTTP.php');
+$exceptions_dir = dirname( dirname( __FILE__ )) . DIRECTORY_SEPARATOR. 'exceptions'. DIRECTORY_SEPARATOR;
+require_once($exceptions_dir . 'oslcException.php');
+
+class CompactController extends Zend_Rest_Controller {
+	
+	private static $supportedAcceptMimeTypes = array(
+		'get' => array(
+			'application/x-oslc-compact+xml' => 'xml'
+		),
+		'oslccompactuser' => array(
+			'application/x-oslc-compact+xml' => 'xml'
+		),
+		'oslccompactusersmall' => array(
+			'application/x-oslc-compact+xml' => 'xml'
+		)
+	);
+
+	private $rest_controller;
+	
+	/**
+	 * Initilizes the Zend REST controler
+	 */
+	public function init() {
+		$controller_dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
+		require_once($controller_dir . 'FusionForgeCompactController.php');
+	}
+	
+	public function getSupportedAcceptMimeTypes(){
+		return self::$supportedAcceptMimeTypes;
+	}
+	
+	public function checkSupportedActionMimeType($mime_types, $action) {
+		$req = $this->getRequest();
+
+		// check Accept header's mime type 
+		$accept = $req->getHeader('Accept');
+
+		// prepare an array of accepted types
+		$accepted_types = array();
+		if(isset($mime_types[$action])) {
+			$accepted_types = array_keys($mime_types[$action]);
+		}
+		// make sure text/html is always an option (in last option)
+		$accepted_types[]='text/html';
+		
+		// If we can't directly find the accept header, then, have to negociate maybe among alternatives
+		if(!isset($mime_types[$action][$accept])) {
+			// use PEAR's HTTP::negotiateMimeType to identify the preferred content-type
+			//$accept = HTTP::negotiateMimeType($accepted_types,'');
+			$http = new HTTP();
+			$content_type = $http->negotiateMimeType($accepted_types,'');
+		} else {
+			// perfect, just found it directly (note that the 'get' action needs all of them)
+			$content_type = $accept;
+		}
+		//print($content_type); die();
+		if (!isset($content_type)) {
+			// unsupported accept type
+			throw new NotAcceptableForCRCollectionException("Accept header '".$req->getHeader('Accept')."' not supported for action .'".$action."' !");
+		}
+
+		return $content_type;
+	}
+	
+	public function getAction(){
+		switch (TRACKER_TYPE) {
+				case 'fusionforge':
+					$this->_forward('get', 'fusionforgecompact');
+					break;
+				default:
+					break;
+			}
+	}
+	
+	public function putAction() {
+		
+	}
+	
+	public function postAction() {
+		
+	}
+	
+	public function deleteAction() {
+		
+	}
+	
+	public function indexAction() {
+		
+	}
+}
+?>
\ No newline at end of file

Added: branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCompactController.php
===================================================================
--- branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCompactController.php	                        (rev 0)
+++ branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCompactController.php	2011-03-10 15:54:01 UTC (rev 12636)
@@ -0,0 +1,118 @@
+<?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.
+ */
+
+$controller_dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
+require_once($controller_dir . 'CompactController.php');
+
+require(APPLICATION_PATH.'/../../../../../common/include/env.inc.php');
+require_once $gfwww.'include/pre.php';
+
+class FusionForgeCompactController extends CompactController {
+	
+	private $actionMimeType;
+	private static $supportedAcceptMimeTypes = array();
+	
+	public function setActionMimeType($action) {
+		if(!isset($this->actionMimeType)) {
+			$this->actionMimeType = parent::checkSupportedActionMimeType(self::$supportedAcceptMimeTypes, $action);
+		}
+	}
+	
+	public function init(){
+		self::$supportedAcceptMimeTypes = parent::getSupportedAcceptMimeTypes();
+		
+		// now do things that relate to the REST framework
+		$req = $this->getRequest();
+
+
+		$action = $req->getActionName();
+
+		if($action =='get')	{
+			$accept = $req->getHeader('Accept');
+		}
+		
+		// Set the mime type for action.
+		$this->setActionMimeType($action);
+		
+		if(isset($this->actionMimeType)) {
+		  $accept = $this->actionMimeType;
+		}
+		//print(self::$supportedAcceptMimeTypes[$action][$accept]); die();
+		// determine output format
+		if (isset(self::$supportedAcceptMimeTypes[$action])) {
+			if (isset(self::$supportedAcceptMimeTypes[$action][$accept])) {
+				$format = self::$supportedAcceptMimeTypes[$action][$accept];
+				//print_r('format :'.$format); die();
+				$req->setParam('format', $format);
+			}
+		}
+		
+		$contextSwitch = $this->_helper->getHelper('contextSwitch');
+
+		$types = array();
+		foreach (self::$supportedAcceptMimeTypes as $action => $typesarr) {
+			$types = array_unique(array_values($typesarr));
+			$contextSwitch->addActionContext($action, $types)->initContext();
+		}
+	}
+	
+	public function getAction(){
+		$params = $this->getRequest()->getParams();
+		
+		if(isset($params['user']) && isset($params['type']) && $params['type'] == "small") {
+				$this->_forward('oslcCompactUserSmall');
+				return;
+		}
+		if(isset($params['user']) && !isset($params['type'])) {
+			$this->_forward('oslcCompactUser');
+			return;
+		}
+	}
+	
+	public function oslccompactuserAction() {
+		if (! isset($this->actionMimeType)) {
+			$this->_forward('UnknownAcceptType','error');
+			return;
+		}
+
+		$req = $this->getRequest();
+		$params = $req->getParams();
+		
+		$user_obj = user_get_object_by_name($params['user']);
+		$this->view->user = $user_obj;
+		
+		$this->getResponse()->setHeader('Content-Type', 'xml');
+	}
+	
+	public function oslccompactusersmallAction() {
+		if (! isset($this->actionMimeType)) {
+			$this->_forward('UnknownAcceptType','error');
+			return;
+		}
+		
+		$req = $this->getRequest();
+		$params = $req->getParams();
+
+		$user_obj = user_get_object_by_name($params['user']);
+		$this->view->user = $user_obj;
+		//print($this->actionMimeType); die();
+		$this->getResponse()->setHeader('Content-Type', $this->actionMimeType);
+	}
+}
+?>
\ No newline at end of file

Added: branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/_compact_user_xml.php
===================================================================
--- branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/_compact_user_xml.php	                        (rev 0)
+++ branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/_compact_user_xml.php	2011-03-10 15:54:01 UTC (rev 12636)
@@ -0,0 +1,59 @@
+<?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/user/'. $this->user->getUnixName());
+
+$user_title = $this->user->getTitle();
+$title = ($user_title ? $user_title .' ' :''). $this->user->getRealName();
+$titlenode = $doc->createElement('dcterms:title', $title);
+$Compact->appendChild($titlenode);
+
+$short_title_node = $doc->createElement('oslc:shortTitle', $this->user->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/user/'. $this->user->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: branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-user-small.phtml
===================================================================
--- branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-user-small.phtml	                        (rev 0)
+++ branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-user-small.phtml	2011-03-10 15:54:01 UTC (rev 12636)
@@ -0,0 +1,44 @@
+<?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.
+ *
+ */
+$user_real_name = $this->user->getRealName();
+$user_name = $this->user->getUnixName();
+$user_id = $this->user->getID();
+$user_uri = $this->serverUrl().'/users/'.$user_name;
+$user_title = $this->user->getTitle();
+$title = ($user_title ? $user_title .' ' :''). $user_real_name;?>
+
+<html>
+<head>
+<title>User: <?php echo $user_real_name;?> (Idenntifier: <?php echo $user_id;?>)</title>
+<link rel="SHORTCUT ICON" href="oslc.png"></link>
+</head>
+<body>
+<i>Compact User Preview </i><br/>
+User Name: <?php echo $title;?><br/>
+Login Name: <?php echo $user_name;?> <br/>
+Identifier:  <?php echo $user_id;?> <br/>
+Member since: <?php print date(_('Y-m-d H:i'), $this->user->getAddDate()); ?><br/>
+<small>URI: <?php echo $user_uri;?></small><br/>
+</body>
+</html>

Added: branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-user.phtml
===================================================================
--- branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-user.phtml	                        (rev 0)
+++ branches/Branch_5_1/src/plugins/oslc/include/oslc-zend/application/views/scripts/fusionforgecompact/oslc-compact-user.phtml	2011-03-10 15:54:01 UTC (rev 12636)
@@ -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_user_xml.php';
+?>
\ No newline at end of file

Added: branches/Branch_5_1/src/plugins/oslc/www/CompactRessourceView.class.php
===================================================================
--- branches/Branch_5_1/src/plugins/oslc/www/CompactRessourceView.class.php	                        (rev 0)
+++ branches/Branch_5_1/src/plugins/oslc/www/CompactRessourceView.class.php	2011-03-10 15:54:01 UTC (rev 12636)
@@ -0,0 +1,93 @@
+<?php 
+/**
+ * This file is (c) Copyright 2009 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.
+ *
+ */
+
+class CompactRessourceView {
+	
+	public function __construct() {
+		
+	}
+	
+	public function CompactUserView($params){
+		$doc = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" .
+			"<rdf:RDF \n" .
+			"   xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" \n" .
+			"   xmlns:dcterms=\"http://purl.org/dc/terms/\" \n" .
+			"   xmlns:oslc=\"http://open-services.net/ns/core#\"> \n" .
+			" <oslc:Compact \n" .
+			"   rdf:about=\"" . $params['userUri'] . "\"> \n" .
+			"   <dcterms:title>" . $params['title'] . "</dcterms:title> \n" .
+			"   <oslc:shortTitle>" . $params['shortTitle'] . "</oslc:shortTitle> \n" .
+			"   <oslc:icon rdf:resource=\"" . $params['iconUrl'] . "\" /> \n" .
+			"   <oslc:smallPreview> \n" .
+			"      <oslc:Preview> \n" .
+			"         <oslc:document rdf:resource=\"" . $params['userCompactUri'] . "\" /> \n" .
+			"         <oslc:hintWidth>500px</oslc:hintWidth> \n" .
+			"         <oslc:hintHeight>120px</oslc:hintHeight> \n" .
+			"      </oslc:Preview> \n" .
+			"   </oslc:smallPreview> \n" .
+			"   <oslc:largePreview> \n" .
+			"      <oslc:Preview> \n" .
+			"         <oslc:document rdf:resource=\"" . $params['lgUrl'] . "\" /> \n" .
+			"         <oslc:hintWidth>500px</oslc:hintWidth> \n" .
+			"         <oslc:hintHeight>500px</oslc:hintHeight> \n" .
+			"      </oslc:Preview> \n" .
+			"   </oslc:largePreview> \n" .
+			" </oslc:Compact> \n" .
+			"</rdf:RDF>";
+		return $doc;
+	}
+	
+	public function CompactChangeRequestView($params){
+				$doc = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" .
+			"<rdf:RDF \n" .
+			"   xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" \n" .
+			"   xmlns:dcterms=\"http://purl.org/dc/terms/\" \n" .
+			"   xmlns:oslc=\"http://open-services.net/ns/core#\"> \n" .
+			" <oslc:Compact \n" .
+			"   rdf:about=\"" . $params['resourceUri'] . "\"> \n" .
+			"   <dcterms:title>" . $params['title'] . "</dcterms:title> \n" .
+			"   <oslc:shortTitle>" . $params['shortTitle'] . "</oslc:shortTitle> \n" .
+			"   <oslc:icon rdf:resource=\"" . $params['iconUrl'] . "\" /> \n" .
+			"   <oslc:smallPreview> \n" .
+			"      <oslc:Preview> \n" .
+			"         <oslc:document rdf:resource=\"" . $params['smUrl'] . "\" /> \n" .
+			"         <oslc:hintWidth>500px</oslc:hintWidth> \n" .
+			"         <oslc:hintHeight>120px</oslc:hintHeight> \n" .
+			"      </oslc:Preview> \n" .
+			"   </oslc:smallPreview> \n" .
+			"   <oslc:largePreview> \n" .
+			"      <oslc:Preview> \n" .
+			"         <oslc:document rdf:resource=\"" . $params['lgUrl'] . "\" /> \n" .
+			"         <oslc:hintWidth>500px</oslc:hintWidth> \n" .
+			"         <oslc:hintHeight>500px</oslc:hintHeight> \n" .
+			"      </oslc:Preview> \n" .
+			"   </oslc:largePreview> \n" .
+			" </oslc:Compact> \n" .
+			"</rdf:RDF>";
+		return $doc;
+	}
+	
+	
+}
+
+?>
\ No newline at end of file

Added: branches/Branch_5_1/src/plugins/oslc/www/scripts/pluginOSLCHoverScripts.js
===================================================================
--- branches/Branch_5_1/src/plugins/oslc/www/scripts/pluginOSLCHoverScripts.js	                        (rev 0)
+++ branches/Branch_5_1/src/plugins/oslc/www/scripts/pluginOSLCHoverScripts.js	2011-03-10 15:54:01 UTC (rev 12636)
@@ -0,0 +1,83 @@
+/**
+ * FusionForge OSLC plugin.
+ *
+ * Copyright 2011, Sabri LABBENE - INSTITUT TELECOM
+ * http://fusionforge.org
+ *
+ * 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
+ */
+var oslcPrefix;
+var rdfPrefix;
+var divId;
+
+function getPrefix(xmlDoc,ns) {
+	var attrs = xmlDoc.documentElement.attributes;
+	for( var i=0; i<attrs.length; i++ ) {
+		if( attrs[i].nodeValue == ns ) {
+			var name = attrs[i].nodeName;
+			var pos = name.indexOf(":");
+			return ( name.substring(pos+1) );
+		}
+	}
+}
+function hover(uri,id){
+	divId = id;
+	var req = new XMLHttpRequest();  
+	req.open('GET', uri, true);  
+	req.setRequestHeader('Accept', 'application/x-oslc-compact+xml');
+	req.onreadystatechange = function (aEvt) {  
+		if (req.readyState == 4) {  
+			if(req.status == 200) {  
+				//debugger;
+				var xmlDoc = req.responseXML;
+				oslcPrefix = getPrefix(xmlDoc, 'http://open-services.net/ns/core#');
+				rdfPrefix = getPrefix(xmlDoc, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
+				var smPreview = xmlDoc.documentElement.getElementsByTagName(oslcPrefix + ':smallPreview')[0];
+				if( smPreview ) {
+					var Preview = smPreview.getElementsByTagName(oslcPrefix + ':Preview')[0];
+					if(Preview){
+						var oslcDoc = Preview.getElementsByTagName(oslcPrefix + ':document')[0];
+						if( oslcDoc ) {
+							var url = oslcDoc.getAttribute(rdfPrefix + ':ressource');
+							if( oslcDoc ) {
+								var div = document.getElementById(divId);
+								if( div ) {
+									var elmHintWidth = smPreview.getElementsByTagName(oslcPrefix + ':hintWidth')[0];
+									var divWidth = elmHintWidth.textContent;
+									var elmHintHeight = smPreview.getElementsByTagName(oslcPrefix + ':hintHeight')[0];
+									var divHeight = elmHintHeight.textContent;
+									div.innerHTML = '<'+'object type="text/html" data="'+url+'" width="'+divWidth+'" height="'+divHeight+'" style="background-color:#ffffee; border-style:solid;border-width:2px;"><\/object>';
+								}
+							}
+						}
+					}
+				}   
+			}
+		}
+	};  
+	req.send(null); 
+}
+function closeHover() { 
+	if( divId ) {
+		var elmDiv = document.getElementById(divId);
+		if( elmDiv ) {
+			elmDiv.innerHTML = '';
+			elmDiv.width = null;
+			elmDiv.height = null;
+		}
+	}
+}
\ No newline at end of file




More information about the Fusionforge-commits mailing list