diff --git a/main/newscorm/openoffice_text_document.class.php b/main/newscorm/openoffice_text_document.class.php index a028fd0c04..c92520a014 100644 --- a/main/newscorm/openoffice_text_document.class.php +++ b/main/newscorm/openoffice_text_document.class.php @@ -19,17 +19,44 @@ class OpenOfficeTextDocument extends OpenofficeDocument { global $_course; - $content = file_get_contents($this->base_work_dir.$this->created_dir.'/'.$this->file_name.'.html'); + // we get a content where ||page_break|| indicates where the page is broken + $content = file_get_contents($this->base_work_dir.$this->created_dir.'/'.$this->file_name.'.html'); + + // set the charset if necessary + $charset = api_get_setting('platform_charset'); + if(strcasecmp($charset,'utf-8')!==0) + { + $content = utf8_decode($content); + $content = str_replace('utf-8',$charset,$content); + } + // set the path to pictures to absolute (so that it can be modified in fckeditor) + $content = preg_replace("|src=\"([^\"]*)|i", "src=\"".api_get_path(REL_COURSE_PATH).$_course['path'].'/document'.$this->created_dir."/\\1", $content); - // we get a content where ||page_break|| indicates where the page is broken - list($header, $body) = explode('\r\n"; + $style_to_import .= '@import "'.api_get_path(WEB_CODE_PATH).'css/'.$my_style.'/default.css";'."\n"; + $style_to_import .= '@import "'.api_get_path(WEB_CODE_PATH).'css/'.$my_style.'/course.css";'."\n"; + $style_to_import .= "\r\n"; + $header = preg_replace("||i", "\r\n$style_to_import\r\n\\0",$header); + + // line break before and after picture + $header = str_replace('p {','p {clear:both;',$header); - $pages = explode('||page_break||',$body); + $header = str_replace('absolute','relative',$header); + $first_item = 0; @@ -86,30 +113,9 @@ class OpenOfficeTextDocument extends OpenofficeDocument { $content = $content.''; } - // set the charset if necessary - $charset = api_get_setting('platform_charset'); - if(!strcasecmp($charset,'utf-8')) - { - $content = utf8_decode($content); - $header = str_replace('utf-8','iso-8859-15',$header); - } - // add the headers $content = $header.$content; - // line break before and after picture - $content = str_replace('p {','p {clear:both;',$content); - - // dokeos styles - $my_style = api_get_setting('stylesheets'); - if(empty($my_style)){$my_style = 'default';} - $style_to_import = '@import "'.api_get_path(WEB_CODE_PATH).'css/'.$my_style.'/default.css";'."\n"; - $style_to_import .= '@import "'.api_get_path(WEB_CODE_PATH).'css/'.$my_style.'/course.css";'."\n"; - - $content = str_replace('/*]*>|i",$content,$images);