lp_impress.php 2.8 KB

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