mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 09:05:16 +01:00
"- added existens check for ZipArchive class (RHEL5 contains zip extension without that class!)
- only fix zip files if php version < 5.3.1 (which claims to fix the issue) - fix mimetype of msword xml format truncated to 64 chars"
This commit is contained in:
parent
96c5f58a49
commit
b49d561491
@ -46,6 +46,12 @@ class addressbook_merge // extends bo_merge
|
|||||||
*/
|
*/
|
||||||
static function is_implemented($mimetype,$extension=null)
|
static function is_implemented($mimetype,$extension=null)
|
||||||
{
|
{
|
||||||
|
static $zip_available;
|
||||||
|
if (is_null($zip_available))
|
||||||
|
{
|
||||||
|
$zip_available = check_load_extension('zip') &&
|
||||||
|
class_exists('ZipArchive'); // some PHP has zip extension, but no ZipArchive (eg. RHEL5!)
|
||||||
|
}
|
||||||
switch ($mimetype)
|
switch ($mimetype)
|
||||||
{
|
{
|
||||||
case 'application/msword':
|
case 'application/msword':
|
||||||
@ -54,11 +60,11 @@ class addressbook_merge // extends bo_merge
|
|||||||
case 'text/rtf':
|
case 'text/rtf':
|
||||||
return true; // rtf files
|
return true; // rtf files
|
||||||
case 'application/vnd.oasis.opendocument.text':
|
case 'application/vnd.oasis.opendocument.text':
|
||||||
if (!check_load_extension('zip')) break;
|
if (!$zip_available) break;
|
||||||
return true; // open office write xml files
|
return true; // open office write xml files
|
||||||
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
|
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
|
||||||
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.d': // mimetypes in vfs are limited to 64 chars
|
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.d': // mimetypes in vfs are limited to 64 chars
|
||||||
if (!check_load_extension('zip')) break;
|
if (!$zip_available) break;
|
||||||
return true; // ms word xml format
|
return true; // ms word xml format
|
||||||
default:
|
default:
|
||||||
if (substr($mimetype,0,5) == 'text/')
|
if (substr($mimetype,0,5) == 'text/')
|
||||||
@ -269,8 +275,9 @@ class addressbook_merge // extends bo_merge
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
list($contentstart,$contentrepeat,$contentend) = preg_split('/\$\$pagerepeat\$\$/',$content,-1, PREG_SPLIT_NO_EMPTY); //get differt parts of document, seperatet by Pagerepeat
|
list($contentstart,$contentrepeat,$contentend) = preg_split('/\$\$pagerepeat\$\$/',$content,-1, PREG_SPLIT_NO_EMPTY); //get differt parts of document, seperatet by Pagerepeat
|
||||||
if ($mimetype == 'application/vnd.oasis.opendocument.text' && count($ids) > 1) {
|
if ($mimetype == 'application/vnd.oasis.opendocument.text' && count($ids) > 1)
|
||||||
//for odt files we have to slpitt the content and add a style for page break to the style area
|
{
|
||||||
|
//for odt files we have to slpit the content and add a style for page break to the style area
|
||||||
list($contentstart,$contentrepeat,$contentend) = preg_split('/office:body>/',$content,-1, PREG_SPLIT_NO_EMPTY); //get differt parts of document, seperatet by Pagerepeat
|
list($contentstart,$contentrepeat,$contentend) = preg_split('/office:body>/',$content,-1, PREG_SPLIT_NO_EMPTY); //get differt parts of document, seperatet by Pagerepeat
|
||||||
$contentstart = substr($contentstart,0,strlen($contentstart)-1); //remove "<"
|
$contentstart = substr($contentstart,0,strlen($contentstart)-1); //remove "<"
|
||||||
$contentrepeat = substr($contentrepeat,0,strlen($contentrepeat)-2); //remove "</";
|
$contentrepeat = substr($contentrepeat,0,strlen($contentrepeat)-2); //remove "</";
|
||||||
@ -418,8 +425,9 @@ class addressbook_merge // extends bo_merge
|
|||||||
copy($content_url,$archive);
|
copy($content_url,$archive);
|
||||||
$content_url = 'zip://'.$archive.'#'.($content_file = 'content.xml');
|
$content_url = 'zip://'.$archive.'#'.($content_file = 'content.xml');
|
||||||
break;
|
break;
|
||||||
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
|
|
||||||
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.d': // mimetypes in vfs are limited to 64 chars
|
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.d': // mimetypes in vfs are limited to 64 chars
|
||||||
|
$mime_type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
|
||||||
|
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
|
||||||
$archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($document,'.dotx').'-').'.dotx';
|
$archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($document,'.dotx').'-').'.dotx';
|
||||||
copy($content_url,$archive);
|
copy($content_url,$archive);
|
||||||
$content_url = 'zip://'.$archive.'#'.($content_file = 'word/document.xml');
|
$content_url = 'zip://'.$archive.'#'.($content_file = 'word/document.xml');
|
||||||
@ -437,7 +445,7 @@ class addressbook_merge // extends bo_merge
|
|||||||
if ($zip->close() !== true) throw new Exception("!ZipArchive::close()");
|
if ($zip->close() !== true) throw new Exception("!ZipArchive::close()");
|
||||||
unset($zip);
|
unset($zip);
|
||||||
unset($merged);
|
unset($merged);
|
||||||
if (file_exists('/usr/bin/zip')) // fix broken zip archives generated by current php
|
if (file_exists('/usr/bin/zip') && version_compare(PHP_VERSION,'5.3.1','<')) // fix broken zip archives generated by current php
|
||||||
{
|
{
|
||||||
exec('/usr/bin/zip -F '.escapeshellarg($archive));
|
exec('/usr/bin/zip -F '.escapeshellarg($archive));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user