Ejemplo n.º 1
0
        public void SetLogo(int postId)
        {
            ContentPost post = postService.GetById(postId, ctx.owner.Id);

            if (post == null)
            {
                echoRedirect(lang("exDataNotFound"));
                return;
            }

            int imgId = ctx.GetInt("imgId");

            ContentImg img = imgService.GetImgById(imgId);

            if (img == null)
            {
                echoRedirect(alang("exImgFound"));
                return;
            }

            post.ImgLink = img.ImgUrl;
            imgService.UpdateImgLogo(post);

            echoRedirect(lang("opok"));
        }
Ejemplo n.º 2
0
 public virtual void DeleteImgOne( ContentImg articleImg )
 {
     db.delete( articleImg );
     Img.DeleteImgAndThumb( strUtil.Join( sys.Path.DiskPhoto, articleImg.ImgUrl ) );
     if (articleImg.ImgUrl.Equals( articleImg.Post.ImgLink )) {
         this.setPreImgLogo( articleImg );
     }
 }
Ejemplo n.º 3
0
 public virtual void DeleteImgOne(ContentImg articleImg)
 {
     db.delete(articleImg);
     Img.DeleteImgAndThumb(strUtil.Join(sys.Path.DiskPhoto, articleImg.ImgUrl));
     if (articleImg.ImgUrl.Equals(articleImg.Post.ImgLink))
     {
         this.setPreImgLogo(articleImg);
     }
 }
Ejemplo n.º 4
0
        private String getSetLogoCmd(ContentPost post, ContentImg img)
        {
            if (img.ImgUrl.Equals(post.ImgLink))
            {
                return("<span style='font-weight:bold;color:red;'>" + alang("currentCover") + "</span>");
            }

            return(string.Format("<a href='{0}' class=\"putCmd cmd\">" + alang("setCover") + "</a>", to(SetLogo, post.Id) + "?imgId=" + img.Id));
        }
Ejemplo n.º 5
0
 private void setNextImgLogo( ContentImg articleImg ) {
     ContentImg img = db.find<ContentImg>( "Id>" + articleImg.Id + " order by Id" ).first();
     if (img != null) {
         articleImg.Post.ImgLink = img.ImgUrl;
         this.UpdateImgLogo( articleImg.Post );
     }
     else {
         articleImg.Post.ImgLink = "";
         this.UpdateImgLogo( articleImg.Post );
     }
 }
Ejemplo n.º 6
0
        private void saveLinkPicSingle(string picUrl, string picDesc, ContentPost post, int i)
        {
            ContentImg img = new ContentImg();

            img.Post        = post;
            img.ImgUrl      = picUrl;
            img.Description = picDesc;
            imgService.CreateImg(img);
            if ((i == 1) && post.HasImg() == false)
            {
                post.ImgLink = img.ImgUrl;
                imgService.UpdateImgLogo(post);
            }
        }
Ejemplo n.º 7
0
        public void CreateImgList(int postId)
        {
            ContentPost post = postService.GetById(postId, ctx.owner.Id);

            if (post == null)
            {
                echoRedirect(lang("exDataNotFound"));
                return;
            }

            if (ctx.GetFiles().Count <= 0)
            {
                errors.Add(alang("plsUpImg"));
                run(AddImgList, postId);
                return;
            }

            for (int i = 0; i < ctx.GetFiles().Count; i++)
            {
                Result result = Uploader.SaveImg(ctx.GetFiles()[i]);
                if (result.HasErrors)
                {
                    errors.Join(result);
                }
                else
                {
                    ContentImg img = new ContentImg();
                    img.Post        = post;
                    img.ImgUrl      = result.Info.ToString();
                    img.Description = ctx.Post("Text" + (i + 1));
                    imgService.CreateImg(img);
                    if ((i == 0) && post.HasImg() == false)
                    {
                        post.ImgLink = img.ImgUrl;
                        imgService.UpdateImgLogo(post);
                    }
                }
            }

            if (errors.Errors.Count >= ctx.GetFiles().Count)
            {
                errors.Errors.Clear();
                errors.Add(alang("plsUpImg"));
                run(AddImgList, postId);
            }
            else
            {
                redirect(AddImgList, postId);
            }
        }
Ejemplo n.º 8
0
        public void DeleteImg(int imgId)
        {
            ContentImg img = imgService.GetImgById(imgId);

            if (img == null)
            {
                echoRedirect(alang("exImgFound"));
                return;
            }

            imgService.DeleteImgOne(img);

            echoRedirect(lang("opok"));
        }
Ejemplo n.º 9
0
        private void setNextImgLogo(ContentImg articleImg)
        {
            ContentImg img = db.find <ContentImg>("Id>" + articleImg.Id + " order by Id").first();

            if (img != null)
            {
                articleImg.Post.ImgLink = img.ImgUrl;
                this.UpdateImgLogo(articleImg.Post);
            }
            else
            {
                articleImg.Post.ImgLink = "";
                this.UpdateImgLogo(articleImg.Post);
            }
        }
Ejemplo n.º 10
0
        public void SetLogo(int imgId)
        {
            ContentImg img = imgService.GetImgById(imgId);

            if (img == null)
            {
                echoRedirect(alang("exImgFound"));
                return;
            }

            ContentPost post = img.Post;

            post.ImgLink = img.ImgUrl;
            imgService.UpdateImgLogo(post);

            echoRedirect(lang("opok"));
        }
