3 * FusionForge Trove Software Map
5 * Copyright 1999-2001, VA Linux Systems, Inc.
6 * Copyright 2009, Roland Mas
7 * Copyright 2011, Franck Villaume - Capgemini
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once('../env.inc.php');
26 require_once $gfcommon.'include/pre.php';
27 require_once $gfwww.'include/trove.php';
29 if (!forge_get_config('use_trove')) {
30 exit_disabled('home');
33 $HTML->header(array('title'=>_('Software Map'),'pagename'=>'softwaremap'));
34 $HTML->printSoftwareMapLinks();
36 $form_cat = getIntFromRequest('form_cat');
37 $page = getIntFromRequest('page',1);
38 $cat = getStringFromRequest('cat');
43 // assign default. 18 is 'topic'
45 $form_cat = forge_get_config('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) {
56 exit_error(_('That Trove category does not exist').': '.db_error(),'trove');
59 echo '<div id="project-tree" class="underline-link">' . "\n";
60 echo '<h2>' . _('Project tree') . '</h2>' . "\n";
62 plugin_hook('display_hierarchy_submenu');
65 $row_trove_cat = db_fetch_array($res_trove_cat);
67 // #####################################
68 // this section limits search and requeries if there are discrim elements
70 $discrim = getStringFromRequest('discrim');
74 $qpa_alias = db_construct_qpa();
75 $qpa_and = db_construct_qpa();
78 $discrim_url_b = array();
81 $expl_discrim = explode(',', $discrim);
83 if (sizeof($expl_discrim) > 6) {
84 array_splice($expl_discrim, 6);
88 for ($i = 0; $i < sizeof($expl_discrim); $i++) {
89 // make sure these are all ints, no url trickery
90 $expl_discrim[$i] = intval($expl_discrim[$i]);
92 // need one aliased table for everything
93 $qpa_alias = db_construct_qpa($qpa_alias,', trove_agg trove_agg_'.$i);
95 // need additional AND entries for aliased tables
96 $qpa_and = db_construct_qpa($qpa_and,
97 sprintf(' AND trove_agg_%d.trove_cat_id=$%d AND trove_agg_%d.group_id=trove_agg.group_id ', $i, $i+1, $i),
98 array($expl_discrim[$i]));
100 $expl_discrim_b = array();
101 for ($j = 0; $j < sizeof($expl_discrim); $j++) {
103 $expl_discrim_b[] = $expl_discrim[$j];
106 $discrim_url_b[$i] = '&discrim=' . implode(',', $expl_discrim_b);
109 $discrim_url = '&discrim=' . implode(',', $expl_discrim);
111 // build text for top of page on what viewier is seeing
112 $discrim_desc = _('Now limiting view to projects in the following categories:');
114 for ($i = 0; $i < sizeof($expl_discrim); $i++) {
115 $discrim_desc .= '<br /> '
116 .trove_getfullpath($expl_discrim[$i])
117 .util_make_link('/softwaremap/trove_list.php?cat=c&form_cat='.$form_cat .$discrim_url_b[$i],' ['._('Remove This Filter').']');
119 $discrim_desc .= "<hr />\n";
122 // #######################################
124 if (!empty($discrim_desc))
125 print '<p>'.$discrim_desc.'</p>';
127 // ######## two column table for key on right
128 // first print all parent cats and current cat
129 print '<table summary="">' . "\n";
131 print '<td id="project-tree-col1">' . "\n";
133 $folders = explode(" :: ",$row_trove_cat['fullpath']);
134 $folders_ids = explode(" :: ",$row_trove_cat['fullpath_ids']);
135 $folders_len = count($folders);
138 print html_image("category.png",'32','33',array('alt'=>""));
141 for ($i = 0; $i < $folders_len; $i++) {
142 // no anchor for current cat
143 if ($folders_ids[$i] != $form_cat) {
144 print util_make_link('/softwaremap/trove_list.php?cat=c&form_cat=' .$folders_ids[$i].$discrim_url,
147 print " > ";
149 print '<strong>'.$folders[$i].'</strong>';
154 // print subcategories
155 $res_sub = db_query_params('
156 SELECT trove_cat.trove_cat_id AS trove_cat_id,
157 trove_cat.fullname AS fullname,
158 trove_treesums.subprojects AS subprojects
159 FROM trove_cat LEFT JOIN trove_treesums USING (trove_cat_id)
161 trove_treesums.limit_1=0
162 OR trove_treesums.limit_1 IS NULL
163 ) AND trove_cat.parent=$1
169 while ($row_sub = db_fetch_array($res_sub)) {
171 print '<a href="trove_list.php?cat=c&form_cat=' . $row_sub['trove_cat_id'] . $discrim_url . '">';
172 print $row_sub['fullname'];
175 print sprintf(_('%1$s projects'), $row_sub['subprojects']?$row_sub['subprojects']:'0');
180 // ########### right column: root level
182 print '<td id="project-tree-col2">';
183 // here we print list of root level categories, and use open folder for current
184 $res_rootcat = db_query_params('
185 SELECT trove_cat_id,fullname
194 print _('Browse By').':';
197 print '<ul id="project-tree-branches">';
198 while ($row_rootcat = db_fetch_array($res_rootcat)) {
199 // print open folder if current, otherwise closed
200 // also make anchor if not current
201 if (($row_rootcat['trove_cat_id'] == $row_trove_cat['root_parent'])
202 || ($row_rootcat['trove_cat_id'] == $row_trove_cat['trove_cat_id'])) {
203 print '<li class="current-cat">' . $row_rootcat['fullname'] . "</li>\n";
206 print util_make_link ('/softwaremap/trove_list.php?cat=c&form_cat=' .$row_rootcat['trove_cat_id'].$discrim_url, $row_rootcat['fullname']);
211 print "</td>\n</tr>\n</table>\n";
216 // one listing for each project
218 $qpa = db_construct_qpa();
219 $qpa = db_construct_qpa($qpa, 'SELECT * FROM trove_agg');
220 $qpa = db_join_qpa($qpa, $qpa_alias);
221 $qpa = db_construct_qpa($qpa, ' WHERE trove_agg.trove_cat_id=$1', array($form_cat));
222 $qpa = db_join_qpa($qpa, $qpa_and);
223 $qpa = db_construct_qpa($qpa, ' ORDER BY trove_agg.trove_cat_id ASC, trove_agg.ranking ASC');
224 $res_grp = db_query_qpa($qpa, $TROVE_HARDQUERYLIMIT, 0, 'SYS_DB_TROVE');
227 while ($row_grp = db_fetch_array($res_grp)) {
228 if (!forge_check_perm ('project_read', $row_grp['group_id'])) {
231 $projects[] = $row_grp;
233 $querytotalcount = count($projects);
235 // #################################################################
236 // limit/offset display
238 // store this as a var so it can be printed later as well
240 if ($querytotalcount == $TROVE_HARDQUERYLIMIT) {
241 $html_limit .= 'More than ';
242 $html_limit .= sprintf(_('More than <strong>%1$s</strong> projects in result set.'), $querytotalcount);
245 $html_limit .= sprintf(ngettext('<strong>%1$s</strong> project in result set.', '<strong>%1$s</strong> projects in result set.', $querytotalcount), $querytotalcount);
247 // only display pages stuff if there is more to display
248 if ($querytotalcount > $TROVE_BROWSELIMIT) {
249 $html_limit .= ' Displaying '.$TROVE_BROWSELIMIT.' per page. Projects sorted by activity ranking.<br />';
251 // display all the numbers
252 for ($i=1;$i<=ceil($querytotalcount/$TROVE_BROWSELIMIT);$i++) {
254 $displayed_i = '<'.$i.'>';
256 $html_limit .= "<strong>$displayed_i</strong>" ;
264 print $html_limit."<hr />\n";
266 // #################################################################
267 // print actual project listings
268 for ($i_proj=0;$i_proj<$querytotalcount;$i_proj++) {
269 $row_grp = $projects[$i_proj];
271 // check to see if row is in page range
272 if (($i_proj >= (($page-1)*$TROVE_BROWSELIMIT)) && ($i_proj < ($page*$TROVE_BROWSELIMIT))) {
278 if ($row_grp && $viewthisrow) {
279 print '<table border="0" cellpadding="0" width="100%"><tr valign="top"><td colspan="2">';
281 print util_make_link_g ($row_grp['unix_group_name'],
282 $row_grp['group_id'],
283 "<strong>".htmlspecialchars($row_grp['group_name'])."</strong> ");
284 if ($row_grp['short_description']) {
285 print "- " . htmlspecialchars($row_grp['short_description']);
288 print '<br /> ';
290 print "</td></tr>\n<tr valign=\"top\"><td>";
291 // list all trove categories
292 print trove_getcatlisting($row_grp['group_id'],1,0,1);
294 print '<td style="text-align:right">'; // now the right side of the display
295 if (group_get_object($row_grp['group_id'])->usesStats()) {
296 print _('Activity Percentile: ').'<strong>'. number_format($row_grp['percentile'],2) .'</strong>';
297 print '<br />'._('Activity Ranking: ').' <strong>'. number_format($row_grp['ranking'],2) .'</strong>';
299 print '<br />'._('Registered: ').' <strong>'.date(_('Y-m-d H:i'),$row_grp['register_time']).'</strong>';
300 print "</td></tr></table>\n<hr />\n";
301 } // end if for row and range chacking
304 // print bottom navigation if there are more projects to display
305 if ($querytotalcount > $TROVE_BROWSELIMIT) {
308 } elseif( $cat === 'h') {
309 plugin_hook('display_hierarchy');
312 // print '<p><FONT size="-1">This listing was produced by the following query: '
313 // .$query_projlist.'</FONT>';
314 echo '</div><!-- id="project-tree" -->' . "\n";
316 $HTML->footer(array());
320 // c-file-style: "bsd"