form.scorm.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. *
  7. * @package chamilo.upload
  8. *
  9. * @author Yannick Warnier <ywarnier@beeznest.org>
  10. */
  11. /**
  12. * Small function to list files in archive/.
  13. */
  14. function get_zip_files_in_garbage()
  15. {
  16. $list = [];
  17. $dh = opendir(api_get_path(SYS_ARCHIVE_PATH));
  18. if ($dh === false) {
  19. //ignore
  20. } else {
  21. while ($entry = readdir($dh)) {
  22. if (substr($entry, 0, 1) == '.') {
  23. /* ignore files starting with . */
  24. } else {
  25. if (preg_match('/^.*\.zip$/i', $entry)) {
  26. $list[] = $entry;
  27. }
  28. }
  29. }
  30. natcasesort($list);
  31. closedir($dh);
  32. }
  33. return $list;
  34. }
  35. /**
  36. * Just display the form needed to upload a SCORM and give its settings.
  37. */
  38. $nameTools = get_lang('File upload');
  39. $interbreadcrumb[] = [
  40. 'url' => api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?action=list&'.api_get_cidreq(),
  41. 'name' => get_lang('Learning path'),
  42. ];
  43. Display::display_header($nameTools, 'Path');
  44. require_once '../lp/content_makers.inc.php';
  45. require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
  46. echo '<div class="actions">';
  47. echo '<a href="'.api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'">'.
  48. Display::return_icon('back.png', get_lang('Back to learning paths'), '', ICON_SIZE_MEDIUM).'</a>';
  49. echo '</div>';
  50. $form = new FormValidator(
  51. '',
  52. 'POST',
  53. api_get_path(WEB_CODE_PATH).'upload/upload.php?'.api_get_cidreq(),
  54. '',
  55. [
  56. 'id' => 'upload_form',
  57. 'enctype' => 'multipart/form-data',
  58. ]
  59. );
  60. $form->addHeader($nameTools);
  61. $form->addLabel(null, Display::return_icon('scorm_logo.jpg', null, ['style' => 'width:230px;height:100px']));
  62. $form->addElement('hidden', 'curdirpath', $path);
  63. $form->addElement('hidden', 'tool', $my_tool);
  64. $form->addElement('file', 'user_file', get_lang('SCORM or AICC file to upload'));
  65. $form->addProgress();
  66. $form->addRule('user_file', get_lang('Required field'), 'required');
  67. unset($content_origins[0]);
  68. unset($content_origins[1]);
  69. if (api_get_setting('search_enabled') == 'true') {
  70. $form->addElement('checkbox', 'index_document', '', get_lang('Index document text?'));
  71. $specific_fields = get_specific_field_list();
  72. foreach ($specific_fields as $specific_field) {
  73. $form->addElement('text', $specific_field['code'], $specific_field['name'].' : ');
  74. }
  75. }
  76. if (api_is_platform_admin()) {
  77. $form->addElement('checkbox', 'use_max_score', null, get_lang('Use default maximum score of 100'));
  78. }
  79. if (api_get_configuration_value('allow_htaccess_import_from_scorm')) {
  80. $form->addElement('checkbox', 'allow_htaccess', null, get_lang('Allow htaccess in the SCORM import'));
  81. }
  82. $form->addButtonUpload(get_lang('Upload'));
  83. // the default values for the form
  84. $defaults = ['index_document' => 'checked="checked"', 'use_max_score' => 1];
  85. $form->setDefaults($defaults);
  86. echo Display::return_message(
  87. Display::tag('strong', get_lang('SCORM Authoring tools supported')).': '.implode(', ', $content_origins),
  88. 'normal',
  89. false
  90. );
  91. $form->display();
  92. Display::display_footer();