[Piwik-svn] r484 - trunk/modules/DataTable/Renderer

svnmaster at piwik.org svnmaster at piwik.org
Sun May 18 20:19:12 CEST 2008


Author: matt
Date: 2008-05-18 20:19:09 +0200 (Sun, 18 May 2008)
New Revision: 484

Modified:
   trunk/modules/DataTable/Renderer/Json.php
Log:
- adding new parameter for JSON export: you can now specify a json callback 
this is to bypass the cross domain requests: http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/

Modified: trunk/modules/DataTable/Renderer/Json.php
===================================================================
--- trunk/modules/DataTable/Renderer/Json.php	2008-05-18 17:39:39 UTC (rev 483)
+++ trunk/modules/DataTable/Renderer/Json.php	2008-05-18 18:19:09 UTC (rev 484)
@@ -39,6 +39,14 @@
 			$array = array('value' => $array);
 		}
 		$str = json_encode($array);
+		
+		if(($jsonCallback = Piwik_Common::getRequestVar('jsoncallback', false)) !== false)
+		{
+			if(preg_match('/^[0-9a-zA-Z]*$/', $jsonCallback) > 0)
+			{
+				$str = $jsonCallback . "(" . $str . ")";
+			}
+		}
 		return $str;
 	}
 }
\ No newline at end of file



More information about the Piwik-svn mailing list