コード例 #1
0
        public ActionResult Gallery(int id, int page = 1)
        {
            if (page == 0)
            {
                return(RedirectToAction("PageNotFound", "Common"));
            }
            ViewBag.GalleryId = id;
            var model = new PublicInfoGalleryModel();

            model.ShowGallery = _gallerySettings.ShowGalleries;
            if (!_gallerySettings.SliderGallery)
            {
                var images = _galleryService.GetGalleryImagesPagesByGalleryId(id, page, _gallerySettings.ItemPerPage);

                foreach (var image in images)
                {
                    var alt = image.GetLocalized(x => x.Description) != null
                                  ? image.GetLocalized(x => x.Description).Replace("<p>", "").Replace("</p>", "")
                                  : "";

                    model.ImageModel.Add(new ImageModel
                    {
                        ShareImage = _gallerySettings.ShareImage,
                        Id         = image.Id,
                        ImageGalleryPictureModel = new PictureModel
                        {
                            FullSizeImageUrl = _pictureService.GetPictureUrl(image.PictureId),
                            ImageUrl         = _pictureService.GetPictureUrl(image.PictureId, GalleryThumbPictureSize),
                            Title            = image.GetLocalized(x => x.Name),
                            AlternateText    = alt,
                        }
                    });
                }
                return
                    (View("~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/List.cshtml", model));
            }
            else
            {
                var gallery = _galleryService.GetGalleryById(id);
                if (gallery.SimpleGallery)
                {
                    var images = _galleryService.GetGalleryImagesByGalleryId(id);
                    foreach (var image in images)
                    {
                        var alt = image.GetLocalized(x => x.Description) != null
                                      ? image.GetLocalized(x => x.Description).Replace("<p>", "").Replace("</p>", "")
                                      : "";

                        model.ImageModel.Add(new ImageModel
                        {
                            ShareImage = _gallerySettings.ShareImage,
                            Id         = image.Id,
                            ImageGalleryPictureModel = new PictureModel
                            {
                                FullSizeImageUrl = _pictureService.GetPictureUrl(image.PictureId),
                                ImageUrl         = _pictureService.GetPictureUrl(image.PictureId, GalleryThumbPictureSize),
                                Title            = image.GetLocalized(x => x.Name),
                                AlternateText    = alt,
                            }
                        });
                    }
                    return
                        (View("~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/GalleriaList.cshtml", model));
                }
                if (gallery.FlickrGallery)
                {
                    ViewBag.FlickrKeysords = gallery.FlickrKeyword;
                    return(View("~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/FlickrList.cshtml"));
                }
                if (gallery.PicasaGallery)
                {
                    ViewBag.PicasaKeyword = gallery.PicasaKeyword;
                    return(View("~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/PicasaList.cshtml"));
                }
                if (gallery.VideoGallery)
                {
                    var videoLinks = new List <string>();
                    if (gallery.VideoLink != null)
                    {
                        videoLinks = gallery.VideoLink.Split(new[] { "%,%" }, StringSplitOptions.None).ToList();
                    }
                    return(View("~/Plugins/Widgets.Gallery/Views/GalleryPublicInfo/VideoList.cshtml", videoLinks));
                }
                return(null);
            }
        }