Пример #1
0
    /// <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));
    }
Пример #2
0
 /// <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);
 }
Пример #3
0
    /// <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);
    }
Пример #4
0
    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", "");
        }
    }
Пример #5
0
    /// <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);
    }
Пример #6
0
    /// <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", "");
            }
        }
    }
Пример #7
0
    /// <summary>
    /// Perform search.
    /// </summary>
    protected override void OnPreRender(EventArgs e)
    {
        // Check whether current request is not postback
        if (!RequestHelper.IsPostBack())
        {
            // Get current search text from query string
            string searchText = QueryHelper.GetString("searchtext", "");
            // Check whether search text is defined
            if (!string.IsNullOrEmpty(searchText))
            {
                // Get current search mode from query string
                string         searchMode     = QueryHelper.GetString("searchmode", "");
                SearchModeEnum searchModeEnum = ISearchHelper.GetSearchModeEnum(searchMode);

                // Get current index id
                int indexId = QueryHelper.GetInteger("indexId", 0);
                // Get current index info object
                SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(indexId);
                // Check whether index info exists
                if (sii != null)
                {
                    // Keep search text in search textbox
                    //txtSearchFor.Text = searchText;

                    searchText = SearchHelper.CombineSearchCondition(searchText, null, searchModeEnum, SearchOptionsEnum.FullSearch, null, null, null, false);

                    // Get positions and ranges for search method
                    int startPosition     = 0;
                    int numberOfProceeded = 100;
                    int displayResults    = 100;
                    if (pgrSearch.PageSize != 0 && pgrSearch.GroupSize != 0)
                    {
                        startPosition     = (pgrSearch.CurrentPage - 1) * pgrSearch.PageSize;
                        numberOfProceeded = (((pgrSearch.CurrentPage / pgrSearch.GroupSize) + 1) * pgrSearch.PageSize * pgrSearch.GroupSize) + pgrSearch.PageSize;
                        displayResults    = pgrSearch.PageSize;
                    }

                    // Prepare parameters
                    SearchParameters parameters = new SearchParameters()
                    {
                        SearchFor                 = searchText,
                        SearchSort                = null,
                        Path                      = null,
                        ClassNames                = null,
                        CurrentCulture            = "##ALL##",
                        DefaultCulture            = null,
                        CombineWithDefaultCulture = false,
                        CheckPermissions          = false,
                        SearchInAttachments       = false,
                        User                      = (UserInfo)CMSContext.CurrentUser,
                        SearchIndexes             = sii.IndexName,
                        StartingPosition          = startPosition,
                        DisplayResults            = displayResults,
                        NumberOfProcessedResults  = numberOfProceeded,
                        NumberOfResults           = 0,
                        AttachmentWhere           = null,
                        AttachmentOrderBy         = null,
                    };

                    // Search
                    DataSet results = SearchHelper.Search(parameters);

                    // Fill repeater with results
                    repSearchResults.DataSource = results;
                    repSearchResults.PagerForceNumberOfResults = parameters.NumberOfResults;
                    repSearchResults.DataBind();

                    // Show now results found ?
                    if (parameters.NumberOfResults == 0)
                    {
                        lblNoResults.Text    = "<br />" + GetString("srch.results.noresults");
                        lblNoResults.Visible = true;

                        Exception searchError = SearchHelper.LastSmartSearchError;
                        if (searchError != null)
                        {
                            pnlError.Visible = true;
                            lblError.Text    = GetString("smartsearch.searcherror") + " " + searchError.Message;
                        }
                    }
                }
            }
        }

        base.OnPreRender(e);
    }