/// <summary> /// Implement OnLoad Event to handle fetching of results. /// Prevents derrived classes from implementing. /// </summary> /// <param name="e"></param> sealed protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Step 1. Load config from App Module Page content item // Set Dictionary Mapping Filepath according to current language this.DictionaryConfig = ModuleObjectFactory <DictionaryConfig> .GetModuleObject(this.SnippetInfo.Data); //Step 2. Parse URL and pull out q, expand, and contains parameters for new URL syntax this.SetupUrls(); String searchString = Strings.Clean(Request.QueryString["q"]); // default results to 'A' if no term chosen String expand = Strings.Clean(Request.QueryString["expand"], "A"); // String language = Strings.Clean(Request.QueryString["language"]); String contains = Strings.Clean(Request.QueryString["contains"], "false"); String first = Strings.Clean(Request.QueryString["first"]); String page = Strings.Clean(Request.QueryString["page"]); // Step 3. Get URL query parameters for expand and handling old URL syntax String legacySearchString = Strings.Clean(Request.QueryString["search"]); String legacyCdrId = Strings.Clean(Request.QueryString["cdrid"]); String legacyId = Strings.Clean(Request.QueryString["id"]); // Step 4. Load control depending on URL and path // Path is either /search?q=<term> or /def/<term or code> // Old URLs (?search=, ?cdrid=, ?id=, ?expand= get redirected or handled BaseDictionaryControl dictionaryControl = null; List <string> route = this.CurrAppPath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries).ToList <string>(); for (int i = 0; i < route.Count; i++) { route[i] = Strings.Clean(route[i]); } if (route.Count > 0) { if (route[0].Equals("search") || route[0].Equals("buscar")) { // If path is /search, load the ResultsList control dictionaryControl = LoadResultsListControl(); } else if (route[0].Equals("def")) { // If path is /def, load DefinitionView control string friendlyName = GetFriendlyName(route[1]); if (!string.IsNullOrEmpty(friendlyName)) { RedirectToDefinitionView(friendlyName); } else { dictionaryControl = LoadDefinitionViewControl(); } } else if (route.Count > 2) { // If path extends further than /search or /def/<term>, raise a 400 error NCI.Web.CDE.Application.ErrorPageDisplayer.RaisePageByCode("Dictionary", 400, "Invalid parameters for dictionary"); } } else if (!String.IsNullOrEmpty(legacySearchString)) { // redirect to new search URL using searchString as term RedirectToResultsList(legacySearchString, contains, first, page); } else if (!String.IsNullOrEmpty(legacyCdrId)) { // redirect to new view URL using cdrId // check for friendly name RedirectToDefinitionView(legacyCdrId); } else if (!String.IsNullOrEmpty(legacyId)) { // redirect to new view URL using cdrId or id // check for friendly name RedirectToDefinitionView(legacyId); } else if (dictionaryControl == null && !String.IsNullOrEmpty(expand)) { dictionaryControl = LoadExpandListControl(); } else { dictionaryControl = LoadExpandListControl(); } // Add control to page if (dictionaryControl != null) { dictionaryControl.DictionaryConfiguration = this.DictionaryConfig; dictionaryControl.PageInstruction = this.PageInstruction; dictionaryControl.DictionaryRouter = this; phDictionary.Controls.Add(dictionaryControl); } }
protected override BaseDictionaryControl LoadResultsListControl() { localControl = (BaseDictionaryControl)Page.LoadControl("~/SnippetTemplates/TermDictionary/Views/TermDictionaryResultsList.ascx"); return(localControl); }
protected override BaseDictionaryControl LoadDefinitionViewControl() { localControl = (BaseDictionaryControl)Page.LoadControl("~/SnippetTemplates/TermDictionary/Views/TermDictionaryDefinitionView.ascx"); return(localControl); }
protected override BaseDictionaryControl LoadExpandListControl() { localControl = (BaseDictionaryControl)Page.LoadControl("~/SnippetTemplates/DrugDictionary/Views/DrugDictionaryExpandList.ascx"); return(localControl); }