Exemple #1
0
        public void ProcessPublish(ID itemId)
        {
            try
            {
                var item = processArgs.PublishOptions.SourceDatabase.GetItem(itemId);

                if (TemplateIds.Contains(item.TemplateID) == false)
                {
                    return;
                }

                mediaItems = new List <ID>();

                //Find and Parse media items from Body section
                if (item.Fields["Body"] != null && string.IsNullOrEmpty(item.Fields["Body"].Value) == false)
                {
                    var body = item.Fields["Body"].Value;

                    addMediaItemsFromTextToDictionary(body);
                }

                //Find and Parse media items from Summary section
                if (item.Fields["Summary"] != null && string.IsNullOrEmpty(item.Fields["Summary"].Value) == false)
                {
                    var summary = item.Fields["Summary"].Value;

                    addMediaItemsFromTextToDictionary(summary);
                }

                //Get the media item from the featured Image
                if (item.Fields["Featured Image 16 9"] != null && string.IsNullOrEmpty(item.Fields["Featured Image 16 9"].Value) == false)
                {
                    Regex featuredRegex = new Regex("{.*}");
                    Match match         = featuredRegex.Match(item.Fields["Featured Image 16 9"].Value);

                    addMediaItemsByIdToDictionary(new ID(match.Value));
                }

                //Get the media items from the Supporting Documents
                if (item.Fields["Supporting Documents"] != null && string.IsNullOrEmpty(item.Fields["Supporting Documents"].Value) == false)
                {
                    foreach (var doc in item.Fields["Supporting Documents"].Value.Split('|'))
                    {
                        if (string.IsNullOrEmpty(doc) == false)
                        {
                            addMediaItemsByIdToDictionary(new ID(doc));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Sitecore.Diagnostics.Log.Error(ex.ToString(), this);
            }
        }
        public void Process(object sender, EventArgs args)
        {
            var publishArgs = args as ItemProcessingEventArgs;

            if (publishArgs == null)
            {
                return;
            }

            var item = publishArgs.Context.PublishHelper.GetSourceItem(publishArgs.Context.ItemId);

            if (item == null || (IgnoreStandardValues && item.Name.IsStandardValues()) || (TemplateIds.Any() && !TemplateIds.Contains(item.TemplateID)))
            {
                return;
            }

            ProcessPublish(item, publishArgs);
        }
Exemple #3
0
 public virtual bool IsDerived(Guid templateId)
 {
     return(TemplateIds?.Contains(templateId) ?? false);
 }