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 // Allow alternate content-type rendering by hook
34 $default_content_type = 'text/html';
36 $script = 'trove_list';
37 $content_type = util_negociate_alternate_content_types($script, $default_content_type);
39 if($content_type != $default_content_type) {
40 $hook_params = array();
41 $hook_params['accept'] = $content_type;
42 $hook_params['return'] = '';
43 $hook_params['content_type'] = '';
44 plugin_hook_by_reference('content_negociated_trove_list', $hook_params);
45 if($hook_params['content_type'] != ''){
46 header('Content-type: '. $hook_params['content_type']);
47 echo $hook_params['content'];
50 header('HTTP/1.1 406 Not Acceptable',true,406);
56 $HTML->header(array('title'=>_('Software Map'),'pagename'=>'softwaremap'));
57 $HTML->printSoftwareMapLinks();
59 $form_cat = getIntFromRequest('form_cat');
60 $page = getIntFromRequest('page',1);
61 $cat = getStringFromRequest('cat');
66 // assign default. 18 is 'topic'
68 $form_cat = forge_get_config('default_trove_cat');
71 // get info about current folder
72 $res_trove_cat = db_query_params('
75 WHERE trove_cat_id=$1 ORDER BY fullname',
78 if (db_numrows($res_trove_cat) < 1) {
79 exit_error(_('That Trove category does not exist').': '.db_error(),'trove');
82 echo '<div id="project-tree" class="underline-link">' . "\n";
83 echo '<h2>' . _('Project tree') . '</h2>' . "\n";
85 plugin_hook('display_hierarchy_submenu');
88 $row_trove_cat = db_fetch_array($res_trove_cat);
90 // #####################################
91 // this section limits search and requeries if there are discrim elements
93 $discrim = getStringFromRequest('discrim');
97 $qpa_alias = db_construct_qpa();
98 $qpa_and = db_construct_qpa();
101 $discrim_url_b = array();
104 $expl_discrim = explode(',', $discrim);
106 if (sizeof($expl_discrim) > 6) {
107 array_splice($expl_discrim, 6);
111 for ($i = 0; $i < sizeof($expl_discrim); $i++) {
112 // make sure these are all ints, no url trickery
113 $expl_discrim[$i] = intval($expl_discrim[$i]);
115 // need one aliased table for everything
116 $qpa_alias = db_construct_qpa($qpa_alias,', trove_agg trove_agg_'.$i);
118 // need additional AND entries for aliased tables
119 $qpa_and = db_construct_qpa($qpa_and,
120 sprintf(' AND trove_agg_%d.trove_cat_id=$%d AND trove_agg_%d.group_id=trove_agg.group_id ', $i, $i+1, $i),
121 array($expl_discrim[$i]));
123 $expl_discrim_b = array();
124 for ($j = 0; $j < sizeof($expl_discrim); $j++) {
126 $expl_discrim_b[] = $expl_discrim[$j];
129 $discrim_url_b[$i] = '&discrim=' . implode(',', $expl_discrim_b);
132 $discrim_url = '&discrim=' . implode(',', $expl_discrim);
134 // build text for top of page on what viewier is seeing
135 $discrim_desc = _('Now limiting view to projects in the following categories:');
137 for ($i = 0; $i < sizeof($expl_discrim); $i++) {
138 $discrim_desc .= '<br /> '
139 .trove_getfullpath($expl_discrim[$i])
140 .util_make_link('/softwaremap/trove_list.php?cat=c&form_cat='.$form_cat .$discrim_url_b[$i],' ['._('Remove This Filter').']');
142 $discrim_desc .= "<hr />\n";
145 // #######################################
147 if (!empty($discrim_desc))
148 print '<p>'.$discrim_desc.'</p>';
150 // ######## two column table for key on right
151 // first print all parent cats and current cat
152 print '<table summary="">' . "\n";
154 print '<td id="project-tree-col1">' . "\n";
156 $folders = explode(" :: ",$row_trove_cat['fullpath']);
157 $folders_ids = explode(" :: ",$row_trove_cat['fullpath_ids']);
158 $folders_len = count($folders);
161 print html_image("category.png",'32','33',array('alt'=>""));
164 for ($i = 0; $i < $folders_len; $i++) {
165 // no anchor for current cat
166 if ($folders_ids[$i] != $form_cat) {
167 print util_make_link('/softwaremap/trove_list.php?cat=c&form_cat=' .$folders_ids[$i].$discrim_url,
170 print " > ";
172 print '<strong>'.$folders[$i].'</strong>';
177 // print subcategories
178 $res_sub = db_query_params('
179 SELECT trove_cat.trove_cat_id AS trove_cat_id,
180 trove_cat.fullname AS fullname,
181 trove_treesums.subprojects AS subprojects
182 FROM trove_cat LEFT JOIN trove_treesums USING (trove_cat_id)
184 trove_treesums.limit_1=0
185 OR trove_treesums.limit_1 IS NULL
186 ) AND trove_cat.parent=$1
192 while ($row_sub = db_fetch_array($res_sub)) {
194 print '<a href="trove_list.php?cat=c&form_cat=' . $row_sub['trove_cat_id'] . $discrim_url . '">';
195 print $row_sub['fullname'];
198 print sprintf(_('%1$s projects'), $row_sub['subprojects']?$row_sub['subprojects']:'0');
203 // ########### right column: root level
205 print '<td id="project-tree-col2">';
206 // here we print list of root level categories, and use open folder for current
207 $res_rootcat = db_query_params('
208 SELECT trove_cat_id,fullname
217 print _('Browse By').':';
220 print '<ul id="project-tree-branches">';
221 while ($row_rootcat = db_fetch_array($res_rootcat)) {
222 // print open folder if current, otherwise closed
223 // also make anchor if not current
224 if (($row_rootcat['trove_cat_id'] == $row_trove_cat['root_parent'])
225 || ($row_rootcat['trove_cat_id'] == $row_trove_cat['trove_cat_id'])) {
226 print '<li class="current-cat">' . $row_rootcat['fullname'] . "</li>\n";
229 print util_make_link ('/softwaremap/trove_list.php?cat=c&form_cat=' .$row_rootcat['trove_cat_id'].$discrim_url, $row_rootcat['fullname']);
234 print "</td>\n</tr>\n</table>\n";
239 // one listing for each project
241 $qpa = db_construct_qpa();
242 $qpa = db_construct_qpa($qpa, 'SELECT * FROM trove_agg');
243 $qpa = db_join_qpa($qpa, $qpa_alias);
244 $qpa = db_construct_qpa($qpa, ' WHERE trove_agg.trove_cat_id=$1', array($form_cat));
245 $qpa = db_join_qpa($qpa, $qpa_and);
246 $qpa = db_construct_qpa($qpa, ' ORDER BY trove_agg.trove_cat_id ASC, trove_agg.ranking ASC');
247 $res_grp = db_query_qpa($qpa, $TROVE_HARDQUERYLIMIT, 0, 'SYS_DB_TROVE');
250 while ($row_grp = db_fetch_array($res_grp)) {
251 if (!forge_check_perm ('project_read', $row_grp['group_id'])) {
254 $projects[] = $row_grp;
256 $querytotalcount = count($projects);
258 // #################################################################
259 // limit/offset display
261 // store this as a var so it can be printed later as well
263 if ($querytotalcount == $TROVE_HARDQUERYLIMIT) {
264 $html_limit .= 'More than ';
265 $html_limit .= sprintf(_('More than <strong>%1$s</strong> projects in result set.'), $querytotalcount);
268 $html_limit .= sprintf(ngettext('<strong>%1$s</strong> project in result set.', '<strong>%1$s</strong> projects in result set.', $querytotalcount), $querytotalcount);
270 // only display pages stuff if there is more to display
271 if ($querytotalcount > $TROVE_BROWSELIMIT) {
272 $html_limit .= ' Displaying '.$TROVE_BROWSELIMIT.' per page. Projects sorted by activity ranking.<br />';
274 // display all the numbers
275 for ($i=1;$i<=ceil($querytotalcount/$TROVE_BROWSELIMIT);$i++) {
277 $displayed_i = '<'.$i.'>';
279 $html_limit .= "<strong>$displayed_i</strong>" ;
287 print $html_limit."<hr />\n";
289 // #################################################################
290 // print actual project listings
291 for ($i_proj=0;$i_proj<$querytotalcount;$i_proj++) {
292 $row_grp = $projects[$i_proj];
294 // check to see if row is in page range
295 if (($i_proj >= (($page-1)*$TROVE_BROWSELIMIT)) && ($i_proj < ($page*$TROVE_BROWSELIMIT))) {
301 if ($row_grp && $viewthisrow) {
302 print '<table border="0" cellpadding="0" width="100%"><tr valign="top"><td colspan="2">';
304 print util_make_link_g ($row_grp['unix_group_name'],
305 $row_grp['group_id'],
306 "<strong>".htmlspecialchars($row_grp['group_name'])."</strong> ");
307 if ($row_grp['short_description']) {
308 print "- " . htmlspecialchars($row_grp['short_description']);
311 print '<br /> ';
313 print "</td></tr>\n<tr valign=\"top\"><td>";
314 // list all trove categories
315 print trove_getcatlisting($row_grp['group_id'],1,0,1);
317 print '<td style="text-align:right">'; // now the right side of the display
318 if (group_get_object($row_grp['group_id'])->usesStats()) {
319 print _('Activity Percentile: ').'<strong>'. number_format($row_grp['percentile'],2) .'</strong>';
320 print '<br />'._('Activity Ranking: ').' <strong>'. number_format($row_grp['ranking'],2) .'</strong>';
322 print '<br />'._('Registered: ').' <strong>'.date(_('Y-m-d H:i'),$row_grp['register_time']).'</strong>';
323 print "</td></tr></table>\n<hr />\n";
324 } // end if for row and range chacking
327 // print bottom navigation if there are more projects to display
328 if ($querytotalcount > $TROVE_BROWSELIMIT) {
331 } elseif( $cat === 'h') {
332 plugin_hook('display_hierarchy');
335 // print '<p><FONT size="-1">This listing was produced by the following query: '
336 // .$query_projlist.'</FONT>';
337 echo '</div><!-- id="project-tree" -->' . "\n";
339 $HTML->footer(array());
343 // c-file-style: "bsd"