protected override void Unpublished(PublishContentContext context) { var contentTags = context.ContentItem.As<TagsPart>(); if (contentTags != null) { _signals.Trigger(TagCloudService.VandelayTagcloudTagschanged); } base.Unpublished(context); }
public void Publishing(PublishContentContext context, FieldIndexPart fieldIndexPart) { foreach (var part in fieldIndexPart.ContentItem.Parts) { foreach(var field in part.PartDefinition.Fields) { // get all drivers for the current field type // the driver will describe what values of the field should be indexed var drivers = _contentFieldDrivers.Where(x => x.GetFieldInfo().Any(fi => fi.FieldTypeName == field.FieldDefinition.Name)).ToList(); ContentPart localPart = part; ContentPartFieldDefinition localField = field; var membersContext = new DescribeMembersContext( (storageName, storageType, displayName, description) => { var fieldStorage = _fieldStorageProvider.BindStorage(localPart, localField); // fieldStorage.Get<T>(storageName) var getter = typeof(IFieldStorage).GetMethod("Get").MakeGenericMethod(storageType); var fieldValue = getter.Invoke(fieldStorage, new[] {storageName}); _fieldIndexService.Set(fieldIndexPart, localPart.PartDefinition.Name, localField.Name, storageName, fieldValue, storageType); }); foreach (var driver in drivers) { driver.Describe(membersContext); } } } }
protected override void Unpublished(PublishContentContext context) { var contentTags = context.ContentItem.As<TagsPart>(); if (contentTags != null) { _signals.Trigger(TagsMenuItemEvent.TagsChanged); } base.Unpublished(context); }
private void OnPublishing(PublishContentContext context, EntityMetadataPart part) { if (context.PreviousItemVersionRecord == null) { CreateEntity(part); } else { var previousEntity = _contentManager.Get<EntityMetadataPart>(context.Id); UpdateEntity(previousEntity, part); } }
void CreateIndexingTask(PublishContentContext context, ContentPart part) { // "Unpublish" case: Same as "remove" if (context.PublishingItemVersionRecord == null) { _indexingTaskManager.CreateDeleteIndexTask(context.ContentItem); return; } // "Publish" case: update index _indexingTaskManager.CreateUpdateIndexTask(context.ContentItem); }
protected override void Unpublished(PublishContentContext context) { var contentTags = context.ContentItem.As<TagsPart>(); if (contentTags != null) { _signals.Trigger(LocalizedTagsService._localizedTagcloudTagsChanged); } base.Unpublished(context); }
private void DeferOrPublishAssets(PublishContentContext context, CloudVideoPart part) { if (part.MezzanineAsset != null && part.MezzanineAsset.UploadState.Status != AssetUploadStatus.Uploaded) { part.PublishOnUpload = true; _notifier.Warning(T("The cloud video item was saved, but will not be published until the primary video asset has finished uploading to Windows Azure Media Services.")); context.Cancel = true; } else _assetManager.PublishAssetsFor(part); }
private void ScheduleUnpublish(PublishContentContext ctx, ProductPart part) { _scheduledTaskManager.DeleteTasks(part.ContentItem, t => t.TaskType == Constants.UnpublishTaskName); var settings = _workContextAccessor.GetContext().CurrentSite.Get<ProductSettingsPart>(); if (settings.HideProductDelay > 0) { // Schedule the unpublish moment var dateToUnpublish = DateTime.UtcNow.AddDays(settings.HideProductDelay); _scheduledTaskManager.CreateTask(Constants.UnpublishTaskName, dateToUnpublish, part.ContentItem); } }
public override void Published(PublishContentContext context) { var utcNow = _clock.UtcNow; // The first time the content is published, reassign the CreateUtc value if(!context.ContentItem.PublishedUtc.HasValue) { context.ContentItem.CreatedUtc = utcNow; } context.ContentItem.PublishedUtc = utcNow; }
private void UpdateContentItemRoleSecurityRecords(PublishContentContext context, ContentItem contentItem) { var roles = _roleService.GetRoles(); var allowedRoles = new List<RoleRecord>(); bool canAnonView = _authorizationService.TryCheckAccess( _permission, null /* null signifies anon user */, contentItem); foreach (var role in roles) { var user = UserSimulation.Create(role.Name); if (_authorizationService.TryCheckAccess( _permission, user, contentItem) ) { allowedRoles.Add(role); } } /* Delete and maintain a fresh one on each publish */ var currentRecord = _roleSecurityRepository .Get(o => o.ContentItemRecord == contentItem.Record); if (currentRecord != null) _roleSecurityRepository.Delete(currentRecord); PermissionRecord permissionRecord = _permissionRepository .Get(x => x.Name == _permission.Name); var entity = new RoleSecurityRecord{ ContentItemRecord = contentItem.Record, AnonymousCanView = canAnonView, Permission = permissionRecord}; _roleSecurityRepository.Create(entity); foreach (var allowedRole in allowedRoles) { entity.RolesSecurities.Add( new RolesSecuritiesRecord{ Role = allowedRole, RoleSecurity = entity }); } }
protected override void Published(PublishContentContext context) { // Check inverse of connector var part = context.ContentItem.As<ConnectorPart>(); if (part!=null) { if (part.InverseConnector != null) { // Make sure inverse has the correct version part.InverseConnector.RightContentVersionId = part.LeftContentVersionId; // Publish the inverse if (!part.InverseConnector.IsPublished()) { Services.ContentManager.Publish(part.InverseConnector.ContentItem); } } } // Publish all connectors of socket var socket = context.ContentItem.As<SocketsPart>(); if (socket!=null) { socket.Sockets.Flush(); PublishConnectors(socket); // TODO: PERF: Could end up with a lot of overhead and triggering all the time when, say, adding comments or any old thing. Actually only need to do this for // specific things like menus. Trigger(socket); } }
private void UpdatePublishedValues(PublishContentContext context, VersionInfoPart part) { part.Draft = false; part.Removed = false; }
protected override void Published(PublishContentContext context) { if (context.ContentItem.Has<ImageProfilePart>()) _signals.Trigger("MediaProcessing_Published_" + context.ContentItem.As<ImageProfilePart>().Name); base.Published(context); }
void Generate(PublishContentContext context, ContentPart part) { if(_orchardServices.WorkContext.CurrentSite.As<WarmupSettingsPart>().OnPublish) { _warmupScheduler.Schedule(true); } }
protected virtual void Publishing(PublishContentContext context) { }
private void UpdateTemplateClients(PublishContentContext context, LayoutPart part) { UpdateTemplateClients(part); }
private static void CreateFilterGroup(PublishContentContext ctx, QueryPart part) { if (!part.FilterGroups.Any()) { part.FilterGroups.Add(new FilterGroupRecord()); } }
public async Task Publish(ContentItem contentItem) { if (contentItem.VersionRecord.Published) { return; } // create a context for the item and it's previous published record var previous = await _session .QueryAsync<ContentItemVersionRecord, ContentItemVersionRecordIndex>(x => x.ContentItemId == contentItem.Id && x.Published) .FirstOrDefault(); var context = new PublishContentContext(contentItem, previous); // invoke handlers to acquire state, or at least establish lazy loading callbacks Handlers.Invoke(handler => handler.Publishing(context), _logger); if (context.Cancel) { return; } if (previous != null) { previous.Published = false; } contentItem.VersionRecord.Published = true; Handlers.Invoke(handler => handler.Published(context), _logger); }
void IContentHandler.Publishing(PublishContentContext context) { }
public void Unpublished(PublishContentContext context) { TriggerIfGraph(context); }
public virtual void Create(ContentItem contentItem, VersionOptions options) { if (contentItem.Number == 0) { contentItem.Number = 1; contentItem.Latest = true; contentItem.Published = true; } // Version may be specified if (options.VersionNumber != 0) { contentItem.Number = options.VersionNumber; } // Draft flag on create is required for explicitly-published content items if (options.IsDraft) { contentItem.Published = false; } // Build a context with the initialized instance to create var context = new CreateContentContext(contentItem); // invoke handlers to add information to persistent stores Handlers.Invoke(handler => handler.Creating(context), _logger); Handlers.Invoke(handler => handler.Created(context), _logger); if (options.IsPublished) { var publishContext = new PublishContentContext(contentItem, null); // invoke handlers to acquire state, or at least establish lazy loading callbacks Handlers.Invoke(handler => handler.Publishing(publishContext), _logger); // invoke handlers to acquire state, or at least establish lazy loading callbacks Handlers.Invoke(handler => handler.Published(publishContext), _logger); } _session.Save(contentItem); _contentManagerSession.Store(contentItem); }
public virtual void Publishing(PublishContentContext context, TPart instance) { }
public async Task PublishAsync(ContentItem contentItem) { if (contentItem.Published) { return; } // Create a context for the item and it's previous published record // Because of this query the content item will need to be re-enlisted // to be saved. var previous = await _session .QueryAsync<ContentItem, ContentItemIndex>(x => x.ContentItemId == contentItem.ContentItemId && x.Published) .FirstOrDefault(); var context = new PublishContentContext(contentItem, previous); // invoke handlers to acquire state, or at least establish lazy loading callbacks Handlers.Invoke(handler => handler.Publishing(context), _logger); if (context.Cancel) { return; } if (previous != null) { _session.Save(previous); previous.Published = false; } contentItem.Published = true; _session.Save(contentItem); Handlers.Invoke(handler => handler.Published(context), _logger); }
protected override void Unpublishing(PublishContentContext context) { var part = context.ContentItem.As<SocketsPart>(); if (part!=null) UnpublishSocket(part); }
private void FinalizePath(RoutePart route, PublishContentContext context, Action<RoutePart> processSlug) { var path = route.Path; route.Path = route.GetPathWithSlug(route.Slug); if (context.PublishingItemVersionRecord != null) processSlug(route); // if the path has changed by having the slug changed on the way in (e.g. user input) or to avoid conflict // then update and publish all contained items if (path != route.Path) { _routablePathConstraint.RemovePath(path); _routableService.FixContainedPaths(route); } if (!string.IsNullOrWhiteSpace(route.Path)) _routablePathConstraint.AddPath(route.Path); }
public virtual void Unpublished(PublishContentContext context, TPart instance) { }
public void Unpublishing(PublishContentContext context) { }
private void CancelAndUnpublishAssets(PublishContentContext context, CloudVideoPart part) { part.PublishOnUpload = false; _assetManager.UnpublishAssetsFor(part); }
protected virtual void Unpublished(PublishContentContext context) { }
protected override void Unpublished(PublishContentContext context) { base.Unpublished(context); }
public virtual void Create(ContentItem contentItem, VersionOptions options) { if (contentItem.VersionRecord == null) { // produce root record to determine the model id contentItem.VersionRecord = new ContentItemVersionRecord { Number = 1, Latest = true, Published = true }; } // add to the collection manually for the created case contentItem.VersionRecord.ContentType = contentItem.ContentType; // version may be specified if (options.VersionNumber != 0) { contentItem.VersionRecord.Number = options.VersionNumber; } // draft flag on create is required for explicitly-published content items if (options.IsDraft) { contentItem.VersionRecord.Published = false; } // build a context with the initialized instance to create var context = new CreateContentContext(contentItem); // invoke handlers to add information to persistent stores Handlers.Invoke(handler => handler.Creating(context), _logger); Handlers.Invoke(handler => handler.Created(context), _logger); if (options.IsPublished) { var publishContext = new PublishContentContext(contentItem, null); // invoke handlers to acquire state, or at least establish lazy loading callbacks Handlers.Invoke(handler => handler.Publishing(publishContext), _logger); // invoke handlers to acquire state, or at least establish lazy loading callbacks Handlers.Invoke(handler => handler.Published(publishContext), _logger); } _session.Save(contentItem.Record); contentItem.VersionRecord.ContentItemId = contentItem.Record.Id; _session.Save(contentItem.VersionRecord); _contentManagerSession.Store(contentItem); }
public async Task UnpublishAsync(ContentItem contentItem) { ContentItem publishedItem; if (contentItem.Published) { // The version passed in is the published one publishedItem = contentItem; } else { // Try to locate the published version of this item publishedItem = await GetAsync(contentItem.ContentItemId, VersionOptions.Published); } if (publishedItem == null) { // No published version exists. no work to perform. return; } // Create a context for the item. the publishing version is null in this case // and the previous version is the one active prior to unpublishing. handlers // should take this null check into account var context = new PublishContentContext(contentItem, publishedItem) { PublishingItem = null }; Handlers.Invoke(handler => handler.Unpublishing(context), _logger); publishedItem.Published = false; _session.Save(contentItem); Handlers.Invoke(handler => handler.Unpublished(context), _logger); }
protected override void Publishing(PublishContentContext context) { base.Publishing(context); }
protected void AssignPublishingDates(PublishContentContext context, CommonPart part) { var utcNow = _clock.UtcNow; part.PublishedUtc = utcNow; part.VersionPublishedUtc = utcNow; }
public override void Unpublished(PublishContentContext context) { var utcNow = _clock.UtcNow; context.ContentItem.PublishedUtc = null; }