Patch für neues Piwik Joomla Plugin


#1

Ich habe hier was zurecht gebogen, damit es mit der neuesten Version funktioniert:

/[joomla_install]/plugins/system/piwik.php, Zeile 26ff


function onAfterRender()
	{
		global $mainframe;
		
		$piwik_site_id = $this->params->get('piwik_site_id', '');
		$piwik_http_url = $this->params->get('piwik_http_url', '');
		$piwik_https_url = $this->params->get('piwik_https_url', '');
		
		if($piwik_site_id == '' || $mainframe->isAdmin() || strpos($_SERVER["PHP_SELF"], "index.php") === false)
		{
			return;
		}

		$buffer = JResponse::getBody();

		$piwik_javascript = '
			<!-- Piwik -->
			
			<script type="text/javascript">
			var pkBaseURL = (("https:" == document.location.protocol) ? "'.$piwik_https_url.'" : "'.$piwik_http_url.'");
			document.write(unescape("%3Cscript src=\'" + pkBaseURL + "piwik.js\' type=\'text/javascript\'%3E%3C/script%3E"));
			</script><script type="text/javascript">
			try {
			var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", '.$piwik_site_id.');
			piwikTracker.trackPageView();
			piwikTracker.enableLinkTracking();
			} catch( err ) {}
			</script><noscript><p><img src="'.$piwik_http_url.'piwik.php?idsite='.$piwik_site_id.'" style="border:0" alt="" /></p></noscript>

			<!-- End Piwik Tag -->
			';

		$pos = strrpos($buffer, "</body>");
		
		if($pos > 0)
		{
			$buffer = substr($buffer, 0, $pos).$piwik_javascript.substr($buffer, $pos);

			JResponse::setBody($buffer);
		}
		
		return true;
	}

Gruß Dirk