[Piwik-svn] r356 - trunk/plugins/SitesManager

svnmaster at piwik.org svnmaster at piwik.org
Mon Mar 10 23:36:17 CET 2008


Author: matt
Date: 2008-03-10 23:36:16 +0100 (Mon, 10 Mar 2008)
New Revision: 356

Modified:
   trunk/plugins/SitesManager/API.php
Log:
- adding getJavascriptTag in API

Modified: trunk/plugins/SitesManager/API.php
===================================================================
--- trunk/plugins/SitesManager/API.php	2008-03-10 18:36:15 UTC (rev 355)
+++ trunk/plugins/SitesManager/API.php	2008-03-10 22:36:16 UTC (rev 356)
@@ -34,6 +34,25 @@
 	static public $methodsNotToPublish = array();
 	
 	/**
+	 * Returns the javascript tag for the given idSite.
+	 * This tag must be included on every page to be tracked by Piwik
+	 *
+	 * @param int $idSite
+	 * @return string The Javascript tag ready to be included on the HTML pages
+	 */
+	static public function getJavascriptTag( $idSite, $piwikUrl = '', $actionName = '')
+	{
+		$actionName = "'$actionName'";
+		if(empty($piwikUrl))
+		{
+			$piwikUrl = Piwik_Url::getCurrentUrlWithoutFileName();
+		}
+		$htmlEncoded = Piwik::getJavascriptCode($idSite, $piwikUrl, $actionName);
+		$htmlEncoded = str_replace(array('<br>','<br />','<br/>'), '', $htmlEncoded);
+		return html_entity_decode($htmlEncoded);
+	}
+	
+	/**
 	 * Returns the website information : name, main_url
 	 * 
 	 * @exception if the site ID doesn't exist or the user doesn't have access to it



More information about the Piwik-svn mailing list