protected void btnCreateDocument_Click(object sender, EventArgs e) { if (radCopy.Checked) { string sourceCulture = copyCulturesElem.Value.ToString(); TreeNode sourceNode = DocumentHelper.GetDocument(NodeID, sourceCulture, Tree); if (sourceNode != null) { if (chkSaveBeforeEditing.Checked && (node != null)) { // Create the version first TreeNode newCulture = TreeNode.New(node.ClassName); DocumentHelper.CopyNodeData(sourceNode, newCulture, new CopyNodeDataSettings(true, null)); NewCultureDocumentSettings settings = new NewCultureDocumentSettings { Node = newCulture, CultureCode = RequiredCulture, CopyAttachments = true, CopyCategories = true }; DocumentHelper.InsertNewCultureVersion(settings); // Refresh page if (RequiresDialog) { string url = URLHelper.ResolveUrl(DocumentURLProvider.GetUrl(newCulture.NodeAliasPath) + "?" + URLHelper.LanguageParameterName + "=" + RequiredCulture); ScriptHelper.RegisterStartupScript(this, typeof(string), "NewCultureRefreshAction", ScriptHelper.GetScript(" wopener.location = " + ScriptHelper.GetString(url) + "; CloseDialog();")); } else { ScriptHelper.RegisterStartupScript(this, typeof(string), "NewCultureRefreshAction", ScriptHelper.GetScript("if (FramesRefresh) { FramesRefresh(" + node.NodeID + "); }")); } } else { var url = GetEditUrl(node); url = URLHelper.AddParameterToUrl(url, "sourcedocumentid", sourceNode.DocumentID.ToString()); Response.Redirect(url); } } else { ShowError(GetString("transman.notallowedcreate")); } } else { var url = GetEditUrl(node); Response.Redirect(url); } }
/// <summary> /// Creates new culture version of object. /// </summary> protected void btnCreateDocument_Click(object sender, EventArgs e) { if (radCopy.Checked) { string sourceCulture = copyCulturesElem.Value.ToString(); TreeNode actualSourceNode = DocumentHelper.GetDocument(NodeID, sourceCulture, Tree); TreeNode sourceNode = actualSourceNode.IsLink ? DocumentHelper.GetDocument(Tree.GetOriginalNode(actualSourceNode), Tree) : actualSourceNode; if (sourceNode != null) { if (chkSaveBeforeEditing.Checked && (Node != null)) { // Create the version first TreeNode newCulture = TreeNode.New(Node.ClassName); DocumentHelper.CopyNodeData(sourceNode, newCulture, new CopyNodeDataSettings(true, null) { ResetChanges = true }); if (Node.ClassName.ToLowerCSafe() == "cms.blogpost") { // Ensure blog post hierarchy if node is blog post newCulture.DocumentCulture = RequiredCulture; DocumentHelper.EnsureBlogPostHierarchy(newCulture, DocumentHelper.GetDocument(newCulture.NodeParentID, TreeProvider.ALL_CULTURES, Tree), Tree); } var settings = new NewCultureDocumentSettings(newCulture, RequiredCulture, Tree) { CopyAttachments = true, CopyCategories = true, ClearAttachmentFields = false }; try { DocumentHelper.InsertNewCultureVersion(settings); } catch (Exception ex) { // Catch possible exceptions LogAndShowError("Content", "NEWCULTUREVERSION", ex); return; } // Make sure document is published when versioning without workflow is applied var workflow = newCulture.GetWorkflow(); if ((workflow != null) && workflow.WorkflowAutoPublishChanges && !workflow.UseCheckInCheckOut(newCulture.NodeSiteName)) { newCulture.MoveToPublishedStep(); } // Refresh page if (RequiresDialog) { string url = URLHelper.ResolveUrl(DocumentURLProvider.GetUrl(newCulture) + "?" + URLHelper.LanguageParameterName + "=" + RequiredCulture); ScriptHelper.RegisterStartupScript(this, typeof(string), "NewCultureRefreshAction", ScriptHelper.GetScript(" wopener.location = " + ScriptHelper.GetString(url) + "; CloseDialog();")); } else { ViewModeEnum mode = ViewModeEnum.Edit; if (!TreePathUtils.IsMenuItemType(Node.NodeClassName) && (PortalContext.ViewMode != ViewModeEnum.EditLive)) { mode = ViewModeEnum.EditForm; } ScriptHelper.RegisterStartupScript(this, typeof(string), "NewCultureRefreshAction", ScriptHelper.GetScript("if (FramesRefresh) { FramesRefresh(" + Node.NodeID + ", '" + mode + "'); }")); } } else { var url = GetEditUrl(Node); url = URLHelper.AddParameterToUrl(url, "sourcedocumentid", sourceNode.DocumentID.ToString()); if (RequiresDialog) { // Reload new page after save url = URLHelper.AddParameterToUrl(url, "reloadnewpage", "true"); } // Provide information about actual node if (actualSourceNode.IsLink) { url = URLHelper.AddParameterToUrl(url, "sourcenodeid", actualSourceNode.NodeID.ToString()); } Response.Redirect(url); } } else { ShowError(GetString("transman.notallowedcreate")); } } else { var url = GetEditUrl(Node); if (RequiresDialog) { // Reload new page after save url = URLHelper.AddParameterToUrl(url, "reloadnewpage", "true"); } Response.Redirect(url); } }
/// <summary> /// Creates new culture version of object. /// </summary> protected void btnCreateDocument_Click(object sender, EventArgs e) { if (radCopy.Checked) { string sourceCulture = copyCulturesElem.Value.ToString(); TreeNode actualSourceNode = DocumentHelper.GetDocument(NodeID, sourceCulture, Tree); TreeNode sourceNode = actualSourceNode.IsLink ? DocumentHelper.GetDocument(Tree.GetOriginalNode(actualSourceNode), Tree) : actualSourceNode; if (sourceNode != null) { if (chkSaveBeforeEditing.Checked && (Node != null)) { // Create the version first TreeNode newCulture = TreeNode.New(Node.ClassName); // The 'DocumentABTestConfiguration' is excluded from copying node to another culture as A/B test is linked to the culture specific node var excludedColumns = new[] { "DocumentABTestConfiguration" }; DocumentHelper.CopyNodeData(sourceNode, newCulture, new CopyNodeDataSettings(true, excludedColumns) { ResetChanges = true }); if (string.Equals(Node.ClassName, "cms.blogpost", StringComparison.InvariantCultureIgnoreCase)) { // Ensure blog post hierarchy if node is blog post newCulture.DocumentCulture = RequiredCulture; DocumentHelper.EnsureBlogPostHierarchy(newCulture, DocumentHelper.GetDocument(newCulture.NodeParentID, TreeProvider.ALL_CULTURES, Tree), Tree); } var settings = new NewCultureDocumentSettings(newCulture, RequiredCulture, Tree) { CopyAttachments = true, CopyCategories = true, ClearAttachmentFields = false }; try { DocumentHelper.InsertNewCultureVersion(settings); } catch (Exception ex) { // Catch possible exceptions LogAndShowError("Content", "NEWCULTUREVERSION", ex); return; } // Make sure document is published when versioning without workflow is applied var workflow = newCulture.GetWorkflow(); if ((workflow != null) && workflow.WorkflowAutoPublishChanges && !workflow.UseCheckInCheckOut(newCulture.NodeSiteName)) { newCulture.MoveToPublishedStep(); } // Refresh page if (RequiresDialog) { string url = UrlResolver.ResolveUrl(DocumentURLProvider.GetUrl(newCulture) + "?" + URLHelper.LanguageParameterName + "=" + RequiredCulture); ScriptHelper.RegisterStartupScript(this, typeof(string), "NewCultureRefreshAction", ScriptHelper.GetScript(" wopener.location = " + ScriptHelper.GetString(url) + "; CloseDialog();")); } else { ViewModeEnum mode = ViewModeEnum.Edit; if (!TreePathUtils.IsMenuItemType(Node.NodeClassName) && (PortalContext.ViewMode != ViewModeEnum.EditLive)) { mode = ViewModeEnum.EditForm; } ScriptHelper.RegisterStartupScript(this, typeof(string), "NewCultureRefreshAction", ScriptHelper.GetScript("if (FramesRefresh) { FramesRefresh(" + Node.NodeID + ", '" + mode + "'); }")); } } else { var url = GetEditUrl(Node); url = URLHelper.AddParameterToUrl(url, "sourcedocumentid", sourceNode.DocumentID.ToString()); if (RequiresDialog) { // Reload new page after save url = URLHelper.AddParameterToUrl(url, "reloadnewpage", "true"); } // Provide information about actual node if (actualSourceNode.IsLink) { url = URLHelper.AddParameterToUrl(url, "sourcenodeid", actualSourceNode.NodeID.ToString()); } URLHelper.ResponseRedirect(url); } } else { ShowError(GetString("transman.notallowedcreate")); } } else { var url = GetEditUrl(Node); if (RequiresDialog) { // Reload new page after save url = URLHelper.AddParameterToUrl(url, "reloadnewpage", "true"); } URLHelper.ResponseRedirect(url); } }
protected void btnCreateDocument_Click(object sender, EventArgs e) { if (radCopy.Checked) { string sourceCulture = copyCulturesElem.Value.ToString(); TreeNode actualSourceNode = DocumentHelper.GetDocument(NodeID, sourceCulture, Tree); TreeNode sourceNode = actualSourceNode.IsLink ? DocumentHelper.GetDocument(Tree.GetOriginalNode(actualSourceNode), Tree) : actualSourceNode; if (sourceNode != null) { if (chkSaveBeforeEditing.Checked && (node != null)) { // Create the version first TreeNode newCulture = TreeNode.New(node.ClassName); DocumentHelper.CopyNodeData(sourceNode, newCulture, new CopyNodeDataSettings(true, null)); NewCultureDocumentSettings settings = new NewCultureDocumentSettings { Node = newCulture, CultureCode = RequiredCulture, CopyAttachments = true, CopyCategories = true }; DocumentHelper.InsertNewCultureVersion(settings); // Refresh page if (RequiresDialog) { string url = URLHelper.ResolveUrl(DocumentURLProvider.GetUrl(newCulture.NodeAliasPath) + "?" + URLHelper.LanguageParameterName + "=" + RequiredCulture); ScriptHelper.RegisterStartupScript(this, typeof(string), "NewCultureRefreshAction", ScriptHelper.GetScript(" wopener.location = " + ScriptHelper.GetString(url) + "; CloseDialog();")); } else { ViewModeEnum mode = ViewModeEnum.Edit; if (!TreePathUtils.IsMenuItemType(node.NodeClassName) && (CMSContext.ViewMode != ViewModeEnum.EditLive)) { mode = ViewModeEnum.EditForm; } ScriptHelper.RegisterStartupScript(this, typeof(string), "NewCultureRefreshAction", ScriptHelper.GetScript("if (FramesRefresh) { FramesRefresh(" + node.NodeID + ", '" + mode + "'); }")); } } else { var url = GetEditUrl(node); url = URLHelper.AddParameterToUrl(url, "sourcedocumentid", sourceNode.DocumentID.ToString()); // Provide information about actual node if ((actualSourceNode != null) && actualSourceNode.IsLink) { url = URLHelper.AddParameterToUrl(url, "sourcenodeid", actualSourceNode.NodeID.ToString()); } Response.Redirect(url); } } else { ShowError(GetString("transman.notallowedcreate")); } } else { var url = GetEditUrl(node); Response.Redirect(url); } }