Fix php warning + add "ext-fileinfo" needed in order to use mime_content_type()

pull/2858/head
Julio Montoya 7 years ago
parent d5b14556a2
commit 1ca163b39f
  1. 1
      composer.json
  2. 13
      main/work/work.lib.php

@ -44,6 +44,7 @@
"ext-mbstring": "*",
"ext-libxml": "*",
"ext-dom": "*",
"ext-fileinfo": "*",
"twig/twig": "1.*",
"twig/extensions": "~1.0",
"doctrine/orm": "~2.4",

@ -137,9 +137,11 @@ function get_work_data_by_id($id, $courseId = 0, $sessionId = 0)
$work['show_url'] = $webCodePath.'work/show_file.php?id='.$work['id'].'&'.api_get_cidreq();
$work['show_content'] = '';
if ($work['contains_file']) {
$fileType = mime_content_type(
api_get_path(SYS_COURSE_PATH).$course->getDirectory().'/'.$work['url']
);
$fileType = '';
$file = api_get_path(SYS_COURSE_PATH).$course->getDirectory().'/'.$work['url'];
if (file_exists($file)) {
$fileType = mime_content_type($file);
}
if (in_array($fileType, ['image/jpeg', 'image/jpg', 'image/png', 'image/gif'])) {
$work['show_content'] = Display::img($work['show_url'], $work['title']);
@ -153,10 +155,7 @@ function get_work_data_by_id($id, $courseId = 0, $sessionId = 0)
}
$fieldValue = new ExtraFieldValue('work');
$work['extra'] = $fieldValue->getAllValuesForAnItem(
$id,
true
);
$work['extra'] = $fieldValue->getAllValuesForAnItem($id, true);
}
return $work;

Loading…
Cancel
Save