protected override void Cloning(MapPart originalPart, MapPart clonePart, CloneContentContext context) { clonePart.Latitude = originalPart.Latitude; clonePart.Longitude = originalPart.Longitude; clonePart.LocationInfo = originalPart.LocationInfo; clonePart.LocationAddress = originalPart.LocationAddress; }
public override async Task CloningAsync(CloneContentContext context) { var containedPart = context.CloneContentItem.As <ContainedPart>(); if (containedPart != null) { // Resolve from DI to avoid circular references. var contentManager = _serviceProvider.GetRequiredService <IContentManager>(); var listContentItem = await contentManager.GetAsync(containedPart.ListContentItemId); if (listContentItem != null) { var contentDefinitionManager = _serviceProvider.GetRequiredService <IContentDefinitionManager>(); var contentTypeDefinition = contentDefinitionManager.GetTypeDefinition(listContentItem.ContentType); var contentTypePartDefinition = contentTypeDefinition.Parts.FirstOrDefault(x => String.Equals(x.PartDefinition.Name, "ListPart")); var settings = contentTypePartDefinition.GetSettings <ListPartSettings>(); if (settings.EnableOrdering) { var containerService = _serviceProvider.GetRequiredService <IContainerService>(); var nextOrder = await containerService.GetNextOrderNumberAsync(containedPart.ListContentItemId); context.CloneContentItem.Alter <ContainedPart>(x => x.Order = nextOrder); } } } }
public override void Cloned(CloneContentContext context) { foreach (var contentPartDriver in _drivers) { contentPartDriver.Cloned(context); } }
/// <summary> /// Updates the target ContentItem firing the right Handlers /// </summary> /// <param name="context">The SyncContext object</param> /// <param name="dest">The destination Content Item</param> private void UpdateTarget(SyncContext context) { var src = context.Source; var dest = context.Result; var targetContext = new UpdateContentContext(dest); var sourceContext = new CloneContentContext(src, dest); Handlers.Invoke(handler => handler.Updating(targetContext), Logger); Handlers.Invoke(handler => handler.Cloning(sourceContext), Logger); Handlers.Invoke(handler => handler.Cloned(sourceContext), Logger); if (context.Source.ContentType == "User") { var cp = dest.As <CommonPart>(); var up = context.Source.As <UserPart>(); if (cp != null && up != null && (cp.Owner == null || context.Target.ForceOwnerUpdate)) { cp.Owner = up; } } else if (context.Source.As <CommonPart>() == null) { var cp = dest.As <CommonPart>(); var up = Services.WorkContext.CurrentUser; if (cp != null && up != null && (cp.Owner == null || context.Target.ForceOwnerUpdate)) { cp.Owner = up; } } dest.As <SyncPart>().SyncronizedRef = context.Source.Id; Handlers.Invoke(handler => handler.Updated(targetContext), Logger); }
void IContentStorageFilter.Cloned(CloneContentContext context) { if (context.ContentItem.Is <TPart>()) { Cloned(context, context.ContentItem.As <TPart>()); } }
public override Task CloningAsync(CloneContentContext context, LocalizationPart part) { var clonedPart = context.CloneContentItem.As <LocalizationPart>(); clonedPart.LocalizationSet = string.Empty; clonedPart.Apply(); return(Task.CompletedTask); }
public override async Task CloningAsync(CloneContentContext context, AliasPart part) { var clonedPart = context.CloneContentItem.As <AliasPart>(); clonedPart.Alias = await GenerateUniqueAliasAsync(part.Alias, clonedPart); clonedPart.Apply(); }
public override void Cloned(CloneContentContext context) { context.Logger = Logger; foreach (var contentFieldDriver in _drivers) { contentFieldDriver.Cloned(context); } }
protected override void Cloning(TermPart originalPart, TermPart clonePart, CloneContentContext context) { clonePart.Count = originalPart.Count; clonePart.Selectable = originalPart.Selectable; clonePart.Weight = originalPart.Weight; clonePart.TaxonomyId = originalPart.TaxonomyId; clonePart.Path = originalPart.Path; }
public async override Task CloningAsync(CloneContentContext context, AutoroutePart part) { var clonedPart = context.CloneContentItem.As <AutoroutePart>(); clonedPart.Path = await GenerateUniquePathAsync(part.Path, clonedPart); clonedPart.SetHomepage = false; clonedPart.Apply(); }
protected override void Cloning(MediaPart originalPart, MediaPart clonePart, CloneContentContext context) { clonePart.Caption = originalPart.Caption; clonePart.FileName = originalPart.FileName; clonePart.FolderPath = originalPart.FolderPath; clonePart.LogicalType = originalPart.LogicalType; clonePart.AlternateText = originalPart.AlternateText; clonePart.MimeType = originalPart.MimeType; }
void IContentPartDriver.Cloned(CloneContentContext context) { var originalPart = context.ContentItem.As <TContent>(); var clonePart = context.CloneContentItem.As <TContent>(); if (originalPart != null && clonePart != null) { Cloned(originalPart, clonePart, context); } }
public async override Task CloningAsync(CloneContentContext context, AutoroutePart part) { var clonedPart = context.CloneContentItem.As <AutoroutePart>(); clonedPart.Path = await GenerateUniqueAbsolutePathAsync(part.Path, context.CloneContentItem.ContentItemId); clonedPart.SetHomepage = false; clonedPart.Apply(); await GenerateContainedPathsFromPattern(context.CloneContentItem, part); }
public virtual ContentItem Clone(ContentItem contentItem) { var cloneContentItem = New(contentItem.ContentType); Create(cloneContentItem, VersionOptions.Draft); var context = new CloneContentContext(contentItem, cloneContentItem); Handlers.Invoke(handler => handler.Cloning(context), Logger); Handlers.Invoke(handler => handler.Cloned(context), Logger); return cloneContentItem; }
/// <summary> /// This method attempts to synchronize a part across the localization set /// </summary> /// <param name="part">The part that has just been published and that we wish to use to update all corresponding parts from /// the other elements of the localization set.</param> /// <param name="localizationPart">The localization part of the ContentItem that was just published.</param> /// <param name="lSet">The localization set for the synchronization</param> private void Synchronize(ContentPart part, LocalizationPart localizationPart, List <LocalizationPart> lSet) { if (lSet.Count > 0) { var partDrivers = _partDrivers.Where(cpd => cpd.GetPartInfo().FirstOrDefault().PartName == part.PartDefinition.Name); //use cloning foreach (var target in lSet.Select(lp => lp.ContentItem)) { var context = new CloneContentContext(localizationPart.ContentItem, target); partDrivers.Invoke(driver => driver.Cloning(context), context.Logger); partDrivers.Invoke(driver => driver.Cloned(context), context.Logger); } } }
protected override void Cloning(GamePart originalPart, GamePart clonePart, CloneContentContext context) { clonePart.AbstractText = originalPart.AbstractText; clonePart.GameDate = originalPart.GameDate; clonePart.RankingIOSIdentifier = originalPart.RankingIOSIdentifier; clonePart.RankingAndroidIdentifier = originalPart.RankingAndroidIdentifier; clonePart.MyOrder = originalPart.MyOrder; //worflowFired is set in the QuestionnaireServices clonePart.QuestionsSortedRandomlyNumber = originalPart.QuestionsSortedRandomlyNumber; clonePart.RandomResponse = originalPart.RandomResponse; clonePart.AnswerPoint = originalPart.AnswerPoint; clonePart.AnswerTime = originalPart.AnswerTime; //State is set in the Handler clonePart.GameType = originalPart.GameType; }
/// <summary> /// This method attempts to synchronize a field across the localization set /// </summary> /// <param name="field">The field that has just been published and that we wish to use to update all corresponding parts from /// the other elements of the localization set.</param> /// <param name="localizationPart">The localization part of the ContentItem that was just published.</param> /// <param name="lSet">The localization set for the synchronization</param> private void Synchronize(ContentField field, LocalizationPart localizationPart, List <LocalizationPart> lSet) { if (lSet.Count > 0) { var fieldDrivers = _fieldDrivers.Where(cfd => cfd.GetFieldInfo().FirstOrDefault().FieldTypeName == field.FieldDefinition.Name); //use cloning foreach (var target in lSet.Select(lp => lp.ContentItem)) { var context = new CloneContentContext(localizationPart.ContentItem, target); context.FieldName = field.Name; fieldDrivers.Invoke(driver => driver.Cloning(context), context.Logger); fieldDrivers.Invoke(driver => driver.Cloned(context), context.Logger); } } }
public override async Task CloningAsync(CloneContentContext context) { try { if (!await _syncOrchestrator.Clone(context.CloneContentItem)) { // sad paths have already been notified to the user and logged Cancel(context); } } catch (Exception ex) { // we log the exception, even though some exceptions will have already been logged, // as there might have been an 'unexpected' exception thrown _logger.LogError(ex, "Exception cloning."); Cancel(context); } }
public async Task <ContentItem> CloneAsync(ContentItem contentItem) { var cloneContentItem = await NewAsync(contentItem.ContentType); await CreateAsync(cloneContentItem, VersionOptions.Draft); var context = new CloneContentContext(contentItem, cloneContentItem); context.CloneContentItem.Data = contentItem.Data.DeepClone() as JObject; context.CloneContentItem.DisplayText = contentItem.DisplayText; await Handlers.InvokeAsync(handler => handler.CloningAsync(context), _logger); await ReversedHandlers.InvokeAsync(handler => handler.ClonedAsync(context), _logger); _session.Save(context.CloneContentItem); return(context.CloneContentItem); }
protected override void Cloning(SeoPart originalPart, SeoPart clonePart, CloneContentContext context) { clonePart.TitleOverride = originalPart.TitleOverride; clonePart.Keywords = originalPart.Keywords; clonePart.Description = originalPart.Description; clonePart.RobotsNoIndex = originalPart.RobotsNoIndex; clonePart.RobotsNoFollow = originalPart.RobotsNoFollow; clonePart.RobotsNoSnippet = originalPart.RobotsNoSnippet; clonePart.RobotsNoOdp = originalPart.RobotsNoOdp; clonePart.RobotsNoArchive = originalPart.RobotsNoArchive; clonePart.RobotsUnavailableAfter = originalPart.RobotsUnavailableAfter; clonePart.RobotsUnavailableAfterDate = originalPart.RobotsUnavailableAfterDate; clonePart.RobotsNoImageIndex = originalPart.RobotsNoImageIndex; clonePart.GoogleNoSiteLinkSearchBox = originalPart.GoogleNoSiteLinkSearchBox; clonePart.GoogleNoTranslate = originalPart.GoogleNoTranslate; clonePart.HideDetailMicrodata = originalPart.HideDetailMicrodata; clonePart.HideAggregatedMicrodata = originalPart.HideAggregatedMicrodata; clonePart.CanonicalUrl = originalPart.CanonicalUrl; }
public virtual ContentItem Clone(ContentItem contentItem) { var cloneContentItem = New(contentItem.ContentType); Create(cloneContentItem, VersionOptions.Draft); var context = new CloneContentContext(contentItem, cloneContentItem); foreach (var contentHandler in Handlers) { contentHandler.Cloning(context); } foreach (var contentHandler in Handlers) { contentHandler.Cloned(context); } return(cloneContentItem); }
public override async Task CloningAsync(CloneContentContext context) { var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(context.ContentItem.ContentType); if (contentTypeDefinition == null) { return; } foreach (var typePartDefinition in contentTypeDefinition.Parts) { var partName = typePartDefinition.PartDefinition.Name; var activator = _contentPartFactory.GetTypeActivator(partName); var part = context.ContentItem.Get(activator.Type, typePartDefinition.Name) as ContentPart; if (part != null) { await _partHandlers.InvokeAsync(handler => handler.CloningAsync(context, part), Logger); } } }
/// <summary> /// Reset the culture of all widgets in the cloned content if this is a translation /// </summary> /// <param name="context"></param> /// <param name="part"></param> private void ResetWidgetsLocalization(CloneContentContext context, WidgetsContainerPart part) { var baseLocPart = part.ContentItem.As <LocalizationPart>(); if (baseLocPart != null) { var routeData = _wca.GetContext().HttpContext.Request.RequestContext.RouteData.Values; object action, area; if (routeData.TryGetValue("action", out action) && routeData.TryGetValue("area", out area) && action.ToString().ToUpperInvariant() == "TRANSLATE" && area.ToString().ToUpperInvariant() == "ORCHARD.LOCALIZATION") { var widgetsLocParts = _widgetManager .GetWidgets(context.CloneContentItem.Id, context.CloneContentItem.IsPublished()) .Select(wi => wi.ContentItem.As <LocalizationPart>()) .Where(pa => pa != null); foreach (var wLocPart in widgetsLocParts) { wLocPart.Culture = null; } } } }
protected override void Cloning(ContentPart part, InputField originalField, InputField cloneField, CloneContentContext context) { cloneField.Value = originalField.Value; }
protected override void Cloning(CommentsPart originalPart, CommentsPart clonePart, CloneContentContext context) { clonePart.CommentsShown = originalPart.CommentsShown; clonePart.CommentsActive = originalPart.CommentsActive; // ThreadedComments will be overrided with settings default }
protected override void Cloning(ContentPart part, DateTimeField originalField, DateTimeField cloneField, CloneContentContext context) { cloneField.DateTime = originalField.DateTime; }
protected virtual void Cloned(ContentPart part, TField originalField, TField cloneField, CloneContentContext context) { }
void ProcessClone(ContentItem originalItem, ContentItem cloneItem, Action <ContentPart, TField, TField> effort, CloneContentContext context) { var occurences = originalItem .Parts .SelectMany(part => part.Fields.OfType <TField>().Select(field => new { part, field })) .Join(cloneItem .Parts .SelectMany(part => part .Fields .OfType <TField>() .Where(fi => string.IsNullOrWhiteSpace(context.FieldName) || context.FieldName == fi.Name)), original => original.field.Name, cloneField => cloneField.Name, (original, cloneField) => new { original, cloneField }); occurences.Invoke(pf => effort(pf.original.part, pf.original.field, pf.cloneField), context.Logger); }
protected override void Cloning(AudioPart originalPart, AudioPart clonePart, CloneContentContext context) { clonePart.Length = originalPart.Length; }
protected override void Cloning(CookieLawPart originalPart, CookieLawPart clonePart, CloneContentContext context) { clonePart.cookieDiscreetLinkText = originalPart.cookieDiscreetLinkText; clonePart.cookiePolicyPageMessage = originalPart.cookiePolicyPageMessage; clonePart.cookieErrorMessage = originalPart.cookieErrorMessage; clonePart.cookieAcceptButtonText = originalPart.cookieAcceptButtonText; clonePart.cookieAcceptSelectedButtonText = originalPart.cookieAcceptSelectedButtonText; clonePart.cookieResetButtonText = originalPart.cookieResetButtonText; clonePart.cookieWhatAreLinkText = originalPart.cookieWhatAreLinkText; clonePart.cookiePolicyLink = originalPart.cookiePolicyLink; clonePart.cookieMessage = originalPart.cookieMessage; clonePart.cookieWhatAreTheyLink = originalPart.cookieWhatAreTheyLink; }
public virtual void Cloned(CloneContentContext context) { }