Exemplo n.º 1
0
    /// <summary>
    /// Runs the search.
    /// </summary>
    private void Search()
    {
        if (!string.IsNullOrEmpty(txtWord.Text))
        {
            string url = SearchResultsPageUrl;

            if (url.StartsWith("~"))
            {
                url = ResolveUrl(url.Trim());
            }

            url = URLHelper.UpdateParameterInUrl(url, "searchtext", HttpUtility.UrlEncode(txtWord.Text));
            url = URLHelper.UpdateParameterInUrl(url, "searchmode", SearchHelper.GetSearchModeString(SearchMode));

            // 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, txtWord.Text, CMSContext.Campaign);
            }

            URLHelper.Redirect(url.Trim());
        }
    }
    protected void srchDialog_DoSearch()
    {
        // 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, this.srchDialog.SearchForTextBox.Text, CMSContext.Campaign);
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// OnGo search click.
    /// </summary>
    protected void btnGo_Click(object sender, EventArgs e)
    {
        if (!String.IsNullOrEmpty(txtSearch.Text))
        {
            string contextQuery = String.Empty;

            if (this.SearchInCurrentContext)
            {
                if ((ForumContext.CurrentForum != null) && (ForumContext.CurrentThread != null) && (ForumContext.CurrentThread.PostForumID == ForumContext.CurrentForum.ForumID))
                {
                    contextQuery = "&searchforums=" + ForumContext.CurrentForum.ForumID + "&searchthread=" + ForumContext.CurrentThread.PostId;
                }
                else if (ForumContext.CurrentForum != null)
                {
                    contextQuery = "&searchforums=" + ForumContext.CurrentForum.ForumID;
                }
            }

            // 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, txtSearch.Text, CMSContext.Campaign);
            }

            if (!String.IsNullOrEmpty(RedirectUrl.Trim()))
            {
                URLHelper.Redirect(ResolveUrl(RedirectUrl) + "?searchtext=" + HttpUtility.UrlEncode(txtSearch.Text) + contextQuery);
            }
            else //Redirect back to current page
            {
                string url = URLHelper.RemoveQuery(URLRewriter.CurrentURL);
                url  = URLHelper.UpdateParameterInUrl(url, "searchtext", HttpUtility.UrlEncode(txtSearch.Text));
                url  = URLHelper.RemoveParameterFromUrl(url, "searchforums");
                url  = URLHelper.RemoveParameterFromUrl(url, "searchthread");
                url += contextQuery;

                URLHelper.Redirect(url);
            }
        }
    }
Exemplo n.º 4
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);
    }
Exemplo n.º 5
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string errMsg = ValidateSearchDialog();

        // Search dialog filled properly
        if (errMsg == string.Empty)
        {
            // Generate query string according search dialog selections
            string queryString = String.Empty;
            queryString += (!string.IsNullOrEmpty(this.txtSearchText.Text)) ? "searchtext=" + HttpUtility.UrlEncode(this.txtSearchText.Text) + "&" : "";
            queryString += (!string.IsNullOrEmpty(this.txtUserName.Text)) ? "searchusername="******"&" : "";
            queryString += (!string.IsNullOrEmpty(this.drpSearchIn.SelectedValue)) ? "searchin=" + this.drpSearchIn.SelectedValue + "&" : "";
            queryString += (!string.IsNullOrEmpty(this.drpSearchOrderBy.SelectedValue)) ? "searchorderby=" + this.drpSearchOrderBy.SelectedValue + "&" : "";
            queryString += (!string.IsNullOrEmpty(this.rblSearchOrder.SelectedValue)) ? "searchorder=" + this.rblSearchOrder.SelectedValue + "&" : "";
            queryString  = queryString.TrimEnd('&');

            if (EnableForumSelection)
            {
                string forQuery = "";
                foreach (ListItem li in listForums.Items)
                {
                    if ((li.Selected) && (li.Value != ""))
                    {
                        if (forQuery != "")
                        {
                            forQuery += ";";
                        }
                        forQuery += li.Value;
                    }
                }

                if (forQuery != "")
                {
                    queryString += "&searchforums=" + forQuery;
                }
            }

            // 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, this.txtSearchText.Text, CMSContext.Campaign);
            }

            // Redirect to the search result page
            if (!string.IsNullOrEmpty(RedirectUrl))
            {
                if (RedirectUrl.IndexOf("?") < 0)
                {
                    queryString = "?" + queryString;
                }

                URLHelper.Redirect(ResolveUrl(RedirectUrl) + queryString);
            }
            else
            {
                string url = URLRewriter.CurrentURL;

                // Get rid of previous query string parameters
                if (url.IndexOf("?") > -1)
                {
                    url = URLHelper.RemoveParameterFromUrl(url, "searchtext");
                    url = URLHelper.RemoveParameterFromUrl(url, "searchusername");
                    url = URLHelper.RemoveParameterFromUrl(url, "searchin");
                    url = URLHelper.RemoveParameterFromUrl(url, "searchorderby");
                    url = URLHelper.RemoveParameterFromUrl(url, "searchorder");
                    url = URLHelper.RemoveParameterFromUrl(url, "searchforums");
                    url = URLHelper.RemoveParameterFromUrl(url, "forumid");
                    url = URLHelper.RemoveParameterFromUrl(url, "threadid");
                    url = URLHelper.RemoveParameterFromUrl(url, "thread");
                    url = URLHelper.RemoveParameterFromUrl(url, "postid");
                    url = URLHelper.RemoveParameterFromUrl(url, "mode");
                    url = URLHelper.RemoveParameterFromUrl(url, "replyto");
                    url = URLHelper.RemoveParameterFromUrl(url, "subscribeto");
                    url = URLHelper.RemoveParameterFromUrl(url, "page");
                }

                // Append query string
                url = URLHelper.AppendQuery(url, queryString);

                //Redirect back to the current page
                URLHelper.Redirect(url);
            }
        }
        else
        {
            // Display error info to the user
            lblInfo.Text    = errMsg;
            lblInfo.Visible = true;
        }
    }