embed.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. require_once __DIR__.'/../inc/global.inc.php';
  5. api_protect_course_script(true);
  6. $type = $_REQUEST['type'];
  7. $src = Security::remove_XSS($_REQUEST['source']);
  8. if (empty($type) || empty($src)) {
  9. api_not_allowed();
  10. }
  11. $iframe = '';
  12. switch ($type) {
  13. case 'download':
  14. /** @var learnpath $learnPath */
  15. $learnPath = Session::read('oLP');
  16. $itemId = isset($_GET['lp_item_id']) ? $_GET['lp_item_id'] : '';
  17. if (!$learnPath || empty($itemId)) {
  18. api_not_allowed();
  19. }
  20. $file = learnpath::rl_get_resource_link_for_learnpath(
  21. api_get_course_int_id(),
  22. $learnPath->get_id(),
  23. $itemId,
  24. $learnPath->get_view_id()
  25. );
  26. $iframe = Display::return_message(
  27. Display::url(get_lang('Download'), $file, ['class' => 'btn btn-primary']),
  28. 'info',
  29. false
  30. );
  31. break;
  32. case 'youtube':
  33. $src = '//www.youtube.com/embed/'.$src;
  34. $iframe .= '<div id="content" style="width: 700px ;margin-left:auto; margin-right:auto;"><br />';
  35. $iframe .= '<iframe class="youtube-player" type="text/html" width="640" height="385" src="'.$src.'" frameborder="0"></iframe>';
  36. $iframe .= '</div>';
  37. break;
  38. case 'vimeo':
  39. $src = '//player.vimeo.com/video/'.$src;
  40. $iframe .= '<div id="content" style="width: 700px ;margin-left:auto; margin-right:auto;"><br />';
  41. $iframe .= '<iframe src="'.$src.'" width="640" height="385" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
  42. $iframe .= '</div>';
  43. break;
  44. case 'nonhttps':
  45. $icon = '&nbsp;<em class="icon-external-link icon-2x"></em>';
  46. $iframe = Display::return_message(
  47. Display::url($src.$icon, $src, ['class' => 'btn', 'target' => '_blank']),
  48. 'normal',
  49. false
  50. );
  51. break;
  52. }
  53. $htmlHeadXtra[] = "
  54. <style>
  55. body { background: none;}
  56. </style>
  57. ";
  58. Display::display_reduced_header();
  59. echo $iframe;
  60. Display::display_footer();