Update document scripts to fix convertion issues and PHP warnings - refs BT#8274

1.9.x
Daniel Barreto 10 years ago
parent 8bd0a23b33
commit dfe4908539
  1. 2
      main/document/document.inc.php
  2. 17
      main/document/document.php
  3. 9
      main/inc/lib/document.lib.php
  4. 4
      main/lang/english/document.inc.php
  5. 6
      main/lang/spanish/document.inc.php
  6. 6
      main/newscorm/openoffice_document.class.php

@ -630,7 +630,7 @@ function build_edit_icons($document_data, $id, $is_template, $is_read_only = 0,
} else {
if ($usePpt2lp && $formatType) {
$modify_icons .= '&nbsp;<a class="convertAction" href="#" data-documentId = ' . $document_id . ' data-formatType = ' . $formatType . '>' .
Display::return_icon('convert.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
Display::return_icon('convert.png', get_lang('Convert'), array(), ICON_SIZE_SMALL) . '</a>';
}
}
}

@ -49,9 +49,11 @@ api_protect_course_script(true);
DocumentManager::removeGeneratedAudioTempFile();
if (isset($_SESSION['temp_realpath_image'])
&& !empty($_SESSION['temp_realpath_image'])
&& is_file($_SESSION['temp_realpath_image'])) {
if(
isset($_SESSION['temp_realpath_image']) &&
!empty($_SESSION['temp_realpath_image']) &&
file_exists($_SESSION['temp_realpath_image'])
) {
unlink($_SESSION['temp_realpath_image']);
}
$courseInfo = api_get_course_info();
@ -424,9 +426,11 @@ switch ($action) {
);
$file = $sys_course_path.$courseInfo['directory'].'/document'.$document_info['path'];
$fileInfo = pathinfo($file);
if (!(in_array($fileInfo['extension'], DocumentManager::get_jodconverter_extension_list('from', $formatType))) ||
if ($fileInfo['extension'] == $formatTarget) {
$message = Display::return_message(get_lang('ErrorSameFormat'), 'warning');
} elseif (!(in_array($fileInfo['extension'], DocumentManager::get_jodconverter_extension_list('from', $formatType))) ||
!(in_array($formatTarget, DocumentManager::get_jodconverter_extension_list('to', $formatType)))) {
$message = Display::return_message(get_lang('FormatNotSupported'), 'error');
$message = Display::return_message(get_lang('FormatNotSupported'), 'warning');
} else {
$convertedFile = $fileInfo['dirname'] . DIRECTORY_SEPARATOR . $fileInfo['filename'] .
'_from_' . $fileInfo['extension'] . '.' . $formatTarget;
@ -436,7 +440,7 @@ switch ($action) {
$message = Display::return_message(get_lang('FileExists'), 'error');
} else {
$result = $obj->convertCopyDocument($file, $convertedFile, $convertedTitle);
if ((empty($result))) {
if (empty($result)) {
$message = Display::return_message(get_lang('CopyFailed'), 'error');
} else {
$cidReq = Security::remove_XSS($_GET['cidReq']);
@ -452,7 +456,6 @@ switch ($action) {
}
}
}
Session::write('message', $message);
break;
}

@ -4042,7 +4042,14 @@ class DocumentManager
if (api_get_setting('show_chat_folder') == 'false') {
$foldersToAvoid[] = '/chat_files';
}
return in_array($path, $foldersToAvoid);
if (is_array($foldersToAvoid)) {
return in_array($path, $foldersToAvoid);
} else {
return false;
}
}
/**

@ -278,3 +278,7 @@ $ConvertedFromX = "Converted from %s";
$PleaseSelectConvertFormat = "Please, Select a format for conversion";
$ConvertFormats = "Formats for conversion";
$SelectConvertFormat = "Select target format";
$ConvertedFromXToY = "Converted from %s to %s";
$Convert = "Convert";
$FormatNotSupported = "Conversion format is not supported";
$ErrorSameFormat = "Target format and origin format for conversion do not match same format type";

@ -277,4 +277,8 @@ $SelectAnAudioFileFromDocuments = "Seleccionar un archivo de audio desde los doc
$ConvertedFromX = "Convertido desde %s";
$PleaseSelectConvertFormat = "Por favor, Seleccione un formato de conversión";
$ConvertFormats = "Formatos de conversión";
$SelectConvertFormat = "Seleccione el formato de conversión";
$SelectConvertFormat = "Seleccione el formato de conversión";
$ConvertedFromXToY = "Convertido desde %s a %s";
$Convert = "Convertir";
$FormatNotSupported = "Formatos de conversión no soportados";
$ErrorSameFormat = "El formato de destino es el mismo del formato de origen";

@ -309,7 +309,11 @@ abstract class OpenofficeDocument extends learnpath
'file',
filesize($this->base_work_dir . '/' . $this->created_dir),
$convertedTitle,
sprintf(get_lang('ConvertedFromX', strtoupper($originalPathInfo['extension']))),
sprintf(
get_lang('ConvertedFromXToY'),
strtoupper($originalPathInfo['extension']),
strtoupper($convertedPathInfo['extension'])
),
0,
true,
null,

Loading…
Cancel
Save