Beispiel #1
0
        private void saveComment(Microblog oBlog, String content)
        {
            User    creator = oBlog.Creator;
            IMember owner   = User.findById(oBlog.OwnerId);

            OpenComment c = new OpenComment();

            c.Content   = content;
            c.TargetUrl = MbLink.ToShowFeed(oBlog.User, oBlog.Id);

            c.TargetDataType = oBlog.GetType().FullName;
            c.TargetDataId   = oBlog.Id;


            c.TargetTitle  = string.Format("(微博{0}){1}", oBlog.Created.ToShortDateString(), strUtil.ParseHtml(oBlog.Content, 25));
            c.TargetUserId = oBlog.User.Id;

            c.OwnerId = owner.Id;
            c.AppId   = 0;
            c.FeedId  = oBlog.Id;

            c.Ip       = oBlog.Ip;
            c.Author   = creator.Name;
            c.ParentId = 0;
            c.AtId     = 0;

            c.Member = creator;

            commentService.Create(c);
        }
Beispiel #2
0
        public void Publish()
        {
            if (Component.IsClose(typeof(MicroblogApp)))
            {
                content("");
                return;
            }


            target(new MicroblogSaveController().Create);

            User user = ctx.owner.obj as User;

            set("my.Name", user.Name);
            set("my.Face", user.PicSmall);
            set("my.Link", to(new UserProfileController().Face));

            set("uploadLink", to(UploadForm));

            String    logStr = "";
            Microblog blog   = microblogService.GetFirst(user.Id);

            if (blog != null)
            {
                String lnkMore = alink.ToUserMicroblog(user);
                logStr = string.Format("{0} <span class=\"note\">{1}</span> <a href='{2}'>{3}...</a>", blog.Content, cvt.ToTimeString(blog.Created), lnkMore, lang("more"));
            }
            set("currentBlog", logStr);
        }
        public void CancelFavorite( int userId, Microblog blog )
        {
            MicroblogFavorite f = MicroblogFavorite.find( "UserId=" + userId + " and MicroblogId=" + blog.Id ).first();
            if (f == null) return;

            f.delete();
        }
Beispiel #4
0
        private void updateTargetReplies(OpenComment c, int replies)
        {
            ICommentTarget target = GetTarget(c) as ICommentTarget;

            if (target != null)
            {
                target.Replies = replies;
                db.update(target);
            }

            // feed replies
            Microblog mblog = getFeed(c);

            if (mblog != null)
            {
                mblog.Replies = replies;
                mblog.update();
            }

            if (c.AppId > 0 && target != null)
            {
                Type appType = target.GetAppType();
                if (appType != null)
                {
                    ICommentApp app = ndb.findById(appType, c.AppId) as ICommentApp;
                    if (app != null)
                    {
                        int appCount = OpenComment.count("AppId=" + c.AppId + " and TargetDataType='" + c.TargetDataType + "'");
                        app.CommentCount = appCount;
                        db.update(app);
                    }
                }
            }
        }
Beispiel #5
0
        private void updateComment(object[] args, object target)
        {
            ForumPost  post   = args[0] as ForumPost;
            User       editor = args[1] as User;
            ForumTopic topic  = ForumTopic.findById(post.TopicId);

            // 更新评论
            CommentSync objSync = CommentSync.find("PostId=" + post.Id).first();

            if (objSync == null)
            {
                return;
            }
            OpenComment comment = objSync.Comment;

            comment.Content = strUtil.ParseHtml(post.Content);
            comment.update();

            // 更新此ForumPost对应的Microblog
            Microblog mblog = Microblog.find("DataId=:id and DataType=:dtype")
                              .set("id", post.Id)
                              .set("dtype", typeof(ForumPost).FullName)
                              .first();

            if (mblog != null)
            {
                mblog.Content = getPostContent(post);
                mblog.update();
            }
        }
        public void commentList(int id)
        {
            int thisPageCount = 10;
            List <MicroblogComment> comments = commentService.GetTop(id, thisPageCount);

            Microblog blog = microblogService.GetById(id);

            if (blog == null)
            {
                echoText("<div class=\"strong red\">本数据已被删除,无法评论</div>");
                return;
            }

            int restCount = blog.Replies - thisPageCount;


            bindOneBlog(this.utils.getCurrentView(), blog, comments);

            String moreInfo = "";

            if (restCount > 0)
            {
                String lnk = to(new MicroblogController().Show, id);
                moreInfo = string.Format("后面还有{0}条评论,<a id=\"moreLink\" href=\"{1}\" to=\"{1}\" target=\"_blank\">点击查看>></a>", restCount, lnk);
            }

            set("moreLink", moreInfo);
        }