Ejemplo n.º 11
0
        private void saveUploadPic(long postId, ContentPost post)
        {
            if (ctx.GetFiles().Count <= 0)
            {
                errors.Add(alang("plsUpImg"));
                run(AddImgList, postId);
                return;
            }

            for (int i = 0; i < ctx.GetFiles().Count; i++)
            {
                Result result = Uploader.SaveImg(ctx.GetFiles()[i]);
                if (result.HasErrors)
                {
                    errors.Join(result);
                }
                else
                {
                    ContentImg img = new ContentImg();
                    img.Post        = post;
                    img.ImgUrl      = result.Info.ToString();
                    img.Description = ctx.Post("Text" + (i + 1));
                    imgService.CreateImg(img);
                    if ((i == 0) && post.HasImg() == false)
                    {
                        post.ImgLink = img.ImgUrl;
                        imgService.UpdateImgLogo(post);
                    }
                }
            }

            if (errors.Errors.Count >= ctx.GetFiles().Count)
            {
                errors.Errors.Clear();
                errors.Add(alang("plsUpImg"));
                run(AddImgList, postId);
            }
            else
            {
                redirect(AddImgList, postId);
            }
        }
Ejemplo n.º 12
0
        public void DeleteImg(int postId)
        {
            ContentPost post = postService.GetById(postId, ctx.owner.Id);

            if (post == null)
            {
                echoRedirect(lang("exDataNotFound"));
                return;
            }

            int        imgId = ctx.GetInt("imgId");
            ContentImg img   = imgService.GetImgById(imgId);

            if (img == null)
            {
                echoRedirect(alang("exImgFound"));
                return;
            }

            imgService.DeleteImgOne(img);

            echoRedirect(lang("opok"));
            HtmlHelper.SetPostToContext(ctx, post);
        }
Ejemplo n.º 13
0
        private void saveLinkPicSingle( string picUrl, string picDesc, ContentPost post, int i ) {

            ContentImg img = new ContentImg();
            img.Post = post;
            img.ImgUrl = picUrl;
            img.Description = picDesc;
            imgService.CreateImg( img );
            if ((i == 1) && post.HasImg() == false) {
                post.ImgLink = img.ImgUrl;
                imgService.UpdateImgLogo( post );
            }
        }
Ejemplo n.º 14
0
        private void saveUploadPic( long postId, ContentPost post ) {

            if (ctx.GetFiles().Count <= 0) {
                errors.Add( alang( "plsUpImg" ) );
                run( AddImgList, postId );
                return;
            }

            for (int i = 0; i < ctx.GetFiles().Count; i++) {
                Result result = Uploader.SaveImg( ctx.GetFiles()[i] );
                if (result.HasErrors) {
                    errors.Join( result );
                }
                else {
                    ContentImg img = new ContentImg();
                    img.Post = post;
                    img.ImgUrl = result.Info.ToString();
                    img.Description = ctx.Post( "Text" + (i + 1) );
                    imgService.CreateImg( img );
                    if ((i == 0) && post.HasImg() == false) {
                        post.ImgLink = img.ImgUrl;
                        imgService.UpdateImgLogo( post );
                    }
                }
            }

            if (errors.Errors.Count >= ctx.GetFiles().Count) {
                errors.Errors.Clear();
                errors.Add( alang( "plsUpImg" ) );
                run( AddImgList, postId );
            }
            else {
                redirect( AddImgList, postId );
            }
        }
Ejemplo n.º 15
0
        public void CreateImgList( int postId )
        {
            ContentPost post = postService.GetById( postId, ctx.owner.Id );
            if (post == null) {
                echoRedirect( lang( "exDataNotFound" ) );
                return;
            }

            if (ctx.GetFiles().Count <= 0) {
                errors.Add( alang( "plsUpImg" ) );
                run(AddImgList, postId );
                return;
            }

            for (int i = 0; i < ctx.GetFiles().Count; i++) {
                Result result = Uploader.SaveImg( ctx.GetFiles()[i] );
                if (result.HasErrors) {
                    errors.Join( result );
                }
                else {
                    ContentImg img = new ContentImg();
                    img.Post = post;
                    img.ImgUrl = result.Info.ToString();
                    img.Description = ctx.Post( "Text" + (i + 1) );
                    imgService.CreateImg( img );
                    if ((i == 0) && post.HasImg()==false) {
                        post.ImgLink = img.ImgUrl;
                        imgService.UpdateImgLogo( post );
                    }
                }
            }

            if (errors.Errors.Count >= ctx.GetFiles().Count) {
                errors.Errors.Clear();
                errors.Add( alang( "plsUpImg" ) );
                run( AddImgList, postId );
            }
            else {
                redirect( AddImgList, postId );
            }
        }
Ejemplo n.º 16
0
 public virtual void CreateImg( ContentImg img )
 {
     db.insert( img );
 }
Ejemplo n.º 17
0
        private String getSetLogoCmd( ContentPost post, ContentImg img )
        {
            if (img.ImgUrl.Equals( post.ImgLink )) {
                return "<span style='font-weight:bold;color:red;'>" + alang( "currentCover" ) + "</span>";
            }

            return string.Format( "<a href='{0}' class=\"putCmd cmd\">" + alang( "setCover" ) + "</a>", to( SetLogo, post.Id ) + "?imgId=" + img.Id );
        }
Ejemplo n.º 18
0
 public virtual void CreateImg(ContentImg img)
 {
     db.insert(img);
 }