form.scorm.php 4.2 KB

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