Beispiel #7
0
        public void Index()
        {
            if (ctx.viewer.IsLogin)
            {
                redirectDirect(Link.To(ctx.viewer.obj, new Microblogs.My.MicroblogController().Home));
                return;
            }

            ctx.Page.Title       = MicroblogAppSetting.Instance.MetaTitle;
            ctx.Page.Keywords    = MicroblogAppSetting.Instance.MetaKeywords;
            ctx.Page.Description = MicroblogAppSetting.Instance.MetaDescription;

            List <Microblog> list = Microblog.find("order by Id desc").list(20);

            ctx.SetItem("_microblogList", list);
            load("recentList", List);

            List <User> follows = User.find("order by FollowersCount desc, Id desc").list(9);

            bindFollowers(follows, "followers");

            List <User> recents = User.find("Pic<>'' order by Id desc").list(9);

            bindFollowers(recents, "recent");
        }
Beispiel #8
0
        public override void After(object returnValue, MethodInfo method, object[] args, object target)
        {
            Microblog blog = args[0] as Microblog;

            if (blog == null || blog.ParentId > 0)
            {
                return;
            }
            if (blog.User == null || blog.User.Id <= 0)
            {
                return;
            }

            UserConnect uc = connectService.GetConnectInfo(blog.User.Id, typeof(WeiboConnect).FullName);

            // 1. 检查:用户是否绑定,是否允许同步
            if (uc == null)
            {
                return;             // 绑定
            }
            if (uc.NoSync == 1)
            {
                logger.Info("取消同步,因为用户明确禁止");
                return;
            }

            // 2. 同步
            WeiboConnect connect = AuthConnectFactory.GetConnect(typeof(WeiboConnect).FullName) as WeiboConnect;

            connect.Publish(uc.AccessToken, _blogContent, getPicDiskPath(blog.Pic));
        }
Beispiel #9
0
        //------------------------------------------------------------------------------------------
        public virtual void DeleteSys( Microblog blog )
        {
            if (blog == null) throw new ArgumentNullException( "blog" );

            blog.SaveStatus = SaveStatus.SysDelete;
            blog.delete();
        }
 private bool hasFavorite( Microblog blog, List<MicroblogFavorite> mfs )
 {
     foreach (MicroblogFavorite mf in mfs) {
         if (mf.Microblog.Id == blog.Id) return true;
     }
     return false;
 }
Beispiel #11
0
        public virtual void Forward(long id)
        {
            Microblog blog = microblogService.GetById(id);

            if (blog == null)
            {
                errors.Add(lang("exDataNotFound"));
                echoError();
                return;
            }

            IBlock pblock = getBlock("parent");

            if (blog.ParentId <= 0)
            {
                set("blog.User", blog.User.Name);
                set("blog.Content", blog.Content);
                set("commentBody", "");
            }

            else
            {
                Microblog parent = microblogService.GetById(blog.ParentId);

                set("blog.User", blog.User.Name);
                set("blog.Content", parent.Content);
                set("commentBody", "//@" + blog.User.Name + ":" + blog.Content);

                pblock.Set("blog.ParentUser", parent.User.Name);
                pblock.Next();
            }

            target(Save, id);
        }
Beispiel #12
0
        public override void After(object returnValue, MethodInfo method, object[] args, object target)
        {
            if (method.Name == "DeleteToTrash")
            {
                ForumTopic topic = args[0] as ForumTopic;
                Microblog  mblog = Microblog.find("DataId=:id and DataType=:dtype")
                                   .set("id", topic.Id)
                                   .set("dtype", typeof(ForumTopic).FullName)
                                   .first();

                if (mblog != null)
                {
                    mblog.delete();
                }
            }

            else if (method.Name == "DeleteList")
            {
                AdminValue av = args[0] as AdminValue;
                if (strUtil.HasText(av.Ids))
                {
                    String str = "DataType='" + typeof(ForumTopic).FullName + "' and DataId in (" + av.Ids + ")";
                    Microblog.deleteBatch(str);
                }
            }
        }
