|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Abstract wizard handler. |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace HDNET\Focuspoint\Service\WizardHandler; |
|
8
|
|
|
|
|
9
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
10
|
|
|
use TYPO3\CMS\Core\Utility\MathUtility; |
|
11
|
|
|
use TYPO3\CMS\Core\Utility\PathUtility; |
|
12
|
|
|
use TYPO3\CMS\Extbase\Object\ObjectManager; |
|
13
|
|
|
use TYPO3\CMS\Extbase\Service\ImageService; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Abstract wizard handler. |
|
17
|
|
|
*/ |
|
18
|
|
|
abstract class AbstractWizardHandler |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* Check if the handler can handle the current request. |
|
22
|
|
|
* |
|
23
|
|
|
* @return true |
|
24
|
|
|
*/ |
|
25
|
|
|
abstract public function canHandle(); |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* get the arguments for same request call. |
|
29
|
|
|
* |
|
30
|
|
|
* @return array |
|
31
|
|
|
*/ |
|
32
|
|
|
abstract public function getArguments(); |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Return the current point (between -100 and 100). |
|
36
|
|
|
* |
|
37
|
|
|
* @return array |
|
38
|
|
|
*/ |
|
39
|
|
|
abstract public function getCurrentPoint(); |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Set the point (between -100 and 100). |
|
43
|
|
|
* |
|
44
|
|
|
* @param int $x |
|
45
|
|
|
* @param int $y |
|
46
|
|
|
*/ |
|
47
|
|
|
abstract public function setCurrentPoint($x, $y); |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Get the public URL for the current handler. |
|
51
|
|
|
* |
|
52
|
|
|
* @return string |
|
53
|
|
|
*/ |
|
54
|
|
|
abstract public function getPublicUrl(); |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @param string $url |
|
58
|
|
|
* |
|
59
|
|
|
* @return string |
|
60
|
|
|
*/ |
|
61
|
|
|
protected function displayableImageUrl($url) |
|
62
|
|
|
{ |
|
63
|
|
|
if (\in_array(PathUtility::pathinfo($url, PATHINFO_EXTENSION), ['tif', 'tiff'], true)) { |
|
64
|
|
|
$objectManager = new ObjectManager(); |
|
65
|
|
|
/** @var ImageService $imageService */ |
|
66
|
|
|
$imageService = $objectManager->get(ImageService::class); |
|
67
|
|
|
$image = $imageService->getImage($url, null, null); |
|
68
|
|
|
$processedImage = $imageService->applyProcessingInstructions($image, [ |
|
69
|
|
|
'width' => '800', |
|
70
|
|
|
]); |
|
71
|
|
|
$url = $imageService->getImageUri($processedImage); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
if(filter_var($url, FILTER_VALIDATE_URL)) { |
|
75
|
|
|
return $url; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
return GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . \ltrim($url, '/'); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Cleanup the position of both values. |
|
83
|
|
|
* |
|
84
|
|
|
* @param array $position |
|
85
|
|
|
* |
|
86
|
|
|
* @return int[] |
|
87
|
|
|
*/ |
|
88
|
|
|
protected function cleanupPosition(array $position): array |
|
89
|
|
|
{ |
|
90
|
|
|
return [ |
|
91
|
|
|
MathUtility::forceIntegerInRange((int) $position[0], -100, 100, 0), |
|
92
|
|
|
MathUtility::forceIntegerInRange((int) $position[1], -100, 100, 0), |
|
93
|
|
|
]; |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|