lp_impress.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. *
  5. * @package chamilo.learnpath
  6. */
  7. require_once __DIR__.'/../inc/global.inc.php';
  8. $_SESSION['whereami'] = 'lp/impress';
  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. if (empty($_SESSION['oLP'])) {
  34. api_not_allowed(true);
  35. }
  36. $debug = 0;
  37. if ($debug) { error_log('------ Entering lp_impress.php -------'); }
  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 = $_SESSION['oLP']->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[] = array(
  47. 'url' => 'lp_controller.php?action=list&isStudentView=false&'.api_get_cidreq(),
  48. 'name' => get_lang('LearningPaths'),
  49. );
  50. $interbreadcrumb[] = array(
  51. 'url' => api_get_self()."?action=add_item&type=step&lp_id=".$_SESSION['oLP']->lp_id."&isStudentView=false&".api_get_cidreq(),
  52. 'name' => $_SESSION['oLP']->get_name(),
  53. );
  54. $interbreadcrumb[] = array('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 = $_SESSION['oLP']->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();