Skip to content

Commit

Permalink
MDL-23991 not a nice hack for sending file as string content to zip p…
Browse files Browse the repository at this point in the history
…acker
  • Loading branch information
skodak committed Aug 29, 2010
1 parent 8512eeb commit 59333bc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/filestorage/zip_packer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class zip_packer extends file_packer {

/**
* Zip files and store the result in file storage
* @param array $files array with full zip paths (including directory information) as keys (archivepath=>ospathname or archivepath/subdir=>stored_file)
* @param array $files array with full zip paths (including directory information)
* as keys (archivepath=>ospathname or archivepath/subdir=>stored_file or archivepath=>array('content_as_string'))
* @param int $contextid
* @param string $component
* @param string $filearea
Expand Down Expand Up @@ -84,7 +85,7 @@ public function archive_to_storage($files, $contextid, $component, $filearea, $i

/**
* Zip files and store the result in os file
* @param array $files array with zip paths as keys (archivepath=>ospathname or archivepath=>stored_file)
* @param array $files array with zip paths as keys (archivepath=>ospathname or archivepath=>stored_file or archivepath=>array('content_as_string'))
* @param string $archivefile path to target zip file
* @return bool success
*/
Expand All @@ -110,6 +111,10 @@ public function archive_to_pathname($files, $archivefile) {
} else if (is_string($file)) {
$this->archive_pathname($ziparch, $archivepath, $file);

} else if (is_array($file)) {
$content = reset($file);
$ziparch->add_file_from_string($archivepath, $content);

} else {
$this->archive_stored($ziparch, $archivepath, $file);
}
Expand Down

0 comments on commit 59333bc

Please sign in to comment.