TYPO3CMS
9.5
Main Page
Related Pages
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Variables
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Files
File List
File Members
All
$
d
e
r
u
Functions
Variables
$
e
r
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Pages
PlainTextExtractor.php
Go to the documentation of this file.
1
<?php
2
namespace
TYPO3\CMS\Core\Resource\TextExtraction
;
3
4
/*
5
* This file is part of the TYPO3 CMS project.
6
*
7
* It is free software; you can redistribute it and/or modify it under
8
* the terms of the GNU General Public License, either version 2
9
* of the License, or any later version.
10
*
11
* For the full copyright and license information, please read the
12
* LICENSE.txt file that was distributed with this source code.
13
*
14
* The TYPO3 project - inspiring people to share!
15
*/
16
17
use
TYPO3\CMS\Core\Resource\FileInterface
;
18
use
TYPO3\CMS\Core\Utility\PathUtility
;
19
23
class
PlainTextExtractor
implements
TextExtractorInterface
24
{
31
public
function
canExtractText
(
FileInterface
$file)
32
{
33
$canExtract =
false
;
34
35
if
($file->
getMimeType
() ===
'text/plain'
) {
36
$canExtract =
true
;
37
}
38
39
return
$canExtract;
40
}
41
48
public
function
extractText
(
FileInterface
$file)
49
{
50
$localTempFile = $file->
getForLocalProcessing
(
false
);
51
52
// extract text
53
$content = file_get_contents($localTempFile);
54
55
// In case of remote storage, the temporary copy of the
56
// original file in typo3temp must be removed
57
// Simply compare the filenames, because the filename is so unique that
58
// it is nearly impossible to have a file with this name in a storage
59
if
(
PathUtility::basename
($localTempFile) !== $file->
getName
()) {
60
unlink($localTempFile);
61
}
62
63
return
$content;
64
}
65
}
TYPO3\CMS\Core\Resource\TextExtraction\PlainTextExtractor\canExtractText
bool canExtractText(FileInterface $file)
Definition:
PlainTextExtractor.php:31
TYPO3\CMS\Core\Utility\PathUtility
Definition:
PathUtility.php:23
TYPO3\CMS\Core\Resource\FileInterface
Definition:
FileInterface.php:21
TYPO3\CMS\Core\Resource\TextExtraction\TextExtractorInterface
Definition:
TextExtractorInterface.php:23
TYPO3\CMS\Core\Resource\FileInterface\getForLocalProcessing
string getForLocalProcessing($writable=true)
TYPO3\CMS\Core\Utility\PathUtility\basename
static string basename($path)
Definition:
PathUtility.php:164
TYPO3\CMS\Core\Resource\TextExtraction\PlainTextExtractor\extractText
string extractText(FileInterface $file)
Definition:
PlainTextExtractor.php:48
TYPO3\CMS\Core\Resource\ResourceInterface\getName
string getName()
TYPO3\CMS\Core\Resource\TextExtraction
Definition:
PlainTextExtractor.php:2
TYPO3\CMS\Core\Resource\TextExtraction\PlainTextExtractor
Definition:
PlainTextExtractor.php:24
TYPO3\CMS\Core\Resource\FileInterface\getMimeType
string getMimeType()
doxygen
typo3
sysext
core
Classes
Resource
TextExtraction
PlainTextExtractor.php
Generated on Tue Oct 5 2021 01:57:13 for TYPO3CMS by
1.8.18