upload_ppt.php 4.6 KB

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