This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  1f85e01f20c341890a6b279da328fd113e9ca041 (commit)
      from  4b8c98650f59fb0266d5a691fddfc3987e3e55ae (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=1f85e01f20c341890a6b279da328fd113e9ca041

commit 1f85e01f20c341890a6b279da328fd113e9ca041
Author: Franck Villaume <[email protected]>
Date:   Thu Jan 14 19:21:26 2016 +0100

    projects page: add paging system in subpage tag_cloud

diff --git a/src/CHANGES b/src/CHANGES
index 0729a11..8ff0391 100644
--- a/src/CHANGES
+++ b/src/CHANGES
@@ -2,6 +2,7 @@ FusionForge 6.X:
 * Accounts: minimum password length is now 8
 * Spellcheck (Anders Jonsson)
 * Site Admin: add paging system in userlist page [#799] (TrivialDev)
+* Projects Page: add paging system in full_list and tag_cloud subpages 
(TrivialDev)
 * Docman: limit number of returned documents on search query. Use paging 
system [#794] (TrivialDev)
 * Docman: limit search using from & to dates [#798] (TrivialDev)
 * Docman: use standard search engine: unify results between 'search in 
project' & search in the docs tab (TrivialDev)
diff --git a/src/common/include/FusionForge.class.php 
b/src/common/include/FusionForge.class.php
index 8cd12b4..a91a66d 100644
--- a/src/common/include/FusionForge.class.php
+++ b/src/common/include/FusionForge.class.php
@@ -94,6 +94,7 @@ class FusionForge extends Error {
                }
                return $this->parseCount($res);
        }
+
        function getNumberOfActiveProjects() {
                return $this->getNumberOfProjects(array('status' => 'A'));
        }
@@ -167,9 +168,37 @@ class FusionForge extends Error {
                return $result;
        }
 
+       function getNumberOfProjectsUsingTags($params = array(), $extended_qpa 
= null) {
+               $qpa = db_construct_qpa(false, 'SELECT count(*) as count FROM 
groups, project_tags WHERE groups.group_id = project_tags.group_id ');
+               if (count($params) > 1) {
+                       $qpa = db_construct_qpa($qpa, ' AND ');
+                       $i = 0;
+                       foreach ($params as $key => $value) {
+                               $i++;
+                               $qpa = db_construct_qpa($qpa, $key.' = $1 ', 
array($value));
+                               if ($i < count($params)) {
+                                       $qpa = db_construct_qpa($qpa, ' AND ');
+                               }
+                       }
+               }
+               if (strlen($extended_qpa) > 1) {
+                       if (strpos($qpa[0], 'AND')) {
+                               $qpa = db_construct_qpa($qpa, ' AND ');
+                       }
+                       $qpa = db_construct_qpa($qpa, $extended_qpa);
+               }
+               $res = db_query_qpa($qpa);
+               if (!$res || db_numrows($res) < 1) {
+                       $this->setError('Unable to get hosted project count: 
'.db_error());
+                       return false;
+               }
+               return $this->parseCount($res);
+       }
+
+
        function parseCount($res) {
                $row_count = db_fetch_array($res);
-               return $row_count['count'];
+               return (int)$row_count['count'];
        }
 }
 
diff --git a/src/common/include/Group.class.php 
b/src/common/include/Group.class.php
index 93b17ba..7f4d130 100644
--- a/src/common/include/Group.class.php
+++ b/src/common/include/Group.class.php
@@ -6,7 +6,7 @@
  * Copyright 2009-2013, Roland Mas
  * Copyright 2010-2011, Franck Villaume - Capgemini
  * Copyright 2010-2012, Alain Peyrat - Alcatel-Lucent
- * Copyright 2012-2014, Franck Villaume - TrivialDev
+ * Copyright 2012-2015, Franck Villaume - TrivialDev
  * Copyright 2013, French Ministry of National Education
  * http://fusionforge.org
  *
@@ -193,6 +193,41 @@ function 
group_get_public_active_projects_asc($max_query_limit = -1, $offset = 0
        return $projects;
 }
 
+/**
+ * group_get_readable_projects_using_tag_asc() - Get a list of group_id for 
active projects (initially in trove/tag_cloud)
+ *
+ * @param      string  $selected_tag           Tag to search
+ * @param      int     $max_query_limit        Optional Maximum number of rows 
to limit query length
+ * @param      int     $offset                 start to retrieve rows from 
offset value
+ * @return     array   List of public active projects
+ */
+function group_get_readable_projects_using_tag_asc($selected_tag, 
$max_query_limit = -1, $offset = 0) {
+       $role_id = 1;
+       if (session_loggedin()) {
+               global $LUSER;
+               $userRoles = $LUSER->getRoles();
+               if (count($userRoles)) {
+                       foreach ($userRoles as $r) {
+                               $role_id .= ', '.$r->getID();
+                       }
+               }
+       }
+
+       $res_grp = db_query_params ('SELECT groups.group_id, group_name, 
unix_group_name, short_description, register_time
+               FROM project_tags, groups
+               WHERE LOWER(name) = $1
+               AND project_tags.group_id = groups.group_id
+               AND groups.status = $2 AND groups.type_id=1 AND 
groups.is_template=0 AND groups.register_time > 0
+               AND groups.group_id in (select ref_id FROM pfo_role_setting 
WHERE section_name = $3 and perm_val = 1 and role_id IN ('.$role_id.'))
+               ORDER BY groups.group_name ASC',
+               array(strtolower($selected_tag), 'A', 'project_read'),
+               $max_query_limit, $offset);
+       $projects = array();
+       while ($row_grp = db_fetch_array($res_grp)) {
+               $projects[] = $row_grp;
+       }
+       return $projects;
+}
 
 class Group extends Error {
        /**
diff --git a/src/www/people/people_utils.php b/src/www/people/people_utils.php
index 956ba39..213a4ba 100644
--- a/src/www/people/people_utils.php
+++ b/src/www/people/people_utils.php
@@ -6,7 +6,7 @@
  * Copyright 2002-2004 (c) GForge Team
  * Copyright 2010 (c) Franck Villaume
  * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
- * Copyright 2013-2014, Franck Villaume - TrivialDev
+ * Copyright 2013-2015, Franck Villaume - TrivialDev
  * http://fusionforge.org/
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -469,6 +469,12 @@ function people_show_job_list($result) {
        return $return;
 }
 
+function people_group_has_job($group_id) {
+       $res = db_query_params('SELECT count(*) as count FROM people_job WHERE 
group_id = $1', array($group_id));
+       $row_count = db_fetch_array($res);
+       return (int)$row_count['count'];
+}
+
 // Local Variables:
 // mode: php
 // c-file-style: "bsd"
diff --git a/src/www/softwaremap/tag_cloud.php 
b/src/www/softwaremap/tag_cloud.php
index 6c28082..d65e50c 100644
--- a/src/www/softwaremap/tag_cloud.php
+++ b/src/www/softwaremap/tag_cloud.php
@@ -1,6 +1,7 @@
 <?php
 /**
  * Copyright (C) 2008-2009 Alcatel-Lucent
+ * Copyright 2015, Franck Villaume - TrivialDev
  *
  * This file is part of FusionForge. FusionForge is free software;
  * you can redistribute it and/or modify it under the terms of the
@@ -44,141 +45,102 @@ require_once '../env.inc.php';
 require_once $gfcommon.'include/pre.php';
 require_once $gfwww.'include/trove.php';
 require_once $gfcommon.'include/tag_cloud.php';
+require_once $gfwww.'people/people_utils.php';
 
 if (!forge_get_config('use_project_tags')) {
        exit_disabled();
 }
 
+global $HTML;
+
 $HTML->header(array('title'=>_('Tag Cloud'),'pagename'=>'softwaremap'));
 $HTML->printSoftwareMapLinks();
 
 $selected_tag = getStringFromRequest('tag');
-$page = getIntFromRequest('page', 1);
 
-echo '<br />' . tag_cloud(array('selected' => $selected_tag, 'nb_max' => 100)) 
. '<br />';
+echo tag_cloud(array('selected' => $selected_tag, 'nb_max' => 100)) . '<br 
/><br />';
 
 if ($selected_tag) {
-       $res_grp = db_query_params('
-               SELECT groups.group_id, group_name, unix_group_name, 
short_description, register_time
-               FROM project_tags, groups
-               WHERE LOWER(name) = $1
-               AND project_tags.group_id = groups.group_id
-               AND status = $2 AND type_id=1 AND register_time > 0
-               ORDER BY group_name ASC',
-               array(strtolower($selected_tag), 'A'), $TROVE_HARDQUERYLIMIT);
-       $projects = array();
-       $project_ids = array();
-       while ($row_grp = db_fetch_array($res_grp)) {
-               if (!forge_check_perm('project_read', $row_grp['group_id'])) {
-                       continue;
+       $role_id = 1;
+
+       if (session_loggedin()) {
+               if (getStringFromRequest('setpaging')) {
+                       /* store paging preferences */
+                       $paging = getIntFromRequest('nres');
+                       if (!$paging) {
+                               $paging = 25;
+                       }
+                       $LUSER->setPreference('paging', $paging);
+               }
+               /* logged in users get configurable paging */
+               $paging = $LUSER->getPreference('paging');
+               $userRoles = $LUSER->getRoles();
+               if (count($userRoles)) {
+                       foreach ($userRoles as $r) {
+                               $role_id .= ', '.$r->getID();
+                       }
                }
-               $projects[] = $row_grp;
-               $project_ids[] = $row_grp['group_id'];
        }
-       $querytotalcount = count($projects);
 
-       // #################################################################
-       // limit/offset display
+       if(!isset($paging) || !$paging)
+               $paging = 25;
 
-       // store this as a var so it can be printed later as well
-       $html_limit = '';
-       if ($querytotalcount == $TROVE_HARDQUERYLIMIT){
-               $html_limit .= sprintf(_('More than <strong>%1$s</strong> 
projects have <strong>%2$s</strong> as tag.'), $TROVE_HARDQUERYLIMIT, 
htmlspecialchars($selected_tag));
-       }
-       else {
-               $html_limit .= sprintf(ngettext('<strong>%d</strong> project in 
result set.',
-                                               '<strong>%d</strong> projects 
in result set.',
-                                               $querytotalcount),
-                                               $querytotalcount);
-       }
+       $start = getIntFromRequest('start');
 
-       // only display pages stuff if there is more to display
-       if ($querytotalcount > $TROVE_BROWSELIMIT) {
-               $html_limit .= ' ';
-               $html_limit .= sprintf(ngettext('Displaying %d project per 
page. Projects sorted by alphabetical order.',
-                                                 'Displaying %d projects per 
page. Projects sorted by alphabetical order.',
-                                                 $TROVE_BROWSELIMIT),
-                                               $TROVE_BROWSELIMIT);
-               $html_limit .= '.<br />';
-
-               // display all the numbers
-               for ($i=1 ;$i <= ceil($querytotalcount/$TROVE_BROWSELIMIT); 
$i++) {
-                       $html_limit .= ' ';
-                       if ($page != $i) {
-                               $html_limit .= util_make_link 
('/softwaremap/tag_cloud.php?tag='.$selected_tag.'&page='.$i,
-                                                              
'&lt;'.$i.'&gt;');
-                       } else {
-                               $html_limit .= 
'<strong>&lt;'.$i.'&gt;</strong>';
-                       }
-                       $html_limit .= ' ';
-               }
+       if ($start < 0) {
+               $start = 0;
        }
+       $nbProjects = 
FusionForge::getInstance()->getNumberOfProjectsUsingTags(array('groups.status' 
=> 'A', 'groups.type_id' => 1, 'groups.is_template' => 0, 'LOWER(name)' => 
strtolower($selected_tag)), 'register_time > 0 AND groups.group_id in (select 
ref_id FROM pfo_role_setting WHERE section_name = \'project_read\' and perm_val 
= 1 and role_id IN ('.$role_id.'))');
+       $projects = group_get_readable_projects_using_tag_asc($selected_tag, 
$paging, $start);
 
-       print $html_limit."<hr />\n";
+       $max = ($nbProjects > ($start + $paging)) ? ($start + $paging) : 
$nbProjects;
+       echo $HTML->paging_top($start, $paging, $nbProjects, $max, 
'/softwaremap/tag_cloud.php?tag='.$selected_tag);
+
+       echo html_e('hr');
 
        // #################################################################
        // print actual project listings
-       for ($i_proj = 0; $i_proj < $querytotalcount; $i_proj++) {
+       for ($i_proj = 0; $i_proj < count($projects); $i_proj++) {
                $row_grp = $projects[$i_proj];
 
-               // check to see if row is in page range
-               if (($i_proj >= (($page-1)*$TROVE_BROWSELIMIT)) && ($i_proj < 
($page*$TROVE_BROWSELIMIT))) {
-                       $viewthisrow = 1;
+               echo $HTML->listTableTop();
+               $cells = array();
+               $content = util_make_link ('/projects/'. 
strtolower($row_grp['unix_group_name']).'/',
+                                     
'<strong>'.$row_grp['group_name'].'</strong> ');
+               if ($row_grp['short_description']) {
+                       $content .= "- " . $row_grp['short_description'];
+               }
+               $cells[] = array($content, 'colspan' => 2);
+               echo $HTML->multiTableRow(array('class' => 'top'), $cells);
+               // extra description
+               $cells = array();
+               $cells[] = array(_('Tags') . _(': ') . 
list_project_tag($row_grp['group_id']), 'colspan' => 2);
+               echo $HTML->multiTableRow(array('class' => 'top'), $cells);
+               $cells = array();
+               $cells[][] = trove_getcatlisting($row_grp['group_id'],0,1,0);
+               $res = db_query_params('SELECT percentile, ranking FROM 
project_weekly_metric WHERE group_id = $1', array($row_grp['group_id']));
+               $nb_line = db_numrows($res);
+               if ($nb_line) {
+                       $percentile = html_e('strong', array(), 
sprintf('%3.0f', number_format(db_result($res, 0, 'percentile'))));
+                       $ranking = html_e('strong', array(), sprintf('%d', 
number_format(db_result($res, 0, 'ranking'))));
                } else {
-                       $viewthisrow = 0;
+                       $percentile = _('N/A');
+                       $ranking = _('N/A');
                }
-
-               if ($row_grp && $viewthisrow) {
-                       print '<table class="fullwidth">';
-                       print '<tr class="top"><td colspan="2">';
-                       print util_make_link ('/projects/'. 
strtolower($row_grp['unix_group_name']).'/',
-                                             
'<strong>'.$row_grp['group_name'].'</strong> ');
-
-                       if ($row_grp['short_description']) {
-                               print "- " . $row_grp['short_description'];
-                       }
-
-                       // extra description
-                       print '</td></tr>';
-                       print '<tr class="top"><td colspan="2">';
-                       print _('Tags') . _(': ') . 
list_project_tag($row_grp['group_id']);
-                       print '</td></tr>';
-                       print '<tr class="top"><td>';
-                       // list all trove categories
-                       print trove_getcatlisting($row_grp['group_id'],0,1,0);
-                       print '</td>'."\n".'<td class="align-right">'; // now 
the right side of the display
-                       $res = db_query_params('SELECT percentile, ranking
-                                       FROM project_weekly_metric
-                                       WHERE group_id=$1', 
array($row_grp['group_id']));
-                       $nb_line = db_numrows($res);
-                       if (! $nb_line) {
-                               $percentile = 'N/A';
-                               $ranking = 'N/A';
-                       }
-                       else {
-                               $percentile = number_format(db_result($res, 0, 
'percentile'));
-                               $ranking = number_format(db_result($res, 0, 
'ranking'));
-                       }
-                       printf ('<br />'._('Activity Percentile: 
<strong>%3.0f</strong>'), $percentile);
-                       printf ('<br />'._('Activity Ranking: 
<strong>%d</strong>'), $ranking);
-                       printf ('<br />'._('Registered') . _(': '));
-                       printf ('<strong>%s</strong>', date(_('Y-m-d 
H:i'),$row_grp['register_time']));
-                       print '</td></tr>';
-                       /*
-                        if ($row_grp['jobs_count']) {
-                        print '<tr><td colspan="2" class="align-center">'
-                        .util_make_link 
('/people/?group_id='.$row_grp['group_id'],_("[This project needs 
help]")).'</td></td>';
-                        }
-                       */
-                       print '</table>';
-                       print '<hr />';
-               } // end if for row and range chacking
-       }
-
-       // print bottom navigation if there are more projects to display
-       if ($querytotalcount > $TROVE_BROWSELIMIT) {
-               print $html_limit;
+               $content = html_e('br')._('Activity Percentile')._(': 
').$percentile;
+               $content .= html_e('br')._('Activity Ranking')._(': ').$ranking;
+               $content .= html_e('br').sprintf(_('Registered') . _(': '));
+               $content .= html_e('strong', array(), date(_('Y-m-d 
H:i'),$row_grp['register_time']));
+               $cells[] = array($content, 'class' => 'align-right');
+               echo $HTML->multiTableRow(array('class' => 'top'), $cells);
+               if (forge_get_config('use_people') && 
people_group_has_job($row_grp['group_id'])) {
+                               $cells = array();
+                               $cells[] = 
array(util_make_link('/people/?group_id='.$row_grp['group_id'],_('[This project 
needs help]')), 'colspan' => 2, 'class' => 'align-center');
+                               echo $HTML->multiTableRow(array('class' => 
'top'), $cells);
+               }
+               echo $HTML->listTableBottom();
+               print '<hr />';
        }
+       echo $HTML->paging_bottom($start, $paging, $nbProjects, 
'/softwaremap/tag_cloud.php?tag='.$selected_tag);
 }
-
 $HTML->footer();

-----------------------------------------------------------------------

Summary of changes:
 src/CHANGES                              |   1 +
 src/common/include/FusionForge.class.php |  31 +++++-
 src/common/include/Group.class.php       |  37 ++++++-
 src/www/people/people_utils.php          |   8 +-
 src/www/softwaremap/tag_cloud.php        | 180 ++++++++++++-------------------
 5 files changed, 145 insertions(+), 112 deletions(-)


hooks/post-receive
-- 
FusionForge

_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits

Reply via email to