Exemplo n.º 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;
    }
Exemplo n.º 2
0
    /// <summary>
    /// Gets and bulk updates inline controls. Called when the "Get and bulk update controls" button is pressed.
    /// Expects the CreateInlineControl method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateInlineControls()
    {
        // Prepare the parameters
        string where = "ControlName LIKE N'MyNewControl%'";

        // Get the data
        DataSet controls = InlineControlInfoProvider.GetInlineControls(where, null);
        if (!DataHelper.DataSourceIsEmpty(controls))
        {
            // Loop through the individual items
            foreach (DataRow controlDr in controls.Tables[0].Rows)
            {
                // Create object from DataRow
                InlineControlInfo modifyControl = new InlineControlInfo(controlDr);

                // Update the properties
                modifyControl.ControlDisplayName = modifyControl.ControlDisplayName.ToUpper();

                // Save the changes
                InlineControlInfoProvider.SetInlineControlInfo(modifyControl);
            }

            return true;
        }

        return false;
    }
    /// <summary>
    /// Reloads selected control displayed properties (name, description, parameter name).
    /// </summary>
    protected void ReloadControlProperties()
    {
        string selectedControlName = lstControls.SelectedValue;

        // get selected control info
        InlineControlInfo control = InlineControlInfoProvider.GetInlineControlInfo(selectedControlName);

        if (control != null)
        {
            lblControlName.Text        = control.ControlDisplayName;
            lblControlDescription.Text = control.ControlDescription;

            // hide or display control parameter name textbox
            if (control.ControlParameterName != "")
            {
                DisplayControlParameterName();
                lblControlParametrName.Text = control.ControlParameterName + " : ";
            }
            else
            {
                HideControlParameterName();
            }
        }
        else
        {
            HideControlParameterName();
        }
    }
Exemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get inline control ID from querystring
        inlinecontrolId = QueryHelper.GetInteger("inlinecontrolid", 0);

        if (!RequestHelper.IsPostBack())
        {
            InitalizeMenu();
        }

        string            currentInlineControlName = null;
        InlineControlInfo iControl = InlineControlInfoProvider.GetInlineControlInfo(inlinecontrolId);

        if (iControl != null)
        {
            currentInlineControlName = iControl.ControlDisplayName;
        }

        // Initializes page title
        string[,] pageTitleTabs = new string[2, 3];
        pageTitleTabs[0, 0]     = GetString("InlineControl_Header.Inlinecontrols");
        pageTitleTabs[0, 1]     = "~/CMSModules/InlineControls/Pages/Development/List.aspx";
        pageTitleTabs[0, 2]     = "_parent";
        pageTitleTabs[1, 0]     = currentInlineControlName;
        pageTitleTabs[1, 1]     = string.Empty;
        pageTitleTabs[1, 2]     = string.Empty;

        CurrentMaster.Title.Breadcrumbs   = pageTitleTabs;
        CurrentMaster.Title.TitleText     = GetString("InlineControl_Header.Title");
        CurrentMaster.Title.TitleImage    = GetImageUrl("Objects/CMS_InlineControl/object.png");
        CurrentMaster.Title.HelpTopicName = "general_tab16";
        CurrentMaster.Title.HelpName      = "helpTopic";
    }
