diff options
author | Andrew Manning <tamanning@zoho.com> | 2016-10-22 08:52:26 -0400 |
---|---|---|
committer | Andrew Manning <tamanning@zoho.com> | 2016-10-22 08:52:26 -0400 |
commit | 02cf7274d28d093094067114d208537cf135266b (patch) | |
tree | 22c4af9569da369d9e7a674a7b7721a67b4b1f87 /Zotlabs/Module | |
parent | 6bf92979a2afe6769e572846e344ffaf3b0c7d85 (diff) | |
download | volse-hubzilla-02cf7274d28d093094067114d208537cf135266b.tar.gz volse-hubzilla-02cf7274d28d093094067114d208537cf135266b.tar.bz2 volse-hubzilla-02cf7274d28d093094067114d208537cf135266b.zip |
Add wiki download button to export the selected wiki repo to a zip file
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r-- | Zotlabs/Module/Wiki.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index bb4e9179c..8cf106b33 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -90,6 +90,35 @@ class Wiki extends \Zotlabs\Web\Controller { // Not the channel owner $channel_acl = $x = array(); } + + // Download a wiki + if ((argc() > 3) && (argv(2) === 'download') && (argv(3) === 'wiki')) { + $resource_id = argv(4); + $w = wiki_get_wiki($resource_id); + if (!$w['path']) { + notice('Error retrieving wiki' . EOL); + } + $zip_folder_name = random_string(10); + $zip_folderpath = '/tmp/' . $zip_folder_name; + if (!mkdir($zip_folderpath, 0770, false)) { + logger('Error creating zip file export folder: ' . $zip_folderpath, LOGGER_NORMAL); + notice('Error creating zip file export folder' . EOL); + } + $zip_filename = $w['urlName']; + $zip_filepath = '/tmp/' . $zip_folder_name . '/' . $zip_filename; + // Generate the zip file + \Zotlabs\Lib\ExtendedZip::zipTree($w['path'], $zip_filepath, \ZipArchive::CREATE); + // Output the file for download + header('Content-disposition: attachment; filename="' . $zip_filename . '.zip"'); + header("Content-Type: application/zip"); + $success = readfile($zip_filepath); + if ($success) { + rrmdir($zip_folderpath); // delete temporary files + } else { + rrmdir($zip_folderpath); // delete temporary files + logger('Error downloading wiki: ' . $resource_id); + } + } switch (argc()) { case 2: @@ -297,6 +326,7 @@ class Wiki extends \Zotlabs\Web\Controller { } } + // Create a page if ((argc() === 4) && (argv(2) === 'create') && (argv(3) === 'page')) { $nick = argv(1); |