[Fusionforge-commits] r12910 - trunk/src/www

Olivier Berger olberger at fusionforge.org
Fri Mar 25 14:07:14 CET 2011


Author: olberger
Date: 2011-03-25 14:07:14 +0100 (Fri, 25 Mar 2011)
New Revision: 12910

Modified:
   trunk/src/www/users
Log:
Put content negociation's dependency on PEAR::HTTP inside hook processing : should only add dependency on plugins packages

Modified: trunk/src/www/users
===================================================================
--- trunk/src/www/users	2011-03-25 13:07:05 UTC (rev 12909)
+++ trunk/src/www/users	2011-03-25 13:07:14 UTC (rev 12910)
@@ -28,9 +28,6 @@
 require_once $gfcommon.'include/pre.php';    
 require_once $gfcommon.'include/User.class.php';    
 
-// PEAR::HTTP (for negotiateMimeType())
-require_once('HTTP.php');
-
 $normalized_urlprefix = normalized_urlprefix();
 $pathinfo = substr_replace(getStringFromServer('REQUEST_URI'), '', 0, strlen($normalized_urlprefix)-1);
 $expl_pathinfo = explode('/', $pathinfo);
@@ -39,22 +36,30 @@
 	exit_error(_('No User Name Provided'));
 }
 
-// By default, text/html is accepted
-$accepted_types = array('text/html');
+$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'] = 'user_home';
-$hook_params['accepted_types'] = $accepted_types;
+$hook_params['accepted_types'] = array();
 plugin_hook_by_reference('script_accepted_types', $hook_params);
 if(isset($hook_params['accepted_types'])){
-	$accepted_types = $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;
+}
 
-// negociate accepted content-type depending on the preferred ones declared by client
-$http=new HTTP();
-$content_type = $http->negotiateMimeType($accepted_types,'text/html');
-
 $username = urldecode($expl_pathinfo[2]);
 
 //get the user object based on the user_name in the URL
@@ -66,7 +71,7 @@
 
 } else {
 	// if a custom content-type is selected, then redirect to plugin's rendering
-	if($content_type != 'text/html') {
+	if($content_type != $default_content_type) {
  		$hook_params = array();
         $hook_params['username'] = $username;
         $hook_params['accept'] = $content_type;




More information about the Fusionforge-commits mailing list