コード例 #1
0
 public void UpdatePageAttribute(PageAttribute pageAttr)
 {
     if (pageAttr == null)
     {
         return;
     }
     if (!string.IsNullOrEmpty(pageAttr.Url))
     {
         Url = pageAttr.Url;
     }
     if (!string.IsNullOrEmpty(pageAttr.Title))
     {
         Title = pageAttr.Title;
     }
     if (pageAttr.IsCheckUrlSetManual)
     {
         UrlCheckType = pageAttr.UrlCheckType;
     }
     if (pageAttr.IsCheckTitleSetManual)
     {
         TitleCheckType = pageAttr.TitleCheckType;
     }
     if (pageAttr.IsHomePage)
     {
         IsHomePage = true;
     }
 }
コード例 #2
0
        public override void Apply(PropertyConfiguration edmProperty,
                                   StructuralTypeConfiguration structuralTypeConfiguration,
                                   Attribute attribute,
                                   ODataConventionModelBuilder model)
        {
            if (edmProperty == null)
            {
                throw Error.ArgumentNull("edmProperty");
            }

            if (!edmProperty.AddedExplicitly)
            {
                PageAttribute           pageAttribute = attribute as PageAttribute;
                ModelBoundQuerySettings querySettings = edmProperty.QueryConfiguration.GetModelBoundQuerySettingsOrDefault();
                if (pageAttribute.MaxTop < 0)
                {
                    querySettings.MaxTop = null;
                }
                else
                {
                    querySettings.MaxTop = pageAttribute.MaxTop;
                }

                if (pageAttribute.PageSize > 0)
                {
                    querySettings.PageSize = pageAttribute.PageSize;
                }
            }
        }
コード例 #3
0
        public static void Init(VISite site)
        {
            site.PagesFields.ForEach(
                page =>
            {
                var instance  = (VIPage)Activator.CreateInstance(page.FieldType);
                instance.Site = site;

                var pageAttr = PageAttribute.Handler(instance);
                if (pageAttr == null)
                {
                    instance.SetEmptyPage();
                }
                else
                {
                    instance.FillFromPageAttribute(pageAttr);
                }

                pageAttr = PageAttribute.Handler(page);
                if (pageAttr != null)
                {
                    instance.UpdatePageAttribute(pageAttr);
                }

                page.SetValue(site, instance);

                instance.InitSubElements();
            });
        }
コード例 #4
0
 public void FillFromPageAttribute(PageAttribute pageAttr)
 {
     if (pageAttr == null)
     {
         return;
     }
     Url            = pageAttr.Url;
     Title          = pageAttr.Title;
     UrlCheckType   = pageAttr.UrlCheckType;
     TitleCheckType = pageAttr.TitleCheckType;
     IsHomePage     = pageAttr.IsHomePage;
 }
コード例 #5
0
        public VIPage(string name, string url = null, string title = null, VISite site = null)
        {
            DefaultNameFunc = () => string.Format("Page with Title: '{0}', Url: '{1}'", Title ?? "", Url ?? "");
            if (!string.IsNullOrEmpty(name))
            {
                Name = name;
            }
            else
            {
                name = NameAttribute.GetName(this);
                if (!string.IsNullOrEmpty(name))
                {
                    Name = name;
                }
            }
            if (site != null)
            {
                Site = site;
            }
            var pageAttr = PageAttribute.Handler(this);

            if (pageAttr != null)
            {
                FillFromPageAttribute(pageAttr);
            }
            else
            {
                SetEmptyPage();
            }
            if (!string.IsNullOrEmpty(url))
            {
                Url = url;
            }
            if (!string.IsNullOrEmpty(title))
            {
                Title = title;
            }
        }
