|
1
|
|
|
<?php |
|
2
|
|
|
namespace AOEPeople\Crawler\Hooks; |
|
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
|
|
|
/** |
|
18
|
|
|
* Crawler hook for indexed search. Works with the "crawler" extension |
|
19
|
|
|
* This hook is specifically used to index external files found on pages through the crawler extension. |
|
20
|
|
|
* @see \TYPO3\CMS\IndexedSearch\Indexer::extractLinks() |
|
21
|
|
|
* @internal this is a TYPO3-internal hook implementation and not part of TYPO3's Core API. |
|
22
|
|
|
*/ |
|
23
|
|
|
class IndexedSearchCrawlerFilesHook |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* Call back function for execution of a log element |
|
27
|
|
|
* |
|
28
|
|
|
* @param array $params Params from log element. |
|
29
|
|
|
* @param object $pObj Parent object (tx_crawler lib) |
|
30
|
|
|
* @return array|null Result array |
|
31
|
|
|
*/ |
|
32
|
|
|
public function crawler_execute($params, &$pObj) |
|
|
|
|
|
|
33
|
|
|
{ |
|
34
|
|
|
if (!is_array($params['conf'])) { |
|
35
|
|
|
return; |
|
36
|
|
|
} |
|
37
|
|
|
// Initialize the indexer class: |
|
38
|
|
|
$indexerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\IndexedSearch\Indexer::class); |
|
39
|
|
|
$indexerObj->conf = $params['conf']; |
|
40
|
|
|
$indexerObj->init(); |
|
41
|
|
|
// Index document: |
|
42
|
|
|
if ($params['alturl']) { |
|
43
|
|
|
$fI = pathinfo($params['document']); |
|
44
|
|
|
$ext = strtolower($fI['extension']); |
|
45
|
|
|
$indexerObj->indexRegularDocument($params['alturl'], true, $params['document'], $ext); |
|
46
|
|
|
} else { |
|
47
|
|
|
$indexerObj->indexRegularDocument($params['document'], true); |
|
48
|
|
|
} |
|
49
|
|
|
// Return OK: |
|
50
|
|
|
return ['content' => []]; |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.