function listcats($cat_id, $cat_parent, $option) { global $mainframe, $mtconf; $database =& JFactory::getDBO(); $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mtconf->getjconf('list_limit')); $limitstart = $mainframe->getUserStateFromRequest("viewcli{$option}limitstart", 'limitstart', 0); if ($cat_id == 0 && $cat_parent > 0) { $cat_id = $cat_parent; } # Creating db connection to #__mt_cats $mtCats = new mtCats($database); $mtCats->load($cat_id); # Page Navigation jimport('joomla.html.pagination'); $pageNav = new JPagination($mtCats->getNumOfLinks_NoRecursive($cat_id), $limitstart, $limit); # Main query - category $sql = 'SELECT cat.* FROM #__mt_cats AS cat ' . 'WHERE cat_parent = ' . $database->quote($cat_id) . ' AND cat_approved = 1 '; if ($mtconf->get('first_cat_order1') != '') { $sql .= ' ORDER BY ' . $mtconf->get('first_cat_order1') . ' ' . $mtconf->get('first_cat_order2'); if ($mtconf->get('second_cat_order1') != '') { $sql .= ', ' . $mtconf->get('second_cat_order1') . ' ' . $mtconf->get('second_cat_order2'); } } $database->setQuery($sql); if (!($result = $database->query())) { echo $database->stderr(); return false; } $cats = $database->loadObjectList(); # Get Pathway $pathWay = new mtPathWay($cat_id); # Get Links for this category $sql = "SELECT l.*, COUNT(r.rev_id) AS reviews, cl.main AS main FROM (#__mt_links AS l, #__mt_cl AS cl)" . "\nLEFT JOIN #__mt_reviews AS r ON (r.link_id = l.link_id)" . "\nWHERE cl.cat_id = " . $database->quote($cat_id) . " AND link_approved = '1' AND (l.link_id = cl.link_id)" . "\nGROUP BY l.link_id"; if ($mtconf->get('min_votes_to_show_rating') > 0 && $mtconf->get('first_listing_order1') == 'link_rating') { $sql .= "\nORDER BY link_votes >= " . $mtconf->get('min_votes_to_show_rating') . " DESC, " . $mtconf->get('first_listing_order1') . ' ' . $mtconf->get('first_listing_order2') . ', ' . $mtconf->get('second_listing_order1') . ' ' . $mtconf->get('second_listing_order2'); } else { $sql .= "\nORDER BY " . $mtconf->get('first_listing_order1') . ' ' . $mtconf->get('first_listing_order2') . ', ' . $mtconf->get('second_listing_order1') . ' ' . $mtconf->get('second_listing_order2'); } $sql .= "\nLIMIT {$pageNav->limitstart},{$pageNav->limit}"; /* if( $mtconf->get('min_votes_to_show_rating') > 0 && $mtconf->get('first_listing_order1') == 'link_rating' ) { $sql .= "\n ORDER BY link_votes >= " . $mtconf->get('min_votes_to_show_rating') . ' DESC, ' . $mtconf->get('first_listing_order1') . ' ' . $mtconf->get('first_listing_order2') . ', ' . $mtconf->get('second_listing_order1') . ' ' . $mtconf->get('second_listing_order2'); } else { $sql .= "\n ORDER BY " . $mtconf->get('first_listing_order1') . ' ' . $mtconf->get('first_listing_order2') . ', ' . $mtconf->get('second_listing_order1') . ' ' . $mtconf->get('second_listing_order2'); } */ $database->setQuery($sql); if (!($result = $database->query())) { echo $database->stderr(); return false; } $links = $database->loadObjectList(); # Get cat_ids for soft listing $softlinks = array(); foreach ($links as $link) { if ($link->main == 0) { $softlinks[] = $link->link_id; } } if (!empty($softlinks)) { $database->setQuery("SELECT link_id, cat_id FROM #__mt_cl WHERE link_id IN (" . implode(", ", $softlinks) . ") AND main = '1'"); $softlink_cat_ids = $database->loadObjectList("link_id"); } HTML_mtree::listcats($cats, $links, $softlink_cat_ids, $mtCats, $pageNav, $pathWay, $option); }