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 MediaItems(string folderPath, int skip = 0, int count = 0, string order = "created", string mediaType = "") { var mediaParts = _mediaLibraryService.GetMediaContentItems(folderPath, skip, count, order, mediaType, Services.WorkContext.CurrentUser); 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)); }
public ActionResult MediaItems(string folderPath, int skip = 0, int count = 0, string order = "created", string mediaType = "") { if (!Services.Authorizer.Authorize(Permissions.ManageMediaContent, T("Cannot view media"))) { return(new HttpUnauthorizedResult()); } 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)); }
public ActionResult MediaItems(string folderPath, int skip = 0, int count = 0, string order = "created", string mediaType = "") { if (!_mediaLibraryService.CheckMediaFolderPermission(Permissions.SelectMediaContent, folderPath)) { Services.Notifier.Add(UI.Notify.NotifyType.Error, T("Cannot select media")); var model = new MediaManagerMediaItemsViewModel { MediaItems = new List <MediaManagerMediaItemViewModel>(), MediaItemsCount = 0, FolderPath = folderPath }; return(View(model)); } // Check permission if (!_mediaLibraryService.CheckMediaFolderPermission(Permissions.SelectMediaContent, folderPath) && !_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 MediaItems(string folderPath, int skip = 0, int count = 0, string order = "created", string mediaType = "", string culture = "") { if (String.IsNullOrWhiteSpace(folderPath)) { folderPath = null; } if (!_mediaLibraryService.CheckMediaFolderPermission(Permissions.SelectMediaContent, folderPath)) { Services.Notifier.Add(UI.Notify.NotifyType.Error, T("Cannot select media")); var model = new MediaManagerMediaItemsViewModel { MediaItems = new List <MediaManagerMediaItemViewModel>(), MediaItemsCount = 0, FolderPath = folderPath }; return(View(model)); } // Check permission if (!_mediaLibraryService.CheckMediaFolderPermission(Permissions.SelectMediaContent, folderPath) && !_mediaLibraryService.CanManageMediaFolder(folderPath)) { var model = new MediaManagerMediaItemsViewModel { MediaItems = new List <MediaManagerMediaItemViewModel>(), MediaItemsCount = 0, FolderPath = folderPath }; return(View(model)); } IEnumerable <MediaPart> mediaParts; var mediaPartsCount = 0; if (culture == "") { mediaParts = _mediaLibraryService.GetMediaContentItems(folderPath, skip, count, order, mediaType, VersionOptions.Latest); mediaPartsCount = _mediaLibraryService.GetMediaContentItemsCount(folderPath, mediaType, VersionOptions.Latest); } else { var cultureId = _cultureManager.GetCultureByName(culture).Id; var query = BuildGetMediaContentItemsQuery(Services.ContentManager, folderPath, order: order, mediaType: mediaType, versionOptions: VersionOptions.Latest) .Join <LocalizationPartRecord>() .Where(x => x.CultureId == cultureId) .Join <MediaPartRecord>(); mediaParts = query .Slice(skip, count); mediaPartsCount = query.Count(); } 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)); }