diff --git a/main/document/showinframes.php b/main/document/showinframes.php index fe299836ba..e343531e53 100755 --- a/main/document/showinframes.php +++ b/main/document/showinframes.php @@ -176,14 +176,14 @@ $frameheight = 135; if (api_is_course_admin()) { $frameheight = 165; } - +$execute_iframe = true; $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; + $execute_iframe = false; $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') { + if (isset($chatFolder['path']) && $chatFolder['path'] === '/chat_files') { $isChatFolder = true; } } @@ -217,17 +216,12 @@ if ($isChatFolder) { '; } -$execute_iframe = true; if ($playerSupported) { $extension = api_strtolower($pathinfo['extension']); $execute_iframe = false; } -if ($show_web_odf) { - $execute_iframe = false; -} - -$is_freemind_available = $pathinfo['extension'] == 'mm' && api_get_setting('enable_freemind') == 'true'; +$is_freemind_available = $pathinfo['extension'] === 'mm' && api_get_setting('enable_freemind') === 'true'; if ($is_freemind_available) { $execute_iframe = false; } @@ -259,27 +253,6 @@ if ($originIsLearnpath) { $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?zoom=page-width#'.$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); } @@ -342,42 +315,37 @@ if ($is_freemind_available) { //fo.addVariable("toolTipsBgColor","0xaaeeaa");: bgcolor for tooltips ej;"0xaaeeaa" //fo.addVariable("defaultWordWrap","300"); //default 600 // - fo.write("flashcontent"); // ]]> 'delete_item', + 'id' => $parentId, + 'deleteid' => $document_data['id'], + ] + ); - $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('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', + ] + ); + + if (false === $show_web_odf) { $actionsLeft .= Display::url( Display::return_icon('pdf.png', get_lang('Export2PDF'), [], 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 $toolbar = Display::toolbarAction('actions-documents', [$actionsLeft]); +if ($show_web_odf) { + $execute_iframe = false; + echo '
'; + $browser = api_get_navigator(); + $pdfUrl = api_get_path(WEB_LIBRARY_PATH).'javascript/ViewerJS/index.html?zoom=page-width#'.$file_url; + if ($browser['name'] === 'Mozilla' && preg_match('|.*\.pdf|i', $header_file)) { + $pdfUrl = $file_url; + } + echo '
'; + echo ''; + echo '
'; + echo '
'; +} +if ($execute_iframe) { + if ($isChatFolder) { + $content = Security::remove_XSS(file_get_contents($file_url_sys)); + echo $content; + } else { echo '