Exemplo n.º 1
0
        /// <summary>
        /// Gets the SEO list for the given internal id.
        /// </summary>
        /// <param name="internalId">The internal id.</param>
        /// <returns>The SEO list</returns>
        public static ListModel GetSEO(string internalId = "")
        {
            if (String.IsNullOrEmpty(internalId))
                internalId = Config.SiteTree;

            ListModel m = new ListModel();
            m.Pages = Sitemap.GetStructure(internalId, false).Flatten()
                .Where(s => !s.IsBlock && s.Published != DateTime.MinValue && (String.IsNullOrEmpty(s.Keywords) || String.IsNullOrEmpty(s.Description))).ToList();
            m.ActiveSite = internalId.ToUpper();

            using (var db = new DataContext())
            {
                m.ActiveSiteId = db.SiteTrees.Where(s => s.InternalId == internalId).Select(s => s.Id).Single();
                m.NewSeqno = db.Pages.Where(p => p.ParentId == null).Count() + 1;
            }

            // Check completion warnings
            foreach (var page in m.Pages)
            {
                m.PageWarnings[page.Id] = 0 + (String.IsNullOrEmpty(page.Keywords) ? 1 : 0) + (String.IsNullOrEmpty(page.Description) ? 1 : 0);
            }
            m.IsSeoList = true;
            return m;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the list model for all available pages.
        /// </summary>
        /// <param name="internalId">Optional internal id of the site tree</param>
        /// <returns>The model.</returns>
        public static ListModel Get(string internalId = "")
        {
            if (String.IsNullOrEmpty(internalId))
                internalId = Config.SiteTree;

            ListModel m = new ListModel();
            m.SiteMap = Sitemap.GetStructure(internalId, false);
            m.Pages = Sitemap.GetStructure(internalId, false).Flatten();
            m.ActiveSite = internalId.ToUpper();
            m.NewSeqno = m.SiteMap.Count + 1;

            using (var db = new DataContext())
            {
                m.ActiveSiteId = db.SiteTrees.Where(s => s.InternalId == internalId).Select(s => s.Id).Single();
            }

            // Check completion warnings
            foreach (var page in m.Pages)
            {
                m.PageWarnings[page.Id] = 0 + (String.IsNullOrEmpty(page.Keywords) ? 1 : 0) + (String.IsNullOrEmpty(page.Description) ? 1 : 0);
            }
            return m;
        }