form.scorm.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php //$id: $
  2. /**
  3. * Display part of the SCORM sub-process for upload. This script MUST BE included by upload/index.php
  4. * as it prepares most of the variables needed here.
  5. * @package dokeos.upload
  6. * @author Yannick Warnier <ywarnier@beeznest.org>
  7. */
  8. /**
  9. * Small function to list files in garbage/
  10. */
  11. function get_zip_files_in_garbage(){
  12. $list = array();
  13. $dh = opendir(api_get_path(SYS_CODE_PATH).'garbage/');
  14. if($dh === false){
  15. //ignore
  16. }else{
  17. while($entry = readdir($dh)){
  18. if(substr($entry,0,1) == '.'){/*ignore files starting with . */}
  19. else
  20. {
  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("Learnpath"));
  36. Display::display_header($nameTools,"Path");
  37. //show the title
  38. api_display_tool_title(get_lang("Learnpath")." - ".$nameTools.$add_group_to_title);
  39. //TODO: Include right language file
  40. require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  41. include('../newscorm/content_makers.inc.php');
  42. require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
  43. $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: 600px;"');
  44. $form->addElement('hidden', 'curdirpath', $path);
  45. $form->addElement('hidden', 'tool', $my_tool);
  46. $form->addElement('file','user_file',get_lang('FileToUpload'));
  47. $select_content_marker = &$form->addElement('select','content_maker',get_lang('ContentMaker'));
  48. foreach($content_origins as $index => $origin){
  49. $select_content_marker->addOption($origin,$origin);
  50. }
  51. $select_content_proximity = &$form->addElement('select','content_proximity',get_lang('ContentProximity'));
  52. $select_content_proximity->addOption(get_lang('Local'),"local");
  53. $select_content_proximity->addOption(get_lang('Remote'),"remote");
  54. $select_content_proximity -> setSelected("local");
  55. if(api_get_setting('search_enabled')=='true')
  56. {
  57. $form -> addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument'));
  58. $specific_fields = get_specific_field_list();
  59. foreach ($specific_fields as $specific_field) {
  60. $form -> addElement ('text', $specific_field['code'], $specific_field['name'].' : ');
  61. }
  62. }
  63. $form->addElement('style_submit_button','submit', get_lang('Send'),'class="save"');
  64. $form->addElement('html', '<br><br><br>');
  65. /*$list = get_zip_files_in_garbage();
  66. if(count($list)>0){
  67. $select_file_name = &$form->addElement('select','file_name',get_lang('Or').' '.strtolower(get_lang('UploadLocalFileFromGarbageDir')));
  68. foreach($list as $file){
  69. $select_file_name->addOption($file,$file);
  70. }
  71. $form->addElement('submit', 'submit', get_lang('Download'));
  72. }
  73. else{
  74. $text_empty = &$form->addElement('text', 'empty', get_lang('Or').' '.strtolower(get_lang('UploadLocalFileFromGarbageDir')));
  75. $defaults["empty"] = get_lang('Empty');
  76. $text_empty->freeze();
  77. }*/
  78. $form->add_real_progress_bar('uploadScorm','user_file');
  79. $defaults = array('index_document'=>'checked="checked"');
  80. $form->setDefaults($defaults);
  81. $form->display();
  82. ?>
  83. <br/>
  84. <?php
  85. /*
  86. ==============================================================================
  87. FOOTER
  88. ==============================================================================
  89. */
  90. Display::display_footer();
  91. ?>