lp_add_audio.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This is a learning path creation and player tool in Chamilo - previously
  5. * @author Julio Montoya - Improving the list of templates
  6. * @package chamilo.learnpath
  7. */
  8. /**
  9. * INIT SECTION
  10. */
  11. $this_section = SECTION_COURSES;
  12. api_protect_course_script();
  13. include 'learnpath_functions.inc.php';
  14. include 'resourcelinker.inc.php';
  15. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  16. $isStudentView = (int) $_REQUEST['isStudentView'];
  17. $learnpath_id = (int) $_REQUEST['lp_id'];
  18. $submit = $_POST['submit_button'];
  19. $type = isset($_GET['type']) ? $_GET['type'] : null;
  20. $action = isset($_GET['action']) ? $_GET['action'] : null;
  21. // Using the resource linker as a tool for adding resources to the learning path.
  22. if ($action == 'add' && $type == 'learnpathitem') {
  23. $htmlHeadXtra[] = "<script language='JavaScript' type='text/javascript'> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
  24. }
  25. if ((!$is_allowed_to_edit) || ($isStudentView)) {
  26. error_log('New LP - User not authorized in lp_add_item.php');
  27. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  28. exit;
  29. }
  30. /* SHOWING THE ADMIN TOOLS */
  31. if (isset($_SESSION['gradebook'])) {
  32. $gradebook = $_SESSION['gradebook'];
  33. }
  34. if (!empty($gradebook) && $gradebook == 'view') {
  35. $interbreadcrumb[] = array (
  36. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  37. 'name' => get_lang('ToolGradebook')
  38. );
  39. }
  40. $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
  41. $interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => $_SESSION['oLP']->get_name());
  42. switch ($type) {
  43. case 'chapter':
  44. $interbreadcrumb[]= array ('url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$_SESSION['oLP']->get_id(), 'name' => get_lang('NewStep'));
  45. $interbreadcrumb[]= array ('url' => '#', 'name' => get_lang('NewChapter'));
  46. break;
  47. case 'document':
  48. $interbreadcrumb[]= array ('url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$_SESSION['oLP']->get_id(), 'name' => get_lang('NewStep'));
  49. break;
  50. default:
  51. $interbreadcrumb[]= array ('url' => '#', 'name' => get_lang('NewStep'));
  52. break;
  53. }
  54. if ($action == 'add_item' && $type == 'document' ) {
  55. $interbreadcrumb[]= array ('url' => '#', 'name' => get_lang('NewDocumentCreated'));
  56. }
  57. // Theme calls.
  58. $show_learn_path = true;
  59. $lp_item_id = isset($_GET['id']) ? intval($_GET['id']) : null;
  60. if (empty($lp_item_id)) {
  61. api_not_allowed();
  62. }
  63. Display::display_header(null, 'Path');
  64. $suredel = trim(get_lang('AreYouSureToDelete'));
  65. /* DISPLAY SECTION */
  66. echo $_SESSION['oLP']->build_action_menu();
  67. echo '<div class="row-fluid" style="overflow:hidden">';
  68. echo '<div id="lp_sidebar" class="span4">';
  69. echo $_SESSION['oLP']->return_new_tree(null, true);
  70. // Show the template list.
  71. echo '</div>';
  72. echo '<div id="doc_form" class="span8">';
  73. $lp_item = new learnpathItem($lp_item_id);
  74. $form = new FormValidator('add_audio', 'post', api_get_self().'?action=add_audio&id='.$lp_item_id, null, array('enctype' => 'multipart/form-data'));
  75. $form->addElement('header', get_lang('UplUpload'));
  76. $form->addElement('html', $lp_item->get_title());
  77. $form->addElement('file', 'file', get_lang('AudioFile'), 'style="width: 250px"');
  78. $form->addElement('hidden', 'id', $lp_item_id);
  79. if (isset($lp_item->audio) && !empty($lp_item->audio)) {
  80. $form->addElement('checkbox', 'delete_file', null, get_lang('RemoveAudio'));
  81. $player = '<script type="text/javascript" src="../inc/lib/mediaplayer/swfobject.js"></script>';
  82. $player .= '<div id="preview"></div><script type="text/javascript">
  83. var s1 = new SWFObject("../inc/lib/mediaplayer/player.swf","ply","250","20","9","#FFFFFF");
  84. s1.addParam("allowscriptaccess","always");
  85. s1.addParam("flashvars","file=../../courses/' . $_course['path'] . '/document/audio/' . $lp_item->audio . '");
  86. s1.write("preview");
  87. </script>';
  88. $form->addElement('label', get_lang('Preview'), $player);
  89. }
  90. $form->addElement('button', 'submit', get_lang('Edit'));
  91. $course_info = api_get_course_info();
  92. $document_tree = DocumentManager::get_document_preview($course_info, null, null, 0, false, '/audio', 'lp_controller.php?action=add_audio&id='.$lp_item_id);
  93. $form->display();
  94. echo '<legend>'.get_lang('SelectAnAudioFileFromDocuments').'</legend>';
  95. echo $document_tree;
  96. echo '</div>';
  97. echo '</div>';
  98. /* FOOTER */
  99. Display::display_footer();