41541d9b447d0f5bb49a592a4fd43aea34ccff5b
[Packages/TYPO3.CMS.git] / typo3 / sysext / indexed_search / Classes / Hook / CrawlerFilesHook.php
1 <?php
2 namespace TYPO3\CMS\IndexedSearch\Hook;
3
4 /**
5 * Crawler hook for indexed search. Works with the "crawler" extension
6 * This hook is specifically used to index external files found on pages through the crawler extension.
7 *
8 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
9 * @see tx_indexedsearch_indexer::extractLinks()
10 */
11 class CrawlerFilesHook {
12
13 /**
14 * Call back function for execution of a log element
15 *
16 * @param array Params from log element.
17 * @param object Parent object (tx_crawler lib)
18 * @return array Result array
19 * @todo Define visibility
20 */
21 public function crawler_execute($params, &$pObj) {
22 // Load indexer if not yet.
23 $this->loadIndexerClass();
24 if (is_array($params['conf'])) {
25 // Initialize the indexer class:
26 $indexerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\IndexedSearch\\Indexer');
27 $indexerObj->conf = $params['conf'];
28 $indexerObj->init();
29 // Index document:
30 if ($params['alturl']) {
31 $fI = pathinfo($params['document']);
32 $ext = strtolower($fI['extension']);
33 $indexerObj->indexRegularDocument($params['alturl'], TRUE, $params['document'], $ext);
34 } else {
35 $indexerObj->indexRegularDocument($params['document'], TRUE);
36 }
37 // Return OK:
38 return array('content' => array());
39 }
40 }
41
42 /**
43 * Include indexer class.
44 *
45 * @return void
46 * @todo Define visibility
47 */
48 public function loadIndexerClass() {
49 global $TYPO3_CONF_VARS;
50 require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('indexed_search') . 'class.indexer.php';
51 }
52
53 }
54
55
56 ?>