Пример #1
0
        /// <summary>
        /// Reads the Content of a Page.
        /// </summary>
        /// <param name="pageInfo">The Page.</param>
        /// <param name="cached">Specifies whether the page has to be cached or not.</param>
        /// <returns>The Page Content.</returns>
        public static PageContent GetPageContent(PageInfo pageInfo, bool cached)
        {
            PageContent result = Cache.GetPageContent(pageInfo);

            if (result == null)
            {
                result = pageInfo.Provider.GetContent(pageInfo);
                if (result != null && !result.IsEmpty())
                {
                    if (cached && !pageInfo.NonCached && !Settings.DisableCache)
                    {
                        Cache.SetPageContent(pageInfo, result);
                    }
                }
            }

            // result should NEVER be null
            if (result == null)
            {
                Log.LogEntry("PageContent could not be retrieved for page " + pageInfo.FullName + " - returning empty", EntryType.Error, Log.SystemUsername);
                result = PageContent.GetEmpty(pageInfo);
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Gets the formatted Page Content, properly handling content caching and the Formatting Pipeline.
        /// </summary>
        /// <param name="page">The Page to get the formatted Content of.</param>
        /// <param name="cached">Specifies whether the formatted content has to be cached or not.</param>
        /// <returns>The formatted content.</returns>
        public static string GetFormattedPageContent(PageInfo page, bool cached)
        {
            var content = Cache.GetFormattedPageContent(page);

            if (content == null)
            {
                PageContent pg = GetPageContent(page, cached);

                var pcc = page.Provider.GetContentCache(page);
                if (pcc != null)
                {
                    content        = pcc.FormattedContent;
                    pg.LinkedPages = pcc.LinkedPages;
                }
                else
                {
                    content        = FormattingPipeline.FormatWithPhase1And2(pg.Content, false, FormattingContext.PageContent, page, out var linkedPages);
                    pg.LinkedPages = linkedPages;

                    if (!pg.IsEmpty() && cached && !page.NonCached && !Settings.DisableCache)
                    {
                        Cache.SetFormattedPageContent(page, content);
                        page.Provider.SetContentCache(page, content, linkedPages);
                    }
                }
            }

            return(FormattingPipeline.FormatWithPhase3(content, FormattingContext.PageContent, page));
        }
Пример #3
0
        /// <summary>
        /// Gets the formatted Page Content, properly handling content caching and the Formatting Pipeline.
        /// </summary>
        /// <param name="page">The Page to get the formatted Content of.</param>
        /// <param name="cached">Specifies whether the formatted content has to be cached or not.</param>
        /// <returns>The formatted content.</returns>
        public static string GetFormattedPageContent(PageInfo page, bool cached)
        {
            string content = Cache.GetFormattedPageContent(page);

            if (content == null)
            {
                PageContent pg = GetPageContent(page, cached);
                string[]    linkedPages;
                content        = FormattingPipeline.FormatWithPhase1And2(pg.Content, false, FormattingContext.PageContent, page, out linkedPages);
                pg.LinkedPages = linkedPages;
                if (!pg.IsEmpty() && cached && !page.NonCached && !Settings.DisableCache)
                {
                    Cache.SetFormattedPageContent(page, content);
                }
            }
            return(FormattingPipeline.FormatWithPhase3(content, FormattingContext.PageContent, page));
        }