Beispiel #13
0
        private static void bindUserInfo( IBlock block, MvcContext ctx, Microblog blog, Boolean showUserFace )
        {
            IBlock ufBlock = block.GetBlock( "userFace" );
            if (showUserFace) {

                ufBlock.Set( "blog.UserName", blog.User.Name );
                ufBlock.Set( "blog.UserFace", blog.User.PicSmall );

                if (ctx.GetItemString( "_showType" ) == "microblog") {
                    ufBlock.Set( "blog.UserLink", alink.ToUserMicroblog( blog.User ) );
                    ufBlock.Set( "userNameInfo", string.Format( "<a href=\"{0}\">{1}</a>", alink.ToUserMicroblog( blog.User ), blog.User.Name ) );
                }
                else {
                    ufBlock.Set( "blog.UserLink", Link.ToMember( blog.User ) );
                    ufBlock.Set( "userNameInfo", string.Format( "<a href=\"{0}\">{1}</a>", Link.ToMember( blog.User ), blog.User.Name ) );
                }

                String deleteCmd = getDeleteCmd( ctx, blog );
                ufBlock.Set( "blog.DeleteCmd", deleteCmd );

                ufBlock.Next();

                if (ctx.GetItemString( "_showType" ) == "microblog") {
                    block.Set( "userNameInfo", string.Format( "<a href=\"{0}\">{1}</a>", alink.ToUserMicroblog( blog.User ), blog.User.Name ) );
                }
                else {
                    block.Set( "userNameInfo", string.Format( "<a href=\"{0}\">{1}</a>", Link.ToMember( blog.User ), blog.User.Name ) );
                }

            }
            else {
                block.Set( "userNameInfo", "" );
            }
        }
Beispiel #14
0
        public void Show(int id)
        {
            Microblog blog = microblogService.GetById(id);

            if (blog == null)
            {
                echo(lang("exDataNotFound"));
                return;
            }

            // 详细内容:使用通用视图文件
            loadCommonView(blog);

            // 评论列表
            DataPage <MicroblogComment> comments = commentService.GetComments(id, 20);
            IBlock cblock = getBlock("comments");

            bindComments(cblock, comments.Results);
            String pager = comments.PageCount > 1 ? comments.PageBar : "";

            set("page", pager);

            // 评论表单
            target(new MicroblogCommentsController().SaveReply);
            set("c.RootId", id);
            set("c.ParentId", 0);
            set("viewer.PicSmall", ctx.viewer.obj.PicSmall);
        }
 public virtual List <Microblog> GetCurrent(int count, int userId)
 {
     if (count <= 0)
     {
         count = 1;
     }
     return(Microblog.find("User.Id=" + userId).list(count));
 }
 public List <Microblog> GetByReplies(int count)
 {
     if (count <= 0)
     {
         count = 10;
     }
     return(Microblog.find("order by Replies desc, Id desc").list(count));
 }
 public List <Microblog> GetRecent(int count)
 {
     if (count <= 0)
     {
         count = 10;
     }
     return(Microblog.find("order by Id desc").list(count));
 }
Beispiel #18
0
 public virtual List <Microblog> GetByReplies(int count)
 {
     if (count <= 0)
     {
         count = 10;
     }
     return(Microblog.find(showCondition() + " order by Replies desc, Id desc").list(count));
 }
Beispiel #19
0
 private long getParentId(Microblog tblog)
 {
     if (tblog.ParentId <= 0)
     {
         return(tblog.Id);
     }
     return(tblog.ParentId);
 }
Beispiel #20
0
 public virtual List <Microblog> GetCurrent(int count, long userId)
 {
     if (count <= 0)
     {
         count = 1;
     }
     return(Microblog.find("User.Id=" + userId + showCondition()).list(count));
 }
Beispiel #21
0
 public virtual List <Microblog> GetByUser(int count, int userId)
 {
     if (count <= 0)
     {
         count = 10;
     }
     return(Microblog.find("User.Id=" + userId + showCondition()).list(count));
 }
