|
1
|
|
|
<?php |
|
2
|
|
|
namespace Fab\Vidi\Grid; |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* This file is part of the TYPO3 CMS project. |
|
6
|
|
|
* |
|
7
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
8
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
9
|
|
|
* of the License, or any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* For the full copyright and license information, please read the |
|
12
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
13
|
|
|
* |
|
14
|
|
|
* The TYPO3 project - inspiring people to share! |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
use Fab\Vidi\Tca\Tca; |
|
18
|
|
|
use TYPO3\CMS\Core\Imaging\Icon; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Class for editing mm relation between objects. |
|
22
|
|
|
*/ |
|
23
|
|
|
class RelationEditRenderer extends ColumnRendererAbstract |
|
24
|
|
|
{ |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @return string |
|
28
|
|
|
*/ |
|
29
|
|
|
public function render() |
|
30
|
|
|
{ |
|
31
|
|
|
$output = ''; |
|
32
|
|
|
if ($this->isBackendMode()) { |
|
33
|
|
|
$output = $this->renderForBackend(); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
return $output; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @return string |
|
41
|
|
|
*/ |
|
42
|
|
|
protected function renderForBackend() |
|
43
|
|
|
{ |
|
44
|
|
|
|
|
45
|
|
|
// Initialize url parameters array. |
|
46
|
|
|
$urlParameters = array( |
|
47
|
|
|
$this->getModuleLoader()->getParameterPrefix() => array( |
|
48
|
|
|
'controller' => 'Content', |
|
49
|
|
|
'action' => 'edit', |
|
50
|
|
|
'matches' => array('uid' => $this->object->getUid()), |
|
51
|
|
|
'fieldNameAndPath' => $this->getFieldName(), |
|
52
|
|
|
), |
|
53
|
|
|
); |
|
54
|
|
|
|
|
55
|
|
|
$fieldLabel = Tca::table()->field($this->getFieldName())->getLabel(); |
|
56
|
|
|
if ($fieldLabel) { |
|
57
|
|
|
$fieldLabel = str_replace(':', '', $fieldLabel); // sanitize label |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
return sprintf( |
|
61
|
|
|
'<div style="text-align: right" class="pull-right invisible"><a href="%s" class="btn-edit-relation" data-field-label="%s">%s</a></div>', |
|
62
|
|
|
$this->getModuleLoader()->getModuleUrl($urlParameters), |
|
63
|
|
|
$fieldLabel, |
|
64
|
|
|
$this->getIconFactory()->getIcon('actions-edit-add', Icon::SIZE_SMALL) |
|
65
|
|
|
); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Returns whether the current mode is Frontend |
|
70
|
|
|
* |
|
71
|
|
|
* @return bool |
|
72
|
|
|
*/ |
|
73
|
|
|
protected function isBackendMode() |
|
74
|
|
|
{ |
|
75
|
|
|
return TYPO3_MODE === 'BE'; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
} |
|
79
|
|
|
|