using System; using System.Data; using System.Web; using System.Web.UI; using CMS.Controls; using CMS.GlobalHelper; using CMS.ISearchEngine; using CMS.PortalControls; public partial class CMSWebParts_Search_cmssearchresults : CMSAbstractWebPart { #region "Public properties" /// /// Gets or sets the value that indicates whether permissions should be 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 which should be displayed. /// 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 ID of the search dialog. /// public string CMSSearchDialogID { get { return DataHelper.GetNotEmpty(ValidationHelper.GetString(GetValue("CMSSearchDialogID"), srchResults.CMSSearchDialogID), srchResults.CMSSearchDialogID); } set { SetValue("CMSSearchDialogID", value); srchResults.CMSSearchDialogID = value; } } /// /// Gets or sets the value that indicates whether documents are combined with default culture version. /// public bool CombineWithDefaultCulture { get { return ValidationHelper.GetBoolean(GetValue("CombineWithDefaultCulture"), srchResults.CombineWithDefaultCulture); } set { SetValue("CombineWithDefaultCulture", value); srchResults.CombineWithDefaultCulture = value; } } /// /// Gets or sets the culture code of the documents. /// 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 path of the documents. /// 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 search mode. /// public SearchModeEnum SearchMode { get { return srchResults.GetSearchMode(DataHelper.GetNotEmpty(GetValue("SearchMode"), SearchHelper.GetSearchModeString(srchResults.SearchMode))); } set { SetValue("SearchMode", value); srchResults.SearchMode = value; } } /// /// Gets or sets the value that indicates whether only published documents are selected. /// public bool SelectOnlyPublished { get { return ValidationHelper.GetBoolean(GetValue("SelectOnlyPublished"), srchResults.SelectOnlyPublished); } set { SetValue("SelectOnlyPublished", 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; } } /// /// Gets or sets the text to be displayed if no results has been found. /// public string NoResultText { get { return DataHelper.GetNotEmpty(GetValue("NoResultText"), ResHelper.LocalizeString("{$CMSSearchResults.NoDocumentFound$}")); } set { SetValue("NoResultText", value); srchResults.NoResultsLabel.Text = value; } } /// /// Gets or sets the name of the transforamtion which is used for displaying the results. /// public string TransformationName { get { return DataHelper.GetNotEmpty(GetValue("TransformationName"), srchResults.TransformationName); } set { SetValue("TransformationName", value); srchResults.TransformationName = value; } } /// /// Gets or sets the name of the query string. /// public string QueryStringKey { get { return DataHelper.GetNotEmpty(GetValue("QueryStringKey"), srchResults.QueryStringKey); } set { SetValue("QueryStringKey", value); srchResults.QueryStringKey = value; } } /// /// Gets or sets the number of the search results on each sigle page. /// public int PageSize { get { return ValidationHelper.GetInteger(GetValue("PageSize"), srchResults.PagerControl.PageSize); } set { SetValue("PageSize", value); srchResults.PagerControl.PageSize = value; } } /// /// Gets or sets the position of the pager. /// public PagingPlaceTypeEnum PagerPosition { get { return srchResults.PagerControl.GetPagerPosition(DataHelper.GetNotEmpty(GetValue("PagerPosition"), srchResults.PagerControl.PagerPosition.ToString())); } set { SetValue("PagerPosition", value); srchResults.PagerControl.PagerPosition = value; } } /// /// Gets or sets the paging mode. /// public PagingModeTypeEnum PagingMode { get { return srchResults.PagerControl.GetPagingMode(DataHelper.GetNotEmpty(GetValue("PagingMode"), srchResults.PagerControl.PagingMode.ToString())); } set { SetValue("PagingMode", value); 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 page is shown if paging is allowed. /// 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 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 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; } } /// /// 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; } } /// /// Filter name. /// public string FilterName { get { return ValidationHelper.GetString(GetValue("FilterName"), srchResults.FilterName); } set { SetValue("FilterName", value); srchResults.FilterName = value; } } #endregion /// /// Content loaded event handler. /// public override void OnContentLoaded() { base.OnContentLoaded(); SetupControl(); } /// /// Initializes the control properties. /// protected void SetupControl() { if (StopProcessing) { srchResults.StopProcessing = true; } else { // Setup the control srchResults.CheckPermissions = CheckPermissions; srchResults.ClassNames = ClassNames; srchResults.CMSSearchDialogID = CMSSearchDialogID; srchResults.CombineWithDefaultCulture = CombineWithDefaultCulture; srchResults.CultureCode = CultureCode; srchResults.Path = Path; srchResults.SearchMode = SearchMode; srchResults.SelectOnlyPublished = SelectOnlyPublished; srchResults.SiteName = SiteName; // Set 'no results' text srchResults.NoResultsLabel.Text = NoResultText; srchResults.TransformationName = TransformationName; // This Query string key isn't property of DataPager ! This property set DataPager QueryStrinKey with search query parameters 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; srchResults.FilterName = FilterName; // Event srchResults.OnSearchCompleted += srchResults_OnSearchCompleted; Visible = false; } } protected void srchResults_OnSearchCompleted(bool noResults, bool renderIt) { if (renderIt) { Visible = true; } else { if (srchResults.NoResultsLabel != null) { if (!string.IsNullOrEmpty(srchResults.NoResultsLabel.Text)) { Visible = true && noResults; } } } } }