public void Dashboard() { RenderTemplate( ResourceMap.GetPageContent(ManagementPage.Plugin_Dashboard), null); }
/// <summary> /// 模板列表 /// </summary> public void Templates_GET() { if (!UserState.Administrator.Current.IsMaster) { return; } string curTemplate = base.CurrentSite.Tpl; string tplRootPath = String.Format("{0}templates/", AppDomain.CurrentDomain.BaseDirectory); string[] tplList = new string[0]; DirectoryInfo dir = new DirectoryInfo(tplRootPath); if (dir.Exists) { DirectoryInfo[] dirs = dir.GetDirectories(); tplList = new string[dirs.Length]; int i = -1; foreach (DirectoryInfo d in dirs) { tplList[++i] = d.Name; } } SettingFile sf; string currentName = "", currentThumbnail = "", tplConfigFile, tplName, tplDescrpt, tplThumbnail; StringBuilder sb = new StringBuilder(); foreach (string tpl in tplList) { tplName = tpl; tplThumbnail = null; tplDescrpt = null; tplConfigFile = String.Format("{0}{1}/tpl.conf", tplRootPath, tpl); if (File.Exists(tplConfigFile)) { sf = new SettingFile(tplConfigFile); if (sf.Contains("name")) { tplName = sf["name"]; } if (sf.Contains("thumbnail")) { tplThumbnail = sf["thumbnail"]; } if (sf.Contains("descript")) { tplDescrpt = sf["descript"]; } } if (String.CompareOrdinal(tpl, curTemplate) != 0) { sb.Append("<li><p><a href=\"javascript:;\">"); if (tplThumbnail != null) { sb.Append("<img src=\"").Append(tplThumbnail).Append("\" alt=\"点击切换模板\" class=\"shot ").Append(tpl).Append("\"/>"); } else { sb.Append("<span title=\"点击切换模板\" class=\"shot ").Append(tpl).Append(" thumbnail\">无缩略图</span>"); } sb.Append("</a></p><p><a href=\"javascript:;\" class=\"t\">") .Append(tplName).Append("</a></p><p><a class=\"btn edit\" href=\"tpl:") .Append(tpl).Append("\">编辑</a> <a class=\"btn down\" href=\"tpl:") .Append(tpl).Append("\">下载</a></p>") .Append("<p class=\"hidden\">").Append(tplDescrpt).Append("</p>") .Append("</li>"); } else { currentName = String.IsNullOrEmpty(tplName) ? curTemplate : tplName; if (tplThumbnail != null) { currentThumbnail = "<img src=\"" + tplThumbnail + "\" alt=\"点击切换模板\" class=\"shot1 " + tpl + "\"/>"; } else { currentThumbnail = "<span class=\"shot1 " + tpl + " thumbnail\">无缩略图</span>"; } } } base.RenderTemplate(ResourceMap.GetPageContent(ManagementPage.Template_Manager), new { list = sb.ToString(), current = curTemplate, currentName = currentName, currentThumbnail = currentThumbnail }); }
/// <summary> /// 创建链接 /// </summary> public string Create_GET() { object data; string plinks = ""; SiteLinkType type = (SiteLinkType)Enum.Parse(typeof(SiteLinkType), base.Request["type"], true); string linkTypeName, resouce; switch (type) { case SiteLinkType.FriendLink: linkTypeName = "友情链接"; resouce = ResourceMap.GetPageContent(ManagementPage.Link_Edit); break; default: case SiteLinkType.CustomLink: linkTypeName = "自定义链接"; resouce = ResourceMap.GetPageContent(ManagementPage.Link_Edit); break; case SiteLinkType.Navigation: linkTypeName = "网站导航"; resouce = ResourceMap.GetPageContent(ManagementPage.Link_Edit_Navigator); break; } //plinks StringBuilder sb = new StringBuilder(); int siteId = base.CurrentSite.SiteId; IEnumerable <SiteLinkDto> parentLinks = ServiceCall.Instance.SiteService .GetLinksByType(this.SiteId, type, true); foreach (SiteLinkDto _link in parentLinks) { if (_link.Pid == 0) { sb.Append("<option value=\"").Append(_link.Id.ToString()) .Append("\">").Append(_link.Text).Append("</option>"); } } plinks = sb.ToString(); string json = JsonSerializer.Serialize( new { Id = 0, Text = String.Empty, Uri = String.Empty, SortNumber = "0", Btn = "添加", BindId = String.Empty, BindType = String.Empty, BindTitle = "未绑定", Target = String.Empty, Type = Request["type"], ImgUrl = String.Empty, pid = '0', Visible = "True" }); ViewData["entity"] = json; ViewData["link_type"] = (int)type; ViewData["form_title"] = "创建" + linkTypeName; ViewData["category_opts"] = Helper.GetCategoryIdSelector(this.SiteId, -1); ViewData["parent_opts"] = plinks; ViewData["site_id"] = siteId; return(base.RequireTemplate(resouce)); }
/// <summary> /// 更新链接 /// </summary> public string Edit_GET() { int linkId = int.Parse(base.Request.QueryString["link_id"]); int bindId = 0; int siteId = this.SiteId; int categoryId = 0; string plinks = ""; SiteLinkDto link = ServiceCall.Instance.SiteService.GetLinkById(this.SiteId, linkId); string bindTitle = String.Empty; string[] binds = (link.Bind ?? "").Split(':'); if (binds.Length != 2 || binds[1] == String.Empty) { binds = null; } else { bindId = int.Parse(binds[1]); if (binds[0] == "category") { CategoryDto cate = ServiceCall.Instance.SiteService.GetCategory(this.SiteId, bindId); bindTitle = cate.ID > 0 ? String.Format("栏目:{0}", cate.Name) : null; categoryId = cate.ID; } else if (binds[0] == "archive") { ArchiveDto archive = ServiceCall.Instance.ArchiveService .GetArchiveById(this.SiteId, bindId); if (archive.Id <= 0) { binds = null; } else { bindTitle = String.Format("文档:{0}", archive.Title); } } } string linkTypeName, resouce; switch ((SiteLinkType)link.Type) { case SiteLinkType.FriendLink: linkTypeName = "友情链接"; resouce = ResourceMap.GetPageContent(ManagementPage.Link_Edit); break; default: case SiteLinkType.CustomLink: linkTypeName = "自定义链接"; resouce = ResourceMap.GetPageContent(ManagementPage.Link_Edit); break; case SiteLinkType.Navigation: linkTypeName = "网站导航"; resouce = ResourceMap.GetPageContent(ManagementPage.Link_Edit_Navigator); break; } //plinks StringBuilder sb = new StringBuilder(); IEnumerable <SiteLinkDto> parentLinks = ServiceCall.Instance.SiteService .GetLinksByType(this.SiteId, link.Type, true); foreach (SiteLinkDto _link in parentLinks) { if (_link.Pid == 0) { sb.Append("<option value=\"").Append(_link.Id.ToString()) .Append("\">").Append(_link.Text).Append("</option>"); } } plinks = sb.ToString(); string json = JsonSerializer.Serialize( new { Id = link.Id, Text = link.Text, Uri = link.Uri, SortNumber = link.SortNumber, Btn = "保存", BindId = bindId, BindType = binds == null ? "" : binds[0], BindTitle = bindTitle == String.Empty ? "未绑定" : bindTitle, Target = link.Target, Type = (int)link.Type, ImgUrl = link.ImgUrl, Visible = link.Visible.ToString(), Pid = link.Pid, CategoryId = categoryId }); ViewData["entity"] = json; ViewData["link_type"] = (int)link.Type; ViewData["form_title"] = "修改" + linkTypeName; ViewData["category_opts"] = Helper.GetCategoryIdSelector(this.SiteId, -1); ViewData["parent_opts"] = plinks; ViewData["site_id"] = siteId; return(base.RequireTemplate(resouce)); }
/// <summary> /// 系统用户列表 /// </summary> public void UserIndex() { RenderTemplate(ResourceMap.GetPageContent(ManagementPage.User_Index), null); }