3 * FusionForge Trove Software Map
5 * Copyright 1999-2001, VA Linux Systems, Inc.
6 * Copyright 2009, Roland Mas
8 * This file is part of FusionForge.
10 * FusionForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published
12 * by the Free Software Foundation; either version 2 of the License,
13 * or (at your option) any later version.
15 * FusionForge is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with FusionForge; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26 require_once('../env.inc.php');
27 require_once $gfwww.'include/pre.php';
29 // entry for hierarchy plugin
30 // we didn't find any other way to do it :(
33 require_once $gfwww.'include/trove.php';
35 if (!forge_get_config('use_trove')) {
39 $form_cat = getIntFromRequest('form_cat');
40 $page = getIntFromRequest('page',1);
43 // assign default. 18 is 'topic'
45 $form_cat = $default_trove_cat;
48 // get info about current folder
49 $res_trove_cat = db_query_params ('
52 WHERE trove_cat_id=$1 ORDER BY fullname',
55 if (db_numrows($res_trove_cat) < 1) {
57 _('Invalid Trove Category'),
58 _('That Trove category does not exist').': '.db_error()
62 $HTML->header(array('title'=>_('Software Map')));
64 $subMenuTitle = array();
65 $subMenuUrl = array();
67 if ($GLOBALS['sys_use_project_tags']) {
68 $subMenuTitle[] = _('Tag cloud');
69 $subMenuUrl[] = '/softwaremap/tag_cloud.php';
72 if (forge_get_config('use_trove')) {
73 $subMenuTitle[] = _('Project Tree');
74 $subMenuUrl[] = '/softwaremap/trove_list.php';
77 $subMenuTitle[] = _('Project List');
78 $subMenuUrl[] = '/softwaremap/full_list.php';
80 echo ($HTML->subMenu($subMenuTitle, $subMenuUrl));
82 echo '<div id="project-tree" class="underline-link">' . "\n";
83 echo '<h2>' . _('Project tree') . '</h2>' . "\n";
85 $row_trove_cat = db_fetch_array($res_trove_cat);
87 // #####################################
88 // this section limits search and requeries if there are discrim elements
90 $discrim = getStringFromRequest('discrim');
94 $qpa_alias = db_construct_qpa () ;
95 $qpa_and = db_construct_qpa () ;
98 $discrim_url_b = array();
101 $expl_discrim = explode(',',$discrim);
103 if (sizeof($expl_discrim) > 6) {
104 array_splice ($expl_discrim, 6) ;
108 for ($i=0;$i<sizeof($expl_discrim);$i++) {
109 // make sure these are all ints, no url trickery
110 $expl_discrim[$i] = intval($expl_discrim[$i]);
112 // need one aliased table for everything
113 $qpa_alias = db_construct_qpa ($qpa_alias,
114 ', trove_agg trove_agg_'.$i) ;
116 // need additional AND entries for aliased tables
117 $qpa_and = db_construct_qpa ($qpa_and,
118 sprintf (' AND trove_agg_%d.trove_cat_id=$%d AND trove_agg_%d.group_id=trove_agg.group_id ', $i, $i+1, $i),
119 array ($expl_discrim[$i])) ;
121 $expl_discrim_b = array () ;
122 for ($j=0;$j<sizeof($expl_discrim);$j++) {
124 $expl_discrim_b[] = $expl_discrim[$j] ;
127 $discrim_url_b[$i] = '&discrim=' . implode (',', $expl_discrim_b) ;
130 $discrim_url = '&discrim=' . implode (',', $expl_discrim);
132 // build text for top of page on what viewier is seeing
133 $discrim_desc = _('Now limiting view to projects in the following categories:');
135 for ($i=0;$i<sizeof($expl_discrim);$i++) {
136 $discrim_desc .= '<br /> '
137 .trove_getfullpath($expl_discrim[$i])
138 .util_make_link ('/softwaremap/trove_list.php?form_cat='.$form_cat .$discrim_url_b[$i],' ['._('Remove This Filter').']');
140 $discrim_desc .= "<hr />\n";
143 // #######################################
145 print '<p>'. (isset($discrim_desc) ? $discrim_desc : '') . '</p>';
147 // ######## two column table for key on right
148 // first print all parent cats and current cat
149 print '<table summary="">' . "\n";
151 print '<td id="project-tree-col1">' . "\n";
153 $folders = explode(" :: ",$row_trove_cat['fullpath']);
154 $folders_ids = explode(" :: ",$row_trove_cat['fullpath_ids']);
155 $folders_len = count($folders);
158 print html_image("category.png",'32','33',array('alt'=>""));
161 for ($i=0;$i<$folders_len;$i++) {
162 // no anchor for current cat
163 if ($folders_ids[$i] != $form_cat) {
164 print util_make_link ('/softwaremap/trove_list.php?form_cat=' .$folders_ids[$i].$discrim_url,
167 print " > ";
169 print '<strong>'.$folders[$i].'</strong>';
174 // print subcategories
175 $res_sub = db_query_params ('
176 SELECT trove_cat.trove_cat_id AS trove_cat_id,
177 trove_cat.fullname AS fullname,
178 trove_treesums.subprojects AS subprojects
179 FROM trove_cat LEFT JOIN trove_treesums USING (trove_cat_id)
181 trove_treesums.limit_1=0
182 OR trove_treesums.limit_1 IS NULL
183 ) AND trove_cat.parent=$1
189 while ($row_sub = db_fetch_array($res_sub)) {
191 print '<a href="trove_list.php?form_cat=' . $row_sub['trove_cat_id'] . $discrim_url . '">';
192 print $row_sub['fullname'];
195 print sprintf(_('%1$s projects'), $row_sub['subprojects']?$row_sub['subprojects']:'0');
200 // ########### right column: root level
202 print '<td id="project-tree-col2">';
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
214 print _('Browse By').':';
217 print '<ul id="project-tree-branches">';
218 while ($row_rootcat = db_fetch_array($res_rootcat)) {
219 // print open folder if current, otherwise closed
220 // also make anchor if not current
221 if (($row_rootcat['trove_cat_id'] == $row_trove_cat['root_parent'])
222 || ($row_rootcat['trove_cat_id'] == $row_trove_cat['trove_cat_id'])) {
223 print '<li class="current-cat">' . $row_rootcat['fullname'] . "</li>\n";
227 print util_make_link ('/softwaremap/trove_list.php?form_cat=' .$row_rootcat['trove_cat_id'].$discrim_url, $row_rootcat['fullname']);
232 print "</td>\n</tr>\n</table>\n";
237 // one listing for each project
239 $qpa = db_construct_qpa () ;
240 $qpa = db_construct_qpa ($qpa, 'SELECT * FROM trove_agg') ;
241 $qpa = db_join_qpa ($qpa, $qpa_alias) ;
242 $qpa = db_construct_qpa ($qpa, ' WHERE trove_agg.trove_cat_id=$1', array ($form_cat)) ;
243 $qpa = db_join_qpa ($qpa, $qpa_and) ;
244 $qpa = db_construct_qpa ($qpa, ' ORDER BY trove_agg.trove_cat_id ASC, trove_agg.ranking ASC') ;
245 $res_grp = db_query_qpa ($qpa, $TROVE_HARDQUERYLIMIT, 0, SYS_DB_TROVE);
248 $querytotalcount = db_numrows($res_grp);
250 // #################################################################
251 // limit/offset display
253 // store this as a var so it can be printed later as well
255 if ($querytotalcount == $TROVE_HARDQUERYLIMIT){
256 $html_limit .= 'More than ';
257 $html_limit .= sprintf(_('More than <strong>%1$s</strong> projects in result set.'), $querytotalcount);
260 $html_limit .= sprintf(ngettext('<strong>%1$s</strong> project in result set.', '<strong>%1$s</strong> projects in result set.', $querytotalcount), $querytotalcount);
262 // only display pages stuff if there is more to display
263 if ($querytotalcount > $TROVE_BROWSELIMIT) {
264 $html_limit .= ' Displaying '.$TROVE_BROWSELIMIT.' per page. Projects sorted by activity ranking.<br />';
266 // display all the numbers
267 for ($i=1;$i<=ceil($querytotalcount/$TROVE_BROWSELIMIT);$i++) {
269 $displayed_i = '<'.$i.'>';
271 $html_limit .= "<strong>$displayed_i</strong>" ;
273 $html_limit .= util_make_link ('/softwaremap/trove_list.php?form_cat='.$form_cat.$discrim_url.'&page='.$i,
281 //$html_limit .= '</span>';
283 print $html_limit."<hr />\n";
285 // #################################################################
286 // print actual project listings
287 // note that the for loop starts at 1, not 0
288 for ($i_proj=1;$i_proj<=$querytotalcount;$i_proj++) {
289 $row_grp = db_fetch_array($res_grp);
291 // check to see if row is in page range
292 if (($i_proj > (($page-1)*$TROVE_BROWSELIMIT)) && ($i_proj <= ($page*$TROVE_BROWSELIMIT))) {
298 if ($row_grp && $viewthisrow) {
299 print '<table border="0" cellpadding="0" width="100%"><tr valign="top"><td colspan="2">';
301 print util_make_link_g ($row_grp['unix_group_name'],
302 $row_grp['group_id'],
303 "<strong>".htmlspecialchars($row_grp['group_name'])."</strong> ");
304 if ($row_grp['short_description']) {
305 print "- " . htmlspecialchars($row_grp['short_description']);
308 print '<br /> ';
310 print '</span></td></tr><tr valign="top"><td>';
311 // list all trove categories
312 print trove_getcatlisting($row_grp['group_id'],1,0,1);
313 print '</span></td>'."\n";
314 print '<td style="text-align:right">'; // now the right side of the display
315 if (group_get_object($row_grp['group_id'])->usesStats()) {
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>';
319 print '<br />'._('Registered: ').' <strong>'.date(_('Y-m-d H:i'),$row_grp['register_time']).'</strong>';
320 print '</span></td>';
324 } // end if for row and range chacking
327 // print bottom navigation if there are more projects to display
328 if ($querytotalcount > $TROVE_BROWSELIMIT) {
332 // print '<p><FONT size="-1">This listing was produced by the following query: '
333 // .$query_projlist.'</FONT>';
334 echo '</div><!-- id="project-tree" -->' . "\n";
336 $HTML->footer(array());
340 // c-file-style: "bsd"