function &getTree(&$xmap, &$parent, &$params)
 {
     $db =& JFactory::getDBO();
     //DOCMan core interaction API
     include_once JPATH_SITE . "/administrator/components/com_docman/docman.class.php";
     global $_DOCMAN, $_DMUSER;
     if (!is_object($_DOCMAN)) {
         $_DOCMAN = new dmMainFrame();
     }
     if (!is_object($_DMUSER)) {
         $_DMUSER = $_DOCMAN->getUser();
     }
     $_DOCMAN->setType(_DM_TYPE_MODULE);
     $_DOCMAN->loadLanguage('modules');
     require_once $_DOCMAN->getPath('classes', 'utils');
     require_once $_DOCMAN->getPath('classes', 'file');
     require_once $_DOCMAN->getPath('classes', 'model');
     // get the parameters
     $menu = JSite::getMenu();
     $queryparams = $menu->getParams($parent->id);
     $catid = intval($queryparams->get('cat_id', NULL));
     if (!$catid) {
         $link_query = parse_url($parent->link);
         parse_str(html_entity_decode($link_query['query']), $link_vars);
         $catid = JArrayHelper::getValue($link_vars, 'gid', 0);
     }
     $include_docs = JArrayHelper::getValue($params, 'include_docs', 1);
     $include_docs = $include_docs == 1 || $include_docs == 2 && $xmap->view == 'xml' || $include_docs == 3 && $xmap->view == 'html';
     $params['include_docs'] = $include_docs;
     $doc_task = JArrayHelper::getValue($params, 'doc_task', 'doc_details');
     $params['doc_task'] = $doc_task;
     $priority = JArrayHelper::getValue($params, 'cat_priority', $parent->priority);
     $changefreq = JArrayHelper::getValue($params, 'cat_changefreq', $parent->changefreq);
     if ($priority == '-1') {
         $priority = $parent->priority;
     }
     if ($changefreq == '-1') {
         $changefreq = $parent->changefreq;
     }
     $params['cat_priority'] = $priority;
     $params['cat_changefreq'] = $changefreq;
     $priority = JArrayHelper::getValue($params, 'doc_priority', $parent->priority);
     $changefreq = JArrayHelper::getValue($params, 'doc_changefreq', $parent->changefreq);
     if ($priority == '-1') {
         $priority = $parent->priority;
     }
     if ($changefreq == '-1') {
         $changefreq = $parent->changefreq;
     }
     $params['doc_priority'] = $priority;
     $params['doc_changefreq'] = $changefreq;
     $menuid = $parent->id;
     $list = xmap_com_docman::getCategoryTree($xmap, $parent, $params, $catid, $menuid);
     return $list;
 }
// text_pfx = text to show before list (default='')
// text_sfx = text to show after list (default='')
// limits = number of downloads to display (default = '')
// cat_limit = search a specific category ( or list ) if provided (default='')
// itid = override the passed itemid and use this one, if present (default='')
// order_by = how to order the results (default = 0) Most hits=0; Least hits=1; Newest=2;
//            oldest=3; Alphabet=4; Alphabet, reverse=5
// Include the DOCman class
include_once JPATH_ADMINISTRATOR . DS . "components" . DS . "com_docman" . DS . "docman.class.php";
//DOCman core interaction API
global $_DOCMAN, $_DMUSER;
if (!is_object($_DOCMAN)) {
    $_DOCMAN = new dmMainFrame();
    $_DMUSER = $_DOCMAN->getUser();
}
$_DOCMAN->setType(_DM_TYPE_MODULE);
$_DOCMAN->loadLanguage('modules');
// Include some other DOCman classes
require_once $_DOCMAN->getPath('classes', 'utils');
require_once $_DOCMAN->getPath('classes', 'file');
require_once $_DOCMAN->getPath('classes', 'model');
// get the parameters
$show_icon = (int) $params->def('show_icon', 1);
$show_counter = (int) $params->def('show_counter', 1);
$show_category = (int) $params->def('show_category', 1);
$link_type = (int) $params->def('link_type', 0);
$moduleclass_sfx = $params->get('moduleclass_sfx');
$show_list = (int) $params->def('show_list', 0);
$text_pfx = $params->def('text_pfx', '');
$text_sfx = $params->def('text_sfx', '');
$limits = (int) $params->def('limits', '');