Ejemplo n.º 1
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(string folderPath = "", bool dialog = false)
        {
            if (!_mediaLibraryService.CheckMediaFolderPermission(Permissions.SelectMediaContent, folderPath))
            {
                Services.Notifier.Add(UI.Notify.NotifyType.Error, T("Cannot select media"));
                return(new HttpUnauthorizedResult());
            }

            var userMediaFolder = _mediaLibraryService.GetUserMediaFolder();

            if (Services.Authorizer.Authorize(Permissions.ManageOwnMedia) && !Services.Authorizer.Authorize(Permissions.ManageMediaContent))
            {
                _storageProvider.TryCreateFolder(userMediaFolder.MediaPath);
            }

            // If the user is trying to access a folder above his boundaries, redirect him to his home folder
            var rootMediaFolder = _mediaLibraryService.GetRootMediaFolder();

            if (!_mediaLibraryService.CheckMediaFolderPermission(Permissions.SelectMediaContent, folderPath) && !_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 rootMediaFolderPath = rootMediaFolder == null ? null : rootMediaFolder.MediaPath;

            var viewModel = new MediaManagerIndexViewModel {
                DialogMode            = dialog,
                FolderPath            = folderPath,
                RootFolderPath        = rootMediaFolderPath,
                ChildFoldersViewModel = new MediaManagerChildFoldersViewModel {
                    Children = _mediaLibraryService.GetMediaFolders(rootMediaFolderPath)
                },
                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));
        }
Ejemplo n.º 3
0
        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 rootMediaFolder = _mediaLibraryService.GetRootMediaFolder();

            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));
        }