Author: fpunt
Date: 2009-06-04 15:09:41 +0200 (Thu, 04 Jun 2009)
New Revision: 35727

Modified:
   
CMSContainer/branches/b1_5/CMSContainer/cmsc/taglib/src/java/com/finalist/cmsc/taglib/stats/GoogleAnalyticsTag.java
   CMSContainer/branches/b1_5/CMSContainer/cmsc/taglib/src/tld/cmsc.tld
Log:
CMSC-1420 Solved, now also looking at site field

Modified: 
CMSContainer/branches/b1_5/CMSContainer/cmsc/taglib/src/java/com/finalist/cmsc/taglib/stats/GoogleAnalyticsTag.java
===================================================================
--- 
CMSContainer/branches/b1_5/CMSContainer/cmsc/taglib/src/java/com/finalist/cmsc/taglib/stats/GoogleAnalyticsTag.java
 2009-06-04 13:08:32 UTC (rev 35726)
+++ 
CMSContainer/branches/b1_5/CMSContainer/cmsc/taglib/src/java/com/finalist/cmsc/taglib/stats/GoogleAnalyticsTag.java
 2009-06-04 13:09:41 UTC (rev 35727)
@@ -11,9 +11,10 @@
 
 import java.io.IOException;
 
-import javax.naming.*;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
 import javax.servlet.jsp.PageContext;
-import javax.servlet.jsp.tagext.SimpleTagSupport;
 
 import net.sf.mmapps.commons.util.EncodingUtil;
 import net.sf.mmapps.modules.cloudprovider.CloudProviderFactory;
@@ -24,11 +25,14 @@
 import org.mmbase.util.logging.Logger;
 import org.mmbase.util.logging.Logging;
 
+import com.finalist.cmsc.beans.om.Site;
 import com.finalist.cmsc.mmbase.PropertiesUtil;
 import com.finalist.cmsc.repository.RepositoryUtil;
+import com.finalist.cmsc.services.sitemanagement.SiteManagement;
+import com.finalist.cmsc.taglib.CmscTag;
 import com.finalist.cmsc.util.ServerUtil;
 
-public class GoogleAnalyticsTag extends SimpleTagSupport {
+public class GoogleAnalyticsTag extends CmscTag {
    /** MMbase logging system */
    private static Logger log = Logging
          .getLoggerInstance(GoogleAnalyticsTag.class.getName());
@@ -62,21 +66,25 @@
    public void doTag() throws IOException {
 
       /*
-       * Find out where to get our account from, search order: 1) The
-       * "account"-parameter passed to the tag (only when available, live and
-       * production) 2) The "googleAnalytics/account" setting in the context
-       * XML (only when available) 3) The "googleanalytics.account" system
-       * property, from the system properties (only when available, live and
-       * production)
+       * Find out where to get our account from, search order: 
+       * 1) The "account"-parameter passed to the tag (only when available, 
live and production) 
+       * 2) The "googleAnalytics/account" setting in the context XML (only 
when available, one of the two prefered methods) 
+       * 3) The "googleanalytics.account" system property, from the system 
properties (only  when available, live and production)
+       * 4) The googleanaliticsId field of the site (only when available, the 
other prefered method)
        */
       String account = null;
       boolean isLiveProduction = (ServerUtil.isProduction() && 
(ServerUtil.isLive() || ServerUtil.isSingle()));
+      String parameterAccount = 
PropertiesUtil.getProperty("googleanalytics.account");
+      
       if (StringUtils.isNotBlank(accountParameter) && isLiveProduction) {
          account = accountParameter;
-      } else if (contextAccount != null) {
+      } else if (StringUtils.isNotBlank(contextAccount)) {
          account = contextAccount;
+      } else if (StringUtils.isNotBlank(parameterAccount) && isLiveProduction) 
{
+         account = parameterAccount;
       } else if (isLiveProduction) {
-         account = PropertiesUtil.getProperty("googleanalytics.account");
+         Site site = SiteManagement.getSiteFromPath(getPath());
+         account = site.getGoogleanalyticsid();
       }
 
       // Include the google analytics code

Modified: CMSContainer/branches/b1_5/CMSContainer/cmsc/taglib/src/tld/cmsc.tld
===================================================================
--- CMSContainer/branches/b1_5/CMSContainer/cmsc/taglib/src/tld/cmsc.tld        
2009-06-04 13:08:32 UTC (rev 35726)
+++ CMSContainer/branches/b1_5/CMSContainer/cmsc/taglib/src/tld/cmsc.tld        
2009-06-04 13:09:41 UTC (rev 35727)
@@ -1528,9 +1528,10 @@
         Meant to put in the body of a page, please note that if you want to 
use events, 
         there has to be a normal tag first. 
         Search order of the google analytics account used:
-                * 1) The "account"-parameter passed to the tag (only when 
available, live and production)
-                * 2) The "googleAnalytics/account" setting in the context XML 
(only when available, this is the prefered manner)
-                * 3) The "googleanalytics.account" system property, from the 
system properties (only when available, live and production)
+       * 1) The "account"-parameter passed to the tag (only when available, 
live and production) 
+       * 2) The "googleAnalytics/account" setting in the context XML (only 
when available, one of the two prefered methods) 
+       * 3) The "googleanalytics.account" system property, from the system 
properties (only  when available, live and production)
+       * 4) The googleanaliticsId field of the site (only when available, the 
other prefered method)
         </description>
         <name>google-analytics</name>
         
<tag-class>com.finalist.cmsc.taglib.stats.GoogleAnalyticsTag</tag-class>

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to