4 * SourceForge Trove Software Map
6 * SourceForge: Breaking Down the Barriers to Open Source Development
7 * Copyright 1999-2001 (c) VA Linux Systems
8 * http://sourceforge.net
10 * @version $Id: trove_list.php,v 1.2 2005/11/28 13:29:52 uid20157 Exp $
15 require_once('../../env.inc.php');
16 require_once('pre.php');
17 require_once('www/include/trove.php');
18 require_once('www/docman/include/doc_utils.php');
20 if (!$sys_use_trove) {
24 //we check if the user has already chosen the tree
25 if(isset($_GET['cat'])){
26 $_SESSION['cat'] = $_GET['cat'];
29 // assign default. 18 is 'topic'
30 if (!isset($form_cat) || !$form_cat) {
31 $form_cat = $default_trove_cat;
34 $form_cat = intval($form_cat);
36 // get info about current folder
37 $res_trove_cat = db_query("
40 WHERE trove_cat_id='$form_cat' ORDER BY fullname");
42 if (db_numrows($res_trove_cat) < 1) {
44 _('Invalid Trove Category'),
45 _('That Trove category does not exist').': '.db_error()
49 $HTML->header(array('title'=>_('Software Map'),'pagename'=>'softwaremap'));
51 //rajout fab a mettre dans head
53 <link rel="StyleSheet" href="dtree.css" type="text/css" />
54 <script type="text/javascript" src="dtree.js"></script>
58 print '<b><a href="./softwaremap.php?cat=c">'._('By Category').'</a> | <a href="./softwaremap.php?cat=t">'._('By Tree').'</a></b>';
63 if(@$_SESSION['cat'] != 't'){
64 $row_trove_cat = db_fetch_array($res_trove_cat);
66 // #####################################
67 // this section limits search and requeries if there are discrim elements
72 if (isset($discrim) && $discrim) {
73 unset ($discrim_queryalias);
74 unset ($discrim_queryand);
75 unset ($discrim_url_b);
78 $expl_discrim = explode(',',$discrim);
80 // need one link for each "get out of this limit" links
81 $discrim_url = '&discrim=';
83 $lims=sizeof($expl_discrim);
89 for ($i=0;$i<$lims;$i++) {
90 // make sure these are all ints, no url trickery
91 $expl_discrim[$i] = intval($expl_discrim[$i]);
93 // need one aliased table for everything
94 //[CB] $discrim_queryalias .= ', trove_group_link trove_group_link_'.$i.' ';
95 $discrim_queryalias .= ', trove_agg trove_agg_'.$i.' ';
97 // need additional AND entries for aliased tables
98 //[CB] $discrim_queryand .= 'AND trove_group_link_'.$i.'.trove_cat_id='
99 //[CB] .$expl_discrim[$i].' AND trove_group_link_'.$i.'.group_id='
100 //[CB] .'trove_group_link.group_id ';
101 $discrim_queryand .= 'AND trove_agg_'.$i.'.trove_cat_id='
102 .$expl_discrim[$i].' AND trove_agg_'.$i.'.group_id='
103 .'trove_agg.group_id ';
105 // must build query string for all urls
107 $discrim_url .= $expl_discrim[$i];
109 $discrim_url .= ','.$expl_discrim[$i];
111 // must also do this for EACH "get out of this limit" links
112 // convoluted logic to build urls for these, but works quickly
113 for ($j=0;$j<sizeof($expl_discrim);$j++) {
115 if (!$discrim_url_b[$j]) {
116 $discrim_url_b[$j] = '&discrim='.$expl_discrim[$i];
118 $discrim_url_b[$j] .= ','.$expl_discrim[$i];
125 // build text for top of page on what viewier is seeing
126 $discrim_desc = '<span style="color:red;font-size:smaller">'._('Now limiting view to projects in the following categories').':
129 for ($i=0;$i<sizeof($expl_discrim);$i++) {
130 $discrim_desc .= '<br /> '
131 .trove_getfullpath($expl_discrim[$i])
132 .' <a href="softwaremap.php?form_cat='.$form_cat
133 .$discrim_url_b[$i].'">['._('Remove This Filter').']'
136 $discrim_desc .= "<hr />\n";
139 // #######################################
141 print '<p>'. (isset($discrim_desc) ? $discrim_desc : '') . '</p>';
143 // ######## two column table for key on right
144 // first print all parent cats and current cat
145 print '<table width="100%" border="0" cellspacing="0" cellpadding="0">
146 <tr valign="top"><td><span style="font-family:arial,helvetica">';
147 $folders = explode(" :: ",$row_trove_cat['fullpath']);
148 $folders_ids = explode(" :: ",$row_trove_cat['fullpath_ids']);
149 $folders_len = count($folders);
150 for ($i=0;$i<$folders_len;$i++) {
151 for ($sp=0;$sp<($i*2);$sp++) {
154 echo html_image("ic/ofolder15.png",'15','13',array());
156 // no anchor for current cat
157 if ($folders_ids[$i] != $form_cat) {
158 print '<a href="softwaremap.php?form_cat='
159 .$folders_ids[$i].$discrim_url.'">';
164 if ($folders_ids[$i] != $form_cat) {
172 // print subcategories
173 $res_sub = db_query("
174 SELECT trove_cat.trove_cat_id AS trove_cat_id,
175 trove_cat.fullname AS fullname,
176 trove_treesums.subprojects AS subprojects
177 FROM trove_cat LEFT JOIN trove_treesums USING (trove_cat_id)
179 trove_treesums.limit_1=0
180 OR trove_treesums.limit_1 IS NULL
181 ) AND " // need no discriminators
182 ."trove_cat.parent='$form_cat'
184 ", -1, 0, SYS_DB_TROVE);
187 while ($row_sub = db_fetch_array($res_sub)) {
188 for ($sp=0;$sp<($folders_len*2);$sp++) {
191 print ('<a href="softwaremap.php?form_cat='.$row_sub['trove_cat_id'].$discrim_url.'">');
192 echo html_image("ic/cfolder15.png",'15','13',array());
193 print (' '.$row_sub['fullname'].'</a> <em>('.
194 sprintf(_('%1$s projects'), $row_sub['subprojects']?$row_sub['subprojects']:'0')
198 // ########### right column: root level
199 print '</span></td><td><span style="font-family:arial,helvetica">';
200 // here we print list of root level categories, and use open folder for current
201 $res_rootcat = db_query("
202 SELECT trove_cat_id,fullname
209 print _('Browse By').':';
210 while ($row_rootcat = db_fetch_array($res_rootcat)) {
211 // print open folder if current, otherwise closed
212 // also make anchor if not current
214 if (($row_rootcat['trove_cat_id'] == $row_trove_cat['root_parent'])
215 || ($row_rootcat['trove_cat_id'] == $row_trove_cat['trove_cat_id'])) {
216 echo html_image('ic/ofolder15.png','15','13',array());
217 print (' <strong>'.$row_rootcat['fullname']."</strong>\n");
219 print ('<a href="softwaremap.php?form_cat='
220 .$row_rootcat['trove_cat_id'].$discrim_url.'">');
221 echo html_image('ic/cfolder15.png','15','13',array());
222 print (' '.$row_rootcat['fullname']."\n");
226 print '</span></td></tr></table>';
230 // one listing for each project
232 if(!isset($discrim_queryalias)) {
233 $discrim_queryalias = '';
236 if(!isset($discrim_queryand)) {
237 $discrim_queryand = '';
240 $res_grp = db_query("
244 WHERE trove_agg.trove_cat_id='$form_cat'
246 ORDER BY trove_agg.trove_cat_id ASC, trove_agg.ranking ASC
247 ", $TROVE_HARDQUERYLIMIT, 0, SYS_DB_TROVE);
249 $querytotalcount = db_numrows($res_grp);
251 // #################################################################
252 // limit/offset display
254 // no funny stuff with get vars
256 if (!isset($page) || !is_numeric($page)) {
260 // store this as a var so it can be printed later as well
261 $html_limit = '<span style="text-align:center;font-size:smaller">';
262 if ($querytotalcount == $TROVE_HARDQUERYLIMIT){
263 $html_limit .= 'More than ';
264 $html_limit .= sprintf(_('More than <strong>%1$s</strong> projects in result set.'), $querytotalcount);
267 $html_limit .= sprintf(ngettext('<strong>%1$s</strong> project in result set.', '<strong>%1$s</strong> projects in result set.', $querytotalcount), $querytotalcount);
269 // only display pages stuff if there is more to display
270 if ($querytotalcount > $TROVE_BROWSELIMIT) {
271 $html_limit .= ' Displaying '.$TROVE_BROWSELIMIT.' per page. Projects sorted by activity ranking.<br />';
273 // display all the numbers
274 for ($i=1;$i<=ceil($querytotalcount/$TROVE_BROWSELIMIT);$i++) {
277 $html_limit .= '<a href="softwaremap.php?form_cat='.$form_cat;
278 $html_limit .= $discrim_url.'&page='.$i;
280 } else $html_limit .= '<strong>';
281 $html_limit .= '<'.$i.'>';
283 $html_limit .= '</a>';
284 } else $html_limit .= '</strong>';
289 $html_limit .= '</span>';
291 print $html_limit."<hr />\n";
293 // #################################################################
294 // print actual project listings
295 // note that the for loop starts at 1, not 0
296 for ($i_proj=1;$i_proj<=$querytotalcount;$i_proj++) {
297 $row_grp = db_fetch_array($res_grp);
299 // check to see if row is in page range
300 if (($i_proj > (($page-1)*$TROVE_BROWSELIMIT)) && ($i_proj <= ($page*$TROVE_BROWSELIMIT))) {
306 if ($row_grp && $viewthisrow) {
307 print '<table border="0" cellpadding="0" width="100%"><tr valign="top"><td colspan="2"><span style="font-family:arial,helvetica">';
308 print '$i_proj. <a href="'.$GLOBALS['sys_urlprefix'].'/projects/'. strtolower($row_grp['unix_group_name']) .'/"><strong>'
309 .htmlspecialchars($row_grp['group_name']).'</strong></a> ';
310 if ($row_grp['short_description']) {
311 print "- " . htmlspecialchars($row_grp['short_description']);
314 print '<br /> ';
316 print '</span></td></tr><tr valign="top"><td><span style="font-family:arial,helvetica">';
317 // list all trove categories
318 print trove_getcatlisting($row_grp['group_id'],1,0);
320 print '</span></td>'."\n".'<td align="right"><span style="font-family:arial,helvetica">'; // now the right side of the display
321 print 'Activity Percentile: <strong>'. number_format($row_grp['percentile'],2) .'</strong>';
322 print '<br />Activity Ranking: <strong>'. number_format($row_grp['ranking'],2) .'</strong>';
323 print '<br />Register Date: <strong>'.date(_('Y-m-d H:i'),$row_grp['register_time']).'</strong>';
324 print '</span></td></tr>';
326 if ($row_grp['jobs_count']) {
327 print '<tr><td colspan="2" align="center">'
328 .'<a href="/people/?group_id='.$row_grp['group_id'].'">[This project needs help]</a></td></td>';
333 } // end if for row and range chacking
336 // print bottom navigation if there are more projects to display
337 if ($querytotalcount > $TROVE_BROWSELIMIT) {
342 // print '<p><FONT size="-1">This listing was produced by the following query: '
343 // .$query_projlist.'</FONT>';
346 function build_tree() {
347 global $project_name ;
348 $query = "select p1.group_id as father_id,p1.unix_group_name as father_unix_name,p1.group_name as father_name,p2.group_id as son_id,p2.unix_group_name as son_unix_name,p2.group_name as son_name from groups as p1,groups as p2,plugin_projects_hierarchy where p1.group_id=plugin_projects_hierarchy.project_id and p2.group_id=plugin_projects_hierarchy.sub_project_id and plugin_projects_hierarchy.activated='t' AND plugin_projects_hierarchy.link_type='shar'";
349 $res = db_query($query);
351 // construction du tableau associatif
352 // key = name of the father
353 // value = list of sons
354 while ($row = db_fetch_array($res)) {
355 //$tree[$row['father_name']][] = $row['son_name'];
356 $tree[$row['father_id']][] = $row['son_id'];
357 //get the unix name of the project
358 $project_name[$row['father_id']][0] = $row['father_name'];
359 $project_name[$row['son_id']][0] = $row['son_name'];
360 $project_name[$row['father_id']][1] = $row['father_unix_name'];
361 $project_name[$row['son_id']][1] = $row['son_unix_name'];
366 function aff_tree($tree, $lvl) {
367 global $project_name ;
373 while (list($key, $sons) = each($tree)) {
374 //echo $key . "<br/>";
375 //we build a array with id of father and son.
377 // Really don't know why there is a warning there, and added @
378 if(@!$arbre[$key] != 0){
382 foreach ($sons as $son) {
383 //echo " " . $son . "<br/>";
384 $arbre[$son] = $cpt_pere;
389 echo '<table ><tr><td>';
392 <script type="text/javascript">
394 //add files dtress.css, dtree.js et du dossier img
396 d.add(0,-1,'<?php echo _('Project Tree');?>');
399 //construction automatique de l'arbre format : (num_fils, num_pere,nom,nom_unix)
400 while (list($key2, $sons2) = each($arbre)) {
401 print "d.add(".$key2.",".$sons2.",'".$project_name[$key2][0]."','".$GLOBALS['sys_urlprefix']."/projects/".$project_name[$key2][1]."');\n";
410 echo '</td></tr></table>';
413 /*function aff_node($node, $lvl) {
414 for ($i = 0; $i < $lvl; ++$i) {
417 echo $node . "<br/>";
420 $tree = build_tree();
424 //docman_display_documents($nested_groups,$df,$is_editor);
425 docman_display_documents($nested_groups,$df,'');
427 $HTML->footer(array());
431 // c-file-style: "bsd"