[Fusionforge-commits] r12017 - in trunk/src: common/docman/views www/docman www/docman/scripts
Franck VILLAUME
nerville at libremir.placard.fr.eu.org
Mon Jan 17 18:50:29 CET 2011
Author: nerville
Date: 2011-01-17 18:50:22 +0100 (Mon, 17 Jan 2011)
New Revision: 12017
Modified:
trunk/src/common/docman/views/listfile.php
trunk/src/www/docman/scripts/DocManController.js
trunk/src/www/docman/view.php
Log:
enable selectall checkbox + download selected files
Modified: trunk/src/common/docman/views/listfile.php
===================================================================
--- trunk/src/common/docman/views/listfile.php 2011-01-17 16:40:51 UTC (rev 12016)
+++ trunk/src/common/docman/views/listfile.php 2011-01-17 17:50:22 UTC (rev 12017)
@@ -86,7 +86,7 @@
}
if (forge_check_perm('docman', $group_id, 'read')) {
- echo '<a href="/docman/view.php/'.$group_id.'/zip/'.$dirid.'" id="docman-downloadaszip" title="'. _('Download this directory as a zip') . '" >' . html_image('docman/download-directory-zip.png',22,22,array('alt'=>'downloadaszip')). '</a>';
+ echo '<a href="/docman/view.php/'.$group_id.'/zip/full/'.$dirid.'" id="docman-downloadaszip" title="'. _('Download this directory as a zip') . '" >' . html_image('docman/download-directory-zip.png',22,22,array('alt'=>'downloadaszip')). '</a>';
}
echo '</h3>';
@@ -101,7 +101,7 @@
echo '</div>';
if (isset($nested_docs[$dirid]) && is_array($nested_docs[$dirid])) {
- $tabletop = array('','', _('Filename'), _('Title'), _('Description'), _('Author'), _('Last time'), _('Status'), _('Size'));
+ $tabletop = array('<input id="checkall" type="checkbox" onchange="controllerListFile.checkAll()" />','', _('Filename'), _('Title'), _('Description'), _('Author'), _('Last time'), _('Status'), _('Size'));
$classth = array('unsortable','unsortable', '', '', '', '', '', '', '');
if (forge_check_perm('docman', $group_id, 'approve'))
$tabletop[] = _('Actions');
@@ -113,12 +113,12 @@
echo '<tr>';
echo '<td>';
if (!$d->getLocked() && !$d->getReserved()) {
- echo '<input type="checkbox" value="'.$d->getID().'" id="checkeddocid" />';
+ echo '<input type="checkbox" value="'.$d->getID().'" id="checkeddocid" class="checkeddocid" onchange="controllerListFile.checkgeneral()" />';
} else {
if ($d->getReservedBy() != $LUSER->getID()) {
echo '<input type="checkbox" name="disabled" disabled="disabled"';
} else {
- echo '<input type="checkbox" value="'.$d->getID().'" id="checkeddocid" />';
+ echo '<input type="checkbox" value="'.$d->getID().'" id="checkeddocid" class="checkeddocid" onchange="controllerListFile.checkgeneral()" />';
}
}
echo '</td>';
@@ -167,10 +167,10 @@
$size = $d->getFileSize();
if ($size > 1024 ) {
$metric = 'KB';
- $size = floor ($size/1024);
+ $size = floor($size/1024);
if ($size > 1024 ) {
$metric = 'MB';
- $size = floor ($size/1024);
+ $size = floor($size/1024);
}
}
echo $size . $metric;
@@ -226,7 +226,7 @@
echo '<a href="#" onClick="window.location.href=\'?group_id='.$group_id.'&action=releasefile&view=listfile&dirid='.$dirid.'&fileid=\'+controllerListFile.buildUrlByCheckbox()" class="docman-releasereservation" title="'. _('Release reservation') .'" >'.html_image('docman/release-document.png',22,22,array('alt'=>_('Release reservation'))). '</a>';
echo '<a href="#" onClick="window.location.href=\'?group_id='.$group_id.'&action=monitorfile&option=add&view=listfile&dirid='.$dirid.'&fileid=\'+controllerListFile.buildUrlByCheckbox()" class="docman-monitorfile" title="'. _('Start monitoring') .'" >'.html_image('docman/monitor-adddocument.png',22,22,array('alt'=>_('Start monitoring'))). '</a>';
echo '<a href="#" onClick="window.location.href=\'?group_id='.$group_id.'&action=monitorfile&option=remove&view=listfile&dirid='.$dirid.'&fileid=\'+controllerListFile.buildUrlByCheckbox()" class="docman-monitorfile" title="'. _('Stop monitoring') .'" >'.html_image('docman/monitor-removedocument.png',22,22,array('alt'=>_('Stop monitoring'))). '</a>';
- echo '<a href="#" id="docman-downloadaszip" title="'. _('Download as a zip') . '" >' . html_image('docman/download-directory-zip.png',22,22,array('alt'=>'downloadaszip')). '</a>';
+ echo '<a href="#" onClick="window.location.href=\'/docman/view.php/'.$group_id.'/zip/selected/\'+controllerListFile.buildUrlByCheckbox()" id="docman-downloadaszip" title="'. _('Download as a zip') . '" >' . html_image('docman/download-directory-zip.png',22,22,array('alt'=>'downloadaszip')). '</a>';
echo '</p></div>';
include ($gfcommon.'docman/views/editfile.php');
}
Modified: trunk/src/www/docman/scripts/DocManController.js
===================================================================
--- trunk/src/www/docman/scripts/DocManController.js 2011-01-17 16:40:51 UTC (rev 12016)
+++ trunk/src/www/docman/scripts/DocManController.js 2011-01-17 17:50:22 UTC (rev 12017)
@@ -139,18 +139,40 @@
clearInterval(this.lockInterval[id]);
}
},
-
+
/*! build list of id, comma separated
*/
buildUrlByCheckbox: function()
{
var CheckedBoxes = new Array();
for (var h = 0; h < jQuery("input:checked").length; h++) {
- CheckedBoxes.push(jQuery("input:checked")[h].value);
+ if (jQuery("input:checked")[h].id == 'checkeddocid' ) {
+ CheckedBoxes.push(jQuery("input:checked")[h].value);
+ }
}
return CheckedBoxes;
},
+ checkAll: function()
+ {
+ if (jQuery('#checkall').is(':checked')) {
+ jQuery('.checkeddocid').each(function() {
+ jQuery(this).attr('checked',true);
+ });
+ } else {
+ jQuery('.checkeddocid').each(function() {
+ jQuery(this).attr('checked',false);
+ });
+ }
+ },
+
+ checkgeneral: function()
+ {
+ if (jQuery(this).attr('checked',false)) {
+ jQuery('#checkall').attr('checked',false);
+ }
+ },
+
computeDocumentsData: function() {
/*
TODO:
Modified: trunk/src/www/docman/view.php
===================================================================
--- trunk/src/www/docman/view.php 2011-01-17 16:40:51 UTC (rev 12016)
+++ trunk/src/www/docman/view.php 2011-01-17 17:50:22 UTC (rev 12017)
@@ -34,9 +34,9 @@
require_once $gfcommon.'docman/DocumentGroupFactory.class.php';
require_once $gfcommon.'docman/include/utils.php';
-$arr=explode('/', getStringFromServer('REQUEST_URI'));
-$group_id=$arr[3];
-$docid=$arr[4];
+$arr = explode('/', getStringFromServer('REQUEST_URI'));
+$group_id = $arr[3];
+$docid = $arr[4];
$g = group_get_object($group_id);
if (!$g || !is_object($g)) {
@@ -49,7 +49,7 @@
session_require_perm('docman', $group_id, 'read');
$docname = urldecode($arr[5]);
- $d = new Document($g,$docid);
+ $d = new Document($g, $docid);
if (!$d || !is_object($d)) {
exit_error(_('Document is not available.'), 'docman');
} elseif ($d->isError()) {
@@ -100,7 +100,7 @@
exit_error(_('Unable to open zip archive for backup'),'docman');
}
- if ( !docman_fill_zip($zip,$nested_groups,$df))
+ if ( !docman_fill_zip($zip, $nested_groups, $df))
exit_error(_('Unable to fill zip archive for backup'), 'docman');
if ( !$zip->close())
@@ -135,41 +135,73 @@
}
} elseif ($docid === 'zip') {
session_require_perm('docman', $group_id, 'read');
- $dirid = $arr[5];
+ if ( $arr[5] === 'full' ) {
+ $dirid = $arr[6];
- $dg = new DocumentGroup($g,$dirid);
- if ($dg->isError())
- exit_error($dg->getErrorMessage(), 'docman');
+ $dg = new DocumentGroup($g, $dirid);
+ if ($dg->isError())
+ exit_error($dg->getErrorMessage(), 'docman');
- $df = new DocumentFactory($g);
- if ($df->isError())
- exit_error($df->getErrorMessage(), 'docman');
+ $df = new DocumentFactory($g);
+ if ($df->isError())
+ exit_error($df->getErrorMessage(), 'docman');
- $dgf = new DocumentGroupFactory($g);
- if ($dgf->isError())
- exit_error($dgf->getErrorMessage(), 'docman');
+ $dgf = new DocumentGroupFactory($g);
+ if ($dgf->isError())
+ exit_error($dgf->getErrorMessage(), 'docman');
- $nested_groups = $dgf->getNested();
+ $nested_groups = $dgf->getNested();
- if ($dg->hasDocuments($nested_groups,$df)) {
- $filename = 'docman-'.$g->getUnixName().'-'.$dg->getID().'.zip';
+ if ($dg->hasDocuments($nested_groups, $df)) {
+ $filename = 'docman-'.$g->getUnixName().'-'.$dg->getID().'.zip';
+ $file = forge_get_config('data_path').'/'.$filename;
+ $zip = new ZipArchive;
+ if ( !$zip->open($file, ZIPARCHIVE::OVERWRITE))
+ exit_error(_('Unable to open zip archive for download as zip'),'docman');
+
+ // ugly workaround to get the files at doc_group_id level
+ $df->setDocGroupID($dg->getID());
+ $docs = $df->getDocuments(1); // no caching
+ if (is_array($docs) && count($docs) > 0) { // this group has documents
+ foreach ($docs as $doc) {
+ if ( !$zip->addFromString($doc->getFileName(),$doc->getFileData()))
+ return false;
+ }
+ }
+ if ( !docman_fill_zip($zip, $nested_groups, $df, $dg->getID()))
+ exit_error(_('Unable to fill zip archive for download as zip'), 'docman');
+
+ if ( !$zip->close())
+ exit_error(_('Unable to close zip archive for download as zip'), 'docman');
+
+ header('Content-disposition: filename="'.$filename.'"');
+ header('Content-type: application/binary');
+
+ readfile($file);
+ unlink($file);
+ } else {
+ $warning_msg = _('This directory is empty.');
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($warning_msg));
+ }
+ } elseif ( $arr[5] === 'selected' ) {
+ $arr_fileid = explode(',',$arr[6]);
+ $filename = 'docman-'.$g->getUnixName().'-selected-'.time().'.zip';
$file = forge_get_config('data_path').'/'.$filename;
$zip = new ZipArchive;
if ( !$zip->open($file, ZIPARCHIVE::OVERWRITE))
exit_error(_('Unable to open zip archive for download as zip'),'docman');
- // ugly workaround to get the files at doc_group_id level
- $df->setDocGroupID($dg->getID());
- $docs = $df->getDocuments(1); // no caching
- if (is_array($docs) && count($docs) > 0) { // this group has documents
- foreach ($docs as $doc) {
- if ( !$zip->addFromString($doc->getFileName(),$doc->getFileData()))
- return false;
+ foreach($arr_fileid as $docid) {
+ $d = new Document($g, $docid);
+ if (!$d || !is_object($d)) {
+ exit_error(_('Document is not available.'), 'docman');
+ } elseif ($d->isError()) {
+ exit_error($d->getErrorMessage(), 'docman');
}
+
+ if ( !$zip->addFromString($d->getFileName(),$d->getFileData()))
+ return false;
}
- if ( !docman_fill_zip($zip,$nested_groups,$df,$dg->getID()))
- exit_error(_('Unable to fill zip archive for download as zip'), 'docman');
-
if ( !$zip->close())
exit_error(_('Unable to close zip archive for download as zip'), 'docman');
@@ -179,8 +211,7 @@
readfile($file);
unlink($file);
} else {
- $warning_msg = _('This directory is empty.');
- session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid.'&warning_msg='.urlencode($warning_msg));
+ exit_error(_('No document to display - invalid or inactive document number.'), 'docman');
}
} else {
exit_error(_('No document to display - invalid or inactive document number.'), 'docman');
More information about the Fusionforge-commits
mailing list