Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
3 lars 1
<?php
2
    /**
3
     * Smarty plugin
4
     * @package Smarty
5
     * @subpackage plugins
6
     */
7
 
8
    /**
9
     * Google Analytics plugin
10
     * Generate XHTML 1.1 valid Google Analytics code
11
     * Name:     google_analytics<br>
12
     * Date:     2009.09.17.<br>
13
     *
14
     * Examples:
15
     * <pre>
16
     * {google_analytics code=UA-xxxxxx-x}
17
     * </pre>
18
     *
19
     * @author   László Kovács <info@laszlokovacs.com>
20
     * @license http://www.gnu.org/copyleft/gpl.html GPL
21
     * @param array $params code parameter required
22
     * @param Smarty $smarty
23
     * @return string
24
     */
25
    function smarty_function_google_analytics( $params, &$smarty )
26
    {
27
 
28
        if ( empty($params['code']) )
29
        {
30
            $smarty->trigger_error( "google_analytics: missing parameter" );
31
            return;
32
        }
33
 
34
        $return = '
35
      <script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>
36
      <script type="text/javascript">
37
      // <![CDATA[
38
      try{
39
      var pageTracker = _gat._getTracker("' . $params['code'] . '");
40
      pageTracker._trackPageview();
41
      } catch(err) {}
42
      // ]]>
43
      </script>';
44
 
45
        return $return;
46
    }
47
 
48
?>