예제 #1
0
파일: Albums.cs 프로젝트: terryxym/DiscuzNT
        /// <summary>
        /// 相册相关页面的弹出导航菜单HTML内容
        /// </summary>
        /// <returns></returns>
        public static string GetPhotoListMenuDivCache()
        {
            string val = DNTCache.GetCacheService().RetrieveObject("/Photo/AlbumCategoryMenu") as string;

            if (val != null)
            {
                return(val);
            }

            StringBuilder sb = new StringBuilder();

            Discuz.Common.Generic.List <AlbumCategoryInfo> acic = DTOProvider.GetAlbumCategory();
            if (acic.Count > 0)
            {
                sb.Append("<div id=\"NavHome_menu\" class=\"NavHomeMenu\" style=\"display:none\"><div id=\"NavHomeWindow\"><ul>");
                foreach (AlbumCategoryInfo aci in acic)
                {
                    sb.AppendLine("<li><a href=\"showalbumlist.aspx?cate=");
                    sb.AppendLine(aci.Albumcateid.ToString());
                    sb.Append("\">");
                    sb.AppendLine(aci.Title);
                    sb.AppendLine("</a></li>");
                }
                sb.Append("</ul></div></div>");
            }

            DNTCache.GetCacheService().AddObject("/Photo/AlbumCategoryMenu", sb.ToString());
            return(sb.ToString());
        }
예제 #2
0
        protected override void ShowPage()
        {
            if (config.Enablealbum != 1)
            {
                AddErrLine("相册功能已被关闭");
                return;
            }
            pagetitle        = "图片排行";
            announcementlist = Announcements.GetAnnouncementList(Utils.GetDateTime(), "2999-01-01 00:00:00");
            if (announcementlist != null)
            {
                announcementcount = announcementlist.Rows.Count;
            }

            type = type < 0 ? 0 : type;
            type = type > 3 ? 3 : type;

            if (type < 3)
            {
                photolist = DTOProvider.GetPhotoRankList(type, photocount);
            }
            else
            {
                albumlist = DTOProvider.GetAlbumRankList(photocount);
            }

            //一周热图总排行
            weekhotphotolist = AggregationFacade.AlbumAggregation.GetWeekHotPhotoList(photoconfig.Weekhot);
            //相册分类
            albumcategorylist     = DTOProvider.GetAlbumCategory();
            recentupdatespaceList = AggregationFacade.SpaceAggregation.GetRecentUpdateSpaceList(AggregationConfig.GetConfig().RecentUpdateSpaceAggregationListCount);
        }
예제 #3
0
        protected override void ShowPage()
        {
            pagetitle = config.Albumname + "首页";

            if (config.Enablealbum != 1)
            {
                AddErrLine("相册功能已被关闭");
                return;
            }

            if (config.Rssstatus == 1)
            {
                AddLinkRss("tools/photorss.aspx", "最新图片");
            }

            announcementlist = Announcements.GetAnnouncementList(Utils.GetDateTime(), "2999-01-01 00:00:00");

            if (announcementlist != null)
            {
                announcementcount = announcementlist.Rows.Count;
            }

            //轮显图片
            rotatepicdata = AggregationFacade.AlbumAggregation.GetRotatePicData();

            //推荐图片
            recommendphotolist = AggregationFacade.AlbumAggregation.GetRecommandPhotoList("Albumindex");
            //焦点图片
            focusphotolist = AggregationFacade.AlbumAggregation.GetFocusPhotoList(photoconfig.Focusphotoshowtype, photoconfig.Focusphotocount, photoconfig.Focusphotodays);
            //推荐相册
            recommendalbumlist = AggregationFacade.AlbumAggregation.GetRecommandAlbumList("Albumindex");
            //焦点相册
            focusalbumlist = AggregationFacade.AlbumAggregation.GetAlbumList(photoconfig.Focusalbumshowtype, photoconfig.Focusalbumcount, photoconfig.Focusalbumdays);
            //一周热图总排行
            weekhotphotolist = AggregationFacade.AlbumAggregation.GetWeekHotPhotoList(photoconfig.Weekhot);
            //相册分类
            albumcategorylist = DTOProvider.GetAlbumCategory();

            if (config.Enablespace == 1)
            {
                recentupdatespaceList = AggregationFacade.SpaceAggregation.GetRecentUpdateSpaceList(AggregationConfig.GetConfig().RecentUpdateSpaceAggregationListCount);
            }
        }
예제 #4
0
 protected void DataGrid1_EditCommand(object source, DataGridCommandEventArgs e)
 {
     #region 加载编辑分类
     if (this.CheckCookie())
     {
         //编辑一个分类
         BindData();
         int albumcateid = Utils.StrToInt(DataGrid1.DataKeys[e.Item.ItemIndex], 0);
         if (albumcateid > 0)
         {
             AlbumCategoryInfo aci = DTOProvider.GetAlbumCategory(albumcateid);
             this.albumcateTitle.Text = aci.Title;
             this.description.Text    = aci.Description;
             this.displayorder.Text   = aci.Displayorder.ToString();
         }
         prompt.Text = "编辑相册分类";
     }
     #endregion
 }
