1 | <?php /* -*- tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ |
---|
2 | /***************************************************************\ |
---|
3 | * This is 'Google Stuff', a plugin for Dotclear 2 * |
---|
4 | * * |
---|
5 | * Copyright (c) 2008 * |
---|
6 | * xave and contributors. * |
---|
7 | * * |
---|
8 | * This is an open source software, distributed under the GNU * |
---|
9 | * General Public License (version 2) terms and conditions. * |
---|
10 | * * |
---|
11 | * You should have received a copy of the GNU General Public * |
---|
12 | * License along with 'My Favicon' (see COPYING.txt); * |
---|
13 | * if not, write to the Free Software Foundation, Inc., * |
---|
14 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
---|
15 | \***************************************************************/ |
---|
16 | |
---|
17 | $core->addBehavior('publicHeadContent',array('googlestuffPublicBehaviours','publicHeadContent')); |
---|
18 | $core->addBehavior('publicFooterContent',array('googlestuffPublicBehaviours','publicFooterContent')); |
---|
19 | |
---|
20 | |
---|
21 | class googlestuffPublicBehaviours |
---|
22 | { |
---|
23 | public static function publicHeadContent($core) |
---|
24 | { |
---|
25 | $res = ''; |
---|
26 | |
---|
27 | if ($core->blog->settings->googlestuff_verify != "") { |
---|
28 | $res .= '<meta name="google-site-verification" content="'.$core->blog->settings->googlestuff_verify.'" />'."\n"; |
---|
29 | } |
---|
30 | |
---|
31 | if ($core->blog->settings->googlestuff_uacct != "") { |
---|
32 | $res .= '<script type="text/javascript">'."\n". |
---|
33 | 'var _gaq = _gaq || [];'."\n". |
---|
34 | '_gaq.push([\'_setAccount\', \''.$core->blog->settings->googlestuff_uacct.'\']);'."\n". |
---|
35 | '_gaq.push([\'_trackPageview\']);'."\n". |
---|
36 | '</script>'."\n"; |
---|
37 | } |
---|
38 | |
---|
39 | echo $res; |
---|
40 | } |
---|
41 | |
---|
42 | public static function publicFooterContent($core) |
---|
43 | { |
---|
44 | if ($core->blog->settings->googlestuff_uacct != "") { |
---|
45 | $res = '<script type="text/javascript">'."\n". |
---|
46 | '(function() {'."\n". |
---|
47 | 'var ga = document.createElement(\'script\');'."\n". |
---|
48 | 'ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' :'. |
---|
49 | '\'http://www\') + \'.google-analytics.com/ga.js\';'."\n". |
---|
50 | 'ga.setAttribute(\'async\', \'true\');'."\n". |
---|
51 | 'document.documentElement.firstChild.appendChild(ga);'."\n". |
---|
52 | '})();'."\n". |
---|
53 | '</script>'; |
---|
54 | |
---|
55 | echo $res; |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | } |
---|
60 | ?> |
---|