Beispiel #1
0
function showCategories($cat, $cname, $extras = "", $levellimit = "4")
{
    $kunena_db =& JFactory::getDBO();
    $kunena_db->setQuery("select id ,parent,name from\n          #__fb_categories" . "\nORDER BY name");
    $mitems = $kunena_db->loadObjectList();
    check_dberror("Unable to load categories.");
    // establish the hierarchy of the menu
    $children = array();
    // first pass - collect children
    foreach ($mitems 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 = catTreeRecurse(0, '', array(), $children);
    // assemble menu items to the array
    $mitems = array();
    $mitems[] = JHTML::_('select.option', '0', _KUNENA_NOPARENT, 'value', 'text');
    $this_treename = '';
    foreach ($list as $item) {
        if ($this_treename) {
            if ($item->id != $mitems && strpos($item->treename, $this_treename) === false) {
                $mitems[] = JHTML::_('select.option', $item->id, $item->treename);
            }
        } else {
            if ($item->id != $mitems) {
                $mitems[] = JHTML::_('select.option', $item->id, $item->treename);
            } else {
                $this_treename = "{$item->treename}/";
            }
        }
    }
    // build the html select list
    $parlist = selectList2($mitems, $cname, 'class="inputbox"  ' . $extras, 'value', 'text', $cat);
    return $parlist;
}
function CategoryList($cat, $cname, $extras = "", $levellimit = 999)
{
    $app = JFactory::getApplication('administrator');
    $db =& JFactory::getDBO();
    $db->setQuery("SELECT *, cid as id, name AS title, parent AS parent_id FROM #__datsogallery_catg ORDER BY name");
    $rows = $db->loadObjectList();
    $children = array();
    asort($children);
    foreach ($rows as $row) {
        $parent = $row->parent_id;
        $list = @$children[$parent] ? $children[$parent] : array();
        array_push($list, $row);
        $children[$parent] = $list;
    }
    $list = JHTML::_('menu.treerecurse', 0, ' ', array(), $children, $levellimit);
    $items = array();
    $text = JRequest::getCmd('task') == 'settings' ? JText::_('JNO') : JText::_('JALL');
    $items[] = JHTML::_('select.option', '', '- ' . $text . ' -');
    foreach ($list as $item) {
        $items[] = JHTML::_('select.option', $item->id, $item->treename);
    }
    $parlist = selectList2($items, $cname, 'class="inputbox" ' . $extras, 'value', 'text', $cat);
    return $parlist;
}