public AddDocumentTask(Page page) : base(page) { NoIndex = page.GetValue<bool>("noIndex"); if (NoIndex) return; Title = page["headline"]; if (string.IsNullOrEmpty(Title)) Title = page.EntityName; TemplateName = page.Template.Name; if (TemplateName == "NewsPage") { var newsPage = page.CastAs<NewsPage>(); Date = newsPage.Date; Subjects = (newsPage["subjects"]?? string.Empty).Split(',','|',';'); } Summary = page["metaDescription"]; if (string.IsNullOrEmpty(Summary)) Summary = page["intro"]; if (string.IsNullOrEmpty(Summary)) { var html = page.GetValue<Html>("body"); if (!html.IsEmpty) Summary = html.GetExtract(150, true).ToString(); } }
internal static void QueueDocumentAdd(Page page) { _queue.Enqueue(new AddDocumentTask(page)); RunThread(); }
internal static void QueueDocumentDelete(Page page) { _queue.Enqueue(new RemoveDocumentTask(page)); RunThread(); }
protected SearchTask(Page page) { Name = page.EntityName; Url = page.Url; }
public RemoveDocumentTask(Page page) : base(page) { }
private static MenuItem GetMenuItemRecursive(Page page, ICollection<Id> menuIds) { var result = GetMenuItem(page); if (result == null) return null; result.Selected = page.Id == menuIds.Last(); var children = page.GetChildren<Page>().Where(c => !c.GetValue<bool>("hideFromMenu")).ToArray(); if (children.Any()) { if (menuIds.Contains(page.Id)) { result.Expanded = true; foreach (var child in children) { var childItem = GetMenuItemRecursive(child, menuIds); if (childItem != null) result.AddChild(childItem); } } else result.Collapsed = true; } return result; }
private static MenuItem GetMenuItem(Page page) { if (page.EntityName.StartsWith("__")) return null; var item = new MenuItem(); item.DisplayName = page.EntityName; item.Url = page.Url; return item; }
public IEnumerable<MenuItem> GetSubMenuItems(Page parentPage) { var homeParts = CmsService.Instance.GetHomeItem().Path.Split('/'); if (parentPage == null) parentPage = CmsService.Instance.GetItem<Page>(); var pageParts = parentPage.Path.Split('/'); if (pageParts.Length - homeParts.Length < 1) return new MenuItem[0]; var selectedIds = CmsService.Instance.GetSelectedMenuIds(); var result = new List<MenuItem>(); foreach (var child in parentPage.GetChildren<Page>().Where(c => !c.GetValue<bool>("hideFromMenu") && !c.EntityName.StartsWith("__"))) { var menuItem = GetMenuItem(child); if (child.Id == selectedIds.Last()) menuItem.Selected = true; else if (selectedIds.Contains(child.Id)) menuItem.Expanded = true; result.Add(menuItem); } return result; }