Skip to content

Commit

Permalink
Minor: Format code + fix HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Mar 6, 2023
1 parent 2a13069 commit f3eb877
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions main/lp/lp_add_audio.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
$isStudentView = api_is_student_view_active();
$learnpath_id = (int) $_REQUEST['lp_id'];
$lp_item_id = isset($_GET['id']) ? (int) $_GET['id'] : null;
$submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : null;
$type = isset($_GET['type']) ? $_GET['type'] : null;
$action = isset($_GET['action']) ? $_GET['action'] : null;
$submit = $_POST['submit_button'] ?? null;
$type = $_GET['type'] ?? null;
$action = $_GET['action'] ?? null;
$courseInfo = api_get_course_info();

if (!$is_allowed_to_edit || $isStudentView) {
Expand Down Expand Up @@ -48,7 +48,7 @@
'name' => $lp->getNameNoTags(),
];

$audioPreview = DocumentManager::generateAudioJavascript([]);
$audioPreview = DocumentManager::generateAudioJavascript();
$htmlHeadXtra[] = "<script>
$(function() {
$audioPreview
Expand Down Expand Up @@ -99,7 +99,7 @@
$audioFolderId = DocumentManager::get_document_id($courseInfo, $currentDir);

if (isset($_REQUEST['folder_id'])) {
$folderIdFromRequest = isset($_REQUEST['folder_id']) ? (int) $_REQUEST['folder_id'] : 0;
$folderIdFromRequest = (int) $_REQUEST['folder_id'];
$documentData = DocumentManager::get_document_data_by_id($folderIdFromRequest, $courseInfo['code']);
if ($documentData) {
$audioFolderId = $folderIdFromRequest;
Expand All @@ -111,6 +111,7 @@
}

$file = null;
$urlFile = '';
if (!empty($lp_item->audio)) {
$file = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document/'.$lp_item->audio;
$urlFile = api_get_path(WEB_COURSE_PATH).$courseInfo['path'].'/document/'.$lp_item->audio.'?'.api_get_cidreq();
Expand All @@ -132,10 +133,14 @@

$recordVoiceForm = '<h3 class="page-header">'.get_lang('RecordYourVoice').'</h3>';
$page .= '<div id="doc_form" class="col-md-8">';

$webLibraryPath = api_get_path(WEB_LIBRARY_PATH);
$webCodePath = api_get_path(WEB_CODE_PATH);

$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'rtc/RecordRTC.js"></script>';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'wami-recorder/recorder.js"></script>';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'wami-recorder/gui.js"></script>';
$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'swfobject/swfobject.js"></script>';
$htmlHeadXtra[] = '<script src="'.$webLibraryPath.'wami-recorder/recorder.js"></script>';
$htmlHeadXtra[] = '<script src="'.$webLibraryPath.'wami-recorder/gui.js"></script>';
$htmlHeadXtra[] = '<script type="text/javascript" src="'.$webLibraryPath.'swfobject/swfobject.js"></script>';

$tpl = new Template(get_lang('Add'));
$tpl->assign('unique_file_id', api_get_unique_id());
Expand All @@ -161,7 +166,14 @@
Display::getMediaPlayer($file, ['url' => $urlFile]).
"</div>";
$form->addElement('label', get_lang('Listen'), $audioPlayer);
$url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?lp_id='.$lp->get_id().'&action=add_audio&id='.$lp_item_id.'&delete_file=1&'.api_get_cidreq();
$url = $webCodePath.'lp/lp_controller.php?&'
.http_build_query([
'lp_id' => $lp->get_id(),
'action' => 'add_audio',
'id' => $lp_item_id,
'delete_file' => 1,
])
.'&'.api_get_cidreq();
$form->addElement(
'label',
null,
Expand All @@ -184,7 +196,7 @@
api_get_session_id(),
false,
'',
api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?action=add_audio&lp_id='.$lp->get_id().'&id='.$lp_item_id,
$webCodePath.'lp/lp_controller.php?action=add_audio&lp_id='.$lp->get_id().'&id='.$lp_item_id,
false,
true,
$audioFolderId,
Expand Down Expand Up @@ -229,7 +241,7 @@
$page .= '<li class="doc_folder" style="margin-left: 36px;">'.get_lang('Audio').'</li>';
$page .= '<li class="doc_folder">';
$page .= '<ul class="lp_resource">'.$documentTree.'</ul>';
$page .= '</div>';
$page .= '</li>';
$page .= '</ul>';
$page .= '</div>';
$page .= '</div>';
Expand Down

0 comments on commit f3eb877

Please sign in to comment.