3 * FusionForge Trove Software Map
5 * Copyright 1999-2001, VA Linux Systems, Inc.
6 * Copyright 2009, Roland Mas
7 * Copyright 2011, Franck Villaume - Capgemini
8 * Copyright 2013-2014, Franck Villaume - TrivialDev
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 require_once '../env.inc.php';
27 require_once $gfcommon.'include/pre.php';
28 require_once $gfwww.'include/trove.php';
30 if (!forge_get_config('use_trove')) {
31 exit_disabled('home');
36 // Allow alternate content-type rendering by hook
37 $default_content_type = 'text/html';
39 $script = 'trove_list';
40 $content_type = util_negociate_alternate_content_types($script, $default_content_type);
42 if($content_type != $default_content_type) {
43 $hook_params = array();
44 $hook_params['accept'] = $content_type;
45 $hook_params['return'] = '';
46 $hook_params['content_type'] = '';
47 plugin_hook_by_reference('content_negociated_trove_list', $hook_params);
48 if($hook_params['content_type'] != ''){
49 header('Content-type: '. $hook_params['content_type']);
50 echo $hook_params['content'];
53 header('HTTP/1.1 406 Not Acceptable',true,406);
58 $HTML->header(array('title'=>_('Software Map'),'pagename'=>'softwaremap'));
59 $HTML->printSoftwareMapLinks();
61 // assign default. 18 is 'topic'
62 $form_cat = getIntFromRequest('form_cat', forge_get_config('default_trove_cat'));
64 // default first page.
65 $page = getIntFromRequest('page', 1);
67 // 'c' for by categories
68 $cat = getStringFromRequest('cat', 'c');
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 html_ao('div', array('id' => 'project-tree', 'class' => 'underline-link'));
83 echo html_e('h2', array(), _('Project Tree'));
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 echo html_e('p', array(), $discrim_desc);
150 // ######## two column table for key on right
151 // first print all parent cats and current cat (breadcrumb)
152 echo $HTML->listTableTop();
153 print '<tr class="top">' . "\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
191 $elementsLi = array();
192 while ($row_sub = db_fetch_array($res_sub)) {
193 $realprojects = ($row_sub['subprojects']) ? $row_sub['subprojects'] : 0;
194 $plural = ($row_sub['subprojects'] > 1) ? $row_sub['subprojects'] : 0;
195 $content = util_make_link('/softwaremap/trove_list.php?cat=c&form_cat='.$row_sub['trove_cat_id'].$discrim_url, $row_sub['fullname']);
196 $content .= ' '.html_e('em', array(), '('.sprintf(ngettext('%s project', '%s projects', $plural), $realprojects).')');
197 $elementsLi[] = array('content' => $content);
199 echo $HTML->html_list($elementsLi);
201 // ########### right column: root level
203 print '<td id="project-tree-col2">';
204 // here we print list of root level categories, and use open folder for current
205 $res_rootcat = db_query_params('
206 SELECT trove_cat_id,fullname
214 echo html_e('p', array(), _('Browse By')._(':'));
216 $elementsLi = array();
217 while ($row_rootcat = db_fetch_array($res_rootcat)) {
218 // print open folder if current, otherwise closed
219 // also make anchor if not current
220 if (($row_rootcat['trove_cat_id'] == $row_trove_cat['root_parent'])
221 || ($row_rootcat['trove_cat_id'] == $row_trove_cat['trove_cat_id'])) {
222 $elementsLi[] = array('content' => $row_rootcat['fullname'], 'attrs' => array('class' => 'current-cat'));
224 $elementsLi[] = array('content' => util_make_link('/softwaremap/trove_list.php?cat=c&form_cat=' .$row_rootcat['trove_cat_id'].$discrim_url, $row_rootcat['fullname']));
227 echo $HTML->html_list($elementsLi, array('id' => 'project-tree-branches'));
228 print "</td>\n</tr>\n";
229 echo $HTML->listTableBottom();
232 // one listing for each project
233 $qpa = db_construct_qpa();
234 $qpa = db_construct_qpa($qpa, 'SELECT * FROM trove_agg');
235 $qpa = db_join_qpa($qpa, $qpa_alias);
236 $qpa = db_construct_qpa($qpa, ' WHERE trove_agg.trove_cat_id=$1', array($form_cat));
237 $qpa = db_join_qpa($qpa, $qpa_and);
238 $qpa = db_construct_qpa($qpa, ' ORDER BY trove_agg.trove_cat_id ASC, trove_agg.ranking ASC');
239 $res_grp = db_query_qpa($qpa, $TROVE_HARDQUERYLIMIT, 0, 'SYS_DB_TROVE');
242 while ($row_grp = db_fetch_array($res_grp)) {
243 if (!forge_check_perm ('project_read', $row_grp['group_id'])) {
246 $projects[] = $row_grp;
248 $querytotalcount = count($projects);
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 .= sprintf(_('More than <strong>%d</strong> projects in result set.'), $querytotalcount);
259 $html_limit .= sprintf(ngettext('<strong>%d</strong> project in result set.', '<strong>%d</strong> projects in result set.', $querytotalcount), $querytotalcount);
260 if ($querytotalcount > $TROVE_BROWSELIMIT) {
261 $html_limit .= html_trove_limit_navigation_box($_SERVER['PHP_SELF'].'?cat=c&form_cat='.$form_cat, $querytotalcount, $TROVE_BROWSELIMIT, $page, sprintf(_('Displaying %1$s per page. Projects sorted by activity ranking.'), $TROVE_BROWSELIMIT));
263 echo $html_limit.html_e('hr');
265 // #################################################################
266 // print actual project listings
267 for ($i_proj=0;$i_proj<$querytotalcount;$i_proj++) {
268 $row_grp = $projects[$i_proj];
270 // check to see if row is in page range
271 if (($i_proj >= (($page-1)*$TROVE_BROWSELIMIT)) && ($i_proj < ($page*$TROVE_BROWSELIMIT))) {
277 if ($row_grp && $viewthisrow) {
278 print '<table class="fullwidth"><tr class="top"><td colspan="2">';
279 print util_make_link_g ($row_grp['unix_group_name'],
280 $row_grp['group_id'],
281 "<strong>".htmlspecialchars($row_grp['group_name'])."</strong> ");
282 if ($row_grp['short_description']) {
283 print "- " . htmlspecialchars($row_grp['short_description']);
286 print '<br /> ';
288 print "</td></tr>\n<tr class=\"top\"><td>";
289 // list all trove categories
290 print trove_getcatlisting($row_grp['group_id'],1,0,1);
292 print '<td class="align-right">'; // now the right side of the display
293 if (group_get_object($row_grp['group_id'])->usesStats()) {
294 print _('Activity Percentile')._(': ').'<strong>'. number_format($row_grp['percentile'],2) .'</strong>';
296 sprintf(_('Activity Ranking: <strong>%d</strong>'), number_format($row_grp['ranking'],2));
298 print '<br />'._('Registered'). _(': ') . '<strong>'.date(_('Y-m-d H:i'),$row_grp['register_time']).'</strong>';
299 print "</td></tr></table>\n<hr />\n";
300 } // end if for row and range chacking
303 // print bottom navigation if there are more projects to display
304 if ($querytotalcount > $TROVE_BROWSELIMIT) {
307 } elseif( $cat === 'h') {
308 plugin_hook('display_hierarchy');
311 // print '<p><FONT size="-1">This listing was produced by the following query: '
312 // .$query_projlist.'</FONT>';
313 echo html_ac(html_ap() -1);
319 // c-file-style: "bsd"