<commit_before><?php 
/**
 * Pimcore
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.pimcore.org/license
 *
 * @copyright  Copyright (c) 2009-2010 elements.at New Media Solutions GmbH (http://www.elements.at)
 * @license    http://www.pimcore.org/license     New BSD License
 */

class Pimcore_Google_Analytics {
    
    public static $stack = array();
    
    public static function isConfigured (Site $site = null) {
        if(self::getSiteConfig($site) && self::getSiteConfig($site)->profile) {
            return true;
        }
        return false;
    }

    public static function getSiteConfig ($site = null) {
        
        $siteKey = Pimcore_Tool_Frontend::getSiteKey($site);
        
        if(Pimcore_Config::getReportConfig()->analytics->sites->$siteKey) {
            return Pimcore_Config::getReportConfig()->analytics->sites->$siteKey;
        }
        return false;
    }
    
    public static function getCode () {
                
        $config = self::getSiteConfig();
        
        // do nothing if not configured
        if(!$config || !$config->trackid) {
            return "";
        }
        
        
        
        $stack = array();
        
        if($config->advanced) {
            foreach (self::$stack as $s) {
            $stack[] = "_gaq.push(" . Zend_Json::encode($s) . ");";
            }
            
            // remove dublicates
            $stack = array_unique($stack);
        }
        
        
        $code = "";
        $code .= "
            <script type=\"text/javascript\">

              var _gaq = _gaq || [];
              _gaq.push(['_setAccount', '" . $config->trackid . "']);
              " . $config->additionalcodebeforepageview . "
              if (typeof _gaqPageView != \"undefined\"){
                _gaq.push(['_trackPageview',_gaqPageView]);
              } else {
                _gaq.push(['_trackPageview']);
              }

              " . $config->additionalcode . "
            
              (function() {
                var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
              })();
              
              " . implode("\n",$stack) . "
              
            </script>
        ";
        
        return $code;  
    }
    
    public static function trackElement (Element_Interface $element) {
        
        $type = "";
        if($element instanceof Document) {<commit_msg>anonymize ip for google analytics integration _gat._anonymizeIp()<commit_after><?php 
/**
 * Pimcore
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.pimcore.org/license
 *
 * @copyright  Copyright (c) 2009-2010 elements.at New Media Solutions GmbH (http://www.elements.at)
 * @license    http://www.pimcore.org/license     New BSD License
 */

class Pimcore_Google_Analytics {
    
    public static $stack = array();
    
    public static function isConfigured (Site $site = null) {
        if(self::getSiteConfig($site) && self::getSiteConfig($site)->profile) {
            return true;
        }
        return false;
    }

    public static function getSiteConfig ($site = null) {
        
        $siteKey = Pimcore_Tool_Frontend::getSiteKey($site);
        
        if(Pimcore_Config::getReportConfig()->analytics->sites->$siteKey) {
            return Pimcore_Config::getReportConfig()->analytics->sites->$siteKey;
        }
        return false;
    }
    
    public static function getCode () {
                
        $config = self::getSiteConfig();
        
        // do nothing if not configured
        if(!$config || !$config->trackid) {
            return "";
        }
        
        
        
        $stack = array();
        
        if($config->advanced) {
            foreach (self::$stack as $s) {
            $stack[] = "_gaq.push(" . Zend_Json::encode($s) . ");";
            }
            
            // remove dublicates
            $stack = array_unique($stack);
        }
        
        
        $code = "";
        $code .= "
            <script type=\"text/javascript\">

              var _gaq = _gaq || [];
              _gaq.push(['_setAccount', '" . $config->trackid . "']);
              _gaq.push (['_gat._anonymizeIp']);
              " . $config->additionalcodebeforepageview . "
              if (typeof _gaqPageView != \"undefined\"){
                _gaq.push(['_trackPageview',_gaqPageView]);
              } else {
                _gaq.push(['_trackPageview']);
              }

              " . $config->additionalcode . "
            
              (function() {
                var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
              })();
              
              " . implode("\n",$stack) . "
              
            </script>
        ";
        
        return $code;  
    }
    
    public static function trackElement (Element_Interface $element) {
        
        $type = "";
        if($element instanceof Document) {
{'fraction_non_alphanumeric': 0.13673433975360055, 'fraction_numerical': 0.0031233732431025507, 'mean_word_length': 1.6391941391941391, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 31, 'https://': 2, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4926003', 'n_tokens_mistral': 1627, 'n_tokens_neox': 1583, 'n_words': 328}