Author: Jonathan.Wage
Date: 2010-02-18 02:46:35 +0100 (Thu, 18 Feb 2010)
New Revision: 28103

Added:
   plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/events/
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/events/sfSympalRenderingResponseFilterContentListener.class.php
Modified:
   
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/config/sfSympalRenderingPluginConfiguration.class.php
Log:
[1.4][sfSympalPlugin][1.0] Fixing issue with old google analytics js and 
updated event listener to new implementation


Modified: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/config/sfSympalRenderingPluginConfiguration.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/config/sfSympalRenderingPluginConfiguration.class.php
      2010-02-18 01:15:48 UTC (rev 28102)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/config/sfSympalRenderingPluginConfiguration.class.php
      2010-02-18 01:46:35 UTC (rev 28103)
@@ -4,22 +4,11 @@
 {
   public function initialize()
   {
-    $this->dispatcher->connect('response.filter_content', array($this, 
'listenToResponseFilterContent'));
+    $this->dispatcher->connect('sympal.load', array($this, 
'listenToSympalLoad'));
   }
 
-  public function listenToResponseFilterContent(sfEvent $event, $content)
+  public function listenToSympalLoad(sfEvent $event)
   {
-    if ($code = sfSympalConfig::get('google_analytics_code'))
-    {
-      $js = '<script src="http://www.google-analytics.com/urchin.js"; 
type="text/javascript">
-</script>
-<script type="text/javascript">
-_uacct = "'.$code.'";
-urchinTracker();
-</script>';
-      return str_replace('</body>', $js.'</body>', $content);
-    } else {
-      return $content;
-    }
+    new sfSympalRenderingResponseFilterContent($this->dispatcher, $this);
   }
 }
\ No newline at end of file

Added: 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/events/sfSympalRenderingResponseFilterContentListener.class.php
===================================================================
--- 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/events/sfSympalRenderingResponseFilterContentListener.class.php
                                (rev 0)
+++ 
plugins/sfSympalPlugin/trunk/lib/plugins/sfSympalRenderingPlugin/lib/events/sfSympalRenderingResponseFilterContentListener.class.php
        2010-02-18 01:46:35 UTC (rev 28103)
@@ -0,0 +1,30 @@
+<?php
+
+class sfSympalRenderingResponseFilterContent extends sfSympalListener
+{
+  public function getEventName()
+  {
+    return 'response.filter_content';
+  }
+
+  public function run(sfEvent $event, $content)
+  {
+    if ($code = sfSympalConfig::get('google_analytics_code'))
+    {
+      $js = <<<EOF
+<script type="text/javascript">
+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"));
+</script>
+<script type="text/javascript">
+try {
+       var pageTracker = _gat._getTracker("$code");
+       pageTracker._trackPageview();
+} catch(err) {}</script>
+EOF;
+      return str_replace('</body>', $js.'</body>', $content);
+    } else {
+      return $content;
+    }
+  }
+}
\ No newline at end of file

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to