From 8314355f30911e9e3def30911d05c30491962828 Mon Sep 17 00:00:00 2001 From: Eric Marguin Date: Wed, 26 Dec 2007 11:16:05 +0100 Subject: [PATCH] [svn r14071] picture can't be larger than max_width (defined in admin). --- .../openoffice_text_document.class.php | 74 ++++++++++--------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/main/newscorm/openoffice_text_document.class.php b/main/newscorm/openoffice_text_document.class.php index f99c05eaf0..ee6dbb5878 100644 --- a/main/newscorm/openoffice_text_document.class.php +++ b/main/newscorm/openoffice_text_document.class.php @@ -70,25 +70,27 @@ class OpenOfficeTextDocument extends OpenofficeDocument { function format_page_content($header, $content, $path_to_folder) { - // Tidy - $tidy = new tidy; - $config = array( - 'indent' => true, - 'output-xhtml' => true, - 'wrap' => 200, - 'clean' => true, - 'bare' => true); - $tidy->parseString($header.$content, $config, 'utf8'); - $tidy->cleanRepair(); - $content = $tidy; // limit the width of the doc - $max_width = '720px'; - $content = preg_replace("|]*>|","\\0\r\n
",$content); - $content = str_replace('','
',$content); + list($max_width, $max_height) = explode('x',api_get_setting('service_ppt2lp','size')); + + $content = preg_replace("|]*>|i","\\0\r\n
",$content, -1,$count); + if($count < 1) + { + $content = '
'.$content; + } + + $content = preg_replace('||i','
\\0',$content, -1, $count); + if($count < 1) + { + $content = $content.'
'; + } + + // add the headers + $content = $header.$content; // line break before and after picture - $content = str_replace('p {','p {clear:both;',strtolower($content)); + $content = str_replace('p {','p {clear:both;',$content); // dokeos styles $my_style = api_get_setting('stylesheets'); @@ -100,33 +102,35 @@ class OpenOfficeTextDocument extends OpenofficeDocument { $content = str_replace('absolute','relative',$content); - /* + // resize all the picture to the max_width-10 - preg_match_all("|]*>|i",$content,$images); - foreach ($images[1] as $image) + foreach ($images[1] as $key => $image) { - list($img_width, $img_height, $type) = getimagesize($path_to_folder.'/'.$image); - - $new_width = $max_width-10; - if($img_width > $new_width) + // check if the $new_width) + { + $picture_resized = str_ireplace(' $max_width-10) + { + $picture_resized = str_ireplace('width='.$img_width,'width="'.($max_width-10).'"',$images[0][$key]); + $content = str_replace($images[0][$key],$picture_resized,$content); } } - */ + return $content;