Exemple #1
0
 public Builder ForCustomNativeAd(string templateId, Action <CustomNativeTemplateAd, string> callback)
 {
     TemplateIds.Add(templateId);
     CustomNativeTemplateClickHandlers[templateId] = callback;
     AdTypes.Add(NativeAdType.CustomTemplate);
     return(this);
 }
Exemple #2
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 AddOrUpdateTemplateId(string fundingStreamId,
                                   string templateId)
 {
     if (TemplateIds.ContainsKey(fundingStreamId))
     {
         TemplateIds[fundingStreamId] = templateId;
     }
     else
     {
         TemplateIds.Add(fundingStreamId, templateId);
     }
 }
Exemple #4
0
 internal bool IsEmpty()
 {
     return((!TemplateIds?.Any() ?? true) && (!Children?.Any() ?? true));
 }
 /// <summary>
 /// Add a template to this request.
 /// You can call this multiple times to add multiple templates to a request,
 /// but templates must have compatible roles to be used together.
 /// </summary>
 /// <param name="templateId"></param>
 public void AddTemplate(string templateId)
 {
     TemplateIds.Add(templateId);
 }
        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 #7
0
 public Builder ForCustomNativeAd(string templateId)
 {
     TemplateIds.Add(templateId);
     AdTypes.Add(NativeAdType.CustomTemplate);
     return(this);
 }
 public bool TemplateVersionHasChanged(string fundingStreamId,
                                       string templateId)
 => !TemplateIds.TryGetValue(fundingStreamId, out string currentTemplate) ||
 currentTemplate != templateId;
Exemple #9
0
 public virtual bool IsDerived(Guid templateId)
 {
     return(TemplateIds?.Contains(templateId) ?? false);
 }