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
13 require_once('../../env.inc.php');
14 require_once $gfwww.'include/pre.php';
15 require_once $gfwww.'include/trove.php';
16 require_once $gfwww.'docman/include/doc_utils.php';
18 if (!$sys_use_trove) {
22 //we check if the user has already chosen the tree
23 if(isset($_GET['cat'])){
24 $_SESSION['cat'] = $_GET['cat'];
27 // assign default. 18 is 'topic'
28 if (!isset($form_cat) || !$form_cat) {
29 $form_cat = $default_trove_cat;
32 $form_cat = intval($form_cat);
34 // get info about current folder
35 $res_trove_cat = db_query_params ('
38 WHERE trove_cat_id=$1 ORDER BY fullname',
41 if (db_numrows($res_trove_cat) < 1) {
43 _('Invalid Trove Category'),
44 _('That Trove category does not exist').': '.db_error()
48 $HTML->header(array('title'=>_('Software Map'),'pagename'=>'softwaremap'));
50 //rajout fab a mettre dans head
52 <link rel="StyleSheet" href="dtree.css" type="text/css" />
53 <script type="text/javascript" src="dtree.js"></script>
57 print '<b><a href="./softwaremap.php?cat=c">'._('By Category').'</a> | <a href="./softwaremap.php?cat=t">'._('By Tree').'</a></b>';
62 if(@$_SESSION['cat'] != 't'){
63 $row_trove_cat = db_fetch_array($res_trove_cat);
65 // #####################################
66 // this section limits search and requeries if there are discrim elements
71 $qpa_alias = db_construct_qpa () ;
72 $qpa_and = db_construct_qpa () ;
74 if (isset($discrim) && $discrim) {
75 unset ($discrim_queryalias);
76 unset ($discrim_queryand);
77 unset ($discrim_url_b);
80 $expl_discrim = explode(',',$discrim);
82 // need one link for each "get out of this limit" links
83 $discrim_url = '&discrim=';
85 $lims=sizeof($expl_discrim);
91 for ($i=0;$i<$lims;$i++) {
92 // make sure these are all ints, no url trickery
93 $expl_discrim[$i] = intval($expl_discrim[$i]);
96 // need one aliased table for everything
97 $qpa_alias = db_construct_qpa ($qpa_alias,
98 sprintf (', trove_agg trove_agg_%d',
101 // need additional AND entries for aliased tables
102 $qpa_and = db_construct_qpa ($qpa_and,
103 sprintf (' AND trove_agg_%d.trove_cat_id=$%d AND trove_agg_%d.group_id=trove_agg.group_id ',
105 array ($expl_discrim[$i])) ;
108 // must build query string for all urls
110 $discrim_url .= $expl_discrim[$i];
112 $discrim_url .= ','.$expl_discrim[$i];
114 // must also do this for EACH "get out of this limit" links
115 // convoluted logic to build urls for these, but works quickly
116 for ($j=0;$j<sizeof($expl_discrim);$j++) {
118 if (!$discrim_url_b[$j]) {
119 $discrim_url_b[$j] = '&discrim='.$expl_discrim[$i];
121 $discrim_url_b[$j] .= ','.$expl_discrim[$i];
128 // build text for top of page on what viewier is seeing
129 $discrim_desc = '<span style="color:red;font-size:smaller">'._('Now limiting view to projects in the following categories').':
132 for ($i=0;$i<sizeof($expl_discrim);$i++) {
133 $discrim_desc .= '<br /> '
134 .trove_getfullpath($expl_discrim[$i])
135 .' <a href="softwaremap.php?form_cat='.$form_cat
136 .$discrim_url_b[$i].'">['._('Remove This Filter').']'
139 $discrim_desc .= "<hr />\n";
142 // #######################################
144 print '<p>'. (isset($discrim_desc) ? $discrim_desc : '') . '</p>';
146 // ######## two column table for key on right
147 // first print all parent cats and current cat
148 print '<table width="100%" border="0" cellspacing="0" cellpadding="0">
149 <tr valign="top"><td><span style="font-family:arial,helvetica">';
150 $folders = explode(" :: ",$row_trove_cat['fullpath']);
151 $folders_ids = explode(" :: ",$row_trove_cat['fullpath_ids']);
152 $folders_len = count($folders);
153 for ($i=0;$i<$folders_len;$i++) {
154 for ($sp=0;$sp<($i*2);$sp++) {
157 echo html_image("ic/ofolder15.png",'15','13',array());
159 // no anchor for current cat
160 if ($folders_ids[$i] != $form_cat) {
161 print '<a href="softwaremap.php?form_cat='
162 .$folders_ids[$i].$discrim_url.'">';
167 if ($folders_ids[$i] != $form_cat) {
175 // print subcategories
176 $res_sub = db_query_params ('
177 SELECT trove_cat.trove_cat_id AS trove_cat_id,
178 trove_cat.fullname AS fullname,
179 trove_treesums.subprojects AS subprojects
180 FROM trove_cat LEFT JOIN trove_treesums USING (trove_cat_id)
182 trove_treesums.limit_1=0
183 OR trove_treesums.limit_1 IS NULL
184 ) AND trove_cat.parent=$1
190 while ($row_sub = db_fetch_array($res_sub)) {
191 for ($sp=0;$sp<($folders_len*2);$sp++) {
194 print ('<a href="softwaremap.php?form_cat='.$row_sub['trove_cat_id'].$discrim_url.'">');
195 echo html_image("ic/cfolder15.png",'15','13',array());
196 print (' '.$row_sub['fullname'].'</a> <em>('.
197 sprintf(_('%1$s projects'), $row_sub['subprojects']?$row_sub['subprojects']:'0')
201 // ########### right column: root level
202 print '</span></td><td><span style="font-family:arial,helvetica">';
203 // here we print list of root level categories, and use open folder for current
204 $res_rootcat = db_query_params ('
205 SELECT trove_cat_id,fullname
213 print _('Browse By').':';
214 while ($row_rootcat = db_fetch_array($res_rootcat)) {
215 // print open folder if current, otherwise closed
216 // also make anchor if not current
218 if (($row_rootcat['trove_cat_id'] == $row_trove_cat['root_parent'])
219 || ($row_rootcat['trove_cat_id'] == $row_trove_cat['trove_cat_id'])) {
220 echo html_image('ic/ofolder15.png','15','13',array());
221 print (' <strong>'.$row_rootcat['fullname']."</strong>\n");
223 print ('<a href="softwaremap.php?form_cat='
224 .$row_rootcat['trove_cat_id'].$discrim_url.'">');
225 echo html_image('ic/cfolder15.png','15','13',array());
226 print (' '.$row_rootcat['fullname']."\n");
230 print '</span></td></tr></table>';
234 // one listing for each project
236 $qpa = db_construct_qpa () ;
237 $qpa = db_construct_qpa ($qpa, 'SELECT * FROM trove_agg') ;
238 $qpa = db_join_qpa ($qpa, $qpa_alias) ;
239 $qpa = db_construct_qpa ($qpa, ' WHERE trove_agg.trove_cat_id=$1', array ($form_cat)) ;
240 $qpa = db_join_qpa ($qpa, $qpa_and) ;
241 $qpa = db_construct_qpa ($qpa, ' ORDER BY trove_agg.trove_cat_id ASC, trove_agg.ranking ASC') ;
242 $res_grp = db_query_qpa ($qpa, $TROVE_HARDQUERYLIMIT, 0, SYS_DB_TROVE);
245 $querytotalcount = db_numrows($res_grp);
247 // #################################################################
248 // limit/offset display
250 // no funny stuff with get vars
252 if (!isset($page) || !is_numeric($page)) {
256 // store this as a var so it can be printed later as well
257 $html_limit = '<span style="text-align:center;font-size:smaller">';
258 if ($querytotalcount == $TROVE_HARDQUERYLIMIT){
259 $html_limit .= 'More than ';
260 $html_limit .= sprintf(_('More than <strong>%1$s</strong> projects in result set.'), $querytotalcount);
263 $html_limit .= sprintf(ngettext('<strong>%1$s</strong> project in result set.', '<strong>%1$s</strong> projects in result set.', $querytotalcount), $querytotalcount);
265 // only display pages stuff if there is more to display
266 if ($querytotalcount > $TROVE_BROWSELIMIT) {
267 $html_limit .= ' Displaying '.$TROVE_BROWSELIMIT.' per page. Projects sorted by activity ranking.<br />';
269 // display all the numbers
270 for ($i=1;$i<=ceil($querytotalcount/$TROVE_BROWSELIMIT);$i++) {
273 $html_limit .= '<a href="softwaremap.php?form_cat='.$form_cat;
274 $html_limit .= $discrim_url.'&page='.$i;
276 } else $html_limit .= '<strong>';
277 $html_limit .= '<'.$i.'>';
279 $html_limit .= '</a>';
280 } else $html_limit .= '</strong>';
285 $html_limit .= '</span>';
287 print $html_limit."<hr />\n";
289 // #################################################################
290 // print actual project listings
291 // note that the for loop starts at 1, not 0
292 for ($i_proj=1;$i_proj<=$querytotalcount;$i_proj++) {
293 $row_grp = db_fetch_array($res_grp);
295 // check to see if row is in page range
296 if (($i_proj > (($page-1)*$TROVE_BROWSELIMIT)) && ($i_proj <= ($page*$TROVE_BROWSELIMIT))) {
302 if ($row_grp && $viewthisrow) {
303 print '<table border="0" cellpadding="0" width="100%"><tr valign="top"><td colspan="2"><span style="font-family:arial,helvetica">';
304 print '$i_proj. '.util_make_link ('/projects/'. strtolower($row_grp['unix_group_name']) .'/','<strong>'.htmlspecialchars($row_grp['group_name']).'</strong> ');
305 if ($row_grp['short_description']) {
306 print "- " . htmlspecialchars($row_grp['short_description']);
309 print '<br /> ';
311 print '</span></td></tr><tr valign="top"><td><span style="font-family:arial,helvetica">';
312 // list all trove categories
313 print trove_getcatlisting($row_grp['group_id'],1,0);
315 print '</span></td>'."\n".'<td align="right"><span style="font-family:arial,helvetica">'; // now the right side of the display
316 print 'Activity Percentile: <strong>'. number_format($row_grp['percentile'],2) .'</strong>';
317 print '<br />Activity Ranking: <strong>'. number_format($row_grp['ranking'],2) .'</strong>';
318 print '<br />Register Date: <strong>'.date(_('Y-m-d H:i'),$row_grp['register_time']).'</strong>';
319 print '</span></td></tr>';
322 } // end if for row and range chacking
325 // print bottom navigation if there are more projects to display
326 if ($querytotalcount > $TROVE_BROWSELIMIT) {
331 // print '<p><FONT size="-1">This listing was produced by the following query: '
332 // .$query_projlist.'</FONT>';
335 function build_tree() {
336 global $project_name ;
337 $res = db_query_params ('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=$1 AND plugin_projects_hierarchy.link_type=$2',
341 // construction du tableau associatif
342 // key = name of the father
343 // value = list of sons
345 while ($row = db_fetch_array($res)) {
346 //$tree[$row['father_name']][] = $row['son_name'];
347 $tree[$row['father_id']][] = $row['son_id'];
348 //get the unix name of the project
349 $project_name[$row['father_id']][0] = $row['father_name'];
350 $project_name[$row['son_id']][0] = $row['son_name'];
351 $project_name[$row['father_id']][1] = $row['father_unix_name'];
352 $project_name[$row['son_id']][1] = $row['son_unix_name'];
357 function aff_tree($tree, $lvl) {
358 global $project_name ;
364 while (list($key, $sons) = each($tree)) {
365 //echo $key . "<br/>";
366 //we build a array with id of father and son.
368 // Really don't know why there is a warning there, and added @
369 if(@!$arbre[$key] != 0){
373 foreach ($sons as $son) {
374 //echo " " . $son . "<br/>";
375 $arbre[$son] = $cpt_pere;
380 echo '<table ><tr><td>';
383 <script type="text/javascript">
385 //add files dtress.css, dtree.js et du dossier img
387 d.add(0,-1,'<?php echo _('Project Tree');?>');
390 //construction automatique de l'arbre format : (num_fils, num_pere,nom,nom_unix)
391 while (list($key2, $sons2) = each($arbre)) {
392 print "d.add(".$key2.",".$sons2.",'".$project_name[$key2][0]."','".util_make_link ("/projects/".$project_name[$key2][1] ."/") . "');\n";
401 echo '</td></tr></table>';
404 /*function aff_node($node, $lvl) {
405 for ($i = 0; $i < $lvl; ++$i) {
408 echo $node . "<br/>";
411 $tree = build_tree();
415 //docman_display_documents($nested_groups,$df,$is_editor);
416 docman_display_documents($nested_groups,$df,'');
418 $HTML->footer(array());
422 // c-file-style: "bsd"