示例#1
0
        public static void BindPostSingle(MvcContext ctx, IBlock block, PhotoPost x, List <int> likedIds)
        {
            block.Set("x.Link", PhotoLink.ToPost(x.Id));
            block.Set("x.Title", x.Title);
            block.Set("x.Description", x.Description);

            block.Set("x.Pic", x.ImgThumbUrl);
            block.Set("x.PicM", x.ImgMediumUrl);
            block.Set("x.PicO", x.ImgUrl);

            block.Set("x.Pins", x.Pins);
            block.Set("x.Likes", x.Likes);

            String pinsLikes = "";

            if (x.Pins > 0)
            {
                pinsLikes += "收集:" + x.Pins;
            }
            if (x.Likes > 0)
            {
                pinsLikes += " 喜欢:" + x.Likes;
            }
            if (x.Replies > 0)
            {
                pinsLikes += " 评论:" + x.Replies;
            }
            block.Set("x.PinsLikes", pinsLikes);

            if (x.PhotoAlbum != null)
            {
                block.Set("x.AlbumName", x.PhotoAlbum.Name);
                block.Set("x.AlbumLink", PhotoLink.ToAlbumOne(x.PhotoAlbum.OwnerUrl, x.PhotoAlbum.Id));
            }
            else
            {
                block.Set("x.AlbumName", "");
                block.Set("x.AlbumLink", "#");
            }

            block.Set("x.CreatorName", x.Creator.Name);
            block.Set("x.CreatorPic", x.Creator.PicSmall);
            block.Set("x.CreatorLink", PhotoLink.ToUser(x.Creator));
            block.Set("x.Created", cvt.ToTimeString(x.Created));

            block.Set("x.RepinLink", ctx.link.To(new HomeController().Repin, x.Id));
            block.Set("x.LikeLink", ctx.link.To(new HomeController().Like, x.Id));
            block.Set("x.UnLikeLink", ctx.link.To(new HomeController().UnLike, x.Id));

            if (likedIds.Contains(x.Id))
            {
                block.Set("x.LikedCss", "wfpost-liked disabled");
                block.Set("x.LikeName", "已喜欢");
            }
            else
            {
                block.Set("x.LikedCss", "wfpost-like");
                block.Set("x.LikeName", "<i class=\"icon-heart icon-white\"></i> 喜欢");
            }
        }
示例#2
0
        public static void BindPostSingle(MvcContext ctx, IBlock block, PhotoPost x, List <int> likedIds)
        {
            block.Set("x.Link", PhotoLink.ToPost(x.Id));
            block.Set("x.Title", x.Title);
            block.Set("x.Description", x.Description);

            block.Set("x.Pic", x.ImgThumbUrl);
            block.Set("x.PicS", x.ImgSmallUrl);
            block.Set("x.PicM", x.ImgMediumUrl);
            block.Set("x.PicO", x.ImgUrl);

            int width    = x.SizeSX == null ? 170 : x.SizeSX.Width;
            int height   = x.SizeSX == null ? 170 : x.SizeSX.Height;
            int cfgWidth = getCfgWidth();

            if (width > cfgWidth)
            {
                height = Convert.ToInt32((decimal)(cfgWidth * height) / (decimal)width);
                width  = cfgWidth;
            }

            block.Set("x.WidthSx", width);
            block.Set("x.HeightSx", height);

            block.Set("x.Pins", x.Pins);
            block.Set("x.Likes", x.Likes);

            String pinsLikes = "";

            if (x.Pins > 0)
            {
                pinsLikes += "收集:" + x.Pins;
            }
            if (x.Likes > 0)
            {
                pinsLikes += " 喜欢:" + x.Likes;
            }
            if (x.Replies > 0)
            {
                pinsLikes += " 评论:" + x.Replies;
            }
            block.Set("x.PinsLikes", pinsLikes);

            if (x.PhotoAlbum != null)
            {
                block.Set("x.AlbumName", x.PhotoAlbum.Name);
                block.Set("x.AlbumLink", PhotoLink.ToAlbumOne(x.PhotoAlbum.OwnerUrl, x.PhotoAlbum.Id));
            }
            else
            {
                block.Set("x.AlbumName", "");
                block.Set("x.AlbumLink", "#");
            }

            block.Set("x.CreatorName", x.Creator.Name);
            block.Set("x.CreatorPic", x.Creator.PicSmall);
            block.Set("x.CreatorLink", PhotoLink.ToUser(x.Creator));
            block.Set("x.Created", cvt.ToTimeString(x.Created));

            block.Set("x.RepinLink", ctx.link.To(new HomeController().Repin, x.Id));
            block.Set("x.LikeLink", ctx.link.To(new HomeController().Like, x.Id));
            block.Set("x.UnLikeLink", ctx.link.To(new HomeController().UnLike, x.Id));

            if (likedIds.Contains(x.Id))
            {
                block.Set("x.LikedCss", "wfpost-liked disabled");
                block.Set("x.LikeName", "已喜欢");
            }
            else
            {
                block.Set("x.LikedCss", "wfpost-like");
                block.Set("x.LikeName", "<i class=\"icon-heart icon-white\"></i> 喜欢");
            }
        }