예제 #1
0
        private void RenderEmailButtonItem(HtmlTextWriter writer, EmailButtonItem button)
        {
            string btnAlt = string.Empty;

            if (!string.IsNullOrEmpty(button.Title.Trim()))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Title, button.Title);
                btnAlt = button.Title;
            }
            writer.AddAttribute(HtmlTextWriterAttribute.Href, pgInstruction.GetUrl("email").ToString());
            string emailOnClick = string.Empty;

            if (!string.IsNullOrEmpty(button.WebAnalytics.Trim()))
            {
                emailOnClick += button.WebAnalytics;
            }
            emailOnClick += " " + "dynPopWindow('" + pgInstruction.GetUrl("email").ToString().Replace("'", "%27").Replace("(", "%28").Replace(")", "%29") + "', 'emailPopUp', 'height=525,width=492'); return false;";
            writer.AddAttribute(HtmlTextWriterAttribute.Onclick, emailOnClick);
            writer.RenderBeginTag(HtmlTextWriterTag.A);
            writer.AddAttribute(HtmlTextWriterAttribute.Alt, btnAlt);
            writer.AddAttribute(HtmlTextWriterAttribute.Src, "/publishedcontent/images/images/spacer.gif");
            writer.RenderBeginTag(HtmlTextWriterTag.Img);
            writer.RenderEndTag(); // img
            writer.RenderEndTag(); // a
        }
        /// <summary>
        /// This method intialize the state of the base object or peform tasks that are
        /// applicable to all derived class object.
        /// </summary>
        public virtual void Initialize()
        {
            IPageAssemblyInstruction pgInst = ((IPageAssemblyInstruction)this);

            // field filters
            pgInst.AddFieldFilter("invokedFrom", (name, field) =>
            {
                field.Value = String.Empty;
            });

            pgInst.AddFieldFilter("language", (name, field) =>
            {
                string languageValue = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
                field.Value          = languageValue;
            });

            // URL filters
            pgInst.AddUrlFilter("RootPrettyURL", (name, url) =>
            {
                url.SetUrl(pgInst.GetUrl("CurrentURL").ToString());
                // This is  hack to fix the RootPrettyURL. If  this content type is
                // rx:pdqCancerInfoSummary then remove the 'patient' or 'healthprofessional' from
                // the pretty url
                string prettyUrl = pgInst.GetUrl("PrettyURL").ToString().ToLower();
                if (ContentItemInfo != null && ContentItemInfo.ContentItemType == "rx:pdqCancerInfoSummary")
                {
                    int verIndex = prettyUrl.LastIndexOf("/patient");
                    if (verIndex == -1)
                    {
                        verIndex = prettyUrl.LastIndexOf("/healthprofessional");
                    }
                    if (verIndex != -1)
                    {
                        prettyUrl = prettyUrl.Substring(0, verIndex);
                    }
                }
                url.SetUrl(prettyUrl);
            });

            pgInst.AddUrlFilter("BookMarkShareUrl", (name, url) =>
            {
                url.SetUrl(pgInst.GetUrl("CurrentURL").ToString());
            });

            pgInst.AddUrlFilter("EmailUrl", (name, url) =>
            {
                url.SetUrl(pgInst.GetUrl("CurrentURL").ToString());
            });

            pgInst.AddUrlFilter("PostBackURL", (name, url) =>
            {
                url.SetUrl(pgInst.GetUrl("CurrentURL") + "?" + HttpContext.Current.Request.QueryString);
            });
        }
        /// <summary>
        /// Adds an appropriate FieldFilter to the given PageAssemblyInstruction object, based on the Tag's
        /// current settings.
        /// </summary>
        /// <param name="pai">The IPageAssemblyInstruction object to receive the new FieldFilter.</param>
        private void RegisterSocialMetaTagFieldFilter(IPageAssemblyInstruction pai, SocialMetaTagData socialMetaTag)
        {
            // add a field filter for each tag
            pai.AddFieldFilter(socialMetaTag.Id, (name, data) =>
            {
                string content = String.Empty;
                switch (socialMetaTag.Source)
                {
                case SocialMetaTagSources.field:
                    content = pai.GetField(socialMetaTag.Content);
                    break;

                case SocialMetaTagSources.url:
                    content = pai.GetUrl(socialMetaTag.Content).ToString();
                    break;

                // both literal types just use the content directly
                default:
                    content = socialMetaTag.Content;
                    break;
                }

                data.Value = content;
            });
        }
        /// <summary>
        /// Register all site wide field filters for Web Analytics.
        /// </summary>
        protected virtual void RegisterWebAnalyticsFieldFilters()
        {
            IPageAssemblyInstruction pgInst = ((IPageAssemblyInstruction)this);

            // Add root pretty URL
            SetWebAnalytics(WebAnalyticsOptions.Props.prop3.ToString(), wbField =>
            {
                wbField.Value = pgInst.GetUrl("RootPrettyURL").ToString();
            });
        }
        public void GetUrl_PrettyURL_Test()
        {
            IPageAssemblyInstruction pageAssemblyInfo = null;

            pageAssemblyInfo = InitializeTestPageAssemblyInfo();


            NciUrl PrettyUrl = new NciUrl();

            PrettyUrl = pageAssemblyInfo.GetUrl(PageAssemblyInstructionUrls.PrettyUrl);

            Assert.AreEqual <string>("/multicancertopics", PrettyUrl.UriStem);
        }
        public void GetUrl_Cannonical_Test()
        {
            IPageAssemblyInstruction pageAssemblyInfo = null;

            pageAssemblyInfo = InitializeTestPageAssemblyInfo();



            NciUrl CanonicalUrl = new NciUrl();

            CanonicalUrl = pageAssemblyInfo.GetUrl(PageAssemblyInstructionUrls.CanonicalUrl);

            Assert.AreEqual <string>("/multicancertopics", CanonicalUrl.UriStem);
        }
        public void GetUrl_Test()
        {
            IPageAssemblyInstruction pageAssemblyInfo = null;

            pageAssemblyInfo = InitializeTestPageAssemblyInfo();


            pageAssemblyInfo.AddUrlFilter("foo", (name, url) =>
            {
                url.Clear();
                url.UriStem = "/foo";
            });

            NciUrl expected = new NciUrl();

            expected.UriStem = "/foo";

            Assert.AreEqual(expected.ToString(), pageAssemblyInfo.GetUrl("foo").ToString());
        }
