lp_impress.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * @package chamilo.learnpath
  6. */
  7. require_once __DIR__.'/../inc/global.inc.php';
  8. $this_section = SECTION_COURSES;
  9. //To prevent the template class
  10. $show_learnpath = true;
  11. api_protect_course_script();
  12. $lp_id = intval($_GET['lp_id']);
  13. // Check if the learning path is visible for student - (LP requisites)
  14. if (!api_is_allowed_to_edit(null, true) &&
  15. !learnpath::is_lp_visible_for_student($lp_id, api_get_user_id(), api_get_course_info())
  16. ) {
  17. api_not_allowed();
  18. }
  19. //Checking visibility (eye icon)
  20. $visibility = api_get_item_visibility(
  21. api_get_course_info(),
  22. TOOL_LEARNPATH,
  23. $lp_id,
  24. api_get_session_id(),
  25. api_get_user_id(),
  26. null,
  27. api_get_group_id()
  28. );
  29. if (!api_is_allowed_to_edit(null, true) && intval($visibility) == 0) {
  30. api_not_allowed();
  31. }
  32. /** @var learnpath $lp */
  33. $lp = Session::read('oLP');
  34. if (!$lp) {
  35. api_not_allowed(true);
  36. }
  37. $debug = 0;
  38. $course_code = api_get_course_id();
  39. $course_id = api_get_course_int_id();
  40. $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/impress/impress-demo.css');
  41. $list = $lp->get_toc();
  42. $is_allowed_to_edit = api_is_allowed_to_edit(null, true, false, false);
  43. if ($is_allowed_to_edit) {
  44. echo '<div style="position: fixed; top: 0px; left: 0px; pointer-events: auto;width:100%">';
  45. global $interbreadcrumb;
  46. $interbreadcrumb[] = [
  47. 'url' => 'lp_controller.php?action=list&isStudentView=false&'.api_get_cidreq(),
  48. 'name' => get_lang('LearningPaths'),
  49. ];
  50. $interbreadcrumb[] = [
  51. 'url' => api_get_self()."?action=add_item&type=step&lp_id=".$lp->lp_id."&isStudentView=false&".api_get_cidreq(),
  52. 'name' => $lp->get_name(),
  53. ];
  54. $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Preview')];
  55. echo return_breadcrumb($interbreadcrumb, null, null);
  56. echo '</div>';
  57. }
  58. $html = '';
  59. $step = 1;
  60. foreach ($list as $toc) {
  61. $x = 1000 * $step;
  62. $html .= '<div id="step-'.$step.'" class="step slide" data-x="'.$x.'" data-y="-1500" >';
  63. $html .= '<div class="impress-content">';
  64. $src = $lp->get_link('http', $toc['id']);
  65. if ($toc['type'] !== 'dir') {
  66. //just showing the src in a iframe ...
  67. $html .= '<h2>'.$toc['title'].'</h2>';
  68. $html .= '<iframe border="0" frameborder="0" style="width:100%;height:600px" src="'.$src.'"></iframe>';
  69. } else {
  70. $html .= "<div class='impress-title'>";
  71. $html .= '<h1>'.$toc['title'].'</h1>';
  72. $html .= "</div>";
  73. }
  74. $html .= "</div>";
  75. $html .= "</div>";
  76. $step++;
  77. }
  78. //Setting the template
  79. $tool_name = get_lang('ViewModeImpress');
  80. $tpl = new Template($tool_name, false, false, true);
  81. $tpl->assign('html', $html);
  82. $templateName = $tpl->get_template('learnpath/impress.tpl');
  83. $content = $tpl->fetch($templateName);
  84. $tpl->assign('content', $content);
  85. $tpl->display_one_col_template();