Exemplo n.º 5
0
 /// <summary>
 /// Load data of editing inlineControl.
 /// </summary>
 /// <param name="inlineControlObj">InlineControl object</param>
 protected void LoadData(InlineControlInfo inlineControlObj)
 {
     txtControlDescription.Text = inlineControlObj.ControlDescription;
     txtControlDisplayName.Text = inlineControlObj.ControlDisplayName;
     txtControlParameterName.Text = inlineControlObj.ControlParameterName;
     FileSystemSelector.Value = inlineControlObj.ControlFileName;
     txtControlName.Text = inlineControlObj.ControlName;
     drpModule.Value = inlineControlObj.ControlResourceID;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Load data of editing inlineControl.
 /// </summary>
 /// <param name="inlineControlObj">InlineControl object</param>
 protected void LoadData(InlineControlInfo inlineControlObj)
 {
     txtControlDescription.Text   = inlineControlObj.ControlDescription;
     txtControlDisplayName.Text   = inlineControlObj.ControlDisplayName;
     txtControlParameterName.Text = inlineControlObj.ControlParameterName;
     FileSystemSelector.Value     = inlineControlObj.ControlFileName;
     txtControlName.Text          = inlineControlObj.ControlName;
     drpModule.Value = inlineControlObj.ControlResourceID;
 }
Exemplo n.º 7
0
    /// <summary>
    /// Deletes inline control. Called when the "Delete control" button is pressed.
    /// Expects the CreateInlineControl method to be run first.
    /// </summary>
    private bool DeleteInlineControl()
    {
        // Get the inline control
        InlineControlInfo deleteControl = InlineControlInfoProvider.GetInlineControlInfo("MyNewControl");

        // Delete the inline control
        InlineControlInfoProvider.DeleteInlineControlInfo(deleteControl);

        return (deleteControl != null);
    }
Exemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        lblFiles.ToolTip    = GetString("clonning.settings.inlinecontrol.files.tooltip");
        lblFileName.ToolTip = GetString("clonning.settings.inlinecontrol.filename.tooltip");

        if (!RequestHelper.IsPostBack())
        {
            InlineControlInfo control = InfoToClone as InlineControlInfo;
            if (control != null)
            {
                txtFileName.Text = FileHelper.GetUniqueFileName(control.ControlFileName);
            }
        }
    }
Exemplo n.º 9
0
    /// <summary>
    /// Creates inline control. Called when the "Create control" button is pressed.
    /// </summary>
    private bool CreateInlineControl()
    {
        // Create new inline control object
        InlineControlInfo newControl = new InlineControlInfo();

        // Set the properties
        newControl.ControlDisplayName = "My new control";
        newControl.ControlName = "MyNewControl";
        newControl.ControlFileName = "~/CMSModules/Polls/InlineControls/PollControl.ascx";
        newControl.ControlParameterName = "Poll name";
        newControl.ControlDescription = "My new inline control description";

        // Save the inline control
        InlineControlInfoProvider.SetInlineControlInfo(newControl);

        return true;
    }
Exemplo n.º 10
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        string errorMessage = new Validator()
                              .NotEmpty(txtControlDisplayName.Text.Trim(), rfvDisplayName.ErrorMessage)
                              .NotEmpty(txtControlName.Text.Trim(), rfvName.ErrorMessage)
                              .IsCodeName(txtControlName.Text.Trim(), GetString("general.errorcodenameinidentificatorformat"))
                              .Result;

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

        if (string.IsNullOrEmpty(errorMessage))
        {
            // Get object
            InlineControlInfo inlineControlObj = InlineControlInfoProvider.GetInlineControlInfo(controlId);
            EditedObject = inlineControlObj;

            // Update properties
            inlineControlObj.ControlDescription   = txtControlDescription.Text.Trim();
            inlineControlObj.ControlDisplayName   = txtControlDisplayName.Text.Trim();
            inlineControlObj.ControlParameterName = txtControlParameterName.Text.Trim();
            inlineControlObj.ControlName          = txtControlName.Text.Trim();
            inlineControlObj.ControlFileName      = FileSystemSelector.Value.ToString().Trim();
            inlineControlObj.ControlResourceID    = ValidationHelper.GetInteger(drpModule.Value, 0);

            try
            {
                // Save changes
                InlineControlInfoProvider.SetInlineControlInfo(inlineControlObj);
                ShowInformation(GetString("general.changessaved"));

                // Refresh header with display name
                ScriptHelper.RefreshTabHeader(Page, null);
            }
            catch (Exception ex)
            {
                ShowError(ex.Message.Replace("%%name%%", txtControlName.Text));
            }
        }
        else
        {
            ShowError(errorMessage);
        }
    }
Exemplo n.º 11
0
    /// <summary>
    /// Creates inline control. Called when the "Create control" button is pressed.
    /// </summary>
    private bool CreateInlineControl()
    {
        // Create new inline control object
        InlineControlInfo newControl = new InlineControlInfo();

        // Set the properties
        newControl.ControlDisplayName = "My new control";
        newControl.ControlName = "MyNewControl";
        newControl.ControlFileName = "~/CMSModules/Polls/InlineControls/PollControl.ascx";
        newControl.ControlParameterName = "Poll name";
        newControl.ControlDescription = "My new inline control description";

        // Save the inline control
        InlineControlInfoProvider.SetInlineControlInfo(newControl);

        return true;
    }
