form.scorm.php 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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) == '.') {/* ignore files starting with . */
  20. } else {
  21. if (preg_match('/^.*\.zip$/i', $entry)) {
  22. $list[] = $entry;
  23. }
  24. }
  25. }
  26. natcasesort($list);
  27. closedir($dh);
  28. }
  29. return $list;
  30. }
  31. /**
  32. * Just display the form needed to upload a SCORM and give its settings
  33. */
  34. $nameTools = get_lang("FileUpload");
  35. $interbreadcrumb[] = array("url" => "../newscorm/lp_controller.php?action=list", "name" => get_lang("ToolLearnpath"));
  36. Display::display_header($nameTools, "Path");
  37. require_once '../newscorm/content_makers.inc.php';
  38. require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
  39. echo '<div class="actions">';
  40. echo '<a href="../newscorm/lp_controller.php?cidReq='.$_course['sysCode'].'">'.Display::return_icon('back.png', get_lang('ReturnToLearningPaths'), '', ICON_SIZE_MEDIUM).'</a>';
  41. echo '</div>';
  42. $form = new FormValidator('', 'POST', 'upload.php', '', 'id="upload_form" enctype="multipart/form-data" style="background-image: url(\'../img/scorm.jpg\'); background-repeat: no-repeat; background-position: 620px;"');
  43. $form->addElement('header', '', $nameTools);
  44. $form->addElement('hidden', 'curdirpath', $path);
  45. $form->addElement('hidden', 'tool', $my_tool);
  46. $form->addElement('file', 'user_file', get_lang('FileToUpload'));
  47. $form->add_real_progress_bar('uploadScorm', 'user_file');
  48. $form->addRule('user_file', get_lang('ThisFieldIsRequired'), 'required');
  49. unset($content_origins[0]);
  50. unset($content_origins[1]);
  51. if (api_get_setting('search_enabled') == 'true') {
  52. $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
  53. $specific_fields = get_specific_field_list();
  54. foreach ($specific_fields as $specific_field) {
  55. $form->addElement('text', $specific_field['code'], $specific_field['name'].' : ');
  56. }
  57. }
  58. if (api_is_platform_admin()) {
  59. $form->addElement('checkbox', 'use_max_score', null, get_lang('UseMaxScore100'));
  60. }
  61. $form->addElement('style_submit_button', 'submit', get_lang('Send'), 'class="upload"');
  62. $form->addElement('html', '<br /><br /><br />');
  63. if (is_dir(api_get_path(PLUGIN_PATH)."/pens")) {
  64. require_once(api_get_path(PLUGIN_PATH)."/pens/chamilo_pens.php");
  65. $list = ChamiloPens::findAll();
  66. if (count($list) > 0) {
  67. $select_pens = $form->addElement('select', 'pens_package', get_lang('Or').' '.get_lang('select a PENS package'));
  68. foreach ($list as $package) {
  69. $select_pens->addOption($package->getPackageName(), $package->getPackageName());
  70. }
  71. }
  72. }
  73. // the default values for the form
  74. $defaults = array('index_document' => 'checked="checked"', 'use_max_score' => 1);
  75. $form->setDefaults($defaults);
  76. Display::display_normal_message(Display::tag('strong', get_lang('SupportedScormContentMakers')).': '.implode(', ', $content_origins), false);
  77. $form->display();
  78. // footer
  79. Display::display_footer();