0) {
$res_par = db_query_params ('
SELECT parent
FROM trove_cat
WHERE trove_cat_id=$1',
array($current_cat));
$row_par = db_fetch_array($res_par);
$parent = $row_par["parent"];
if ($parent == 0) return $current_cat;
$current_cat = $parent;
}
return 0;
}
/**
* trove_getallroots() - Returns an associative array of all project roots
*/
function trove_getallroots() {
$res = db_query_params ('
SELECT trove_cat_id,fullname
FROM trove_cat
WHERE parent=0
AND trove_cat_id!=0',
array());
while ($row = db_fetch_array($res)) {
$tmpcatid = $row["trove_cat_id"];
$CATROOTS[$tmpcatid] = $row["fullname"];
}
return $CATROOTS;
}
/**
* trove_catselectfull() - Returns full select output for a particular root
*
* @param int The node
* @param string The category to pre-select
* @param string THe select-box name
*/
function trove_catselectfull($node, $selected, $name, $title='') {
print ' \n";
}
/**
* trove_getcatlisting() - Gets discriminator listing for a group
*
* @param int The group ID
* @param bool Whether filters have already been applied
* @param bool Whether to print category links
* @param bool ???
*/
function trove_getcatlisting($group_id,$a_filter,$a_cats,$a_complete=0) {
global $discrim_url;
global $expl_discrim;
global $form_cat;
$res_trovecat = db_query_params ('
SELECT trove_cat.fullpath AS fullpath,
trove_cat.fullpath_ids AS fullpath_ids,
trove_cat.trove_cat_id AS trove_cat_id
FROM trove_cat,trove_group_link
WHERE trove_cat.trove_cat_id=trove_group_link.trove_cat_id
AND trove_group_link.group_id=$1
ORDER BY trove_cat.fullpath',
array($group_id));
$return = '';
$need_close_ul_tag = 0;
if (db_numrows($res_trovecat) < 1) {
$return .= _('This project has not yet categorized itself in the').' '
.util_make_link ('/softwaremap/trove_list.php',_('Trove Software Map'))
.'
';
} else {
$return .= '
';
$need_close_ul_tag = 1;
}
// first initialise the vars we're using here
$proj_discrim_used=array();
$isfirstdiscrim = 1;
while ($row_trovecat = db_fetch_array($res_trovecat)) {
$folders = explode(" :: ",$row_trovecat['fullpath']);
$folders_ids = explode(" :: ",$row_trovecat['fullpath_ids']);
$folders_len = count($folders);
// if first in discrim print root category
if (!array_key_exists($folders_ids[0], $proj_discrim_used)) {
if (!$isfirstdiscrim) {
$return .= "\n";
}
$return .= '
';
if ($a_complete==0) {
$return .= $folders[0].' : ';
}
}
// filter links, to add discriminators
// first check to see if filter is already applied
$filterisalreadyapplied = 0;
for ($i=0;$i';
}
$return .= ($folders[$i]);
if ($a_cats) {
$return .= '';
}
if ($i!=$folders_len-1) {
$return .= " : ";
}
}
} else {
if ($a_cats) {
$return .= '';
}
$return .= ($folders[$folders_len-1]);
if ($a_cats) {
$return .= '';
}
if ($i!=$folders_len-1) {
$return .= " : ";
}
}
if ($a_filter) {
if ($filterisalreadyapplied) {
$return .= ' '._('(Now Filtering)').' ';
} else {
$return .= ' '._('[Filter]').' ';
}
}
$proj_discrim_used[$folders_ids[0]] = 1;
$isfirstdiscrim = 0;
}
if ($need_close_ul_tag)
{
$return .= '
';
}
return $return;
}
/**
* trove_getfullname() - Returns cat fullname
*
* @param int The node
*/
function trove_getfullname($node) {
$res = db_query_params ('
SELECT fullname
FROM trove_cat
WHERE trove_cat_id=$1',
array($node));
$row = db_fetch_array($res);
return $row['fullname'];
}
/**
* trove_getfullpath() - Returns a full path for a trove category
*
* @param int The node
*/
function trove_getfullpath($node) {
$currentcat = $node;
$first = 1;
$return = '';
while ($currentcat > 0) {
$res = db_query_params ('
SELECT trove_cat_id,parent,fullname
FROM trove_cat
WHERE trove_cat_id=$1',
array($currentcat));
$row = db_fetch_array($res);
$return = $row["fullname"] . ($first ? "" : " :: ") . $return;
$currentcat = $row["parent"];
$first = 0;
}
return $return;
}
/**
* trove_del_cat_id() - Delete the selected node (and its sub-nodes) in the trove tree
*
* @param int The node
*/
function trove_del_cat_id($node) {
$res=db_query_params ('SELECT * FROM trove_cat WHERE parent=$1',
array($node));
if (!$res) {
exit_error(sprintf(_('Error In Trove Operation : %s'),db_error()),'home');
}
if (db_numrows($res)>0) {
for ($i=0; $i