Пример #1
0
        public void Forword_GET()
        {
            int        id         = int.Parse(base.Request["archive.id"]);
            ArchiveDto archive    = ServiceCall.Instance.ArchiveService.GetArchiveById(this.SiteId, id);
            string     fullDomain = this.CurrentSite.FullDomain;

            if (fullDomain.IndexOf("#", StringComparison.Ordinal) != -1)
            {
                fullDomain = fullDomain.Replace("#", WebCtx.Current.Host);
            }
            string url = Request.Url.Scheme + ":" + fullDomain + archive.Url + ".html";


            if (String.IsNullOrEmpty(archive.Outline))
            {
                archive.Outline = ArchiveUtility.GetOutline(archive.Content, 100);
            }

            object data = new
            {
                title           = archive.Title,
                outline         = archive.Outline,
                url             = url,
                forword_content = String.Format("<a href=\"{0}\" target=\"_blank\"><strong>{1}</strong><br />{2}</a>",
                                                url,
                                                archive.Title,
                                                archive.Outline),
                link_content = ""
            };

            base.RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Archive_Forword), data);
        }
Пример #2
0
        public void TagsIndex_POST()
        {
            int siteId = this.CurrentSite.SiteId;

            String content = ResourceMap.GetPageContent(ManagementPage.Archive_Tags);

            GetTags(siteId).ProcessRequest(HttpContext.Current, content);
        }
Пример #3
0
        public void TagsIndex_GET()
        {
            string js  = ManagerTemplate.GetScriptTag();
            string css = ManagerTemplate.GetCssTag();

            int    siteId  = this.CurrentSite.SiteId;
            String content = ResourceMap.GetPageContent(ManagementPage.Archive_Tags);

            GetTags(siteId).ProcessRequest(HttpContext.Current, content.Replace("$js()", js).Replace("$css()", css));
        }
Пример #4
0
        /// <summary>
        /// 文档列表
        /// </summary>
        public string List_GET()
        {
            //const int __pageSize = 10;

            string categoryId  = Request["category.id"];
            int    publisherId = int.Parse(Request["author_id"] ?? "0");

            ViewData["category_id"] = categoryId ?? String.Empty;
            ViewData["author_id"]   = publisherId;
            ViewData["site_id"]     = this.CurrentSite.SiteId;

            return(base.RequireTemplate(ResourceMap.GetPageContent(ManagementPage.Archive_List)));
        }
Пример #5
0
        /// <summary>
        /// 预览文档
        /// </summary>
        public void View_GET()
        {
            int        id      = int.Parse(base.Request["archive.id"]);
            ArchiveDto archive = ServiceCall.Instance.ArchiveService.GetArchiveById(this.SiteId, id);
            //UserBll author = CmsLogic.UserBll.GetUser(archive.Author);
            UserDto user = ServiceCall.Instance.UserService.GetUser(archive.PublisherId);

            base.RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Archive_View), new
            {
                title         = archive.Title,
                publisherName = user == null ? "" : user.Name,
                publishdate   = String.Format("{0:yyyy-MM-dd HH:mm:ss}", archive.CreateTime),
                content       = archive.Content,
                thumbnail     = archive.Thumbnail,
                count         = archive.ViewCount
            });
        }
