protected void Page_Load(object sender, EventArgs e) { RegisterResources(); Collection cFolders = null; long subfolderid = -1; long locID = -1; long backID = -1; Collection cRecursive = null; bool rec = false; bool CanCreateContent = false; string AddType = ""; string MenuTitle = ""; string CachedId = ""; bool canTraverse = true; CurrentUserID = AppUI.UserId; AppImgPath = AppUI.AppImgPath; AppPath = AppUI.AppPath; sitePath = AppUI.SitePath; MsgHelper = AppUI.EkMsgRef; if (!string.IsNullOrEmpty(Request.QueryString["LangType"])) { ContentLanguage = Convert.ToInt32(Request.QueryString["LangType"]); AppUI.SetCookieValue("LastValidLanguageID", ContentLanguage.ToString()); } else { if (!string.IsNullOrEmpty(Convert.ToString(AppUI.GetCookieValue("LastValidLanguageID")))) { ContentLanguage = Convert.ToInt32(AppUI.GetCookieValue("LastValidLanguageID")); } } AppUI.ContentLanguage = ContentLanguage; folderId = Convert.ToInt64(Request.QueryString["folderid"]); mpID = Convert.ToInt64(Request.QueryString["parentid"]); maID = Convert.ToInt64(Request.QueryString["ancestorid"]); if (!string.IsNullOrEmpty(Request.QueryString["SelTaxonomyID"])) { selTaxID = Convert.ToInt64(Request.QueryString["SelTaxonomyID"]); } if (CommonApi.GetEcmCookie().HasKeys) { CurrentUserID = Convert.ToInt64(CommonApi.GetEcmCookie()["user_id"]); } else { CurrentUserID = 0; } AddType = Strings.LCase(Request.QueryString["addto"]); if (string.IsNullOrEmpty(AddType)) { AddType = "collection"; } nID = Convert.ToInt64(Request.QueryString["nid"]); subfolderid = Convert.ToInt64(Request.QueryString["subfolderid"]); if ( !string.IsNullOrEmpty(Request.QueryString["cacheidentifier"])) { CachedId = "&cacheidentifier=" + Request.QueryString["cacheidentifier"]; } if (subfolderid > 0) { locID = subfolderid; } else { locID = folderId; } gtObj = AppUI.EkContentRef; SiteObj = AppUI.EkSiteRef; cPerms = SiteObj.GetPermissions(locID, 0, "folder"); canTraverse = Convert.ToBoolean(cPerms["TransverseFolder"]); if (ErrorString != "") { CanCreateContent = false; } else { CanCreateContent = Convert.ToBoolean(cPerms["Add"]); } if (AddType == "menu" || AddType == "submenu") { cRecursive = gtObj.GetMenuByID(nID, 0,false); if (string.IsNullOrEmpty(ErrorString)) { if (cRecursive.Count > 0) { MenuTitle = cRecursive["MenuTitle"].ToString(); rec = Convert.ToBoolean(cRecursive["Recursive"]); } } } else { cRecursive = gtObj.GetEcmCollectionByID(nID, false, false, ref ErrorString, true, false, true); if (string.IsNullOrEmpty(ErrorString)) { if (cRecursive.Count > 0) { CollectionTitle = cRecursive["CollectionTitle"].ToString(); rec = Convert.ToBoolean(cRecursive["Recursive"]); } } else { pnlError.Visible = true; pnlPage.Visible = false; } } if (!canTraverse) { rec = false; } if (rec && ErrorString == "") { cTmp = new Collection(); cTmp.Add(Convert.ToInt64(locID), "ParentID",null,null); cTmp.Add("name", "OrderBy",null,null); cFolders = gtObj.GetAllViewableChildFoldersv2_0(cTmp); } if (ErrorString == "") { gtNavs = gtObj.GetFolderInfov2_0(locID); if(gtNavs.Count > 0) { FolderName = gtNavs["FolderName"].ToString(); backID = Convert.ToInt64(gtNavs["ParentID"]); } } StringBuilder sb = new StringBuilder(); //ToolBar sb.Append("<table width=\"100%\">").Append(Environment.NewLine); if(rec) { if(locID != 0) { sb.Append("<tr>").Append(Environment.NewLine); sb.Append(" <td>").Append(Environment.NewLine); sb.Append(" <a href=\"collectiontree.aspx?nId=").Append(nID).Append("&folderid=").Append(folderId).Append("&subfolderid=").Append(backID).Append("&addto=").Append(AddType).Append("&parentid=").Append(mpID).Append("&ancestorid=").Append(maID).Append("&SelTaxonomyID=").Append(selTaxID).Append("\" ").Append(Environment.NewLine); sb.Append(" title=\"").Append(MsgHelper.GetMessage("alt: generic previous dir text")).Append("\" > ").Append(Environment.NewLine); sb.Append(" <img src=\"").Append(AppPath + "images/UI/Icons/folderUp.png").Append("\" title=\"").Append(MsgHelper.GetMessage("alt: generic previous dir text")).Append("\" alt=\"").Append(MsgHelper.GetMessage("alt: generic previous dir text")).Append("\" align=\"absbottom\"/>..").Append(Environment.NewLine); sb.Append(" </a>").Append(Environment.NewLine); sb.Append(" </td>").Append(Environment.NewLine); sb.Append(" <td> </td>").Append(Environment.NewLine); sb.Append(" <td> </td>").Append(Environment.NewLine); sb.Append("</tr>").Append(Environment.NewLine); } foreach( Collection folder in cFolders) { if(Convert.ToInt32(folder["FolderType"]) <= 1) { sb.Append("<tr>").Append(Environment.NewLine); sb.Append(" <td nowrap=\"true\">").Append(Environment.NewLine); sb.Append(" <a href=\"collectiontree.aspx?nId=").Append(nID).Append("&folderid=").Append(folderId).Append("&subfolderid=").Append(folder["ID"]).Append("&addto=").Append(AddType).Append("&parentid=").Append(mpID).Append("&ancestorid=").Append(maID).Append("&SelTaxonomyID=").Append(selTaxID).Append("\" ").Append(Environment.NewLine); sb.Append(" title=\"").Append(MsgHelper.GetMessage("alt: generic view folder content text")).Append("\">").Append(Environment.NewLine); sb.Append(" <img src=\"").Append(AppImgPath).Append(Convert.ToInt32(folder["FolderType"]) == 1 ? "folders/blogfolderopen.gif": "folderclosed_1.gif").Append("\" title=\"").Append(MsgHelper.GetMessage("alt: generic view folder content text")).Append("\" alt=\"").Append(MsgHelper.GetMessage("alt: generic view folder content text")).Append("\" align=\"absbottom\"/>").Append(folder["Name"]).Append(Environment.NewLine); sb.Append(" </a>").Append(Environment.NewLine); sb.Append(" </td>").Append(Environment.NewLine); sb.Append(" <td> </td>").Append(Environment.NewLine); sb.Append(" <td> </td>").Append(Environment.NewLine); sb.Append("</tr>").Append(Environment.NewLine); } } } sb.Append("<tr>").Append(Environment.NewLine); sb.Append(" <td align=\"center\" colspan=\"3\">").Append(Environment.NewLine); sb.Append(" <hr/>").Append(Environment.NewLine); sb.Append(" </td>").Append(Environment.NewLine); sb.Append("</tr>").Append(Environment.NewLine); sb.Append("<tr>").Append(Environment.NewLine); sb.Append(" <td align=\"center\" colspan=\"3\">").Append(Environment.NewLine); sb.Append(" First Pick the folder").Append(Environment.NewLine); sb.Append(" </td>").Append(Environment.NewLine); sb.Append("</tr>").Append(Environment.NewLine); sb.Append("<tr>").Append(Environment.NewLine); sb.Append(" <td align=\"center\" colspan=\"3\">").Append(Environment.NewLine); if(AddType == "submenu") sb.Append(" <input name=\"next\" type=\"button\" value=\"Next...\" onclick=\"javascript:location.href='collections.aspx?action=AddSubMenu&LangType=").Append(ContentLanguage).Append("&folderid=").Append(locID).Append("&nId=").Append(nID).Append("&parentid=").Append(mpID).Append("&ancestorid=").Append(maID).Append("&SelTaxonomyID=").Append(selTaxID).Append("'\" />").Append(Environment.NewLine); else sb.Append(" <input name=\"next\" type=\"button\" value=\"Next...\" onclick=\"javascript:location.href='editarea.aspx?LangType=").Append(ContentLanguage).Append("&type=add&id=").Append(locID).Append("&SelTaxonomyID=").Append(selTaxID).Append("&mycollection=").Append(nID).Append("&addto=").Append(AddType).Append(CachedId).Append("'\" />").Append(Environment.NewLine); sb.Append(" </td>").Append(Environment.NewLine); sb.Append("</tr>").Append(Environment.NewLine); sb.Append("</table>").Append(Environment.NewLine); ltrPage.Text = sb.ToString(); }
private void FillContentFolderInfo() { try { bool bCheckout = false; NextPage.Attributes.Add("onclick", "return resetPostback()"); lnkBtnPreviousPage.Attributes.Add("onclick", "return resetPostback()"); FirstPage.Attributes.Add("onclick", "return resetPostback()"); LastPage.Attributes.Add("onclick", "return resetPostback()"); m_refMsg = m_refContentApi.EkMsgRef; //Put user code to initialize the page here AppImgPath = m_refContentApi.AppImgPath; AppName = m_refContentApi.AppName; ContentIcon = "<img src=\"" + AppPath + "images/UI/Icons/contentHtml.png\" alt=\"Content\" />"; //-HC- WebEventIcon = "<img src=\"" + AppPath + "images/UI/Icons/calendarViewDay.png\" alt=\"WebEvent\" />"; formsIcon = "<img src=\"" + AppPath + "images/UI/Icons/contentForm.png\" alt=\"Form\" />"; //-HC- pageIcon = "<img src=\"" + AppPath + "images/UI/Icons/layout.png\" alt=\"Page\" />"; //-HC- //intQString = Request.QueryString AddType = Strings.LCase(Request.QueryString["addto"]); nId = Convert.ToInt64(Request.QueryString["nid"]); subfolderid = Convert.ToInt64(Request.QueryString["subfolderid"]); FolderId = Convert.ToInt64(Request.QueryString["folderid"]); bool showQDContentOnly = System.Convert.ToBoolean(Request.QueryString["qdo"] == "1"); m_refContent = m_refContentApi.EkContentRef; if (!(Request.QueryString["subfolderid"] == null)) { locID = subfolderid; } else { locID = FolderId; } gtNavs = m_refContent.GetFolderInfoWithPath(locID); if (!Ektron.Cms.Common.EkFunctions.DoesKeyExist(gtNavs, "FolderName")) { // invalid folder, so start at root instead of taking an error locID = 0; gtNavs = m_refContent.GetFolderInfoWithPath(0); } //Set content type if (Request.QueryString[Ektron.Cms.Common.EkConstants.ContentTypeUrlParam] != "") { if (Information.IsNumeric(Request.QueryString[Ektron.Cms.Common.EkConstants.ContentTypeUrlParam])) { g_ContentTypeSelected = System.Convert.ToInt32(Request.QueryString[Ektron.Cms.Common.EkConstants.ContentTypeUrlParam]); m_refContentApi.SetCookieValue(Ektron.Cms.Common.EkConstants.ContentTypeUrlParam, g_ContentTypeSelected.ToString()); } } else if (Request.Cookies["ecm"][Ektron.Cms.Common.EkConstants.ContentTypeUrlParam] != "") { if (Information.IsNumeric(Request.Cookies["ecm"][Ektron.Cms.Common.EkConstants.ContentTypeUrlParam])) { g_ContentTypeSelected = System.Convert.ToInt32(Request.Cookies["ecm"][Ektron.Cms.Common.EkConstants.ContentTypeUrlParam]); } } ///end set content type if (AddType == "menu") { if (m_refContentApi.TreeModel == 1) { cRecursive = m_refContent.GetMenuByID(nId, 0, false); } else { cRecursive = m_refContent.GetMenuByID(nId, 0, false); } if (cRecursive.Count > 0) { MenuTitle = cRecursive["MenuTitle"].ToString(); rec = Convert.ToBoolean(cRecursive["Recursive"]); } } else { if (Request.QueryString["checkout"] != null) { bCheckout = System.Convert.ToBoolean(Request.QueryString["checkout"].ToString()); } if (bCheckout) { cRecursive = m_refContent.GetEcmStageCollectionByID(nId, false, false, ref ErrorString, true, false, true); } else { cRecursive = m_refContent.GetEcmCollectionByID(nId, false, false, ref ErrorString, true, false, true); } if (cRecursive.Count > 0) { CollectionTitle = cRecursive["CollectionTitle"].ToString(); rec = Convert.ToBoolean(cRecursive["Recursive"]); } } perm_data = m_refContentApi.LoadPermissions(locID, "folder", 0); if (!perm_data.CanTraverseFolders) { rec = false; } if (rec) { cTmp = new Collection(); cTmp.Add(locID, "ParentID", null, null); cTmp.Add("name", "OrderBy", null, null); cFolders = m_refContent.GetAllViewableChildFoldersv2_0(cTmp); } FolderName = gtNavs["FolderName"].ToString(); backId = Convert.ToInt64(gtNavs["ParentID"]); fPath = gtNavs["Path"].ToString(); EkEnumeration.FolderType folderType = (EkEnumeration.FolderType)Enum.Parse(typeof(EkEnumeration.FolderType), gtNavs["FolderType"].ToString()); cTmp = new Collection(); cTmp.Add("name", "OrderBy", null, null); cTmp.Add(FolderId, "FolderID", null, null); cTmp.Add(FolderId, "ParentID", null, null); EkEnumeration.CMSContentType ContentTypeSelected = (EkEnumeration.CMSContentType)Enum.Parse(typeof(EkEnumeration.CMSContentType), g_ContentTypeSelected.ToString()); if (AddType == "menu") { cConts = m_refContent.GetAllContentNotInEcmMenu(nId, locID, "title", _currentPageNumber, m_refContentApi.RequestInformationRef.PagingSize, ref TotalPagesNumber, ContentTypeSelected); } else { if (bCheckout || ((Request.QueryString["status"] != null) && Request.QueryString["status"].ToUpper() == "O")) { cConts = m_refContent.GetAllContentNotInEcmCollection(nId, locID, "title", _currentPageNumber, m_refContentApi.RequestInformationRef.PagingSize, ref TotalPagesNumber, ContentTypeSelected, Ektron.Cms.Content.EkContent.ContentResultType.Staged); } else { // Defect#: 49013 // cConts = m_refContent.GetAllContentNotInEcmCollection(nId, CLng(locID), "title", _currentPageNumber, m_refContentApi.RequestInformationRef.PagingSize, TotalPagesNumber, g_ContentTypeSelected) EkEnumeration.CMSContentType myContentType = (EkEnumeration.CMSContentType)Enum.Parse(typeof(EkEnumeration.CMSContentType), g_ContentTypeSelected.ToString()); cConts = GetAllContent(nId, locID, "title", _currentPageNumber, m_refContentApi.RequestInformationRef.PagingSize, ref TotalPagesNumber, myContentType); } } if (showQDContentOnly && (gtNavs["ReplicationMethod"].ToString() != "1") && m_refContentApi.RequestInformationRef.EnableReplication) { // only display QD content, clean out the content list cConts.Clear(); } gtNavs = null; if (TotalPagesNumber <= 1) { TotalPages.Visible = false; CurrentPage.Visible = false; lnkBtnPreviousPage.Visible = false; NextPage.Visible = false; LastPage.Visible = false; FirstPage.Visible = false; PageLabel.Visible = false; OfLabel.Visible = false; } else { TotalPages.Visible = true; CurrentPage.Visible = true; lnkBtnPreviousPage.Visible = true; NextPage.Visible = true; LastPage.Visible = true; FirstPage.Visible = true; PageLabel.Visible = true; OfLabel.Visible = true; TotalPages.Text = (System.Math.Ceiling(Convert.ToDouble(TotalPagesNumber))).ToString(); TotalPages.ToolTip = TotalPages.Text; CurrentPage.Text = _currentPageNumber.ToString(); CurrentPage.ToolTip = CurrentPage.Text; if (_currentPageNumber == 1) { lnkBtnPreviousPage.Enabled = false; if (TotalPagesNumber > 1) { NextPage.Enabled = true; } else { NextPage.Enabled = false; } } else { lnkBtnPreviousPage.Enabled = true; if (_currentPageNumber == TotalPagesNumber) { NextPage.Enabled = false; } else { NextPage.Enabled = true; } } } Ektron.Cms.TemplateData[] templatelist = m_refContentApi.GetEnabledTemplatesByFolder(locID); bool hasNormalTemplate = false; foreach (TemplateData template in templatelist) { if (template.Type == EkEnumeration.TemplateType.Default && template.SubType == EkEnumeration.TemplateSubType.Default) { hasNormalTemplate = true; break; } } CanCreateContent = System.Convert.ToBoolean((perm_data.CanAdd && hasNormalTemplate) && !(folderType == EkEnumeration.FolderType.Catalog || folderType == EkEnumeration.FolderType.Calendar)); asset_data = m_refContent.GetAssetSuperTypes(); if (Ektron.Cms.Common.EkConstants.CMSContentType_Content == g_ContentTypeSelected || Ektron.Cms.Common.EkConstants.CMSContentType_Archive_Content == g_ContentTypeSelected) { lContentType = g_ContentTypeSelected; } else if (Ektron.Cms.Common.EkConstants.ManagedAsset_Min <= g_ContentTypeSelected & g_ContentTypeSelected <= Ektron.Cms.Common.EkConstants.ManagedAsset_Max) { if (DoesAssetSupertypeExist(asset_data, g_ContentTypeSelected)) { lContentType = g_ContentTypeSelected; } } DisplayToolBarAndContent(); } catch (Exception ex) { Utilities.ShowError(ex.Message); } }