예제 #1
0
        /// <summary>
        /// Returns the metadata value for different types of metadata name.
        /// </summary>
        /// <param name="metaDataType"></param>
        /// <returns></returns>
        private String getMetaData(HtmlMetaDataType metaDataType)
        {
            IPageAssemblyInstruction asmInstr = PageAssemblyInstruction;
            string path     = asmInstr.SectionPath;
            string metaData = String.Empty;

            if (asmInstr != null)
            {
                switch (metaDataType)
                {
                case HtmlMetaDataType.Description:
                    metaData = asmInstr.GetField(PageAssemblyInstructionFields.HTML_MetaDescription);
                    break;

                case HtmlMetaDataType.KeyWords:
                    metaData = asmInstr.GetField(PageAssemblyInstructionFields.HTML_MetaKeywords);
                    break;

                case HtmlMetaDataType.Robots:
                    metaData = asmInstr.GetField(PageAssemblyInstructionFields.HTML_MetaRobots);
                    break;

                case HtmlMetaDataType.ContentLanguage:
                    metaData = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
                    break;

                case HtmlMetaDataType.Coverage:     // Suite(s)
                    metaData = SectionDetailFactory.GetSectionDetail(path).GetWASuites();
                    break;

                case HtmlMetaDataType.Subject:     // Channel(s)
                    metaData = SectionDetailFactory.GetSectionDetail(path).GetWAChannels();
                    break;

                case HtmlMetaDataType.IsPartOf:     // Content group(s)
                    metaData = SectionDetailFactory.GetSectionDetail(path).GetWAContentGroups();
                    break;

                case HtmlMetaDataType.DatePublished:
                    metaData = String.Format("{0:MM/dd/yyyy}", ((BasePageAssemblyInstruction)PageAssemblyInstruction).ContentDates.FirstPublished);
                    break;

                case HtmlMetaDataType.EnglishLinkingPolicy:
                    metaData = ContentDeliveryEngineConfig.PathInformation.EnglishLinkingPolicyPath.Path;
                    break;

                case HtmlMetaDataType.EspanolLinkingPolicy:
                    metaData = ContentDeliveryEngineConfig.PathInformation.EspanolLinkingPolicyPath.Path;
                    break;

                case HtmlMetaDataType.ContentType:
                    metaData = ((BasePageAssemblyInstruction)PageAssemblyInstruction).ContentItemInfo.ContentItemType;
                    metaData = metaData.Replace("rx:", "");
                    break;
                }
            }

            metaData = string.IsNullOrEmpty(metaData) ? "" : metaData.Trim();
            return(metaData);
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IPageAssemblyInstruction    pageInstruction = PageAssemblyContext.Current.PageAssemblyInstruction;
            BasePageAssemblyInstruction basePage        = pageInstruction as BasePageAssemblyInstruction;
            string blogName        = "";
            string blogContentType = "rx:cgvBlogPost";

            if (basePage.ContentItemInfo.ContentItemType == blogContentType)
            {
                blogName = SectionDetailFactory.GetSectionDetail(pageInstruction.SectionPath).GetWAContentGroups();
                if (!String.IsNullOrWhiteSpace(blogName))
                {
                    basePage.SetWebAnalytics(WebAnalyticsOptions.eVars.evar48.ToString(), ffD =>
                    {
                        ffD.Value = blogName + " Viewer";
                    });
                    basePage.SetWebAnalytics(WebAnalyticsOptions.Events.event53.ToString(), ffD =>
                    {
                        ffD.Value = String.Empty; // only fires off event number; no value needed
                    });
                }
            }

            this.Visible = false;
        }
예제 #3
0
        public override void RenderControl(HtmlTextWriter writer)
        {
            string        sectionPath = PageAssemblyContext.Current.PageAssemblyInstruction.SectionPath;
            SectionDetail details     = SectionDetailFactory.GetSectionDetail(sectionPath);

            if (details == null)
            {
                log.Error("Section detail cannot be null.");
                return;
            }

            //if the current page is the landing page of the root navon for the breadcrumbs, I.E. you are viewing the page that would be the root, then DO NOT DRAW ANYTHING.
            if (RootPath == details.ParentPath && details.LandingPageURL == CurrUrl)
            {
                return;
            }

            //Opening UL tag
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "breadcrumbs");
            writer.RenderBeginTag(HtmlTextWriterTag.Ul);

            //Draw parents
            RenderBreadcrumbSections(details, writer);

            //Close UL tag
            writer.RenderEndTag();
        }
