upload_ppt.php 4.2 KB

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