Пример #1
0
        /// <summary>
        /// Creates a new model.
        /// </summary>
        /// <param name="loadRegionTypes">If the region types should be loaded</param>
        /// <param name="loadTemplates">If the templates should be loaded</param>
        internal PageEditModel(bool loadRegionTypes = true, bool loadTemplates = true)
        {
            Template = new PageTemplate()
            {
                Preview = new HtmlString(
                    "<table class=\"template\">" +
                    "<tr><td></td></tr>" +
                    "</table>"
                    )
            };
            Regions     = new List <RegionTemplate>();
            RegionTypes = new List <dynamic>();

            if (loadRegionTypes)
            {
                ExtensionManager.Current.GetByExtensionType(ExtensionType.Region).OrderBy(e => e.Metadata.Name).Each((i, r) =>
                                                                                                                     RegionTypes.Add(new { Name = ExtensionManager.Current.GetNameByType(r.Value.GetType().FullName), Type = r.Value.GetType().FullName }));
                RegionTypes.Insert(0, new { Name = "", Type = "" });
            }

            if (loadTemplates)
            {
                Templates = PageTemplate.GetFields("pagetemplate_id, pagetemplate_name, pagetemplate_type", "pagetemplate_site_template = 0", new Data.Params()
                {
                    OrderBy = "pagetemplate_name"
                });
            }
        }
Пример #2
0
        /// <summary>
        /// Default constructor, creates a new model.
        /// </summary>
        public ListModel()
        {
            Pages     = new List <Sitemap>();
            Templates = PageTemplate.GetFields("pagetemplate_id, pagetemplate_name, pagetemplate_preview, pagetemplate_description",
                                               "pagetemplate_site_template = 0", new Params()
            {
                OrderBy = "pagetemplate_name ASC"
            });
            AllPages = Sitemap.GetFields("page_id, page_title, page_navigation_title, pagetemplate_name, sitetree_name", "page_draft = 1 AND page_original_id IS NULL AND (page_parent_id IS NULL OR page_parent_id NOT IN (SELECT sitetree_id FROM sitetree))",
                                         new Params()
            {
                OrderBy = "sitetree_name, COALESCE(page_navigation_title, page_title)"
            });

            SitePage          = new Dictionary <Guid, Guid>();
            SiteWarnings      = new Dictionary <Guid, int>();
            TotalSiteWarnings = new Dictionary <Guid, int>();
            PageWarnings      = new Dictionary <Guid, int>();

            using (var db = new DataContext()) {
                SiteTrees = db.SiteTrees.OrderBy(s => s.Name).ToList();

                foreach (var site in SiteTrees)
                {
                    SitePage[site.Id]     = db.Pages.Where(p => p.SiteTreeId == site.Id && p.ParentId == site.Id).Select(p => p.Id).SingleOrDefault();
                    SiteWarnings[site.Id] = 0 + (String.IsNullOrEmpty(site.MetaTitle) ? 1 : 0) + (String.IsNullOrEmpty(site.MetaDescription) ? 1 : 0);

                    TotalSiteWarnings[site.Id] =
                        Page.GetScalar("SELECT COUNT(*) FROM page WHERE page_draft = 1 AND page_sitetree_id = @0 AND page_parent_id != @0 AND page_original_id IS NULL AND page_published IS NOT NULL AND page_keywords IS NULL", site.Id) +
                        Page.GetScalar("SELECT COUNT(*) FROM page WHERE page_draft = 1 AND page_sitetree_id = @0 AND page_parent_id != @0 AND page_original_id IS NULL AND page_published IS NOT NULL AND page_description IS NULL", site.Id);
                }
            }
        }
Пример #3
0
 /// <summary>
 /// Default constructor, creates a new model.
 /// </summary>
 public ListModel()
 {
     Pages     = new List <Sitemap>();
     Templates = PageTemplate.GetFields("pagetemplate_id, pagetemplate_name, pagetemplate_preview, pagetemplate_description",
                                        new Params()
     {
         OrderBy = "pagetemplate_name ASC"
     });
 }
Пример #4
0
        /// <summary>
        /// Gets the list model for all available templates.
        /// </summary>
        /// <returns>The model.</returns>
        public static PageListModel Get()
        {
            PageListModel m = new PageListModel();

            m.Templates = PageTemplate.GetFields("pagetemplate_id,pagetemplate_name,pagetemplate_type,pagetemplate_created,pagetemplate_updated",
                                                 "pagetemplate_site_template = 0", new Params()
            {
                OrderBy = "pagetemplate_name ASC"
            });
            return(m);
        }