Commit 2020bd44c18f31ca6993ffd77b8296864fb374cf
1 parent
ef0be948
KTS-673
"The search algorithm needs some work" Updated. Added Exif extractor Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7435 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
50 additions
and
0 deletions
search2/indexing/extractors/ExifExtractor.inc.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +class ExifExtractor extends DocumentExtractor | ||
| 4 | +{ | ||
| 5 | + public function getDisplayName() | ||
| 6 | + { | ||
| 7 | + return _kt('Exif Extractor'); | ||
| 8 | + } | ||
| 9 | + | ||
| 10 | + public function getSupportedMimeTypes() | ||
| 11 | + { | ||
| 12 | + return array( | ||
| 13 | + 'image/tiff','image/jpeg' | ||
| 14 | + ); | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + public function extractTextContent() | ||
| 18 | + { | ||
| 19 | + $exif = exif_read_data($this->sourcefile, 0, true); | ||
| 20 | + $content = ''; | ||
| 21 | + foreach ($exif as $key => $section) | ||
| 22 | + { | ||
| 23 | + foreach ($section as $name => $val) | ||
| 24 | + { | ||
| 25 | + if (is_numeric($val)) | ||
| 26 | + { | ||
| 27 | + // no point indexing numeric content. it will be ignored anyways! | ||
| 28 | + continue; | ||
| 29 | + } | ||
| 30 | + $content .= "$val\n"; | ||
| 31 | + } | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + $result = file_put_contents($this->targetfile, $content); | ||
| 35 | + | ||
| 36 | + return false !== $result; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public function diagnose() | ||
| 40 | + { | ||
| 41 | + if (!function_exists('exif_read_data')) | ||
| 42 | + { | ||
| 43 | + return sprintf(_kt('The Exif extractor requires the module exif php extension. Please include this in the php.ini.')); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + return null; | ||
| 47 | + } | ||
| 48 | +} | ||
| 49 | + | ||
| 50 | +?> | ||
| 0 | \ No newline at end of file | 51 | \ No newline at end of file |