Location: PHPKode > projects > FeedMeLinks, Social BookmarkingSince2002 > feedmelinks.com/modules/folder-list.inc.php
<%
	global $prof;
	if(!$modules)
		include_once( "modules/utils.inc.php" );

	$debug = 0;
	$con_index = mysql_connect();
	mysql_selectdb( getDBName() );
	$who = $who ? $who : $u;
	$qs = $mode == "js" ?  get_taglist_query($who) : get_category_counts_query( $who );
	if( $debug ) echo "\n//$qs\n<br>";
	$q = mysql_query( $qs );

	$groups = array();
	$groupCounts = array();
	$groupPublicFlags = array();
	$groupIDs = array();

	if( $q ) {
		while( $row = mysql_fetch_assoc( $q )) {
	
			$id = $row["catID"];
			$numLinks = $row["num_links"];
			$name = makeSafeName( $row["name"] );

			$public = false;
			if( isPublic( $name )) {
				$name = makePrettyFolderName( $name );
				$public = true;
			}

			$groups[$id] = $name;
			$groupCounts[$id] = $numLinks;
			$groupPublicFlags[$id] = $public ? 1 : 0;
			$groupIDs[$id] = $id;
		}
		conClose( $con_index);
		
		# sort by usage:
		if( $taglist_sort_order != "alphabetic" )
			array_multisort($groupCounts, SORT_DESC, $groups, $groupPublicFlags, $groupIDs);

		# else sort alphabetically
		else {
			$groups = array_map('strtolower', $groups);
			array_multisort($groups, SORT_ASC, $groupCounts, $groupPublicFlags, $groupIDs);
		}

		if( $groups ) {
			while (list ($key, $val) = each($groupCounts) ) {
				if( $val != "__anchor" ) {
					$i++;
					if( $mode == "js" ) {
						echo print_js_folder( $groupCounts[$key], $groupPublicFlags[$key], $groupIDs[$key], $groups[$key], $i - 1 );
					} else if( $mode == "xml" ) {
						if( !strstr( $val, "&amp;" ))
							$val = str_replace( "&", "&amp;", $val );
							$str = <<<EOD
<tag count="$groupCounts[$key]" tag="$val"/>
EOD;
echo $str;
					} else {
						echo print_css_folder( $who, $val, $groupPublicFlags[$key], $groupIDs[$key], $groups[$key], $i % 2 );
					}
				}
			}
		}
	}
%>
Return current item: FeedMeLinks, Social BookmarkingSince2002