2015-09-29 03:57:26 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class pluginGoogleTools extends Plugin {
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$this->dbFields = array(
|
|
|
|
'tracking-id'=>'',
|
|
|
|
'google-site-verification'=>''
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function form()
|
|
|
|
{
|
|
|
|
$html = '<div>';
|
2016-11-07 20:58:47 +01:00
|
|
|
$html .= '<label for="jsgoogle-site-verification">'.$this->L('Google Webmasters tools').'</label>';
|
2015-09-29 03:57:26 +02:00
|
|
|
$html .= '<input id="jsgoogle-site-verification" type="text" name="google-site-verification" value="'.$this->getDbField('google-site-verification').'">';
|
2016-11-07 20:58:47 +01:00
|
|
|
$html .= '<div class="tip">'.$this->L('complete-this-field-with-the-google-site-verification').'</div>';
|
2015-09-29 03:57:26 +02:00
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
$html .= '<div>';
|
2016-11-07 20:58:47 +01:00
|
|
|
$html .= '<label for="jstracking-id">'.$this->L('Google Analytics Tracking ID').'</label>';
|
2015-09-29 03:57:26 +02:00
|
|
|
$html .= '<input id="jstracking-id" type="text" name="tracking-id" value="'.$this->getDbField('tracking-id').'">';
|
2016-11-07 20:58:47 +01:00
|
|
|
$html .= '<div class="tip">'.$this->L('complete-this-field-with-the-tracking-id').'</div>';
|
2015-09-29 03:57:26 +02:00
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function siteHead()
|
|
|
|
{
|
2016-05-05 13:57:47 +02:00
|
|
|
global $Url;
|
2015-09-29 03:57:26 +02:00
|
|
|
|
2016-05-05 13:50:47 +02:00
|
|
|
if(Text::isEmpty($this->getDbField('google-site-verification')) || !($Url->whereAmI()=='home')) {
|
2015-09-29 03:57:26 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-05 13:50:47 +02:00
|
|
|
$html = PHP_EOL.'<!-- Google Webmasters Tools -->'.PHP_EOL;
|
|
|
|
$html .= '<meta name="google-site-verification" content="'.$this->getDbField('google-site-verification').'">'.PHP_EOL;
|
|
|
|
|
2015-09-29 03:57:26 +02:00
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function siteBodyEnd()
|
|
|
|
{
|
|
|
|
$html = PHP_EOL.'<!-- Google Analytics -->'.PHP_EOL;
|
|
|
|
$html .= "<script>
|
|
|
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
|
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
|
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
|
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
|
|
|
|
|
|
ga('create', '".$this->getDbField('tracking-id')."', 'auto');
|
|
|
|
ga('send', 'pageview');
|
|
|
|
</script>".PHP_EOL;
|
|
|
|
|
|
|
|
if(Text::isEmpty($this->getDbField('tracking-id'))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
2016-05-05 13:50:47 +02:00
|
|
|
}
|