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 c41d4330fc84510ac03ad0dc174da575ddbf9747 (commit)
from 11dbb66b84578ac2650d72ab6a769c78a88a640e (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=c41d4330fc84510ac03ad0dc174da575ddbf9747
commit c41d4330fc84510ac03ad0dc174da575ddbf9747
Author: Franck Villaume <[email protected]>
Date: Sat Dec 5 10:42:26 2015 +0100
docman: support paging in listfile view
diff --git a/src/common/docman/DocumentFactory.class.php
b/src/common/docman/DocumentFactory.class.php
index 75e05f1..85c51af 100644
--- a/src/common/docman/DocumentFactory.class.php
+++ b/src/common/docman/DocumentFactory.class.php
@@ -79,6 +79,13 @@ class DocumentFactory extends Error {
var $limit = 0;
/**
+ * The offset
+ * @var integer Contains the offset of the query used to retrive
documents using getDocuments.
+ * Default value is 0 which means NO OFFSET
+ */
+ var $offset = 0;
+
+ /**
* Constructor.
*
* @param $Group
@@ -260,6 +267,17 @@ class DocumentFactory extends Error {
}
/**
+ * setOffset - call this before getDocuments() if you want to move to
the offset in the query used to retrieve documents.
+ * default value is 0 which means : no offset.
+ *
+ * @param int $offset The offset to use
+ * @access public
+ */
+ function setOffset($offset) {
+ $this->offset = $offset;
+ }
+
+ /**
* getDocuments - returns an array of Document objects.
*
* @param int $nocache Force to reset the cached data
if any available.
@@ -353,6 +371,8 @@ class DocumentFactory extends Error {
$qpa = db_construct_qpa($qpa, ' LIMIT $1',
array($this->limit));
}
+ $qpa = db_construct_qpa($qpa, ' OFFSET $1',
array($this->offset));
+
$result = db_query_qpa($qpa);
if (!$result) {
$this->setError('getFromStorage:'.db_error());
diff --git a/src/common/docman/views/listfile.php
b/src/common/docman/views/listfile.php
index bf8e124..6e908ad 100644
--- a/src/common/docman/views/listfile.php
+++ b/src/common/docman/views/listfile.php
@@ -36,6 +36,7 @@ global $LUSER; // User object
global $g; // the Group object
global $dm; // the docman manager
global $warning_msg;
+global $start; // use to set the offset
$linkmenu = 'listfile';
$baseredirecturl = '/docman/?group_id='.$group_id;
@@ -60,6 +61,22 @@ if ($childgroup_id) {
$g = group_get_object($childgroup_id);
}
+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');
+}
+
+if(!isset($paging) || !$paging)
+ $paging = 25;
+
$df = new DocumentFactory($g);
if ($df->isError())
exit_error($df->getErrorMessage(), 'docman');
@@ -68,6 +85,8 @@ $dgf = new DocumentGroupFactory($g);
if ($dgf->isError())
exit_error($dgf->getErrorMessage(), 'docman');
+$df->setLimit($paging);
+$df->setOffset($start);
$df->setDocGroupID($dirid);
//active, hidden & private state ids
@@ -91,6 +110,12 @@ if ($dirid) {
$error_msg = _('Invalid folder');
session_redirect($baseredirecturl.'&view=listfile');
}
+ $nbDocs = $ndg->getNumberOfDocuments(1);
+ if (forge_check_perm('docman', $g->getID(), 'approve')) {
+ $nbDocs += $ndg->getNumberOfDocuments(3);
+ $nbDocs += $ndg->getNumberOfDocuments(4);
+ $nbDocs += $ndg->getNumberOfDocuments(5);
+ }
}
if ($d_arr != NULL) {
@@ -154,6 +179,8 @@ if ($DocGroupName) {
}
$headerPath .= _('Path')._(': ').html_e('i', array(), $dgpath, false);
echo html_e('h2', array(), $headerPath, false);
+ $max = ($nbDocs > ($start + $paging)) ? ($start + $paging) : $nbDocs;
+ echo $HTML->paging_top($start, $paging, $nbDocs, $max, $redirecturl);
echo html_ao('h3', array('class' => 'docman_h3'));
echo html_e('span', array(), _('Document Folder')._(': ').html_e('i',
array(), $DocGroupName, false).' ', false);
/* should we steal the lock on folder ? */
@@ -396,6 +423,8 @@ if ($DocGroupName) {
echo html_ac(html_ap() - 1);
}
}
+
+ echo $HTML->paging_bottom($start, $paging, $nbDocs, $redirecturl);
}
include ($gfcommon.'docman/views/help.php');
diff --git a/src/www/docman/index.php b/src/www/docman/index.php
index 985437f..a972c41 100644
--- a/src/www/docman/index.php
+++ b/src/www/docman/index.php
@@ -97,6 +97,10 @@ switch ($action) {
}
}
+$start = getIntFromRequest('start', 0);
+if ($start < 0)
+ $start = 0;
+
html_use_storage();
html_use_simplemenu();
html_use_jqueryui();
-----------------------------------------------------------------------
Summary of changes:
src/common/docman/DocumentFactory.class.php | 20 ++++++++++++++++++++
src/common/docman/views/listfile.php | 29 +++++++++++++++++++++++++++++
src/www/docman/index.php | 4 ++++
3 files changed, 53 insertions(+)
hooks/post-receive
--
FusionForge
_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits