public ActivityStreamContentDescription GetContentDescription(ActiviyStreamWriterContext context) { if (!this.CanApply(context)) { return(null); } TitlePart part = context.ContentItem.As <TitlePart>(); string contentType = context.ContentItem.TypeDefinition.DisplayName; string description = string.Empty; // new item if (context.Snapshot == null) { description = string.Format("Creates new {0} - {1}", contentType, part.Title); } else { description = string.Format("updates {0} - '{1}'", contentType, part.Title); } return(new ActivityStreamContentDescription(this.Name) { Description = description, Weight = 10 }); }
public ApprenticeshipStandardContentItem(string title, string timestamp, string contentItemId = null) : base("ApprenticeshipStandard", title, timestamp, contentItemId) { TitlePart = new TitlePart(title); GraphSyncPart = new GraphSyncPart("ApprenticeshipStandard"); DisplayText = TitlePart.Title; }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { writer.WriteStartObject(); TitlePart contentPart = value as TitlePart; // Title Utility.WriteProperty("Title", contentPart.Title, writer, serializer); this.WriteCommonFields(writer, contentPart, serializer); writer.WriteEnd(); }
public ContentItem CreateProjection(string contentType, string queryName, string title, string itemContentType, int maxItems) { // get query var query = this.GetQuery(queryName); if (query != null) { var contentItem = contentManager.New(contentType); contentManager.Create(contentItem); // projection var projection = contentItem.As <ProjectionWithDynamicSortPart>(); projection.Record.QueryPartRecord = query.Record; projection.Record.MaxItems = maxItems; // layout var layout = this.layoutRepository.Table.FirstOrDefault(c => c.QueryPartRecord.Id == query.Id && c.Category == "Html" && c.Type == "Shape"); if (layout != null) { projection.Record.LayoutRecord = layout; } // Title TitlePart titlePart = contentItem.As <TitlePart>(); titlePart.Title = title; // item type var projectProjectionPart = contentItem.Parts.FirstOrDefault(c => c.PartDefinition.Name == ContentTypes.ProjectProjectionContentType); if (projectProjectionPart != null) { var field = projectProjectionPart.Fields.FirstOrDefault(c => c.Name == FieldNames.ProjectProjectionItemTypeFieldName); if (field != null) { ((InputField)field).Value = itemContentType; } var displayField = projectProjectionPart.Fields.FirstOrDefault(c => c.Name == FieldNames.ProjectProjectionItemTypeDisplayFieldName); if (displayField != null) { var contentTypeDefinition = this.contentManager.GetContentTypeDefinitions().FirstOrDefault(c => c.Name == itemContentType); ((InputField)displayField).Value = contentTypeDefinition.DisplayName; } } this.contentManager.Publish(contentItem); return(contentItem); } return(null); }
public TitleTextDescriptionContentItem(string contentType, string title, string timestamp, string description, string contentItemId = null) : base(contentType, title, timestamp, contentItemId) { TitlePart = new TitlePart(title); GraphSyncPart = new GraphSyncPart(contentType); EponymousPart = new TitleTextDescriptionPart { Description = new TextField(description) }; // update DisplayText with transformed title //todo: transform DisplayText and use that to initialize title? DisplayText = TitlePart.Title; }