コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="category"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public string GetCategory(CategoryDto category, int pageIndex)
        {
            var tplId = GetCategoryTemplateId(category);


            //
            //todo:  /news/news/news/时候仍然能访问
            //

            //用于当前的模板共享数据
            //Cms.Context.Items["category.tag"] = category.Tag;
            Cms.Context.Items["category.path"] = category.Path;
            Cms.Context.Items["module.id"]     = category.ModuleId;
            Cms.Context.Items["page.index"]    = pageIndex;

            string title;

            if (pageIndex == 1)
            {
                title = !string.IsNullOrEmpty(category.PageTitle) ? category.PageTitle : $"{category.Name}_{_site.Title}";
            }
            else
            {
                switch (_site.Language)
                {
                case Languages.zh_CN:
                    title = $"- 第{pageIndex}页";
                    break;

                default:
                case Languages.en_US:
                    title = "- page " + pageIndex;
                    break;
                }

                title = $"{category.Name}{title}_{_site.Title}";
            }

            //解析模板
            return(PageUtility.Require(tplId, page =>
            {
                page.AddVariable("site", _site);
                page.AddVariable("page", new PageVariable
                {
                    Title = title,
                    SubTitle = _site.Title,
                    Keywords = category.Keywords,
                    Description = category.Description,
                    PageIndex = pageIndex
                });
                page.AddVariable("category", category);
                page.AddVariable("module", new Module {
                    ID = category.ModuleId
                });
            }));
        }
コード例 #2
0
 public virtual string GetIndex(params object[] args)
 {
     return(PageUtility.Require(this.FormatTemplatePath("index"), page =>
     {
         page.AddVariable("site", this._site);
         page.AddVariable("page", new PageVariable {
             Title = _site.Title, SubTitle = _site.Title, Keywords = _site.Keywords, Description = _site.Description
         });
     }));
 }
コード例 #3
0
        public virtual string GetSearch(params object[] args)
        {
            string cate = args[0] as string;
            string key  = args[1] as string;

            //计算页码
            int pageIndex;

            int.TryParse(HttpContext.Current.Request["p"], out pageIndex);
            if (pageIndex < 1)
            {
                pageIndex = 1;
            }

            //模板标签共享数据
            Cms.Context.Items["search.key"]   = key;
            Cms.Context.Items["search.param"] = cate;       //搜索按模块或按栏目
            Cms.Context.Items["page.index"]   = pageIndex;

            //解析模板
            string html = PageUtility.Require(this.FormatTemplatePath("search"),
                                              page =>
            {
                page.AddVariable("site", this._site);

                page.AddVariable("page", new PageVariable
                {
                    Title = String.Format("\"{0}\"相关的信息{1}_{2}",
                                          key,
                                          pageIndex == 1 ? String.Empty :
                                          String.Format(Cms.Language.Get(LanguagePackageKey.PAGE_PagerTitle), pageIndex.ToString()),
                                          _site.Title),
                    SubTitle    = _site.Title,
                    Keywords    = key,
                    Description = String.Empty,
                    PageIndex   = pageIndex
                });

                page.AddVariable("search", new
                {
                    Key        = key.ToString().Replace(",", "+"),
                    Param      = cate,
                    PageIndex  = pageIndex,
                    EscapeKey  = HttpContext.Current.Server.UrlEncode(key.ToString()),
                    Escape_Key = HttpContext.Current.Server.UrlEncode(key.ToString()),                                                     //过期
                    Cate       = cate                                                                                                      //过期
                });
            }
                                              );

            return(html);
        }
コード例 #4
0
        public string GetTagArchive(string key)
        {
            var ctx = HttpHosting.Context;
            //计算页码
            int pageIndex;

            int.TryParse(ctx.Request.Query("p"), out pageIndex);
            if (pageIndex < 1)
            {
                pageIndex = 1;
            }

            //模板标签共享数据
            Cms.Context.Items["tag.key"]    = key;
            Cms.Context.Items["page.index"] = pageIndex;

            //解析模板
            var html = PageUtility.Require(FormatTemplatePath("tag"),
                                           page =>
            {
                page.AddVariable("site", _site);

                page.AddVariable("page", new PageVariable
                {
                    Title = string.Format("{0}{1}_{2}",
                                          key,
                                          pageIndex == 1
                                ? string.Empty
                                : string.Format(Cms.Language.Get(LanguagePackageKey.PAGE_PagerTitle),
                                                pageIndex.ToString()),
                                          _site.Title),
                    SubTitle    = _site.Title,
                    Keywords    = key,
                    Description = string.Empty,
                    PageIndex   = pageIndex
                });

                page.AddVariable("tag", new
                {
                    Key        = key.Replace(",", "+"),
                    Param      = key,
                    PageIndex  = pageIndex,
                    EscapeKey  = HttpUtils.UrlEncode(key.ToString()),
                    Escape_Key = HttpUtils.UrlEncode(key.ToString()),
                    Cate       = key
                });
            }
                                           );

            return(html);
        }