예제 #4
0
        public void GetSnippetsNotAssociatedWithSlots_Test()
        {
            using (HttpSimulator httpSimulator = GetStandardSimulatedRequest())
            {
                string path = "/cancertopics";

                SectionDetail      target   = new SectionDetail(); // TODO: Initialize to an appropriate value
                List <SnippetInfo> expected = null;                // TODO: Initialize to an appropriate value
                expected = new List <SnippetInfo>()
                {
                    new SnippetInfo {
                        ContentID = "", Data = "", SlotName = "FooterSlot", SnippetTemplatePath = ""
                    },
                    new SnippetInfo {
                        ContentID = "", Data = "", SlotName = "LeftNavSlot", SnippetTemplatePath = ""
                    }
                };
                List <SnippetInfo> actual;

                List <string> snippets = new List <string>()
                {
                    "BannerSlot"
                };
                IEnumerable <string> templateSlotExclusionList = snippets;

                SectionDetail sectionDetail = SectionDetailFactory.GetSectionDetail(path);
                actual = sectionDetail.GetSnippetsNotAssociatedWithSlots(templateSlotExclusionList);
                Assert.AreEqual(expected.ToArray()[0].SlotName, actual.ToArray()[0].SlotName);
                Assert.AreEqual(expected.ToArray()[1].SlotName, actual.ToArray()[1].SlotName);
            }
        }
예제 #5
0
        public void GetSectionDetail_InvalidPath_Test()
        {
            //Initialize the Section Detail Factory
            //TODO: FIX THIS
            using (HttpSimulator httpSimulator = GetStandardSimulatedRequest())
            {
                string path = "/23423423";

                SectionDetailFactory.GetSectionDetail(path);
            }
        }
예제 #6
0
        public void GetSectionDetail_RootPath_Test()
        {
            //Initialize the Section Detail Factory
            //TODO: FIX THIS
            using (HttpSimulator httpSimulator = GetStandardSimulatedRequest())
            {
                string path = "/";

                SectionDetail expected = GetRootSectionDetailForComparison(); // TODO: Initialize to an appropriate value
                SectionDetail actual;

                actual = SectionDetailFactory.GetSectionDetail(path);

                Assert.AreEqual(expected, actual);
            }
        }
예제 #7
0
        public string Tag()
        {
            StringBuilder output       = new StringBuilder();
            string        reportSuites = "";

            // Fire off old constructor actions
            DoLegacyPageLoad();

            if (WebAnalyticsOptions.IsEnabled)
            {
                output.AppendLine("");
                output.AppendLine(WEB_ANALYTICS_COMMENT_START);

                // Report Suites JavaScript variable (s_account) must be set before the s_code file is loaded
                // Get custom suites that are set on the navon. Default suites are being set in wa_wcms_pre.js
                try
                {
                    string        sectionPath  = pgInstruction.SectionPath;
                    SectionDetail detail       = SectionDetailFactory.GetSectionDetail(sectionPath);
                    string        customSuites = detail.GetWASuites();
                    if (!string.IsNullOrEmpty(customSuites))
                    {
                        reportSuites += customSuites;
                    }
                }
                catch (Exception ex)
                {
                    log.Debug("Tag(): Exception encountered while retrieving web analytics suites.", ex);
                    reportSuites += "";
                }

                // Output analytics Javascript to HTML source in this order:
                // 1. wa_wcms_pre.js source URL
                // 2. Snippet to set s_account value
                // 3. NCIAnalyticsFunctions.js source URL (see line 47)
                // 4. s_code source URL
                // 5. Channel, Prop, eVar, and Event info
                // Note: as of 08/2018, the web analytics javascript is hosted on DTM
                output.AppendLine("<script language=\"JavaScript\" type=\"text/javascript\" src=\"" + WaPre + "\"></script>");
                output.AppendLine("<script language=\"JavaScript\" type=\"text/javascript\">");
                output.AppendLine("<!--");
                output.AppendLine("var s_account = AnalyticsMapping.GetSuites(\"" + reportSuites + "\");");
                output.AppendLine("-->");
                output.AppendLine("</script>");

                output.Append(pageLoadPreTag.ToString());

                if (pageWideLinkTracking)
                {
                    // Page-wide link tracking is current not used - this may be implemented at a future date
                    // This however should just output a JS function call that lives in the NCIAnalytics.js
                    // file instead of the inline code.
                    //output.AppendLine(LinkTrackPageLoadCode().ToString());
                }

                if (channel != "") // if channel is set, output them to the tag
                {
                    output.AppendLine("s.channel=" + DELIMITER + channel + DELIMITER + ";");
                }

                if (pageName != null) // if pageName is not null (empty string ok), output them to the tag
                {
                    output.AppendLine("s.pageName=" + DELIMITER + pageName + DELIMITER + ";");
                }

                if (pageType != "") // if pageType is set, output them to the tag
                {
                    output.AppendLine("s.pageType=" + DELIMITER + pageType + DELIMITER + ";");
                }

                if (props.Count > 0) // if props are set, output them to the tag
                {
                    foreach (var k in props.Keys.OrderBy(k => k))
                    {
                        output.AppendLine("s.prop" + k.ToString() + "=" + props[k] + ";");
                    }
                }

                if (evars.Count > 0) // if eVars are set, output them to the tag
                {
                    var items = from k in evars.Keys
                                orderby k ascending
                                select k;
                    foreach (int k in items)
                    {
                        output.AppendLine("s.eVar" + k.ToString() + "=" + evars[k] + ";");
                    }
                }

                if (events.Count > 0)  // if events have been defined, output then to the tag
                {
                    output.AppendLine("s.events=" + DELIMITER + string.Join(",", events.ToArray <string>()) + DELIMITER + ";");
                }

                output.AppendLine("");

                // Add calls to special page-load functions for a specific channel
                bool firstTime         = true;
                bool containsFunctions = false;
                foreach (string function in WebAnalyticsOptions.GetSpecialPageLoadFunctionsForChannel(channel, language))
                {
                    if (function != "")
                    {
                        if (firstTime)
                        {
                            output.AppendLine("//Special Page-Load Functions (SPLF)");
                            firstTime = false;
                        }
                        string[] functions = function.Split(',');
                        foreach (string item in functions)
                        {
                            output.AppendLine("if(typeof(NCIAnalytics." + item.Trim() + ") == 'function')");
                            output.AppendLine("   NCIAnalytics." + item.Trim() + "();");
                        }
                        containsFunctions = true;
                    }
                }
                if (containsFunctions)
                {
                    output.AppendLine("");
                }

                output.AppendLine(pageLoadPostTag.ToString());
            }
            return(output.ToString());
        }
