upload_word.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Action controller for the upload process. The display scripts (web forms)
  5. * 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. include '../inc/global.inc.php';
  11. $form_style= '<style>
  12. .row {
  13. width: 200px;
  14. }
  15. .convert_button{
  16. background: url("../img/icons/22/learnpath.png") 0px 0px no-repeat;
  17. padding: 2px 0px 2px 22px;
  18. }
  19. #dynamic_div_container{float:left;margin-right:10px;}
  20. #dynamic_div_waiter_container{float:left;}
  21. </style>';
  22. $htmlHeadXtra[] = '<script language="javascript" src="../inc/lib/javascript/upload.js" type="text/javascript"></script>';
  23. $htmlHeadXtra[] = '<script type="text/javascript">
  24. var myUpload = new upload(0);
  25. </script>';
  26. $htmlHeadXtra[] = $form_style;
  27. if (api_get_setting('search_enabled')=='true') {
  28. $specific_fields = get_specific_field_list();
  29. }
  30. if (isset($_POST['convert'])) {
  31. $cwdir = getcwd();
  32. if (isset($_FILES['user_file'])) {
  33. $allowed_extensions = array('doc','docx','odt','txt','sxw','rtf');
  34. if (in_array(strtolower(pathinfo($_FILES['user_file']['name'],PATHINFO_EXTENSION)),$allowed_extensions)) {
  35. require('../newscorm/lp_upload.php');
  36. if (isset($o_doc) && $first_item_id != 0) {
  37. // Search-related section
  38. if (api_get_setting('search_enabled')=='true') {
  39. require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
  40. $specific_fields = get_specific_field_list();
  41. foreach ($specific_fields as $specific_field) {
  42. $values = explode(',', trim($_POST[$specific_field['code']]));
  43. if (!empty($values)) {
  44. foreach ($values as $value) {
  45. $value = trim($value);
  46. if (!empty($value)) {
  47. add_specific_field_value($specific_field['id'], api_get_course_id(), TOOL_LEARNPATH, $o_doc->lp_id, $value);
  48. }
  49. }
  50. }
  51. }
  52. } //end of search-related section
  53. header('Location: ../newscorm/lp_controller.php?'.api_get_cidreq().'&lp_id='.$o_doc->lp_id.'&action=view_item&id='.$first_item_id);
  54. } else {
  55. if (!empty($o_doc->error)) {
  56. $errorMessage = $o_doc->error;
  57. } else {
  58. $errorMessage = get_lang('OogieUnknownError');
  59. }
  60. }
  61. } else {
  62. $errorMessage = get_lang('WoogieBadExtension');
  63. }
  64. }
  65. }
  66. Event::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("WoogieConversionPowerPoint");
  74. Display :: display_header($nameTools);
  75. //echo '<img src="../img/mascot.png"><br />';
  76. echo '<span style="color: #5577af; font-size: 16px; font-family: Arial; margin-left: 10px;">'.get_lang("WelcomeWoogieSubtitle").'</span><br>';
  77. $message = get_lang("WelcomeWoogieConverter");
  78. echo '<br />';
  79. $s_style = "border-width: 1px;
  80. border-style: solid;
  81. margin-left: 0;
  82. margin-top: 10px;
  83. margin-bottom: 0px;
  84. min-height: 30px;
  85. padding: 5px;
  86. position: relative;
  87. width: 500px;
  88. background-color: #E5EDF9;
  89. border-color: #4171B5;
  90. color: #000;";
  91. $s_style_error="border-width: 1px;
  92. border-style: solid;
  93. margin-left: 0;
  94. margin-top: 10px;
  95. margin-bottom: 10px;
  96. min-height: 30px;
  97. padding: 5px;
  98. position: relative;
  99. width: 500px;
  100. background-color: #FFD1D1;
  101. border-color: #FF0000;
  102. color: #000;";
  103. echo '<div style="'.$s_style.'"><div style="float:left; margin-right:10px;"><img src="'.api_get_path(WEB_IMG_PATH)."message_normal.gif".'" alt="'.$alt_text.'" '.$attribute_list.' /></div><div style="margin-left: 43px">'.$message.'</div></div>';
  104. if (!empty($errorMessage)) {
  105. echo '<div style="'.$s_style_error.'"><div style="float:left; margin-right:10px;"><img src="'.api_get_path(WEB_IMG_PATH)."message_error.gif".'" alt="'.$alt_text.'" '.$attribute_list.' /></div><div style="margin-left: 43px">'.$errorMessage.'</div></div>';
  106. }
  107. $form = new FormValidator('update_course', 'POST', '', '', 'style="margin: 0;"');
  108. // build the form
  109. $form -> addElement ('html','<br>');
  110. $div_upload_limit = '&nbsp;&nbsp;'.get_lang('UploadMaxSize').' : '.ini_get('post_max_size');
  111. $renderer = $form->defaultRenderer();
  112. // set template for user_file element
  113. $user_file_template =
  114. <<<EOT
  115. <div class="row" style="margin-top:10px;width:100%">
  116. <!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}{element}$div_upload_limit
  117. <!-- BEGIN error --><br /><span class="form_error">{error}</span><!-- END error -->
  118. </div>
  119. EOT;
  120. $renderer->setElementTemplate($user_file_template,'user_file');
  121. // set template for other elements
  122. $user_file_template =
  123. <<<EOT
  124. <div class="row" style="margin-top:10px;width:100%">
  125. <!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}{element}
  126. <!-- BEGIN error --><br /><span class="form_error">{error}</span><!-- END error -->
  127. </div>
  128. EOT;
  129. $renderer->setCustomElementTemplate($user_file_template);
  130. $form -> addElement ('file', 'user_file','<img src="../img/word_big.gif" align="absbottom" />');
  131. if (api_get_setting('search_enabled')=='true') {
  132. $form -> addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument'));
  133. $form -> addElement ('html','<br />');
  134. $form -> addElement ('html', get_lang('SearchFeatureDocumentLanguage').': &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'. api_get_languages_combo());
  135. $form -> addElement ('html','<div class="sub-form">');
  136. foreach ($specific_fields as $specific_field) {
  137. $form -> addElement ('text', $specific_field['code'], $specific_field['name'].' : ');
  138. }
  139. $form -> addElement ('html','</div>');
  140. }
  141. /*
  142. * commented because SplitStepsPerChapter is not stable at all
  143. * $form -> addElement ('radio', 'split_steps',null, get_lang('SplitStepsPerPage'),'per_page');
  144. * $form -> addElement ('radio', 'split_steps',null, get_lang('SplitStepsPerChapter'),'per_chapter');
  145. */
  146. $form -> addElement ('hidden', 'split_steps','per_page');
  147. $form -> addElement ('submit', 'convert', get_lang('ConvertToLP'), 'class="convert_button"');
  148. $form -> addElement ('hidden', 'woogie', 'true');
  149. $form -> add_real_progress_bar(md5(rand(0,10000)), 'user_file', 1, true);
  150. $defaults = array('split_steps'=>'per_page','index_document'=>'checked="checked"');
  151. $form -> setDefaults($defaults);
  152. // display the form
  153. $form -> display();
  154. Display::display_footer();