Пример #6
0
        /// <summary>
        /// 文档评论
        /// </summary>
        public void Comment_GET()
        {
            string commentListHtml;

            int        id      = int.Parse(base.Request["archive.id"]);
            ArchiveDto archive = ServiceCall.Instance.ArchiveService.GetArchiveById(this.SiteId, id);

            bool desc = base.Request["desc"] == "true";

            CategoryDto category = archive.Category;

            StringBuilder sb    = new StringBuilder();
            DataTable     table = CmsLogic.Comment.GetArchiveComments(archive.StrId, desc);


            int    i = 1;
            bool   isGuest = false;
            string nickName, content, avatar;
            Match  match;

            foreach (DataRow dr in table.Rows)
            {
                //筛选出游客的昵称和内容
                if (dr["memberid"].ToString() != "0")
                {
                    nickName = dr["nickname"].ToString();
                    content  = dr["content"].ToString();
                    avatar   = dr["avatar"].ToString();
                    isGuest  = false;
                }
                else
                {
                    content = dr["content"].ToString();
                    match   = Regex.Match(content, "\\(u:'(?<user>.+?)'\\)");

                    if (match != null)
                    {
                        nickName = match.Groups["user"].Value;
                        content  = Regex.Replace(content, "\\(u:'(.+?)'\\)", String.Empty);
                    }
                    else
                    {
                        nickName = "游客";
                    }

                    avatar  = "?module=file&action=guestavatar";
                    isGuest = true;
                }


                sb.Append("<p class=\"comment\"><img src=\"").Append(avatar).Append("\" /><span class=\"time\">")
                .Append(String.Format("{0:yyyy-MM-dd HH:mm:ss}", dr["create_time"])).Append("</span><span class=\"details\"><a href=\"#\">")
                .Append(nickName).Append("</a><br />").Append(content).Append("</span><span class=\"floor\">")
                .Append(i.ToString()).Append("楼</span><span class=\"control\"><a href=\"javascript:;\" onclick=\"remove(this,'").Append(dr["id"].ToString()).Append("')\">删除</a></span></p>");
                ++i;
            }

            commentListHtml = sb.Length == 0 ? "暂无评论!" : sb.ToString();

            object data = new
            {
                archive_id      = archive.StrId,
                archive_title   = archive.Title,
                publisher_name  = archive.PublisherId,
                publish_date    = String.Format("{0:yyyy-MM-dd HH:mm:ss}", archive.CreateTime),
                commentListHtml = commentListHtml
            };

            //base.RenderTemplate(ResourceMap.CommentList, data);
            base.RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Comment_List), data);
        }
Пример #7
0
        /// <summary>
        /// search文档列表
        /// </summary>
        public void Search_GET()
        {
            HttpRequest request = HttpContext.Current.Request;

            const int __pageSize = 10;

            object data;            //返回的数据

            int pageSize,
                pageIndex,
                recordCount,
                pages;


            string _keyword   = request["keyword"],
                   _pageIndex = request["page"] ?? "1",
                   _pageSize  = request["size"];


            if (String.IsNullOrEmpty(_keyword))
            {
                data = new
                {
                    keyword         = _keyword ?? "",
                    headerText      = "",
                    archiveListHtml = "",
                    pagerHtml       = ""
                };
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                string        pagerHtml,            //分页链接
                              tableHeaderText,      //表头字段
                              archiveListHtml;      //文档列表HTML

                //获取表头
                bool isMaster = UserState.Administrator.Current.IsMaster;
                tableHeaderText = isMaster ? "<th>发布人</th>" : String.Empty;


                //处理页码大小并保存

                if (!Regex.IsMatch(_pageIndex, "^(?!0)\\d+$"))
                {
                    pageIndex = 1;                                              //If pageindex start with zero or lower
                }
                else
                {
                    pageIndex = int.Parse(_pageIndex);
                }

                if (String.IsNullOrEmpty(_pageSize))
                {
                    int.TryParse(HttpContext.Current.Session["archivelist_pagesize"] as string, out pageSize);
                }
                else
                {
                    int.TryParse(_pageSize, out pageSize);
                    HttpContext.Current.Session["archivelist_pagesize"] = pageSize;
                }
                if (pageSize == 0)
                {
                    pageSize = __pageSize;
                }



                //文档数据表,并生成Html
                DataTable dt = null;// CmsLogic.Archive.Search(this.CurrentSite.SiteId, _keyword, pageSize, pageIndex, out recordCount, out pages, null);



                bool isSpecial,
                     isSystem,
                     isVisible,
                     isPage;

                foreach (DataRow dr in dt.Rows)
                {
                    int flag = Convert.ToInt32(dr["flag"]);
                    isSpecial = this.FlagAnd(flag, BuiltInArchiveFlags.IsSpecial);
                    isSystem  = this.FlagAnd(flag, BuiltInArchiveFlags.IsSystem);
                    isVisible = this.FlagAnd(flag, BuiltInArchiveFlags.Visible);
                    isPage    = this.FlagAnd(flag, BuiltInArchiveFlags.AsPage);

                    //编号
                    sb.Append("<tr><td align=\"center\">").Append(dr["id"].ToString()).Append("</td>");
                    //标题
                    sb.Append("<td").Append(isSpecial ? " class=\"special\">" : ">").Append(dr["title"].ToString()).Append("</td>");

                    //管理员可以查看发布人
                    if (isMaster)
                    {
                        sb.Append("<td><a href=\"?module=archive&amp;action=list&amp;moduleID=&amp;author_id=")
                        .Append(dr["author"].ToString()).Append("\" title=\"查看该用户发布的文档\">").Append(dr["Author"].ToString()).Append("</a></td>");
                    }

                    sb.Append("<td>").Append(String.Format("{0:yyyy/MM/dd HH:mm}", TimeUtils.UnixTime(Convert.ToInt32(dr["create_time"]), TimeZone.CurrentTimeZone)))
                    .Append("</td><td align=\"center\">")
                    .Append(dr["view_count"].ToString()).Append("</td><td><button class=\"refresh\" /></td><td><button class=\"file\" /></td><td><button class=\"edit\" /></td><td><button class=\"delete\" /></td></tr>");
                }

                archiveListHtml = sb.ToString();



                string format = String.Format("?module=archive&action=search&keyword={1}&page={0}&size={2}", "{0}", HttpUtility.UrlEncode(_keyword), pageSize);

                //pagerHtml = Helper.BuildPagerInfo(format, pageIndex, recordCount, pages);

                data = new
                {
                    keyword         = _keyword ?? "",
                    headerText      = tableHeaderText,
                    archiveListHtml = archiveListHtml,
                    // pagerHtml = pagerHtml
                };
            }
            base.RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Archive_Search), data);
        }
