public ProxyItemLanguage(IItemLanguage baseLanguage) { Assert.ArgumentNotNull(baseLanguage, nameof(baseLanguage)); Fields = baseLanguage.Fields.ToArray(); Language = baseLanguage.Language; }
public ProxyItemLanguage(IItemLanguage baseLanguage) { Assert.ArgumentNotNull(baseLanguage, nameof(baseLanguage)); Fields = baseLanguage.Fields.ToArray(); Language = baseLanguage.Language; }
protected virtual void PasteUnversionedLanguage(Item item, IItemLanguage serializedLanguage, bool newItemWasCreated, List <TemplateMissingFieldException> softErrors) { Language language = Language.Parse(serializedLanguage.Language.Name); Item targetItem = item.Database.GetItem(item.ID, language); bool commitEditContext = false; try { targetItem.Editing.BeginEdit(); targetItem.RuntimeSettings.ReadOnlyStatistics = true; targetItem.RuntimeSettings.SaveAll = true; var allTargetUnversionedFields = serializedLanguage.Fields.ToLookup(field => field.FieldId); foreach (Field field in targetItem.Fields) { // field was not serialized. Which means the field is either blank or has its standard value, so let's reset it if (field.Unversioned && !field.Shared && !allTargetUnversionedFields.Contains(field.ID.Guid)) { _logger.ResetFieldThatDidNotExistInSerialized(field); field.Reset(); commitEditContext = true; } } foreach (var field in serializedLanguage.Fields) { try { if (PasteField(targetItem, field, newItemWasCreated)) { commitEditContext = true; } } catch (TemplateMissingFieldException tex) { softErrors.Add(tex); } } // we commit the edit context - and write to the DB - only if we changed something if (commitEditContext) { targetItem.Editing.EndEdit(); } } finally { if (targetItem.Editing.IsEditing) { targetItem.Editing.CancelEdit(); } } }
protected virtual void PasteUnversionedLanguage(Item item, IItemLanguage serializedLanguage, bool newItemWasCreated, List<TemplateMissingFieldException> softErrors) { Language language = Language.Parse(serializedLanguage.Language.Name); Item targetItem = item.Database.GetItem(item.ID, language); bool commitEditContext = false; try { targetItem.Editing.BeginEdit(); targetItem.RuntimeSettings.ReadOnlyStatistics = true; targetItem.RuntimeSettings.SaveAll = true; var allTargetUnversionedFields = serializedLanguage.Fields.ToLookup(field => field.FieldId); foreach (Field field in targetItem.Fields) { // field was not serialized. Which means the field is either blank or has its standard value, so let's reset it if (field.Unversioned && !field.Shared && !allTargetUnversionedFields.Contains(field.ID.Guid)) { _logger.ResetFieldThatDidNotExistInSerialized(field); field.Reset(); commitEditContext = true; } } foreach (var field in serializedLanguage.Fields) { try { if (PasteField(targetItem, field, newItemWasCreated)) commitEditContext = true; } catch (TemplateMissingFieldException tex) { softErrors.Add(tex); } } // we commit the edit context - and write to the DB - only if we changed something if (commitEditContext) targetItem.Editing.EndEdit(); } finally { if (targetItem.Editing.IsEditing) targetItem.Editing.CancelEdit(); } }
public RainbowItemLanguageAdapter(IItemLanguage itemLanguage) { _itemLanguage = itemLanguage; }
protected virtual bool PasteUnversionedLanguage(Item item, IItemLanguage serializedLanguage, bool newItemWasCreated, List <TemplateMissingFieldException> softErrors, IFieldValueManipulator fieldValueManipulator) { Language language = Language.Parse(serializedLanguage.Language.Name); Item targetItem = item.Database.GetItem(item.ID, language); if (targetItem == null) { // this can occasionally occur when syncing a tpSync config CacheManager.ClearAllCaches(); targetItem = item.Database.GetItem(item.ID, language); } Assert.IsNotNull(targetItem, "Target item language to paste unversioned fields into was null."); bool commitEdit = false; try { targetItem.Editing.BeginEdit(); targetItem.RuntimeSettings.ReadOnlyStatistics = true; targetItem.RuntimeSettings.SaveAll = true; var allTargetUnversionedFields = serializedLanguage.Fields.ToLookup(field => field.FieldId); foreach (Field field in targetItem.Fields) { // field was not serialized. Which means the field is either blank or has its standard value, so let's reset it if (field.Unversioned && fieldValueManipulator?.GetFieldValueTransformer(field.Name) == null && !field.Shared && !allTargetUnversionedFields.Contains(field.ID.Guid) && _fieldFilter.Includes(field.ID.Guid)) { _logger.ResetFieldThatDidNotExistInSerialized(field); field.Reset(); commitEdit = true; } } var transformersArray = fieldValueManipulator?.GetFieldValueTransformers(); List <IFieldValueTransformer> transformersList = new List <IFieldValueTransformer>(); if (transformersArray != null) { transformersList = new List <IFieldValueTransformer>(transformersArray); } foreach (var field in serializedLanguage.Fields) { try { if (PasteField(targetItem, field, newItemWasCreated, fieldValueManipulator)) { commitEdit = true; } var t = transformersList.FirstOrDefault(x => x.FieldName.Equals(field.NameHint)); if (t != null) { transformersList.Remove(t); } } catch (TemplateMissingFieldException tex) { softErrors.Add(tex); } } // Whatever remains here are field transformers that are NOT represented in the serialized data foreach (var t in transformersList) { var fieldMeta = targetItem.Template.GetField(t.FieldName); // If the field doesn't exist on the target template, it's time to just skip if (fieldMeta != null) { if (!fieldMeta.IsUnversioned) { continue; } var existingField = targetItem.Fields[fieldMeta.ID]; if (t.ShouldDeployFieldValue(existingField.Value, null)) { var fakeField = new ItemFieldValue(existingField, null); if (PasteField(targetItem, fakeField, newItemWasCreated, fieldValueManipulator)) { commitEdit = true; } } } } // we commit the edit context - and write to the DB - only if we changed something if (commitEdit) { targetItem.Editing.EndEdit(); return(true); } } finally { if (targetItem.Editing.IsEditing) { targetItem.Editing.CancelEdit(); } } return(false); }
public ItemLanguageComparisonResult(IItemLanguage language, FieldComparisonResult[] changedFields) { Language = language; ChangedFields = new List<FieldComparisonResult>(changedFields ?? new FieldComparisonResult[0]); }
public SitecoreItemLanguageAdapter(IItemLanguage itemLanguage) { _itemLanguage = itemLanguage; }
public ItemLanguageComparisonResult(IItemLanguage language, FieldComparisonResult[] changedFields) { Language = language; ChangedFields = new List <FieldComparisonResult>(changedFields ?? new FieldComparisonResult[0]); }
public FilteredLanguage(IItemLanguage baseLanguage, IFieldFilter filter) : base(baseLanguage) { _baseLanguage = baseLanguage; _filter = filter; }