public ActionResult Index(string folderPath = "", bool dialog = false) {
            if (!Services.Authorizer.Authorize(Permissions.ManageOwnMedia, T("Cannot view media")))
                return new HttpUnauthorizedResult();

            // If the user is trying to access a folder above his boundaries, redirect him to his home folder
            var rootMediaFolder = _mediaLibraryService.GetRootMediaFolder();
            if (!Services.Authorizer.Authorize(Permissions.ManageMediaContent) && !_mediaLibraryService.CanManageMediaFolder(folderPath)) {
                return RedirectToAction("Index", new { folderPath = rootMediaFolder.MediaPath, dialog });
            }

            // let other modules enhance the ui by providing custom navigation and actions
            var explorer = Services.ContentManager.New("MediaLibraryExplorer");
            explorer.Weld(new MediaLibraryExplorerPart());

            var explorerShape = Services.ContentManager.BuildDisplay(explorer);

            var viewModel = new MediaManagerIndexViewModel {
                DialogMode = dialog,
                FolderPath = folderPath,
                ChildFoldersViewModel = new MediaManagerChildFoldersViewModel{Children = _mediaLibraryService.GetMediaFolders(rootMediaFolder == null ? null : rootMediaFolder.MediaPath)},
                MediaTypes = _mediaLibraryService.GetMediaTypes(),
                CustomActionsShapes = explorerShape.Actions,
                CustomNavigationShapes = explorerShape.Navigation,
            };

            foreach (var shape in explorerShape.Actions.Items) {
                shape.MediaManagerIndexViewModel = viewModel;
            }

            foreach (var shape in explorerShape.Navigation.Items) {
                shape.MediaManagerIndexViewModel = viewModel;
            }

            return View(viewModel);
        }
        public ActionResult Index(string folderPath = "", bool dialog = false) {
            if (!Services.Authorizer.Authorize(Permissions.ManageMediaContent, T("Cannot view media")))
                return new HttpUnauthorizedResult();

            // let other modules enhance the ui by providing custom navigation and actions
            var explorer = Services.ContentManager.New("MediaLibraryExplorer");
            explorer.Weld(new MediaLibraryExplorerPart());

            var explorerShape = Services.ContentManager.BuildDisplay(explorer);
            
            var viewModel = new MediaManagerIndexViewModel {
                DialogMode = dialog,
                FolderPath = folderPath,
                ChildFoldersViewModel = new MediaManagerChildFoldersViewModel{Children = _mediaLibraryService.GetMediaFolders(null)},
                MediaTypes = _mediaLibraryService.GetMediaTypes(),
                CustomActionsShapes = explorerShape.Actions,
                CustomNavigationShapes = explorerShape.Navigation,
            };

            foreach (var shape in explorerShape.Actions.Items) {
                shape.MediaManagerIndexViewModel = viewModel;
            }

            foreach (var shape in explorerShape.Navigation.Items) {
                shape.MediaManagerIndexViewModel = viewModel;
            }

            return View(viewModel);
        }
Exemple #3
0
        public ActionResult Index(string folderPath = "", bool dialog = false) {
            
            // let other modules enhance the ui by providing custom navigation and actions
            var explorer = Services.ContentManager.New("MediaLibraryExplorer");
            explorer.Weld(new MediaLibraryExplorerPart());

            var explorerShape = Services.ContentManager.BuildDisplay(explorer);
            
            var viewModel = new MediaManagerIndexViewModel {
                DialogMode = dialog,
                Folders = _mediaLibraryService.GetMediaFolders(null).Select(GetFolderHierarchy),
                FolderPath = folderPath,
                MediaTypes = _mediaLibraryService.GetMediaTypes(),
                CustomActionsShapes = explorerShape.Actions,
                CustomNavigationShapes = explorerShape.Navigation,
            };

            foreach (var shape in explorerShape.Actions.Items) {
                shape.MediaManagerIndexViewModel = viewModel;
            }

            foreach (var shape in explorerShape.Navigation.Items) {
                shape.MediaManagerIndexViewModel = viewModel;
            }

            return View(viewModel);
        }
        public ActionResult Index(int? id, bool dialog = false) {
            var viewModel = new MediaManagerIndexViewModel {
                DialogMode = dialog,
                Folders = _mediaLibraryService.GetMediaFolders(),
                Folder = id,
                Hierarchy = id.HasValue ? _mediaLibraryService.GetMediaFolderHierarchy(id.Value) : Enumerable.Empty<MediaFolder>()
            };

            if (!id.HasValue && viewModel.Folders.Any()) {
                viewModel.Folder = viewModel.Folders.First().TermId;
            }

            return View(viewModel);
        }
Exemple #5
0
        public ActionResult Index(string folderPath = "", bool dialog = false) {
            var mediaTypes = new List<string>();

            foreach(var contentTypeDefinition in _contentDefinitionManager.ListTypeDefinitions()) {
                string stereotype;
                if (contentTypeDefinition.Settings.TryGetValue("Stereotype", out stereotype) && stereotype == "Media")
                    mediaTypes.Add(contentTypeDefinition.Name);
            }

            var viewModel = new MediaManagerIndexViewModel {
                DialogMode = dialog,
                Folders = _mediaLibraryService.GetMediaFolders(null).Select(GetFolderHierarchy),
                FolderPath = folderPath,
                MediaTypes = mediaTypes.ToArray()
            };

            return View(viewModel);
        }