X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FGoogleAnalytics%2FGoogleAnalyticsPlugin.php;h=1dc0f0f07a402ca6955a808bdd3c4a5d55d11fc1;hb=546a03b5eac5f172d543a889625e2f4de446e8b7;hp=b34fe203ec9075f2ec54d3a87d2f93094152e6bc;hpb=f47027abbefe35d17df50c67eec7cd1156a5e39a;p=quix0rs-gnu-social.git diff --git a/plugins/GoogleAnalytics/GoogleAnalyticsPlugin.php b/plugins/GoogleAnalytics/GoogleAnalyticsPlugin.php index b34fe203ec..1dc0f0f07a 100644 --- a/plugins/GoogleAnalytics/GoogleAnalyticsPlugin.php +++ b/plugins/GoogleAnalytics/GoogleAnalyticsPlugin.php @@ -49,31 +49,66 @@ if (!defined('STATUSNET')) { */ class GoogleAnalyticsPlugin extends Plugin { - var $code = null; + var $code; + var $domain; + + const VERSION = '0.2'; function __construct($code=null) { - $this->code = $code; + if (!empty($code)) { + global $config; + $config['googleanalytics']['code'] = $code; + } + parent::__construct(); } function onEndShowScripts($action) { - $js1 = 'var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");'. - 'document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));'; - $js2 = sprintf('try{'. - 'var pageTracker = _gat._getTracker("%s");'. - 'pageTracker._trackPageview();'. - '} catch(err) {}', - $this->code); - $action->inlineScript($js1); - $action->inlineScript($js2); + $code = common_config('googleanalytics', 'code'); + if (empty($code)) { + $code = $this->code; + } + $domain = common_config('googleanalytics', 'domain'); + if (empty($domain)) { + $domain = $this->domain; + } + + $js = <<inlineScript($js); } - function onPluginVersion(&$versions) + function onPluginVersion(array &$versions) { $versions[] = array('name' => 'GoogleAnalytics', - 'version' => STATUSNET_VERSION, + 'version' => self::VERSION, 'author' => 'Evan Prodromou', 'homepage' => 'http://status.net/wiki/Plugin:GoogleAnalytics', 'rawdescription' =>