private void Process_DeleteContent() { string strCallBackPage = ""; long m_intId = -1; Ektron.Cms.Content.EkContent m_refContent; StyleHelper m_refStyle = new StyleHelper(); m_intId = Convert.ToInt64(Request.QueryString["delete_id"].ToString()); try { m_refContent = m_refContentApi.EkContentRef; m_intFolderId = Convert.ToInt64(Request.QueryString["folder_id"].ToString()); Ektron.Cms.Common.EkEnumeration.CMSContentSubtype subtype = m_refContent.GetContentSubType(m_intId); if (subtype == Ektron.Cms.Common.EkEnumeration.CMSContentSubtype.PageBuilderMasterData) { Ektron.Cms.PageBuilder.TemplateModel tm = new Ektron.Cms.PageBuilder.TemplateModel(); TemplateData td = tm.FindByMasterLayoutID(m_intId); if ((td != null) && td.Id > 0) { long[] folders = m_refContent.GetTemplateDefaultFolderUsage(td.Id); Collection contentBlockInfo = m_refContent.GetTemplateContentBlockUsage(td.Id); if (folders.Length > 0 || contentBlockInfo.Count > 0) { StringBuilder message = new StringBuilder(); message.Append("This master layout cannot be deleted until it is unassigned from the following folders: "); if (folders.Length > 0) { for (int i = 0; i <= folders.Length - 1; i++) { message.Append(m_refContent.GetFolderById(folders[i]).NameWithPath + ", "); } } message.Append("and the following layouts: "); if (contentBlockInfo.Count > 0) { foreach (Collection col in contentBlockInfo) { ContentData content_data = m_refContentApi.EkContentRef.GetContentById(Convert.ToInt64(col["content_id"]), 0); string folderpath = (string)(m_refContent.GetFolderById(content_data.FolderId).NameWithPath); message.Append(folderpath + content_data.Title + ": (id=" + content_data.Id + ", lang=" + content_data.LanguageId + "), "); } } throw (new Exception(message.ToString())); } } } m_refContent.SubmitForDeletev2_0(m_intId, m_intFolderId); if (Request.QueryString["page"] == "webpage") { m_strReloadJS = "<script language=\"Javascript\">"; m_strReloadJS += "top.opener.location.reload(true);"; m_strReloadJS += "top.close();"; m_strReloadJS += "</script>"; Page.ClientScript.RegisterStartupScript(this.GetType(), "SetAction", m_strReloadJS); } else { strCallBackPage = m_refStyle.getCallBackupPage((string)("content.aspx?LangType=" + ContentLanguage + "&action=ViewContentByCategory&id=" + m_intFolderId)); Response.Redirect(strCallBackPage, false); } } catch (Exception ex) { Response.Redirect((string)("reterror.aspx?info=" + EkFunctions.UrlEncode(ex.Message)), false); } }
private void DrawContentTemplatesTable() { TemplateData[] active_templates; active_templates = _ContentApi.GetEnabledTemplatesByFolder(_FolderData.Id); TemplateData[] template_data; template_data = _ContentApi.GetAllTemplates("TemplateFileName"); Ektron.Cms.PageBuilder.TemplateModel tmodel = new Ektron.Cms.PageBuilder.TemplateModel(); for (int i = 0; i <= template_data.Length - 1; i++) { if (template_data[i].SubType == EkEnumeration.TemplateSubType.MasterLayout) { template_data[i] = tmodel.FindByID(template_data[i].Id); } } int k = 0; int row_id = 0; Collection addNew = new Collection(); bool isInheriting = IsInheritingMultiConfig(); //If (Not foundDefault) Then // isInheriting = False //End If StringBuilder str = new StringBuilder(); str.Append(DrawContentTemplatesBreaker(isInheriting)); str.Append("<div class=\"ektronTopSpace\"></div>"); str.Append("<div>"); str.Append(DrawContentTemplatesHeader()); //if (_FolderData.Id == 0) //{ // isInheriting = false; //} Collection ActiveTemplateIdList = new Collection(); for (k = 0; k <= active_templates.Length - 1; k++) { if (!ActiveTemplateIdList.Contains(Convert.ToString(active_templates[k].Id))) { ActiveTemplateIdList.Add(active_templates[k].Id, Convert.ToString(active_templates[k].Id), null, null); } } if (!ActiveTemplateIdList.Contains(Convert.ToString(_FolderData.TemplateId))) { ActiveTemplateIdList.Add(_FolderData.TemplateId, Convert.ToString(_FolderData.TemplateId), null, null); } for (k = 0; k <= template_data.Length - 1; k++) { if (ActiveTemplateIdList.Contains(Convert.ToString(template_data[k].Id))) { string typestring = ""; if (template_data[k].SubType == EkEnumeration.TemplateSubType.Wireframes) { typestring = " (" + MessageHelper.GetMessage("lbl pagebuilder wireframe template") + ")"; } else if (template_data[k].SubType == EkEnumeration.TemplateSubType.MasterLayout) { typestring = " (" + MessageHelper.GetMessage("lbl pagebuilder master layouts") + ")"; } str.Append(DrawContentTemplatesEntry(row_id, template_data[k].FileName, typestring, template_data[k].Id, System.Convert.ToBoolean(!isInheriting), template_data[k])); row_id++; } else { Collection cRow = new Collection(); string type; if (template_data[k].SubType == EkEnumeration.TemplateSubType.Wireframes) { type = " (" + MessageHelper.GetMessage("lbl pagebuilder wireframe template") + ")"; } else if (template_data[k].SubType == EkEnumeration.TemplateSubType.MasterLayout) { type = " (" + MessageHelper.GetMessage("lbl pagebuilder master layouts") + ")"; } else { type = ""; } cRow.Add(type, "template_type", null, null); cRow.Add(template_data[k].FileName, "template_name", null, null); cRow.Add(template_data[k].Id, "template_id", null, null); string url = ""; if (template_data[k].SubType == EkEnumeration.TemplateSubType.MasterLayout) { url = _ContentApi.EkContentRef.GetContentQlink(template_data[k].MasterLayoutID, _ContentApi.GetFolderIdForContentId(template_data[k].MasterLayoutID)); } cRow.Add(url, "url", null, null); addNew.Add(cRow, null, null, null); } } str.Append(DrawContentTemplatesFooter()); str.Append("</div>"); str.Append("<div class=\"ektronTopSpace\"></div>"); str.Append("<table><tbody>"); str.Append("<tr>"); str.Append("<td>"); str.Append("<select name=\"addTemplate\" id=\"addTemplate\" disabled>"); str.Append("<option value=\"0\">" + MessageHelper.GetMessage("generic select template") + "</option>"); foreach (Collection row in addNew) { str.Append("<option value=\"" + row["template_id"] + "\""); if (!string.IsNullOrEmpty(Convert.ToString(row["url"]))) { str.Append(" url=\"" + row["url"] + "\""); } str.Append(">" + row["template_name"] + row["template_type"] + "</option>"); } str.Append("</select>"); str.Append("</td>"); str.Append("<td> </td>"); str.Append("<td>"); str.Append("<a href=\"#\" onclick=\"PreviewTemplate(\'" + _ContentApi.SitePath + "\', 800,600);return false;\"><img src=\"" + _AppPath + "images/UI/Icons/preview.png" + "\" alt=\""+ MessageHelper.GetMessage("lbl preview template") + "\" title=\"" + MessageHelper.GetMessage("lbl preview template") + "\" /></a>"); str.Append("</td>"); str.Append("<td> </td>"); str.Append("<td>"); str.Append("<a href=\"javascript:ActivateTemplate(\'" + this._ContentApi.SitePath + "\')\"><img src=\"" + _AppPath + "images/UI/icons/add.png\" alt=\"" + MessageHelper.GetMessage("add title") + "\" title=\"" + MessageHelper.GetMessage("add title") + "\" /></a>"); str.Append("</td>"); str.Append("</tr>"); str.Append("</tbody></table>"); if (row_id % 2 == 0) { str.Append("<input type=\"hidden\" name=\"tisEven\" id=\"tisEven\" value=\"1\" />"); } else { str.Append("<input type=\"hidden\" name=\"tisEven\" id=\"tisEven\" value=\"0\" />"); } str.Append("<div class=\"ektronTopSpace\"></div>"); str.Append("<a href=\"javascript:OpenAddDialog()\" class=\"button buttonInlineBlock greenHover buttonAdd\">" + MessageHelper.GetMessage("lbl add new template") + "</a>"); //str.Append("<a href=""javascript:LoadChildPage()"" class=""button buttonInlineBlock greenHover buttonAdd"">" & MessageHelper.GetMessage("lbl add new template") & "</a>") litBlogTemplate.Text = str.ToString(); template_list.Text = str.ToString(); }
private void DeleteTemplate() { long template_id = System.Convert.ToInt64(Request.QueryString["id"]); Ektron.Cms.PageBuilder.WireframeModel wireframeModel = new Ektron.Cms.PageBuilder.WireframeModel(); Ektron.Cms.PageBuilder.WireframeData wireframe = wireframeModel.FindByTemplateID(template_id); SetTitleBarToMessage("lbl delete template"); AddBackButton("template_config.aspx?view=list"); AddHelpButton("template_delete"); long[] folders = m_refContentApi.EkContentRef.GetTemplateDefaultFolderUsage(template_id); Collection contentBlockInfo = m_refContentApi.EkContentRef.GetTemplateContentBlockUsage(template_id); StringBuilder str = new StringBuilder(); str.Append("<div class=\"ektronPageContainer\">"); if (folders.Length > 0) { str.Append(m_refMsg.GetMessage("lbl folders with") + " " + "\'<i>" + m_refContentApi.EkContentRef.GetTemplateNameByID(template_id) + "</i>\'" + " " + m_refMsg.GetMessage("lbl as their default template") + ":"); str.Append("<div class=\"ektronTopSpace\"></div>"); str.Append("<table width=\"100%\" class=\"ektronGrid ektronBorder\">"); str.Append("<tbody>"); str.Append("<tr class=\"title-header\">"); str.Append("<th>Folder Path</th>"); str.Append("</tr>"); int i = 0; for (i = 0; i <= folders.Length - 1; i++) { str.Append("<tr>"); str.Append("<td>" + m_refContentApi.GetFolderById(folders[i]).NameWithPath + "</td>"); str.Append("</tr>"); } str.Append("</tbody>"); str.Append("</table>"); str.Append("<div class=\"ektronTopSpace\"></div>"); str.Append(m_refMsg.GetMessage("alert msg set folders") + " " + "\'<i>" + m_refContentApi.EkContentRef.GetTemplateNameByID(template_id) + "</i>\'."); } else { if (contentBlockInfo.Count == 0 || !(Request.Form["deleteTemplate"] == null)) { bool messageadded = false; if (wireframe != null) { if (wireframe.Template.SubType == Ektron.Cms.Common.EkEnumeration.TemplateSubType.MasterLayout) { //delete the layout as well Ektron.Cms.PageBuilder.TemplateModel templmodel = new Ektron.Cms.PageBuilder.TemplateModel(); string status = string.Empty; Ektron.Cms.SiteAPI siteApi = new Ektron.Cms.SiteAPI(); Ektron.Cms.LanguageData[] langData = siteApi.GetAllActiveLanguages(); int j = 0; for (j = 0; j <= langData.Length - 1; j++) { long contType = this.ContentAPIRef.EkContentRef.GetContentType(wireframe.Template.MasterLayoutID, langData[j].Id); if (contType != 0) { int tempLang = System.Convert.ToInt32(ContentAPIRef.ContentLanguage); ContentAPIRef.ContentLanguage = langData[j].Id; status = (string)(this.ContentAPIRef.EkContentRef.GetContentStatev2_0(wireframe.Template.MasterLayoutID)["ContentStatus"]); if (status == "O" || status == "S") { Collection permissions = ContentAPIRef.EkContentRef.CanIv2_0(wireframe.Template.MasterLayoutID, "content"); if (permissions.Contains("CanIApprove") && System.Convert.ToBoolean(permissions["CanIApprove"])) { ContentAPIRef.EkContentRef.TakeOwnership(wireframe.Template.MasterLayoutID); } } if (status == "S") { ContentAPIRef.EkContentRef.CheckContentOutv2_0(wireframe.Template.MasterLayoutID); } status = (string)(this.ContentAPIRef.EkContentRef.GetContentStatev2_0(wireframe.Template.MasterLayoutID)["ContentStatus"]); if (status == "O") { ContentAPIRef.EkContentRef.CheckIn(wireframe.Template.MasterLayoutID, ""); } Ektron.Cms.Content.Behaviors.DeleteContentBehavior deletebehavior = new Ektron.Cms.Content.Behaviors.DeleteContentBehavior(ContentAPIRef.RequestInformationRef); deletebehavior.Delete(wireframe.Template.MasterLayoutID, null); ContentAPIRef.ContentLanguage = tempLang; //if content exists and status is now M then show tell user that layout has been marked for delete if (!messageadded) { Collection cont = ContentAPIRef.EkContentRef.GetContentByIDv2_0(wireframe.Template.MasterLayoutID); if (cont.Contains("ContentStatus")) { if ((string)cont["ContentStatus"] == "M") { str.Append("Template <i>" + wireframe.Template.FileName + "</i> is a Master Layout and has been marked for delete. When an approver approves this delete it will be removed from the templates list."); messageadded = true; } } } } } } else { wireframeModel.Remove(wireframe.ID); Response.Redirect("template_config.aspx", false); } } try { m_refContentApi.EkContentRef.PurgeTemplate(template_id); } catch (Exception ex) { string _error = ex.Message; } if (!messageadded) { Response.Redirect("template_config.aspx", false); } } else { LocalizationAPI objLocalizationApi = new LocalizationAPI(); str.Append(m_refMsg.GetMessage("lbl content with") + " " + "\'<i>" + m_refContentApi.EkContentRef.GetTemplateNameByID(template_id) + "</i>\'" + " " + m_refMsg.GetMessage("lbl as a template") + ":"); str.Append("<div class=\"ektronTopSpace\"></div>"); str.Append("<table width=\"100%\" class=\"ektronGrid ektronBorder\">"); str.Append("<tbody>"); str.Append("<tr class=\"title-header\">"); str.Append("<th width=\"70%\" align=\"center\">Title</th>"); str.Append("<th width=\"15%\" align=\"center\">ID</th>"); str.Append("<th width=\"15%\" align=\"center\">Language</th>"); str.Append("</tr>"); int i = 0; foreach (Collection col in contentBlockInfo) { str.Append("<tr>"); m_refContentApi.ContentLanguage = Convert.ToInt32(col["language_id"]); ContentData content_data = m_refContentApi.EkContentRef.GetContentById(Convert.ToInt64(col["content_id"]), Ektron.Cms.Content.EkContent.ContentResultType.Published); str.Append("<td>" + content_data.Title + "</td>"); str.Append("<td align=\"center\">" + content_data.Id + "</td>"); str.Append("<td align=\"center\"><img src=\"" + objLocalizationApi.GetFlagUrlByLanguageID(content_data.LanguageId) + "\" /></td>"); str.Append("</tr>"); i++; } str.Append("</tbody>"); str.Append("</table>"); if (wireframe == null || wireframe.Template.SubType != Ektron.Cms.Common.EkEnumeration.TemplateSubType.MasterLayout) { str.Append("<div class=\"ektronTopSpace\"></div>"); str.Append(m_refMsg.GetMessage("alert msg del template")); str.Append(" <input type=\"submit\" id=\"deleteTemplate\" name=\"deleteTemplate\" value=\"Delete\" /> "); str.Append("<input type=\"button\" id=\"cancelDelete\" name=\"cancelDelete\" value=\"Cancel\" onclick=\"window.location.replace(\'template_config.aspx\')\" />"); } else { str.Append("<div class=\"ektronTopSpace\"></div>"); str.Append(m_refMsg.GetMessage("alert msg set layout") + " " + "\'<i>" + wireframe.Template.FileName + "</i>\'."); } } } str.Append("</div>"); MainBody.Text = str.ToString(); }
private void EditSelectedTemplate() { StringBuilder str = new StringBuilder(); bool bShowTemplateUI = false; int iContType; if (Request.QueryString["ContType"] == null) { iContType = Ektron.Cms.Common.EkConstants.CMSContentType_Content; } else { iContType = Convert.ToInt32(Request.QueryString["ContType"]); } if (m_strType == "add") { if (iContType == Ektron.Cms.Common.EkConstants.CMSContentType_Content || iContType == Ektron.Cms.Common.EkConstants.CMSContentType_Forms || iContType == EkConstants.CMSContentType_Media || iContType == EkConstants.CMSContentType_Archive_Content || iContType == EkConstants.CMSContentType_Archive_Forms || iContType == EkConstants.CMSContentType_Archive_Media) { bShowTemplateUI = true; } } else { if (content_edit_data != null) { iContType = content_edit_data.Type; if (iContType == Ektron.Cms.Common.EkConstants.CMSContentType_Content || iContType == Ektron.Cms.Common.EkConstants.CMSContentType_Forms || iContType == EkConstants.CMSContentType_Media || iContType == EkConstants.CMSContentType_Archive_Content || iContType == EkConstants.CMSContentType_Archive_Forms || iContType == EkConstants.CMSContentType_Archive_Media) { bShowTemplateUI = true; } } } if (!bShowTemplateUI) { str.Append( m_refMsg.GetMessage("Generic Not Applicable")); } else { if ((m_strType == "add" && (content_data != null) && (content_data.SubType == Ektron.Cms.Common.EkEnumeration.CMSContentSubtype.PageBuilderData || content_data.SubType == Ektron.Cms.Common.EkEnumeration.CMSContentSubtype.PageBuilderMasterData)) || ((content_edit_data != null) && (content_edit_data.SubType == Ektron.Cms.Common.EkEnumeration.CMSContentSubtype.PageBuilderData || content_edit_data.SubType == Ektron.Cms.Common.EkEnumeration.CMSContentSubtype.PageBuilderMasterData))) { //show available wireframes Ektron.Cms.PageBuilder.WireframeModel wfm = new Ektron.Cms.PageBuilder.WireframeModel(); Ektron.Cms.PageBuilder.WireframeData[] active_template_list = wfm.FindByFolderID(folder_data.Id); long selected_templateid = this.m_refContApi.GetSelectedTemplateByContent(m_refContentId, m_refContApi.RequestInformationRef.ContentLanguage); if (selected_templateid == 0) { //check if this is a translation, if so, get the one from the original language if (!string.IsNullOrEmpty(Request.QueryString["translate"]) && !string.IsNullOrEmpty(Request.QueryString["con_lang_id"])) { int originalLang = Int32.Parse(Request.QueryString["con_lang_id"]); selected_templateid = this.m_refContApi.GetSelectedTemplateByContent(m_refContentId, originalLang); } //check if default language has one if (selected_templateid == 0 && m_refContApi.RequestInformationRef.ContentLanguage != m_refContApi.RequestInformationRef.DefaultContentLanguage) { selected_templateid = this.m_refContApi.GetSelectedTemplateByContent(m_refContentId, m_refContApi.RequestInformationRef.DefaultContentLanguage); } if (selected_templateid == 0)//just use the default { selected_templateid = folder_data.TemplateId; } } if (active_template_list.Length < 1 && selected_templateid == 0) { phTemplates.Visible = false; EditTemplateHtml.Visible = false; } str.Append("<table class=\"ektronForm\">"); str.Append("<tr>"); str.Append("<td class=\"label\">"); str.Append(m_refMsg.GetMessage("template label") + ":"); str.Append("</td>"); str.Append("<td class=\"value\">"); str.Append("<select id=\"templateSelect\" name=\"templateSelect\">"); foreach (Ektron.Cms.PageBuilder.WireframeData wireframe in active_template_list) { if (wireframe.Template.Id == selected_templateid) { str.Append("<option value=\"" + wireframe.Template.Id + "\" selected>" + wireframe.Path + "</option>"); } else { str.Append("<option value=\"" + wireframe.Template.Id + "\">" + wireframe.Path + "</option>"); } } if (active_template_list.Length == 0) { Ektron.Cms.PageBuilder.TemplateModel templModel = new Ektron.Cms.PageBuilder.TemplateModel(); TemplateData selectedTemplate = templModel.FindByID(selected_templateid); string selectedTemplateName = (selectedTemplate != null) ? selectedTemplate.TemplateName : ""; str.Append("<option value=\"" + selected_templateid + "\" selected>" + selectedTemplateName + "</option>"); } str.Append("</select>"); str.Append("</td>"); str.Append("</tr>"); str.Append("</table>"); if (content_edit_data != null) { if (content_edit_data.LockedContentLink) { str.AppendLine("<br/>"); str.AppendLine("<label>Quicklink Locked:</label><input type=\"checkbox\" onclick=\"DisableTemplateSelect(this.checked)\" name=\"chkLockedContentLink\" id=\"chkLockedContentLink\"" + (content_edit_data.LockedContentLink ? "checked=\"true\"" : "") + "\"/>"); str.AppendLine("<br/>"); str.AppendLine("<label>Quicklink:</label> \"" + content_edit_data.Quicklink + "\""); str.AppendLine("<script language=\"Javascript\"> DisableTemplateSelect(true) </script>"); } else { str.AppendLine("<input type=\"hidden\" name=\"chkLockedContentLink\" id=\"chkLockedContentLink\" value=\"false\" />"); } } else { str.AppendLine("<input type=\"hidden\" name=\"chkLockedContentLink\" id=\"chkLockedContentLink\" value=\"false\" />"); } } else { TemplateData[] active_template_list = m_refContApi.GetEnabledTemplatesByFolder(folder_data.Id); if (active_template_list.Length < 1) { phTemplates.Visible = false; EditTemplateHtml.Visible = false; } long selected_folder = this.m_refContApi.GetSelectedTemplateByContent(m_refContentId, m_refContApi.RequestInformationRef.ContentLanguage); if (selected_folder == 0) { selected_folder = folder_data.TemplateId; } str.Append("<table class=\"ektronForm\">"); str.Append("<tr>"); str.Append("<td class=\"label\">"); str.Append(m_refMsg.GetMessage("template label") + ":"); str.Append("</td>"); str.Append("<td class=\"value\">"); str.Append("<select id=\"templateSelect\" name=\"templateSelect\">"); foreach (TemplateData template in active_template_list) { if (template.SubType != Ektron.Cms.Common.EkEnumeration.TemplateSubType.Wireframes) { if (template.Id == selected_folder) { str.Append("<option value=\"" + template.Id + "\" selected>" + template.FileName + "</option>"); } else { str.Append("<option value=\"" + template.Id + "\">" + template.FileName + "</option>"); } } } if (active_template_list.Length == 0) { str.Append("<option value=\"" + folder_data.TemplateId + "\">" + folder_data.TemplateFileName + "</option>"); } str.Append("</select>"); str.Append("</td>"); str.Append("</tr>"); str.Append("</table>"); if (content_edit_data != null) { if (content_edit_data.LockedContentLink) { str.AppendLine("<br/>"); str.AppendLine("<label>Quicklink Locked:</label><input type=\"checkbox\" onclick=\"DisableTemplateSelect(this.checked)\" name=\"chkLockedContentLink\" id=\"chkLockedContentLink\"" + (content_edit_data.LockedContentLink ? "checked=\"true\"" : "") + "\"/>"); str.AppendLine("<br/>"); str.AppendLine("<label>Quicklink:</label> \"" + content_edit_data.Quicklink + "\""); str.AppendLine("<script language=\"Javascript\"> DisableTemplateSelect(true) </script>"); } else { str.AppendLine("<input type=\"hidden\" name=\"chkLockedContentLink\" id=\"chkLockedContentLink\" value=\"false\" />"); } } else { str.AppendLine("<input type=\"hidden\" name=\"chkLockedContentLink\" id=\"chkLockedContentLink\" value=\"false\" />"); } } } EditTemplateHtml.Text = "<div id=\"dvTemplates\">" + str.ToString() + "</div>"; }