Exemplo n.º 1
0
        /// <summary>
        /// get all pages (from rootPageToGatherFrom and below) that implement one or more placeholderTypes.
        /// </summary>
        /// <param name="placeholderType"></param>
        /// <param name="rootPageToGatherFrom"></param>
        /// <param name="gatheringMode"></param>
        /// <returns></returns>
        public static CmsPage[] getAllPagesWithPlaceholders(string[] placeholderTypes, CmsPage rootPageToGatherFrom, PageGatheringMode gatheringMode)
        {
            List <CmsPage> ret = new List <CmsPage>();

            try
            {
                if (gatheringMode == PageGatheringMode.FullRecursion)
                {
                    Dictionary <int, CmsPage> allPages = rootPageToGatherFrom.getLinearizedPages();
                    foreach (CmsPage page in allPages.Values)
                    {
                        foreach (string placeholderType in placeholderTypes)
                        {
                            if (page.hasPlaceholder(placeholderType))
                            {
                                ret.Add(page);
                                break; // only add the page once if it implements more than one placeholder
                            }
                        }
                    } // foreach page
                }
                else if (gatheringMode == PageGatheringMode.ChildPagesOnly)
                {
                    foreach (CmsPage page in rootPageToGatherFrom.ChildPages)
                    {
                        foreach (string placeholderType in placeholderTypes)
                        {
                            if (page.hasPlaceholder(placeholderType))
                            {
                                ret.Add(page);
                                break; // only add the page once if it implements more than one placeholder
                            }
                        } // foreach placeholderType
                    } // foreach page
                }
            }
            catch
            { }
            return(ret.ToArray());
        }
Exemplo n.º 2
0
        /// <summary>
        /// NOTE: returns ALL matching pages in the system, regardless of the user's security level.
        /// </summary>
        /// <param name="placeholderType"></param>
        /// <param name="rootPageToGatherFrom"></param>
        /// <param name="gatheringMode"></param>
        /// <returns></returns>
        public static Dictionary <CmsPage, CmsPlaceholderDefinition[]> getAllPlaceholderDefinitions(string placeholderType, CmsPage rootPageToGatherFrom, PageGatheringMode gatheringMode)
        {
            Dictionary <CmsPage, CmsPlaceholderDefinition[]> ret = new Dictionary <CmsPage, CmsPlaceholderDefinition[]>();

            try
            {
                if (gatheringMode == PageGatheringMode.FullRecursion)
                {
                    Dictionary <int, CmsPage> allPages = rootPageToGatherFrom.getLinearizedPages();
                    foreach (CmsPage page in allPages.Values)
                    {
                        CmsPlaceholderDefinition[] defs = page.getPlaceholderDefinitions(placeholderType);
                        if (defs.Length > 0)
                        {
                            ret.Add(page, defs);
                        }
                    } // foreach page
                }
                else if (gatheringMode == PageGatheringMode.ChildPagesOnly)
                {
                    foreach (CmsPage page in rootPageToGatherFrom.ChildPages)
                    {
                        CmsPlaceholderDefinition[] defs = page.getPlaceholderDefinitions(placeholderType);
                        if (defs.Length > 0)
                        {
                            ret.Add(page, defs);
                        }
                    } // foreach page
                }
            }
            catch
            { }
            return(ret);
        }
Exemplo n.º 3
0
 /// <summary>
 /// get all pages (from rootPageToGatherFrom and below) that implement placeholderType.
 /// </summary>
 /// <param name="placeholderType"></param>
 /// <param name="rootPageToGatherFrom"></param>
 /// <param name="gatheringMode"></param>
 /// <returns></returns>
 public static CmsPage[] getAllPagesWithPlaceholder(string placeholderType, CmsPage rootPageToGatherFrom, PageGatheringMode gatheringMode)
 {
     return(getAllPagesWithPlaceholders(new string[] { placeholderType }, rootPageToGatherFrom, gatheringMode));
 }