public WikiPageTreeNode Create(WikiPage page) { WikiPageTreeNode parent = null; if (page.Parent != null) { parent = _session.Query<WikiPageTreeNode>().FirstOrDefault(x => x.PageId == page.Parent.Id); } var node = new WikiPageTreeNode(page, parent); _session.Save(node); return node; }
/// <summary> /// Initializes a new instance of the <see cref="WikiPage" /> class. /// </summary> /// <param name="parent"> Parent page. </param> /// <param name="pagePath"> Absolute path from wiki root. </param> /// <param name="title"> Page title. </param> /// <param name="template"> Template to use for child pages (if any). </param> public WikiPage(WikiPage parent, PagePath pagePath, string title, PageTemplate template) { if (pagePath == null) throw new ArgumentNullException("pagePath"); if (title == null) throw new ArgumentNullException("title"); Parent = parent; PagePath = pagePath; Title = title; CreatedBy = WikiContext.Current.User; CreatedAt = DateTime.Now; UpdatedAt = DateTime.Now; ChildTemplate = template; _backReferences = new List<WikiPage>(); }
public WikiPageTreeNode(WikiPage page, WikiPageTreeNode parentNode) { if (page == null) throw new ArgumentNullException("page"); if (parentNode == null) { Lineage = string.Format("/{0}/", page.Id); Titles = page.Title; Path = page.PagePath; Depth = 1; } else { Lineage = string.Format("{0}{1}/", parentNode.Lineage, page.Id); Depth = parentNode.Depth + 1; Path = page.PagePath; // level two should not include the parent name (one = root document i.e. "home") Titles = Depth == 2 ? page.Title : string.Format("{0}{{#}}{1}", parentNode.Titles, page.Title); } Page = page; }
public void TestMethod1() { var repos = new Mock<IPageRepository>(); var page = new WikiPage(null, new PagePath("MyTitle"), "PageName", null); page.SetBody(null, "Some comment", repos.Object); }
/// <summary> /// Move page to another parent /// </summary> /// <param name="newParent"> New parent page </param> public virtual void Move(WikiPage newParent) { if (newParent == null) throw new ArgumentNullException("newParent"); var oldParent = Parent; Parent = newParent; DomainEvent.Publish(new PageMoved(this, oldParent)); }
/// <summary> /// Initializes a new instance of the <see cref="IPostLoadProcessor"/> class. /// </summary> /// <param name="page">The page.</param> public PostLoadProcessorContext(WikiPage page, string body) { if (page == null) throw new ArgumentNullException("page"); Page = page; HtmlBody = body; }
/// <summary> /// Can create child pages for the specified on /// </summary> /// <param name="page">Page</param> /// <returns>true if user can perform the operation; otherwise false.</returns> public bool CanCreateBelow(WikiPage page) { return Thread.CurrentPrincipal.IsInRole(WikiRole.Contributor); }
/// <summary> /// View privileges /// </summary> /// <param name="page">Current page</param> /// <returns>true if user can view the specified page; otherwise false.</returns> public bool CanView(WikiPage page) { return Thread.CurrentPrincipal.IsInRole(WikiRole.Viewer) || CanEdit(page); }
/// <summary> /// Delete privileges /// </summary> /// <param name="page">Current page</param> /// <returns>true if user can delete the specified page; otherwise false.</returns> public bool CanDelete(WikiPage page) { return Thread.CurrentPrincipal.IsInRole(WikiRole.Administrator); }
/// <summary> /// Can edit a page /// </summary> /// <param name="page">Page to edit</param> /// <returns>true if user can edit the specified page; otherwise false.</returns> public bool CanEdit(WikiPage page) { return Thread.CurrentPrincipal.IsInRole(WikiRole.User) || Thread.CurrentPrincipal.IsInRole(WikiRole.Contributor) || Thread.CurrentPrincipal.IsInRole(WikiRole.Administrator); }