Ejemplo n.º 1
0
        public int SaveLink(int siteId, SiteLinkDto dto)
        {
            ISite     site = this.repo.GetSiteById(siteId);
            ISiteLink link = null;

            if (dto.Id <= 0)
            {
                link = this.repo.CreateLink(site, 0, dto.Text);
            }
            else
            {
                link = site.GetLinkManager().GetLinkById(dto.Id);
            }

            link.Bind       = dto.Bind;
            link.ImgUrl     = dto.ImgUrl;
            link.SortNumber = dto.SortNumber;
            link.Pid        = dto.Pid;
            link.Target     = dto.Target;
            link.Text       = dto.Text;
            link.Type       = dto.Type;
            link.Uri        = dto.Uri;
            link.Visible    = dto.Visible;

            return(link.Save());
        }
Ejemplo n.º 2
0
        public int SaveLink(int siteId, SiteLinkDto dto)
        {
            ISite     site = this._resp.GetSiteById(siteId);
            ISiteLink link = null;

            if (dto.Id <= 0)
            {
                link = this._resp.CreateLink(site, 0, dto.Text);
            }
            else
            {
                link = site.LinkManager.GetLinkById(dto.Id);
            }

            link.Bind       = dto.Bind;
            link.ImgUrl     = dto.ImgUrl;
            link.OrderIndex = dto.OrderIndex;
            link.Pid        = dto.Pid;
            link.Target     = dto.Target;
            link.Text       = dto.Text;
            link.Type       = dto.Type;
            link.Uri        = dto.Uri;
            link.Visible    = dto.Visible;

            return(link.Save());
        }
Ejemplo n.º 3
0
        public string Set_visible_POST()
        {
            int         linkId = int.Parse(base.Request.Form["link_id"]);
            SiteLinkDto link   = ServiceCall.Instance.SiteService.GetLinkById(this.SiteId, linkId);

            link.Visible = !link.Visible;
            int id = ServiceCall.Instance.SiteService.SaveLink(this.SiteId, link);

            return(base.ReturnSuccess());
        }
Ejemplo n.º 4
0
        public SiteLinkDto GetLinkById(int siteId, int linkId)
        {
            ISite     site = this._resp.GetSiteById(siteId);
            ISiteLink link = site.LinkManager.GetLinkById(linkId);

            if (link == null)
            {
                return(default(SiteLinkDto));
            }

            return(SiteLinkDto.ConvertFrom(link));
        }
Ejemplo n.º 5
0
        public IEnumerable <SiteLinkDto> GetLinksByType(int siteId, SiteLinkType type, bool ignoreDisabled)
        {
            ISite site = this._resp.GetSiteById(siteId);
            IEnumerable <ISiteLink> links = site.LinkManager.GetLinks(type);

            foreach (ISiteLink link in links)
            {
                if (!ignoreDisabled && !link.Visible)
                {
                    continue;
                }

                yield return(SiteLinkDto.ConvertFrom(link));
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 查看是否可见
        /// </summary>
        public void GetVisible_POST()
        {
            int linkId = int.Parse(base.Request.Form["link_id"]);

            SiteLinkDto link = ServiceCall.Instance.SiteService.GetLinkById(this.SiteId, linkId);

            if (link.Visible)
            {
                base.RenderSuccess();
            }
            else
            {
                base.RenderError("链接不可见");
            }
        }
Ejemplo n.º 7
0
Archivo: LinkC.cs Proyecto: jooper/cms
        public string Save_POST()
        {
            HttpRequest request = HttpContext.Current.Request;
            SiteLinkDto link    = default(SiteLinkDto);

            int linkId = 0;

            int.TryParse(request["Id"] ?? "0", out linkId);

            string bindtype = request.Form["bindtype"],
                   bindId   = request.Form["bindid"];

            if (linkId > 0)
            {
                link = ServiceCall.Instance
                       .SiteService.GetLinkById(this.SiteId, linkId);
            }

            //link = base.Request.Form.BindToEntity(link);

            link.ImgUrl     = base.Request.Form["imgurl"];
            link.OrderIndex = int.Parse(base.Request.Form["orderindex"]);
            link.Pid        = int.Parse(base.Request.Form["pid"]);
            link.Target     = base.Request.Form["target"];
            link.Text       = base.Request.Form["text"].Trim();
            link.Type       = (SiteLinkType)int.Parse(base.Request.Form["type"]);
            link.Uri        = base.Request.Form["uri"];
            link.Visible    = base.Request.Form["visible"] == "True";


            if (!String.IsNullOrEmpty(bindtype) &&
                Regex.IsMatch(bindId, "^\\d+$"))
            {
                link.Bind = String.Format("{0}:{1}", bindtype, bindId);
            }
            else
            {
                link.Bind = String.Empty;
            }

            int id = ServiceCall.Instance.SiteService.SaveLink(this.SiteId, link);

            return(base.ReturnSuccess());
        }
Ejemplo n.º 8
0
        /// <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));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 更新链接
        /// </summary>
        public void Edit_GET()
        {
            object data;
            int    linkId = int.Parse(base.Request.QueryString["linkId"]);
            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
            {
                if (binds[0] == "category")
                {
                    CategoryDto cate = ServiceCall.Instance.SiteService.GetCategory(this.SiteId, int.Parse(binds[1]));

                    bindTitle = cate.ID > 0 ?
                                String.Format("栏目:{0}", cate.Name) :
                                null;
                }
                else if (binds[0] == "archive")
                {
                    int archiveId;
                    int.TryParse(binds[1], out archiveId);

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

                    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_SiteLinkEdit);
                break;

            default:
            case SiteLinkType.CustomLink: linkTypeName = "自定义链接";
                resouce = ResourceMap.GetPageContent(ManagementPage.Link_SiteLinkEdit);
                break;

            case SiteLinkType.Navigation: linkTypeName = "网站导航";
                resouce = ResourceMap.GetPageContent(ManagementPage.Link_SiteLinkEdit_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();


            int categoryId = -1;

            if (link.Bind != null && link.Bind.StartsWith("category:"))
            {
                categoryId = int.Parse(binds[1]);
            }

            string json = JsonSerializer.Serialize(
                new
            {
                ID         = link.ID,
                Text       = link.Text,
                Uri        = link.Uri,
                OrderIndex = link.OrderIndex,
                Btn        = "保存",
                BindId     = binds == null ? "" : binds[1],
                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        = '0'
            });

            base.RenderTemplate(resouce, new
            {
                entity        = json,
                LinkType      = (int)link.Type,
                linkTypeName  = linkTypeName,
                categoryNodes = this.GetCategorySelector(this.SiteId, -1),
                plinks        = plinks
            });
        }