| @@ 898-918 (lines=21) @@ | ||
| 895 | * |
|
| 896 | * @throws NotPermittedException |
|
| 897 | */ |
|
| 898 | private function extractContentFromFilePDF(FilesDocument $document, File $file) { |
|
| 899 | if ($this->parseMimeType($document->getMimeType(), $file->getExtension()) |
|
| 900 | !== self::MIMETYPE_PDF) { |
|
| 901 | return; |
|
| 902 | } |
|
| 903 | ||
| 904 | $this->configService->setDocumentIndexOption($document, ConfigService::FILES_PDF); |
|
| 905 | if (!$this->isSourceIndexable($document)) { |
|
| 906 | return; |
|
| 907 | } |
|
| 908 | ||
| 909 | if ($this->configService->getAppValue(ConfigService::FILES_PDF) !== '1') { |
|
| 910 | $document->setContent(''); |
|
| 911 | ||
| 912 | return; |
|
| 913 | } |
|
| 914 | ||
| 915 | $document->setContent( |
|
| 916 | base64_encode($file->getContent()), IndexDocument::ENCODED_BASE64 |
|
| 917 | ); |
|
| 918 | } |
|
| 919 | ||
| 920 | ||
| 921 | /** |
|
| @@ 927-947 (lines=21) @@ | ||
| 924 | * |
|
| 925 | * @throws NotPermittedException |
|
| 926 | */ |
|
| 927 | private function extractContentFromFileZip(FilesDocument $document, File $file) { |
|
| 928 | if ($this->parseMimeType($document->getMimeType(), $file->getExtension()) |
|
| 929 | !== self::MIMETYPE_ZIP) { |
|
| 930 | return; |
|
| 931 | } |
|
| 932 | ||
| 933 | $this->configService->setDocumentIndexOption($document, ConfigService::FILES_ZIP); |
|
| 934 | if (!$this->isSourceIndexable($document)) { |
|
| 935 | return; |
|
| 936 | } |
|
| 937 | ||
| 938 | if ($this->configService->getAppValue(ConfigService::FILES_ZIP) !== '1') { |
|
| 939 | $document->setContent(''); |
|
| 940 | ||
| 941 | return; |
|
| 942 | } |
|
| 943 | ||
| 944 | $document->setContent( |
|
| 945 | base64_encode($file->getContent()), IndexDocument::ENCODED_BASE64 |
|
| 946 | ); |
|
| 947 | } |
|
| 948 | ||
| 949 | ||
| 950 | /** |
|
| @@ 956-976 (lines=21) @@ | ||
| 953 | * |
|
| 954 | * @throws NotPermittedException |
|
| 955 | */ |
|
| 956 | private function extractContentFromFileOffice(FilesDocument $document, File $file) { |
|
| 957 | if ($this->parseMimeType($document->getMimeType(), $file->getExtension()) |
|
| 958 | !== self::MIMETYPE_OFFICE) { |
|
| 959 | return; |
|
| 960 | } |
|
| 961 | ||
| 962 | $this->configService->setDocumentIndexOption($document, ConfigService::FILES_OFFICE); |
|
| 963 | if (!$this->isSourceIndexable($document)) { |
|
| 964 | return; |
|
| 965 | } |
|
| 966 | ||
| 967 | if ($this->configService->getAppValue(ConfigService::FILES_OFFICE) !== '1') { |
|
| 968 | $document->setContent(''); |
|
| 969 | ||
| 970 | return; |
|
| 971 | } |
|
| 972 | ||
| 973 | $document->setContent( |
|
| 974 | base64_encode($file->getContent()), IndexDocument::ENCODED_BASE64 |
|
| 975 | ); |
|
| 976 | } |
|
| 977 | ||
| 978 | ||
| 979 | /** |
|