I should have posted this blog couple of weeks back and reflects the work done between June 1st and June 10th. The primary task was to implement the architecture [https://community.joomla.org/gsoc2009/gartheeban-ganneshapillai/831-architecture-design-taxonomy-extension-project.html] in Joomla! library. Albeit having clear specs [https://community.joomla.org/gsoc2009/gartheeban-ganneshapillai/862-taxonomy-extension-design-spec-and-api.html] about the final outcome, it was not straight forward as Joomla! follows a distinct OOP based design highly inclined towards Factory pattern.
The first hurdle was to follow Joomla! style i.e. using JTable for CURD while ensuring that the performance and features are not limited by it. Also as it is Joomla! 1.6 that is targetted and there is no clear documentation available, I chose to follow JUser (a core joomla library class) as reference because it parallels JTaxonomyTree and JTaxonomyLeaf two primary classes exposed by Taxonomy framework. This post talks about the library design.
I had some discussion with the mentors as where to place the taxonomy library folder, and finally it was decided to go under libraries/joomla/taxonomy, although it could be moved later to to libraries/taxonomy if it is deemed to be more appropriate.< p>
- The latest code can be checked here : http://labs.joomla.org/svn/labs/playground/people/garthee/trunk/
- The demo can be tried at (need not parallel the version in SVN) : http://gsoc.theebgar.net/administrator/index.php?option=com_taxonomy (username : admin, password - why dont you drop a mail at ?)
JTaxonomy
At the root JTaxonomy class which extends JClass, exposes the full set of features. It is used in a singleton form and must be invoked as
jimport('joomla.taxonomy.taxonomy');
$taxonomy =&JTaxonomy::getInstance();
This class provides the following set of methods
1. Tree related
&getTreeList($extension = null)
&getTrees($extension = null)
&getTree($id = 0, $options = null)
First returns an array of tree names keyed by tree IDs, second returns an array tree objects keyed by tree IDs, and the last gives tree object for the given tree ID. They are eventually routed through JTaxonomyTree which provides the implmentation for trees.
2. Leaf related
&getLeafList($options = null)
&getLeaves($options = null)
&getLeaf($id = 0, $options = null)
&getLeafHierarchy($tid, $options = null)
The last function exposes an important function implemented in a helper class. It builds a complete leaf hierarchy under a given tree.
3. Map related
&getMap()
It returns a TaxonomyMap object that provides methods handling leaf mapping.
JTaxonomyTree
JTaxonomyTree extends JClass, and mainly handles the CRUD operations that are routed through its JTable subclass JTabeTaxTree class.
JTaxonomyLeaf
JTaxonomyLeaf extends JClass, and mainly handles the CRUD operations that are routed through its JTable subclass JTabeTaxLeaf class.
JTaxonomyMap
This class handles the object - leaf mapping, the fundamental operation of taxonomy frame, through standard methods. The implementation is expected to change with the requirements imposed along the way, which will be actually finalized later with the implementation of com_contentPlus (a content component with taxonomy support). This class together with JHTMLTaxonomy is expected to provide a complete form support for integration with any components easily.
Summary
Although the feature sets of Taxonomy Library is currently completely determined, it might evolve with the requirements of components and plugins as demanded. Hence it is provided here for reference and feedback only. In the next blog I will discuss the dilemma we had in compromising between performance, standard pattern and generality and steps we took.