示例#1
0
        public ActionResult Index()
        {
            var viewModel = new MediaManagerIndexViewModel();

            if (CmsConfiguration.Security.AccessControlEnabled && !StorageService.SecuredUrlsEnabled)
            {
                viewModel.CustomFilesMessages = new UserMessages();
                viewModel.CustomFilesMessages.AddWarn(MediaGlobalization.TokenBasedSecurity_NotSupported_Message);
            }
            if (CmsConfiguration.Security.AccessControlEnabled &&
                StorageService.SecuredUrlsEnabled &&
                StorageService.SecuredContainerIssueWarning != null)
            {
                if (viewModel.CustomFilesMessages == null)
                {
                    viewModel.CustomFilesMessages = new UserMessages();
                }
                viewModel.CustomFilesMessages.AddWarn(StorageService.SecuredContainerIssueWarning);
            }

            var images  = GetCommand <GetImagesCommand>().ExecuteCommand(new MediaManagerViewModel());
            var success = images != null;
            var view    = RenderView("Index", viewModel);

            return(ComboWireJson(success, view, images, JsonRequestBehavior.AllowGet));
        }
示例#2
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));
        }
示例#4
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));
        }
示例#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));
        }