mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-29 10:09:10 +01:00
check if we can use the XSL extension, to not give a fatal error and rendering whole merge-print non-functional AND only keep tags, if XSL is available
This commit is contained in:
parent
9066385fa5
commit
132cafc8a9
@ -389,9 +389,6 @@ abstract class bo_merge
|
|||||||
}
|
}
|
||||||
// Tags we can replace with the target document's version
|
// Tags we can replace with the target document's version
|
||||||
$replace_tags = array();
|
$replace_tags = array();
|
||||||
// check if we can use the XSL extension, to not give a fatal error and rendering whole merge-print non-functional
|
|
||||||
if (class_exists(XSLTProcessor) && class_exists(DOMDocument))
|
|
||||||
{
|
|
||||||
switch($mimetype.$mso_application_progid)
|
switch($mimetype.$mso_application_progid)
|
||||||
{
|
{
|
||||||
case 'application/vnd.oasis.opendocument.text': // open office
|
case 'application/vnd.oasis.opendocument.text': // open office
|
||||||
@ -408,6 +405,8 @@ abstract class bo_merge
|
|||||||
$xslt = new XSLTProcessor();
|
$xslt = new XSLTProcessor();
|
||||||
$doc->load(EGW_INCLUDE_ROOT.'/etemplate/templates/default/openoffice.xslt');
|
$doc->load(EGW_INCLUDE_ROOT.'/etemplate/templates/default/openoffice.xslt');
|
||||||
$xslt->importStyleSheet($doc);
|
$xslt->importStyleSheet($doc);
|
||||||
|
|
||||||
|
//echo $content;die();
|
||||||
break;
|
break;
|
||||||
case 'application/xmlWord.Document': // Word 2003*/
|
case 'application/xmlWord.Document': // Word 2003*/
|
||||||
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': // ms office 2007
|
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': // ms office 2007
|
||||||
@ -429,6 +428,7 @@ abstract class bo_merge
|
|||||||
'/<span>(.*?)<\/span>/' => '$1'
|
'/<span>(.*?)<\/span>/' => '$1'
|
||||||
);
|
);
|
||||||
$content = preg_replace(array_keys($replace_tags),array_values($replace_tags),$content);
|
$content = preg_replace(array_keys($replace_tags),array_values($replace_tags),$content);
|
||||||
|
//echo $content;die();
|
||||||
$doc = new DOMDocument();
|
$doc = new DOMDocument();
|
||||||
$xslt = new XSLTProcessor();
|
$xslt = new XSLTProcessor();
|
||||||
$xslt_file = $mimetype == 'application/xml' ? 'wordml.xslt' : 'msoffice.xslt';
|
$xslt_file = $mimetype == 'application/xml' ? 'wordml.xslt' : 'msoffice.xslt';
|
||||||
@ -436,7 +436,6 @@ abstract class bo_merge
|
|||||||
$xslt->importStyleSheet($doc);
|
$xslt->importStyleSheet($doc);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// XSLT transform known tags
|
// XSLT transform known tags
|
||||||
if($xslt)
|
if($xslt)
|
||||||
@ -445,6 +444,8 @@ abstract class bo_merge
|
|||||||
{
|
{
|
||||||
$element = new SimpleXMLelement($content);
|
$element = new SimpleXMLelement($content);
|
||||||
$content = @$xslt->transformToXml($element);
|
$content = @$xslt->transformToXml($element);
|
||||||
|
|
||||||
|
//echo $content;die();
|
||||||
// Word 2003 needs two declarations, add extra declaration back in
|
// Word 2003 needs two declarations, add extra declaration back in
|
||||||
if($mimetype == 'application/xml' && $mso_application_progid == 'Word.Document' && strpos($content, '<?xml') !== 0) {
|
if($mimetype == 'application/xml' && $mso_application_progid == 'Word.Document' && strpos($content, '<?xml') !== 0) {
|
||||||
$content = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'.$content;
|
$content = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'.$content;
|
||||||
@ -698,6 +699,9 @@ abstract class bo_merge
|
|||||||
|
|
||||||
// Tags we can replace with the target document's version
|
// Tags we can replace with the target document's version
|
||||||
$replace_tags = array();
|
$replace_tags = array();
|
||||||
|
// only keep tags, if we have xsl extension available
|
||||||
|
if (class_exists(XSLTProcessor) && class_exists(DOMDocument))
|
||||||
|
{
|
||||||
switch($mimetype.$mso_application_progid)
|
switch($mimetype.$mso_application_progid)
|
||||||
{
|
{
|
||||||
case 'application/vnd.oasis.opendocument.text': // open office
|
case 'application/vnd.oasis.opendocument.text': // open office
|
||||||
@ -716,6 +720,7 @@ abstract class bo_merge
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// clean replacements from array values and html or html-entities, which mess up xml
|
// clean replacements from array values and html or html-entities, which mess up xml
|
||||||
foreach($replacements as $name => &$value)
|
foreach($replacements as $name => &$value)
|
||||||
{
|
{
|
||||||
@ -1040,8 +1045,11 @@ abstract class bo_merge
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply HTML formatting to target document, if possible
|
// Apply HTML formatting to target document, if possible
|
||||||
|
// check if we can use the XSL extension, to not give a fatal error and rendering whole merge-print non-functional
|
||||||
|
if (class_exists(XSLTProcessor) && class_exists(DOMDocument))
|
||||||
|
{
|
||||||
$this->apply_styles($merged, $mimetype);
|
$this->apply_styles($merged, $mimetype);
|
||||||
|
}
|
||||||
if(!empty($name))
|
if(!empty($name))
|
||||||
{
|
{
|
||||||
if(empty($ext))
|
if(empty($ext))
|
||||||
|
Loading…
Reference in New Issue
Block a user