예제 #1
0
        public static XDoc BuildXmlSiteMap(PageBE rootPage, string language)
        {
            Dictionary <ulong, PageBE> pagesById = null;

            rootPage = PageBL.PopulateDescendants(rootPage, null, out pagesById, ConfigBL.GetInstanceSettingsValueAs <int>(ConfigBL.MAX_SITEMAP_SIZE_KEY, ConfigBL.MAX_SITEMAP_SIZE));

            PageBE[] allowedPages = PermissionsBL.FilterDisallowed(DekiContext.Current.User, new List <PageBE>(pagesById.Values).ToArray(), false, new Permissions[] { Permissions.BROWSE });
            Dictionary <ulong, PageBE> allowedPagesById = allowedPages.AsHash(e => e.ID);
            Dictionary <ulong, PageBE> addedPagesById   = null;

            if (!string.IsNullOrEmpty(language))
            {
                List <ulong> pagesToRemove = new List <ulong>();
                foreach (KeyValuePair <ulong, PageBE> page in allowedPagesById)
                {
                    if (!string.IsNullOrEmpty(page.Value.Language) && !StringUtil.EqualsInvariantIgnoreCase(page.Value.Language, language))
                    {
                        pagesToRemove.Add(page.Key);
                    }
                }
                foreach (ulong pageId in pagesToRemove)
                {
                    allowedPagesById.Remove(pageId);
                }
            }
            PageBL.AddParentsOfAllowedChildren(rootPage, allowedPagesById, addedPagesById);

            return(BuildXmlSiteMap(rootPage, new XDoc("pages"), allowedPagesById));
        }
예제 #2
0
        /// <summary>
        /// Builds an HTML view of the site (with permissions enforced)
        /// </summary>
        /// <param name="rootPage"></param>
        /// <returns></returns>
        public static XDoc BuildHtmlSiteMap(PageBE rootPage, string language, int depth, bool reverse)
        {
            if (depth <= 0)
            {
                return(XDoc.Empty);
            }
            Dictionary <ulong, PageBE> pagesById = null;

            if (depth == 1)
            {
                rootPage.ChildPages = PageBL.GetChildren(rootPage, true).ToArray();
                pagesById           = rootPage.ChildPages.ToDictionary(p => p.ID, true);
            }
            else
            {
                rootPage = PageBL.PopulateDescendants(rootPage, null, out pagesById, ConfigBL.GetInstanceSettingsValueAs <int>(ConfigBL.MAX_SITEMAP_SIZE_KEY, ConfigBL.MAX_SITEMAP_SIZE));
            }
            PageBE[] filteredPages = null;
            PageBE[] allowedPages  = PermissionsBL.FilterDisallowed(DekiContext.Current.User, new List <PageBE>(pagesById.Values).ToArray(), false, out filteredPages, new Permissions[] { Permissions.BROWSE });
            Dictionary <ulong, PageBE> allowedPagesById  = allowedPages.AsHash(e => e.ID);
            Dictionary <ulong, PageBE> filteredPagesById = filteredPages.AsHash(e => e.ID);

            if (!string.IsNullOrEmpty(language))
            {
                List <ulong> pagesToRemove = new List <ulong>();
                foreach (KeyValuePair <ulong, PageBE> page in allowedPagesById)
                {
                    if (!string.IsNullOrEmpty(page.Value.Language) && !StringUtil.EqualsInvariantIgnoreCase(page.Value.Language, language))
                    {
                        pagesToRemove.Add(page.Key);
                    }
                }
                foreach (ulong pageId in pagesToRemove)
                {
                    allowedPagesById.Remove(pageId);
                }
            }
            Dictionary <ulong, PageBE> addedPagesById = null;

            PageBL.AddParentsOfAllowedChildren(rootPage, allowedPagesById, addedPagesById);

            XDoc result = new XDoc("ul");

            result = BuildHtmlSiteMap(rootPage, result, allowedPagesById, filteredPagesById, depth, reverse);
            return(result);
        }
예제 #3
0
        /// <summary>
        /// Builds a http://sitemaps.org compliant sitemap as used by google (https://www.google.com/webmasters/tools/docs/en/protocol.html)
        /// </summary>
        /// <param name="rootPage"></param>
        /// <returns></returns>
        public static XDoc BuildGoogleSiteMap(PageBE rootPage, string language)
        {
            IList <PageBE> pages = null;
            Dictionary <ulong, IList <ulong> > childrenInfo = null;

            DbUtils.CurrentSession.Pages_GetDescendants(rootPage, null, true, out pages, out childrenInfo, ConfigBL.GetInstanceSettingsValueAs <int>(ConfigBL.MAX_SITEMAP_SIZE_KEY, ConfigBL.MAX_SITEMAP_SIZE));

            PageBE[] allowedPages = PermissionsBL.FilterDisallowed(DekiContext.Current.User, pages, false, new Permissions[] { Permissions.BROWSE });
            Dictionary <ulong, PageBE> allowedPagesById = allowedPages.AsHash(e => e.ID);
            Dictionary <ulong, PageBE> addedPagesById   = null;

            if (!string.IsNullOrEmpty(language))
            {
                List <ulong> pagesToRemove = new List <ulong>();
                foreach (KeyValuePair <ulong, PageBE> page in allowedPagesById)
                {
                    if (!string.IsNullOrEmpty(page.Value.Language) && !StringUtil.EqualsInvariantIgnoreCase(page.Value.Language, language))
                    {
                        pagesToRemove.Add(page.Key);
                    }
                }
                foreach (ulong pageId in pagesToRemove)
                {
                    allowedPagesById.Remove(pageId);
                }
            }
            PageBL.AddParentsOfAllowedChildren(rootPage, allowedPagesById, addedPagesById);

            XDoc x = new XDoc("urlset", "http://www.google.com/schemas/sitemap/0.84");

            foreach (PageBE p in allowedPagesById.Values)
            {
                x.Start("url");
                x.Elem("loc", Utils.AsPublicUiUri(p.Title));
                x.Start("lastmod").Value(p.TimeStamp.ToString("yyyy-MM-dd")).End();
                x.End();
            }

            return(x);
        }
예제 #4
0
 public void ClearConfigCache()
 {
     ConfigBL.ClearConfigCache();
 }
예제 #5
0
 public XDoc GetAsDoc()
 {
     return(ConfigBL.GetInstanceSettingsAsDoc(false));
 }
예제 #6
0
 public T GetValue <T>(string key, T def)
 {
     return(ConfigBL.GetInstanceSettingsValueAs <T>(key, def));
 }
예제 #7
0
 //--- Methods ---
 public string GetValue(string key, string def)
 {
     return(ConfigBL.GetInstanceSettingsValue(key, def));
 }