upload_ppt.php 4.4 KB

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