api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(), 'name' => get_lang('Groups'), ]; $interbreadcrumb[] = [ 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), 'name' => get_lang('Group area').' '.$current_group_name, ]; $name_to_show = explode('/', $name_to_show); unset($name_to_show[1]); $name_to_show = implode('/', $name_to_show); } $interbreadcrumb[] = [ 'url' => './document.php?curdirpath='.dirname($header_file).'&'.api_get_cidreq(), 'name' => get_lang('Documents'), ]; if (empty($document_data['parents'])) { if (isset($_GET['createdir'])) { $interbreadcrumb[] = [ 'url' => $document_data['document_url'], 'name' => $document_data['title'], ]; } else { $interbreadcrumb[] = [ 'url' => '#', 'name' => $document_data['title'], ]; } } else { foreach ($document_data['parents'] as $document_sub_data) { if (!isset($_GET['createdir']) && $document_sub_data['id'] == $document_data['id']) { $document_sub_data['document_url'] = '#'; } $interbreadcrumb[] = [ 'url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title'], ]; } } $this_section = SECTION_COURSES; $nameTools = get_lang('Documents'); /** * Main code section. */ header('Expires: Wed, 01 Jan 1990 00:00:00 GMT'); //header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); header('Last-Modified: Wed, 01 Jan 2100 00:00:00 GMT'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); $browser_display_title = 'Documents - '.Security::remove_XSS($_GET['cidReq']).' - '.$file; // Only admins get to see the "no frames" link in pageheader.php, so students get a header that's not so high $frameheight = 135; if (api_is_course_admin()) { $frameheight = 165; } $frameReady = Display::getFrameReadyBlock('#mainFrame'); $web_odf_supported_files = DocumentManager::get_web_odf_extension_list(); // PDF should be displayed with viewerJS $web_odf_supported_files[] = 'pdf'; if (in_array(strtolower($pathinfo['extension']), $web_odf_supported_files)) { $show_web_odf = true; $htmlHeadXtra[] = ' ' ; } // Activate code highlight. $isChatFolder = false; if (isset($document_data['parents']) && isset($document_data['parents'][0])) { $chatFolder = $document_data['parents'][0]; if (isset($chatFolder['path']) && $chatFolder['path'] == '/chat_files') { $isChatFolder = true; } } if ($isChatFolder) { $htmlHeadXtra[] = api_get_js('highlight/highlight.pack.js'); $htmlHeadXtra[] = api_get_css(api_get_path(WEB_CSS_PATH).'chat.css'); $htmlHeadXtra[] = api_get_css( api_get_path(WEB_LIBRARY_PATH).'javascript/highlight/styles/github.css' ); $htmlHeadXtra[] = ' '; } $execute_iframe = true; if ($playerSupported) { $extension = api_strtolower($pathinfo['extension']); $execute_iframe = false; } if ($show_web_odf) { $execute_iframe = false; } if (!$playerSupported && $execute_iframe) { $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; } if ($originIsLearnpath) { Display::display_reduced_header(); } else { Display::display_header(); } $file_url = api_get_path(WEB_COURSE_PATH).$courseInfo['path'].'/document'.$header_file; $file_url_web = $file_url.'?'.api_get_cidreq(); if ($show_web_odf) { echo '
'; $browser = api_get_navigator(); $pdfUrl = api_get_path(WEB_LIBRARY_PATH).'javascript/ViewerJS/index.html#'.$file_url; if ($browser['name'] == 'Mozilla' && preg_match('|.*\.pdf|i', $header_file)) { $pdfUrl = $file_url; } echo '
'; echo ''; echo '
'; echo '
'; } if ($playerSupported) { echo DocumentManager::generateMediaPreview($file_url_web, $extension); } if ($execute_iframe) { if ($isChatFolder) { $content = Security::remove_XSS(file_get_contents($file_url_sys)); echo $content; } else { $parentId = $document_data['parent_id']; $url = api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq().'&id='.$parentId; $actionsLeft = Display::url( Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM), $url ); $groupMemberWithEditRights = false; $groupId = api_get_group_id(); if (!empty($groupId)) { $groupInfo = GroupManager::get_group_properties($groupId); if ($groupInfo) { $groupMemberWithEditRights = GroupManager::allowUploadEditDocument( api_get_user_id(), api_get_course_int_id(), $groupInfo, $document_data ); } } $allowToEdit = api_is_allowed_to_edit(null, true) || $groupMemberWithEditRights; if ($allowToEdit) { $actionsLeft .= Display::url( Display::return_icon( 'edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM ), api_get_path(WEB_CODE_PATH).'document/edit_document.php?'.api_get_cidreq().'&id='.$document_id ); $titleToShow = addslashes(basename($document_data['title'])); $urlDeleteParams = http_build_query( [ 'action' => 'delete_item', 'id' => $parentId, 'deleteid' => $document_data['id'], ] ); $actionsLeft .= Display::url( Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_MEDIUM), '#', [ 'data-item-title' => $titleToShow, 'data-href' => api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq( ).'&'.$urlDeleteParams, 'data-toggle' => 'modal', 'data-target' => '#confirm-delete', ] ); $actionsLeft .= Display::url( Display::return_icon('pdf.png', get_lang('Export to PDF format'), [], ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq( ).'&action=export_to_pdf&id='.$document_id ); } echo $toolbar = Display::toolbarAction('actions-documents', [$actionsLeft]); echo ''; } } Display::display_footer();