if (is_array($uploadedFileName)) { if (get_conf('cldoc_notifyAllFilesWhenUncompressingArchives', false)) { foreach ($uploadedFileName as $uploadedFile) { $eventNotifier->notifyCourseEvent('document_file_added', claro_get_current_course_id(), claro_get_current_tool_id(), $cwd . '/' . $uploadedFile['stored_filename'], claro_get_current_group_id(), '0'); } } else { $eventNotifier->notifyCourseEvent('document_file_modified', claro_get_current_course_id(), claro_get_current_tool_id(), array('old_uri' => $cwd, 'new_uri' => $cwd), claro_get_current_group_id(), '0'); } } else { $eventNotifier->notifyCourseEvent('document_file_added', claro_get_current_course_id(), claro_get_current_tool_id(), $cwd . '/' . $uploadedFileName, claro_get_current_group_id(), '0'); } /*-------------------------------------------------------------------- IN CASE OF HTML FILE, LOOKS FOR IMAGE NEEDING TO BE UPLOADED TOO --------------------------------------------------------------------*/ if (preg_match('/.htm$/i', $_FILES['userFile']['name']) || preg_match('/.html$/i', $_FILES['userFile']['name'])) { $imgFilePath = search_img_from_html($baseWorkDir . $cwd . '/' . $uploadedFileName); /* * Generate Form for image upload */ if (sizeof($imgFilePath) > 0) { $dialogBox->warning(get_lang("Missing images detected")); $form = '<form method="post" action="' . claro_htmlspecialchars($_SERVER['PHP_SELF']) . '" ' . 'enctype="multipart/form-data">' . "\n" . claro_form_relay_context() . '<input type="hidden" name="claroFormId" value="' . uniqid('') . '" />' . '<input type="hidden" name="cmd" value="submitImage" />' . "\n" . '<input type="hidden" name="relatedFile" ' . ' value="' . $cwd . '/' . $uploadedFileName . '" />' . "\n" . '<table border="0">' . "\n"; foreach ($imgFilePath as $thisImgKey => $thisImgFilePath) { $form .= '<tr>' . "\n" . '<td>' . "\n" . '<label for="' . $thisImgKey . '">' . basename($thisImgFilePath) . ' : </label>' . "\n" . '</td>' . "\n" . '<td>' . '<input type="file" id="' . $thisImgKey . '" name="imgFile[]" />' . "\n" . '<input type="hidden" name="imgFilePath[]" value="' . $thisImgFilePath . '" />' . '</td>' . "\n" . '</tr>' . "\n"; } $form .= '<tr>' . "\n" . '<td> </td>' . "\n" . '<td>' . "\n" . '<input type="submit" name="submitImage" value="' . get_lang("Ok") . '" /> ' . "\n" . claro_html_button(claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=exChDir&file=' . base64_encode($cwd))), get_lang("Cancel")) . '</td>' . "\n" . '</tr>' . "\n\n" . '</table>' . "\n" . '</form>' . "\n"; $dialogBox->form($form); } // end if ($imgFileNb > 0) } // end if (strrchr($fileName) == "htm"
/** * Checks the extension of a file, if it's .htm or .html * we use search_img_from_html to get all image paths in the file * * @param string $file * @return array paths * @see check_for_missing_files() uses search_img_from_html() */ function check_for_missing_files($file) { if (strrchr($file, '.') == '.htm' || strrchr($file, '.') == '.html') { $img_file_path = search_img_from_html($file); return $img_file_path; } return false; }