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