예제 #5
0
        protected override void ShowPage()
        {
            if (config.Enablealbum != 1)
            {
                AddErrLine("相册功能已被关闭");
                return;
            }

            forumpath = BaseConfigs.GetForumPath;
            if (albumid < 1)
            {
                AddErrLine("指定的相册不存在");
                return;
            }

            album = DTOProvider.GetAlbumInfo(albumid);
            if (album == null)
            {
                AddErrLine("指定的相册不存在");
                return;
            }

            if (config.Rssstatus == 1)
            {
                if (GeneralConfigs.GetConfig().Aspxrewrite == 1)
                {
                    photorssurl = string.Format("photorss-{0}{1}", album.Userid, GeneralConfigs.GetConfig().Extname);
                }
                else
                {
                    photorssurl = string.Format("rss.aspx?uid={0}&type=photo", album.Userid);
                }

                AddLinkRss(string.Format("tools/{0}", photorssurl), "最新图片");
            }

            pagetitle = album.Title;

            //权限验证部分,私有相册,不是相册所有者
            if (album.Type == 1 && album.Userid != userid)
            {
                if (ForumUtils.GetCookie("album" + albumid + "password") != Utils.MD5(album.Password))
                {
                    //首先验证Cookie中如果相册密码不正确,则要求输入密码,并以输入值验证
                    string password = DNTRequest.GetFormString("albumpassword");
                    if (album.Password == password)
                    {
                        ForumUtils.WriteCookie("album" + albumid + "password", Utils.MD5(password));
                        needpassword = false;
                    }
                }
                else
                {
                    needpassword = false;
                }
            }
            else
            {
                needpassword = false;
            }

            if (Utils.InArray(usergroupid.ToString(), config.Photomangegroups))
            {
                needpassword = false;
            }

            albumcategory = DTOProvider.GetAlbumCategory(album.Albumcateid);
            photoscount   = DTOProvider.GetSpacePhotosCount(albumid);

            pageCount = photoscount % pageSize == 0 ? photoscount / pageSize : photoscount / pageSize + 1;

            if (pageCount == 0)
            {
                pageCount = 1;
            }

            if (currentpage < 1)
            {
                currentpage = 1;
            }

            if (currentpage > pageCount)
            {
                currentpage = pageCount;
            }

            pagenumbers = Utils.GetPageNumbers(currentpage, pageCount, string.Format("showalbum.aspx?albumid={0}", albumid), 8);
            photolist   = DTOProvider.GetSpacePhotosInfo(DbProvider.GetInstance().SpacePhotosList(pageSize, currentpage, album.Userid, album.Albumid));

            foreach (PhotoInfo photo in photolist)
            {
                //当是远程照片时
                if (photo.Filename.IndexOf("http") < 0)
                {
                    photo.Filename = forumpath + Globals.GetThumbnailImage(photo.Filename);
                }
                else
                {
                    photo.Filename = Globals.GetThumbnailImage(photo.Filename);
                }
            }

            if (photolist.Count == 0)
            {
                AddMsgLine("暂无图片");
            }

            ForumUtils.WriteCookie("referer", string.Format("showalbum.aspx?albumid={0}&page={1}", albumid, currentpage));
        }
예제 #6
0
        protected override void ShowPage()
        {
            pagetitle = "相册列表";

            if (config.Enablealbum != 1)
            {
                AddErrLine("相册功能已被关闭");
                return;
            }

            if (albumsuserid == -1 && userid != -1)
            {
                albumsuserid = userid;
            }

            if (currentcate != 0)
            {
                currentalbumcategory = DTOProvider.GetAlbumCategory(currentcate);
                pagetitle            = currentalbumcategory.Title;
            }
            if (albumsuserid != 0)
            {
                ShortUserInfo shortUserInfo = Users.GetShortUserInfo(albumsuserid);
                albumusername = shortUserInfo == null ? "" : shortUserInfo.Username;
                pagetitle     = albumusername + "的" + pagetitle;
            }

            albumscount = DTOProvider.GetSpaceAlbumListCount(albumsuserid, currentcate);
            pagecount   = albumscount % pageSize == 0 ? albumscount / pageSize : albumscount / pageSize + 1;
            if (pagecount == 0)
            {
                pagecount = 1;
            }

            if (currentpage < 1)
            {
                currentpage = 1;
            }

            if (currentpage > pagecount)
            {
                currentpage = pagecount;
            }

            string parm = string.Empty;

            if (currentcate != 0)
            {
                parm = "cate=" + currentcate;
                if (albumsuserid != 0)
                {
                    parm += "&uid=" + albumsuserid;
                }
            }
            else if (albumsuserid != 0)
            {
                parm += "uid=" + albumsuserid;
            }

            if (parm != string.Empty)
            {
                parm += "&page=";
            }
            else
            {
                parm += "page=";
            }

            if (currentpage > 1)
            {
                prevpage = "<a href='showalbumlist.aspx?" + parm + (currentpage - 1) + "'>上一页</a>";
            }

            if (currentpage < pagecount)
            {
                nextpage = "<a href='showalbumlist.aspx?" + parm + (currentpage + 1) + "'>下一页</a>";
            }

            pagenumbers = Utils.GetPageNumbers(currentpage, pagecount, "showalbumlist.aspx", 8);
            albumlist   = DTOProvider.GetSpaceAlbumList(albumsuserid, currentcate, pageSize, currentpage);

            if (albumlist.Count == 0)
            {
                AddMsgLine("暂无相册");
            }
        }
예제 #7
0
        protected override void ShowPage()
        {
            if (config.Enablealbum != 1)
            {
                AddErrLine("相册功能已被关闭");
                return;
            }

            //一周热图总排行
            weekhotphotolist = AggregationFacade.AlbumAggregation.GetWeekHotPhotoList(photoconfig.Weekhot);
            string go = DNTRequest.GetString("go");

            switch (go)
            {
            case "prev":
                mode = 1;
                break;

            case "next":
                mode = 2;
                break;

            default:
                mode = 0;
                break;
            }

            if (photoid < 1)
            {
                AddErrLine("指定的图片不存在");
                return;
            }

            photo = DTOProvider.GetPhotoInfo(photoid, 0, 0);
            if (photo == null)
            {
                AddErrLine("指定的图片不存在");
                return;
            }

            album = DTOProvider.GetAlbumInfo(photo.Albumid);
            if (album == null)
            {
                AddErrLine("指定的相册不存在");
                return;
            }

            if (mode != 0)
            {
                photo = DTOProvider.GetPhotoInfo(photoid, photo.Albumid, mode);
                if (photo == null)
                {
                    AddErrLine("指定的图片不存在");
                    return;
                }
            }

            if (config.Rssstatus == 1)
            {
                if (GeneralConfigs.GetConfig().Aspxrewrite == 1)
                {
                    photorssurl = string.Format("photorss-{0}{1}", photo.Userid, GeneralConfigs.GetConfig().Extname);
                }
                else
                {
                    photorssurl = string.Format("rss.aspx?uid={0}&type=photo", photo.Userid);
                }

                AddLinkRss(string.Format("tools/{0}", photorssurl), "最新图片");
            }

            comments  = DTOProvider.GetPhotoCommentCollection(photo.Photoid);
            pagetitle = photo.Title;

            //权限验证部分,私有相册,不是相册所有者
            if (album.Type == 1 && album.Userid != userid)
            {
                if (ForumUtils.GetCookie("album" + photo.Albumid + "password") != Utils.MD5(album.Password))
                {
                    //首先验证Cookie中如果相册密码不正确,则要求输入密码,并以输入值验证
                    string password = DNTRequest.GetFormString("albumpassword");
                    if (album.Password == password)
                    {
                        ForumUtils.WriteCookie("album" + photo.Albumid + "password", Utils.MD5(password));
                        needpassword = false;
                    }
                }
                else
                {
                    needpassword = false;
                }
            }
            else
            {
                needpassword = false;
            }

            if (Utils.InArray(usergroupid.ToString(), config.Photomangegroups))
            {
                needpassword = false;
            }

            albumcategory = DTOProvider.GetAlbumCategory(album.Albumcateid);
            jsonfilename  = "cache/album/" + (album.Albumid / 1000 + 1).ToString() + "/" + album.Albumid.ToString() + "_json.txt";

            //非图片所有者时更新图片浏览量
            if (userid != photo.Userid)
            {
                DTOProvider.UpdatePhotoViews(photoid);
            }

            //判断权限
            {
                switch (photo.Commentstatus)
                {
                case PhotoStatus.Owner:
                    if (userid != photo.Userid)
                    {
                        commentable = false;
                    }
                    break;
                }
                if (userid < 1)
                {
                    commentable = false;
                }

                //重构时加入指定管理用户组
                if (userid == photo.Userid || Utils.InArray(usergroupid.ToString(), config.Photomangegroups))
                {
                    editable = true;
                }
            }

            // 如果评论数不同步则同步
            if (photo.Comments != comments.Count)
            {
                DbProvider.GetInstance().UpdatePhotoComments(photo.Photoid, comments.Count - photo.Comments);//更新评论数
            }
            if (ispost)
            {
                string message = DNTRequest.GetFormString("message").Trim();
                int    delcid  = DNTRequest.GetFormInt("delcommentid", 0);
                if (message != string.Empty)
                {
                    SavePhotoComment(message);
                    return;
                }
                else if (delcid > 0)
                {
                    if (editable)
                    {
                        DbProvider.GetInstance().DeletePhotoComment(delcid);
                        //更新评论数
                        DbProvider.GetInstance().UpdatePhotoComments(photo.Photoid, -1);
                        AddMsgLine("删除成功!");
                        SetUrl("showphoto.aspx?photoid=" + photo.Photoid);
                        SetMetaRefresh();
                        return;
                    }
                }
                AddErrLine("非法操作");
                SetMetaRefresh();
            }
        }