Esempio n. 1
0
    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);
        }
    }