| @@ 864-884 (lines=21) @@ | ||
| 861 | * |
|
| 862 | * @throws NotPermittedException |
|
| 863 | */ |
|
| 864 | private function extractContentFromFilePDF(FilesDocument $document, File $file) { |
|
| 865 | if ($this->parseMimeType($document->getMimeType(), $file->getExtension()) |
|
| 866 | !== self::MIMETYPE_PDF) { |
|
| 867 | return; |
|
| 868 | } |
|
| 869 | ||
| 870 | $this->configService->setDocumentIndexOption($document, ConfigService::FILES_PDF); |
|
| 871 | if (!$this->isSourceIndexable($document)) { |
|
| 872 | return; |
|
| 873 | } |
|
| 874 | ||
| 875 | if ($this->configService->getAppValue(ConfigService::FILES_PDF) !== '1') { |
|
| 876 | $document->setContent(''); |
|
| 877 | ||
| 878 | return; |
|
| 879 | } |
|
| 880 | ||
| 881 | $document->setContent( |
|
| 882 | base64_encode($file->getContent()), IndexDocument::ENCODED_BASE64 |
|
| 883 | ); |
|
| 884 | } |
|
| 885 | ||
| 886 | ||
| 887 | /** |
|
| @@ 893-913 (lines=21) @@ | ||
| 890 | * |
|
| 891 | * @throws NotPermittedException |
|
| 892 | */ |
|
| 893 | private function extractContentFromFileZip(FilesDocument $document, File $file) { |
|
| 894 | if ($this->parseMimeType($document->getMimeType(), $file->getExtension()) |
|
| 895 | !== self::MIMETYPE_ZIP) { |
|
| 896 | return; |
|
| 897 | } |
|
| 898 | ||
| 899 | $this->configService->setDocumentIndexOption($document, ConfigService::FILES_ZIP); |
|
| 900 | if (!$this->isSourceIndexable($document)) { |
|
| 901 | return; |
|
| 902 | } |
|
| 903 | ||
| 904 | if ($this->configService->getAppValue(ConfigService::FILES_ZIP) !== '1') { |
|
| 905 | $document->setContent(''); |
|
| 906 | ||
| 907 | return; |
|
| 908 | } |
|
| 909 | ||
| 910 | $document->setContent( |
|
| 911 | base64_encode($file->getContent()), IndexDocument::ENCODED_BASE64 |
|
| 912 | ); |
|
| 913 | } |
|
| 914 | ||
| 915 | ||
| 916 | /** |
|
| @@ 922-942 (lines=21) @@ | ||
| 919 | * |
|
| 920 | * @throws NotPermittedException |
|
| 921 | */ |
|
| 922 | private function extractContentFromFileOffice(FilesDocument $document, File $file) { |
|
| 923 | if ($this->parseMimeType($document->getMimeType(), $file->getExtension()) |
|
| 924 | !== self::MIMETYPE_OFFICE) { |
|
| 925 | return; |
|
| 926 | } |
|
| 927 | ||
| 928 | $this->configService->setDocumentIndexOption($document, ConfigService::FILES_OFFICE); |
|
| 929 | if (!$this->isSourceIndexable($document)) { |
|
| 930 | return; |
|
| 931 | } |
|
| 932 | ||
| 933 | if ($this->configService->getAppValue(ConfigService::FILES_OFFICE) !== '1') { |
|
| 934 | $document->setContent(''); |
|
| 935 | ||
| 936 | return; |
|
| 937 | } |
|
| 938 | ||
| 939 | $document->setContent( |
|
| 940 | base64_encode($file->getContent()), IndexDocument::ENCODED_BASE64 |
|
| 941 | ); |
|
| 942 | } |
|
| 943 | ||
| 944 | ||
| 945 | /** |
|