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 AOE\Crawler\Domain\Repository\ConfigurationRepository; |
23
|
|
|
use TYPO3\CMS\Backend\ContextMenu\ItemProviders\AbstractProvider; |
24
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility; |
25
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Provides a ContextMenu item |
29
|
|
|
* @internal since v9.2.5 |
30
|
|
|
*/ |
31
|
|
|
class ItemProvider extends AbstractProvider |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* @var array |
35
|
|
|
*/ |
36
|
|
|
protected $itemsConfiguration = [ |
37
|
|
|
'crawler' => [ |
38
|
|
|
'type' => 'item', |
39
|
|
|
'label' => 'LLL:EXT:crawler/Resources/Private/Language/Backend.xlf:contextMenu.label', |
40
|
|
|
'iconIdentifier' => 'tx-crawler', |
41
|
|
|
'callbackAction' => 'crawler', |
42
|
|
|
], |
43
|
|
|
]; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Item is added only for crawler configurations |
47
|
|
|
*/ |
48
|
|
|
public function canHandle(): bool |
49
|
|
|
{ |
50
|
|
|
return $this->table === ConfigurationRepository::TABLE_NAME; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* This needs to be lower than priority of the RecordProvider |
55
|
|
|
*/ |
56
|
|
|
public function getPriority(): int |
57
|
|
|
{ |
58
|
|
|
return 50; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Adds the crawler info |
63
|
|
|
*/ |
64
|
|
|
public function addItems(array $items): array |
65
|
|
|
{ |
66
|
|
|
$localItems = $this->prepareItems($this->itemsConfiguration); |
67
|
|
|
return $items + $localItems; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
protected function getAdditionalAttributes(string $itemName): array |
71
|
|
|
{ |
72
|
|
|
$crawlerConfiguration = BackendUtility::getRecordWSOL($this->table, $this->identifier); |
|
|
|
|
73
|
|
|
|
74
|
|
|
$additionalParameters = []; |
75
|
|
|
$additionalParameters[] = 'SET[function]=AOE\Crawler\Backend\BackendModule'; |
76
|
|
|
$additionalParameters[] = 'SET[crawlaction]=start'; |
77
|
|
|
$additionalParameters[] = 'configurationSelection[]=' . $crawlerConfiguration['name']; |
78
|
|
|
return [ |
79
|
|
|
'onclick' => 'top.goToModule(\'web_info\', 1, ' . GeneralUtility::quoteJSvalue('&' . implode('&', $additionalParameters)) . ');', |
80
|
|
|
]; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|