예제 #8
0
        /// <summary>
        /// Uses the WebAnalyticsPageLoad helper class to render the required omniture java script
        /// for Web Analytics.
        /// </summary>
        /// <param name="output">HtmlTextWriter object</param>
        protected override void RenderContents(HtmlTextWriter output)
        {
            base.RenderContents(output);
            IPageAssemblyInstruction pgInstruction        = PageAssemblyContext.Current.PageAssemblyInstruction;
            WebAnalyticsSettings     webAnalyticsSettings = pgInstruction.GetWebAnalytics();
            string configChannelName = "";

            // If web analytics are present, create a new instance of WebAnalyticsPageload,
            // set its variables, and use those to draw the analytics HTML.
            if (webAnalyticsSettings != null)
            {
                WebAnalyticsPageLoad webAnalyticsPageLoad = new WebAnalyticsPageLoad();
                webAnalyticsPageLoad.SetLanguage(PageAssemblyContext.Current.PageAssemblyInstruction.GetField("language"));

                // Use pretty url to get channel name from the mapping, mapping information is in web.config
                string prettyUrl = pgInstruction.GetUrl("PrettyUrl").UriStem;
                if (!string.IsNullOrEmpty(prettyUrl))
                {
                    configChannelName = WebAnalyticsOptions.GetChannelForUrlPath(prettyUrl);
                }

                // Get the channel name from the section details. As of the cancer.gov Feline release, analytics channels
                // are set in the navons, not Web.config. The old functionality is being used in the catch block for now.
                try
                {
                    string        sectionPath = pgInstruction.SectionPath;
                    SectionDetail detail      = SectionDetailFactory.GetSectionDetail(sectionPath);
                    string        channelName = WebAnalyticsOptions.GetChannelsFromSectionDetail(detail);
                    webAnalyticsPageLoad.SetChannel(channelName);
                    webAnalyticsPageLoad.SetReportSuites(detail);
                }
                catch (Exception ex)
                {
                    log.Warn("RenderContents(): Error retrieving analytics channel.", ex);
                    webAnalyticsPageLoad.SetChannel(configChannelName);
                }

                foreach (KeyValuePair <WebAnalyticsOptions.eVars, string> kvp in webAnalyticsSettings.Evars)
                {
                    webAnalyticsPageLoad.AddEvar(kvp.Key, kvp.Value);
                }

                foreach (KeyValuePair <WebAnalyticsOptions.Events, string> kvp in webAnalyticsSettings.Events)
                {
                    webAnalyticsPageLoad.AddEvent(kvp.Key);
                }

                foreach (KeyValuePair <WebAnalyticsOptions.Props, string> kvp in webAnalyticsSettings.Props)
                {
                    webAnalyticsPageLoad.AddProp(kvp.Key, kvp.Value);
                }

                // Draw the control HTML based on the control ID
                switch (this.ID)
                {
                // Draw analytics HTML data element
                case "WebAnalyticsData":
                    webAnalyticsPageLoad.DrawAnalyticsDataTag(output);
                    break;

                // Draw s_code script block
                // This should NOT be used once DTM Analytics are in place
                case "WebAnalyticsControl1":
                case "WebAnalyticsLegacy":
                    output.Write(webAnalyticsPageLoad.Tag());
                    break;

                default:
                    break;
                }
            }
        }