upload_ppt.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. /**
  10. * First, initialise the script
  11. */
  12. //the document file is loaded because most of the upload vocab relates to the document tool
  13. $language_file[] = "document";
  14. $language_file[] = "learnpath";
  15. $language_file[] = "scormdocument";
  16. // global settings initialisation
  17. //require_once '../inc/global.inc.php';
  18. $htmlHeadXtra[] = '<script>
  19. var myUpload = new upload(0);
  20. </script>';
  21. if (isset($_POST['convert'])) {
  22. $cwdir = getcwd();
  23. if (isset($_FILES['user_file'])) {
  24. $allowed_extensions = array('odp', 'sxi', 'ppt', 'pps', 'sxd', 'pptx');
  25. if (in_array(strtolower(pathinfo($_FILES['user_file']['name'], PATHINFO_EXTENSION)), $allowed_extensions)) {
  26. require_once api_get_path(SYS_CODE_PATH).'newscorm/lp_upload.php';
  27. if (isset($o_ppt) && $first_item_id != 0) {
  28. if (api_get_setting('search_enabled') == 'true') {
  29. require_once(api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php');
  30. $specific_fields = get_specific_field_list();
  31. foreach ($specific_fields as $specific_field) {
  32. $values = explode(',', trim($_POST[$specific_field['code']]));
  33. if (!empty($values)) {
  34. foreach ($values as $value) {
  35. $value = trim($value);
  36. if (!empty($value)) {
  37. add_specific_field_value(
  38. $specific_field['id'],
  39. api_get_course_id(),
  40. TOOL_LEARNPATH,
  41. $o_ppt->lp_id,
  42. $value
  43. );
  44. }
  45. }
  46. }
  47. }
  48. }
  49. header(
  50. 'Location: ../newscorm/lp_controller.php?'.api_get_cidreq(
  51. ).'&lp_id='.$o_ppt->lp_id.'&action=view_item&id='.$first_item_id
  52. );
  53. } else {
  54. if (!empty($o_ppt->error)) {
  55. $errorMessage = $o_ppt->error;
  56. } else {
  57. $errorMessage = get_lang('OogieUnknownError');
  58. }
  59. }
  60. } else {
  61. $errorMessage = get_lang('OogieBadExtension');
  62. }
  63. }
  64. }
  65. Event::event_access_tool(TOOL_UPLOAD);
  66. // check access permissions (edit permission is needed to add a document or a LP)
  67. $is_allowed_to_edit = api_is_allowed_to_edit();
  68. if (!$is_allowed_to_edit) {
  69. api_not_allowed(true);
  70. }
  71. $interbreadcrumb[] = array("url" => "../newscorm/lp_controller.php?action=list", "name" => get_lang("Doc"));
  72. $nameTools = get_lang("OogieConversionPowerPoint");
  73. Display :: display_header($nameTools);
  74. $message = get_lang("WelcomeOogieConverter");
  75. if (!empty($errorMessage)) {
  76. echo Display::return_message($errorMessage, 'warning', false);
  77. }
  78. $form = new FormValidator('upload_ppt', 'POST', '', '');
  79. $form->addElement('header', get_lang("WelcomeOogieSubtitle"));
  80. $form->addElement('html', Display::return_message($message, 'info', false));
  81. // build the form
  82. $div_upload_limit = get_lang('UploadMaxSize').' : '.ini_get('post_max_size');
  83. $form->addElement('file', 'user_file', array(Display::return_icon('powerpoint_big.gif'), $div_upload_limit));
  84. $form->addElement('checkbox', 'take_slide_name', '', get_lang('TakeSlideName'));
  85. if (api_get_setting('search_enabled') == 'true') {
  86. require_once(api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php');
  87. $specific_fields = get_specific_field_list();
  88. $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
  89. $form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage'));
  90. foreach ($specific_fields as $specific_field) {
  91. $form->addElement('text', $specific_field['code'], $specific_field['name'].' : ');
  92. }
  93. }
  94. $form->addElement('style_submit_button', 'convert', get_lang('ConvertToLP'));
  95. $form->addElement('hidden', 'ppt2lp', 'true');
  96. $form->add_real_progress_bar(md5(rand(0, 10000)), 'user_file', 1, true);
  97. $defaults = array('take_slide_name' => 'checked="checked"', 'index_document' => 'checked="checked"');
  98. $form->setDefaults($defaults);
  99. // display the form
  100. $form->display();
  101. Display::display_footer();