Ejemplo n.º 1
0
        public static void Init()
        {
            var sqlDb     = FreesqlDbInstance.GetInstance();
            var templates = sqlDb.Select <cms_template>().ToList();
            var channels  = sqlDb.Select <cms_channel>().ToList();


            templates.ForEach(s =>
            {
                TemplateManagerCache.AddTemplate(s);
            });

            channels.ForEach(s =>
            {
                ChannelManagerCache.AddChannel(s);
            });

            ///站点设置
            var site = sqlDb.Select <cms_site>().OrderBy(s => s.id).First();

            if (site == null)
            {
                site              = new cms_site();
                site.site_name    = "EasyCMS内容发布系统";
                site.site_favicon = "/favicon.ico";
                site.site_logo    = "/static/images/logo.png";
            }
            SiteManagerCache.SetSiteInfo(site);
        }
        /// <summary>
        /// 获取栏目的文章模板
        /// </summary>
        /// <param name="channelId"></param>
        /// <returns></returns>
        public static cms_template GetContentTemplate(int channelId)
        {
            var channel = GetChannel(channelId);

            if (channel == null)
            {
                return(null);
            }

            return(TemplateManagerCache.GetContentTemplate(channel.content_template));
        }
Ejemplo n.º 3
0
        public static void Init()
        {
            var sqlDb     = FreesqlDbInstance.GetInstance();
            var templates = sqlDb.Select <cms_template>().ToList();
            var channels  = sqlDb.Select <cms_channel>().ToList();

            templates.ForEach(s =>
            {
                TemplateManagerCache.AddTemplate(s);
            });

            channels.ForEach(s =>
            {
                ChannelManagerCache.AddChannel(s);
            });
        }
Ejemplo n.º 4
0
        public static void Init()
        {
            var sqlDb     = DbInstanceFactory.GetInstance();
            var templates = sqlDb.Select <cms_template>().ToList();
            var channels  = sqlDb.Select <cms_channel>().ToList();


            templates.ForEach(s =>
            {
                TemplateManagerCache.AddTemplate(s);
            });

            channels.ForEach(s =>
            {
                if (s.link_type == 1 && string.IsNullOrEmpty(s.channel_href))
                {
                    var firstId = sqlDb.Select <cms_content>().Where(a => a.channel_id == s.id).OrderByDescending(a => a.id).First(a => a.id);
                    if (firstId > 0)
                    {
                        s.channel_href = $"/news/{s.id}/{firstId}";
                    }
                }
                ChannelManagerCache.AddChannel(s);
            });

            ///站点设置
            var site = sqlDb.Select <cms_site>().OrderBy(s => s.id).First();

            if (site == null)
            {
                site              = new cms_site();
                site.site_name    = "EasyCMS内容发布系统";
                site.site_favicon = "/favicon.ico";
                site.site_logo    = "/static/images/logo.png";
            }
            SiteManagerCache.SetSiteInfo(site);
            //上传设置
            var uploadSet = sqlDb.Select <cms_upload_set>().OrderBy(s => s.id).First();

            if (uploadSet == null)
            {
                uploadSet = new cms_upload_set();
            }
            SiteManagerCache.SetUploadInfo(uploadSet);
        }