/// <summary> /// Loads drop-down lists. /// </summary> private void LoadDropDowns() { // Init operands if (drpLanguage.Items.Count == 0) { drpLanguage.Items.Add(new ListItem(GetString("transman.translatedto"), "=")); drpLanguage.Items.Add(new ListItem(GetString("transman.nottranslatedto"), "<>")); } // Get site indexes DataSet ds = SearchIndexSiteInfoProvider.GetIndexSites("IndexId", "IndexSiteID = " + CMSContext.CurrentSiteID + " AND IndexID IN (SELECT IndexID FROM CMS_SearchIndex WHERE IndexType = N'" + PredefinedObjectType.DOCUMENT + "')", null, 0); if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow dr in ds.Tables[0].Rows) { SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(ValidationHelper.GetInteger(dr["IndexId"], 0)); if ((sii != null) && (sii.IndexType == PredefinedObjectType.DOCUMENT)) { drpIndexes.Items.Add(new ListItem(sii.IndexDisplayName, sii.IndexName)); } } } drpIndexes.Items.Insert(0, new ListItem(GetString("search.sqlsearch"), SQL)); // Init Search for drop down list DataHelper.FillListControlWithEnum(typeof(SearchModeEnum), drpSearchMode, "srch.dialog.", SearchHelper.GetSearchModeString); drpSearchMode.SelectedValue = QueryHelper.GetString("searchmode", SearchHelper.GetSearchModeString(SearchModeEnum.AnyWord)); }
/// <summary> /// Sets controls from query string parameters. /// </summary> private void SetControls() { drpLanguage.SelectedValue = QueryHelper.GetString("searchlanguage", "="); cultureElem.Value = QueryHelper.GetString("searchculture", ANY); cultureElem.ReloadData(); cultureElem.Reload(true); drpIndexes.SelectedValue = QueryHelper.GetString("searchindex", SQL); chkOnlyPublished.Checked = QueryHelper.GetBoolean("searchpublished", true); if (drpIndexes.SelectedValue != SQL) { plcPublished.Visible = false; } drpSearchMode.SelectedValue = QueryHelper.GetString("searchmode", SearchHelper.GetSearchModeString(SearchModeEnum.AnyWord)); txtSearchFor.Text = QueryHelper.GetString("searchtext", null); }
/// <summary> /// Fires at btn search click. /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Arguments</param> protected void btnSearch_Click(object sender, EventArgs e) { string url = URLHelper.CurrentURL; // Remove pager query string url = URLHelper.RemoveParameterFromUrl(url, "page"); // Update search text parameter url = URLHelper.UpdateParameterInUrl(url, "searchtext", HttpUtility.UrlEncode(txtSearchFor.Text)); // Update search mode parameter url = URLHelper.RemoveParameterFromUrl(url, "searchmode"); if (this.ShowSearchMode) { url = URLHelper.AddParameterToUrl(url, "searchmode", drpSearchMode.SelectedValue); } else { url = URLHelper.AddParameterToUrl(url, "searchmode", SearchHelper.GetSearchModeString(SearchMode)); } // Add filter params to url foreach (string urlParam in FilterUrlParameters) { string[] urlParams = urlParam.Split('='); url = URLHelper.UpdateParameterInUrl(url, urlParams[0], urlParams[1]); } // Log "internal search" activity string siteName = CMSContext.CurrentSiteName; if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) && ActivitySettingsHelper.SearchEnabled(siteName)) { ActivityLogProvider.LogInternalSearchActivity(CMSContext.CurrentDocument, ModuleCommands.OnlineMarketingGetCurrentContactID(), CMSContext.CurrentSiteID, URLHelper.CurrentRelativePath, txtSearchFor.Text, CMSContext.Campaign); } // Redirect URLHelper.Redirect(url); }
protected void Page_Load(object sender, EventArgs e) { // Get current index id int indexId = QueryHelper.GetInteger("indexId", 0); // Get current index info object SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(indexId); // Show warning if indes isn't ready yet if ((sii != null) && (sii.IndexStatus == IndexStatusEnum.NEW)) { ShowWarning(GetString("srch.index.needrebuild"), null, null); } if (!RequestHelper.IsPostBack()) { // Fill dropdownlist option with values DataHelper.FillListControlWithEnum(typeof(SearchModeEnum), drpSearchMode, "srch.dialog.", ISearchHelper.GetSearchModeString); drpSearchMode.SelectedValue = QueryHelper.GetString("searchmode", ISearchHelper.GetSearchModeString(SearchModeEnum.AnyWord)); // Set up search text txtSearchFor.Text = QueryHelper.GetString("searchtext", ""); } }
/// <summary> /// Fires at btn search click. /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Arguments</param> protected void btnSearch_Click(object sender, EventArgs e) { string url = URLHelper.CurrentURL; // Remove pager query string url = URLHelper.RemoveParameterFromUrl(url, "page"); // Update search text parameter url = URLHelper.UpdateParameterInUrl(url, "searchtext", HttpUtility.UrlEncode(txtSearchFor.Text)); // Update search mode parameter url = URLHelper.RemoveParameterFromUrl(url, "searchmode"); if (ShowSearchMode) { url = URLHelper.AddParameterToUrl(url, "searchmode", drpSearchMode.SelectedValue); } else { url = URLHelper.AddParameterToUrl(url, "searchmode", SearchHelper.GetSearchModeString(SearchMode)); } // Add filter params to url foreach (string urlParam in FilterUrlParameters) { string[] urlParams = urlParam.Split('='); url = URLHelper.UpdateParameterInUrl(url, urlParams[0], urlParams[1]); } // Log "internal search" activity Activity internalSearch = new ActivityInternalSearch(txtSearchFor.Text, CMSContext.CurrentDocument, CMSContext.ActivityEnvironmentVariables); internalSearch.Log(); // Redirect URLHelper.Redirect(url); }
/// <summary> /// Page load. /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Arguments</param> protected void Page_Load(object sender, EventArgs e) { if (this.StopProcessing) { return; } else { // Set up drop down list if (ShowSearchMode) { if (!RequestHelper.IsPostBack()) { // Fill dropdownlist option with values DataHelper.FillListControlWithEnum(typeof(SearchModeEnum), drpSearchMode, "srch.dialog.", SearchHelper.GetSearchModeString); drpSearchMode.SelectedValue = QueryHelper.GetString("searchmode", SearchHelper.GetSearchModeString(SearchMode)); } } // Set up search text if (!RequestHelper.IsPostBack()) { txtSearchFor.Text = QueryHelper.GetString("searchtext", ""); } } }