Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get inline control ID from querystring
        controlId = QueryHelper.GetInteger("inlinecontrolid", 0);

        InlineControlInfo inlineControlObj = InlineControlInfoProvider.GetInlineControlInfo(controlId);

        EditedObject = inlineControlObj;

        if (controlId > 0)
        {
            // Get the active sites
            DataSet ds = InlineControlSiteInfoProvider.GetInlineControlSites("SiteID", "ControlID = " + controlId, null, 0);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                currentValues = TextHelper.Join(";", SqlHelperClass.GetStringValues(ds.Tables[0], "SiteID"));
            }

            if (!RequestHelper.IsPostBack())
            {
                usSites.Value = currentValues;
            }
        }

        usSites.OnSelectionChanged += usSites_OnSelectionChanged;
    }
Beispiel #2
0
    /// <summary>
    /// Adds inline control to current site. Called when the "Add control to site" button is pressed.
    /// Expects the CreateInlineControl method to be run first.
    /// </summary>
    private bool AddInlineControlToSite()
    {
        // Get the inline control
        InlineControlInfo control = InlineControlInfoProvider.GetInlineControlInfo("MyNewControl");
        if (control != null)
        {
            int controlId = control.ControlID;
            int siteId = CMSContext.CurrentSiteID;

            // Save the binding
            InlineControlSiteInfoProvider.AddInlineControlToSite(controlId, siteId);

            return true;
        }

        return false;
    }
Beispiel #3
0
    protected void SaveSites()
    {
        // Get object
        InlineControlInfo inlineControlObj = InlineControlInfoProvider.GetInlineControlInfo(controlId);

        EditedObject = inlineControlObj;

        // Remove old items
        string newValues = ValidationHelper.GetString(usSites.Value, null);
        string items     = DataHelper.GetNewItemsInList(newValues, currentValues);

        if (!string.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                int siteId = 0;
                foreach (string item in newItems)
                {
                    siteId = ValidationHelper.GetInteger(item, 0);
                    // Remove inline control from the site
                    InlineControlSiteInfoProvider.RemoveInlineControlFromSite(controlId, siteId);
                }
            }
        }

        // Add new items
        items = DataHelper.GetNewItemsInList(currentValues, newValues);
        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                int siteId = 0;
                // Add all new items to site
                foreach (string item in newItems)
                {
                    siteId = ValidationHelper.GetInteger(item, 0);
                    // Add inline control to the site
                    InlineControlSiteInfoProvider.AddInlineControlToSite(controlId, siteId);
                }
            }
        }

        ShowInformation(GetString("General.ChangesSaved"));
    }
Beispiel #4
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // Validate inputs
        string errorMessage = new Validator().NotEmpty(txtControlDisplayName.Text.Trim(), rfvDisplayName.ErrorMessage)
                              .NotEmpty(txtControlName.Text.Trim(), rfvName.ErrorMessage)
                              .IsCodeName(txtControlName.Text.Trim(), GetString("general.errorcodenameinidentifierformat")).Result;

        if ((string.IsNullOrEmpty(errorMessage)) && (!FileSystemSelector.IsValid()))
        {
            errorMessage = FileSystemSelector.ValidationError;
        }

        if (string.IsNullOrEmpty(errorMessage))
        {
            // Create new inline control object
            InlineControlInfo inlineControlObj = new InlineControlInfo();

            inlineControlObj.ControlDescription   = txtControlDescription.Text.Trim();
            inlineControlObj.ControlDisplayName   = txtControlDisplayName.Text.Trim();
            inlineControlObj.ControlFileName      = FileSystemSelector.Value.ToString().Trim();
            inlineControlObj.ControlParameterName = txtControlParameterName.Text.Trim();
            inlineControlObj.ControlName          = txtControlName.Text.Trim();

            try
            {
                // Create new inline control
                InlineControlInfoProvider.SetInlineControlInfo(inlineControlObj);
                if ((chkAssign.Visible) && (chkAssign.Checked) && (CMSContext.CurrentSite != null))
                {
                    // Add new control to the actual site
                    InlineControlSiteInfoProvider.AddInlineControlToSite(inlineControlObj.ControlID, CMSContext.CurrentSiteID);
                }
                // Redirect to edit page
                URLHelper.Redirect("Frameset.aspx?inlinecontrolid=" + Convert.ToString(inlineControlObj.ControlID) + "&saved=1");
            }
            catch (Exception ex)
            {
                ShowError(ex.Message.Replace("%%name%%", txtControlName.Text));
            }
        }
        else
        {
            ShowError(errorMessage);
        }
    }
Beispiel #5
0
    /// <summary>
    /// Removes inline control from site. Called when the "Remove control from site" button is pressed.
    /// Expects the AddInlineControlToSite method to be run first.
    /// </summary>
    private bool RemoveInlineControlFromSite()
    {
        // Get the inline control
        InlineControlInfo removeControl = InlineControlInfoProvider.GetInlineControlInfo("MyNewControl");
        if (removeControl != null)
        {
            int siteId = CMSContext.CurrentSiteID;

            // Get the binding
            InlineControlSiteInfo inlineControlSite = InlineControlSiteInfoProvider.GetInlineControlSiteInfo(removeControl.ControlID, siteId);

            // Delete the binding
            InlineControlSiteInfoProvider.DeleteInlineControlSiteInfo(inlineControlSite);

            return true;
        }

        return false;
    }