示例#1
0
        public ActionResult Create()
        {
            if (!Services.Authorizer.Authorize(Permissions.ManageOwnMedia, T("Couldn't create media folder")))
            {
                return(new HttpUnauthorizedResult());
            }

            var viewModel = new MediaManagerFolderCreateViewModel();

            UpdateModel(viewModel);

            if (!_mediaLibraryService.CanManageMediaFolder(viewModel.FolderPath))
            {
                return(new HttpUnauthorizedResult());
            }

            try {
                _mediaLibraryService.CreateFolder(viewModel.FolderPath, viewModel.Name);
                Services.Notifier.Information(T("Media folder created"));
            }
            catch (ArgumentException argumentException) {
                Services.Notifier.Error(T("Creating Folder failed: {0}", argumentException.Message));
                Services.TransactionManager.Cancel();
                return(View(viewModel));
            }

            return(RedirectToAction("Index", "Admin", new { area = "Tomelt.MediaLibrary" }));
        }
        protected string GetThumbnailFolder(string mediaPath)
        {
            // Creates a thumbnail folder if doesn't exists
            if (!_mediaService.GetMediaFolders(mediaPath).Select(o => o.Name).Contains(ThumbnailFolder))
            {
                _mediaService.CreateFolder(mediaPath, ThumbnailFolder);
            }

            return(_storageProvider.Combine(mediaPath, ThumbnailFolder));
        }
示例#3
0
        //TODO: Remove Image repository as soon as it can cascade the saving
        public ImageGalleryService(IMediaLibraryService mediaService, IRepository<ImageGallerySettingsRecord> repository,
								   IRepository<ImageGalleryImageSettingsRecord> imageRepository, IThumbnailService thumbnailService,
								   IRepository<ImageGalleryRecord> imageGalleryPartRepository, IOrchardServices services,
								   IStorageProvider storageProvider)
        {
            _storageProvider = storageProvider;
            _services = services;
            _imageGalleryPartRepository = imageGalleryPartRepository;
            _repository = repository;
            _mediaService = mediaService;
            _imageRepository = imageRepository;
            _thumbnailService = thumbnailService;

            if (_mediaService.GetMediaFolders(string.Empty).All(o => o.Name != ImageGalleriesMediaFolder))
            {
                _mediaService.CreateFolder(string.Empty, ImageGalleriesMediaFolder);
            }
        }
示例#4
0
        //TODO: Remove Image repository as soon as it can cascade the saving
        public ImageGalleryService(IMediaLibraryService mediaService, IRepository <ImageGallerySettingsRecord> repository,
                                   IRepository <ImageGalleryImageSettingsRecord> imageRepository, IThumbnailService thumbnailService,
                                   IRepository <ImageGalleryRecord> imageGalleryPartRepository, IOrchardServices services,
                                   IStorageProvider storageProvider)
        {
            _storageProvider            = storageProvider;
            _services                   = services;
            _imageGalleryPartRepository = imageGalleryPartRepository;
            _repository                 = repository;
            _mediaService               = mediaService;
            _imageRepository            = imageRepository;
            _thumbnailService           = thumbnailService;

            if (_mediaService.GetMediaFolders(string.Empty).All(o => o.Name != ImageGalleriesMediaFolder))
            {
                _mediaService.CreateFolder(string.Empty, ImageGalleriesMediaFolder);
            }
        }
示例#5
0
        public ActionResult Create()
        {
            if (!Services.Authorizer.Authorize(Permissions.ManageOwnMedia))
            {
                Services.Notifier.Error(T("Couldn't create media folder"));
                return(new HttpUnauthorizedResult());
            }

            var viewModel = new MediaManagerFolderCreateViewModel();

            UpdateModel(viewModel);

            if (!(_mediaLibraryService.CheckMediaFolderPermission(Permissions.ImportMediaContent, viewModel.FolderPath) ||
                  _mediaLibraryService.CheckMediaFolderPermission(Permissions.EditMediaContent, viewModel.FolderPath)))
            {
                return(new HttpUnauthorizedResult());
            }

            try {
                bool valid = String.IsNullOrWhiteSpace(viewModel.Name) || Regex.IsMatch(viewModel.Name, @"^[^:?#\[\]@!$&'()*+,.;=\s\""\<\>\\\|%]+$");
                if (!valid)
                {
                    throw new ArgumentException(T("Folder contains invalid characters").ToString());
                }
                else
                {
                    _mediaLibraryService.CreateFolder(viewModel.FolderPath, viewModel.Name);
                    Services.Notifier.Information(T("Media folder created"));
                }
            }
            catch (ArgumentException argumentException) {
                Services.Notifier.Error(T("Creating Folder failed: {0}", argumentException.Message));
                Services.TransactionManager.Cancel();
                return(View(viewModel));
            }
            return(RedirectToAction("Index", "Admin", new { area = "Orchard.MediaLibrary" }));
        }
示例#6
0
 public async Task <ActionResult <MediaFolder> > CreateFolder([FromQuery] string folderName, [FromQuery] string parentFolderId)
 {
     return(Ok(await _mediaLibraryService.CreateFolder(folderName, parentFolderId)));
 }
示例#7
0
 public void CreateImageGallery(string name)
 {
     _mediaService.CreateFolder(ImageGalleriesMediaFolder, name);
 }