using System; using System.Data; using System.Collections; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using CMS.CMSHelper; using CMS.Controls; using CMS.GlobalHelper; using CMS.ISearchEngine; using CMS.PortalControls; using CMS.PortalEngine; using CMS.SettingsProvider; using CMS.WebAnalytics; public partial class CMSWebParts_Search_cmssearchdialog : CMSAbstractWebPart { #region "Variables" /// /// Flag indicates whether DoSearch event has been called. /// private bool doSearch = false; #endregion #region "Public properties" /// /// Gets or sets the label search for text. /// public string SearchForLabel { get { return DataHelper.GetNotEmpty(GetValue("SearchForLabel"), ResHelper.LocalizeString("{$CMSSearchDialog.SearchFor$}")); } set { SetValue("SearchForLabel", value); srchDialog.SearchForLabel.Text = value; } } /// /// Gets or sets the value that indicates whether search mode settings should be displayed. /// public bool ShowSearchMode { get { return ValidationHelper.GetBoolean(GetValue("ShowSearchMode"), srchDialog.ShowSearchMode); } set { SetValue("ShowSearchMode", value); srchDialog.ShowSearchMode = value; } } /// /// Gets or sets the search button text. /// public string SearchButtonText { get { return DataHelper.GetNotEmpty(GetValue("SearchButtonText"), ResHelper.LocalizeString("{$CMSSearchDialog.Go$}")); } set { SetValue("SearchButtonText", value); srchDialog.SearchButton.Text = value; } } /// /// Gets or sets the search mode. /// public SearchModeEnum SearchMode { get { return CMSSearchDialog.GetSearchMode(DataHelper.GetNotEmpty(GetValue("SearchMode"), SearchHelper.GetSearchModeString(srchDialog.SearchMode))); } set { SetValue("SearchMode", value.ToString()); srchDialog.SearchMode = value; } } /// /// Gets or sets the search mode label text. /// public string SearchModeLabel { get { return DataHelper.GetNotEmpty(GetValue("SearchModeLabel"), ResHelper.LocalizeString("{$CMSSearchDialog.SearchMode$}")); } set { SetValue("SearchModeLabel", value); srchDialog.SearchModeLabel.Text = value; } } /// /// Gets or sets the value that indicates whether search scope drop down is displayed. /// public bool ShowSearchScope { get { return ValidationHelper.GetBoolean(GetValue("ShowSearchScope"), srchDialog.ShowSearchScope); } set { SetValue("ShowSearchScope", value); srchDialog.ShowSearchScope = value; } } /// /// Gets or sets the search scope. /// public SearchScopeEnum SearchScope { get { return CMSSearchDialog.GetSearchScope(DataHelper.GetNotEmpty(GetValue("SearchScope"), srchDialog.SearchScope.ToString())); } set { SetValue("SearchScope", value.ToString()); srchDialog.SearchScope = value; } } /// /// Gets or sets the search scope label text. /// public string SearchScopeLabel { get { return DataHelper.GetNotEmpty(GetValue("SearchScopeLabel"), ResHelper.LocalizeString("{$CMSSearchDialog.SearchScope$}")); } set { SetValue("SearchScopeLabel", value); srchDialog.SearchScopeLabel.Text = value; } } /// /// Gets or sets the Skin ID. /// public override string SkinID { get { return base.SkinID; } set { base.SkinID = value; srchDialog.SkinID = value; } } #endregion /// /// Content loaded event handler. /// public override void OnContentLoaded() { base.OnContentLoaded(); SetupControl(); } /// /// Initializes the control properties. /// protected void SetupControl() { if (StopProcessing) { srchDialog.StopProcessing = true; } else { srchDialog.ID = ID + "_CMSSearchDialog"; // Set label text srchDialog.SearchForLabel.Text = SearchForLabel; // Set button text srchDialog.SearchButton.Text = SearchButtonText; srchDialog.DoSearch += new CMSSearchDialog.DoSearchEventHandler(srchDialog_DoSearch); if (srchDialog.ShowSearchMode = ShowSearchMode) { // Set search mode srchDialog.SearchMode = SearchMode; // Set mode label text srchDialog.SearchModeLabel.Text = SearchModeLabel; } if (srchDialog.ShowSearchScope = ShowSearchScope) { // Set search scope srchDialog.SearchScope = SearchScope; // Set scope label text srchDialog.SearchScopeLabel.Text = SearchScopeLabel; } if (!StandAlone && (PageCycle < PageCycleEnum.Initialized) && (ValidationHelper.GetString(Page.StyleSheetTheme, "") == "")) { // Set SkinID property srchDialog.SkinID = SkinID; } } } protected void srchDialog_DoSearch() { if (!doSearch) { doSearch = true; // Log "internal search" activity Activity internalSearch = new ActivityInternalSearch(srchDialog.SearchForTextBox.Text, CMSContext.CurrentDocument, CMSContext.ActivityEnvironmentVariables); internalSearch.Log(); } } /// /// Applies given stylesheet skin. /// public override void ApplyStyleSheetSkin(Page page) { srchDialog.SkinID = SkinID; base.ApplyStyleSheetSkin(page); } }