Beispiel #22
0
        public virtual void SaveLike(long mid)
        {
            if (ctx.viewer.IsLogin == false)
            {
                echoJsonMsg("请先登录", false, "");
                return;
            }

            if (mid <= 0)
            {
                echoText("mid=" + mid);
                return;
            }

            Microblog microblog = Microblog.findById(mid);

            if (microblog == null)
            {
                echoText("microblog is null. mid=" + mid);
                return;
            }

            // 检查是否已经like
            MicroblogLike flike = MicroblogLike.find("UserId=" + ctx.viewer.Id + " and MicroblogId=" + mid).first();

            if (flike != null)
            {
                echoText("您已经赞过");
                return;
            }

            microblog.Likes = microblog.Likes + 1;
            microblog.update();

            MicroblogLike microblogLike = new MicroblogLike();

            microblogLike.User      = ctx.viewer.obj as User;
            microblogLike.Microblog = microblog;
            microblogLike.Ip        = ctx.Ip;
            microblogLike.insert();

            // target likes
            if (strUtil.HasText(microblog.DataType))
            {
                Type targetType = Entity.GetType(microblog.DataType);
                if (targetType != null)
                {
                    ILike target = ndb.findById(targetType, microblog.DataId) as ILike;
                    if (target != null)
                    {
                        target.Likes = microblog.Likes;
                        db.update(target);
                    }
                }
            }

            echoAjaxOk();
        }
Beispiel #23
0
        private string getFavoriteCmd(Microblog blog, Boolean isFavorite)
        {
            if (isFavorite)
            {
                return(string.Format("<span class=\"cancelFavorite link left10 right10\" to=\"{0}\">取消收藏</span>", to(CancelFavorite, blog.Id)));
            }

            return(string.Format("<span class=\"addFavorite link left10 right10\" to=\"{0}\">收藏</span>", to(SaveFavorite, blog.Id)));
        }
Beispiel #24
0
        private void logtest(MvcContext ctx)
        {
            List <String> list = getContentList();

            for (int i = 0; i < list.Count; i++)
            {
                Microblog blog = getBlog(null, list[i], i);
            }
        }
Beispiel #25
0
        public virtual void DeleteBatch(string ids)
        {
            int[] arrIds = cvt.ToIntArray(ids);
            if (arrIds.Length == 0)
            {
                return;
            }

            Microblog.updateBatch("SaveStatus=" + SaveStatus.Delete, "id in (" + ids + ")");
        }
Beispiel #26
0
        //----------------------------------------------------------------------------

        public virtual void Delete(Microblog blog)
        {
            if (blog == null)
            {
                throw new ArgumentNullException("blog");
            }

            blog.SaveStatus = SaveStatus.Delete;
            blog.delete();
        }
Beispiel #27
0
 public ActionResult Edit([Bind(Include = "bid,uid,uname,time,title,text,reads,tag")] Microblog microblog)
 {
     if (ModelState.IsValid)
     {
         db.Entry(microblog).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(microblog));
 }
Beispiel #28
0
 private static void bindPicInfo( IBlock block, Microblog blog )
 {
     IBlock picBlock = block.GetBlock( "pic" );
     if (strUtil.HasText( blog.Pic )) {
         picBlock.Set( "blog.PicSmall", blog.PicSmall );
         picBlock.Set( "blog.PicMedium", blog.PicMedium );
         picBlock.Set( "blog.PicOriginal", blog.PicOriginal );
         picBlock.Next();
     }
 }
        public void SaveFavorite( int userId, Microblog blog )
        {
            MicroblogFavorite f = MicroblogFavorite.find( "UserId=" + userId + " and MicroblogId=" + blog.Id ).first();
            if (f != null) return;

            MicroblogFavorite mf = new MicroblogFavorite();
            mf.UserId = userId;
            mf.Microblog = blog;
            mf.insert();
        }
Beispiel #30
0
        private static String getDeleteCmd(MvcContext ctx, Microblog blog)
        {
            String deleteCmd = "";

            if (ctx.viewer.Id == blog.User.Id || ctx.viewer.IsAdministrator())
            {
                deleteCmd = string.Format("<a href=\"{0}\" class=\"left10 ajaxDeleteCmd\" removeId=\"mblog{1}\">x</a>", Link.To(new Microblogs.MicroblogSaveController().Delete, blog.Id), blog.Id);
            }
            return(deleteCmd);
        }
Beispiel #31
0
        public void RestoreSysBatch(string ids)
        {
            int[] arrIds = cvt.ToIntArray(ids);
            if (arrIds.Length == 0)
            {
                return;
            }

            Microblog.updateBatch("SaveStatus=" + SaveStatus.Normal, "id in (" + ids + ")");
        }
