lp_impress.php 3.0 KB

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