Completed
Push — 1.10.x ( 107530...61bd88 )
by Yannick
161:59 queued 121:42
created
main/document/create_audio.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -63,35 +63,35 @@  discard block
 block discarded – undo
63 63
 }
64 64
 
65 65
 if ($dir[0] != '/') {
66
-    $dir = '/' . $dir;
66
+    $dir = '/'.$dir;
67 67
 }
68 68
 
69 69
 if ($dir[strlen($dir) - 1] != '/') {
70 70
     $dir .= '/';
71 71
 }
72 72
 
73
-$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document' . $dir;
73
+$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
74 74
 
75 75
 if (!is_dir($filepath)) {
76
-    $filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document/';
76
+    $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
77 77
     $dir = '/';
78 78
 }
79 79
 
80 80
 //groups //TODO: clean
81 81
 if (!empty($groupId)) {
82 82
     $interbreadcrumb[] = array(
83
-        "url" => "../group/group_space.php?" . api_get_cidreq(),
83
+        "url" => "../group/group_space.php?".api_get_cidreq(),
84 84
         "name" => get_lang('GroupSpace')
85 85
     );
86 86
     $group = GroupManager:: get_group_properties($groupId);
87 87
     $path = explode('/', $dir);
88
-    if ('/' . $path[1] != $group['directory']) {
88
+    if ('/'.$path[1] != $group['directory']) {
89 89
         api_not_allowed(true);
90 90
     }
91 91
 }
92 92
 
93 93
 $interbreadcrumb[] = array(
94
-    "url" => "./document.php?curdirpath=" . urlencode($dir) . "&" . api_get_cidreq(),
94
+    "url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(),
95 95
     "name" => get_lang('Documents')
96 96
 );
97 97
 
@@ -129,23 +129,23 @@  discard block
 block discarded – undo
129 129
 
130 130
 $dir_acum = '';
131 131
 for ($i = 0; $i < $array_len; $i++) {
132
-    $url_dir = 'document.php?&curdirpath=' . $dir_acum . $dir_array[$i];
132
+    $url_dir = 'document.php?&curdirpath='.$dir_acum.$dir_array[$i];
133 133
     //Max char 80
134 134
     $url_to_who = cut($dir_array[$i], 80);
135 135
     $interbreadcrumb[] = array('url' => $url_dir, 'name' => $url_to_who);
136
-    $dir_acum .= $dir_array[$i] . '/';
136
+    $dir_acum .= $dir_array[$i].'/';
137 137
 }
138 138
 
139 139
 Display:: display_header($nameTools, 'Doc');
140 140
 
141 141
 echo '<div class="actions">';
142
-echo '<a href="document.php?id=' . $document_id . '">' .
143
-    Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('DocumentsOverview'), '',
144
-        ICON_SIZE_MEDIUM) . '</a>';
145
-echo '<a href="create_audio.php?' . api_get_cidreq() . '&amp;id=' . $document_id . '&amp;dt2a=google">' .
146
-    Display::return_icon('google.png', get_lang('GoogleAudio'), '', ICON_SIZE_MEDIUM) . '</a>';
147
-echo '<a href="create_audio.php?' . api_get_cidreq() . '&amp;id=' . $document_id . '&amp;dt2a=pediaphon">' .
148
-    Display::return_icon('pediaphon.png', get_lang('Pediaphon'), '', ICON_SIZE_MEDIUM) . '</a>';
142
+echo '<a href="document.php?id='.$document_id.'">'.
143
+    Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '',
144
+        ICON_SIZE_MEDIUM).'</a>';
145
+echo '<a href="create_audio.php?'.api_get_cidreq().'&amp;id='.$document_id.'&amp;dt2a=google">'.
146
+    Display::return_icon('google.png', get_lang('GoogleAudio'), '', ICON_SIZE_MEDIUM).'</a>';
147
+echo '<a href="create_audio.php?'.api_get_cidreq().'&amp;id='.$document_id.'&amp;dt2a=pediaphon">'.
148
+    Display::return_icon('pediaphon.png', get_lang('Pediaphon'), '', ICON_SIZE_MEDIUM).'</a>';
149 149
 echo '</div>';
150 150
 
151 151
 ?>
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
 $selected_language = null;
212 212
 
213 213
 while ($row = Database::fetch_array($result_select)) {
214
-    $options[$row['isocode']] = $row['original_name'] . ' (' . $row['english_name'] . ')';
214
+    $options[$row['isocode']] = $row['original_name'].' ('.$row['english_name'].')';
215 215
     if (in_array($row['isocode'], array('de', 'en', 'es', 'fr'))) {
216
-        $options_pedia[$row['isocode']] = $row['original_name'] . ' (' . $row['english_name'] . ')';
216
+        $options_pedia[$row['isocode']] = $row['original_name'].' ('.$row['english_name'].')';
217 217
     }
218 218
 }
