Exemplo n.º 1
0
function showCategories()
{
    global $option, $menutype;
    $database = JFactory::getDBO();
    $my = JFactory::getUser();
    $mainframe = JFactory::getApplication();
    $limit = $mainframe->getCfg('list_limit');
    $section = "com_docman";
    $sectionid = $mainframe->getUserStateFromRequest("sectionid{$section}{$section}", 'sectionid', 0);
    $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $limit);
    $limitstart = $mainframe->getUserStateFromRequest("view{$section}limitstart", 'limitstart', 0);
    $levellimit = $mainframe->getUserStateFromRequest("view{$option}limit{$menutype}", 'levellimit', 10);
    $query = "SELECT  c.*, c.checked_out as checked_out_contact_category, c.parent_id as parent, g.name AS groupname, u.name AS editor" . "\n FROM #__categories AS c" . "\n LEFT JOIN #__users AS u ON u.id = c.checked_out" . "\n LEFT JOIN #__groups AS g ON g.id = c.access" . "\n WHERE c.section='{$section}'" . "\n AND c.published != -2" . "\n ORDER BY parent_id,ordering";
    $database->setQuery($query);
    $rows = $database->loadObjectList();
    if ($database->getErrorNum()) {
        echo $database->stderr();
        return false;
    }
    // establish the hierarchy of the categories
    $children = array();
    // first pass - collect children
    foreach ($rows as $v) {
        $pt = $v->parent;
        $list = @$children[$pt] ? $children[$pt] : array();
        array_push($list, $v);
        $children[$pt] = $list;
    }
    // second pass - get an indent list of the items
    $list = DOCMAN_Utils::mosTreeRecurse(0, '', array(), $children, max(0, $levellimit - 1));
    $list = is_array($list) ? $list : array();
    $total = count($list);
    $pageNav = new DOCMAN_Pagination($total, $limitstart, $limit);
    $levellist = JHTML::_('select.integerlist', 1, 20, 1, 'levellimit', 'size="1" onchange="document.adminForm.submit();"', $levellimit);
    // slice out elements based on limits
    $list = array_slice($list, $pageNav->limitstart, $pageNav->limit);
    $count = count($list);
    // number of Active Items
    $active = 0;
    for ($i = 0; $i < $count; $i++) {
        $query = "SELECT COUNT( d.id )" . "\n FROM #__docman AS d" . "\n WHERE d.catid = " . $list[$i]->id;
        // . "\n AND d.state <> '-2'";
        $database->setQuery($query);
        $active = $database->loadResult();
        $list[$i]->documents = $active;
    }
    // get list of sections for dropdown filter
    $javascript = 'onchange="document.adminForm.submit();"';
    $lists['sectionid'] = JHTML::_('list.section', 'sectionid', $active, $javascript);
    HTML_DMCategories::show($list, $my->id, $pageNav, $lists, 'other');
}
Exemplo n.º 2
0
 /**
  * Joomla 1.0's mosTreeRecurse for backward compat in 1.5
  */
 function mosTreeRecurse($id, $indent, $list, &$children, $maxlevel = 9999, $level = 0, $type = 1)
 {
     if (@$children[$id] && $level <= $maxlevel) {
         foreach ($children[$id] as $v) {
             $id = $v->id;
             if ($type) {
                 $pre = '<sup>|_</sup>&nbsp;';
                 $spacer = '.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
             } else {
                 $pre = '- ';
                 $spacer = '&nbsp;&nbsp;';
             }
             if ($v->parent == 0) {
                 $txt = $v->name;
             } else {
                 $txt = $pre . $v->name;
             }
             $pt = $v->parent;
             $list[$id] = $v;
             $list[$id]->treename = "{$indent}{$txt}";
             $list[$id]->children = count(@$children[$id]);
             $list = DOCMAN_Utils::mosTreeRecurse($id, $indent . $spacer, $list, $children, $maxlevel, $level + 1, $type);
         }
     }
     return $list;
 }