[Fusionforge-commits] r15978 - in trunk/src: docs plugins/doaprdf/include www/include

Olivier Berger olberger at fusionforge.org
Tue Jul 10 16:05:33 CEST 2012


Author: olberger
Date: 2012-07-10 16:05:32 +0200 (Tue, 10 Jul 2012)
New Revision: 15978

Modified:
   trunk/src/docs/README.Plugins
   trunk/src/plugins/doaprdf/include/doaprdfPlugin.class.php
   trunk/src/www/include/Layout.class.php
Log:
Add alt_representations hook to support Linked Data Autodiscovery links in HTML link/meta

Conflicts:
	src/docs/README.Plugins

Modified: trunk/src/docs/README.Plugins
===================================================================
--- trunk/src/docs/README.Plugins	2012-07-10 11:29:39 UTC (rev 15977)
+++ trunk/src/docs/README.Plugins	2012-07-10 14:05:32 UTC (rev 15978)
@@ -522,6 +522,10 @@
   Locations  : common/include/RBAC.php
   Description: Called when a role is removed to an user.
 
+  Hook Name  : alt_representations
+  Parameters : $params['script_name'] contains the SCRIPT_NAME (filtered to work only on /projects or /users for the moment)
+  Description: returns alternate representations for a particular page in $params['results'] which is populated by the hook users 
+
 TODO (nerville) : document display_hierarchy
 TODO (lolando ?) : document role_normalize, role_translate_strings, role_has_permission, role_get_setting, list_roles_by_permission 
 TODO : document project_link_with_tooltip

Modified: trunk/src/plugins/doaprdf/include/doaprdfPlugin.class.php
===================================================================
--- trunk/src/plugins/doaprdf/include/doaprdfPlugin.class.php	2012-07-10 11:29:39 UTC (rev 15977)
+++ trunk/src/plugins/doaprdf/include/doaprdfPlugin.class.php	2012-07-10 14:05:32 UTC (rev 15978)
@@ -36,6 +36,7 @@
 		$this->text = "DoaPRDF!"; // To show in the tabs, use...
 		$this->_addHook("script_accepted_types");
 		$this->_addHook("content_negociated_project_home");
+		$this->_addHook("alt_representations");
 
 	}
 
@@ -156,6 +157,18 @@
 			$params['content'] = $doc;
 		}
 	}
+	
+	/**
+	 * Declares a link to itself in the link+meta HTML headers
+	 * @param unknown_type $params
+	 */
+	function alt_representations (&$params) {
+		$script_name = $params['script_name'];
+		if ($script_name == '/projects') {
+			$params['return'][] = '<link rel="meta" type="application/rdf+xml" title="DOAP RDF Data" href=""/>';
+		}
+	}
+	
 }
 
 // Local Variables:

Modified: trunk/src/www/include/Layout.class.php
===================================================================
--- trunk/src/www/include/Layout.class.php	2012-07-10 11:29:39 UTC (rev 15977)
+++ trunk/src/www/include/Layout.class.php	2012-07-10 14:05:32 UTC (rev 15978)
@@ -268,6 +268,7 @@
 		$this->headerCSS();
 		$this->headerJS();
 		$this->headerForgepluckerMeta();
+		$this->headerLinkedDataAutodiscovery();
 		?>
 	</head>
 		<?php
@@ -369,6 +370,28 @@
 		}
 	}
 
+	/**
+ 	 * headerLinkedDataAutodiscovery() - creates the link+meta links to alternate
+ 	 * 		representations for Linked Data autodiscovery
+ 	 */
+	function headerLinkedDataAutodiscovery() {
+		// Only activated for /projects or /users for the moment
+		$script_name = getStringFromServer('SCRIPT_NAME');
+
+		if ($script_name == '/projects' || $script_name == '/users') {
+
+			// invoke the 'alt_representations' hook
+			$params = array('script_name' => $script_name,
+							'return' => array());
+
+			plugin_hook_by_reference('alt_representations', $params);
+
+			foreach($params['return'] as $link) {
+				echo "                        $link"."\n";
+			}
+		}
+	}
+
 	function headerForgepluckerMeta() {
 		/*-
 		 * Forge-Identification Meta Header, Version 1.0




More information about the Fusionforge-commits mailing list