upload_ppt.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. // name of the language file which needs to be included
  13. // 'inc.php' is automatically appended to the file name
  14. $language_file[] = "document"; //the document file is loaded because most of the upload vocab relates to the document tool
  15. $language_file[] = "learnpath";
  16. $language_file[] = "scormdocument";
  17. // global settings initialisation
  18. // also provides access to main api (inc/lib/main_api.lib.php)
  19. require_once '../inc/global.inc.php';
  20. require_once(api_get_path(LIBRARY_PATH) . 'fileUpload.lib.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/icons/22/learnpath.png") 0px 0px no-repeat;
  30. padding: 2px 0px 2px 22px;
  31. }
  32. .sub-form{
  33. width: 25em;
  34. }
  35. .sub-form input{
  36. float:right;
  37. margin-top:-1.2em;
  38. }
  39. #dynamic_div_container{float:left;margin-right:10px;}
  40. #dynamic_div_waiter_container{float:left;}
  41. </style>';
  42. $htmlHeadXtra[] = '<script language="javascript" src="../inc/lib/javascript/upload.js" type="text/javascript"></script>';
  43. $htmlHeadXtra[] = '<script type="text/javascript">
  44. var myUpload = new upload(0);
  45. </script>';
  46. $htmlHeadXtra[] = $form_style;
  47. if(isset($_POST['convert'])){
  48. $cwdir = getcwd();
  49. if(isset($_FILES['user_file']))
  50. {
  51. $allowed_extensions = array('odp','sxi','ppt','pps','sxd','pptx');
  52. if(in_array(strtolower(pathinfo($_FILES['user_file']['name'],PATHINFO_EXTENSION)),$allowed_extensions))
  53. {
  54. require('../newscorm/lp_upload.php');
  55. if(isset($o_ppt) && $first_item_id != 0){
  56. if (api_get_setting('search_enabled')=='true') {
  57. require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
  58. $specific_fields = get_specific_field_list();
  59. foreach ($specific_fields as $specific_field) {
  60. $values = explode(',', trim($_POST[$specific_field['code']]));
  61. if ( !empty($values) ) {
  62. foreach ($values as $value) {
  63. $value = trim($value);
  64. if ( !empty($value) ) {
  65. add_specific_field_value($specific_field['id'], api_get_course_id(), TOOL_LEARNPATH, $o_ppt->lp_id, $value);
  66. }
  67. }
  68. }
  69. }
  70. }
  71. header('Location: ../newscorm/lp_controller.php?'.api_get_cidreq().'&lp_id='.$o_ppt->lp_id.'&action=view_item&id='.$first_item_id);
  72. }
  73. else {
  74. if(!empty($o_ppt->error))
  75. $errorMessage = $o_ppt->error;
  76. else
  77. $errorMessage = get_lang('OogieUnknownError');
  78. }
  79. }
  80. else
  81. {
  82. $errorMessage = get_lang('OogieBadExtension');
  83. }
  84. }
  85. }
  86. event_access_tool(TOOL_UPLOAD);
  87. // check access permissions (edit permission is needed to add a document or a LP)
  88. $is_allowed_to_edit = api_is_allowed_to_edit();
  89. if(!$is_allowed_to_edit){
  90. api_not_allowed(true);
  91. }
  92. $interbreadcrumb[]= array ("url"=>"../newscorm/lp_controller.php?action=list", "name"=> get_lang("Doc"));
  93. $nameTools = get_lang("OogieConversionPowerPoint");
  94. Display :: display_header($nameTools);
  95. ?>
  96. <img src="../img/mascot.png"><br>
  97. <span style="color: #ff6434; font-size: 16px; font-family: Arial; margin-left: 10px;"><?php echo get_lang("WelcomeOogieSubtitle");?></span><br>
  98. <?php
  99. $message=get_lang("WelcomeOogieConverter");
  100. echo '<br>';
  101. $s_style="border-width: 1px;
  102. border-style: solid;
  103. margin-left: 0;
  104. margin-top: 10px;
  105. margin-bottom: 0px;
  106. min-height: 30px;
  107. padding: 5px;
  108. position: relative;
  109. width: 500px;
  110. background-color: #E5EDF9;
  111. border-color: #4171B5;
  112. color: #000;";
  113. $s_style_error="border-width: 1px;
  114. border-style: solid;
  115. margin-left: 0;
  116. margin-top: 10px;
  117. margin-bottom: 10px;
  118. min-height: 30px;
  119. padding: 5px;
  120. position: relative;
  121. width: 500px;
  122. background-color: #FFD1D1;
  123. border-color: #FF0000;
  124. color: #000;";
  125. //Display::display_normal_message($message);
  126. $alt_text = '';
  127. $attribute_list = '';
  128. 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>';
  129. if(!empty($errorMessage)){
  130. //Display::display_error_message($errorMessage);
  131. 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>';
  132. }
  133. $form = new FormValidator('upload_ppt', 'POST', '', '');
  134. // build the form
  135. $form -> addElement ('html','<br />');
  136. $div_upload_limit = '&nbsp;&nbsp;'.get_lang('UploadMaxSize').' : '.ini_get('post_max_size');
  137. $renderer = & $form->defaultRenderer();
  138. // set template for user_file element
  139. $user_file_template =
  140. <<<EOT
  141. <div class="row" style="margin-top:10px;width:100%">
  142. <!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}{element}$div_upload_limit
  143. <!-- BEGIN error --><br /><span class="form_error">{error}</span><!-- END error -->
  144. </div>
  145. EOT;
  146. $renderer->setElementTemplate($user_file_template,'user_file');
  147. // set template for other elements
  148. $user_file_template =
  149. <<<EOT
  150. <div class="row" style="margin-top:10px;width:100%">
  151. <!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}{element}
  152. <!-- BEGIN error --><br /><span class="form_error">{error}</span><!-- END error -->
  153. </div>
  154. EOT;
  155. $renderer->setElementTemplate($user_file_template);
  156. $form -> addElement ('file', 'user_file','<img src="../img/powerpoint_big.gif" align="absbottom" />&nbsp;&nbsp;');
  157. $form -> addElement ('checkbox', 'take_slide_name','', get_lang('TakeSlideName'));
  158. if (api_get_setting('search_enabled')=='true') {
  159. require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
  160. $specific_fields = get_specific_field_list();
  161. $form -> addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument'));
  162. //$form -> addElement ('text', 'terms', get_lang('SearchFeatureDocumentTagsIfIndexing').': ');
  163. $form -> addElement ('html','<br />');
  164. $form -> addElement ('html', get_lang('SearchFeatureDocumentLanguage').': &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'. api_get_languages_combo());
  165. $form -> addElement ('html','<div class="sub-form">');
  166. foreach ($specific_fields as $specific_field) {
  167. $form -> addElement ('text', $specific_field['code'], $specific_field['name'].' : ');
  168. }
  169. $form -> addElement ('html','</div>');
  170. }
  171. $form -> addElement ('submit', 'convert', get_lang('ConvertToLP'), 'class="convert_button"');
  172. $form -> addElement ('hidden', 'ppt2lp', 'true');
  173. $form -> add_real_progress_bar(md5(rand(0,10000)), 'user_file', 1, true);
  174. $defaults = array('take_slide_name'=>'checked="checked"','index_document'=>'checked="checked"');
  175. $form->setDefaults($defaults);
  176. // display the form
  177. $form -> display();
  178. /*
  179. FOOTER
  180. */
  181. Display::display_footer();
  182. ?>