Skip to content

Commit 87c808c

Browse files
committed
Minor: Format code + fix HTML
1 parent 2a13069 commit 87c808c

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

main/inc/lib/document.lib.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3773,8 +3773,6 @@ public static function write_resources_tree(
37733773
$addAudioPreview
37743774
);
37753775
}
3776-
$return .= '</div>';
3777-
$return .= '</ul>';
37783776
} else {
37793777
if ($resource['filetype'] === 'folder') {
37803778
$return .= self::parseFolder($folderId, $resource, $lp_id);

main/lp/lp_add_audio.php

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
$isStudentView = api_is_student_view_active();
1616
$learnpath_id = (int) $_REQUEST['lp_id'];
1717
$lp_item_id = isset($_GET['id']) ? (int) $_GET['id'] : null;
18-
$submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : null;
19-
$type = isset($_GET['type']) ? $_GET['type'] : null;
20-
$action = isset($_GET['action']) ? $_GET['action'] : null;
18+
$submit = $_POST['submit_button'] ?? null;
19+
$type = $_GET['type'] ?? null;
20+
$action = $_GET['action'] ?? null;
2121
$courseInfo = api_get_course_info();
2222

2323
if (!$is_allowed_to_edit || $isStudentView) {
@@ -48,7 +48,7 @@
4848
'name' => $lp->getNameNoTags(),
4949
];
5050

51-
$audioPreview = DocumentManager::generateAudioJavascript([]);
51+
$audioPreview = DocumentManager::generateAudioJavascript();
5252
$htmlHeadXtra[] = "<script>
5353
$(function() {
5454
$audioPreview
@@ -99,7 +99,7 @@
9999
$audioFolderId = DocumentManager::get_document_id($courseInfo, $currentDir);
100100

101101
if (isset($_REQUEST['folder_id'])) {
102-
$folderIdFromRequest = isset($_REQUEST['folder_id']) ? (int) $_REQUEST['folder_id'] : 0;
102+
$folderIdFromRequest = (int) $_REQUEST['folder_id'];
103103
$documentData = DocumentManager::get_document_data_by_id($folderIdFromRequest, $courseInfo['code']);
104104
if ($documentData) {
105105
$audioFolderId = $folderIdFromRequest;
@@ -111,6 +111,7 @@
111111
}
112112

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

133134
$recordVoiceForm = '<h3 class="page-header">'.get_lang('RecordYourVoice').'</h3>';
134135
$page .= '<div id="doc_form" class="col-md-8">';
136+
137+
$webLibraryPath = api_get_path(WEB_LIBRARY_PATH);
138+
$webCodePath = api_get_path(WEB_CODE_PATH);
139+
135140
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'rtc/RecordRTC.js"></script>';
136-
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'wami-recorder/recorder.js"></script>';
137-
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'wami-recorder/gui.js"></script>';
138-
$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'swfobject/swfobject.js"></script>';
141+
$htmlHeadXtra[] = '<script src="'.$webLibraryPath.'wami-recorder/recorder.js"></script>';
142+
$htmlHeadXtra[] = '<script src="'.$webLibraryPath.'wami-recorder/gui.js"></script>';
143+
$htmlHeadXtra[] = '<script type="text/javascript" src="'.$webLibraryPath.'swfobject/swfobject.js"></script>';
139144

140145
$tpl = new Template(get_lang('Add'));
141146
$tpl->assign('unique_file_id', api_get_unique_id());
@@ -161,7 +166,14 @@
161166
Display::getMediaPlayer($file, ['url' => $urlFile]).
162167
"</div>";
163168
$form->addElement('label', get_lang('Listen'), $audioPlayer);
164-
$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();
169+
$url = $webCodePath.'lp/lp_controller.php?&'
170+
.http_build_query([
171+
'lp_id' => $lp->get_id(),
172+
'action' => 'add_audio',
173+
'id' => $lp_item_id,
174+
'delete_file' => 1,
175+
])
176+
.'&'.api_get_cidreq();
165177
$form->addElement(
166178
'label',
167179
null,
@@ -184,7 +196,7 @@
184196
api_get_session_id(),
185197
false,
186198
'',
187-
api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?action=add_audio&lp_id='.$lp->get_id().'&id='.$lp_item_id,
199+
$webCodePath.'lp/lp_controller.php?action=add_audio&lp_id='.$lp->get_id().'&id='.$lp_item_id,
188200
false,
189201
true,
190202
$audioFolderId,
@@ -229,7 +241,7 @@
229241
$page .= '<li class="doc_folder" style="margin-left: 36px;">'.get_lang('Audio').'</li>';
230242
$page .= '<li class="doc_folder">';
231243
$page .= '<ul class="lp_resource">'.$documentTree.'</ul>';
232-
$page .= '</div>';
244+
$page .= '</li>';
233245
$page .= '</ul>';
234246
$page .= '</div>';
235247
$page .= '</div>';

0 commit comments

Comments
 (0)