From 664891d56b4a094ae118fe5ac368c3acc2f8c411 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 17 Feb 2016 06:36:27 +0000 Subject: [PATCH] enhanced the pdf file detection in the code file view --- codepot/src/codepot/views/code_file.php | 23 ++++++++++++++++------- codepot/src/js/Makefile.in | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/codepot/src/codepot/views/code_file.php b/codepot/src/codepot/views/code_file.php index 1b5750e6..223d4ff7 100644 --- a/codepot/src/codepot/views/code_file.php +++ b/codepot/src/codepot/views/code_file.php @@ -14,15 +14,24 @@ { if ($pn == 'svn:mime-type') { - if ($pv == 'application/octet-stream' && - in_array (strtolower($fileext), array ('png', 'jpg', 'gif', 'tif', 'bmp', 'ico'))) + if ($pv == 'application/octet-stream') { - $img = @imagecreatefromstring ($file['content']); - if ($img !== FALSE) + $lower_fileext = strtolower($fileext); + if (in_array ($lower_fileext, array ('png', 'jpg', 'gif', 'tif', 'bmp', 'ico'))) + { + $img = @imagecreatefromstring ($file['content']); + if ($img !== FALSE) + { + @imagedestroy ($img); + $is_image_file = TRUE; + $is_special_stream = TRUE; + break; + } + } + else if (in_array ($lower_fileext, array ('pdf'))) { - @imagedestroy ($img); - $is_image_file = TRUE; $is_special_stream = TRUE; + $is_pdf_file = TRUE; break; } } @@ -502,7 +511,7 @@ if ($login['settings'] != NULL && print '
'; print ''; print ''; - print ''; + print ''; print '/'; print ''; print ''; diff --git a/codepot/src/js/Makefile.in b/codepot/src/js/Makefile.in index a4992e55..9b86b637 100644 --- a/codepot/src/js/Makefile.in +++ b/codepot/src/js/Makefile.in @@ -181,7 +181,7 @@ www_DATA = \ medium-editor-tables.js \ showdown.js \ d3.min.js \ - CodeFlower.js \ + CodeFlower.js \ pdf.min.js \ pdf.worker.min.js