1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace AOE\Crawler\ContextMenu; |
||
6 | |||
7 | /* |
||
8 | * (c) 2020 AOE GmbH <[email protected]> |
||
9 | * |
||
10 | * This file is part of the TYPO3 Crawler Extension. |
||
11 | * |
||
12 | * It is free software; you can redistribute it and/or modify it under |
||
13 | * the terms of the GNU General Public License, either version 2 |
||
14 | * of the License, or any later version. |
||
15 | * |
||
16 | * For the full copyright and license information, please read the |
||
17 | * LICENSE.txt file that was distributed with this source code. |
||
18 | * |
||
19 | * The TYPO3 project - inspiring people to share! |
||
20 | */ |
||
21 | |||
22 | use TYPO3\CMS\Backend\ContextMenu\ItemProviders\AbstractProvider; |
||
23 | use TYPO3\CMS\Backend\Utility\BackendUtility; |
||
24 | use TYPO3\CMS\Core\Utility\GeneralUtility; |
||
25 | |||
26 | /** |
||
27 | * Provides a ContextMenu item |
||
28 | */ |
||
29 | class ItemProvider extends AbstractProvider |
||
30 | { |
||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $itemsConfiguration = [ |
||
35 | 'crawler' => [ |
||
36 | 'type' => 'item', |
||
37 | 'label' => 'LLL:EXT:crawler/Resources/Private/Language/Backend.xlf:contextMenu.label', |
||
38 | 'iconIdentifier' => 'tx-crawler', |
||
39 | 'callbackAction' => 'crawler', |
||
40 | ], |
||
41 | ]; |
||
42 | |||
43 | /** |
||
44 | * Item is added only for crawler configurations |
||
45 | */ |
||
46 | public function canHandle(): bool |
||
47 | { |
||
48 | return $this->table === 'tx_crawler_configuration'; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * This needs to be lower than priority of the RecordProvider |
||
53 | */ |
||
54 | public function getPriority(): int |
||
55 | { |
||
56 | return 50; |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Adds the crawler info |
||
61 | */ |
||
62 | public function addItems(array $items): array |
||
63 | { |
||
64 | $localItems = $this->prepareItems($this->itemsConfiguration); |
||
65 | return $items + $localItems; |
||
66 | } |
||
67 | |||
68 | protected function getAdditionalAttributes(string $itemName): array |
||
69 | { |
||
70 | $crawlerConfiguration = BackendUtility::getRecordWSOL($this->table, $this->identifier); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
71 | |||
72 | $additionalParameters = []; |
||
73 | $additionalParameters[] = 'SET[function]=AOE\Crawler\Backend\BackendModule'; |
||
74 | $additionalParameters[] = 'SET[crawlaction]=start'; |
||
75 | $additionalParameters[] = 'configurationSelection[]=' . $crawlerConfiguration['name']; |
||
76 | return [ |
||
77 | 'onclick' => 'top.goToModule(\'web_info\', 1, ' . GeneralUtility::quoteJSvalue('&' . implode('&', $additionalParameters)) . ');', |
||
78 | ]; |
||
79 | } |
||
80 | } |
||
81 |