[svn r15530] Moved default charset and default locale to public object attributes

skala
Yannick Warnier 18 years ago
parent 7e1657c6f8
commit c92b96832e
  1. 4
      main/newscorm/openoffice_document.class.php
  2. 8
      main/newscorm/openoffice_presentation.class.php
  3. 6
      main/newscorm/openoffice_text_document.class.php

@ -15,6 +15,8 @@ abstract class OpenofficeDocument extends learnpath {
public $first_item = 0;
public $original_charset = 'utf-8';
public $original_locale = 'en_US.UTF-8';
/**
* Class constructor. Based on the parent constructor.
@ -82,7 +84,7 @@ abstract class OpenofficeDocument extends learnpath {
chmod ($this->base_work_dir.$this->created_dir,0777);
chmod ($this->base_work_dir.'/'.$this->file_path,0777);
$locale = 'en_US.UTF-8'; // TODO : improve it because we're not sure this locale is present everywhere
$locale = $this->original_locale; // TODO : improve it because we're not sure this locale is present everywhere
putenv('LC_ALL='.$locale);
$shell = exec($cmd, $files, $return);
if($return != 0) { //if the java application returns an error code

@ -42,9 +42,9 @@ class OpenofficePresentation extends OpenofficeDocument {
//filename is utf8 encoded, but when we decode, some chars are not translated (like quote ’).
//so we remove these chars by translating it in htmlentities and the reconvert it in want charset
$slide_name = htmlentities($slide_name,ENT_COMPAT,'utf-8');
$slide_name = htmlentities($slide_name,ENT_COMPAT,$this->original_charset);
$slide_name = str_replace('’','\'',$slide_name);
$slide_name = mb_convert_encoding($slide_name, api_get_setting('platform_charset'), 'utf-8');
$slide_name = mb_convert_encoding($slide_name, api_get_setting('platform_charset'), $this->original_charset);
$slide_name = html_entity_decode($slide_name);
if($this->take_slide_name === true)
@ -112,9 +112,9 @@ class OpenofficePresentation extends OpenofficeDocument {
foreach($files as $file){
list($slide_name,$file_name) = explode('||',$file); // '||' is used as separator between slide name (with accents) and file name (without accents)
$slide_name = htmlentities($slide_name,ENT_COMPAT,'utf-8');
$slide_name = htmlentities($slide_name,ENT_COMPAT,$this->original_charset);
$slide_name = str_replace('’','\'',$slide_name);
$slide_name = mb_convert_encoding($slide_name, api_get_setting('platform_charset'), 'utf-8');
$slide_name = mb_convert_encoding($slide_name, api_get_setting('platform_charset'), $this->original_charset);
$slide_name = html_entity_decode($slide_name);
$did = add_document($_course, $this->created_dir.'/'.urlencode($file_name), 'file', filesize($this->base_work_dir.$this->created_dir.'/'.$file_name), $slide_name);

@ -53,10 +53,10 @@ class OpenOfficeTextDocument extends OpenofficeDocument {
// the file is utf8 encoded and it seems to make problems with special quotes.
// then we htmlentities that, we replace these quotes and html_entity_decode that in good charset
$charset = api_get_setting('platform_charset');
$content = htmlentities($content,ENT_COMPAT,'utf-8');
$content = htmlentities($content,ENT_COMPAT,$this->original_charset);
$content = str_replace('’','\'',$content);
$content = mb_convert_encoding($content, $charset, 'utf-8');
$content = str_replace('utf-8',$charset,$content);
$content = mb_convert_encoding($content, $charset, $this->original_charset);
$content = str_replace($this->original_charset,$charset,$content);
$content = html_entity_decode($content);
// set the path to pictures to absolute (so that it can be modified in fckeditor)

Loading…
Cancel
Save