Commit 2cef11f485bc0a07bb4fb28bc53289d83aad8f8d
1 parent
74f373cc
KTS-2828
"Mime types of Microsoft Office documents are being resolved incorrectly as binary files that cannot be indexed" Fixed. Committed By: Conrad Vermeulen Reviewed By: Megan Watson git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7982 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
19 additions
and
25 deletions
lib/mime.inc.php
| @@ -5,32 +5,32 @@ | @@ -5,32 +5,32 @@ | ||
| 5 | * KnowledgeTree Open Source Edition | 5 | * KnowledgeTree Open Source Edition |
| 6 | * Document Management Made Simple | 6 | * Document Management Made Simple |
| 7 | * Copyright (C) 2004 - 2008 The Jam Warehouse Software (Pty) Limited | 7 | * Copyright (C) 2004 - 2008 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | 8 | + * |
| 9 | * This program is free software; you can redistribute it and/or modify it under | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | * the terms of the GNU General Public License version 3 as published by the | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | * Free Software Foundation. | 11 | * Free Software Foundation. |
| 12 | - * | 12 | + * |
| 13 | * This program is distributed in the hope that it will be useful, but WITHOUT | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | * details. | 16 | * details. |
| 17 | - * | 17 | + * |
| 18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | 20 | + * |
| 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | 23 | + * |
| 24 | * The interactive user interfaces in modified source and object code versions | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | * of this program must display Appropriate Legal Notices, as required under | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | * Section 5 of the GNU General Public License version 3. | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | 27 | + * |
| 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | * these Appropriate Legal Notices must retain the display of the "Powered by | 29 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 30 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | 30 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the |
| 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 32 | - * must display the words "Powered by KnowledgeTree" and retain the original | ||
| 33 | - * copyright notice. | 32 | + * must display the words "Powered by KnowledgeTree" and retain the original |
| 33 | + * copyright notice. | ||
| 34 | * Contributor( s): ______________________________________ | 34 | * Contributor( s): ______________________________________ |
| 35 | * | 35 | * |
| 36 | */ | 36 | */ |
| @@ -50,15 +50,9 @@ class KTMime { | @@ -50,15 +50,9 @@ class KTMime { | ||
| 50 | function getMimeTypeID($sMimeType, $sFileName) { | 50 | function getMimeTypeID($sMimeType, $sFileName) { |
| 51 | global $default; | 51 | global $default; |
| 52 | $sTable = KTUtil::getTableName('mimetypes'); | 52 | $sTable = KTUtil::getTableName('mimetypes'); |
| 53 | - $lookupExtension = false; | ||
| 54 | 53 | ||
| 55 | - if (in_array($sMimeType, array('application/x-zip','application/octet-stream', 'application/msword', 'text/plain'))) | ||
| 56 | - { | ||
| 57 | - $lookupExtension = true; | ||
| 58 | - } | ||
| 59 | 54 | ||
| 60 | - if ($lookupExtension || empty($sMimeType)) | ||
| 61 | - { | 55 | + |
| 62 | // check by file extension | 56 | // check by file extension |
| 63 | $sExtension = KTMime::stripAllButExtension($sFileName); | 57 | $sExtension = KTMime::stripAllButExtension($sFileName); |
| 64 | $res = DBUtil::getOneResultKey(array("SELECT id FROM " . $sTable . " WHERE LOWER(filetypes) = ?", array($sExtension)),'id'); | 58 | $res = DBUtil::getOneResultKey(array("SELECT id FROM " . $sTable . " WHERE LOWER(filetypes) = ?", array($sExtension)),'id'); |
| @@ -69,7 +63,7 @@ class KTMime { | @@ -69,7 +63,7 @@ class KTMime { | ||
| 69 | else { | 63 | else { |
| 70 | return $res; | 64 | return $res; |
| 71 | } | 65 | } |
| 72 | - } | 66 | + |
| 73 | 67 | ||
| 74 | // get the mime type id | 68 | // get the mime type id |
| 75 | if (isset($sMimeType)) { | 69 | if (isset($sMimeType)) { |
| @@ -207,12 +201,12 @@ class KTMime { | @@ -207,12 +201,12 @@ class KTMime { | ||
| 207 | function stripAllButExtension($sFileName) { | 201 | function stripAllButExtension($sFileName) { |
| 208 | return strtolower(substr($sFileName, strrpos($sFileName, ".")+1, strlen($sFileName) - strrpos($sFileName, "."))); | 202 | return strtolower(substr($sFileName, strrpos($sFileName, ".")+1, strlen($sFileName) - strrpos($sFileName, "."))); |
| 209 | } | 203 | } |
| 210 | - | 204 | + |
| 211 | /** | 205 | /** |
| 212 | - * getAllMimeTypesInformation is a staic function used to get a fuller set of | 206 | + * getAllMimeTypesInformation is a staic function used to get a fuller set of |
| 213 | * information on the mime types held in the database. | 207 | * information on the mime types held in the database. |
| 214 | - * | ||
| 215 | - */ | 208 | + * |
| 209 | + */ | ||
| 216 | function getAllMimeTypesInformation() | 210 | function getAllMimeTypesInformation() |
| 217 | { | 211 | { |
| 218 | $sTable = KTUtil::getTableName('mimetypes'); | 212 | $sTable = KTUtil::getTableName('mimetypes'); |
| @@ -221,10 +215,10 @@ class KTMime { | @@ -221,10 +215,10 @@ class KTMime { | ||
| 221 | $res = DBUtil::getResultArray($aQuery); | 215 | $res = DBUtil::getResultArray($aQuery); |
| 222 | return $res; | 216 | return $res; |
| 223 | } | 217 | } |
| 224 | - | 218 | + |
| 225 | /** | 219 | /** |
| 226 | * get all information on all the extractors in the database | 220 | * get all information on all the extractors in the database |
| 227 | - * | 221 | + * |
| 228 | */ | 222 | */ |
| 229 | function getMimeExtractorInformation() | 223 | function getMimeExtractorInformation() |
| 230 | { | 224 | { |
| @@ -232,11 +226,11 @@ class KTMime { | @@ -232,11 +226,11 @@ class KTMime { | ||
| 232 | $res = DBUtil::getResultArray($aQuery); | 226 | $res = DBUtil::getResultArray($aQuery); |
| 233 | return $res; | 227 | return $res; |
| 234 | } | 228 | } |
| 235 | - | 229 | + |
| 236 | /** | 230 | /** |
| 237 | *give the mimetype name and get the friendly names and the extensions | 231 | *give the mimetype name and get the friendly names and the extensions |
| 238 | * | 232 | * |
| 239 | - */ | 233 | + */ |
| 240 | function getFriendlyNameAndExtension($sMimeType) | 234 | function getFriendlyNameAndExtension($sMimeType) |
| 241 | { | 235 | { |
| 242 | $sTable = KTUtil::getTableName('mimetypes'); | 236 | $sTable = KTUtil::getTableName('mimetypes'); |