Merge remote-tracking branch 'origin/dev-v7' into dev-v8
# Conflicts: # src/Umbraco.Web/PropertyEditors/FileUploadPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/GridPropertyEditor.cs # src/Umbraco.Web/PropertyEditors/ImageCropperPropertyEditor.cs
This commit is contained in:
@@ -32,11 +32,11 @@ namespace Umbraco.Web.PropertyEditors
|
||||
if (mediaFileSystem == null) throw new ArgumentNullException("mediaFileSystem");
|
||||
if (contentSettings == null) throw new ArgumentNullException("contentSettings");
|
||||
if (textService == null) throw new ArgumentNullException("textService");
|
||||
_applicationStartup = new FileUploadPropertyEditorApplicationStartup(this);
|
||||
_mediaFileSystem = mediaFileSystem;
|
||||
_contentSettings = contentSettings;
|
||||
_textService = textService;
|
||||
MemberService.Deleted += (sender, args) =>
|
||||
args.MediaFilesToDelete.AddRange(ServiceDeleted(args.DeletedEntities.Cast<ContentBase>()));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -59,7 +59,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// Ensures any files associated are removed
|
||||
/// </summary>
|
||||
/// <param name="allPropertyData"></param>
|
||||
static IEnumerable<string> ServiceEmptiedRecycleBin(Dictionary<int, IEnumerable<Property>> allPropertyData)
|
||||
IEnumerable<string> ServiceEmptiedRecycleBin(Dictionary<int, IEnumerable<Property>> allPropertyData)
|
||||
{
|
||||
var list = new List<string>();
|
||||
//Get all values for any image croppers found
|
||||
@@ -81,7 +81,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
/// Ensures any files associated are removed
|
||||
/// </summary>
|
||||
/// <param name="deletedEntities"></param>
|
||||
static IEnumerable<string> ServiceDeleted(IEnumerable<ContentBase> deletedEntities)
|
||||
IEnumerable<string> ServiceDeleted(IEnumerable<ContentBase> deletedEntities)
|
||||
{
|
||||
var list = new List<string>();
|
||||
foreach (var property in deletedEntities.SelectMany(deletedEntity => deletedEntity
|
||||
@@ -267,36 +267,60 @@ namespace Umbraco.Web.PropertyEditors
|
||||
}
|
||||
|
||||
#region Application event handler, used to bind to events on startup
|
||||
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
}
|
||||
private readonly FileUploadPropertyEditorApplicationStartup _applicationStartup;
|
||||
|
||||
/// <summary>
|
||||
/// We're going to bind to the MediaService Saving event so that we can populate the umbracoFile size, type, etc... label fields
|
||||
/// if we find any attached to the current media item.
|
||||
/// we're using a sub -class because this has the logic to prevent it from executing if the application is not configured
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// I think this kind of logic belongs on this property editor, I guess it could exist elsewhere but it all has to do with the upload field.
|
||||
/// </remarks>
|
||||
private class FileUploadPropertyEditorApplicationStartup : ApplicationEventHandler
|
||||
{
|
||||
private FileUploadPropertyEditor _fileUploadPropertyEditor;
|
||||
|
||||
public FileUploadPropertyEditorApplicationStartup(FileUploadPropertyEditor fileUploadPropertyEditor)
|
||||
{
|
||||
this._fileUploadPropertyEditor = fileUploadPropertyEditor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// We're going to bind to the MediaService Saving event so that we can populate the umbracoFile size, type, etc... label fields
|
||||
/// if we find any attached to the current media item.
|
||||
/// </summary>
|
||||
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
MediaService.Saving += _fileUploadPropertyEditor.MediaServiceSaving;
|
||||
MediaService.Created += _fileUploadPropertyEditor.MediaServiceCreating;
|
||||
ContentService.Copied += _fileUploadPropertyEditor.ContentServiceCopied;
|
||||
|
||||
MediaService.Deleted += (sender, args) =>
|
||||
args.MediaFilesToDelete.AddRange(_fileUploadPropertyEditor.ServiceDeleted(args.DeletedEntities.Cast<ContentBase>()));
|
||||
MediaService.EmptiedRecycleBin += (sender, args) =>
|
||||
args.Files.AddRange(_fileUploadPropertyEditor.ServiceEmptiedRecycleBin(args.AllPropertyData));
|
||||
ContentService.Deleted += (sender, args) =>
|
||||
args.MediaFilesToDelete.AddRange(_fileUploadPropertyEditor.ServiceDeleted(args.DeletedEntities.Cast<ContentBase>()));
|
||||
ContentService.EmptiedRecycleBin += (sender, args) =>
|
||||
args.Files.AddRange(_fileUploadPropertyEditor.ServiceEmptiedRecycleBin(args.AllPropertyData));
|
||||
MemberService.Deleted += (sender, args) =>
|
||||
args.MediaFilesToDelete.AddRange(_fileUploadPropertyEditor.ServiceDeleted(args.DeletedEntities.Cast<ContentBase>()));
|
||||
}
|
||||
}
|
||||
|
||||
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
//wrap
|
||||
_applicationStartup.OnApplicationInitialized(umbracoApplication, applicationContext);
|
||||
}
|
||||
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
//wrap
|
||||
_applicationStartup.OnApplicationStarting(umbracoApplication, applicationContext);
|
||||
}
|
||||
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
MediaService.Saving += MediaServiceSaving;
|
||||
MediaService.Created += MediaServiceCreating;
|
||||
ContentService.Copied += ContentServiceCopied;
|
||||
|
||||
MediaService.Deleted += (sender, args) =>
|
||||
args.MediaFilesToDelete.AddRange(ServiceDeleted(args.DeletedEntities.Cast<ContentBase>()));
|
||||
MediaService.EmptiedRecycleBin += (sender, args) =>
|
||||
args.Files.AddRange(ServiceEmptiedRecycleBin(args.AllPropertyData));
|
||||
ContentService.Deleted += (sender, args) =>
|
||||
args.MediaFilesToDelete.AddRange(ServiceDeleted(args.DeletedEntities.Cast<ContentBase>()));
|
||||
ContentService.EmptiedRecycleBin += (sender, args) =>
|
||||
args.Files.AddRange(ServiceEmptiedRecycleBin(args.AllPropertyData));
|
||||
}
|
||||
//wrap
|
||||
_applicationStartup.OnApplicationStarted(umbracoApplication, applicationContext);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,15 +14,13 @@ namespace Umbraco.Web.PropertyEditors
|
||||
{
|
||||
[PropertyEditor(Core.Constants.PropertyEditors.GridAlias, "Grid layout", "grid", HideLabel = true, IsParameterEditor = false, ValueType = PropertyEditorValueTypes.Json, Group="rich content", Icon="icon-layout")]
|
||||
public class GridPropertyEditor : PropertyEditor, IApplicationEventHandler
|
||||
{
|
||||
private readonly IExamineIndexCollectionAccessor _indexCollection;
|
||||
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public GridPropertyEditor(ILogger logger, IExamineIndexCollectionAccessor indexCollection) : base(logger)
|
||||
{
|
||||
_indexCollection = indexCollection;
|
||||
{
|
||||
_applicationStartup = new GridPropertyEditorApplicationStartup(indexCollection);
|
||||
}
|
||||
|
||||
private static void DocumentWriting(object sender, Examine.LuceneEngine.DocumentWritingEventArgs e)
|
||||
@@ -132,23 +130,47 @@ namespace Umbraco.Web.PropertyEditors
|
||||
}
|
||||
|
||||
#region Application event handler, used to bind to events on startup
|
||||
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
}
|
||||
private readonly GridPropertyEditorApplicationStartup _applicationStartup;
|
||||
|
||||
/// <summary>
|
||||
/// We're going to bind to the Examine events so we can ensure grid data is index nicely.
|
||||
/// </summary>
|
||||
/// we're using a sub -class because this has the logic to prevent it from executing if the application is not configured
|
||||
/// </summary>
|
||||
private class GridPropertyEditorApplicationStartup : ApplicationEventHandler
|
||||
{
|
||||
private readonly IExamineIndexCollectionAccessor _indexCollection;
|
||||
|
||||
public GridPropertyEditorApplicationStartup(IExamineIndexCollectionAccessor indexCollection)
|
||||
{
|
||||
this._indexCollection = indexCollection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// We're going to bind to the Examine events so we can ensure grid data is index nicely.
|
||||
/// </summary>
|
||||
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
foreach (var i in _indexCollection.Indexes.Values.OfType<BaseUmbracoIndexer>())
|
||||
{
|
||||
i.DocumentWriting += DocumentWriting;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
//wrap
|
||||
_applicationStartup.OnApplicationInitialized(umbracoApplication, applicationContext);
|
||||
}
|
||||
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
//wrap
|
||||
_applicationStartup.OnApplicationStarting(umbracoApplication, applicationContext);
|
||||
}
|
||||
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
foreach (var i in _indexCollection.Indexes.Values.OfType<BaseUmbracoIndexer>())
|
||||
{
|
||||
i.DocumentWriting += DocumentWriting;
|
||||
}
|
||||
//wrap
|
||||
_applicationStartup.OnApplicationStarted(umbracoApplication, applicationContext);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ namespace Umbraco.Web.PropertyEditors
|
||||
{
|
||||
if (mediaFileSystem == null) throw new ArgumentNullException("mediaFileSystem");
|
||||
if (contentSettings == null) throw new ArgumentNullException("contentSettings");
|
||||
|
||||
_applicationStartup = new FileUploadPropertyEditorApplicationStartup(this);
|
||||
|
||||
_mediaFileSystem = mediaFileSystem;
|
||||
_contentSettings = contentSettings;
|
||||
|
||||
@@ -34,9 +37,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
{
|
||||
{"focalPoint", "{left: 0.5, top: 0.5}"},
|
||||
{"src", ""}
|
||||
};
|
||||
MemberService.Deleted += (sender, args) =>
|
||||
args.MediaFilesToDelete.AddRange(ServiceDeleted(args.DeletedEntities.Cast<ContentBase>()));
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -253,35 +254,58 @@ namespace Umbraco.Web.PropertyEditors
|
||||
}
|
||||
|
||||
#region Application event handler, used to bind to events on startup
|
||||
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
}
|
||||
private readonly FileUploadPropertyEditorApplicationStartup _applicationStartup;
|
||||
|
||||
/// <summary>
|
||||
/// We're going to bind to the MediaService Saving event so that we can populate the umbracoFile size, type, etc... label fields
|
||||
/// if we find any attached to the current media item.
|
||||
/// we're using a sub -class because this has the logic to prevent it from executing if the application is not configured
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// I think this kind of logic belongs on this property editor, I guess it could exist elsewhere but it all has to do with the cropper.
|
||||
/// </remarks>
|
||||
private class FileUploadPropertyEditorApplicationStartup : ApplicationEventHandler
|
||||
{
|
||||
private readonly ImageCropperPropertyEditor _imageCropperPropertyEditor;
|
||||
|
||||
public FileUploadPropertyEditorApplicationStartup(ImageCropperPropertyEditor imageCropperPropertyEditor)
|
||||
{
|
||||
_imageCropperPropertyEditor = imageCropperPropertyEditor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// We're going to bind to the MediaService Saving event so that we can populate the umbracoFile size, type, etc... label fields
|
||||
/// if we find any attached to the current media item.
|
||||
/// </summary>
|
||||
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
MediaService.Saving += _imageCropperPropertyEditor.MediaServiceSaving;
|
||||
MediaService.Created += _imageCropperPropertyEditor.MediaServiceCreated;
|
||||
ContentService.Copied += _imageCropperPropertyEditor.ContentServiceCopied;
|
||||
|
||||
MediaService.Deleted += (sender, args) =>
|
||||
args.MediaFilesToDelete.AddRange(_imageCropperPropertyEditor.ServiceDeleted(args.DeletedEntities.Cast<ContentBase>()));
|
||||
MediaService.EmptiedRecycleBin += (sender, args) =>
|
||||
args.Files.AddRange(_imageCropperPropertyEditor.ServiceEmptiedRecycleBin(args.AllPropertyData));
|
||||
ContentService.Deleted += (sender, args) =>
|
||||
args.MediaFilesToDelete.AddRange(_imageCropperPropertyEditor.ServiceDeleted(args.DeletedEntities.Cast<ContentBase>()));
|
||||
ContentService.EmptiedRecycleBin += (sender, args) =>
|
||||
args.Files.AddRange(_imageCropperPropertyEditor.ServiceEmptiedRecycleBin(args.AllPropertyData));
|
||||
MemberService.Deleted += (sender, args) =>
|
||||
args.MediaFilesToDelete.AddRange(_imageCropperPropertyEditor.ServiceDeleted(args.DeletedEntities.Cast<ContentBase>()));
|
||||
}
|
||||
}
|
||||
|
||||
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
//wrap
|
||||
_applicationStartup.OnApplicationInitialized(umbracoApplication, applicationContext);
|
||||
}
|
||||
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
//wrap
|
||||
_applicationStartup.OnApplicationStarting(umbracoApplication, applicationContext);
|
||||
}
|
||||
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
MediaService.Saving += MediaServiceSaving;
|
||||
MediaService.Created += MediaServiceCreated;
|
||||
ContentService.Copied += ContentServiceCopied;
|
||||
|
||||
MediaService.Deleted += (sender, args) =>
|
||||
args.MediaFilesToDelete.AddRange(ServiceDeleted(args.DeletedEntities.Cast<ContentBase>()));
|
||||
MediaService.EmptiedRecycleBin += (sender, args) =>
|
||||
args.Files.AddRange(ServiceEmptiedRecycleBin(args.AllPropertyData));
|
||||
ContentService.Deleted += (sender, args) =>
|
||||
args.MediaFilesToDelete.AddRange(ServiceDeleted(args.DeletedEntities.Cast<ContentBase>()));
|
||||
ContentService.EmptiedRecycleBin += (sender, args) =>
|
||||
args.Files.AddRange(ServiceEmptiedRecycleBin(args.AllPropertyData));
|
||||
//wrap
|
||||
_applicationStartup.OnApplicationStarted(umbracoApplication, applicationContext);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user