api_get_path(WEB_CODE_PATH).'gradebook/index.php?'.api_get_cidreq(), 'name' => get_lang('ToolGradebook') ); } $learnPath = learnpath::getCurrentLpFromSession(); $interbreadcrumb[] = array( 'url' => 'lp_controller.php?action=list?'.api_get_cidreq(), 'name' => get_lang('LearningPaths'), ); $interbreadcrumb[] = array( 'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(), 'name' => $learnPath->get_name(), ); switch ($type) { case 'chapter': $interbreadcrumb[] = array( 'url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$learnPath->get_id(), 'name' => get_lang('NewStep'), ); $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('NewChapter')); break; case 'document': $interbreadcrumb[] = array( 'url' => 'lp_controller.php?action=add_item&type=step&lp_id='.$learnPath->get_id(), 'name' => get_lang('NewStep'), ); break; default: $interbreadcrumb[]= array('url' => '#', 'name' => get_lang('NewStep')); break; } if ($action == 'add_item' && $type == 'document') { $interbreadcrumb[]= array ('url' => '#', 'name' => get_lang('NewDocumentCreated')); } // Theme calls. $show_learn_path = true; $lp_item_id = isset($_GET['id']) ? intval($_GET['id']) : null; if (empty($lp_item_id)) { api_not_allowed(); } $courseInfo = api_get_course_info(); $lp_item = new learnpathItem($lp_item_id); $form = new FormValidator( 'add_audio', 'post', api_get_self() . '?action=add_audio&id=' . $lp_item_id . '&' . api_get_cidreq().'&lp_id='.$learnpath_id, null, array('enctype' => 'multipart/form-data') ); $suredel = trim(get_lang('AreYouSureToDeleteJS')); $lpPathInfo = $learnPath->generate_lp_folder(api_get_course_info()); $file = null; if (isset($lp_item->audio) && !empty($lp_item->audio)) { $file = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document/audio/'.$lp_item->audio; $urlFile = api_get_path(WEB_COURSE_PATH).$courseInfo['path'].'/document/audio/'.$lp_item->audio.'?'.api_get_cidreq(); if (!file_exists($file)) { $file = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document'.$lpPathInfo['dir'].$lp_item->audio; $urlFile = api_get_path(WEB_COURSE_PATH).$courseInfo['path'].'/document'.$lpPathInfo['dir'].$lp_item->audio.'?'.api_get_cidreq(); } } $page = $learnPath->build_action_menu(true); $page .= '
'; $page .= '
'; $page .= $learnPath->return_new_tree(null, true); // Show the template list. $page .= '
'; $recordVoiceForm = Display::page_subheader(get_lang('RecordYourVoice')); $page .= '
'; $tpl = \Chamilo\CoreBundle\Framework\Container::getTwig(); $tpl->addGlobal('unique_file_id', api_get_unique_id()); $tpl->addGlobal('course_code', api_get_course_id()); $tpl->addGlobal('php_session_id', session_id()); $tpl->addGlobal('filename', $lp_item->get_title().'_nano.wav'); $tpl->addGlobal( 'enable_nanogong', api_get_setting('document.enable_nanogong') == 'true' ? 1 : 0 ); $tpl->addGlobal( 'enable_wami', api_get_setting('document.enable_wami_record') == 'true' ? 1 : 0 ); $tpl->addGlobal('cur_dir_path', '/audio'); $tpl->addGlobal('lp_item_id', $lp_item_id); $tpl->addGlobal('lp_dir', api_remove_trailing_slash($lpPathInfo['dir'])); $recordVoiceForm .= $tpl->render( '@template_style/learnpath/record_voice.html.twig' ); $form->addElement('header', get_lang('Or')); $form->addElement('header', get_lang('AudioFile')); $form->addElement('html', sprintf(get_lang('AudioFileForItemX'), $lp_item->get_title())); if (!empty($file)) { $audioPlayer = '
'. Display::getMediaPlayer($file, array('url' => $urlFile)). "
"; $form->addElement('label', get_lang('Listen'), $audioPlayer); $url = api_get_path( WEB_CODE_PATH ).'newscorm/lp_controller.php?lp_id='.$learnPath->get_id( ).'&action=add_audio&id='.$lp_item_id.'&delete_file=1&'.api_get_cidreq( ); $form->addElement('label', null, Display::url(get_lang('RemoveAudio'), $url, array('class' => 'btn btn-danger'))); } else { $form->addElement('file', 'file'); $form->addElement('hidden', 'id', $lp_item_id); $form->addButtonSave(get_lang('Save')); } $form->addElement('header', get_lang('Or')); $courseInfo = api_get_course_info(); $documentTree = DocumentManager::get_document_preview( $courseInfo, false, null, api_get_session_id(), false, '', urlencode( 'lp_controller.php?action=add_audio&lp_id='.$learnPath->get_id( ).'&id='.$lp_item_id ), false, true //$folderId = false ); $page .= $recordVoiceForm; $page .= $form->returnForm(); $page .= ''.get_lang('SelectAnAudioFileFromDocuments').''; $page .= $documentTree; $page .= '
'; $page .= '
'; echo $page;