upload_word.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?php // $Id$
  2. /**
  3. * Action controller for the upload process. The display scripts (web forms) redirect
  4. * the process here to do what needs to be done with each file.
  5. * @package dokeos.upload
  6. * @author Yannick Warnier <ywarnier@beeznest.org>
  7. */
  8. /**
  9. * First, initialise the script
  10. */
  11. // name of the language file which needs to be included
  12. // 'inc.php' is automatically appended to the file name
  13. $language_file[] = "document"; //the document file is loaded because most of the upload vocab relates to the document tool
  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. include("../inc/global.inc.php");
  19. require_once(api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php');
  20. require_once(api_get_path(LIBRARY_PATH) . 'events.lib.inc.php');
  21. require_once(api_get_path(LIBRARY_PATH) . 'document.lib.php');
  22. require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  23. $form_style= '
  24. <style>
  25. .row {
  26. width: 200px;
  27. }
  28. .convert_button{
  29. background: url("../img/scorm.gif") 0px 0px no-repeat;
  30. padding: 2px 0px 2px 22px;
  31. }
  32. #dynamic_div_container{float:left;margin-right:10px;}
  33. #dynamic_div_waiter_container{float:left;}
  34. </style>';
  35. $htmlHeadXtra[] = '<script language="javascript" src="../inc/lib/javascript/upload.js" type="text/javascript"></script>';
  36. $htmlHeadXtra[] = '<script type="text/javascript">
  37. var myUpload = new upload(0);
  38. </script>';
  39. $htmlHeadXtra[] = $form_style;
  40. if(isset($_POST['convert'])){
  41. $cwdir = getcwd();
  42. if(isset($_FILES['user_file']))
  43. {
  44. $allowed_extensions = array('doc','docx','odt','txt','sxw','rtf');
  45. if(in_array(strtolower(pathinfo($_FILES['user_file']['name'],PATHINFO_EXTENSION)),$allowed_extensions))
  46. {
  47. require('../newscorm/lp_upload.php');
  48. if(isset($o_doc) && $first_item_id != 0){
  49. header('Location: ../newscorm/lp_controller.php?'.api_get_cidreq().'&lp_id='.$o_doc->lp_id.'&action=view_item&id='.$first_item_id);
  50. }
  51. else {
  52. if(!empty($o_doc->error))
  53. $errorMessage = $o_doc->error;
  54. else
  55. $errorMessage = get_lang('OogieUnknownError');
  56. }
  57. }
  58. else
  59. {
  60. $errorMessage = get_lang('WoogieBadExtension');
  61. }
  62. }
  63. }
  64. event_access_tool(TOOL_UPLOAD);
  65. // check access permissions (edit permission is needed to add a document or a LP)
  66. $is_allowed_to_edit = api_is_allowed_to_edit();
  67. if(!$is_allowed_to_edit){
  68. api_not_allowed(true);
  69. }
  70. $interbreadcrumb[]= array ("url"=>"../newscorm/lp_controller.php?action=list", "name"=> get_lang("Doc"));
  71. $nameTools = get_lang("WoogieConversionPowerPoint");
  72. Display :: display_header($nameTools);
  73. ?>
  74. <img src="../img/woogie.gif"><br>
  75. <span style="color: #5577af; font-size: 16px; font-family: Arial; margin-left: 10px;"><?php echo get_lang("WelcomeWoogieSubtitle");?></span><br>
  76. <?php
  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->setElementTemplate($user_file_template);
  130. $form -> addElement ('file', 'user_file','<img src="../img/word_big.gif" align="absbottom" />');
  131. /*
  132. * commented because SplitStepsPerChapter is not stable at all
  133. * $form -> addElement ('radio', 'split_steps',null, get_lang('SplitStepsPerPage'),'per_page');
  134. * $form -> addElement ('radio', 'split_steps',null, get_lang('SplitStepsPerChapter'),'per_chapter');
  135. */
  136. $form -> addElement ('hidden', 'split_steps','per_page');
  137. $form -> addElement ('submit', 'convert', get_lang('ConvertToLP'), 'class="convert_button"');
  138. $form -> addElement ('hidden', 'woogie', 'true');
  139. $form -> add_real_progress_bar(md5(rand(0,10000)), 'user_file', 1, true);
  140. $defaults['split_steps'] = 'per_page';
  141. $form -> setDefaults($defaults);
  142. // display the form
  143. $form -> display();
  144. /*
  145. ==============================================================================
  146. FOOTER
  147. ==============================================================================
  148. */
  149. Display::display_footer();
  150. ?>