コード例 #6
0
        /// <summary>
        /// Set page size of the entity type.
        /// </summary>
        /// <param name="edmTypeConfiguration">The structural type to configure.</param>
        /// <param name="model">The edm model that this type belongs to.</param>
        /// <param name="attribute">The <see cref="Attribute"/> found on this type.</param>
        public override void Apply(StructuralTypeConfiguration edmTypeConfiguration, ODataConventionModelBuilder model,
                                   Attribute attribute)
        {
            if (edmTypeConfiguration == null)
            {
                throw Error.ArgumentNull("edmTypeConfiguration");
            }

            if (model == null)
            {
                throw Error.ArgumentNull("model");
            }

            if (!edmTypeConfiguration.AddedExplicitly)
            {
                PageAttribute pageAttribute = attribute as PageAttribute;

                /*
                 * ModelBoundQuerySettings querySettings =
                 *  edmTypeConfiguration.QueryConfiguration.GetModelBoundQuerySettingsOrDefault();
                 *
                 * if (pageAttribute.MaxTop < 0)
                 * {
                 *  querySettings.MaxTop = null;
                 * }
                 * else
                 * {
                 *  querySettings.MaxTop = pageAttribute.MaxTop;
                 * }
                 *
                 * if (pageAttribute.PageSize > 0)
                 * {
                 *  querySettings.PageSize = pageAttribute.PageSize;
                 * }
                 */
            }
        }
コード例 #7
0
ファイル: TemplateHelper.cs プロジェクト: svn2github/KCMS2
        /// <summary>
        /// 生成播放页面--快播
        /// </summary>
        /// <param name="kuaib">百度影音地址</param>
        /// <param name="cls">分类</param>
        public string CreateDramapage(MovieUrlBaidu kuaib, Class cls)
        {
            DataEntities ent = new DataEntities();

            MovieInfo movie = (from l in ent.MovieInfo where l.id == kuaib.MovieID select l).FirstOrDefault();

            string FileName = BasePage.GetMovieDramaUrl(kuaib, cls);
            string Content = "";

            TemplateContent temp = this.GetContentTemplate(cls);

            Content = GetTempateString(1, TempType.百度影音页面);

            Content = ReplacePublicTemplate(Content);
            Content = ReplacePublicTemplate(Content);
            Content = ReplacePublicTemplate(Content);

            Content = ReplaceSystemSetting(Content);

            PageAttribute pa = new PageAttribute() { Title = movie.Title + "-" + kuaib.Title + "快播在线播放", UpdateTime = DateTime.Now.ToString(), Description = string.Format("电影《{0}》{1} 快播在线播放页面,《{0}》{1}高清版下载。", movie.Title, kuaib.Title) };

            Content = ReplacePageAttribute(Content, pa);

            #region 替换内容

            MovieUrlBaidu next = BasePage.GetNextBaidu(kuaib);
            if (next == null)
            {
                next = new MovieUrlBaidu();
                next.Url = "";
            }

            Content = Content.Replace("[!--class.id--]", cls.ID.ToString());
            Content = Content.Replace("[!--class.name--]", cls.ClassName);
            Content = Content.Replace("[!--class.url--]", BasePage.GetClassUrl(cls));

            Content = Content.Replace("[!--movie.url--]", BasePage.GetMovieUrl(movie, movie.GetClass()));
            Content = Content.Replace("[!--movie.nextpageurl--]",
                ReplaceAll(
                BasePage.SystemSetting.SiteUrl + BasePage.GetMovieDramaUrl(next, next.GetClass()),
                "[\\u4e00-\\u9fa5]",
                "1")
                );

            Content = Content.Replace("[!--drama.title--]", kuaib.Title);
            Content = Content.Replace("[!--drama.url--]", kuaib.Url);
            Content = Content.Replace("[!--drama.updatetime--]", kuaib.UpdateTime.ToDateTime().ToString(temp.TimeFormat));

            Content = ReplaceContent(Content, movie, cls);

            StringBuilder sb = new StringBuilder();
            List<MovieUrlKuaib> qb = (from l in ent.MovieUrlKuaib where l.MovieID == movie.id select l).ToList();
            string list_tmp = GetTempateString(1, TempType.下载地址);
            foreach (MovieUrlKuaib q in qb)
            {
                string row = list_tmp.Replace("[!--url.id--]", q.id.ToS());
                row = row.Replace("[!--url.url--]", q.Url);
                row = row.Replace("[!--url.title--]", q.Title);
                row = row.Replace("[!--url.movieid--]", q.MovieID.ToS());
                row = row.Replace("[!--url.movietitle--]", q.MovieTitle);
                row = row.Replace("[!--url--]", BasePage.GetMovieDramaUrl(q, q.GetClass()));
                sb.Append(row);
            }
            Content = Content.Replace("[!--movie.kuib--]", sb.ToS());

            sb = new StringBuilder();
            List<MovieUrlBaidu> baidu = (from l in ent.MovieUrlBaidu where l.MovieID == movie.id select l).ToList();
            foreach (MovieUrlBaidu q in baidu)
            {
                string row = list_tmp.Replace("[!--url.id--]", q.id.ToS());
                row = row.Replace("[!--url.url--]", q.Url);
                row = row.Replace("[!--url.title--]", q.Title);
                row = row.Replace("[!--url.movieid--]", q.MovieID.ToS());
                row = row.Replace("[!--url.movietitle--]", q.MovieTitle);
                row = row.Replace("[!--url--]", BasePage.GetMovieDramaUrl(q, q.GetClass()));
                sb.Append(row);
            }
            Content = Content.Replace("[!--movie.baidu--]", sb.ToS());

            sb = new StringBuilder();
            List<MovieUrlMag> mag = (from l in ent.MovieUrlMag where l.MovieID == movie.id select l).ToList();
            foreach (MovieUrlMag q in mag)
            {
                string row = list_tmp.Replace("[!--url.id--]", q.id.ToS());
                row = row.Replace("[!--url.url--]", q.Url);
                row = row.Replace("[!--url.title--]", q.Title);
                row = row.Replace("[!--url.movieid--]", q.MovieID.ToS());
                row = row.Replace("[!--url.movietitle--]", q.MovieTitle);
                sb.Append(row);
            }
            Content = Content.Replace("[!--movie.mag--]", sb.ToS());

            #endregion

            Content = ReplaceTagContent(Content);

            //替换导航条
            Content = Content.Replace("[!--newsnav--]", BuildClassNavString(cls));
            ent.Dispose();

            return Content;
        }
