form.scorm.php 4.3 KB

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