Exemplo n.º 12
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;
    }
Exemplo n.º 13
0
    /// <summary>
    /// Gets and updates inline control. Called when the "Get and update control" button is pressed.
    /// Expects the CreateInlineControl method to be run first.
    /// </summary>
    private bool GetAndUpdateInlineControl()
    {
        // Get the inline control
        InlineControlInfo updateControl = InlineControlInfoProvider.GetInlineControlInfo("MyNewControl");
        if (updateControl != null)
        {
            // Update the properties
            updateControl.ControlDisplayName = updateControl.ControlDisplayName.ToLower();

            // Save the changes
            InlineControlInfoProvider.SetInlineControlInfo(updateControl);

            return true;
        }

        return false;
    }
Exemplo n.º 14
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"));
    }
Exemplo n.º 15
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);
        }
    }
Exemplo n.º 16
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.errorcodenameinidentificatorformat")).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);
        }
    }
Exemplo n.º 17
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;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        lblFiles.ToolTip    = GetString("clonning.settings.inlinecontrol.files.tooltip");
        lblFileName.ToolTip = GetString("clonning.settings.inlinecontrol.filename.tooltip");

        if (!RequestHelper.IsPostBack())
        {
            InlineControlInfo control = InfoToClone as InlineControlInfo;
            if (control != null)
            {
                txtFileName.Text = FileHelper.GetUniqueFileName(control.ControlFileName);
            }
        }

        if (SystemContext.IsPrecompiledWebsite)
        {
            txtFileName.Text = "";
            chkFiles.Checked = false;

            txtFileName.Enabled = chkFiles.Enabled = false;
            txtFileName.ToolTip = chkFiles.ToolTip = GetString("general.copyfiles.precompiled");
        }
    }
Exemplo n.º 19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Controls initializations
        rfvDisplayName.ErrorMessage = GetString("InlineControl_Edit.ErrorDisplayName");
        rfvName.ErrorMessage        = GetString("InlineControl_Edit.ErrorName");

        plcDevelopment.Visible = SettingsKeyProvider.DevelopmentMode;

        // Get inline control ID from querystring
        controlId = QueryHelper.GetInteger("inlinecontrolid", 0);
        InlineControlInfo inlineControlObj = InlineControlInfoProvider.GetInlineControlInfo(controlId);

        EditedObject = inlineControlObj;

        // Fill editing form
        if (!RequestHelper.IsPostBack())
        {
            LoadData(inlineControlObj);

            if (QueryHelper.GetBoolean("saved", false))
            {
                ShowInformation(GetString("general.changessaved"));
            }
        }

        FileSystemDialogConfiguration config = new FileSystemDialogConfiguration
        {
            DefaultPath       = "CMSInlineControls",
            AllowedExtensions = "ascx",
            ShowFolders       = false
        };

        FileSystemSelector.DialogConfig       = config;
        FileSystemSelector.AllowEmptyValue    = false;
        FileSystemSelector.SelectedPathPrefix = "~/CMSInlineControls/";
        FileSystemSelector.ValidationError    = GetString("InlineControl_Edit.ErrorFileName");
    }
Exemplo n.º 20
0
    /// <summary>
    /// Gets and bulk updates inline controls. Called when the "Get and bulk update controls" button is pressed.
    /// Expects the CreateInlineControl method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateInlineControls()
    {
        // Prepare the parameters
        string where = "ControlName LIKE N'MyNewControl%'";

        // Get the data
        DataSet controls = InlineControlInfoProvider.GetInlineControls(where, null);
        if (!DataHelper.DataSourceIsEmpty(controls))
        {
            // Loop through the individual items
            foreach (DataRow controlDr in controls.Tables[0].Rows)
            {
                // Create object from DataRow
                InlineControlInfo modifyControl = new InlineControlInfo(controlDr);

                // Update the properties
                modifyControl.ControlDisplayName = modifyControl.ControlDisplayName.ToUpper();

                // Save the changes
                InlineControlInfoProvider.SetInlineControlInfo(modifyControl);
            }

            return true;
        }

        return false;
    }