doc); try { $ZIPextract = new \splitbrain\PHPArchive\Zip(); $ZIPextract->open(TMP_DIR.'/odt/temp_test_doc.odt'); $ZIPextract->extract(TMP_DIR.'/odt/unpacked'); } catch (\splitbrain\PHPArchive\ArchiveIOException $e) { throw new Exception(' Error extracting the zip archive:'.$template.' to '.$tempDir); } $files ['content-xml'] = file_get_contents(TMP_DIR.'/odt/unpacked/content.xml'); $files ['meta-xml'] = file_get_contents(TMP_DIR.'/odt/unpacked/meta.xml'); $files ['styles-xml'] = file_get_contents(TMP_DIR.'/odt/unpacked/styles.xml'); // Success return true; } /** * This function "uploads" all files from $sourcedir to the destination * namespace $destns. * * @param string $destns Desinatio namespace, e.g. 'wiki' * @param string $souredir Directory which shall be copied * @author LarsDW223 */ public static function rcopyMedia($destns, $sourcedir) { // Buffer all outputs generated from media_save ob_start(); // Read directory manually and call media_save for each file $handle = opendir($sourcedir); $read_res = readdir($handle); while ($read_res !== false) { if ($read_res != '.' && $read_res != '..') { $path = $sourcedir.'/'.$read_res; $ns = $destns; $id = $read_res; list($ext,$mime) = mimetype($path); $res = media_save( array('name' => $path, 'mime' => $mime, 'ext' => $ext), $ns.':'.$id, true, AUTH_UPLOAD, 'copy' ); } $read_res = readdir($handle); } closedir($handle); // Disable buffering and throw all outputs away ob_end_clean(); } }