protected void Page_Load(object sender, EventArgs e) { InitHeaderActions(); rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname"); rfvCodeName.ErrorMessage = GetString("general.requirescodename"); if (mDialogMode) { SetDialogMode(); } else { // Get by container ID containerId = QueryHelper.GetInteger("containerid", 0); if (containerId > 0) { webPartContainerObj = WebPartContainerInfoProvider.GetWebPartContainerInfo(containerId); SetEditedObject(webPartContainerObj, null); } } if (!RequestHelper.IsPostBack()) { LoadData(webPartContainerObj); // Show changes saved if specified from querystring if (QueryHelper.GetInteger("saved", 0) == 1) { ShowInformation(GetString("General.ChangesSaved")); } } this.plcCssLink.Visible = String.IsNullOrEmpty(txtContainerCSS.Text); }
protected override void OnPreInit(EventArgs e) { RequireSite = false; dialogMode = (QueryHelper.GetBoolean("dialog", false) || QueryHelper.GetBoolean("isindialog", false)); tabMode = QueryHelper.GetBoolean("tabmode", false); if (dialogMode) { if (!QueryHelper.ValidateHash("hash", "objectid")) { URLHelper.Redirect(ResolveUrl(string.Format("~/CMSMessages/Error.aspx?title={0}&text={1}", ResHelper.GetString("dialogs.badhashtitle"), ResHelper.GetString("dialogs.badhashtext")))); } } else { CheckGlobalAdministrator(); } var containerId = QueryHelper.GetInteger("containerid", 0); webPartContainer = WebPartContainerInfoProvider.GetWebPartContainerInfo(containerId); if (webPartContainer == null) { string containerName = QueryHelper.GetString("name", null); webPartContainer = WebPartContainerInfoProvider.GetWebPartContainerInfo(containerName); } SetEditedObject(webPartContainer, null); base.OnPreInit(e); }
/// <summary> /// Gets and bulk updates web part containers. Called when the "Get and bulk update containers" button is pressed. /// Expects the CreateWebPartContainer method to be run first. /// </summary> private bool GetAndBulkUpdateWebPartContainers() { // Prepare the parameters string where = "ContainerName LIKE N'MyNewContainer%'"; string orderBy = ""; int topN = 0; string columns = ""; // Get the data DataSet containers = WebPartContainerInfoProvider.GetContainers(where, orderBy, topN, columns); if (!DataHelper.DataSourceIsEmpty(containers)) { // Loop through the individual items foreach (DataRow containerDr in containers.Tables[0].Rows) { // Create object from DataRow WebPartContainerInfo modifyContainer = new WebPartContainerInfo(containerDr); // Update the properties modifyContainer.ContainerDisplayName = modifyContainer.ContainerDisplayName.ToUpper(); // Save the changes WebPartContainerInfoProvider.SetWebPartContainerInfo(modifyContainer); } return(true); } return(false); }
private void ProcessDialog(WebPartContainerInfo webPartContainer, bool closeOnSave) { WebPartContainerSiteInfoProvider.AddContainerToSite(webPartContainer, CMSContext.CurrentSite); string selector = QueryHelper.GetString("selectorid", string.Empty); if (string.IsNullOrEmpty(selector)) { return; } // Selects newly created container in the UniSelector string script = string.Format(@"var wopener = window.top.opener ? window.top.opener : window.top.dialogArguments if (wopener) {{ wopener.US_SelectNewValue_{0}('{1}'); }}", selector, webPartContainer.ContainerName); // Redirects to edit window or simply closes the current window if (closeOnSave) { script += "window.close();"; } else { script += string.Format(@"window.name = {0}; window.open('Container_Edit_General.aspx?name={1}&saved=1&editonlycode=true&selectorid='+{0}+'&hash={2}',window.name);", ScriptHelper.GetString(selector), webPartContainer.ContainerName, QueryHelper.GetHash("?editonlycode=true")); } ScriptHelper.RegisterStartupScript(this, GetType(), "UpdateSelector", script, true); }
protected override void OnPreInit(EventArgs e) { RequireSite = false; dialogMode = (QueryHelper.GetBoolean("dialog", false) || QueryHelper.GetBoolean("isindialog", false)); tabMode = QueryHelper.GetBoolean("tabmode", false); if (dialogMode) { if (!QueryHelper.ValidateHash("hash", "objectid")) { URLHelper.Redirect(AdministrationUrlHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext")); } } else { CheckGlobalAdministrator(); } var containerId = QueryHelper.GetInteger("containerid", 0); webPartContainer = WebPartContainerInfoProvider.GetWebPartContainerInfo(containerId); if (webPartContainer == null) { string containerName = QueryHelper.GetString("name", null); webPartContainer = WebPartContainerInfoProvider.GetWebPartContainerInfo(containerName); } SetEditedObject(webPartContainer, null); base.OnPreInit(e); }
private void SetDialogMode() { CurrentMaster.PanelContent.CssClass = "PageContent"; string containerName = QueryHelper.GetString("name", string.Empty); if (!string.IsNullOrEmpty(containerName)) { // Set page title CurrentMaster.Title.TitleText = GetString("Container_Edit.EditContainer"); CurrentMaster.Title.TitleImage = GetObjectIconUrl(PortalObjectType.WEBPARTCONTAINER, null); CurrentMaster.Title.HelpTopicName = "newedit_container"; // Get container data webPartContainerObj = WebPartContainerInfoProvider.GetWebPartContainerInfo(containerName); SetEditedObject(webPartContainerObj, "Container_Edit_Frameset.aspx"); } AddDialogButtons(); // Disable display and code name editing txtContainerDisplayName.ReadOnly = txtContainerName.ReadOnly = true; // When in modal dialog, the window scrolls to bottom, so this hack will scroll it back to top string scrollScript = "var scrollerDiv = document.getElementById('divContent'); if (scrollerDiv != null) setTimeout(function() { scrollerDiv.scrollTop = 0; }, 500);"; ScriptHelper.RegisterStartupScript(this, GetType(), "ScrollTop", scrollScript, true); }
private bool Save(bool closeOnSave) { // Validate user input string errorMessage = new Validator() .NotEmpty(txtContainerDisplayName.Text, rfvDisplayName.ErrorMessage) .NotEmpty(txtContainerName.Text, rfvCodeName.ErrorMessage) .IsCodeName(txtContainerName.Text, GetString("General.InvalidCodeName")) .Result; if (!string.IsNullOrEmpty(errorMessage)) { ShowError(errorMessage); return(false); } // Parse the container text string text = txtContainerText.Text; string after = ""; int wpIndex = text.IndexOf(WebPartContainerInfoProvider.WP_CHAR); if (wpIndex >= 0) { after = text.Substring(wpIndex + 1).Replace(WebPartContainerInfoProvider.WP_CHAR, ""); text = text.Substring(0, wpIndex); } WebPartContainerInfo webPartContainerObj = new WebPartContainerInfo() { ContainerTextBefore = text, ContainerTextAfter = after, ContainerCSS = txtContainerCSS.Text, ContainerName = txtContainerName.Text.Trim(), ContainerDisplayName = txtContainerDisplayName.Text.Trim() }; // Check for duplicity if (WebPartContainerInfoProvider.GetWebPartContainerInfo(webPartContainerObj.ContainerName) != null) { ShowError(GetString("Container_Edit.UniqueError")); return(false); } WebPartContainerInfoProvider.SetWebPartContainerInfo(webPartContainerObj); CMSContext.EditedObject = webPartContainerObj; CMSObjectManager.CheckOutNewObject(Page); if (mDialogMode) { ProcessDialog(webPartContainerObj, closeOnSave); } else { ProcessPage(webPartContainerObj); } return(true); }
/// <summary> /// Deletes web part container. Called when the "Delete container" button is pressed. /// Expects the CreateWebPartContainer method to be run first. /// </summary> private bool DeleteWebPartContainer() { // Get the web part container WebPartContainerInfo deleteContainer = WebPartContainerInfoProvider.GetWebPartContainerInfo("MyNewContainer"); // Delete the web part container WebPartContainerInfoProvider.DeleteWebPartContainerInfo(deleteContainer); return(deleteContainer != null); }
private void ProcessPage(WebPartContainerInfo webPartContainer) { if (chkAssign.Visible && chkAssign.Checked) { WebPartContainerSiteInfoProvider.AddContainerToSite(webPartContainer, CMSContext.CurrentSite); } URLHelper.Redirect(string.Format("Container_Edit_Frameset.aspx?containerid={0}&saved=1&hash={1}", webPartContainer.ContainerID, QueryHelper.GetHash(string.Empty))); }
/// <summary> /// Load data of editing webPartContainer. /// </summary> /// <param name="webPartContainer">WebPartContainer object</param> protected void LoadData(WebPartContainerInfo webPartContainer) { if (webPartContainer != null) { // Load fields txtContainerTextBefore.Text = webPartContainer.ContainerTextBefore; txtContainerTextAfter.Text = webPartContainer.ContainerTextAfter; txtContainerCSS.Text = webPartContainer.ContainerCSS; txtContainerName.Text = webPartContainer.ContainerName; txtContainerDisplayName.Text = webPartContainer.ContainerDisplayName; } }
protected void Page_Load(object sender, EventArgs e) { // Initialize container object if (PersistentEditedObject == null) { PersistentEditedObject = WebPartContainer; } WebPartContainer = PersistentEditedObject as WebPartContainerInfo; // Initialize master page elements InitializeMasterPage(); }
/// <summary> /// Saves the web part container. /// </summary> /// <returns>true if web part container was saved successfully, otherwise false.</returns> private bool Save() { string errorMessage = new Validator() .NotEmpty(txtContainerDisplayName.Text, rfvDisplayName.ErrorMessage) .NotEmpty(txtContainerName.Text, rfvCodeName.ErrorMessage) .IsCodeName(txtContainerName.Text, GetString("general.invalidcodename")) .Result; if (errorMessage != string.Empty) { ShowError(errorMessage); return(false); } // If webPartContainer doesnt already exist, create new one if (webPartContainerObj == null) { webPartContainerObj = new WebPartContainerInfo(); } webPartContainerObj.ContainerTextBefore = txtContainerTextBefore.Text; webPartContainerObj.ContainerTextAfter = txtContainerTextAfter.Text; webPartContainerObj.ContainerCSS = txtContainerCSS.Text; webPartContainerObj.ContainerName = txtContainerName.Text.Trim(); webPartContainerObj.ContainerDisplayName = txtContainerDisplayName.Text.Trim(); // Check existing name if (!mDialogMode) { WebPartContainerInfo wPcI = WebPartContainerInfoProvider.GetWebPartContainerInfo(webPartContainerObj.ContainerName); if ((wPcI != null) && (wPcI.ContainerID != webPartContainerObj.ContainerID)) { ShowError(GetString("Container_Edit.UniqueError")); return(false); } } // Save the container WebPartContainerInfoProvider.SetWebPartContainerInfo(webPartContainerObj); ShowInformation(GetString("General.ChangesSaved")); // Reload header if changes were saved if (TabMode) { ScriptHelper.RefreshTabHeader(Page, null); } return(true); }
private void ProcessDialog(WebPartContainerInfo webPartContainer, bool closeOnSave) { WebPartContainerSiteInfoProvider.AddContainerToSite(webPartContainer, CMSContext.CurrentSite); string selector = QueryHelper.GetString("selectorid", string.Empty); if (string.IsNullOrEmpty(selector)) { return; } ScriptHelper.RegisterWOpenerScript(this); // Selects newly created container in the UniSelector string script = string.Format(@"if (wopener) {{ wopener.US_SelectNewValue_{0}('{1}'); }}", selector, webPartContainer.ContainerName); // Redirects to edit window or simply closes the current window if (closeOnSave) { script += "CloseDialog();"; } else { String previewSuffix = String.Empty; string aliasPath = QueryHelper.GetString("aliaspath", String.Empty); Guid instanceGUID = QueryHelper.GetGuid("instanceguid", Guid.Empty); if (aliasPath != String.Empty) { previewSuffix = "&aliaspath=" + aliasPath; } if (instanceGUID != Guid.Empty) { previewSuffix += "&instanceguid=" + instanceGUID; } script += string.Format(@"window.name = {0}; window.open('Container_Edit_General.aspx?name={1}&saved=1&editonlycode=true&selectorid='+{0}+'&hash={2}{3}',window.name);", ScriptHelper.GetString(selector), webPartContainer.ContainerName, QueryHelper.GetHash("?editonlycode=true"), previewSuffix ); } ScriptHelper.RegisterStartupScript(this, GetType(), "UpdateSelector", script, true); }
/// <summary> /// Creates web part container. Called when the "Create container" button is pressed. /// </summary> private bool CreateWebPartContainer() { // Create new web part container object WebPartContainerInfo newContainer = new WebPartContainerInfo(); // Set the properties newContainer.ContainerDisplayName = "My new container"; newContainer.ContainerName = "MyNewContainer"; newContainer.ContainerTextBefore = "<div class=\"myNewContainer\">"; newContainer.ContainerTextAfter = "</div>"; // Save the web part container WebPartContainerInfoProvider.SetWebPartContainerInfo(newContainer); return(true); }
private void ProcessPage(WebPartContainerInfo webPartContainer) { if (chkAssign.Visible && chkAssign.Checked) { WebPartContainerSiteInfoProvider.AddContainerToSite(webPartContainer, SiteContext.CurrentSite); } UIElementInfo ui = UIElementInfoProvider.GetUIElementInfo("cms.Design", "EditWebPartContainer"); if (ui != null) { String url = UIContextHelper.GetElementUrl(ui, false); url = URLHelper.AddParameterToUrl(url, "objectID", webPartContainer.ContainerID.ToString()); URLHelper.Redirect(url); } }
/// <summary> /// Removes web part container from site. Called when the "Remove container from site" button is pressed. /// Expects the AddWebPartContainerToSite method to be run first. /// </summary> private bool RemoveWebPartContainerFromSite() { // Get the web part container WebPartContainerInfo removeContainer = WebPartContainerInfoProvider.GetWebPartContainerInfo("MyNewContainer"); if (removeContainer != null) { int siteId = CMSContext.CurrentSiteID; // Delete the binding WebPartContainerSiteInfoProvider.RemoveContainerFromSite(removeContainer.ContainerID, siteId); return(true); } return(false); }
/// <summary> /// Gets and updates web part container. Called when the "Get and update container" button is pressed. /// Expects the CreateWebPartContainer method to be run first. /// </summary> private bool GetAndUpdateWebPartContainer() { // Get the web part container WebPartContainerInfo updateContainer = WebPartContainerInfoProvider.GetWebPartContainerInfo("MyNewContainer"); if (updateContainer != null) { // Update the properties updateContainer.ContainerDisplayName = updateContainer.ContainerDisplayName.ToLower(); // Save the changes WebPartContainerInfoProvider.SetWebPartContainerInfo(updateContainer); return(true); } return(false); }
/// <summary> /// Adds web part container to site. Called when the "Add container to site" button is pressed. /// Expects the CreateWebPartContainer method to be run first. /// </summary> private bool AddWebPartContainerToSite() { // Get the web part container WebPartContainerInfo container = WebPartContainerInfoProvider.GetWebPartContainerInfo("MyNewContainer"); if (container != null) { int containerId = container.ContainerID; int siteId = CMSContext.CurrentSiteID; // Save the binding WebPartContainerSiteInfoProvider.AddContainerToSite(containerId, siteId); return(true); } return(false); }
private bool Save(bool closeOnSave) { // Validate user input string errorMessage = new Validator() .NotEmpty(txtContainerDisplayName.Text, rfvDisplayName.ErrorMessage) .NotEmpty(txtContainerName.Text, rfvCodeName.ErrorMessage) .IsCodeName(txtContainerName.Text, GetString("General.InvalidCodeName")) .Result; if (!string.IsNullOrEmpty(errorMessage)) { ShowError(errorMessage); return(false); } WebPartContainerInfo webPartContainerObj = new WebPartContainerInfo { ContainerTextBefore = txtContainerTextBefore.Text, ContainerTextAfter = txtContainerTextAfter.Text, ContainerCSS = txtContainerCSS.Text, ContainerName = txtContainerName.Text.Trim(), ContainerDisplayName = txtContainerDisplayName.Text.Trim() }; // Check for duplicity if (WebPartContainerInfoProvider.GetWebPartContainerInfo(webPartContainerObj.ContainerName) != null) { ShowError(GetString("Container_Edit.UniqueError")); return(false); } WebPartContainerInfoProvider.SetWebPartContainerInfo(webPartContainerObj); if (mDialogMode) { ProcessDialog(webPartContainerObj, closeOnSave); } else { ProcessPage(webPartContainerObj); } return(true); }
/// <summary> /// Retrieves the stylesheets of the web part container from the database. /// </summary> /// <param name="containerName">Container name</param> /// <returns>The stylesheet data (plain version only)</returns> private static CMSOutputResource GetContainer(string containerName) { WebPartContainerInfo containerInfo = WebPartContainerInfoProvider.GetWebPartContainerInfo(containerName); if (containerInfo == null) { return(null); } // Build the result CMSOutputResource resource = new CMSOutputResource() { Data = HTMLHelper.ResolveCSSUrls(containerInfo.ContainerCSS, URLHelper.ApplicationPath), LastModified = containerInfo.ContainerLastModified, Etag = containerInfo.ContainerName }; return(resource); }
private void InitEditeObject() { if (PersistentEditedObject != null) { webPartContainer = PersistentEditedObject as WebPartContainerInfo; return; } if (containerId > 0) { webPartContainer = WebPartContainerInfoProvider.GetWebPartContainerInfo(containerId); } else { webPartContainer = WebPartContainerInfoProvider.GetWebPartContainerInfo(containerName); } PersistentEditedObject = webPartContainer; }
protected override void OnPreInit(EventArgs e) { RequireSite = false; dialogMode = QueryHelper.GetBoolean("editonlycode", false); tabMode = QueryHelper.GetBoolean("tabmode", false); if (dialogMode) { // Check hash if (!QueryHelper.ValidateHash("hash", "saved;containerid;name;selectorid;tabmode;aliaspath;instanceGUID", true, true, true)) { URLHelper.Redirect(ResolveUrl(string.Format("~/CMSMessages/Error.aspx?title={0}&text={1}", ResHelper.GetString("dialogs.badhashtitle"), ResHelper.GetString("dialogs.badhashtext")))); } // Check permissions for web part properties UI if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Content", new string[] { "Design", "Design.WebPartProperties", "WebPartProperties.General", "WebPartProperties.EditContainers" }, CMSContext.CurrentSiteName)) { RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "Design.WebPartProperties;WebPartProperties.General;WebPartProperties.EditContainers"); } } else { CheckAccessToSiteManager(); } var containerId = QueryHelper.GetInteger("containerid", 0); webPartContainer = WebPartContainerInfoProvider.GetWebPartContainerInfo(containerId); if (webPartContainer == null) { string containerName = QueryHelper.GetString("name", null); webPartContainer = WebPartContainerInfoProvider.GetWebPartContainerInfo(containerName); } string frameSetUrl = dialogMode ? "Container_Edit_Frameset.aspx" : null; SetEditedObject(webPartContainer, frameSetUrl); base.OnPreInit(e); }
protected void Page_Load(object sender, EventArgs e) { // Setup the filesystem browser int containerId = QueryHelper.GetInteger("containerid", 0); if (containerId > 0) { WebPartContainerInfo ci = WebPartContainerInfoProvider.GetWebPartContainerInfo(containerId); EditedObject = ci; if (ci != null) { // Ensure the theme folder themeElem.Path = ci.GetThemePath(); } } else { EditedObject = null; } }
private void ProcessDialog(WebPartContainerInfo webPartContainer, bool closeOnSave) { WebPartContainerSiteInfoProvider.AddContainerToSite(webPartContainer, SiteContext.CurrentSite); ScriptHelper.RegisterWOpenerScript(this); string returnHandler = ScriptHelper.GetString(QueryHelper.GetString("returnhandler", String.Empty), false); string script = "if (wopener && wopener." + returnHandler + ") { wopener." + returnHandler + "('" + webPartContainer.ContainerName + "'); }"; // Redirects to edit window or simply closes the current window if (closeOnSave) { script += "CloseDialog();"; } else { UIElementInfo ui = UIElementInfoProvider.GetUIElementInfo("cms.Design", "EditWebPartContainer"); if (ui != null) { // Create base URL for element String url = UIContextHelper.GetElementUrl(ui, UIContext); // Append object ID url = URLHelper.AddParameterToUrl(url, "objectid", webPartContainer.ContainerID.ToString()); // Append actual query string parameters url = URLHelper.AddParameterToUrl(url, "returnhandler", QueryHelper.GetString("returnhandler", String.Empty)); url = URLHelper.AddParameterToUrl(url, "dialog", "1"); url = URLHelper.AddParameterToUrl(url, "aliaspath", QueryHelper.GetString("aliaspath", String.Empty)); url = URLHelper.AddParameterToUrl(url, "instanceguid", QueryHelper.GetString("instanceguid", String.Empty)); // Append dialog hash url = UIContextHelper.AppendDialogHash(url); script += "window.location.replace('" + ResolveUrl(url) + "');"; } } ScriptHelper.RegisterStartupScript(this, GetType(), "UpdateSelector", script, true); }
/// <summary> /// Saves the web part container. /// </summary> /// <returns>true if web part container was saved successfully, otherwise false.</returns> private bool Save() { string errorMessage = new Validator() .NotEmpty(txtContainerDisplayName.Text, rfvDisplayName.ErrorMessage) .NotEmpty(txtContainerName.Text, rfvCodeName.ErrorMessage) .IsCodeName(txtContainerName.Text, GetString("general.invalidcodename")) .Result; if (errorMessage != string.Empty) { ShowError(errorMessage); return false; } // If webPartContainer doesnt already exist, create new one if (webPartContainerObj == null) { webPartContainerObj = new WebPartContainerInfo(); } webPartContainerObj.ContainerTextBefore = txtContainerTextBefore.Text; webPartContainerObj.ContainerTextAfter = txtContainerTextAfter.Text; webPartContainerObj.ContainerCSS = txtContainerCSS.Text; webPartContainerObj.ContainerName = txtContainerName.Text.Trim(); webPartContainerObj.ContainerDisplayName = txtContainerDisplayName.Text.Trim(); // Check existing name if (!mDialogMode) { WebPartContainerInfo wPcI = WebPartContainerInfoProvider.GetWebPartContainerInfo(webPartContainerObj.ContainerName); if ((wPcI != null) && (wPcI.ContainerID != webPartContainerObj.ContainerID)) { ShowError(GetString("Container_Edit.UniqueError")); return false; } } // Save the container WebPartContainerInfoProvider.SetWebPartContainerInfo(webPartContainerObj); ShowInformation(GetString("General.ChangesSaved")); // Reload header if changes were saved if (TabMode) { ScriptHelper.RefreshTabHeader(Page, null); } return true; }
private bool Save(bool closeOnSave) { // Validate user input string errorMessage = new Validator() .NotEmpty(txtContainerDisplayName.Text, rfvDisplayName.ErrorMessage) .NotEmpty(txtContainerName.Text, rfvCodeName.ErrorMessage) .IsCodeName(txtContainerName.Text, GetString("General.InvalidCodeName")) .Result; if (!string.IsNullOrEmpty(errorMessage)) { ShowError(errorMessage); return false; } WebPartContainerInfo webPartContainerObj = new WebPartContainerInfo { ContainerTextBefore = txtContainerTextBefore.Text, ContainerTextAfter = txtContainerTextAfter.Text, ContainerCSS = txtContainerCSS.Text, ContainerName = txtContainerName.Text.Trim(), ContainerDisplayName = txtContainerDisplayName.Text.Trim() }; // Check for duplicity if (WebPartContainerInfoProvider.GetWebPartContainerInfo(webPartContainerObj.ContainerName) != null) { ShowError(GetString("Container_Edit.UniqueError")); return false; } WebPartContainerInfoProvider.SetWebPartContainerInfo(webPartContainerObj); if (mDialogMode) { ProcessDialog(webPartContainerObj, closeOnSave); } else { ProcessPage(webPartContainerObj); } return true; }
private bool Save(bool closeOnSave) { // Validate user input string errorMessage = new Validator() .NotEmpty(txtContainerDisplayName.Text, rfvDisplayName.ErrorMessage) .NotEmpty(txtContainerName.Text, rfvCodeName.ErrorMessage) .IsCodeName(txtContainerName.Text, GetString("General.InvalidCodeName")) .Result; if (!string.IsNullOrEmpty(errorMessage)) { ShowError(errorMessage); return false; } // Parse the container text string text = txtContainerText.Text; string after = ""; int wpIndex = text.IndexOf(WebPartContainerInfoProvider.WP_CHAR); if (wpIndex >= 0) { after = text.Substring(wpIndex + 1).Replace(WebPartContainerInfoProvider.WP_CHAR, ""); text = text.Substring(0, wpIndex); } WebPartContainerInfo webPartContainerObj = new WebPartContainerInfo() { ContainerTextBefore = text, ContainerTextAfter = after, ContainerCSS = txtContainerCSS.Text, ContainerName = txtContainerName.Text.Trim(), ContainerDisplayName = txtContainerDisplayName.Text.Trim() }; // Check for duplicity if (WebPartContainerInfoProvider.GetWebPartContainerInfo(webPartContainerObj.ContainerName) != null) { ShowError(GetString("Container_Edit.UniqueError")); return false; } WebPartContainerInfoProvider.SetWebPartContainerInfo(webPartContainerObj); CMSContext.EditedObject = webPartContainerObj; CMSObjectManager.CheckOutNewObject(Page); if (mDialogMode) { ProcessDialog(webPartContainerObj, closeOnSave); } else { ProcessPage(webPartContainerObj); } return true; }
/// <summary> /// Gets and bulk updates web part containers. Called when the "Get and bulk update containers" button is pressed. /// Expects the CreateWebPartContainer method to be run first. /// </summary> private bool GetAndBulkUpdateWebPartContainers() { // Prepare the parameters string where = "ContainerName LIKE N'MyNewContainer%'"; string orderBy = ""; int topN = 0; string columns = ""; // Get the data DataSet containers = WebPartContainerInfoProvider.GetContainers() .Where(where) .Columns(columns) .TopN(topN) .OrderBy(orderBy); if (!DataHelper.DataSourceIsEmpty(containers)) { // Loop through the individual items foreach (DataRow containerDr in containers.Tables[0].Rows) { // Create object from DataRow WebPartContainerInfo modifyContainer = new WebPartContainerInfo(containerDr); // Update the properties modifyContainer.ContainerDisplayName = modifyContainer.ContainerDisplayName.ToUpper(); // Save the changes WebPartContainerInfoProvider.SetWebPartContainerInfo(modifyContainer); } return true; } return false; }
/// <summary> /// Creates web part container. Called when the "Create container" button is pressed. /// </summary> private bool CreateWebPartContainer() { // Create new web part container object WebPartContainerInfo newContainer = new WebPartContainerInfo(); // Set the properties newContainer.ContainerDisplayName = "My new container"; newContainer.ContainerName = "MyNewContainer"; newContainer.ContainerTextBefore = "<div class=\"myNewContainer\">"; newContainer.ContainerTextAfter = "</div>"; // Save the web part container WebPartContainerInfoProvider.SetWebPartContainerInfo(newContainer); return true; }
private void SaveContainer() { try { // Validate user input string errorMessage = new Validator() .NotEmpty(txtContainerDisplayName.Text, rfvDisplayName.ErrorMessage) .NotEmpty(txtContainerName.Text, rfvCodeName.ErrorMessage) .IsCodeName(txtContainerName.Text, GetString("General.InvalidCodeName")) .Result; if (!string.IsNullOrEmpty(errorMessage)) { ShowError(errorMessage); return; } // Parse the container text string text = txtContainerText.Text; string after = ""; int wpIndex = text.IndexOf(WebPartContainerInfoProvider.WP_CHAR); if (wpIndex >= 0) { after = text.Substring(wpIndex + 1).Replace(WebPartContainerInfoProvider.WP_CHAR, ""); text = text.Substring(0, wpIndex); } WebPartContainerInfo webPartContainerObj = new WebPartContainerInfo() { ContainerTextBefore = text, ContainerTextAfter = after, ContainerCSS = txtContainerCSS.Text, ContainerName = txtContainerName.Text.Trim(), ContainerDisplayName = txtContainerDisplayName.Text.Trim() }; // Check for duplicity if (WebPartContainerInfoProvider.GetWebPartContainerInfo(webPartContainerObj.ContainerName) != null) { ShowError(GetString("Container_Edit.UniqueError")); return; } WebPartContainerInfoProvider.SetWebPartContainerInfo(webPartContainerObj); UIContext.EditedObject = webPartContainerObj; CMSObjectManager.CheckOutNewObject(Page); if (mDialogMode) { ProcessDialog(webPartContainerObj, true); } else { ProcessPage(webPartContainerObj); } } catch (SecurityException ex) { ShowError(!SystemContext.IsFullTrustLevel ? ResHelper.GetStringFormat("general.fulltrustrequired", ex.Message) : ex.Message); } catch (Exception ex) { ShowError(ex.Message); } }