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_cmscompletesearchdialog : CMSAbstractWebPart { #region "Search dialog 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 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", SearchHelper.GetSearchModeString(value)); srchDialog.SearchMode = value; } } /// /// Gets or sets the search mode label. /// 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 diplayed. /// 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. /// 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 #region "Document properties" /// /// Gets or sets the value that indidcates whether permissions are checked. /// public bool CheckPermissions { get { return ValidationHelper.GetBoolean(GetValue("CheckPermissions"), srchResults.CheckPermissions); } set { SetValue("CheckPermissions", value); srchResults.CheckPermissions = value; } } /// /// Gets or sets the class names. /// public string ClassNames { get { return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("Classnames"), srchResults.ClassNames), srchResults.ClassNames); } set { SetValue("ClassNames", value); srchResults.ClassNames = value; } } /// /// Gets or sets the value that indidcates whether current culture will be combined with default culture. /// public bool CombineWithDefaultCulture { get { return ValidationHelper.GetBoolean(GetValue("CombineWithDefaultCulture"), srchResults.CombineWithDefaultCulture); } set { SetValue("CombineWithDefaultCulture", value); srchResults.CombineWithDefaultCulture = value; } } /// /// Gets or sets the culture code. /// public string CultureCode { get { return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("CultureCode"), srchResults.CultureCode), srchResults.CultureCode); } set { SetValue("CultureCode", value); srchResults.CultureCode = value; } } /// /// Gets or sets the nodes path. /// public string Path { get { return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("Path"), srchResults.Path), srchResults.Path); } set { SetValue("Path", value); srchResults.Path = value; } } /// /// Gets or sets the value that indicates whether only published nodes will be selected. /// public bool SelectOnlyPublished { get { return ValidationHelper.GetBoolean(GetValue("SelectOnlyPublished"), srchResults.SelectOnlyPublished); } set { SetValue("SelctOnlyPublished", value); srchResults.SelectOnlyPublished = value; } } /// /// Gets or sets the site name. /// public string SiteName { get { return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("SiteName"), srchResults.SiteName), srchResults.SiteName); } set { SetValue("SiteName", value); srchResults.SiteName = value; } } /// /// Gets or sets the where condition. /// public string WhereCondition { get { return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("WhereCondition"), srchResults.WhereCondition), srchResults.WhereCondition); } set { SetValue("WhereCondition", value); srchResults.WhereCondition = value; } } /// /// Gets or sets the order by. /// public string OrderBy { get { return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("OrderBy"), srchResults.OrderBy), srchResults.OrderBy); } set { SetValue("OrderBy", value); srchResults.OrderBy = value; } } #endregion #region "Pager properties" /// /// Gets or sets the value that indicates whether paging is enabled. /// public bool EnablePaging { get { return ValidationHelper.GetBoolean(GetValue("EnablePaging"), srchResults.EnablePaging); } set { SetValue("EnablePaging", value); srchResults.EnablePaging = value; } } /// /// Gets or sets the pager position. /// public PagingPlaceTypeEnum PagerPosition { get { return srchResults.PagerControl.GetPagerPosition(DataHelper.GetNotEmpty(GetValue("PagerPosition"), srchResults.PagerControl.PagerPosition.ToString())); } set { SetValue("PagerPosition", value.ToString()); srchResults.PagerControl.PagerPosition = value; } } /// /// Gets or sets the page size. /// public int PageSize { get { return ValidationHelper.GetInteger(GetValue("PageSize"), srchResults.PagerControl.PageSize); } set { SetValue("PageSize", value); srchResults.PagerControl.PageSize = value; } } /// /// Gets or sets the pager query string key. /// public string QueryStringKey { get { return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("QueryStringKey"), srchResults.PagerControl.QueryStringKey), srchResults.PagerControl.QueryStringKey); } set { SetValue("QueryStringKey", value); srchResults.PagerControl.QueryStringKey = value; } } /// /// Gets or sets the paging mode (QueryString, PostBack). /// public PagingModeTypeEnum PagingMode { get { return srchResults.PagerControl.GetPagingMode(DataHelper.GetNotEmpty(GetValue("PagingMode"), srchResults.PagerControl.PagingMode.ToString())); } set { SetValue("PagingMode", value.ToString()); srchResults.PagerControl.PagingMode = value; } } /// /// Gets or sets the navigation mode. /// public BackNextLocationTypeEnum BackNextLocation { get { return srchResults.PagerControl.GetBackNextLocation(DataHelper.GetNotEmpty(GetValue("BackNextLocation"), srchResults.PagerControl.BackNextLocation.ToString())); } set { SetValue("BackNextLocation", value.ToString()); srchResults.PagerControl.BackNextLocation = value; } } /// /// Gets or sets the value that indicates whether first and last links will be displayed. /// public bool ShowFirstLast { get { return ValidationHelper.GetBoolean(GetValue("ShowFirstLast"), srchResults.PagerControl.ShowFirstLast); } set { SetValue("ShowFirstLast", value); srchResults.PagerControl.ShowFirstLast = value; } } /// /// Gets or sets the html which will be displayed before pager. /// public string PagerHTMLBefore { get { return ValidationHelper.GetString(GetValue("PagerHTMLBefore"), srchResults.PagerControl.PagerHTMLBefore); } set { SetValue("PagerHTMLBefore", value); srchResults.PagerControl.PagerHTMLBefore = value; } } /// /// Gets or sets the html which will be displayed after pager. /// public string PagerHTMLAfter { get { return ValidationHelper.GetString(GetValue("PagerHTMLAfter"), srchResults.PagerControl.PagerHTMLAfter); } set { SetValue("PagerHTMLAfter", value); srchResults.PagerControl.PagerHTMLAfter = value; } } /// /// Gets or sets the results position. /// public ResultsLocationTypeEnum ResultsPosition { get { return srchResults.PagerControl.GetResultPosition(ValidationHelper.GetString(GetValue("ResultsPosition"), "")); } set { SetValue("ResultsPosition", value); srchResults.PagerControl.ResultsLocation = value; } } /// /// Gets or sets the page numbers separator. /// public string PageNumbersSeparator { get { return ValidationHelper.GetString(GetValue("PageNumbersSeparator"), srchResults.PagerControl.PageNumbersSeparator); } set { SetValue("PageNumbersSeparator", value); srchResults.PagerControl.PageNumbersSeparator = value; } } #endregion #region "Public properties" /// /// Gets or sets the name of the transforamtion which is used for displaying the results. /// public string TransformationName { get { return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("TransformationName"), srchResults.TransformationName), srchResults.TransformationName); } set { SetValue("TransformationName", value); srchResults.TransformationName = value; } } /// /// Gets or sets the text which will be displayed if no result were found. /// public string NoResultsLabel { get { return DataHelper.GetNotEmpty(GetValue("NoResults"), ResHelper.LocalizeString("{$CMSSearchResults.NoDocumentFound$}")); } set { SetValue("NoResults", value); srchResults.NoResultsLabel.Text = 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; srchResults.StopProcessing = true; } else { //Search dialog srchDialog.ID = ID + "_CMSSearchDialog"; srchDialog.SearchForLabel.Text = SearchForLabel; srchDialog.SearchButton.Text = SearchButtonText; srchDialog.ShowSearchMode = ShowSearchMode; srchDialog.SearchMode = SearchMode; srchDialog.SearchModeLabel.Text = SearchModeLabel; srchDialog.ShowSearchScope = ShowSearchScope; srchDialog.SearchScope = SearchScope; srchDialog.SearchScopeLabel.Text = SearchScopeLabel; srchDialog.DoSearch += new CMSSearchDialog.DoSearchEventHandler(srchDialog_DoSearch); // Document properties srchResults.CheckPermissions = CheckPermissions; srchResults.ClassNames = ClassNames; srchResults.CombineWithDefaultCulture = CombineWithDefaultCulture; srchResults.CultureCode = CultureCode; srchResults.Path = Path; srchResults.SelectOnlyPublished = SelectOnlyPublished; srchResults.SiteName = SiteName; srchResults.CMSSearchDialogID = ID + "_CMSSearchDialog"; srchResults.SearchMode = SearchMode; srchResults.TransformationName = TransformationName; srchResults.NoResultsLabel.Text = NoResultsLabel; // Pager srchResults.EnablePaging = EnablePaging; srchResults.QueryStringKey = QueryStringKey; srchResults.PagerControl.PageSize = PageSize; srchResults.PagerControl.PagerPosition = PagerPosition; srchResults.PagerControl.PagingMode = PagingMode; srchResults.PagerControl.BackNextLocation = BackNextLocation; srchResults.PagerControl.ShowFirstLast = ShowFirstLast; srchResults.PagerControl.PagerHTMLBefore = PagerHTMLBefore; srchResults.PagerControl.PagerHTMLAfter = PagerHTMLAfter; srchResults.PagerControl.ResultsLocation = ResultsPosition; srchResults.PagerControl.PageNumbersSeparator = PageNumbersSeparator; srchResults.WhereCondition = WhereCondition; srchResults.OrderBy = OrderBy; // Set SkinID property if (!StandAlone && (PageCycle < PageCycleEnum.Initialized) && (ValidationHelper.GetString(Page.StyleSheetTheme, "") == "")) { srchDialog.SkinID = SkinID; srchResults.SkinID = SkinID; } } } protected void srchDialog_DoSearch() { // 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) { string skinId = SkinID; srchDialog.SkinID = skinId; srchResults.SkinID = skinId; base.ApplyStyleSheetSkin(page); } }