From 28cbdc2c6afdaccfab5febe35449903d39a876ed Mon Sep 17 00:00:00 2001 From: Daniel Barreto Date: Fri, 21 Nov 2014 14:17:54 -0500 Subject: [PATCH] Enable viewerJS for ODF - refs CT#7406 --- main/document/document.inc.php | 5 +++-- main/document/showinframes.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/main/document/document.inc.php b/main/document/document.inc.php index 5aef0bafa2..27a08b9855 100755 --- a/main/document/document.inc.php +++ b/main/document/document.inc.php @@ -112,6 +112,7 @@ function create_document_link( global $dbl_click_id; $course_info = api_get_course_info(); $www = api_get_path(WEB_COURSE_PATH) . $course_info['path'] . '/document'; + $webOdflist = DocumentManager::get_web_odf_extension_list(); // Get the title or the basename depending on what we're using if ($document_data['title'] != '') { @@ -153,7 +154,7 @@ function create_document_link( $is_browser_viewable_file = is_browser_viewable($ext); if ($is_browser_viewable_file) { - if ($ext == 'pdf') { + if ($ext == 'pdf' || in_array($ext, $webOdflist)) { $url = api_get_self() . '?' . api_get_cidreq() . '&action=download&id=' . $document_data['id']; } else { $url = 'showinframes.php?' . api_get_cidreq() . '&id=' . $document_data['id']; @@ -298,7 +299,7 @@ function create_document_link( } else { // For PDF Download the file. $pdfPreview = null; - if ($ext != 'pdf') { + if ($ext != 'pdf' && !in_array($ext, $webOdflist)) { $url = 'showinframes.php?' . api_get_cidreq() . '&id=' . $document_data['id']; } else { $pdfPreview = Display::url( diff --git a/main/document/showinframes.php b/main/document/showinframes.php index 065eecfd43..621e4276cd 100755 --- a/main/document/showinframes.php +++ b/main/document/showinframes.php @@ -342,7 +342,7 @@ if (!$is_nanogong_available) { if ($show_web_odf) { $browser = api_get_navigator(); $pdfUrl = api_get_path(WEB_LIBRARY_PATH) . 'javascript/ViewerJS/index.html#' . $file_url; - if ($browser['name'] == 'Mozilla') { + if ($browser['name'] == 'Mozilla' && preg_match('|.*\.pdf|i', $header_file)) { $pdfUrl = $file_url; } echo '
';