219 219
 
220 220
 if (Security::remove_XSS($_GET['dt2a']) == 'google') {
221
-    $selected_language = api_get_language_isocode();//lang default is the course language
221
+    $selected_language = api_get_language_isocode(); //lang default is the course language
222 222
 
223 223
     $form = new FormValidator('form1', 'post', null, '', array('id' => 'form1'));
224 224
     $form->addHeader(get_lang('HelpText2Audio'));
@@ -272,16 +272,16 @@  discard block
 block discarded – undo
272 272
         var voices = new Array()
273 273
 
274 274
         <!--German -->
275
-        voices['de'] = ["<?php echo get_lang('Female') . ' (de1)'; ?>|de1", "<?php echo get_lang('Male') . ' (de2)'; ?>|de2", "<?php echo get_lang('Female') . ' (de3)'; ?>|de3", "<?php echo get_lang('Male') . ' (de4)'; ?>|de4", "<?php echo get_lang('Female') . ' (de5)'; ?>|de5", "<?php echo get_lang('Male') . ' (de6)'; ?>|de6", "<?php echo get_lang('Female') . ' (de7)'; ?>|de7", "<?php echo get_lang('Female') . ' (de8 HQ)'; ?>|de8"]
275
+        voices['de'] = ["<?php echo get_lang('Female').' (de1)'; ?>|de1", "<?php echo get_lang('Male').' (de2)'; ?>|de2", "<?php echo get_lang('Female').' (de3)'; ?>|de3", "<?php echo get_lang('Male').' (de4)'; ?>|de4", "<?php echo get_lang('Female').' (de5)'; ?>|de5", "<?php echo get_lang('Male').' (de6)'; ?>|de6", "<?php echo get_lang('Female').' (de7)'; ?>|de7", "<?php echo get_lang('Female').' (de8 HQ)'; ?>|de8"]
276 276
 
277 277
         <!--English -->
278
-        voices['en'] = ["<?php echo get_lang('Male') . ' (en1)'; ?>|en1", "<?php echo get_lang('Male') . ' (en2 HQ)'; ?>|en2", "<?php echo get_lang('Female') . ' (us1)'; ?>|us1", "<?php echo get_lang('Male') . ' (us2)'; ?>|us2", "<?php echo get_lang('Male') . ' (us3)'; ?>|us3", "<?php echo get_lang('Female') . '(us4 HQ)'; ?>|us4"]
278
+        voices['en'] = ["<?php echo get_lang('Male').' (en1)'; ?>|en1", "<?php echo get_lang('Male').' (en2 HQ)'; ?>|en2", "<?php echo get_lang('Female').' (us1)'; ?>|us1", "<?php echo get_lang('Male').' (us2)'; ?>|us2", "<?php echo get_lang('Male').' (us3)'; ?>|us3", "<?php echo get_lang('Female').'(us4 HQ)'; ?>|us4"]
279 279
 
280 280
         <!--Spanish -->
281
-        voices['es'] = ["<?php echo get_lang('Male') . ' (es5 HQ)'; ?>|es5"]
281
+        voices['es'] = ["<?php echo get_lang('Male').' (es5 HQ)'; ?>|es5"]
282 282
 
283 283
         <!--French -->
284
-        voices['fr'] = ["<?php echo get_lang('Female') . ' (fr8 HQ)'; ?>|fr8"]
284
+        voices['fr'] = ["<?php echo get_lang('Female').' (fr8 HQ)'; ?>|fr8"]
285 285
 
286 286
         $(document).ready(function () {
287 287
             $('.lang').on('change', function () {
@@ -313,11 +313,11 @@  discard block
 block discarded – undo
313 313
  */
314 314
 function downloadMP3_google($filepath, $dir)
315 315
 {
316
-    $location = 'create_audio.php?' . api_get_cidreq() . '&id=' . intval($_POST['id']) . '&dt2a=google';
316
+    $location = 'create_audio.php?'.api_get_cidreq().'&id='.intval($_POST['id']).'&dt2a=google';
317 317
 
318 318
     //security
319 319
     if (!isset($_POST['lang']) && !isset($_POST['text']) && !isset($_POST['title']) && !isset($filepath) && !isset($dir)) {
320
-        echo '<script>window.location.href="' . $location . '"</script>';
320
+        echo '<script>window.location.href="'.$location.'"</script>';
321 321
         return;
322 322
     }
323 323
 
@@ -327,32 +327,32 @@  discard block
 block discarded – undo
327 327
     $clean_title = trim($_POST['title']);
328 328
     $clean_text = trim($_POST['text']);
329 329
     if (empty($clean_title) || empty($clean_text)) {
330
-        echo '<script>window.location.href="' . $location . '"</script>';
330
+        echo '<script>window.location.href="'.$location.'"</script>';
331 331
         return;
332 332
     }
333 333
     $clean_title = Security::remove_XSS($clean_title);
334 334
     $clean_title = Database::escape_string($clean_title);
335
-    $clean_title = str_replace(' ', '_', $clean_title);//compound file names
335
+    $clean_title = str_replace(' ', '_', $clean_title); //compound file names
336 336
 
337 337
     $clean_text = Security::remove_XSS($clean_text);
338 338
     $clean_lang = Security::remove_XSS($_POST['lang']);
339 339
 
340 340
     $extension = 'mp3';
341
-    $audio_filename = $clean_title . '.' . $extension;
341
+    $audio_filename = $clean_title.'.'.$extension;
342 342
     $audio_title = str_replace('_', ' ', $clean_title);
343 343
 
344 344
     //prevent duplicates
345
-    if (file_exists($filepath . '/' . $clean_title . '.' . $extension)) {
345
+    if (file_exists($filepath.'/'.$clean_title.'.'.$extension)) {
346 346
         $i = 1;
347
-        while (file_exists($filepath . '/' . $clean_title . '_' . $i . '.' . $extension)) {
347
+        while (file_exists($filepath.'/'.$clean_title.'_'.$i.'.'.$extension)) {
348 348
             $i++;
349 349
         }
350
-        $audio_filename = $clean_title . '_' . $i . '.' . $extension;
351
-        $audio_title = $clean_title . '_' . $i . '.' . $extension;
350
+        $audio_filename = $clean_title.'_'.$i.'.'.$extension;
351
+        $audio_title = $clean_title.'_'.$i.'.'.$extension;
352 352
         $audio_title = str_replace('_', ' ', $audio_title);
353 353
     }
354 354
 
355
-    $documentPath = $filepath . '/' . $audio_filename;
355
+    $documentPath = $filepath.'/'.$audio_filename;
356 356
 
357 357
     $clean_text = api_replace_dangerous_char($clean_text);
358 358
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 
362 362
     $proxySettings = api_get_configuration_value('proxy_settings');
363 363
     $key = api_get_configuration_value('translate_app_google_key');
364
-    $url = "https://www.googleapis.com/language/translate/v2?key=$key&" . $clean_lang . "&target=$clean_lang&q=" . urlencode($clean_text) . "";
364
+    $url = "https://www.googleapis.com/language/translate/v2?key=$key&".$clean_lang."&target=$clean_lang&q=".urlencode($clean_text)."";
365 365
 
366 366
     if (empty($proxySettings)) {
367 367
         $content = file_get_contents($url);
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
     $relativeUrlPath = $dir;
382 382
     $doc_id = add_document(
383 383
         $_course,
384
-        $relativeUrlPath . $audio_filename,
384
+        $relativeUrlPath.$audio_filename,
385 385
         'file',
386 386
         filesize($documentPath),
387 387
         $audio_title
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
     );
401 401
     Display::display_confirmation_message(get_lang('DocumentCreated'));
402 402
     //return to location
403
-    echo '<script>window.location.href="' . $location . '"</script>';
403
+    echo '<script>window.location.href="'.$location.'"</script>';
404 404
 }
405 405
 
406 406
 /**
@@ -413,10 +413,10 @@  discard block
 block discarded – undo
413 413
  */
414 414
 function downloadMP3_pediaphon($filepath, $dir)
415 415
 {
416
-    $location = 'create_audio.php?' . api_get_cidreq() . '&id=' . intval($_POST['id']) . '&dt2a=pediaphon';
416
+    $location = 'create_audio.php?'.api_get_cidreq().'&id='.intval($_POST['id']).'&dt2a=pediaphon';
417 417
     //security
418 418
     if (!isset($_POST['lang']) && !isset($_POST['text']) && !isset($_POST['title']) && !isset($filepath) && !isset($dir)) {
419
-        echo '<script>window.location.href="' . $location . '"</script>';
419
+        echo '<script>window.location.href="'.$location.'"</script>';
420 420
         return;
421 421
     }
422 422
     $_course = api_get_course_info();
@@ -426,33 +426,33 @@  discard block
 block discarded – undo
426 426
     $clean_text = trim($_POST['text']);
427 427
     $clean_voices = Security::remove_XSS($_POST['voices']);
428 428
     if (empty($clean_title) || empty($clean_text) || empty($clean_voices)) {
429
-        echo '<script>window.location.href="' . $location . '"</script>';
429
+        echo '<script>window.location.href="'.$location.'"</script>';
430 430
 
431 431
         return;
432 432
     }
433 433
     $clean_title = Security::remove_XSS($clean_title);
434 434
     $clean_title = Database::escape_string($clean_title);
435
-    $clean_title = str_replace(' ', '_', $clean_title);//compound file names
435
+    $clean_title = str_replace(' ', '_', $clean_title); //compound file names
436 436
     $clean_text = Security::remove_XSS($clean_text);
437 437
     $clean_lang = Security::remove_XSS($_POST['lang']);
438 438
     $clean_speed = Security::remove_XSS($_POST['speed']);
439 439
 
440 440
     $extension = 'mp3';
441
-    $audio_filename = $clean_title . '.' . $extension;
441
+    $audio_filename = $clean_title.'.'.$extension;
442 442
     $audio_title = str_replace('_', ' ', $clean_title);
443 443
 
444 444
     //prevent duplicates
445
-    if (file_exists($filepath . '/' . $clean_title . '.' . $extension)) {
445
+    if (file_exists($filepath.'/'.$clean_title.'.'.$extension)) {
446 446
         $i = 1;
447
-        while (file_exists($filepath . '/' . $clean_title . '_' . $i . '.' . $extension)) {
447
+        while (file_exists($filepath.'/'.$clean_title.'_'.$i.'.'.$extension)) {
448 448
             $i++;
449 449
         }
450
-        $audio_filename = $clean_title . '_' . $i . '.' . $extension;
451
-        $audio_title = $clean_title . '_' . $i . '.' . $extension;
450
+        $audio_filename = $clean_title.'_'.$i.'.'.$extension;
451
+        $audio_title = $clean_title.'_'.$i.'.'.$extension;
452 452
         $audio_title = str_replace('_', ' ', $audio_title);
453 453
     }
454 454
 
455
-    $documentPath = $filepath . '/' . $audio_filename;
455
+    $documentPath = $filepath.'/'.$audio_filename;
456 456
     $clean_text = api_replace_dangerous_char($clean_text);
457 457
 
458 458
     //adding the file
@@ -461,17 +461,17 @@  discard block
 block discarded – undo
461 461
         $url_pediaphon = 'http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice.cgi';
462 462
         $find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/(.*)\.mp3\"/';
463 463
     } else {
464
-        $url_pediaphon = 'http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice_' . $clean_lang . '.cgi';//en, es, fr
465
-        $find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/' . $clean_lang . '\/(.*)\.mp3\"/';
464
+        $url_pediaphon = 'http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice_'.$clean_lang.'.cgi'; //en, es, fr
465
+        $find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/'.$clean_lang.'\/(.*)\.mp3\"/';
466 466
     }
467 467
 
468
-    $data = "stimme=" . $clean_voices . "&inputtext=" . $clean_text . "&speed=" . $clean_speed . "&go=speak";
468
+    $data = "stimme=".$clean_voices."&inputtext=".$clean_text."&speed=".$clean_speed."&go=speak";
469 469
     $opts = array(
470 470
         'http' =>
471 471
             array(
472 472
                 'method' => 'POST',
473 473
                 'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
474
-                "Content-Length: " . strlen($data) . "\r\n",
474
+                "Content-Length: ".strlen($data)."\r\n",
475 475
                 'content' => $data
476 476
             )
477 477
     );
@@ -494,10 +494,10 @@  discard block
 block discarded – undo
494 494
     $current_session_id = api_get_session_id();
495 495
     $groupId = api_get_group_id();
496 496
     $relativeUrlPath = $dir;
497
-    $doc_id = add_document($_course, $relativeUrlPath . $audio_filename, 'file', filesize($documentPath), $audio_title);
497
+    $doc_id = add_document($_course, $relativeUrlPath.$audio_filename, 'file', filesize($documentPath), $audio_title);
498 498
     api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null,
499 499
         null, $current_session_id);
500 500
     Display::display_confirmation_message(get_lang('DocumentCreated'));
501 501
     //return to location
502
-    echo '<script>window.location.href="' . $location . '"</script>';
502
+    echo '<script>window.location.href="'.$location.'"</script>';
503 503
 }
Please login to merge, or discard this patch.