1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace ApacheSolrForTypo3\Tika\Hooks; |
6
|
|
|
|
7
|
|
|
/* |
8
|
|
|
* This file is part of the TYPO3 CMS project. |
9
|
|
|
* |
10
|
|
|
* It is free software; you can redistribute it and/or modify it under |
11
|
|
|
* the terms of the GNU General Public License, either version 2 |
12
|
|
|
* of the License, or any later version. |
13
|
|
|
* |
14
|
|
|
* For the full copyright and license information, please read the |
15
|
|
|
* LICENSE.txt file that was distributed with this source code. |
16
|
|
|
* |
17
|
|
|
* The TYPO3 project - inspiring people to share! |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
use TYPO3\CMS\Backend\Controller\BackendController; |
21
|
|
|
use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException; |
22
|
|
|
use TYPO3\CMS\Backend\Routing\UriBuilder; |
23
|
|
|
use TYPO3\CMS\Core\Page\PageRenderer; |
24
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* This class adds Filelist related JavaScript to the backend |
28
|
|
|
*/ |
29
|
|
|
class BackendControllerHook |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* Adds Filelist JavaScript used e.g. by context menu |
33
|
|
|
* |
34
|
|
|
* @param array $configuration |
35
|
|
|
* @param BackendController $backendController |
36
|
|
|
* @throws RouteNotFoundException |
37
|
|
|
* @noinspection PhpUnused |
38
|
|
|
* @noinspection PhpUnusedParameterInspection |
39
|
|
|
*/ |
40
|
|
|
public function addJavaScript(array $configuration, BackendController $backendController): void |
41
|
|
|
{ |
42
|
|
|
$this->getPageRenderer()->addInlineSetting( |
43
|
|
|
'TikaPreview', |
44
|
|
|
'moduleUrl', |
45
|
|
|
(string)$this->getBackendUriBuilder()->buildUriFromRoute('tika_preview') |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @return PageRenderer |
51
|
|
|
* @noinspection PhpIncompatibleReturnTypeInspection |
52
|
|
|
*/ |
53
|
|
|
protected function getPageRenderer(): PageRenderer |
54
|
|
|
{ |
55
|
|
|
return GeneralUtility::makeInstance(PageRenderer::class); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return UriBuilder |
60
|
|
|
* @noinspection PhpIncompatibleReturnTypeInspection |
61
|
|
|
*/ |
62
|
|
|
protected function getBackendUriBuilder(): UriBuilder |
63
|
|
|
{ |
64
|
|
|
return GeneralUtility::makeInstance(UriBuilder::class); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|