upload_ppt.php 4.4 KB

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