public IEnumerable <ContentItem> GetChildren(string path) { foreach (var pair in UploadFolderPaths) { if (pair.ParentPath.Equals(path, StringComparison.InvariantCultureIgnoreCase)) { yield return(CreateDirectory(pair)); } else if (path.StartsWith(pair.Path, StringComparison.InvariantCultureIgnoreCase)) { ContentItem dir = CreateDirectory(pair); var subdirPath = path.Substring(pair.Path.Length); if (subdirPath != "") { dir = dir.GetChild(subdirPath); } if (dir != null) { foreach (var child in dir.GetChildren(new NullFilter())) { yield return(child); } } } } }
public virtual ContentItem Navigate(ContentItem startingPoint, string path) { return startingPoint.GetChild(path) ?? sources.ResolvePath(startingPoint, path).CurrentItem ?? virtualNodes.Get(startingPoint.Path + path.TrimStart('/')) ?? virtualNodes.Get(path); }
public bool HasChildren(string path) { foreach (var pair in UploadFolderPaths) { if (pair.ParentPath.Equals(path, StringComparison.InvariantCultureIgnoreCase)) { return(true); } if (pair.Path.Equals(path, StringComparison.InvariantCultureIgnoreCase)) { return(true); } if (path.StartsWith(pair.Path, StringComparison.InvariantCultureIgnoreCase)) { ContentItem dir = CreateDirectory(pair); var remaining = path.Substring(pair.Path.Length); if (!string.IsNullOrEmpty(remaining)) { dir = dir.GetChild(remaining); } if (dir != null) { return(dir.GetChildren().Any()); } } } return(false); }
public void CopyWithChildren() { ContentItem root = CreateRoot("root", "root item"); ContentItem item1 = CreateAndSaveItem("item1", "item one", root); ContentItem item2 = CreateAndSaveItem("item2", "item two", root); using (engine.Persister) { engine.Persister.Copy(item1, item2); engine.Persister.Copy(item2, item1); Assert.AreEqual(root.Children.Count, 2); Assert.AreEqual(item1.Children.Count, 1); Assert.AreEqual(item2.Children.Count, 1); ContentItem item1copy = item2.GetChild("item1"); Assert.IsNotNull(item1copy); Assert.AreNotEqual(item1copy, item1); ContentItem item2copy = item1.GetChild("item2"); Assert.IsNotNull(item2copy); Assert.AreNotEqual(item2copy, item2); ContentItem item1copyofcopy = item2copy.GetChild("item1"); Assert.IsNotNull(item1copyofcopy); Assert.AreNotEqual(item1copyofcopy, item1copy); } }
public virtual ContentItem Navigate(ContentItem startingPoint, string path) { return(startingPoint.GetChild(path) ?? sources.ResolvePath(startingPoint, path).CurrentItem ?? virtualNodes.Get(startingPoint.Path + path.TrimStart('/')) ?? virtualNodes.Get(path)); }
public static ContentItem WalkPath(ContentItem startItem, string path) { // find starting point if (path.StartsWith("/")) { startItem = Context.Current.Persister.Get(Context.Current.Host.CurrentSite.RootItemID); path = path.Substring(1); } else if (path.StartsWith("~/")) { startItem = Context.Current.UrlParser.StartPage; path = path.Substring(2); } // walk path ContentItem item = startItem; string[] names = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); foreach (string name in names) { if (item == null) { break; } else if (name == "..") { item = item.Parent; } else if (name != "." && !string.IsNullOrEmpty(name)) { item = item.GetChild(name); } } return(item); }
/// <summary>Checks that destination have no child item with the same name.</summary> public virtual bool IsNameOccupiedOnDestination(ContentItem source, ContentItem destination, bool excludeMyself = true) { if (source == null) { throw new ArgumentNullException("source"); } if (destination == null) { throw new ArgumentNullException("destination"); } ContentItem existingItem = destination.GetChild(source.Name); if (existingItem == null) { return(false); } if (excludeMyself && existingItem == source) { return(false); } if (!excludeMyself && source.Name == source.ID.ToString()) { return(false); } return(true); }
protected override ContentItem GetChild(ContentItem item) { ContentItem childItem = item.GetChild(DefaultChildName); if (childItem == null) { childItem = CreateChild(item, ChildType); } return childItem; }
protected override ContentItem GetChild(ContentItem item) { ContentItem childItem = item.GetChild(DefaultChildName); if (childItem == null) { childItem = CreateChild(item, ChildType); } return(childItem); }
/// <summary>Checks that destination have no child item with the same name.</summary> public virtual bool IsNameOccupiedOnDestination(ContentItem source, ContentItem destination) { if (source == null) { throw new ArgumentNullException("source"); } if (destination == null) { throw new ArgumentNullException("destination"); } ContentItem existingItem = destination.GetChild(source.Name); return(existingItem != null && existingItem != source); }
protected virtual ContentItem Parse(ContentItem current, string url) { if (current == null) { throw new ArgumentNullException("current"); } logger.Debug("Parsing " + url); url = CleanUrl(url); if (url.Length == 0) { return(current); } return(current.GetChild(url) ?? NotFoundPage(url)); }
protected virtual ContentItem Parse(ContentItem current, Url url) { if (current == null) { throw new ArgumentNullException("current"); } logger.Debug("Parsing " + url); var path = CleanUrl(url.PathAndQuery); if (path.Length == 0) { return(current); } return(current.GetChild(path) ?? NotFoundPage(url)); }
public void Move() { using (engine.Persister) { ContentItem root = CreateRoot("root", "root item"); ContentItem item1 = CreateAndSaveItem("item1", "item one", root); ContentItem item2 = CreateAndSaveItem("item2", "item two", root); engine.Persister.Move(item1, item2); Assert.AreEqual(1, root.Children.Count); Assert.AreEqual(0, item1.Children.Count); Assert.AreEqual(1, item2.Children.Count); Assert.AreEqual(item2, root.GetChild("item2")); Assert.AreEqual(item1, item2.GetChild("item1")); } }
public ContentItem Navigate(ContentItem startingPoint, string path) { return startingPoint.GetChild(path) ?? virtualNodes.Get(startingPoint.Path + path.TrimStart('/')) ?? virtualNodes.Get(path); }
protected virtual ContentItem Parse(ContentItem current, string url) { if (current == null) throw new ArgumentNullException("current"); Debug.WriteLine("Parsing " + url); url = CleanUrl(url); if (url.Length == 0) return current; return current.GetChild(url) ?? NotFoundPage(url); }
public ContentItem Navigate(ContentItem startingPoint, string path) { return startingPoint.GetChild(path) ?? virtualNodes.Get(path); }
/// <summary>Checks that destination have no child item with the same name.</summary> public virtual bool IsNameOccupiedOnDestination(ContentItem source, ContentItem destination, bool excludeMyself = true) { if (source == null) throw new ArgumentNullException("source"); if (destination == null) throw new ArgumentNullException("destination"); ContentItem existingItem = destination.GetChild(source.Name); if (existingItem == null) return false; if (excludeMyself && existingItem == source) return false; if (!excludeMyself && source.Name == source.ID.ToString()) return false; return true; }
protected virtual ContentItem Parse(ContentItem current, Url url) { if (current == null) throw new ArgumentNullException("current"); logger.Debug("Parsing " + url); var path = CleanUrl(url.PathAndQuery); if (path.Length == 0) return current; return current.GetChild(path) ?? NotFoundPage(url); }
/// <summary>Checks that destination have no child item with the same name.</summary> public virtual bool IsNameOccupiedOnDestination(ContentItem source, ContentItem destination) { if (source == null) throw new ArgumentNullException("source"); if (destination == null) throw new ArgumentNullException("destination"); ContentItem existingItem = destination.GetChild(source.Name); return existingItem != null && existingItem != source; }
public ContentItem Navigate(ContentItem startingPoint, string path) { return(startingPoint.GetChild(path) ?? virtualNodes.Get(path)); }
protected virtual ContentItem Parse(ContentItem current, string url) { if (current == null) throw new ArgumentNullException("current"); url = CleanUrl(url); if (url.Length == 0) return current; // Check if start of URL contains a language identifier. foreach (Language language in Context.Current.LanguageManager.GetAvailableLanguages()) if (url.StartsWith(language.Name, StringComparison.InvariantCultureIgnoreCase)) throw new NotImplementedException(); return current.GetChild(url) ?? NotFoundPage(url); }