Пример #8
0
        /// <summary>
        /// 创建文档
        /// </summary>
        public void Create_GET()
        {
            object data;
            string tpls,
                   nodesHtml,
            //栏目JSON
                   extendFieldsHtml = "";                                                              //属性Html

            Module module;

            int         categoryId = int.Parse(base.Request["category.id"] ?? "1");                            //分类ID
            CategoryDto category   = ServiceCall.Instance.SiteService.GetCategory(base.SiteId, categoryId);


            //获取模板视图下拉项
            StringBuilder sb2 = new StringBuilder();

            //模板目录
            DirectoryInfo dir = new DirectoryInfo(
                String.Format("{0}templates/{1}",
                              AppDomain.CurrentDomain.BaseDirectory,
                              base.CurrentSite.Tpl + "/"
                              ));

            IDictionary <String, String> names = Cms.TemplateManager.Get(base.CurrentSite.Tpl).GetNameDictionary();

            EachClass.EachTemplatePage(
                dir,
                dir,
                sb2,
                names,
                TemplatePageType.Custom,
                TemplatePageType.Archive
                );

            tpls = sb2.ToString();
            sb2.Remove(0, sb2.Length);

            //获取该模块栏目JSON数据
            //categoryJSON = CmsLogic.Category.GetJson(m.ID);

            nodesHtml = Helper.GetCategoryIdSelector(this.SiteId, categoryId);


            //=============  拼接模块的属性值 ==============//

            /*
             * //========= 统计tab =============//
             * sb.Append("<ul class=\"dataExtend_tabs\">");
             * foreach (DataExtend e in extends)
             * {
             *  sb.Append("<li><span>").Append(e.Name).Append("</span></li>");
             * }
             * sb.Append("</ul>");
             *
             * extendItemsHtml = sb.ToString();
             *
             * sb.Capacity = 1000;
             * sb.Remove(0, sb.Length);
             */



            //======== 生成值 =============//

            StringBuilder sb = new StringBuilder(500);

            sb.Append("<div class=\"dataextend_item\">");
            PropertyUI uiType;

            foreach (IExtendField p in category.ExtendFields)
            {
                uiType = (PropertyUI)int.Parse(p.Type);
                this.AppendExtendFormHtml(sb, p, p.DefaultValue);
            }


            sb.Append("</div>");
            extendFieldsHtml = sb.ToString();


            // extendFieldsHtml = "<div style=\"color:red;padding:20px;\">所选栏目模块不包含任何自定义属性,如需添加请到模块管理-》属性设置</div>";


            object json = new
            {
                IsVisible = true,
                Thumbnail = CmsVariables.FRAMEWORK_ARCHIVE_NoPhoto,
                Location  = String.Empty
            };

            data = new
            {
                extendFieldsHtml = extendFieldsHtml,
                extend_cls       = category.ExtendFields.Count == 0 ? "hidden" : "",
                thumbPrefix      = CmsVariables.Archive_ThumbPrefix,
                nodes            = nodesHtml,
                url  = Request.Url.PathAndQuery,
                tpls = tpls,
                json = JsonSerializer.Serialize(json)
            };

            base.RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Archive_Create), data);
        }
