Item916: Need a Func: call to return the topic hierarchy for a topic.
Priority: Enhancement
Current State: No Action Required
Released In: n/a
Target Release: n/a
Applies To: Engine
Component: Store
Branches:
Plugins need a way to explode a Topic's child or parent hierarchy. It seems as though this should be useful in both Core and Plugins.
GenPDFAddOn currently uses a brute force fgrep against all .txt files in the file system for the Web's directory. It searches for %META:TOPICPARENT data. This implementation is tied to the file system and won't survive any store rewrite. It also currently runs into taint issues with the "chdir" command on Foswiki.
I expect that other plugins have similar requirements, I propose that the topic hierarchy should probably be implemented as part of Store, so that parent/child topic relationships can be optimized when possible in the backend systems.
Functions could include something like:
- listTopicAncestors
- Return a list of all ancestor topics from named topic up through first ancestor. (Equivalent of breadcrumbs)
- listTopicDescendents
- Return a complete lists of all children and their children, up to a configurable maximum depth.
- listTopicChildren
- Return a simple list of child topics. (Equivalent to listTopicDescendents with a depth of 1.)
- listTopicParent
- Return parent topic
- reparentTopic
- Replace the parent topic of a specified topic.
- listOrphanTopics
- Return a list of topics with no parent set (or set but missing).
Functions should only (optionally?) return topics that are visible to the current user. It might also be useful to apply an optional bounds to the current web, or include a function to find topics where a parent or children are in a different web.
I've been using
DBCachePlugin and DBRECURSE to perform this task in wiki applications (see
Support.IncludeTopicHierarchyIntoDotGraphs for an example). But I am also working on a plugin to take advantage of these hierarchies.
It's a satisfactory (cached) solution that should hopefully survive re-implementing the store away from files/RCS.
I'm also using DBRECURSE to iterate over relationships other than TOPICPARENT.
There are a couple of caveats to using DBRECURSE and DBQUERY though, see
Item2033
--
PaulHarvey - 26 Oct 2009
I'm going to no-action this. The Query search enhancements coming are sufficient. No need to add to Func API.
--
GeorgeClark - 14 Mar 2011