public void LoadDynamicList() { // In this case the snippet info data is not HTML(which is often the case) // but xml data which contains rendering properties for each page option item string xmlData = @"<?xml version=""1.0"" encoding=""utf-8""?> <cde:Module_DynamicList xsi:schemaLocation=""http://www.example.org/CDESchema CDESchema.xsd"" xmlns:cde=""http://www.example.org/CDESchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""> <SearchTitle>search_title field</SearchTitle> <RecordsPerPage>1</RecordsPerPage> <MaxResults>100</MaxResults> <SearchFilter>search_filter field</SearchFilter> <ExcludeSearchFilter>exclude_search_filter field</ExcludeSearchFilter> <ResultsSortOrder>results_sort_order field</ResultsSortOrder> <Language>language field</Language> <SearchType>search_type field</SearchType> <SearchParameters> <Keyword>keyword field</Keyword> <StartDate>01/01/1919</StartDate> <EndDate>01/02/1919</EndDate> </SearchParameters> <ResultsTemplate> <![CDATA[ The template which will be used to render the results on the CDE. See RQ002027 ]]> </ResultsTemplate> </cde:Module_DynamicList>"; DynamicList obj = ModuleObjectFactory <DynamicList> .GetModuleObject(xmlData); Assert.IsNotNull(obj); }
public void Page_Load(object sender, EventArgs e) { if (this.BlogSearchList == null) { this.BlogSearchList = ModuleObjectFactory <BlogSearchList> .GetModuleObject(SnippetInfo.Data); } processData(); }
public void Page_Load(object sender, EventArgs e) { // FIX THIS COMMENT BasePageAssemblyInstruction basePage = PageAssemblyContext.Current.PageAssemblyInstruction as BasePageAssemblyInstruction; if (basePage == null) { return; } bool isCommentingAvailable = Strings.ToBoolean(PageAssemblyContext.Current.PageAssemblyInstruction.GetField("is_commenting_available"), false, false); log.DebugFormat("Page_Load(): SocialMetadata isCommentingAvailable value is {0}", isCommentingAvailable); // if commenting is not available, then done with processing if (!isCommentingAvailable) { return; } // initialize the control theControl = new IntenseDebateControl(); // load the account from settings IntenseDebateCommentsSettings intenseDebateCommentsSettings = ModuleObjectFactory <IntenseDebateCommentsSettings> .GetModuleObject(SnippetInfo.Data); if (intenseDebateCommentsSettings != null) { string account = intenseDebateCommentsSettings.DevAccount; // do not configure the control if no account available if (String.IsNullOrEmpty(intenseDebateCommentsSettings.DevAccount) || String.IsNullOrEmpty(intenseDebateCommentsSettings.LiveAccount)) { theControl.Dispose(); theControl = null; return; } // check if the site is in production bool isProd = PageAssemblyContext.Current.IsProd; // append a shortname prefix based on the production state theControl.Account = (isProd ? intenseDebateCommentsSettings.LiveAccount : intenseDebateCommentsSettings.DevAccount); } // add the control this.Controls.Add(theControl); // begin setting the control's properties // identifer string contentType = basePage.ContentItemInfo.ContentItemType; string contentId = basePage.ContentItemInfo.ContentItemID; theControl.Identifier = contentType + "-" + contentId; // split based on multipage or singlepage theControl.Title = PageAssemblyContext.Current.PageAssemblyInstruction.GetField("short_title"); theControl.URL = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + PageAssemblyContext.Current.PageAssemblyInstruction.GetUrl("PrettyUrl"); theControl.CommentPolicyText = intenseDebateCommentsSettings.CommentPolicy; }
public void Page_Load(object sender, EventArgs e) { SearchBoxSettings searchBoxSettings = ModuleObjectFactory <SearchBoxSettings> .GetModuleObject(SnippetInfo.Data); if (searchBoxSettings != null) { this.Title = searchBoxSettings.Title; this.ActionURL = searchBoxSettings.ActionUrl; this.WebAnalyticsFunction = searchBoxSettings.WebAnalyticsFunction; this.SearchType = searchBoxSettings.SearchType; } }
/// <summary> /// Identify the Templates on the Page. For each template add the Snippet info objects. /// </summary> /// <param name="e">Not Used</param> protected override void OnInit(EventArgs e) { base.OnInit(e); loadTemplateSlots(); loadSnippetsIntoTemplateSlots(); string snippetXmlData = this.SnippetInfo.Data; snippetXmlData = snippetXmlData.Replace("]]ENDCDATA", "]]>"); _subLayoutInfo = ModuleObjectFactory <SublayoutInfo> .GetModuleObject(snippetXmlData); this.AddFieldFilter("sublayout_title", (name, data) => { data.Value = this.Title; }); }
public void Page_Load(object sender, EventArgs e) { // FIX THIS COMMENT SinglePageAssemblyInstruction basePage = PageAssemblyContext.Current.PageAssemblyInstruction as SinglePageAssemblyInstruction; if (basePage == null) { return; } BlogSeriesArchiveSettings blogSeriesArchiveSettings = ModuleObjectFactory <BlogSeriesArchiveSettings> .GetModuleObject(SnippetInfo.Data); // initialize the control var language = PageAssemblyContext.Current.PageAssemblyInstruction.Language; string years = blogSeriesArchiveSettings.Years; string groupBy = blogSeriesArchiveSettings.GroupBy; string blogMainPage = blogSeriesArchiveSettings.BlogMainPage; string blogSeriesId = "Blog Series-" + blogSeriesArchiveSettings.BlogSeriesId; theControl = new BlogSeriesArchiveControl(language, groupBy, blogMainPage); // load the shortname from settings if (blogSeriesArchiveSettings != null) { // do not configure the control if no shortname available if (String.IsNullOrEmpty(years)) { return; } } var results = BlogArchiveDataManager.Execute(blogSeriesId, Int32.Parse(years)); theControl.results = results; // add the control this.Controls.Add(theControl); }
protected void Page_PreRender(object sender, EventArgs e) { //Get Settings if (Request.RequestType == "POST") { } else { //The method was a GET, therfore we must be paging. _currentPage = Strings.ToInt(Request.Params["PageNum"], 1); _recordsPerPage = Strings.ToInt(Request.Params["RecordsPerPage"], 10); _offSet = Strings.ToInt(Request.Params["OffSet"], 0); } if (PerformSearch) { if (Keyword != null) { //Store keyword in viewstate (This does not check if it is not there already) if (ViewState[swKeyword] == null) { ViewState.Add(swKeyword, Keyword); } else { ViewState[swKeyword] = Keyword; } //set up the search collection //determine what text needs to be removed from the title e.g. - National Cancer Institute SiteWideSearchConfig searchConfig = ModuleObjectFactory <SiteWideSearchConfig> .GetModuleObject(SnippetInfo.Data); if (searchConfig != null) { SearchCollection = searchConfig.SearchCollection; ResultTitleText = searchConfig.ResultTitleText; } try { long dimFilter = Strings.ToLong(ConfigurationManager.AppSettings["EndecaSWSearchDimFilter"], 0); ISiteWideSearchResultCollection results = NCI.Search.SiteWideSearch.GetSearchResults(SearchCollection, Keyword, _recordsPerPage, (_currentPage - 1) * _recordsPerPage); rptSearchResults.DataSource = results; rptSearchResults.DataBind(); if (results.ResultCount == 0) { ResultsText = "No results found"; rptSearchResults.Visible = false; } else { int startRecord = 0; int endRecord = 0; _resultsFound = true; SimplePager.GetFirstItemLastItem(_currentPage, _recordsPerPage, (int)results.ResultCount, out startRecord, out endRecord); //phNoResultsLabel.Visible = false; rptSearchResults.Visible = true; string resultsCount = String.Format("{0}-{1} of {2}", startRecord.ToString(), endRecord.ToString(), results.ResultCount.ToString()); ResultsText = "Results " + resultsCount; } spPager.RecordCount = (int)results.ResultCount; spPager.RecordsPerPage = _recordsPerPage; spPager.CurrentPage = _currentPage; spPager.BaseUrl = PrettyUrl + "?swKeywordQuery=" + Keyword; } catch (Exception ex) { //capture exactly which keyword caused the error log.ErrorFormat("Search with the following keyword returned an error: {0}", ex, Keyword); } } else { ResultsText = "No results found"; rptSearchResults.Visible = false; } } else { ResultsText = String.Empty; } }
/// <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); } } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); string searchType = Strings.Clean(Request.Params["cbsubmit"]); int startMonth = Strings.ToInt(Strings.Clean(Request.Params["startMonth"])); int startYear = Strings.ToInt(Strings.Clean(Request.Params["startYear"])); int endMonth = Strings.ToInt(Strings.Clean(Request.Params["endMonth"])); int endYear = Strings.ToInt(Strings.Clean(Request.Params["endYear"])); keyword = Strings.Clean(Request.Params["cbkeyword"]); int currentPage = Strings.ToInt(Strings.Clean(Request.Params["page"])); bool bSearchRange = false; if (Page.Request.HttpMethod == "POST") { bSearchRange = (Request.Params["searchRangeButton"] != null); } else { bSearchRange = (searchType != null && string.Compare(searchType, "range", true) == 0); } firstRecord = 0; lastRecord = 0; totalItems = 0; if (currentPage < 0) { currentPage = 1; } int pageSize = 10; if (keyword == null) { resultsHtml = "<br><br>Please enter a search phrase.<br><br><br>"; } else { firstRecord = (currentPage - 1) * pageSize + 1; recordIndex = firstRecord; //set up the search collection //determine what text needs to be removed from the title e.g. - National Cancer Institute SiteWideSearchConfig searchConfig = ModuleObjectFactory <SiteWideSearchConfig> .GetModuleObject(SnippetInfo.Data); if (searchConfig != null) { SearchCollection = searchConfig.SearchCollection; ResultTitleText = searchConfig.ResultTitleText; } ISiteWideSearchResultCollection results; try { results = NCI.Search.SiteWideSearch.GetSearchResults(SearchCollection, Keyword, pageSize, (currentPage - 1) * pageSize); if (results != null && results.ResultCount > 0) { lastRecord = firstRecord + (int)results.ResultCount - 1; totalItems = (int)results.ResultCount; ResultRepeater.DataSource = results; ResultRepeater.DataBind(); //pager code string urlFormat; string pagerUrl; if (bSearchRange) { urlFormat = PrettyUrl + "?cbsubmit=range&cbkeyword={0}&startMonth={1}&startYear={2}&endMonth={3}&endYear={4}"; pagerUrl = String.Format(urlFormat, Server.UrlEncode(keyword), startMonth.ToString(), startYear.ToString(), endMonth.ToString(), endYear.ToString()); } else { urlFormat = PrettyUrl + "?cbkeyword={0}"; pagerUrl = String.Format(urlFormat, Server.UrlEncode(keyword)); } ResultPager objPager = new ResultPager(pagerUrl, currentPage, pageSize, 2, totalItems); pager = objPager.RenderPager(); } else { firstRecord = 0; } } catch (Exception ex) { //capture exactly which keyword caused the error log.ErrorFormat("{0} - Search with the following keyword returned an error: {1}", ex, PrettyUrl, Keyword); this.RaiseErrorPage(); } //eSearch.FillSearchResults(eSearchResults); } this.PageInstruction.AddFieldFilter("channelName", (fieldName, data) => { data.Value = "Newsletter"; }); }
/// <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); } }
/// <summary> /// Event method sets content version and template and user control properties<br /><br /> /// [1] Input form parameters:<br /> /// keyword {string: search string},<br /> /// first {integer: ordinal index of first result},<br /> /// resultSearch {string: search within results search string},<br /> /// chkCategories {comma-delimited set of strings: specific virtual paths to search},<br /> /// selectedPage {integer: current result page number}<br /> /// [2] Builds Verity and BestBet query language and Verity query xml document<br /> /// [3] Parses Verity results and errors<br /> /// [4] Builds Verity and BestBet result HTML<br /> /// [5] Builds paging control for results browsing<br /> /// </summary> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); //Setup the title, header, and left nav SetupCancerGovPageStuff(); SetLabels(); //Hide the error message phError.Visible = false; //set up the search collection (CancerGovEnglish or CancerGovSpanish) //determine what text needs to be removed from the title e.g. - National Cancer Institute SiteWideSearchConfig searchConfig = ModuleObjectFactory <SiteWideSearchConfig> .GetModuleObject(SnippetInfo.Data); if (searchConfig != null) { SearchCollection = searchConfig.SearchCollection; } if (Page.Request.RequestType == "POST") { if (!IsPostBack) { /*********************************************/ /* Search using header search box */ /*********************************************/ Keyword = Request.Params["swKeyword"]; if (Keyword == string.Empty) { ShowErrorMessage(); } else { LoadResults(); //Log User Input for initial search. LogUserInput("Keyword:" + Keyword); } } else { //This is a postback from a user changing the items per page or //searching within results. There is one problem though. //By default, if (Strings.Clean(Request.Params["__EVENTTARGET"]) == null && Strings.Clean(Request.Params["__EVENTARGUMENT"]) == null && Strings.Clean(Request.Params[btnTextChangePageUnit.UniqueID]) == null && Strings.Clean(Request.Params[btnSWRTxtSearch.UniqueID]) == null) { //THIS IS FOR IE with no JS. Oddly in most ways it is more broken than firefox, but //is so broken that we can easily tell that the user hit enter on the only //text box. //Basically if all the buttons that can be clicked are null, and there //is no event target or argument, then this is IE with Javascript turned //off and the user clicked enter on the text box. Also, image buttons do //not come back ID, but ID.x and ID.y. (Hopefully screen readers send those //things too. // //We need to handle this stuff after all the other postback events happen. //so lets just set a variable for now. _isIENoJSAndHitEnderInTheSearchBox = true; } } } else { /*********************************************/ /* Either Paging or a DYM Click */ /*********************************************/ //No Matter if this is a DYM or a Paging, swKeyword is the keyword. (There may be an old one, but that is for later) Keyword = Request.Params["swKeyword"]; if (Keyword == string.Empty) { ShowErrorMessage(); } else { //These things only apply to paging //Get Items per page. ItemsPerPage = Strings.ToInt(Request.Params["pageunit"], 10); //Get the current Page CurrentPage = Strings.ToInt(Request.Params["page"], 1); //"De-serialize" old keywords. if (!string.IsNullOrEmpty(Request.Params["old_keywords"])) { string[] oldKeys = Request.Params["old_keywords"].Split(new char[] { '|' }); OldKeywords.AddRange(oldKeys); } LoadResults(); } } // build the OnClineClick value for results search var siteResultSearchSubmitParameter = ""; if (PageDisplayInformation.Language == DisplayLanguage.Spanish) { siteResultSearchSubmitParameter = "true"; } // removed search validation for now var siteResultSearchSubmitCall = ""; //"return siteResultSearchSubmit(" + siteResultSearchSubmitParameter + ")"; // Web Analytics ************************************************* if (WebAnalyticsOptions.IsEnabled) { siteResultSearchSubmitCall += "return NCIAnalytics.SiteWideSearchResultsSearch(this,'" + txtSWRKeyword.ClientID + "','" + rblSWRSearchType.UniqueID + "')"; } // End Web Analytics ********************************************* if (!String.IsNullOrEmpty(siteResultSearchSubmitCall)) { siteResultSearchSubmitCall += ";"; btnSWRTxtSearch.OnClientClick = siteResultSearchSubmitCall; } }