Now resource's FileManager is using central zip & unzip functions.

Merged from MOODLE_14_STABLE
This commit is contained in:
stronk7 2004-10-17 19:36:27 +00:00
parent e472709ddd
commit 4f9b2efd50

View file

@ -350,25 +350,16 @@
if (!empty($name)) { if (!empty($name)) {
html_header($course, $wdir); html_header($course, $wdir);
$name = clean_filename($name); $name = clean_filename($name);
if (empty($CFG->zip)) { // Use built-in php-based zip function
$files = array(); $files = array();
foreach ($USER->filelist as $file) { foreach ($USER->filelist as $file) {
$files[] = "$basedir/$file"; $files[] = "$basedir/$file";
} }
include_once($CFG->libdir.'/pclzip/pclzip.lib.php');
$archive = new PclZip("$basedir/$wdir/$name"); if (!zip_files($files,"$basedir/$wdir/$name")) {
if (($list = $archive->create($files,'',"$basedir/$wdir/")) == 0) { error(get_string("zipfileserror","error"));
error($archive->errorInfo(true));
}
} else { // Use external zip program
$files = "";
foreach ($USER->filelist as $file) {
$files .= basename($file);
$files .= " ";
}
$command = "cd $basedir/$wdir ; $CFG->zip -r $name $files";
Exec($command);
} }
clearfilelist(); clearfilelist();
displaydir($wdir); displaydir($wdir);
@ -409,10 +400,6 @@
case "unzip": case "unzip":
html_header($course, $wdir); html_header($course, $wdir);
if (!empty($file)) { if (!empty($file)) {
$strname = get_string("name");
$strsize = get_string("size");
$strmodified = get_string("modified");
$strstatus = get_string("status");
$strok = get_string("ok"); $strok = get_string("ok");
$strunpacking = get_string("unpacking", "", $file); $strunpacking = get_string("unpacking", "", $file);
@ -420,41 +407,8 @@
$file = basename($file); $file = basename($file);
if (empty($CFG->unzip)) { // Use built-in php-based unzip function if (!unzip_file("$basedir/$wdir/$file")) {
include_once($CFG->libdir.'/pclzip/pclzip.lib.php'); error(get_string("unzipfileserror","error"));
$archive = new PclZip("$basedir/$wdir/$file");
if (!$list = $archive->extract("$basedir/$wdir")) {
error($archive->errorInfo(true));
} else { // print some output
echo "<table cellpadding=\"4\" cellspacing=\"2\" border=\"0\" width=\"640\">";
echo "<tr><th align=\"left\">$strname</th>";
echo "<th align=\"right\">$strsize</th>";
echo "<th align=\"right\">$strmodified</th>";
echo "<th align=\"right\">$strstatus</th></tr>";
foreach ($list as $item) {
echo "<tr>";
$item['filename'] = str_replace("$basedir/$wdir/", "", $item['filename']);
print_cell("left", $item['filename']);
if (! $item['folder']) {
print_cell("right", display_size($item['size']));
} else {
echo "<td>&nbsp;</td>";
}
$filedate = userdate($item['mtime'], get_string("strftimedatetime"));
print_cell("right", $filedate);
print_cell("right", $item['status']);
echo "</tr>";
}
echo "</table>";
}
} else { // Use external unzip program
print_simple_box_start("center");
echo "<pre>";
$command = "cd $basedir/$wdir ; $CFG->unzip -o $file 2>&1";
passthru($command);
echo "</pre>";
print_simple_box_end();
} }
echo "<center><form action=\"".$ME."\" method=\"get\">"; echo "<center><form action=\"".$ME."\" method=\"get\">";