public ActionResult MediaItems(int id, int skip = 0, int count = 0) {
            var mediaParts = _mediaLibraryService.GetMediaContentItemsForLocation(id, skip, count);
            var mediaPartsCount = _mediaLibraryService.GetMediaContentItemsCountForLocation(id);

            var mediaItems = mediaParts.Select(x => new MediaManagerMediaItemViewModel {
                MediaPart = x,
                Shape = Services.ContentManager.BuildDisplay(x, "Thumbnail")
            }).ToList();

            var viewModel = new MediaManagerMediaItemsViewModel {
                MediaItems = mediaItems,
                MediaItemsCount = mediaPartsCount
            };

            return View(viewModel);
        }
Пример #2
0
        public ActionResult MediaItems(string folderPath, int skip = 0, int count = 0, string order = "created", string mediaType = "", string search = "")
        {
            var builder = _indexProvider.CreateSearchBuilder("Media");

            if (!String.IsNullOrEmpty(search)) {
                builder.WithField("title", search);
                builder.WithField("author", search);
                builder.WithField("media-caption", search);
                builder.WithField("media-alternatetext", search);
                builder.WithField("media-filename", search);
            }

            if (!String.IsNullOrEmpty(mediaType)) {
                builder.WithField("type", mediaType).Mandatory().AsFilter();
            }

            if (!String.IsNullOrEmpty(folderPath)) {
                var path = folderPath.Replace("\\", "/");
                builder.WithField("media-folderpath", path.ToLowerInvariant()).AsFilter();
            }

            builder.SortBy(order);

            if (order == "title") {
                builder.Ascending();
            }

            var mediaPartsCount = builder.Count();
            var contentItemIds = builder.Slice(skip, count).Search().Select(x => x.ContentItemId).ToArray();
            var mediaParts = _contentManager.GetMany<MediaPart>(contentItemIds, VersionOptions.Published, QueryHints.Empty);

            var mediaItems = mediaParts.Select(x => new MediaManagerMediaItemViewModel {
                MediaPart = x,
                Shape = _contentManager.BuildDisplay(x, "Thumbnail")
            }).ToList();

            var viewModel = new MediaManagerMediaItemsViewModel {
                MediaItems = mediaItems,
                MediaItemsCount = mediaPartsCount
            };

            return View(viewModel);
        }
        public ActionResult MediaItems(string folderPath, int skip = 0, int count = 0, string order = "created", string mediaType = "") {
            if (!Services.Authorizer.Authorize(Permissions.ManageOwnMedia, T("Cannot view media")))
                return new HttpUnauthorizedResult();

            // Check permission.var rootMediaFolder = _mediaLibraryService.GetRootMediaFolder();
            if (!Services.Authorizer.Authorize(Permissions.ManageMediaContent) && !_mediaLibraryService.CanManageMediaFolder(folderPath)) {
                var model = new MediaManagerMediaItemsViewModel {
                    MediaItems = new List<MediaManagerMediaItemViewModel>(),
                    MediaItemsCount = 0,
                    FolderPath = folderPath
                };

                return View(model);
            }
            
            var mediaParts = _mediaLibraryService.GetMediaContentItems(folderPath, skip, count, order, mediaType, VersionOptions.Latest);
            var mediaPartsCount = _mediaLibraryService.GetMediaContentItemsCount(folderPath, mediaType, VersionOptions.Latest);

            var mediaItems = mediaParts.Select(x => new MediaManagerMediaItemViewModel {
                MediaPart = x,
                Shape = Services.ContentManager.BuildDisplay(x.ContentItem, "Thumbnail")
            }).ToList();

            var viewModel = new MediaManagerMediaItemsViewModel {
                MediaItems = mediaItems,
                MediaItemsCount = mediaPartsCount,
                FolderPath = folderPath
            };

            return View(viewModel);
        }
        public ActionResult RecentMediaItems(int skip = 0, int count = 0, string order = "created", string mediaType = "") {
            if (!Services.Authorizer.Authorize(Permissions.ManageOwnMedia, T("Cannot view media")))
                return new HttpUnauthorizedResult();

            var rootMediaFolder = _mediaLibraryService.GetRootMediaFolder();
            var rootMediaFolderPath = rootMediaFolder == null ? null : rootMediaFolder.MediaPath;
            var mediaParts = _mediaLibraryService.GetMediaContentItems(rootMediaFolderPath, skip, count, order, mediaType);
            var mediaPartsCount = _mediaLibraryService.GetMediaContentItemsCount(rootMediaFolderPath, mediaType);


            var mediaItems = mediaParts.Select(x => new MediaManagerMediaItemViewModel {
                MediaPart = x,
                Shape = Services.ContentManager.BuildDisplay(x, "Thumbnail")
            }).ToList();

            var viewModel = new MediaManagerMediaItemsViewModel {
                MediaItems = mediaItems,
                MediaItemsCount = mediaPartsCount
            };

            return View("MediaItems", viewModel);
        }
Пример #5
0
        public ActionResult MediaItems(string folderPath, int skip = 0, int count = 0, string order = "created", string mediaType = "") {
            var mediaParts = _mediaLibraryService.GetMediaContentItems(folderPath, skip, count, order, mediaType);
            var mediaPartsCount = _mediaLibraryService.GetMediaContentItemsCount(folderPath, mediaType);

            var mediaItems = mediaParts.Select(x => new MediaManagerMediaItemViewModel {
                MediaPart = x,
                Shape = Services.ContentManager.BuildDisplay(x.ContentItem, "Thumbnail")
            }).ToList();

            var viewModel = new MediaManagerMediaItemsViewModel {
                MediaItems = mediaItems,
                MediaItemsCount = mediaPartsCount
            };

            return View(viewModel);
        }