Beispiel #32
0
        public ActionResult DeleteConfirmed(int id)
        {
            Tag       tag       = db.tag.Where(v => v.bid == id).FirstOrDefault();
            Microblog microblog = db.microblog.Find(id);

            db.tag.Remove(tag);
            db.microblog.Remove(microblog);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        private void bindOneBlog(IBlock block, Microblog blog, List <MicroblogComment> comments)
        {
            block.Set("blog.Id", blog.Id);
            block.Set("blog.Content", blog.Content);
            block.Set("blog.Created", blog.Created);

            IBlock cblock = block.GetBlock("comments");

            bindComments(cblock, comments);
        }
        public virtual void DeleteBatch(string ids)
        {
            int[] arrIds = cvt.ToIntArray(ids);
            if (arrIds.Length == 0)
            {
                return;
            }

            Microblog.deleteBatch("id in (" + ids + ")");
        }
Beispiel #35
0
        public virtual void CancelFavorite(long userId, Microblog blog)
        {
            MicroblogFavorite f = MicroblogFavorite.find("UserId=" + userId + " and MicroblogId=" + blog.Id).first();

            if (f == null)
            {
                return;
            }

            f.delete();
        }
Beispiel #36
0
 private bool hasFavorite(Microblog blog, List <MicroblogFavorite> mfs)
 {
     foreach (MicroblogFavorite mf in mfs)
     {
         if (mf.Microblog.Id == blog.Id)
         {
             return(true);
         }
     }
     return(false);
 }
        /// <summary>
        /// 纯粹插入数据库,不检查表情、at用户、不处理tag;不处理转发
        /// </summary>
        /// <param name="creator"></param>
        /// <param name="msg"></param>
        /// <param name="dataType"></param>
        /// <param name="dataId"></param>
        /// <param name="ip"></param>
        public virtual void AddSimple(User creator, string msg, string dataType, long dataId, string ip)
        {
            Microblog x = new Microblog();
            x.User = creator;
            x.Content = msg;
            x.Ip = ip;

            x.DataType = dataType;
            x.DataId = dataId;

            x.insert();
        }
Beispiel #38
0
        public virtual void Add( User creator, String msg, String dataType, int dataId, String ip )
        {
            Microblog x = new Microblog();
            x.User = creator;
            x.Content = msg;
            x.Ip = ip;

            x.DataType = dataType;
            x.DataId = dataId;

            this.Insert( x, 0 );
        }
Beispiel #39
0
        private static void bindVideoInfo( IBlock block, Microblog blog )
        {
            IBlock vBlock = block.GetBlock( "video" );
            if (strUtil.HasText( blog.FlashUrl )) {

                String vpic = strUtil.HasText( blog.PicUrl ) ? blog.PicUrl : strUtil.Join( sys.Path.Img, "/big/novideopic.png" );

                vBlock.Set( "blog.FlashPic", vpic );
                vBlock.Set( "blog.Flash", wojilu.Web.Utils.WebHelper.GetFlash( blog.FlashUrl, 450, 340 ) );
                vBlock.Set( "blog.FlashPageUrl", blog.PageUrl );
                vBlock.Next();
            }
        }
        private Microblog getBlog( User creator, String content, int i )
        {
            Microblog x = new Microblog();

            x.Creator = creator;
            x.Content = content;
            logger.Info( x.Content );

            if (i % 2 == 1 && i > 0) {
                // 发布一篇图片微博
                x.Pic = Img.CopyToUploadPath( "/__installer/pic/pic" + i + ".jpg" );
            }

            return x;
        }
Beispiel #41
0
        private static void bindUserInfo( IBlock block, Microblog blog, Boolean showUserFace )
        {
            IBlock ufBlock = block.GetBlock( "userFace" );
            if (showUserFace) {

                ufBlock.Set( "blog.UserName", blog.User.Name );
                ufBlock.Set( "blog.UserFace", blog.User.PicSmall );
                ufBlock.Set( "blog.UserLink", alink.ToUserMicroblog( blog.User ) );

                ufBlock.Next();

                block.Set( "userNameInfo", string.Format( "<a href=\"{0}\">{1}</a>: ", alink.ToUserMicroblog( blog.User ), blog.User.Name ) );
            }
            else {
                block.Set( "userNameInfo", "" );
            }
        }
        public void Create()
        {
            if (Component.IsClose( typeof( MicroblogApp ) )) {
                content( "对不起,微博功能暂停运行" );
                return;
            }

            String blogContent = ctx.Post( "Content" );
            if (strUtil.IsNullOrEmpty( blogContent )) {
                content( lang( "exContent" ) );
                return;
            }

            String picUrl = ctx.Post( "PicUrl" );

            User user = ctx.viewer.obj as User;

            Microblog blog = new Microblog();
            blog.Content = blogContent;
            blog.Ip = ctx.Ip;
            blog.User = user;
            blog.Pic = picUrl;

            setVideoInfo( blog );

            microblogService.Insert( blog );

            String srcType = ctx.Post( "srcType" );

            if ("shareBox".Equals( srcType )) {
                returnCloseBox();
            }
            else if ("mbHome".Equals( srcType )) {
                returnOneBlogHtml( blog );
            }
            else {
                echoRedirect( "ok", to( new My.MicroblogController().Home ) );
            }
        }
Beispiel #43
0
        private void saveCommentParent( Microblog tblog, string content )
        {
            if (tblog.ParentId <= 0) return;

            Microblog parent = microblogService.GetById( tblog.ParentId );
            saveComment( parent, content );
        }
Beispiel #44
0
        private void addNotification( List<User> users, Microblog blog )
        {
            // ��@�û���֪ͨ
            foreach (User u in users) {

                //String msg = string.Format( "��΢���ᵽ����:<a href=\"{0}\">{1}</a>", lnk, strUtil.ParseHtml( blog.Content, 30 ) );
                //nfService.send( u.Id, msg );

                MicroblogAt mat = new MicroblogAt();
                mat.Microblog = blog;
                mat.User = u;
                mat.insert();

                u.MicroblogAt++;
                u.update( "MicroblogAt" );

                u.MicroblogAtUnread++;
                u.update( "MicroblogAtUnread" );

            }
        }
Beispiel #45
0
        private void addFeedInfo( Microblog log )
        {
            Feed feed = new Feed();
            feed.Creator = log.User;
            feed.DataType = typeof( Microblog ).FullName;
            feed.DataId = log.Id;

            // ת��΢����Ϣ
            String pbody = "";
            if (log.ParentId > 0) {
                Microblog parent = GetById( log.ParentId );
                if (parent == null) {
                    pbody = " [��ת΢���ѱ�ԭ����ɾ��]";
                }
                else {
                    pbody = ": [ת]" + parent.Content;
                }
            }

            feed.TitleTemplate = "{*actor*} :" + strUtil.SubString( log.Content + pbody, 230 );

            if (strUtil.HasText( log.Pic )) {

                Dictionary<String, String> data = new Dictionary<string, string>();
                data.Add( "pic", "<img src=\"" + log.PicSmall + "\" />" );

                feed.BodyTemplate = "{*pic*}";
                feed.BodyData = JsonString.ConvertDictionary( data );
            }

            feedService.publishUserAction( feed );
        }
Beispiel #46
0
        public virtual void Insert( Microblog blog, int i )
        {
            String rcontent = blog.Content;

            MicroblogBinder smbinder = new MicroblogBinder();

            MicroblogParser mp = new MicroblogParser( blog.Content, smbinder );
            mp.Process();

            blog.Content = mp.ToString();

            blog.Content = processEmotions( blog.Content );

            Result result = blog.insert();

            if( i==0 ) {

                // ����tag
                TagService.SaveDataTag( blog, mp.GetTagList() );

                // ��֪ͨ
                addNotification( smbinder.GetValidUsers(), blog );
            }

            // ת����Ҫˢ��ԭ����ת����
            if (blog.ParentId > 0) {
                Microblog parent = GetById( blog.ParentId );
                if (parent != null) {
                    parent.Reposts = Microblog.count( "ParentId=" + parent.Id );
                    parent.update( "Reposts" );
                }
            }

            if (result.IsValid) addFeedInfo( blog );
        }
Beispiel #47
0
        //--------------------------------------
        //public virtual void InsertBig( Microblog blog ) {
        //    List<String> arrContent = strUtil.SplitByNum( blog.Content, config.Instance.Site.MicroblogContentMax );
        //    for (int i = 0; i < arrContent.Count; i++) {
        //        saveMicroblogOther( blog, arrContent, i );
        //    }
        //}
        //private void saveMicroblogOther( Microblog ob, List<String> arrContent, int i ) {
        //    Microblog blog = new Microblog();
        //    if (arrContent.Count > 1) {
        //        blog.Content = "(" + (i + 1) + ")" + arrContent[i];
        //    }
        //    else {
        //        blog.Content = arrContent[i];
        //    }
        //    if (i == 0) {
        //        blog.Pic = ob.Pic;
        //        blog.FlashUrl = ob.FlashUrl;
        //        blog.PageUrl = ob.PageUrl;
        //        blog.PicUrl = ob.PicUrl;
        //    }
        //    blog.Ip = ob.Ip;
        //    blog.User = ob.User;
        //    Insert( blog, i );
        //}
        public virtual void Insert( Microblog blog )
        {
            blog.Content = strUtil.SubString( blog.Content, config.Instance.Site.MicroblogContentMax );

            Insert( blog, 0 );
        }
Beispiel #48
0
        private string getBlogContent( Microblog blog )
        {
            if (blog.ParentId <= 0) return blog.Content;

            String content = strUtil.HasText( blog.Content ) ? blog.Content : "ת��΢��";

            return content;
        }
Beispiel #49
0
 private int getParentId( Microblog tblog )
 {
     if (tblog.ParentId <= 0) return tblog.Id;
     return tblog.ParentId;
 }
        private long getDataId( Microblog x ) {

            if (x.DataType != null && x.DataType.Equals( typeof( Microblog ).FullName )) {
                return x.Id;
            }

            if (x.DataId <= 0) return x.Id;

            return x.DataId;
        }
Beispiel #51
0
        //--------------------------------------------------------------------------------------------------
        private void bindOne( IBlock block, Microblog blog, Boolean isFavorite, Boolean showUserFace )
        {
            block.Set( "blog.Id", blog.Id );
            block.Set( "blog.Created", blog.Created );

            if (ctx.GetItemString( "_showType" ) == "microblog") {
                block.Set( "blog.ShowLink", MbLink.ToShowMicroblog( blog.User, blog.Id ) );
            }
            else {
                block.Set( "blog.ShowLink", MbLink.ToShowFeed( blog.User, blog.Id ) );
            }

            block.Set( "blog.Content", getBlogContent( blog ) );

            bindUserInfo( block, ctx, blog, showUserFace ); // 用户信息
            bindRepost( block, blog ); // 转发信息
            bindPicInfo( block, blog ); // 图片信息
            bindVideoInfo( block, blog ); // 视频信息

            // 评论数
            block.Set( "blog.StrReplies", blog.Replies == 0 ? "" : string.Format( "<span class=\"feed-replies\">(<span class=\"feed-replies-num\" id=\"renum{1}\">{0}</span>)</span>", blog.Replies, blog.Id ) );

            block.Set( "blog.StrLikes", blog.Likes == 0 ? "" : string.Format( "<span class=\"feed-likes\">(<span class=\"feed-likes-num\">{0}</span>)</span>", blog.Likes ) );
            block.Set( "blog.SaveLikeLink", to( SaveLike, blog.Id ) );

            // 转发数
            String reposts = blog.Reposts > 0 ? "(" + blog.Reposts + ")" : "";
            block.Set( "blog.Reposts", reposts );

            block.Set( "blog.CommentsLink", getCommentUrl( blog ) );
            block.Set( "blog.ForwardUrl", to( Forward, blog.Id ) );
            block.Set( "blog.FavoriteCmd", getFavoriteCmd( blog, isFavorite ) ); // 收藏命令

            // 删除命令
            String deleteCmd = getDeleteCmd( ctx, blog );
            block.Set( "blog.DeleteCmd", deleteCmd );
        }
Beispiel #52
0
        private string getCommentUrl( Microblog x )
        {
            String dataType = strUtil.IsNullOrEmpty( x.DataType ) ? typeof( Microblog ).FullName : x.DataType;
            int dataId = x.DataId <= 0 ? x.Id : x.DataId;

            return t2( new wojilu.Web.Controller.Open.CommentController().List )
                + "?dataType=" + dataType
                + "&ownerId=" + x.User.Id
                + "&dataId=" + dataId
                + "&dataTitle=(微博" + x.Created.ToShortDateString() + ")" + strUtil.ParseHtml( x.Content, 25 )
                + "&url=" + MbLink.ToShow( x.User, x.Id )
                + "&dataUserId=" + x.Creator.Id
                + "&feedId=" + x.Id;
        }
Beispiel #53
0
 private static String getDeleteCmd( MvcContext ctx, Microblog blog )
 {
     String deleteCmd = "";
     if (ctx.viewer.Id == blog.User.Id || ctx.viewer.IsAdministrator()) {
         deleteCmd = string.Format( "<a href=\"{0}\" class=\"left10 ajaxDeleteCmd\" removeId=\"mblog{1}\">x</a>", Link.To( new Microblogs.MicroblogSaveController().Delete, blog.Id ), blog.Id );
     }
     return deleteCmd;
 }
Beispiel #54
0
        private void loadCommonView( Microblog blog )
        {
            List<Microblog> list = new List<Microblog>();
            list.Add( blog );
            List<MicroblogVo> volist = mfService.CheckFavorite( list, ctx.viewer.Id );

            ctx.SetItem( "_microblogVoList", volist );
            ctx.SetItem( "_showUserFace", false );
            load( "blogList", bindBlogs );
        }
Beispiel #55
0
        private string getFavoriteCmd( Microblog blog, Boolean isFavorite )
        {
            if (isFavorite) {
                return string.Format( "<span class=\"cancelFavorite link left10 right10\" to=\"{0}\">ȡ���ղ�</span>", to( CancelFavorite, blog.Id ) );
            }

            return string.Format( "<span class=\"addFavorite link left10 right10\" to=\"{0}\">�ղ�</span>", to( SaveFavorite, blog.Id ) );
        }
Beispiel #56
0
 public virtual void DeleteTrue( Microblog blog )
 {
     blog.delete();
 }
Beispiel #57
0
        private void saveComment( Microblog tblog, String content )
        {
            MicroblogComment c = new MicroblogComment();
            c.Root = tblog;
            c.Content = content;
            c.User = ctx.viewer.obj as User;
            c.Ip = ctx.Ip;

            commentService.InsertComment( c, to( new MicroblogController().Show, tblog.Id ) );
        }
Beispiel #58
0
        private void bindVideoInfo( IBlock block, Microblog blog )
        {
            IBlock vBlock = block.GetBlock( "video" );
            if (strUtil.HasText( blog.FlashUrl )) {

                String vpic = strUtil.HasText( blog.PicUrl ) ? blog.PicUrl : strUtil.Join( sys.Path.Img, "/big/novideopic.png" );

                vBlock.Set( "blog.FlashPic", vpic );
                vBlock.Set( "blog.ShowLink", MbLink.ToShowFeed( blog.User, blog.Id ) );

                vBlock.Next();
            }
        }
Beispiel #59
0
        //--------------------------------------------------------------------------------------------------
        private void bindOne( IBlock block, Microblog blog, Boolean isFavorite, Boolean showUserFace )
        {
            block.Set( "blog.Id", blog.Id );
            block.Set( "blog.Created", blog.Created );

            block.Set( "blog.ShowLink", Link.To( blog.User, Show, blog.Id ) );

            block.Set( "blog.Content", getBlogContent( blog ) );

            bindUserInfo( block, blog, showUserFace ); // �û���Ϣ
            bindRepost( block, blog ); // ת����Ϣ
            bindPicInfo( block, blog ); // ͼƬ��Ϣ
            bindVideoInfo( block, blog ); // ��Ƶ��Ϣ

            // ������
            String replies = blog.Replies > 0 ? "(" + blog.Replies + ")" : "";
            block.Set( "blog.Replies", replies );

            // ת����
            String reposts = blog.Reposts > 0 ? "(" + blog.Reposts + ")" : "";
            block.Set( "blog.Reposts", reposts );

            block.Set( "blog.CommentsLink", to( new MicroblogCommentsController().Show, blog.Id ) );
            block.Set( "blog.ForwardUrl", to( Forward, blog.Id ) );
            block.Set( "blog.FavoriteCmd", getFavoriteCmd( blog, isFavorite ) ); // �ղ�����

            // ɾ������
            String deleteCmd = "";
            if (ctx.viewer.Id == blog.User.Id) {
                deleteCmd = string.Format( "<a href=\"{0}\" class=\"left10 ajaxDeleteCmd\" removeId=\"mblog{1}\">ɾ��</a>", to( new Microblogs.My.MicroblogController().Delete, blog.Id ), blog.Id );
            }
            block.Set( "blog.DeleteCmd", deleteCmd );
        }
Beispiel #60
0
        private void bindRepost( IBlock block, Microblog blog )
        {
            // ת��������
            if (blog.ParentId > 0) {

                Microblog parent = microblogService.GetById( blog.ParentId );
                if (parent == null) {
                    block.Set( "blog.ForwardContent", "<div class=\"mblogSingle\">��΢���ѱ�ԭ����ɾ��</div>" );
                }
                else {
                    block.Set( "blog.ForwardContent", loadHtml( Single, blog.ParentId ) );
                }
            }
            else {
                block.Set( "blog.ForwardContent", "" );
            }
        }