コード例 #5
0
        public string GetSearch(string catPath, string key)
        {
            var ctx = HttpHosting.Context;
            //计算页码
            int pageIndex;

            int.TryParse(ctx.Request.Query("p"), out pageIndex);
            if (pageIndex < 1)
            {
                pageIndex = 1;
            }

            //模板标签共享数据
            Cms.Context.Items["search.key"]   = key;
            Cms.Context.Items["search.param"] = catPath; //搜索按模块或按栏目
            Cms.Context.Items["page.index"]   = pageIndex;

            //解析模板
            var html = PageUtility.Require(FormatTemplatePath("search"),
                                           page =>
            {
                page.AddVariable("site", _site);

                page.AddVariable("page", new PageVariable
                {
                    Title       = $"\"{key}\"相关的信息{(pageIndex == 1 ? string.Empty : string.Format(Cms.Language.Get(LanguagePackageKey.PAGE_PagerTitle), pageIndex.ToString()))}_{_site.Title}",
                    SubTitle    = _site.Title,
                    Keywords    = key,
                    Description = string.Empty,
                    PageIndex   = pageIndex
                });

                page.AddVariable("search", new
                {
                    Key        = key.Replace(",", "+"),
                    Param      = catPath,
                    PageIndex  = pageIndex,
                    EscapeKey  = HttpUtils.UrlEncode(key.ToString()),
                    Escape_Key = HttpUtils.UrlEncode(key.ToString()), //过期
                    Cate       = catPath                              //过期
                });
            }
                                           );

            return(html);
        }
コード例 #6
0
        public virtual string GetArchive(ArchiveDto archive, params object[] args)
        {
            #region 属性

            /*
             * //验证密码
             * PropertyBLL pbll = new PropertyBLL();
             * var a = pbll.GetProperty(category.ModuleID, "pwd");
             * if (a != null)
             * {
             *  var json = archive.GetPropertiesJson();
             *  string key = json.GetValue("pwd");
             *  if (!String.IsNullOrEmpty(key))
             *  {
             *      string requireKey = HttpContext.Current.Request.QueryString["pwd"];
             *      if (requireKey != key)
             *      {
             *          HttpContext.Current.Response.Write("<div style='margin:0 auto;padding:30px 0'>请输入密码:<input type='text'/><input type='button' value='提交' onclick=\"location.replace(location.href+'?pwd='+this.previousSibling.value)\"/></div>");
             *          HttpContext.Current.Response.End();
             *      }
             *
             *  }
             * }*/
            #endregion

            //获取模板ID
            string      tplId    = this.GetArchiveTemplateId(archive);
            CategoryDto category = archive.Category;

            //用于当前的模板共享数据
            Cms.Context.Items["archive.id"]    = archive.Id;
            Cms.Context.Items["category.path"] = category.Path;
            Cms.Context.Items["module.id"]     = category.ModuleId;

            //解析模板
            string html = PageUtility.Require(tplId,

                                              page =>
            {
                page.AddVariable("site", this._site);

                PageArchive pageArchive = new PageArchive(archive);

                page.AddVariable("archive", pageArchive);

                page.AddVariable("category", category);
                page.AddVariable("module", new Module {
                    ID = category.ModuleId
                });


                page.AddVariable("page", new PageVariable
                {
                    Title       = String.Format("{0}_{1}_{2}", archive.Title, category.Name, _site.Title),
                    SubTitle    = _site.Title,
                    Keywords    = archive.Tags,
                    Description = pageArchive.Outline.Replace("\"", String.Empty)
                });
            });
            return(html);
        }
コード例 #7
0
        public virtual string GetCategory(CategoryDto category, int pageIndex, params object[] args)
        {
            string tplId = this.GetCategoryTemplateId(category);


            //
            //todo:  /news/news/news/时候仍然能访问
            //

            //用于当前的模板共享数据
            //Cms.Context.Items["category.tag"] = category.Tag;
            Cms.Context.Items["category.path"] = category.Path;
            Cms.Context.Items["module.id"]     = category.ModuleId;
            Cms.Context.Items["page.index"]    = pageIndex;

            bool isFirstPage = pageIndex == 1;

            string title;

            if (pageIndex == 1)
            {
                if (!String.IsNullOrEmpty(category.PageTitle))
                {
                    title = category.PageTitle;
                }
                else
                {
                    title = String.Format("{0}_{1}", category.Name, _site.Title);
                }
            }
            else
            {
                switch (_site.Language)
                {
                case Languages.Zh_CN:
                    title = String.Format("- 第" + pageIndex.ToString() + "页");
                    break;

                default:
                case Languages.En:
                    title = String.Format("- page " + pageIndex.ToString());
                    break;
                }

                title = String.Format("{0}{1}_{2}", category.Name, title, _site.Title);
            }

            //解析模板
            return(PageUtility.Require(tplId, page =>
            {
                page.AddVariable("site", _site);
                page.AddVariable("page", new PageVariable
                {
                    Title = title,
                    SubTitle = _site.Title,
                    Keywords = category.Keywords,
                    Description = category.Description,
                    PageIndex = pageIndex
                });
                page.AddVariable("category", category);
                page.AddVariable("module", new Module {
                    ID = category.ModuleId
                });
            }));
        }