1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Wizard controller. |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace HDNET\Focuspoint\Controller\Wizard; |
8
|
|
|
|
9
|
|
|
use HDNET\Focuspoint\Service\WizardHandler\AbstractWizardHandler; |
10
|
|
|
use HDNET\Focuspoint\Service\WizardHandler\File; |
11
|
|
|
use HDNET\Focuspoint\Service\WizardHandler\FileReference; |
12
|
|
|
use HDNET\Focuspoint\Service\WizardHandler\Group; |
13
|
|
|
use Psr\Http\Message\ResponseInterface; |
14
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
15
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility; |
16
|
|
|
use TYPO3\CMS\Core\Http\HtmlResponse; |
17
|
|
|
use TYPO3\CMS\Core\Utility\ArrayUtility; |
18
|
|
|
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; |
19
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
20
|
|
|
use TYPO3\CMS\Core\Utility\HttpUtility; |
21
|
|
|
use TYPO3\CMS\Fluid\View\StandaloneView; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Wizard controller. |
25
|
|
|
*/ |
26
|
|
|
class FocuspointController |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Main action. |
30
|
|
|
* |
31
|
|
|
* @throws \Exception |
32
|
|
|
* |
33
|
|
|
* @return string |
34
|
|
|
*/ |
35
|
|
|
public function main() |
36
|
|
|
{ |
37
|
|
|
$handler = $this->getCurrentHandler(); |
38
|
|
|
$parameter = GeneralUtility::_GET(); |
39
|
|
|
if (isset($parameter['save'])) { |
40
|
|
|
if (\is_object($handler)) { |
41
|
|
|
$handler->setCurrentPoint($parameter['xValue'] * 100, $parameter['yValue'] * 100); |
42
|
|
|
} |
43
|
|
|
HttpUtility::redirect($parameter['P']['returnUrl']); |
44
|
|
|
} |
45
|
|
|
$saveArguments = [ |
46
|
|
|
'save' => 1, |
47
|
|
|
'P' => [ |
48
|
|
|
'returnUrl' => $parameter['P']['returnUrl'], |
49
|
|
|
], |
50
|
|
|
]; |
51
|
|
|
|
52
|
|
|
/** @var StandaloneView $template */ |
53
|
|
|
$template = GeneralUtility::makeInstance(StandaloneView::class); |
54
|
|
|
$template->setTemplatePathAndFilename(ExtensionManagementUtility::extPath( |
55
|
|
|
'focuspoint', |
56
|
|
|
'Resources/Private/Templates/Wizard/Focuspoint.html' |
57
|
|
|
)); |
58
|
|
|
|
59
|
|
|
if (\is_object($handler)) { |
60
|
|
|
ArrayUtility::mergeRecursiveWithOverrule($saveArguments, $handler->getArguments()); |
61
|
|
|
list($x, $y) = $handler->getCurrentPoint(); |
62
|
|
|
$template->assign('filePath', $handler->getPublicUrl()); |
63
|
|
|
$template->assign('currentLeft', (($x + 100) / 2) . '%'); |
64
|
|
|
$template->assign('currentTop', (($y - 100) / -2) . '%'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
$template->assign('saveUri', BackendUtility::getModuleUrl('focuspoint', $saveArguments)); |
|
|
|
|
68
|
|
|
|
69
|
|
|
return $template->render(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Returns the Module menu for the AJAX request. |
74
|
|
|
* |
75
|
|
|
* @param ServerRequestInterface $request |
76
|
|
|
* @param ResponseInterface $response |
77
|
|
|
* |
78
|
|
|
* @return ResponseInterface |
79
|
|
|
*/ |
80
|
|
|
public function mainAction(ServerRequestInterface $request, ResponseInterface $response = null) |
|
|
|
|
81
|
|
|
{ |
82
|
|
|
if($response === null) { |
83
|
|
|
$response = new HtmlResponse(''); |
84
|
|
|
} |
85
|
|
|
$content = $this->main(); |
86
|
|
|
$response->getBody()->write($content); |
87
|
|
|
|
88
|
|
|
return $response; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Get the current handler. |
93
|
|
|
* |
94
|
|
|
* @return AbstractWizardHandler|null |
95
|
|
|
*/ |
96
|
|
|
protected function getCurrentHandler() |
97
|
|
|
{ |
98
|
|
|
foreach ($this->getWizardHandler() as $handler) { |
99
|
|
|
/** @var $handler AbstractWizardHandler */ |
100
|
|
|
if ($handler->canHandle()) { |
101
|
|
|
return $handler; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Get the wizard handler. |
108
|
|
|
* |
109
|
|
|
* @return array |
110
|
|
|
*/ |
111
|
|
|
protected function getWizardHandler() |
112
|
|
|
{ |
113
|
|
|
return [ |
114
|
|
|
GeneralUtility::makeInstance(File::class), |
115
|
|
|
GeneralUtility::makeInstance(FileReference::class), |
116
|
|
|
GeneralUtility::makeInstance(Group::class), |
117
|
|
|
]; |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.