|
1
|
|
|
<?php |
|
2
|
|
|
namespace AOEPeople\Crawler\Worker; |
|
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 AOE\Crawler\Controller\CrawlerController; |
|
18
|
|
|
use AOEPeople\Crawler\Hooks\IndexedSearchCrawlerFilesHook; |
|
19
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
20
|
|
|
use TYPO3\CMS\Core\TimeTracker\TimeTracker; |
|
21
|
|
|
use TYPO3\CMS\IndexedSearch\Worker\WorkerInterface; |
|
22
|
|
|
|
|
23
|
|
|
class CrawlerWorker implements WorkerInterface |
|
24
|
|
|
{ |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* CrawlerWorker constructor. |
|
28
|
|
|
*/ |
|
29
|
|
|
public function __construct() |
|
30
|
|
|
{ |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param object $caller Method caller |
|
35
|
|
|
* @param array $conf Indexed search configuration |
|
36
|
|
|
* @param string $file Relative Filename, relative to public web path. It can also be an absolute path as long as it is inside the lockRootPath (validated with \TYPO3\CMS\Core\Utility\GeneralUtility::isAbsPath()). Finally, if $contentTmpFile is set, this value can be anything, most likely a URL |
|
37
|
|
|
* @param string $contentTmpFile Temporary file with the content to read it from (instead of $file). Used when the $file is a URL. |
|
38
|
|
|
* @param string $fileExtension File extension for temporary file. |
|
39
|
|
|
* @return mixed |
|
40
|
|
|
*/ |
|
41
|
|
|
public function index(object $caller, array $conf, string $file, string $contentTmpFile = '', $fileExtension = '') |
|
42
|
|
|
{ |
|
43
|
|
|
$crawler = GeneralUtility::makeInstance(CrawlerController::class); |
|
44
|
|
|
|
|
45
|
|
|
$params = [ |
|
46
|
|
|
'document' => $contentTmpFile, |
|
47
|
|
|
'alturl' =>$file, |
|
48
|
|
|
'conf' => $conf |
|
49
|
|
|
]; |
|
50
|
|
|
|
|
51
|
|
|
unset($params['conf']['content']); |
|
52
|
|
|
|
|
53
|
|
|
$crawler->addQueueEntry_callBack(0, $params, IndexedSearchCrawlerFilesHook::class, $conf['id']); |
|
54
|
|
|
|
|
55
|
|
|
GeneralUtility::makeInstance(TimeTracker::class)->setTSlogMessage('media "' . $params['document'] . '" added to "crawler" queue.', 1); |
|
56
|
|
|
} |
|
57
|
|
|
} |