예제 #8
0
        /// <summary>
        /// Process the page options information in the xml and creates
        /// the page options items.
        /// </summary>
        /// <param name="snippetXmlData">The xml fragment which contains pageoptions information.</param>
        private void processPageOptionsData(string snippetXmlData)
        {
            // The snippet CDATA may contain CDATA as part of the data but percussion replaces the CDATA
            // close tag with Replace ']]>' with ']]ENDCDATA' this ']]ENDCDATA' should be replaced with
            // valid CDATA close tag ']]>' before it can be deserialized
            snippetXmlData = snippetXmlData.Replace("]]ENDCDATA", "]]>");

            IPageAssemblyInstruction pgInstruction = PageAssemblyContext.Current.PageAssemblyInstruction;

            // If AlternateContentVersions information is not in the instructions then do not create
            // the PageOptions box.
            string[] acvKeys = pgInstruction.AlternateContentVersionsKeys;

            if (acvKeys != null)
            {
                Module_PageOptionsBox mPBO = ModuleObjectFactory <Module_PageOptionsBox> .GetModuleObject(snippetXmlData);

                if (mPBO != null)
                {
                    // Create the Page Options box control.
                    PageOptionsBox pageOptionsBox = new PageOptionsBox();
                    pageOptionsBox.BoxTitle = mPBO.Title;
                    pageOptionsBox.CssClass = "po-box";

                    foreach (PageOption pgOptionItem in mPBO.PageOptions)
                    {
                        try
                        {
                            // Check if the Pageoptions are recognized in the Alternate Content Version keys
                            string key = pgOptionItem.Key;

                            if (!string.IsNullOrEmpty(key))
                            {
                                key = key.ToLower();
                            }

                            if (acvKeys.Contains <string>(key))
                            {
                                NCI.Web.UI.WebControls.PageOption pgoBase = null;

                                if (String.Compare(pgOptionItem.OptionType, PageOptionType.Link.ToString()) == 0)
                                {
                                    pgoBase = new LinkPageOption();
                                    ((LinkPageOption)pgoBase).OnClick = pgOptionItem.WebAnalyticsFunction;
                                    ((LinkPageOption)pgoBase).Href    = pgInstruction.GetUrl(key).ToString();
                                }
                                else if (String.Compare(pgOptionItem.OptionType, PageOptionType.Email.ToString()) == 0)
                                {
                                    pgoBase = new LinkPageOption();
                                    ((LinkPageOption)pgoBase).Href     = pgInstruction.GetUrl("email").ToString();
                                    ((LinkPageOption)pgoBase).OnClick  = pgOptionItem.WebAnalyticsFunction;
                                    ((LinkPageOption)pgoBase).OnClick += " " + "dynPopWindow('" + ((LinkPageOption)pgoBase).Href.Replace("'", "%27").Replace("(", "%28").Replace(")", "%29") + "', 'emailPopUp', 'height=525,width=492'); return false;";
                                }
                                else if (String.Compare(pgOptionItem.OptionType, PageOptionType.BookMarkShare.ToString()) == 0)
                                {
                                    pgoBase = new AddThisPageOption();
                                    ((AddThisPageOption)pgoBase).Settings.Language = pgInstruction.Language;
                                    //((AddThisPageOption)pgoBase).PageTitle = pgInstruction.GetField("long_description").ToString();  //pgInstruction.GetUrl("BookMarkShareUrl").ToString();
                                    ((AddThisPageOption)pgoBase).PageTitle = pgInstruction.GetField("long_title").ToString();
                                    ((AddThisPageOption)pgoBase).OnClick   = pgOptionItem.WebAnalyticsFunction;
                                }

                                if (pgoBase != null)
                                {
                                    pgoBase.CssClass = pgOptionItem.CssClass;
                                    pgoBase.LinkText = pgOptionItem.LinkText;
                                    pageOptionsBox.PageOptions.Add(pgoBase);
                                }
                            }
                        }
                        catch
                        {
                            //TODO, log exception
                        }
                    }

                    if (pageOptionsBox.PageOptions.Count > 0)
                    {
                        this.Controls.Add(pageOptionsBox);
                    }
                }
            }
        }
예제 #9
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;
                }
            }
        }