public ThemeFiles Resolve(ThemeItem themeItem) { // todo: implement caching with clear on publish. var stylesheets = new List <ThemeInclude>(); var scripts = new List <ThemeScriptInclude>(); var children = themeItem?.InnerItem.GetChildren() ?? Enumerable.Empty <Item>(); foreach (Item item in children) { if (_templateManager.TemplateIsOrBasedOn(item, StylesheetItem.TemplateId)) { var include = CreateThemeInclude(item); stylesheets.Add(include); } if (_templateManager.TemplateIsOrBasedOn(item, ScriptItem.TemplateId)) { var include = CreateThemeScriptInclude(item); scripts.Add(include); } } return(new ThemeFiles(stylesheets, scripts)); }
public void Process(PopulateScribanMailActionModelArgs args) { EntryItem entryItem = null; CommentItem commentItem = null; var dataItem = args.WorkflowPipelineArgs.DataItem; if (_templateManager.TemplateIsOrBasedOn(dataItem, _settings.EntryTemplateIds)) { entryItem = new EntryItem(args.WorkflowPipelineArgs.DataItem); } else if (_templateManager.TemplateIsOrBasedOn(dataItem, _settings.CommentTemplateIds)) { commentItem = new CommentItem(args.WorkflowPipelineArgs.DataItem); entryItem = _entryManager.GetBlogEntryItemByCommentUri(commentItem.InnerItem.Uri); } if (args.EntryItem == null && entryItem != null) { args.EntryItem = entryItem; } if (args.CommentItem == null && commentItem != null) { args.CommentItem = commentItem; } }
protected void HandleOnItemSaved(Item item) { if (item != null) { if (_templateManager.TemplateIsOrBasedOn(item, _settings.DictionaryEntryTemplateId)) { Logger.Info("Dictionary Entry saved, clearing Translator cache", this); CacheManager.TranslatorCache.ClearCache(); } if (_templateManager.TemplateIsOrBasedOn(item, _settings.ProfanityListTemplateId)) { Logger.Info("Profanity Filter item saved, clearing cache", this); CacheManager.ProfanityFilterCache.ClearCache(); } } }
public override PipelineProcessorResponseValue ProcessRequest() { return(new PipelineProcessorResponseValue { Value = _templateManager.TemplateIsOrBasedOn(RequestContext.Item, _settings.EntryTemplateIds) }); }
/// <summary> /// Finds the current type of item for the given item /// </summary> /// <param name="item">The item to search from</param> /// <param name="templateIds">The template the target item must be based on or derived from</param> /// <param name="templateManager">The <see cref="BaseTemplateManager"/> used to access templates.</param> /// <returns>The target item if found, otherwise null</returns> public static Item FindAncestorByAnyTemplate(this Item item, IEnumerable<ID> templateIds, BaseTemplateManager templateManager) { if (item == null) return null; if (templateManager == null) return null; var currentItem = item; while (currentItem != null && !templateManager.TemplateIsOrBasedOn(currentItem, templateIds)) { currentItem = currentItem.Parent; } return currentItem; }
/// <summary> /// Finds the current type of item for the given item /// </summary> /// <param name="item">The item to search from</param> /// <param name="templateId">The template the target item must be based on or derived from</param> /// <param name="templateManager">The <see cref="BaseTemplateManager"/> used to access templates.</param> /// <returns>The target item if found, otherwise null</returns> public static Item FindAncestorByTemplate(this Item item, ID templateId, BaseTemplateManager templateManager) { if (item == null) { return(null); } if (templateManager == null) { return(null); } var currentItem = item; while (currentItem != null && !templateManager.TemplateIsOrBasedOn(currentItem, templateId)) { currentItem = currentItem.Parent; } return(currentItem); }
/// <summary> /// Determine if an item is based on a given template or if the item's template is based on the given template /// </summary> /// <param name="templateManager">The template manager to use to locate templates.</param> /// <param name="item">The item to test the template of.</param> /// <param name="templateId">The ID of the template which the item's template should be or inherit from.</param> /// <returns>True if the item's template is based on the given templates, otherwise false.</returns> public static bool TemplateIsOrBasedOn(this BaseTemplateManager templateManager, Item item, ID templateId) { return(templateManager.TemplateIsOrBasedOn(item, new[] { templateId })); }