Esempio n. 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));
    }
    /// <summary>
    /// Returns string with site ids where user is member.
    /// </summary>
    private string GetIndexSites()
    {
        DataSet ds = SearchIndexSiteInfoProvider.GetIndexSites("SiteID", "IndexID = " + indexId, null, 0);

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            return(TextHelper.Join(";", SystemDataHelper.GetStringValues(ds.Tables[0], "SiteID")));
        }

        return(String.Empty);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Show panel with message how to enable indexing
        ucDisabledModule.SettingsKeys = "CMSSearchIndexingEnabled";
        ucDisabledModule.InfoText     = GetString("srch.searchdisabledinfo");

        // Module forums is not available
        if (!(ModuleEntry.IsModuleRegistered(ModuleEntry.FORUMS) && ModuleEntry.IsModuleLoaded(ModuleEntry.FORUMS)))
        {
            return;
        }

        selForum = this.LoadUserControl("~/CMSModules/Forums/FormControls/ForumSelector.ascx") as FormEngineUserControl;
        if (selForum != null)
        {
            selForum.IsLiveSite = false;
            plcForumSelector.Controls.Add(selForum);
        }

        selSite.AllowAll = false;
        selSite.UseCodeNameForSelection = true;

        string siteWhere = String.Empty;

        DataSet ds = SearchIndexSiteInfoProvider.GetIndexSites("SiteID", "IndexID = " + ItemID, null, 0);

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                siteWhere += dr["SiteID"] + ",";
            }

            siteWhere = "," + siteWhere;

            // Preselect current site if it is assigned to index
            if (!RequestHelper.IsPostBack() && siteWhere.Contains("," + CMSContext.CurrentSiteID + ","))
            {
                selSite.Value = CMSContext.CurrentSiteName;
            }

            siteWhere = siteWhere.Trim(',');
            siteWhere = "SiteID IN (" + siteWhere + ")";
            selSite.UniSelector.WhereCondition = siteWhere;
        }
        else
        {
            selSite.Enabled  = false;
            selForum.Enabled = false;
            btnOk.Enabled    = false;

            ShowError(GetString("srch.index.nositeselected"));
        }

        // Set default vaules for forum selector
        selForum.SetValue("selectionmode", SelectionModeEnum.MultipleTextBox);
        selForum.SetValue("DisplayAdHocOption", false);
        selForum.SetValue("SiteName", Convert.ToString(selSite.Value));

        // Set events and default values for site selector
        selSite.UniSelector.OnSelectionChanged   += new EventHandler(UniSelector_OnSelectionChanged);
        selSite.DropDownSingleSelect.AutoPostBack = true;

        LoadControls();

        if (ItemType == SearchIndexSettingsInfo.TYPE_ALLOWED)
        {
            selSite.AllowAll = true;
        }

        // Init controls
        if (!RequestHelper.IsPostBack())
        {
            selForum.Enabled = true;

            string siteName = ValidationHelper.GetString(selSite.Value, String.Empty);
            if (String.IsNullOrEmpty(siteName) || (siteName == "-1"))
            {
                selForum.Enabled = false;
            }
            else
            {
                selForum.SetValue("SiteName", siteName);
                SetControlsStatus(false);
            }
        }
    }