コード例 #8
0
ファイル: TemplateHelper.cs プロジェクト: svn2github/KCMS2
 /// <summary> 
 /// 替换页面属性
 /// </summary>
 /// <param name="Content"></param>
 /// <param name="pa"></param>
 /// <returns></returns>
 public string ReplacePageAttribute(string Content, PageAttribute pa)
 {
     Content = Content.Replace("[!--page.title--]", pa.Title);
     Content = Content.Replace("[!--page.updatetime--]", pa.UpdateTime);
     Content = Content.Replace("[!--page.description--]", pa.Description);
     Content = Content.Replace("[!--page.keyword--]", pa.Keyword);
     return Content;
 }
コード例 #9
0
ファイル: TemplateHelper.cs プロジェクト: svn2github/KCMS2
        /// <summary>
        /// 创建章节页面
        /// </summary>
        /// <param name="cp"></param>
        /// <param name="b"></param>
        /// <param name="cls"></param>
        public string CreateBookChapterPage(BookChapter cp, Book b, Class cls)
        {
            string bookurl = BasePage.GetBookUrl(b, cls);
            string Content = GetTempateString(1, TempType.小说章节);

            Content = ReplacePublicTemplate(Content);
            Content = ReplacePublicTemplate(Content);
            Content = ReplacePublicTemplate(Content);

            Content = ReplaceSystemSetting(Content);

            string ChapterContent = Voodoo.IO.File.Read(System.Web.HttpContext.Current.Server.MapPath(BasePage.GetBookChapterTxtUrl(cp, cls)));
            ChapterContent = ChapterContent.Replace("<<", "<br />");
            ChapterContent = ReplaceContentKey(ChapterContent);//伪原创

            //如果章节正在处理中,则填入自定义内容
            if (cp.IsTemp == true)
            {
                ChapterContent = string.Format("{0}的小说{1}最新章节-{2}正在处理中,请稍后访问阅读。同时推荐您阅读以下精品小说<ul id=\"ul_tjlist\">{3}</ul>,<br /><br />阅读{1}最新章节{2},尽在<a href=\"{4}\">{5}</a>",
                    b.Author,
                    b.Title,
                    cp.Title,
                    Functions.Getnovellist("Enable=1 order by clickcount desc", 10, 100, "<li><a href=\"{url}\" title=\"{title}\">{title}</a></li>"),
                    BasePage.SystemSetting.SiteUrl,
                    BasePage.SystemSetting.SiteName
                    );
            }

            PageAttribute pa = new PageAttribute()
            {
                Title = string.Format("{0}-{1}-{2}", b.Title, cp.Title, b.Author),
                UpdateTime = DateTime.Now.ToString(),
                Description = ChapterContent.TrimHTML().Replace("\n", "").CutString(100),
                Keyword = string.Format("{0},{1}最新章节,{1}txt下载,{1}在线阅读", cp.Title, b.Title)
            };

            Content = ReplacePageAttribute(Content, pa);

            #region 替换内容

            //替换栏目
            Content = Content.Replace("[!--class.id--]", cls.ID.ToString());
            Content = Content.Replace("[!--class.name--]", cls.ClassName);
            Content = Content.Replace("[!--class.url--]", BasePage.GetClassUrl(cls));

            Content = Content.Replace("[!--book.url--]", bookurl);

            //替换书籍信息
            Content = ReplaceContent(Content, b, cls);

            //替换章节信息

            Content = Content.Replace("[!--chapter.id--]", cp.ID.ToS());
            Content = Content.Replace("[!--chapter.bookid--]", cp.BookID.ToS());
            Content = Content.Replace("[!--chapter.booktitle--]", cp.BookTitle);
            Content = Content.Replace("[!--chapter.classid--]", cp.ClassID.ToS());
            Content = Content.Replace("[!--chapter.classname--]", cp.ClassName);
            Content = Content.Replace("[!--chapter.valumeid--]", cp.ValumeID.ToS());
            Content = Content.Replace("[!--chapter.valumename--]", cp.ValumeName);
            Content = Content.Replace("[!--chapter.title--]", cp.Title);
            Content = Content.Replace("[!--chapter.isvipchapter--]", cp.IsVipChapter.ToBoolean().ToChinese());
            Content = Content.Replace("[!--chapter.textlength--]", cp.TextLength.ToS());
            Content = Content.Replace("[!--chapter.updatetime--]", cp.UpdateTime.ToS());
            Content = Content.Replace("[!--chapter.enable--]", cp.Enable.ToBoolean().ToChinese());
            Content = Content.Replace("[!--chapter.istemp--]", cp.IsTemp.ToBoolean().ToChinese());
            Content = Content.Replace("[!--chapter.isfree--]", cp.IsFree.ToBoolean().ToChinese());
            Content = Content.Replace("[!--chapter.chapterindex--]", cp.ChapterIndex.ToS());
            Content = Content.Replace("[!--chapter.isimagechapter--]", cp.IsImageChapter.ToBoolean().ToChinese());
            Content = Content.Replace("[!--chapter.content--]", ChapterContent);
            Content = Content.Replace("[!--chapter.clickcount--]", cp.ClickCount.ToS());

            #endregion

            Content = ReplaceTagContent(Content);

            #region 上一篇  下一篇 链接
            BookChapter news_pre = BasePage.GetPreChapter(cp, b);
            BookChapter news_next = BasePage.GetNextChapter(cp, b);

            string preurl = news_pre == null ? bookurl : BasePage.GetBookChapterUrl(news_pre, cls);
            string nexturl = news_next == null ? bookurl : BasePage.GetBookChapterUrl(news_next, cls);

            Content = Content.Replace("[!--chapter.preurl--]", preurl);
            Content = Content.Replace("[!--chapter.nexturl--]", nexturl);
            Content = Content.Replace("[!--chapter.pretitle--]", news_pre == null ? b.Title : news_pre.Title);
            Content = Content.Replace("[!--chapter.nexttitle--]", news_next == null ? b.Title : news_next.Title);

            //上一篇
            string pre_link = "<a href=\"#\">上章:没有了</a>";
            if (news_pre != null)
            {
                pre_link = string.Format("<a id=\"btn_pre\" href=\"{0}\" title=\"{1}\">上章:{2}</a>", nexturl, news_pre.Title, news_pre.Title.CutString(20));
            }
            Content = Content.Replace("[!--news.prelink--]", pre_link);

            //下一篇
            string next_link = "<a href=\"#\">下章:没有了</a>";
            if (news_next != null)
            {
                next_link = string.Format("<a id=\"btn_next\" href=\"{0}\" title=\"{1}\">下章:{2}</a>", nexturl, news_next.Title, news_next.Title.CutString(20));
            }
            Content = Content.Replace("[!--news.nextlink--]", next_link);

            #endregion

            //替换导航条
            Content = Content.Replace("[!--newsnav--]", BuildClassNavString(cls));

            return Content;
        }