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); }
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); }
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); }
/// <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 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); }
/// <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); }
/// <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) { switch (actionName.ToLowerCSafe()) { case "edit": URLHelper.Redirect(string.Format("Container_Edit_Frameset.aspx?containerid={0}&hash={1}&tabmode=1", Convert.ToString(actionArgument), QueryHelper.GetHash(string.Empty))); break; case "delete": WebPartContainerInfoProvider.DeleteWebPartContainerInfo(Convert.ToInt32(actionArgument)); break; } }
/// <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); }
/// <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> /// 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); }
/// <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); }
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 void InitEditeObject() { if (PersistentEditedObject != null) { webPartContainer = PersistentEditedObject as WebPartContainerInfo; return; } if (containerId > 0) { webPartContainer = WebPartContainerInfoProvider.GetWebPartContainerInfo(containerId); } else { webPartContainer = WebPartContainerInfoProvider.GetWebPartContainerInfo(containerName); } PersistentEditedObject = webPartContainer; }
/// <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); }
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 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); } }