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; }
/// <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(); } }
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"; }
/// <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); }
/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void uniGrid_OnAction(string actionName, object actionArgument) { if (actionName == "edit") { URLHelper.Redirect("Frameset.aspx?inlinecontrolid=" + Convert.ToString(actionArgument)); } else if (actionName == "delete") { // Delete InlineControlInfo object from database InlineControlInfoProvider.DeleteInlineControlInfo(ValidationHelper.GetInteger(actionArgument, 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); } }
/// <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; }
/// <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; }
/// <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; }
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")); }
/// <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); } }
/// <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; }
/// <summary> /// Reloads list of available controls. /// </summary> protected void ReloadControls() { if (CMSContext.CurrentSite != null) { // get controls for selected site lstControls.DataSource = InlineControlInfoProvider.GetInlineControlsForSite(CMSContext.CurrentSite.SiteID, "ControlName, ControlDisplayName"); lstControls.DataBind(); // select and display first control of the list by default if (lstControls.Items.Count > 0) { lstControls.SelectedIndex = 0; ReloadControlProperties(); } else { HideControlParameterName(); } } }
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"); }