Пример #9
0
        /// <summary>
        /// 更新文档
        /// </summary>
        public void Update_GET()
        {
            object data;
            int    archiveId = int.Parse(base.Request["archive.id"]);
            string tpls, nodesHtml,
            //栏目JSON
                   extendFieldsHtml = "";                                     //属性Html

            Module module;

            int siteId = this.CurrentSite.SiteId;

            ArchiveDto archive = ServiceCall.Instance.ArchiveService.GetArchiveById(siteId, archiveId);

            int categoryId = archive.Category.ID;

            //=============  拼接模块的属性值 ==============//

            StringBuilder sb = new StringBuilder(50);

            string       attrValue;
            IExtendField field;

            sb.Append("<div class=\"dataextend_item\">");

            foreach (IExtendValue extValue in archive.ExtendValues)
            {
                field     = extValue.Field;
                attrValue = (extValue.Value ?? field.DefaultValue).Replace("<br />", "\n");
                this.AppendExtendFormHtml(sb, field, attrValue);
            }


            sb.Append("</div>");

            extendFieldsHtml = sb.ToString();



            //获取模板视图下拉项
            StringBuilder sb2 = new StringBuilder();

            //模板目录
            DirectoryInfo dir = new DirectoryInfo(
                String.Format("{0}templates/{1}",
                              AppDomain.CurrentDomain.BaseDirectory,
                              base.CurrentSite.Tpl + "/"
                              ));

            IDictionary <String, String> names = Cms.TemplateManager.Get(base.CurrentSite.Tpl).GetNameDictionary();

            EachClass.EachTemplatePage(dir, dir,
                                       sb2,
                                       names,
                                       TemplatePageType.Custom,
                                       TemplatePageType.Archive
                                       );

            tpls = sb2.ToString();

            nodesHtml = Helper.GetCategoryIdSelector(this.SiteId, categoryId);


            string thumbnail = !String.IsNullOrEmpty(archive.Thumbnail)
                    ? archive.Thumbnail
                    : "/" + CmsVariables.FRAMEWORK_ARCHIVE_NoPhoto;

            object json = new
            {
                //IsSpecial = flags.ContainsKey(ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.IsSpecial))
                //                            && flags[ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.IsSpecial)],

                //IsSystem = flags.ContainsKey(ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.IsSystem))
                //                            && flags[ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.IsSystem)],

                //IsNotVisible = !(flags.ContainsKey(ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.Visible))
                //                            && flags[ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.Visible)]),

                //AsPage = flags.ContainsKey(ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.AsPage))
                //                            && flags[ArchiveFlag.GetInternalFlagKey(BuiltInArchiveFlags.AsPage)],
                IsSpecial    = this.FlagAnd(archive.Flag, BuiltInArchiveFlags.IsSpecial),
                IsSystem     = this.FlagAnd(archive.Flag, BuiltInArchiveFlags.IsSystem),
                IsVisible    = this.FlagAnd(archive.Flag, BuiltInArchiveFlags.Visible),
                AsPage       = this.FlagAnd(archive.Flag, BuiltInArchiveFlags.AsPage),
                Id           = archive.Id,
                Title        = archive.Title,
                SmallTitle   = archive.SmallTitle,
                Alias        = archive.Alias ?? String.Empty,
                Tags         = archive.Tags,
                Source       = archive.Source,
                Outline      = archive.Outline,
                Content      = archive.Content,
                TemplatePath = archive.IsSelfTemplate &&
                               !String.IsNullOrEmpty(archive.TemplatePath) ?
                               archive.TemplatePath :
                               String.Empty,
                Thumbnail = thumbnail,
                Location  = archive.Location
            };


            data = new
            {
                extendFieldsHtml = extendFieldsHtml,
                extend_cls       = archive.ExtendValues.Count == 0 ? "hidden" : "",
                thumbPrefix      = CmsVariables.Archive_ThumbPrefix,
                nodes            = nodesHtml,
                url  = Request.Url.PathAndQuery,
                tpls = tpls,
                json = JsonSerializer.Serialize(json)
            };

            base.RenderTemplate(
                BasePage.CompressHtml(ResourceMap.GetPageContent(ManagementPage.Archive_Update)),
                data);
        }