upload_ppt.php 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Action controller for the upload process. The display scripts (web forms) redirect
  5. * the process here to do what needs to be done with each file.
  6. * @package chamilo.upload
  7. * @author Yannick Warnier <ywarnier@beeznest.org>
  8. */
  9. $htmlHeadXtra[] = '<script type="text/javascript">
  10. var myUpload = new upload(0);
  11. </script>';
  12. if (isset($_POST['convert'])) {
  13. $cwdir = getcwd();
  14. if (isset($_FILES['user_file'])) {
  15. $allowed_extensions = array('odp', 'sxi', 'ppt', 'pps', 'sxd', 'pptx');
  16. if (in_array(strtolower(pathinfo($_FILES['user_file']['name'], PATHINFO_EXTENSION)), $allowed_extensions)) {
  17. require_once api_get_path(SYS_CODE_PATH).'newscorm/lp_upload.php';
  18. if (isset($o_ppt) && $first_item_id != 0) {
  19. if (api_get_setting('search.search_enabled') == 'true') {
  20. require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
  21. $specific_fields = get_specific_field_list();
  22. foreach ($specific_fields as $specific_field) {
  23. $values = explode(',', trim($_POST[$specific_field['code']]));
  24. if (!empty($values)) {
  25. foreach ($values as $value) {
  26. $value = trim($value);
  27. if (!empty($value)) {
  28. add_specific_field_value($specific_field['id'], api_get_course_id(), TOOL_LEARNPATH, $o_ppt->lp_id, $value);
  29. }
  30. }
  31. }
  32. }
  33. }
  34. header('Location: ../newscorm/lp_controller.php?'.api_get_cidreq().'&lp_id='.$o_ppt->lp_id.'&action=view_item&id='.$first_item_id);
  35. exit;
  36. } else {
  37. if (!empty($o_ppt->error)) {
  38. $errorMessage = $o_ppt->error;
  39. } else {
  40. $errorMessage = get_lang('OogieUnknownError');
  41. }
  42. }
  43. } else {
  44. $errorMessage = get_lang('OogieBadExtension');
  45. }
  46. }
  47. }
  48. Event::event_access_tool(TOOL_UPLOAD);
  49. // check access permissions (edit permission is needed to add a document or a LP)
  50. $is_allowed_to_edit = api_is_allowed_to_edit();
  51. if (!$is_allowed_to_edit) {
  52. api_not_allowed(true);
  53. }
  54. $interbreadcrumb[]= array ("url"=>"../newscorm/lp_controller.php?action=list", "name"=> get_lang("Doc"));
  55. $nameTools = get_lang("OogieConversionPowerPoint");
  56. Display :: display_header($nameTools);
  57. $message = get_lang("WelcomeOogieConverter");
  58. if (!empty($errorMessage)) {
  59. echo Display::return_message($errorMessage, 'warning', false);
  60. }
  61. $div_upload_limit = get_lang('UploadMaxSize').' : '.ini_get('post_max_size');
  62. $form = new FormValidator('upload_ppt', 'POST', '', '');
  63. $form->addElement('header', get_lang("WelcomeOogieSubtitle"));
  64. $form->addElement('html', Display::return_message($message, 'info', false));
  65. $form->addElement('file', 'user_file', array(Display::return_icon('powerpoint_big.gif'), $div_upload_limit));
  66. $form->addElement('checkbox', 'take_slide_name', '', get_lang('TakeSlideName'));
  67. if (api_get_setting('search.search_enabled') == 'true') {
  68. require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
  69. $specific_fields = get_specific_field_list();
  70. $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
  71. $form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage'));
  72. foreach ($specific_fields as $specific_field) {
  73. $form->addElement('text', $specific_field['code'], $specific_field['name'].' : ');
  74. }
  75. }
  76. $form->addButtonUpload(get_lang('ConvertToLP'), 'convert');
  77. $form->addElement('hidden', 'ppt2lp', 'true');
  78. $form->add_real_progress_bar(md5(rand(0, 10000)), 'user_file', 1, true);
  79. $defaults = array('take_slide_name'=>'checked="checked"','index_document'=>'checked="checked"');
  80. $form->setDefaults($defaults);
  81. // display the form
  82. $form->display();
  83. Display::display_footer();