diff --git a/src/Umbraco.Core/Services/IPackagingService.cs b/src/Umbraco.Core/Services/IPackagingService.cs
index 4056b27be7..2f711eb8af 100644
--- a/src/Umbraco.Core/Services/IPackagingService.cs
+++ b/src/Umbraco.Core/Services/IPackagingService.cs
@@ -48,15 +48,17 @@ namespace Umbraco.Core.Services
/// Imports and saves the 'DictionaryItems' part of the package xml as a list of
///
/// Xml to import
+ /// Optional parameter indicating whether or not to raise events
/// An enumerable list of dictionary items
- IEnumerable ImportDictionaryItems(XElement dictionaryItemElementList);
+ IEnumerable ImportDictionaryItems(XElement dictionaryItemElementList, bool raiseEvents = true);
///
/// Imports and saves the 'Languages' part of a package xml as a list of
///
/// Xml to import
+ /// Optional parameter indicating whether or not to raise events
/// An enumerable list of generated languages
- IEnumerable ImportLanguages(XElement languageElementList);
+ IEnumerable ImportLanguages(XElement languageElementList, bool raiseEvents = true);
///
/// Imports and saves package xml as
@@ -97,44 +99,50 @@ namespace Umbraco.Core.Services
/// Exports a list of items to xml as an
///
/// List of Languages to export
+ /// Optional parameter indicating whether or not to raise events
/// containing the xml representation of the Language object
- XElement Export(IEnumerable languages);
+ XElement Export(IEnumerable languages, bool raiseEvents = true);
///
/// Exports a single item to xml as an
///
/// Language to export
+ /// Optional parameter indicating whether or not to raise events
/// containing the xml representation of the Language object
- XElement Export(ILanguage language);
+ XElement Export(ILanguage language, bool raiseEvents = true);
///
/// Exports a list of items to xml as an
///
/// List of dictionary items to export
/// Optional boolean indicating whether or not to include children
+ /// Optional parameter indicating whether or not to raise events
/// containing the xml representation of the IDictionaryItem objects
- XElement Export(IEnumerable dictionaryItem, bool includeChildren = true);
+ XElement Export(IEnumerable dictionaryItem, bool includeChildren = true, bool raiseEvents = true);
///
/// Exports a single item to xml as an
///
/// Dictionary Item to export
/// Optional boolean indicating whether or not to include children
+ /// Optional parameter indicating whether or not to raise events
/// containing the xml representation of the IDictionaryItem object
- XElement Export(IDictionaryItem dictionaryItem, bool includeChildren);
+ XElement Export(IDictionaryItem dictionaryItem, bool includeChildren, bool raiseEvents = true);
///
/// Exports a list of Data Types
///
/// List of data types to export
+ /// Optional parameter indicating whether or not to raise events
/// containing the xml representation of the IDataTypeDefinition objects
- XElement Export(IEnumerable dataTypeDefinitions);
+ XElement Export(IEnumerable dataTypeDefinitions, bool raiseEvents = true);
///
/// Exports a single Data Type
///
/// Data type to export
+ /// Optional parameter indicating whether or not to raise events
/// containing the xml representation of the IDataTypeDefinition object
- XElement Export(IDataTypeDefinition dataTypeDefinition);
+ XElement Export(IDataTypeDefinition dataTypeDefinition, bool raiseEvents = true);
}
}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Services/PackagingService.cs b/src/Umbraco.Core/Services/PackagingService.cs
index 1b897a6aca..03e0d96a59 100644
--- a/src/Umbraco.Core/Services/PackagingService.cs
+++ b/src/Umbraco.Core/Services/PackagingService.cs
@@ -752,13 +752,14 @@ namespace Umbraco.Core.Services
/// Exports a list of Data Types
///
/// List of data types to export
+ /// Optional parameter indicating whether or not to raise events
/// containing the xml representation of the IDataTypeDefinition objects
- public XElement Export(IEnumerable dataTypeDefinitions)
+ public XElement Export(IEnumerable dataTypeDefinitions, bool raiseEvents = true)
{
var container = new XElement("DataTypes");
- foreach (var d in dataTypeDefinitions)
+ foreach (var dataTypeDefinition in dataTypeDefinitions)
{
- container.Add(Export(d));
+ container.Add(Export(dataTypeDefinition, raiseEvents));
}
return container;
}
@@ -767,9 +768,16 @@ namespace Umbraco.Core.Services
/// Exports a single Data Type
///
/// Data type to export
+ /// Optional parameter indicating whether or not to raise events
/// containing the xml representation of the IDataTypeDefinition object
- public XElement Export(IDataTypeDefinition dataTypeDefinition)
+ public XElement Export(IDataTypeDefinition dataTypeDefinition, bool raiseEvents = true)
{
+ if (raiseEvents)
+ {
+ if (ExportingDataType.IsRaisedEventCancelled(new SaveEventArgs(dataTypeDefinition), this))
+ return default(XElement);
+ }
+
var prevalues = new XElement("PreValues");
var prevalueList = _dataTypeService.GetPreValuesCollectionByDataTypeId(dataTypeDefinition.Id)
@@ -794,6 +802,9 @@ namespace Umbraco.Core.Services
xml.Add(new XAttribute("Definition", dataTypeDefinition.Key));
xml.Add(new XAttribute("DatabaseType", dataTypeDefinition.DatabaseType.ToString()));
+ if (raiseEvents)
+ DataTypeExported.RaiseEvent(new SaveEventArgs(xml, false), this);
+
return xml;
}
@@ -916,13 +927,14 @@ namespace Umbraco.Core.Services
///
/// List of dictionary items to export
/// Optional boolean indicating whether or not to include children
+ /// Optional parameter indicating whether or not to raise events
/// containing the xml representation of the IDictionaryItem objects
- public XElement Export(IEnumerable dictionaryItem, bool includeChildren = true)
+ public XElement Export(IEnumerable dictionaryItem, bool includeChildren = true, bool raiseEvents = true)
{
var xml = new XElement("DictionaryItems");
foreach (var item in dictionaryItem)
{
- xml.Add(Export(item, includeChildren));
+ xml.Add(Export(item, includeChildren, raiseEvents));
}
return xml;
}
@@ -932,9 +944,16 @@ namespace Umbraco.Core.Services
///
/// Dictionary Item to export
/// Optional boolean indicating whether or not to include children
+ /// Optional parameter indicating whether or not to raise events
/// containing the xml representation of the IDictionaryItem object
- public XElement Export(IDictionaryItem dictionaryItem, bool includeChildren)
+ public XElement Export(IDictionaryItem dictionaryItem, bool includeChildren, bool raiseEvents = true)
{
+ if (raiseEvents)
+ {
+ if (ExportingDictionaryItem.IsRaisedEventCancelled(new SaveEventArgs(dictionaryItem), this))
+ return default(XElement);
+ }
+
var xml = new XElement("DictionaryItem", new XAttribute("Key", dictionaryItem.ItemKey));
foreach (var translation in dictionaryItem.Translations)
{
@@ -953,6 +972,9 @@ namespace Umbraco.Core.Services
}
}
+ if (raiseEvents)
+ DictionaryItemExported.RaiseEvent(new SaveEventArgs(xml, false), this);
+
return xml;
}
@@ -960,18 +982,29 @@ namespace Umbraco.Core.Services
/// Imports and saves the 'DictionaryItems' part of the package xml as a list of
///
/// Xml to import
+ /// Optional parameter indicating whether or not to raise events
/// An enumerable list of dictionary items
- public IEnumerable ImportDictionaryItems(XElement dictionaryItemElementList)
+ public IEnumerable ImportDictionaryItems(XElement dictionaryItemElementList, bool raiseEvents = true)
{
+ if (raiseEvents)
+ {
+ if (ImportingDictionaryItem.IsRaisedEventCancelled(new SaveEventArgs(dictionaryItemElementList), this))
+ return Enumerable.Empty();
+ }
+
var languages = _localizationService.GetAllLanguages().ToList();
- return ImportDictionaryItems(dictionaryItemElementList, languages);
+ return ImportDictionaryItems(dictionaryItemElementList, languages, raiseEvents);
}
- private IEnumerable ImportDictionaryItems(XElement dictionaryItemElementList, List languages)
+ private IEnumerable ImportDictionaryItems(XElement dictionaryItemElementList, List languages, bool raiseEvents)
{
var items = new List();
foreach (var dictionaryItemElement in dictionaryItemElementList.Elements("DictionaryItem"))
items.AddRange(ImportDictionaryItem(dictionaryItemElement, languages));
+
+ if (raiseEvents)
+ DictionaryItemImported.RaiseEvent(new SaveEventArgs(items, false), this);
+
return items;
}
@@ -1041,13 +1074,14 @@ namespace Umbraco.Core.Services
/// Exports a list of items to xml as an
///
/// List of Languages to export
+ /// Optional parameter indicating whether or not to raise events
/// containing the xml representation of the ILanguage objects
- public XElement Export(IEnumerable languages)
+ public XElement Export(IEnumerable languages, bool raiseEvents = true)
{
var xml = new XElement("Languages");
foreach (var language in languages)
{
- xml.Add(Export(language));
+ xml.Add(Export(language, raiseEvents));
}
return xml;
}
@@ -1056,13 +1090,24 @@ namespace Umbraco.Core.Services
/// Exports a single item to xml as an
///
/// Language to export
+ /// Optional parameter indicating whether or not to raise events
/// containing the xml representation of the ILanguage object
- public XElement Export(ILanguage language)
+ public XElement Export(ILanguage language, bool raiseEvents = true)
{
+ if (raiseEvents)
+ {
+ if (ExportingLanguage.IsRaisedEventCancelled(new SaveEventArgs(language), this))
+ return default(XElement);
+ }
+
var xml = new XElement("Language",
new XAttribute("Id", language.Id),
new XAttribute("CultureAlias", language.IsoCode),
new XAttribute("FriendlyName", language.CultureName));
+
+ if (raiseEvents)
+ LanguageExported.RaiseEvent(new SaveEventArgs(xml, false), this);
+
return xml;
}
@@ -1070,9 +1115,16 @@ namespace Umbraco.Core.Services
/// Imports and saves the 'Languages' part of a package xml as a list of
///
/// Xml to import
+ /// Optional parameter indicating whether or not to raise events
/// An enumerable list of generated languages
- public IEnumerable ImportLanguages(XElement languageElementList)
+ public IEnumerable ImportLanguages(XElement languageElementList, bool raiseEvents = true)
{
+ if (raiseEvents)
+ {
+ if (ImportingLanguage.IsRaisedEventCancelled(new SaveEventArgs(languageElementList), this))
+ return Enumerable.Empty();
+ }
+
var list = new List();
foreach (var languageElement in languageElementList.Elements("Language"))
{
@@ -1089,6 +1141,9 @@ namespace Umbraco.Core.Services
}
}
+ if (raiseEvents)
+ LanguageImported.RaiseEvent(new SaveEventArgs(list, false), this);
+
return list;
}
@@ -1426,6 +1481,56 @@ namespace Umbraco.Core.Services
///
public static event TypedEventHandler> DataTypeImported;
+ ///
+ /// Occurs before Exporting DataType
+ ///
+ public static event TypedEventHandler> ExportingDataType;
+
+ ///
+ /// Occurs after DataType is Exported to Xml
+ ///
+ public static event TypedEventHandler> DataTypeExported;
+
+ ///
+ /// Occurs before Importing DictionaryItem
+ ///
+ public static event TypedEventHandler> ImportingDictionaryItem;
+
+ ///
+ /// Occurs after DictionaryItem is Imported and Saved
+ ///
+ public static event TypedEventHandler> DictionaryItemImported;
+
+ ///
+ /// Occurs before Exporting DictionaryItem
+ ///
+ public static event TypedEventHandler> ExportingDictionaryItem;
+
+ ///
+ /// Occurs after DictionaryItem is Exported to Xml
+ ///
+ public static event TypedEventHandler> DictionaryItemExported;
+
+ ///
+ /// Occurs before Importing Language
+ ///
+ public static event TypedEventHandler> ImportingLanguage;
+
+ ///
+ /// Occurs after Language is Imported and Saved
+ ///
+ public static event TypedEventHandler> LanguageImported;
+
+ ///
+ /// Occurs before Exporting Language
+ ///
+ public static event TypedEventHandler> ExportingLanguage;
+
+ ///
+ /// Occurs after Language is Exported to Xml
+ ///
+ public static event TypedEventHandler> LanguageExported;
+
///
/// Occurs before Importing Template
///