upload_ppt.php 4.7 KB

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