form.scorm.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Display part of the SCORM sub-process for upload. This script MUST BE included by upload/index.php
  5. * as it prepares most of the variables needed here.
  6. * @package chamilo.upload
  7. * @author Yannick Warnier <ywarnier@beeznest.org>
  8. */
  9. /**
  10. * Small function to list files in archive/
  11. */
  12. function get_zip_files_in_garbage()
  13. {
  14. $list = [];
  15. $dh = opendir(api_get_path(SYS_ARCHIVE_PATH));
  16. if ($dh === false) {
  17. //ignore
  18. } else {
  19. while ($entry = readdir($dh)) {
  20. if (substr($entry, 0, 1) == '.') {
  21. /* ignore files starting with . */
  22. } else {
  23. if (preg_match('/^.*\.zip$/i', $entry)) {
  24. $list[] = $entry;
  25. }
  26. }
  27. }
  28. natcasesort($list);
  29. closedir($dh);
  30. }
  31. return $list;
  32. }
  33. /**
  34. * Just display the form needed to upload a SCORM and give its settings
  35. */
  36. $nameTools = get_lang("FileUpload");
  37. $interbreadcrumb[] = [
  38. "url" => api_get_path(WEB_CODE_PATH)."lp/lp_controller.php?action=list?".api_get_cidreq(),
  39. "name" => get_lang("ToolLearnpath"),
  40. ];
  41. Display::display_header($nameTools, "Path");
  42. require_once '../lp/content_makers.inc.php';
  43. require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
  44. echo '<div class="actions">';
  45. echo '<a href="'.api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'">'.
  46. Display::return_icon('back.png', get_lang('ReturnToLearningPaths'), '', ICON_SIZE_MEDIUM).'</a>';
  47. echo '</div>';
  48. $form = new FormValidator(
  49. '',
  50. 'POST',
  51. api_get_path(WEB_CODE_PATH).'upload/upload.php?'.api_get_cidreq(),
  52. '',
  53. [
  54. 'id' => "upload_form",
  55. 'enctype' => "multipart/form-data"
  56. ]
  57. );
  58. $form->addHeader($nameTools);
  59. $form->addLabel(null, Display::return_icon('scorm_logo.jpg', null, ['style' => 'width:230px;height:100px']));
  60. $form->addElement('hidden', 'curdirpath', $path);
  61. $form->addElement('hidden', 'tool', $my_tool);
  62. $form->addElement('file', 'user_file', get_lang('FileToUpload'));
  63. $form->addProgress();
  64. $form->addRule('user_file', get_lang('ThisFieldIsRequired'), 'required');
  65. unset($content_origins[0]);
  66. unset($content_origins[1]);
  67. if (api_get_setting('search_enabled') == 'true') {
  68. $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
  69. $specific_fields = get_specific_field_list();
  70. foreach ($specific_fields as $specific_field) {
  71. $form->addElement('text', $specific_field['code'], $specific_field['name'].' : ');
  72. }
  73. }
  74. if (api_is_platform_admin()) {
  75. $form->addElement('checkbox', 'use_max_score', null, get_lang('UseMaxScore100'));
  76. }
  77. /* This is a special section that has to be enabled in specific cases
  78. * PLEASE DO NOT REMOVE
  79. $list = get_zip_files_in_garbage();
  80. if (count($list)>0) {
  81. $select_file_name = &$form->addElement(
  82. 'select',
  83. 'file_name',
  84. get_lang('Or').' '.api_strtolower(get_lang('UploadLocalFileFromGarbageDir'))
  85. );
  86. foreach($list as $file){
  87. $select_file_name->addOption($file, $file);
  88. }
  89. $form->addElement('submit', 'submit', get_lang('Download'));
  90. } else {
  91. $text_empty = &$form->addElement(
  92. 'text',
  93. 'empty',
  94. get_lang('Or').' '.api_strtolower(get_lang('UploadLocalFileFromGarbageDir'))
  95. );
  96. $defaults["empty"] = get_lang('Empty');
  97. $text_empty->freeze();
  98. }*/
  99. $form->addButtonUpload(get_lang('Upload'));
  100. /*
  101. TODO: check the pens plugin is enabled before using it
  102. if (is_dir(api_get_path(PLUGIN_PATH)."/pens")) {
  103. require_once api_get_path(PLUGIN_PATH)."/pens/chamilo_pens.php";
  104. $list = ChamiloPens::findAll();
  105. if (count($list) > 0) {
  106. $select_pens = $form->addElement('select', 'pens_package', get_lang('Or').' '.get_lang('select a PENS package'));
  107. foreach ($list as $package) {
  108. $select_pens->addOption($package->getPackageName(), $package->getPackageName());
  109. }
  110. }
  111. }
  112. */
  113. // the default values for the form
  114. $defaults = ['index_document' => 'checked="checked"', 'use_max_score' => 1];
  115. $form->setDefaults($defaults);
  116. echo Display::return_message(
  117. Display::tag('strong', get_lang('SupportedScormContentMakers')).': '.implode(', ', $content_origins),
  118. 'normal',
  119. false
  120. );
  121. $form->display();
  122. Display::display_footer();