New feature "Orchard.MediaLibrary.LocalizationExtensions"#7935
Conversation
- MediaLocalizationMigrations: Adds LocalizationPart to all Media stereotyped types - MediaLibraryPickerFieldLocalizationExtensionHandler: Updates the media items within the field according to field settings - Settings for translation behaviours for MediaLibraryPickerField - Adds warning on localizing media items - form filter media by culture "MediaLibrary" feature: - Implemented Cloning methods of all medias PartDrivers - MediaPartHandler: Adds a check to prevent file system media deletion when the file is referenced by other medias - ClientStorageController: Adds a check to prevent file system media deletion when the file is referenced by other medias "Localization" feature: - Adds a logic to propagate returnurl parameter to the redirection url - ILocalizationService: Adds a new method to set the culture of a content and at the same time the master content of it - Propagate returnurl parameter if necessary "Search" feature: - updated json of media items called via ajax
| } | ||
| } | ||
| if (mediaIds.Count > 0) { | ||
| field.Ids = mediaIds.Distinct().ToArray(); |
There was a problem hiding this comment.
@sebastienros I don't know if we should do distinct() here. Should we allow duplicated media items in the field? I added the distinct here because of #7934, but I can remove it.
| } | ||
| foreach (var key in Request.QueryString.AllKeys.Where(x => !x.StartsWith("__") && !editorRouteValues.Keys.Contains(x))) { | ||
| editorRouteValues.Add(key, Request.QueryString[key]); | ||
| } |
There was a problem hiding this comment.
In media library the edit button adds a "ReturnUrl" QueryString in order to have a redirection to the caller page when saving/cancelling operation.
The translate link has the prop "Unsafe", so it transforms the request from get + querystring in post + body . So I propagate those parameters through redirection translate (which clone) > edit content, in order to be able to manage the right returnurl (and other parameters if they are there). To restrict the logic to only the "redirecturl" parameter, could be less flexible but more safe. @sebastienros what do you prefer?
| FolderPath = folderPath | ||
| }; | ||
| return View(viewModel); | ||
| } |
There was a problem hiding this comment.
I have replicated the logic within Orchard.Search, even if I don't like so much the results because filters from different features can't works together. Basically I have not introduced anything worse than it already was, so i ask you if you can merge it anyway.
But we should consider to change the current approach; I don't know if it is possible but:
- the responsible of acting the filter should be the medialibrary module
- other modules can partecipate in building the where clause of the query (as per projections)
- every change in the filters form/folders navigation fires a medialibrary controller responsible of combining the queries and then exposing the result.
@sebastienros if you agree I will file a new issue describing the problem and proposing the above solution.
|
Looks good, waiting for a demo. |
| if (!string.IsNullOrEmpty(part.FileName)) { | ||
| _mediaLibraryService.DeleteFile(part.FolderPath, part.FileName); | ||
| var mediaItemsUsingTheFile = _contentManager.Query<MediaPart, MediaPartRecord>() | ||
| .ForVersion(VersionOptions.Latest) |
There was a problem hiding this comment.
Thinking about your @sebastienros comment to query latest and published version here...
As I Know Medias are not draftable, so querying latest should be enough. The only case in which a Media can be in draft, right now, is after a clone/translation and it has not a published version. In all the other cases if a media is published it's the Latest also. If you agree I will keep this code as is.
| .ForVersion(VersionOptions.Latest) | ||
| .Where(x => x.FolderPath == replaceMedia.FolderPath && x.FileName == replaceMedia.FileName) | ||
| .Count(); | ||
| if (mediaItemsUsingTheFile == 1) { // if the file is referenced only by the deleted media content, the file too can be removed. |
There was a problem hiding this comment.
@sebastienros Same here, Latest should be enough
|
@sebastienros , After yesterday demo, consider to merge it in dev. We will cherry pick and deliver it in our production env. |
…#7935) * New feature "Orchard.MediaLibrary.LocalizationExtensions": - MediaLocalizationMigrations: Adds LocalizationPart to all Media stereotyped types - MediaLibraryPickerFieldLocalizationExtensionHandler: Updates the media items within the field according to field settings - Settings for translation behaviours for MediaLibraryPickerField - Adds warning on localizing media items - form filter media by culture "MediaLibrary" feature: - Implemented Cloning methods of all medias PartDrivers - MediaPartHandler: Adds a check to prevent file system media deletion when the file is referenced by other medias - ClientStorageController: Adds a check to prevent file system media deletion when the file is referenced by other medias "Localization" feature: - Adds a logic to propagate returnurl parameter to the redirection url - ILocalizationService: Adds a new method to set the culture of a content and at the same time the master content of it - Propagate returnurl parameter if necessary "Search" feature: - updated json of media items called via ajax # Conflicts: # src/Orchard.Web/Modules/Orchard.MediaLibrary/Controllers/ClientStorageController.cs # src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/MediaPartDriver.cs # src/Orchard.Web/Modules/Orchard.MediaLibrary/Drivers/OEmbedPartDriver.cs # src/Orchard.Web/Modules/Orchard.MediaLibrary/Orchard.MediaLibrary.csproj
Implements what opened with #7843
"Orchard.MediaLibrary.LocalizationExtensions" feature:
"MediaLibrary" feature:
"Localization" feature:
"Search" feature: