|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Edit link for the backend. |
|
5
|
|
|
*/ |
|
6
|
|
|
declare(strict_types = 1); |
|
7
|
|
|
|
|
8
|
|
|
namespace HDNET\Autoloader\ViewHelpers\Be; |
|
9
|
|
|
|
|
10
|
|
|
use TYPO3\CMS\Backend\Routing\UriBuilder; |
|
11
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Edit link for the backend. |
|
15
|
|
|
*/ |
|
16
|
|
|
class EditLinkViewHelper extends \TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* Specifies whether the escaping interceptors should be disabled or enabled for the result of renderChildren() calls within this ViewHelper. |
|
20
|
|
|
* |
|
21
|
|
|
* @see isChildrenEscapingEnabled() |
|
22
|
|
|
* |
|
23
|
|
|
* Note: If this is NULL the value of $this->escapingInterceptorEnabled is considered for backwards compatibility |
|
24
|
|
|
* |
|
25
|
|
|
* @var bool |
|
26
|
|
|
* |
|
27
|
|
|
* @api |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $escapeChildren = false; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Specifies whether the escaping interceptors should be disabled or enabled for the render-result of this ViewHelper. |
|
33
|
|
|
* |
|
34
|
|
|
* @see isOutputEscapingEnabled() |
|
35
|
|
|
* |
|
36
|
|
|
* @var bool |
|
37
|
|
|
* |
|
38
|
|
|
* @api |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $escapeOutput = false; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Init arguments. |
|
44
|
|
|
*/ |
|
45
|
|
|
public function initializeArguments(): void |
|
46
|
|
|
{ |
|
47
|
|
|
parent::initializeArguments(); |
|
48
|
|
|
$this->registerArgument('data', 'array', 'Row of the content element', true, []); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Render a edit link for the backend preview. |
|
53
|
|
|
* |
|
54
|
|
|
* @return string |
|
55
|
|
|
*/ |
|
56
|
|
|
public function render() |
|
57
|
|
|
{ |
|
58
|
|
|
$urlParameter = [ |
|
59
|
|
|
'edit[tt_content][' . $this->arguments['data']['uid'] . ']' => 'edit', |
|
60
|
|
|
'returnUrl' => GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'), |
|
61
|
|
|
]; |
|
62
|
|
|
|
|
63
|
|
|
return '<a href="' . $this->getModuleUrl('record_edit', $urlParameter) . '">' . $this->renderChildren() . '</a>'; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* getModuleUrl. |
|
68
|
|
|
* |
|
69
|
|
|
* @return string |
|
70
|
|
|
*/ |
|
71
|
|
|
protected function getModuleUrl(string $moduleName, array $urlParameters) |
|
72
|
|
|
{ |
|
73
|
|
|
/** @var UriBuilder $uriBuilder */ |
|
74
|
|
|
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); |
|
75
|
|
|
|
|
76
|
|
|
return (string)$uriBuilder->buildUriFromRoute($moduleName, $urlParameters); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|