protected void Page_Load(object sender, EventArgs e)
        {
            string input_term;

            if (PageAssemblyContext.Current.DisplayVersion == DisplayVersions.Web)
            {
                urlArgs    = Request.Url.Query.Substring(1);
                input_term = Strings.Clean(Request.Params["term"]);
                CdrID      = Strings.IfNull(Strings.Clean(Request.Params["id"]), Strings.Clean(Request.Params["cdrid"]));
                AudienceType   audience   = GetAudienceType(Strings.Clean(Request.Params["version"]));
                DictionaryType dictionary = GetDictionaryType(Strings.Clean(Request.Params["dictionary"]));

                //load the definition
                DictionaryAppManager _dictionaryAppManager = new DictionaryAppManager();

                DictionaryTerm dataItem = null;

                if (!string.IsNullOrEmpty(CdrID))
                {
                    CdrID = Regex.Replace(CdrID, "^CDR0+", "", RegexOptions.Compiled);
                    // call appropriate method if dictionary type is known
                    // the language is set to English = en by default
                    if (dictionary == DictionaryType.Unknown)
                    {
                        dataItem = _dictionaryAppManager.GetTermForAudience(Convert.ToInt32(CdrID), dictionaryLanguage, "v1", audience);
                    }
                    else
                    {
                        dataItem = _dictionaryAppManager.GetTerm(Convert.ToInt32(CdrID), dictionary, dictionaryLanguage, "v1", audience);
                    }
                }

                if (dataItem != null && dataItem.Term != null)
                {
                    ActivateDefinitionView(dataItem);
                }
                else
                {
                    phDefinition.Visible = false;
                    phNoResult.Visible   = true;
                }

                // Web Analytics *************************************************
                WebAnalyticsPageLoad webAnalyticsPageLoad = new WebAnalyticsPageLoad();

                webAnalyticsPageLoad.SetChannel("Dictionary of Cancer Terms");
                webAnalyticsPageLoad.SetLanguage("en");

                webAnalyticsPageLoad.AddEvent(WebAnalyticsOptions.Events.event11); // Dictionary Term view (event11)
                litOmniturePageLoad.Text = webAnalyticsPageLoad.Tag();             // Load page load script
                // End Web Analytics *********************************************
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string input_term;

            if (PageAssemblyContext.Current.DisplayVersion == DisplayVersions.Web)
            {
                urlArgs    = Request.Url.Query.Substring(1);
                input_term = Strings.Clean(Request.Params["term"]);
                CdrID      = Strings.IfNull(Strings.Clean(Request.Params["id"]), Strings.Clean(Request.Params["cdrid"]));
                AudienceType   audience   = GetAudienceType(Strings.Clean(Request.Params["version"]));
                DictionaryType dictionary = GetDictionaryType(Strings.Clean(Request.Params["dictionary"]));

                if (Request.QueryString["language"] == "Spanish")
                {
                    dictionaryLanguage        = "es";
                    logoAnchor.HRef           = "/espanol";
                    logoImage.Alt             = "Instituto Nacional Del Cáncer";
                    logoImage.Src             = "/publishedcontent/images/images/design-elements/logos/nci-logo-full-es.svg";
                    closeWindowText.InnerText = "Cerrar";
                    definitionLabel.Text      = "Definición:";
                }
                else
                {
                    logoAnchor.HRef           = "/";
                    logoImage.Alt             = "National Cancer Institute";
                    logoImage.Src             = "/publishedcontent/images/images/design-elements/logos/nci-logo-full.svg";
                    closeWindowText.InnerText = "Close Window";
                    definitionLabel.Text      = "Definition:";
                }

                //load the definition
                DictionaryAppManager _dictionaryAppManager = new DictionaryAppManager();

                DictionaryTerm dataItem = null;

                if (!string.IsNullOrEmpty(CdrID))
                {
                    CdrID = Regex.Replace(CdrID, "^CDR0+", "", RegexOptions.Compiled);

                    // call appropriate method if dictionary type is known
                    if (dictionary == DictionaryType.Unknown)
                    {
                        dataItem = _dictionaryAppManager.GetTermForAudience(Convert.ToInt32(CdrID), dictionaryLanguage, "v1", audience);
                    }
                    else
                    {
                        dataItem = _dictionaryAppManager.GetTerm(Convert.ToInt32(CdrID), dictionary, dictionaryLanguage, "v1", audience);
                    }
                }

                if (dataItem != null && dataItem.Term != null)
                {
                    ActivateDefinitionView(dataItem);
                }
                else
                {
                    phDefinition.Visible = false;
                    phNoResult.Visible   = true;
                }

                // Web Analytics *************************************************
                WebAnalyticsPageLoad webAnalyticsPageLoad = new WebAnalyticsPageLoad();

                if (dictionaryLanguage == "es")
                {
                    webAnalyticsPageLoad.SetChannel("Diccionario de cancer (Dictionary of Cancer Terms)");
                    webAnalyticsPageLoad.SetLanguage("es");
                }
                else
                {
                    webAnalyticsPageLoad.SetChannel("Dictionary of Cancer Terms");
                    webAnalyticsPageLoad.SetLanguage("en");
                }
                webAnalyticsPageLoad.AddEvent(WebAnalyticsOptions.Events.event11); // Dictionary Term view (event11)
                litOmniturePageLoad.Text = webAnalyticsPageLoad.Tag();             // Load page load script
                // End Web Analytics *********************************************
            }
        }
        /// <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;
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Event method sets frame content version and parameters
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            string     input_term;
            string     term;
            string     id;
            string     mediaHtml      = "";
            string     audioMediaHTML = String.Empty;
            PDQVersion version;
            string     pronunciation;
            string     termDefinition;

            DisplayLanguage dl = new DisplayLanguage();

            if (Request.QueryString["language"] == "English")
            {
                dl = DisplayLanguage.English;
            }
            else if (Request.QueryString["language"] == "Spanish")
            {
                dl = DisplayLanguage.Spanish;
            }
            else
            {
                dl = DisplayLanguage.English;
            }

            ValidateParams();

            //include page title
            this.pageHtmlHead.Title = "Definition - National Cancer Institute";
            input_term = Strings.Clean(Request.Params["term"]);
            id         = Strings.IfNull(Strings.Clean(Request.Params["id"]), Strings.Clean(Request.Params["cdrid"]));
            version    = PDQVersionResolver.GetPDQVersion(Strings.Clean(Request.Params["version"]));
            //version = PDQVersion.version;

            ArrayList result = null;

            if (input_term == null && id == null)
            {
                term           = "Error";
                pronunciation  = "invalid input";
                termDefinition = "You have not specified either a CDRID nor a term name.";
            }
            else
            {
                if (input_term != null && input_term.Length > 0)
                {
                    result = get_definition("term", input_term, version, dl);
                    if (result == null && input_term.EndsWith("s"))
                    {
                        result = get_definition("term", input_term.Substring(0, input_term.Length - 1), version, dl);
                        if (result == null && input_term.EndsWith("es"))
                        {
                            result = get_definition("term", input_term.Substring(0, input_term.Length - 2), version, dl);
                            if (result == null && input_term.EndsWith("ies"))
                            {
                                result = get_definition("term", input_term.Substring(0, input_term.Length - 3) + "y", version, dl);
                                if (result == null && input_term.EndsWith("um"))
                                {
                                    result = get_definition("term", input_term.Substring(0, input_term.Length - 2) + "a", version, dl);
                                    if (result == null && input_term.EndsWith("ly"))
                                    {
                                        result = get_definition("term", input_term.Substring(0, input_term.Length - 2), version, dl);
                                        if (result == null && input_term.EndsWith("ii"))
                                        {
                                            result = get_definition("term", input_term.Substring(0, input_term.Length - 2) + "us", version, dl);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    id     = Regex.Replace(id, "^CDR0+", "", RegexOptions.Compiled);
                    result = get_definition("id", id, version, dl);
                }

                if (result == null)
                {
                    term           = "term not found";
                    pronunciation  = "";
                    termDefinition = "The term you are looking for does not exist in the glossary.";
                }
                else
                {
                    term           = result[0].ToString();
                    pronunciation  = result[1].ToString();
                    termDefinition = result[2].ToString();
                    mediaHtml      = result[3].ToString();
                    mediaHtml      = mediaHtml.Replace("[__imagelocation]", ConfigurationManager.AppSettings["CDRImageLocation"]);

                    if (result[4] != null)
                    {
                        audioMediaHTML = result[4].ToString();
                        audioMediaHTML = audioMediaHTML.Replace("[_audioMediaLocation]", ConfigurationManager.AppSettings["CDRAudioMediaLocation"]);
                    }
                }
            }

            if (dl == DisplayLanguage.Spanish)
            {
                strSendPrinter = "Imprima esta página";
                pronunciation  = String.Empty;
                //strHeading = "<h3 class='popup-definition'>Definición del Diccionario de cáncer del NCI</h3>";
                strHeading = "<div class=\"heading\">Definición:</div>";
            }

            content = new HtmlSegment("<div class=\"audioPronounceLink\">"
                                      + String.Format("<span class=\"term\">{0}</span>", term)
                                      + String.Format("<span class=\"pronunciation\">{0}</span>", ((Strings.Clean(pronunciation) != null) ? " " + pronunciation : ""))
                                      + audioMediaHTML + "</div>"
                                      + String.Format("<div class=\"definition\">{0}</div>", termDefinition)
                                      + String.Format("<div class=\"definitionImage\">{0}</div>", mediaHtml)
                                      );

            // Web Analytics *************************************************
            WebAnalyticsPageLoad webAnalyticsPageLoad = new WebAnalyticsPageLoad();

            if (dl == DisplayLanguage.Spanish)
            {
                webAnalyticsPageLoad.SetChannel("Diccionario de cancer (Dictionary of Cancer Terms)");
                webAnalyticsPageLoad.SetLanguage("es");
            }
            else
            {
                webAnalyticsPageLoad.SetChannel("Dictionary of Cancer Terms");
                webAnalyticsPageLoad.SetLanguage("en");
            }
            webAnalyticsPageLoad.AddEvent(WebAnalyticsOptions.Events.event11); // Dictionary Term view (event11)
            litOmniturePageLoad.Text = webAnalyticsPageLoad.Tag();             // Load page load script
            // End Web Analytics *********************************************
        }