Completed
Push — master ( b70884...5fde98 )
by Fabien
55:11
created
Classes/Facet/FacetSuggestionService.php 1 patch
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -21,103 +21,103 @@
 block discarded – undo
21 21
  */
22 22
 class FacetSuggestionService
23 23
 {
24
-    /**
25
-     * Retrieve possible suggestions for a field name
26
-     *
27
-     * @param string $fieldNameAndPath
28
-     * @return array
29
-     */
30
-    public function getSuggestions($fieldNameAndPath): array
31
-    {
32
-        $values = [];
33
-
34
-        $dataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath);
35
-        $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
36
-
37
-        if (Tca::grid()->facet($fieldNameAndPath)->hasSuggestions()) {
38
-            $values = Tca::grid()->facet($fieldNameAndPath)->getSuggestions();
39
-        } elseif (Tca::table($dataType)->hasField($fieldName)) {
40
-            if (Tca::table($dataType)->field($fieldName)->hasRelation()) {
41
-                // Fetch the adequate repository
42
-                $foreignTable = Tca::table($dataType)->field($fieldName)->getForeignTable();
43
-                $contentRepository = ContentRepositoryFactory::getInstance($foreignTable);
44
-                $table = Tca::table($foreignTable);
45
-
46
-                // Initialize the matcher object.
47
-                $matcher = MatcherObjectFactory::getInstance()->getMatcher([], $foreignTable);
48
-
49
-                $numberOfValues = $contentRepository->countBy($matcher);
50
-                if ($numberOfValues <= $this->getLimit()) {
51
-                    $contents = $contentRepository->findBy($matcher);
52
-
53
-                    foreach ($contents as $content) {
54
-                        $values[] = array($content->getUid() => $content[$table->getLabelField()]);
55
-                    }
56
-                }
57
-            } elseif (!Tca::table($dataType)->field($fieldName)->isTextArea()) { // We don't want suggestion if field is text area.
58
-                // Fetch the adequate repository
59
-                /** @var ContentRepository $contentRepository */
60
-                $contentRepository = ContentRepositoryFactory::getInstance($dataType);
61
-
62
-                // Initialize some objects related to the query
63
-                $matcher = MatcherObjectFactory::getInstance()->getMatcher([], $dataType);
64
-
65
-                // Count the number of objects.
66
-                $numberOfValues = $contentRepository->countDistinctValues($fieldName, $matcher);
67
-
68
-                // Only returns suggestion if there are not too many for the browser.
69
-                if ($numberOfValues <= $this->getLimit()) {
70
-                    // Query the repository.
71
-                    $contents = $contentRepository->findDistinctValues($fieldName, $matcher);
72
-
73
-                    foreach ($contents as $content) {
74
-                        $value = $content[$fieldName];
75
-                        $label = $content[$fieldName];
76
-                        if (Tca::table($dataType)->field($fieldName)->isSelect()) {
77
-                            $label = Tca::table($dataType)->field($fieldName)->getLabelForItem($value);
78
-                        }
79
-
80
-                        $values[] = $label;
81
-                    }
82
-                }
83
-            }
84
-        }
85
-        return $values;
86
-    }
87
-
88
-    /**
89
-     * Return from settings the suggestion limit.
90
-     *
91
-     * @return int
92
-     */
93
-    protected function getLimit(): int
94
-    {
95
-        $settings = $this->getSettings();
96
-        $suggestionLimit = (int)$settings['suggestionLimit'];
97
-        if ($suggestionLimit <= 0) {
98
-            $suggestionLimit = 1000;
99
-        }
100
-        return $suggestionLimit;
101
-    }
102
-
103
-    /**
104
-     * @return FieldPathResolver|object
105
-     */
106
-    protected function getFieldPathResolver()
107
-    {
108
-        return GeneralUtility::makeInstance(FieldPathResolver::class);
109
-    }
110
-
111
-    /**
112
-     * Returns the module settings.
113
-     *
114
-     * @return array
115
-     */
116
-    protected function getSettings()
117
-    {
118
-        /** @var BackendConfigurationManager $backendConfigurationManager */
119
-        $backendConfigurationManager = GeneralUtility::makeInstance(BackendConfigurationManager::class);
120
-        $configuration = $backendConfigurationManager->getTypoScriptSetup();
121
-        return $configuration['module.']['tx_vidi.']['settings.'];
122
-    }
24
+	/**
25
+	 * Retrieve possible suggestions for a field name
26
+	 *
27
+	 * @param string $fieldNameAndPath
28
+	 * @return array
29
+	 */
30
+	public function getSuggestions($fieldNameAndPath): array
31
+	{
32
+		$values = [];
33
+
34
+		$dataType = $this->getFieldPathResolver()->getDataType($fieldNameAndPath);
35
+		$fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
36
+
37
+		if (Tca::grid()->facet($fieldNameAndPath)->hasSuggestions()) {
38
+			$values = Tca::grid()->facet($fieldNameAndPath)->getSuggestions();
39
+		} elseif (Tca::table($dataType)->hasField($fieldName)) {
40
+			if (Tca::table($dataType)->field($fieldName)->hasRelation()) {
41
+				// Fetch the adequate repository
42
+				$foreignTable = Tca::table($dataType)->field($fieldName)->getForeignTable();
43
+				$contentRepository = ContentRepositoryFactory::getInstance($foreignTable);
44
+				$table = Tca::table($foreignTable);
45
+
46
+				// Initialize the matcher object.
47
+				$matcher = MatcherObjectFactory::getInstance()->getMatcher([], $foreignTable);
48
+
49
+				$numberOfValues = $contentRepository->countBy($matcher);
50
+				if ($numberOfValues <= $this->getLimit()) {
51
+					$contents = $contentRepository->findBy($matcher);
52
+
53
+					foreach ($contents as $content) {
54
+						$values[] = array($content->getUid() => $content[$table->getLabelField()]);
55
+					}
56
+				}
57
+			} elseif (!Tca::table($dataType)->field($fieldName)->isTextArea()) { // We don't want suggestion if field is text area.
58
+				// Fetch the adequate repository
59
+				/** @var ContentRepository $contentRepository */
60
+				$contentRepository = ContentRepositoryFactory::getInstance($dataType);
61
+
62
+				// Initialize some objects related to the query
63
+				$matcher = MatcherObjectFactory::getInstance()->getMatcher([], $dataType);
64
+
65
+				// Count the number of objects.
66
+				$numberOfValues = $contentRepository->countDistinctValues($fieldName, $matcher);
67
+
68
+				// Only returns suggestion if there are not too many for the browser.
69
+				if ($numberOfValues <= $this->getLimit()) {
70
+					// Query the repository.
71
+					$contents = $contentRepository->findDistinctValues($fieldName, $matcher);
72
+
73
+					foreach ($contents as $content) {
74
+						$value = $content[$fieldName];
75
+						$label = $content[$fieldName];
76
+						if (Tca::table($dataType)->field($fieldName)->isSelect()) {
77
+							$label = Tca::table($dataType)->field($fieldName)->getLabelForItem($value);
78
+						}
79
+
80
+						$values[] = $label;
81
+					}
82
+				}
83
+			}
84
+		}
85
+		return $values;
86
+	}
87
+
88
+	/**
89
+	 * Return from settings the suggestion limit.
90
+	 *
91
+	 * @return int
92
+	 */
93
+	protected function getLimit(): int
94
+	{
95
+		$settings = $this->getSettings();
96
+		$suggestionLimit = (int)$settings['suggestionLimit'];
97
+		if ($suggestionLimit <= 0) {
98
+			$suggestionLimit = 1000;
99
+		}
100
+		return $suggestionLimit;
101
+	}
102
+
103
+	/**
104
+	 * @return FieldPathResolver|object
105
+	 */
106
+	protected function getFieldPathResolver()
107
+	{
108
+		return GeneralUtility::makeInstance(FieldPathResolver::class);
109
+	}
110
+
111
+	/**
112
+	 * Returns the module settings.
113
+	 *
114
+	 * @return array
115
+	 */
116
+	protected function getSettings()
117
+	{
118
+		/** @var BackendConfigurationManager $backendConfigurationManager */
119
+		$backendConfigurationManager = GeneralUtility::makeInstance(BackendConfigurationManager::class);
120
+		$configuration = $backendConfigurationManager->getTypoScriptSetup();
121
+		return $configuration['module.']['tx_vidi.']['settings.'];
122
+	}
123 123
 }
Please login to merge, or discard this patch.
Classes/Grid/ColumnRendererAbstract.php 2 patches
Indentation   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -19,190 +19,190 @@
 block discarded – undo
19 19
  */
20 20
 abstract class ColumnRendererAbstract implements ColumnRendererInterface
21 21
 {
22
-    /**
23
-     * The content object.
24
-     *
25
-     * @var Content
26
-     */
27
-    protected $object;
28
-
29
-    /**
30
-     * @var string
31
-     */
32
-    protected $fieldName;
33
-
34
-    /**
35
-     * @var int
36
-     */
37
-    protected $rowIndex;
38
-
39
-    /**
40
-     * @var array
41
-     */
42
-    protected $fieldConfiguration = [];
43
-
44
-    /**
45
-     * @var array
46
-     */
47
-    protected $gridRendererConfiguration = [];
48
-
49
-    /**
50
-     * @var array
51
-     */
52
-    protected $configuration = [];
53
-
54
-    /**
55
-     * Constructor of a Generic component in Vidi.
56
-     *
57
-     * @param array $configuration
58
-     * @param array $legacyParameterConfiguration
59
-     */
60
-    public function __construct($configuration = [], $legacyParameterConfiguration = array())
61
-    {
62
-        if (is_string($configuration)) {
63
-            $configuration = $legacyParameterConfiguration;
64
-            trigger_error('ColumnRendererAbstract: first parameter must now be an array. Please edit me in ' . get_class($this), E_USER_DEPRECATED);
65
-        }
66
-        $this->configuration = $configuration;
67
-    }
68
-
69
-    /**
70
-     * @return array
71
-     */
72
-    public function getConfiguration()
73
-    {
74
-        return $this->configuration;
75
-    }
76
-
77
-    /**
78
-     * @return Content
79
-     */
80
-    public function getObject()
81
-    {
82
-        return $this->object;
83
-    }
84
-
85
-    /**
86
-     * @param Content $object
87
-     * @return $this
88
-     */
89
-    public function setObject($object)
90
-    {
91
-        $this->object = $object;
92
-        return $this;
93
-    }
94
-
95
-    /**
96
-     * @return string
97
-     */
98
-    public function getFieldName()
99
-    {
100
-        return $this->fieldName;
101
-    }
102
-
103
-    /**
104
-     * @param string $fieldName
105
-     * @return $this
106
-     */
107
-    public function setFieldName($fieldName)
108
-    {
109
-        $this->fieldName = $fieldName;
110
-        return $this;
111
-    }
112
-
113
-    /**
114
-     * @return int
115
-     */
116
-    public function getRowIndex()
117
-    {
118
-        return $this->rowIndex;
119
-    }
120
-
121
-    /**
122
-     * @param int $rowIndex
123
-     * @return $this
124
-     */
125
-    public function setRowIndex($rowIndex)
126
-    {
127
-        $this->rowIndex = $rowIndex;
128
-        return $this;
129
-    }
130
-
131
-    /**
132
-     * @return array
133
-     */
134
-    public function getFieldConfiguration()
135
-    {
136
-        return $this->fieldConfiguration;
137
-    }
138
-
139
-    /**
140
-     * @param array $fieldConfiguration
141
-     * @return $this
142
-     */
143
-    public function setFieldConfiguration($fieldConfiguration)
144
-    {
145
-        $this->fieldConfiguration = $fieldConfiguration;
146
-        return $this;
147
-    }
148
-
149
-    /**
150
-     * @return array
151
-     */
152
-    public function getGridRendererConfiguration()
153
-    {
154
-        return $this->gridRendererConfiguration;
155
-    }
156
-
157
-    /**
158
-     * @param array $gridRendererConfiguration
159
-     * @return $this
160
-     */
161
-    public function setGridRendererConfiguration($gridRendererConfiguration)
162
-    {
163
-        $this->gridRendererConfiguration = $gridRendererConfiguration;
164
-        return $this;
165
-    }
166
-
167
-    /**
168
-     * Escapes special characters with their escaped counterparts as needed using PHPs htmlentities() function.
169
-     *
170
-     * @param string $value string to format
171
-     * @param bool $keepQuotes if TRUE, single and double quotes won't be replaced (sets ENT_NOQUOTES flag)
172
-     * @param string $encoding
173
-     * @return string
174
-     * @see http://www.php.net/manual/function.htmlentities.php
175
-     * @api
176
-     */
177
-    protected function secure($value, $keepQuotes = false, $encoding = 'UTF-8')
178
-    {
179
-        $flags = $keepQuotes ? ENT_NOQUOTES : ENT_COMPAT;
180
-        return htmlspecialchars($value, $flags, $encoding);
181
-    }
182
-
183
-    /**
184
-     * Get the Vidi Module Loader.
185
-     *
186
-     * @return object|ModuleLoader
187
-     */
188
-    protected function getModuleLoader()
189
-    {
190
-        return GeneralUtility::makeInstance(ModuleLoader::class);
191
-    }
192
-
193
-    /**
194
-     * @return object|IconFactory
195
-     */
196
-    protected function getIconFactory()
197
-    {
198
-        return GeneralUtility::makeInstance(IconFactory::class);
199
-    }
200
-
201
-    /**
202
-     * @return object|LanguageService
203
-     */
204
-    protected function getLanguageService()
205
-    {
206
-        return GeneralUtility::makeInstance(LanguageService::class);
207
-    }
22
+	/**
23
+	 * The content object.
24
+	 *
25
+	 * @var Content
26
+	 */
27
+	protected $object;
28
+
29
+	/**
30
+	 * @var string
31
+	 */
32
+	protected $fieldName;
33
+
34
+	/**
35
+	 * @var int
36
+	 */
37
+	protected $rowIndex;
38
+
39
+	/**
40
+	 * @var array
41
+	 */
42
+	protected $fieldConfiguration = [];
43
+
44
+	/**
45
+	 * @var array
46
+	 */
47
+	protected $gridRendererConfiguration = [];
48
+
49
+	/**
50
+	 * @var array
51
+	 */
52
+	protected $configuration = [];
53
+
54
+	/**
55
+	 * Constructor of a Generic component in Vidi.
56
+	 *
57
+	 * @param array $configuration
58
+	 * @param array $legacyParameterConfiguration
59
+	 */
60
+	public function __construct($configuration = [], $legacyParameterConfiguration = array())
61
+	{
62
+		if (is_string($configuration)) {
63
+			$configuration = $legacyParameterConfiguration;
64
+			trigger_error('ColumnRendererAbstract: first parameter must now be an array. Please edit me in ' . get_class($this), E_USER_DEPRECATED);
65
+		}
66
+		$this->configuration = $configuration;
67
+	}
68
+
69
+	/**
70
+	 * @return array
71
+	 */
72
+	public function getConfiguration()
73
+	{
74
+		return $this->configuration;
75
+	}
76
+
77
+	/**
78
+	 * @return Content
79
+	 */
80
+	public function getObject()
81
+	{
82
+		return $this->object;
83
+	}
84
+
85
+	/**
86
+	 * @param Content $object
87
+	 * @return $this
88
+	 */
89
+	public function setObject($object)
90
+	{
91
+		$this->object = $object;
92
+		return $this;
93
+	}
94
+
95
+	/**
96
+	 * @return string
97
+	 */
98
+	public function getFieldName()
99
+	{
100
+		return $this->fieldName;
101
+	}
102
+
103
+	/**
104
+	 * @param string $fieldName
105
+	 * @return $this
106
+	 */
107
+	public function setFieldName($fieldName)
108
+	{
109
+		$this->fieldName = $fieldName;
110
+		return $this;
111
+	}
112
+
113
+	/**
114
+	 * @return int
115
+	 */
116
+	public function getRowIndex()
117
+	{
118
+		return $this->rowIndex;
119
+	}
120
+
121
+	/**
122
+	 * @param int $rowIndex
123
+	 * @return $this
124
+	 */
125
+	public function setRowIndex($rowIndex)
126
+	{
127
+		$this->rowIndex = $rowIndex;
128
+		return $this;
129
+	}
130
+
131
+	/**
132
+	 * @return array
133
+	 */
134
+	public function getFieldConfiguration()
135
+	{
136
+		return $this->fieldConfiguration;
137
+	}
138
+
139
+	/**
140
+	 * @param array $fieldConfiguration
141
+	 * @return $this
142
+	 */
143
+	public function setFieldConfiguration($fieldConfiguration)
144
+	{
145
+		$this->fieldConfiguration = $fieldConfiguration;
146
+		return $this;
147
+	}
148
+
149
+	/**
150
+	 * @return array
151
+	 */
152
+	public function getGridRendererConfiguration()
153
+	{
154
+		return $this->gridRendererConfiguration;
155
+	}
156
+
157
+	/**
158
+	 * @param array $gridRendererConfiguration
159
+	 * @return $this
160
+	 */
161
+	public function setGridRendererConfiguration($gridRendererConfiguration)
162
+	{
163
+		$this->gridRendererConfiguration = $gridRendererConfiguration;
164
+		return $this;
165
+	}
166
+
167
+	/**
168
+	 * Escapes special characters with their escaped counterparts as needed using PHPs htmlentities() function.
169
+	 *
170
+	 * @param string $value string to format
171
+	 * @param bool $keepQuotes if TRUE, single and double quotes won't be replaced (sets ENT_NOQUOTES flag)
172
+	 * @param string $encoding
173
+	 * @return string
174
+	 * @see http://www.php.net/manual/function.htmlentities.php
175
+	 * @api
176
+	 */
177
+	protected function secure($value, $keepQuotes = false, $encoding = 'UTF-8')
178
+	{
179
+		$flags = $keepQuotes ? ENT_NOQUOTES : ENT_COMPAT;
180
+		return htmlspecialchars($value, $flags, $encoding);
181
+	}
182
+
183
+	/**
184
+	 * Get the Vidi Module Loader.
185
+	 *
186
+	 * @return object|ModuleLoader
187
+	 */
188
+	protected function getModuleLoader()
189
+	{
190
+		return GeneralUtility::makeInstance(ModuleLoader::class);
191
+	}
192
+
193
+	/**
194
+	 * @return object|IconFactory
195
+	 */
196
+	protected function getIconFactory()
197
+	{
198
+		return GeneralUtility::makeInstance(IconFactory::class);
199
+	}
200
+
201
+	/**
202
+	 * @return object|LanguageService
203
+	 */
204
+	protected function getLanguageService()
205
+	{
206
+		return GeneralUtility::makeInstance(LanguageService::class);
207
+	}
208 208
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
     {
62 62
         if (is_string($configuration)) {
63 63
             $configuration = $legacyParameterConfiguration;
64
-            trigger_error('ColumnRendererAbstract: first parameter must now be an array. Please edit me in ' . get_class($this), E_USER_DEPRECATED);
64
+            trigger_error('ColumnRendererAbstract: first parameter must now be an array. Please edit me in '.get_class($this), E_USER_DEPRECATED);
65 65
         }
66 66
         $this->configuration = $configuration;
67 67
     }
Please login to merge, or discard this patch.
Classes/Grid/RelationRenderer.php 1 patch
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -20,150 +20,150 @@
 block discarded – undo
20 20
  */
21 21
 class RelationRenderer extends ColumnRendererAbstract
22 22
 {
23
-    /**
24
-     * Render a representation of the relation on the GUI.
25
-     *
26
-     * @return string
27
-     */
28
-    public function render()
29
-    {
30
-        if ($this->isBackendMode()) {
31
-            $output = $this->renderForBackend();
32
-        } else {
33
-            $output = $this->renderForFrontend();
34
-        }
35
-
36
-        return $output;
37
-    }
38
-
39
-    /**
40
-     * @return string
41
-     */
42
-    protected function renderForBackend()
43
-    {
44
-        $output = '';
45
-
46
-        // Get label of the foreign table.
47
-        $foreignLabelField = $this->getForeignTableLabelField($this->fieldName);
48
-
49
-        if (Tca::table($this->object)->field($this->fieldName)->hasOne()) {
50
-            $foreignObject = $this->object[$this->fieldName];
51
-
52
-            if ($foreignObject) {
53
-                $output = sprintf(
54
-                    '<a href="%s" data-uid="%s" class="btn-edit invisible">%s</a> <span>%s</span>',
55
-                    $this->getEditUri($foreignObject),
56
-                    $this->object->getUid(),
57
-                    $this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL),
58
-                    $foreignObject[$foreignLabelField]
59
-                );
60
-            }
61
-        } elseif (Tca::table($this->object)->field($this->fieldName)->hasMany()) {
62
-            if (!empty($this->object[$this->fieldName])) {
63
-                /** @var $foreignObject \Fab\Vidi\Domain\Model\Content */
64
-                foreach ($this->object[$this->fieldName] as $foreignObject) {
65
-                    $output .= sprintf(
66
-                        '<li><a href="%s" data-uid="%s" class="btn-edit invisible">%s</a> <span>%s</span></li>',
67
-                        $this->getEditUri($foreignObject),
68
-                        $this->object->getUid(),
69
-                        $this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL),
70
-                        $foreignObject[$foreignLabelField]
71
-                    );
72
-                }
73
-                $output = sprintf('<ul class="list-unstyled">%s</ul>', $output);
74
-            }
75
-        }
76
-        return $output;
77
-    }
78
-
79
-    /**
80
-     * @return string
81
-     */
82
-    protected function renderForFrontend()
83
-    {
84
-        $output = '';
85
-
86
-        // Get label of the foreign table.
87
-        $foreignLabelField = $this->getForeignTableLabelField($this->fieldName);
88
-
89
-        if (Tca::table($this->object)->field($this->fieldName)->hasOne()) {
90
-            $foreignObject = $this->object[$this->fieldName];
91
-
92
-            if ($foreignObject) {
93
-                $output = sprintf(
94
-                    '%s',
95
-                    $foreignObject[$foreignLabelField]
96
-                );
97
-            }
98
-        } elseif (Tca::table($this->object)->field($this->fieldName)->hasMany()) {
99
-            if (!empty($this->object[$this->fieldName])) {
100
-                /** @var $foreignObject \Fab\Vidi\Domain\Model\Content */
101
-                foreach ($this->object[$this->fieldName] as $foreignObject) {
102
-                    $output .= sprintf(
103
-                        '<li>%s</li>',
104
-                        $foreignObject[$foreignLabelField]
105
-                    );
106
-                }
107
-                $output = sprintf('<ul class="list-unstyled">%s</ul>', $output);
108
-            }
109
-        }
110
-        return $output;
111
-    }
112
-
113
-    /**
114
-     * Render an edit URI given an object.
115
-     *
116
-     * @param Content $object
117
-     * @return string
118
-     */
119
-    protected function getEditUri(Content $object)
120
-    {
121
-        $uri = BackendUtility::getModuleUrl(
122
-            'record_edit',
123
-            array(
124
-                $this->getEditParameterName($object) => 'edit',
125
-                'returnUrl' => $this->getModuleLoader()->getModuleUrl()
126
-            )
127
-        );
128
-        return $uri;
129
-    }
130
-
131
-    /**
132
-     * @param Content $object
133
-     * @return string
134
-     */
135
-    protected function getEditParameterName(Content $object)
136
-    {
137
-        return sprintf(
138
-            'edit[%s][%s]',
139
-            $object->getDataType(),
140
-            $object->getUid()
141
-        );
142
-    }
143
-
144
-    /**
145
-     * Return the label field of the foreign table.
146
-     *
147
-     * @param string $fieldName
148
-     * @return string
149
-     */
150
-    protected function getForeignTableLabelField($fieldName)
151
-    {
152
-        // Get TCA table service.
153
-        $table = Tca::table($this->object);
154
-
155
-        // Compute the label of the foreign table.
156
-        $relationDataType = $table->field($fieldName)->relationDataType();
157
-        return Tca::table($relationDataType)->getLabelField();
158
-    }
159
-
160
-    /**
161
-     * Returns whether the current mode is Frontend
162
-     *
163
-     * @return bool
164
-     */
165
-    protected function isBackendMode()
166
-    {
167
-        return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend();
168
-    }
23
+	/**
24
+	 * Render a representation of the relation on the GUI.
25
+	 *
26
+	 * @return string
27
+	 */
28
+	public function render()
29
+	{
30
+		if ($this->isBackendMode()) {
31
+			$output = $this->renderForBackend();
32
+		} else {
33
+			$output = $this->renderForFrontend();
34
+		}
35
+
36
+		return $output;
37
+	}
38
+
39
+	/**
40
+	 * @return string
41
+	 */
42
+	protected function renderForBackend()
43
+	{
44
+		$output = '';
45
+
46
+		// Get label of the foreign table.
47
+		$foreignLabelField = $this->getForeignTableLabelField($this->fieldName);
48
+
49
+		if (Tca::table($this->object)->field($this->fieldName)->hasOne()) {
50
+			$foreignObject = $this->object[$this->fieldName];
51
+
52
+			if ($foreignObject) {
53
+				$output = sprintf(
54
+					'<a href="%s" data-uid="%s" class="btn-edit invisible">%s</a> <span>%s</span>',
55
+					$this->getEditUri($foreignObject),
56
+					$this->object->getUid(),
57
+					$this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL),
58
+					$foreignObject[$foreignLabelField]
59
+				);
60
+			}
61
+		} elseif (Tca::table($this->object)->field($this->fieldName)->hasMany()) {
62
+			if (!empty($this->object[$this->fieldName])) {
63
+				/** @var $foreignObject \Fab\Vidi\Domain\Model\Content */
64
+				foreach ($this->object[$this->fieldName] as $foreignObject) {
65
+					$output .= sprintf(
66
+						'<li><a href="%s" data-uid="%s" class="btn-edit invisible">%s</a> <span>%s</span></li>',
67
+						$this->getEditUri($foreignObject),
68
+						$this->object->getUid(),
69
+						$this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL),
70
+						$foreignObject[$foreignLabelField]
71
+					);
72
+				}
73
+				$output = sprintf('<ul class="list-unstyled">%s</ul>', $output);
74
+			}
75
+		}
76
+		return $output;
77
+	}
78
+
79
+	/**
80
+	 * @return string
81
+	 */
82
+	protected function renderForFrontend()
83
+	{
84
+		$output = '';
85
+
86
+		// Get label of the foreign table.
87
+		$foreignLabelField = $this->getForeignTableLabelField($this->fieldName);
88
+
89
+		if (Tca::table($this->object)->field($this->fieldName)->hasOne()) {
90
+			$foreignObject = $this->object[$this->fieldName];
91
+
92
+			if ($foreignObject) {
93
+				$output = sprintf(
94
+					'%s',
95
+					$foreignObject[$foreignLabelField]
96
+				);
97
+			}
98
+		} elseif (Tca::table($this->object)->field($this->fieldName)->hasMany()) {
99
+			if (!empty($this->object[$this->fieldName])) {
100
+				/** @var $foreignObject \Fab\Vidi\Domain\Model\Content */
101
+				foreach ($this->object[$this->fieldName] as $foreignObject) {
102
+					$output .= sprintf(
103
+						'<li>%s</li>',
104
+						$foreignObject[$foreignLabelField]
105
+					);
106
+				}
107
+				$output = sprintf('<ul class="list-unstyled">%s</ul>', $output);
108
+			}
109
+		}
110
+		return $output;
111
+	}
112
+
113
+	/**
114
+	 * Render an edit URI given an object.
115
+	 *
116
+	 * @param Content $object
117
+	 * @return string
118
+	 */
119
+	protected function getEditUri(Content $object)
120
+	{
121
+		$uri = BackendUtility::getModuleUrl(
122
+			'record_edit',
123
+			array(
124
+				$this->getEditParameterName($object) => 'edit',
125
+				'returnUrl' => $this->getModuleLoader()->getModuleUrl()
126
+			)
127
+		);
128
+		return $uri;
129
+	}
130
+
131
+	/**
132
+	 * @param Content $object
133
+	 * @return string
134
+	 */
135
+	protected function getEditParameterName(Content $object)
136
+	{
137
+		return sprintf(
138
+			'edit[%s][%s]',
139
+			$object->getDataType(),
140
+			$object->getUid()
141
+		);
142
+	}
143
+
144
+	/**
145
+	 * Return the label field of the foreign table.
146
+	 *
147
+	 * @param string $fieldName
148
+	 * @return string
149
+	 */
150
+	protected function getForeignTableLabelField($fieldName)
151
+	{
152
+		// Get TCA table service.
153
+		$table = Tca::table($this->object);
154
+
155
+		// Compute the label of the foreign table.
156
+		$relationDataType = $table->field($fieldName)->relationDataType();
157
+		return Tca::table($relationDataType)->getLabelField();
158
+	}
159
+
160
+	/**
161
+	 * Returns whether the current mode is Frontend
162
+	 *
163
+	 * @return bool
164
+	 */
165
+	protected function isBackendMode()
166
+	{
167
+		return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend();
168
+	}
169 169
 }
Please login to merge, or discard this patch.
Classes/Grid/CheckBoxRenderer.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -14,31 +14,31 @@
 block discarded – undo
14 14
  */
15 15
 class CheckBoxRenderer extends ColumnRendererAbstract
16 16
 {
17
-    /**
18
-     * Configure the "Check Box" Grid Renderer.
19
-     */
20
-    public function __construct()
21
-    {
22
-        $configuration = array(
23
-            'width' => '5px',
24
-            'sortable' => false,
25
-            'canBeHidden' => false,
26
-            'html' => '<input type="checkbox" class="checkbox-row-top"/>',
27
-        );
28
-        parent::__construct($configuration);
29
-    }
17
+	/**
18
+	 * Configure the "Check Box" Grid Renderer.
19
+	 */
20
+	public function __construct()
21
+	{
22
+		$configuration = array(
23
+			'width' => '5px',
24
+			'sortable' => false,
25
+			'canBeHidden' => false,
26
+			'html' => '<input type="checkbox" class="checkbox-row-top"/>',
27
+		);
28
+		parent::__construct($configuration);
29
+	}
30 30
 
31
-    /**
32
-     * Render the "Check Box" in the Grid.
33
-     *
34
-     * @return string
35
-     */
36
-    public function render()
37
-    {
38
-        return sprintf(
39
-            '<input type="checkbox" class="checkbox-row" data-index="%s" data-uid="%s"/>',
40
-            $this->getRowIndex(),
41
-            $this->getObject()->getUid()
42
-        );
43
-    }
31
+	/**
32
+	 * Render the "Check Box" in the Grid.
33
+	 *
34
+	 * @return string
35
+	 */
36
+	public function render()
37
+	{
38
+		return sprintf(
39
+			'<input type="checkbox" class="checkbox-row" data-index="%s" data-uid="%s"/>',
40
+			$this->getRowIndex(),
41
+			$this->getObject()->getUid()
42
+		);
43
+	}
44 44
 }
Please login to merge, or discard this patch.
Classes/Grid/GridAnalyserService.php 1 patch
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -16,108 +16,108 @@
 block discarded – undo
16 16
  */
17 17
 class GridAnalyserService
18 18
 {
19
-    /**
20
-     * Check relation for table.
21
-     *
22
-     * @param $tableName
23
-     * @return array
24
-     */
25
-    public function checkRelationForTable($tableName)
26
-    {
27
-        $relations = [];
28
-        $table = Tca::table($tableName);
29
-
30
-        $missingOppositionRelationMessage = <<<EOF
19
+	/**
20
+	 * Check relation for table.
21
+	 *
22
+	 * @param $tableName
23
+	 * @return array
24
+	 */
25
+	public function checkRelationForTable($tableName)
26
+	{
27
+		$relations = [];
28
+		$table = Tca::table($tableName);
29
+
30
+		$missingOppositionRelationMessage = <<<EOF
31 31
 
32 32
   WARNING! Could not define relation precisely. This is not necessarily a problem
33 33
   if the opposite relation is not required in a Grid. But consider adding the opposite
34 34
   TCA configuration if so.
35 35
 EOF;
36 36
 
37
-        foreach (Tca::grid($tableName)->getFields() as $fieldName => $configuration) {
38
-            if ($table->hasField($fieldName)) {
39
-                if ($table->field($fieldName)->hasMany()) {
40
-                    if ($table->field($fieldName)->hasRelationWithCommaSeparatedValues()) {
41
-                        $_relations = $this->checkRelationOf($tableName, $fieldName, 'comma separated values');
42
-                        $relations = array_merge($relations, $_relations);
43
-                    } elseif ($table->field($fieldName)->hasRelationManyToMany()) {
44
-                        $_relations = $this->checkRelationManyToMany($tableName, $fieldName);
45
-                        $relations = array_merge($relations, $_relations);
46
-                    } elseif ($table->field($fieldName)->hasRelationOneToMany()) {
47
-                        $_relations = $this->checkRelationOf($tableName, $fieldName, 'one-to-many');
48
-                        $relations = array_merge($relations, $_relations);
49
-                    } else {
50
-                        $relations[] = sprintf('* field: "%s", relation: ?-to-many%s', $fieldName, $missingOppositionRelationMessage);
51
-                    }
52
-                    $relations[] = '';
53
-                } elseif ($table->field($fieldName)->hasOne()) {
54
-                    if ($table->field($fieldName)->hasRelationOneToOne()) {
55
-                        $relations[] = sprintf('* one-to-one "%s"', $fieldName);
56
-                    } elseif ($table->field($fieldName)->hasRelationManyToOne()) {
57
-                        $_relations = $this->checkRelationOf($tableName, $fieldName, 'many-to-one');
58
-                        $relations = array_merge($relations, $_relations);
59
-                    } else {
60
-                        $relations[] = sprintf('* field: "%s", relation: ?-to-one%s', $fieldName, $missingOppositionRelationMessage);
61
-                    }
62
-                    $relations[] = '';
63
-                }
64
-            }
65
-        }
66
-        return $relations;
67
-    }
68
-
69
-    /**
70
-     * Convenience method for printing out relation many-to-many.
71
-     *
72
-     * @param string $tableName
73
-     * @param string $fieldName
74
-     * @return array
75
-     */
76
-    protected function checkRelationManyToMany($tableName, $fieldName)
77
-    {
78
-        $output = [];
79
-
80
-        $table = Tca::table($tableName);
81
-        $output[] = sprintf('* field: "%s", relation: many-to-many', $fieldName);
82
-
83
-        $foreignTable = $table->field($fieldName)->getForeignTable();
84
-        $manyToManyTable = $table->field($fieldName)->getManyToManyTable();
85
-        $foreignField = $table->field($fieldName)->getForeignField();
86
-
87
-        if (!$foreignField) {
88
-            $output[] = sprintf('  ERROR! Can not found foreign field for "%s". Perhaps missing opposite configuration?', $fieldName);
89
-        } elseif (!$foreignTable) {
90
-            $output[] = sprintf('  ERROR! Can not found foreign table for "%s". Perhaps missing opposite configuration?', $fieldName);
91
-        } elseif (!$manyToManyTable) {
92
-            $output[] = sprintf('  ERROR! Can not found relation table (MM) for "%s". Perhaps missing opposite configuration?', $fieldName);
93
-        } else {
94
-            $output[] = sprintf('  %s.%s <--> %s <--> %s.%s', $tableName, $fieldName, $manyToManyTable, $foreignTable, $foreignField);
95
-        }
96
-
97
-        $output[] = '';
98
-        return $output;
99
-    }
100
-
101
-    /**
102
-     * Convenience method for printing out relation.
103
-     *
104
-     * @param string $tableName
105
-     * @param string $fieldName
106
-     * @param string $relationType
107
-     * @return array
108
-     */
109
-    protected function checkRelationOf($tableName, $fieldName, $relationType)
110
-    {
111
-        $output = [];
112
-
113
-        $table = Tca::table($tableName);
114
-        $output[] = sprintf('* field: "%s", relation: %s', $fieldName, $relationType);
115
-
116
-        $foreignTable = $table->field($fieldName)->getForeignTable();
117
-        $foreignField = $table->field($fieldName)->getForeignField();
118
-        $output[] = sprintf('  %s.%s <--> %s.%s', $tableName, $fieldName, $foreignTable, $foreignField);
119
-        $output[] = '';
120
-
121
-        return $output;
122
-    }
37
+		foreach (Tca::grid($tableName)->getFields() as $fieldName => $configuration) {
38
+			if ($table->hasField($fieldName)) {
39
+				if ($table->field($fieldName)->hasMany()) {
40
+					if ($table->field($fieldName)->hasRelationWithCommaSeparatedValues()) {
41
+						$_relations = $this->checkRelationOf($tableName, $fieldName, 'comma separated values');
42
+						$relations = array_merge($relations, $_relations);
43
+					} elseif ($table->field($fieldName)->hasRelationManyToMany()) {
44
+						$_relations = $this->checkRelationManyToMany($tableName, $fieldName);
45
+						$relations = array_merge($relations, $_relations);
46
+					} elseif ($table->field($fieldName)->hasRelationOneToMany()) {
47
+						$_relations = $this->checkRelationOf($tableName, $fieldName, 'one-to-many');
48
+						$relations = array_merge($relations, $_relations);
49
+					} else {
50
+						$relations[] = sprintf('* field: "%s", relation: ?-to-many%s', $fieldName, $missingOppositionRelationMessage);
51
+					}
52
+					$relations[] = '';
53
+				} elseif ($table->field($fieldName)->hasOne()) {
54
+					if ($table->field($fieldName)->hasRelationOneToOne()) {
55
+						$relations[] = sprintf('* one-to-one "%s"', $fieldName);
56
+					} elseif ($table->field($fieldName)->hasRelationManyToOne()) {
57
+						$_relations = $this->checkRelationOf($tableName, $fieldName, 'many-to-one');
58
+						$relations = array_merge($relations, $_relations);
59
+					} else {
60
+						$relations[] = sprintf('* field: "%s", relation: ?-to-one%s', $fieldName, $missingOppositionRelationMessage);
61
+					}
62
+					$relations[] = '';
63
+				}
64
+			}
65
+		}
66
+		return $relations;
67
+	}
68
+
69
+	/**
70
+	 * Convenience method for printing out relation many-to-many.
71
+	 *
72
+	 * @param string $tableName
73
+	 * @param string $fieldName
74
+	 * @return array
75
+	 */
76
+	protected function checkRelationManyToMany($tableName, $fieldName)
77
+	{
78
+		$output = [];
79
+
80
+		$table = Tca::table($tableName);
81
+		$output[] = sprintf('* field: "%s", relation: many-to-many', $fieldName);
82
+
83
+		$foreignTable = $table->field($fieldName)->getForeignTable();
84
+		$manyToManyTable = $table->field($fieldName)->getManyToManyTable();
85
+		$foreignField = $table->field($fieldName)->getForeignField();
86
+
87
+		if (!$foreignField) {
88
+			$output[] = sprintf('  ERROR! Can not found foreign field for "%s". Perhaps missing opposite configuration?', $fieldName);
89
+		} elseif (!$foreignTable) {
90
+			$output[] = sprintf('  ERROR! Can not found foreign table for "%s". Perhaps missing opposite configuration?', $fieldName);
91
+		} elseif (!$manyToManyTable) {
92
+			$output[] = sprintf('  ERROR! Can not found relation table (MM) for "%s". Perhaps missing opposite configuration?', $fieldName);
93
+		} else {
94
+			$output[] = sprintf('  %s.%s <--> %s <--> %s.%s', $tableName, $fieldName, $manyToManyTable, $foreignTable, $foreignField);
95
+		}
96
+
97
+		$output[] = '';
98
+		return $output;
99
+	}
100
+
101
+	/**
102
+	 * Convenience method for printing out relation.
103
+	 *
104
+	 * @param string $tableName
105
+	 * @param string $fieldName
106
+	 * @param string $relationType
107
+	 * @return array
108
+	 */
109
+	protected function checkRelationOf($tableName, $fieldName, $relationType)
110
+	{
111
+		$output = [];
112
+
113
+		$table = Tca::table($tableName);
114
+		$output[] = sprintf('* field: "%s", relation: %s', $fieldName, $relationType);
115
+
116
+		$foreignTable = $table->field($fieldName)->getForeignTable();
117
+		$foreignField = $table->field($fieldName)->getForeignField();
118
+		$output[] = sprintf('  %s.%s <--> %s.%s', $tableName, $fieldName, $foreignTable, $foreignField);
119
+		$output[] = '';
120
+
121
+		return $output;
122
+	}
123 123
 }
Please login to merge, or discard this patch.
Classes/Grid/ColumnRendererInterface.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -15,45 +15,45 @@
 block discarded – undo
15 15
  */
16 16
 interface ColumnRendererInterface
17 17
 {
18
-    /**
19
-     * Render a column in the Grid.
20
-     *
21
-     * @return string
22
-     */
23
-    public function render();
24
-
25
-    /**
26
-     * @param Content $object
27
-     * @return $this
28
-     */
29
-    public function setObject($object);
30
-
31
-    /**
32
-     * @param string $fieldName
33
-     * @return $this
34
-     */
35
-    public function setFieldName($fieldName);
36
-
37
-    /**
38
-     * @param int $index
39
-     * @return $this
40
-     */
41
-    public function setRowIndex($index);
42
-
43
-    /**
44
-     * @param array $configuration
45
-     * @return $this
46
-     */
47
-    public function setFieldConfiguration($configuration);
48
-
49
-    /**
50
-     * @param array $configuration
51
-     * @return $this
52
-     */
53
-    public function setGridRendererConfiguration($configuration);
54
-
55
-    /**
56
-     * @return array
57
-     */
58
-    public function getConfiguration();
18
+	/**
19
+	 * Render a column in the Grid.
20
+	 *
21
+	 * @return string
22
+	 */
23
+	public function render();
24
+
25
+	/**
26
+	 * @param Content $object
27
+	 * @return $this
28
+	 */
29
+	public function setObject($object);
30
+
31
+	/**
32
+	 * @param string $fieldName
33
+	 * @return $this
34
+	 */
35
+	public function setFieldName($fieldName);
36
+
37
+	/**
38
+	 * @param int $index
39
+	 * @return $this
40
+	 */
41
+	public function setRowIndex($index);
42
+
43
+	/**
44
+	 * @param array $configuration
45
+	 * @return $this
46
+	 */
47
+	public function setFieldConfiguration($configuration);
48
+
49
+	/**
50
+	 * @param array $configuration
51
+	 * @return $this
52
+	 */
53
+	public function setGridRendererConfiguration($configuration);
54
+
55
+	/**
56
+	 * @return array
57
+	 */
58
+	public function getConfiguration();
59 59
 }
Please login to merge, or discard this patch.
Classes/Grid/ButtonGroupRenderer.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -16,40 +16,40 @@
 block discarded – undo
16 16
  */
17 17
 class ButtonGroupRenderer extends ColumnRendererAbstract
18 18
 {
19
-    /**
20
-     * Configure the "Button Group" Grid Renderer.
21
-     */
22
-    public function __construct()
23
-    {
24
-        $configuration = array(
25
-            'sortable' => false,
26
-            'canBeHidden' => false,
27
-            'width' => '100px',
28
-        );
29
-        parent::__construct($configuration);
30
-    }
31
-
32
-    /**
33
-     * Render the "Button Group" in the Grid, e.g. edit, delete, etc..
34
-     *
35
-     * @return string
36
-     */
37
-    public function render()
38
-    {
39
-        $components = $this->getModuleLoader()->getGridButtonsComponents();
40
-
41
-        $buttons = [];
42
-        foreach ($components as $component) {
43
-            /** @var  $view */
44
-            $view = GeneralUtility::makeInstance($component);
45
-            $buttons[] = $view->render($this->getObject());
46
-        }
47
-
48
-        $output = sprintf(
49
-            '<div class="btn-toolbar pull-right" role="toolbar" aria-label=""><div class="btn-group" role="group" aria-label="">%s</div></div>',
50
-            implode("\n", $buttons)
51
-        );
52
-
53
-        return $output;
54
-    }
19
+	/**
20
+	 * Configure the "Button Group" Grid Renderer.
21
+	 */
22
+	public function __construct()
23
+	{
24
+		$configuration = array(
25
+			'sortable' => false,
26
+			'canBeHidden' => false,
27
+			'width' => '100px',
28
+		);
29
+		parent::__construct($configuration);
30
+	}
31
+
32
+	/**
33
+	 * Render the "Button Group" in the Grid, e.g. edit, delete, etc..
34
+	 *
35
+	 * @return string
36
+	 */
37
+	public function render()
38
+	{
39
+		$components = $this->getModuleLoader()->getGridButtonsComponents();
40
+
41
+		$buttons = [];
42
+		foreach ($components as $component) {
43
+			/** @var  $view */
44
+			$view = GeneralUtility::makeInstance($component);
45
+			$buttons[] = $view->render($this->getObject());
46
+		}
47
+
48
+		$output = sprintf(
49
+			'<div class="btn-toolbar pull-right" role="toolbar" aria-label=""><div class="btn-group" role="group" aria-label="">%s</div></div>',
50
+			implode("\n", $buttons)
51
+		);
52
+
53
+		return $output;
54
+	}
55 55
 }
Please login to merge, or discard this patch.
Classes/Grid/RelationCountRenderer.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -20,66 +20,66 @@
 block discarded – undo
20 20
  */
21 21
 class RelationCountRenderer extends ColumnRendererAbstract
22 22
 {
23
-    /**
24
-     * Render a representation of the relation on the GUI.
25
-     *
26
-     * @return string
27
-     */
28
-    public function render()
29
-    {
30
-        $output = '';
31
-        if ($this->isBackendMode()) {
32
-            $output = $this->renderForBackend();
33
-        }
23
+	/**
24
+	 * Render a representation of the relation on the GUI.
25
+	 *
26
+	 * @return string
27
+	 */
28
+	public function render()
29
+	{
30
+		$output = '';
31
+		if ($this->isBackendMode()) {
32
+			$output = $this->renderForBackend();
33
+		}
34 34
 
35
-        return $output;
36
-    }
35
+		return $output;
36
+	}
37 37
 
38
-    /**
39
-     * @return string
40
-     */
41
-    protected function renderForBackend()
42
-    {
43
-        $numberOfObjects = count($this->object[$this->fieldName]);
38
+	/**
39
+	 * @return string
40
+	 */
41
+	protected function renderForBackend()
42
+	{
43
+		$numberOfObjects = count($this->object[$this->fieldName]);
44 44
 
45
-        if ($numberOfObjects > 1) {
46
-            $label = 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:items';
47
-            if (isset($this->gridRendererConfiguration['labelPlural'])) {
48
-                $label = $this->gridRendererConfiguration['labelPlural'];
49
-            }
50
-        } else {
51
-            $label = 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:item';
52
-            if (isset($this->gridRendererConfiguration['labelSingular'])) {
53
-                $label = $this->gridRendererConfiguration['labelSingular'];
54
-            }
55
-        }
45
+		if ($numberOfObjects > 1) {
46
+			$label = 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:items';
47
+			if (isset($this->gridRendererConfiguration['labelPlural'])) {
48
+				$label = $this->gridRendererConfiguration['labelPlural'];
49
+			}
50
+		} else {
51
+			$label = 'LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:item';
52
+			if (isset($this->gridRendererConfiguration['labelSingular'])) {
53
+				$label = $this->gridRendererConfiguration['labelSingular'];
54
+			}
55
+		}
56 56
 
57
-        $template = '<a href="%s&returnUrl=%s&search=%s&query=%s:%s">%s %s<span class="invisible" style="padding-left: 5px">%s</span></a>';
57
+		$template = '<a href="%s&returnUrl=%s&search=%s&query=%s:%s">%s %s<span class="invisible" style="padding-left: 5px">%s</span></a>';
58 58
 
59
-        $foreignField = Tca::table($this->object)->field($this->fieldName)->getForeignField();
60
-        $search = json_encode(array(array($foreignField => $this->object->getUid())));
59
+		$foreignField = Tca::table($this->object)->field($this->fieldName)->getForeignField();
60
+		$search = json_encode(array(array($foreignField => $this->object->getUid())));
61 61
 
62
-        $moduleTarget = empty($this->gridRendererConfiguration['targetModule']) ? '' : $this->gridRendererConfiguration['targetModule'];
63
-        return sprintf(
64
-            $template,
65
-            BackendUtility::getModuleUrl($moduleTarget),
66
-            rawurlencode(BackendUtility::getModuleUrl($this->gridRendererConfiguration['sourceModule'])),
67
-            rawurlencode($search),
68
-            rawurlencode($foreignField),
69
-            rawurlencode($this->object->getUid()),
70
-            htmlspecialchars($numberOfObjects),
71
-            htmlspecialchars(LocalizationUtility::translate($label, '')),
72
-            $this->getIconFactory()->getIcon('extensions-vidi-go', Icon::SIZE_SMALL)
73
-        );
74
-    }
62
+		$moduleTarget = empty($this->gridRendererConfiguration['targetModule']) ? '' : $this->gridRendererConfiguration['targetModule'];
63
+		return sprintf(
64
+			$template,
65
+			BackendUtility::getModuleUrl($moduleTarget),
66
+			rawurlencode(BackendUtility::getModuleUrl($this->gridRendererConfiguration['sourceModule'])),
67
+			rawurlencode($search),
68
+			rawurlencode($foreignField),
69
+			rawurlencode($this->object->getUid()),
70
+			htmlspecialchars($numberOfObjects),
71
+			htmlspecialchars(LocalizationUtility::translate($label, '')),
72
+			$this->getIconFactory()->getIcon('extensions-vidi-go', Icon::SIZE_SMALL)
73
+		);
74
+	}
75 75
 
76
-    /**
77
-     * Returns whether the current mode is Frontend
78
-     *
79
-     * @return bool
80
-     */
81
-    protected function isBackendMode()
82
-    {
83
-        return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend();
84
-    }
76
+	/**
77
+	 * Returns whether the current mode is Frontend
78
+	 *
79
+	 * @return bool
80
+	 */
81
+	protected function isBackendMode()
82
+	{
83
+		return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend();
84
+	}
85 85
 }
Please login to merge, or discard this patch.
Classes/Grid/RelationEditRenderer.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -18,55 +18,55 @@
 block discarded – undo
18 18
  */
19 19
 class RelationEditRenderer extends ColumnRendererAbstract
20 20
 {
21
-    /**
22
-     * @return string
23
-     */
24
-    public function render()
25
-    {
26
-        $output = '';
27
-        if ($this->isBackendMode()) {
28
-            $output = $this->renderForBackend();
29
-        }
21
+	/**
22
+	 * @return string
23
+	 */
24
+	public function render()
25
+	{
26
+		$output = '';
27
+		if ($this->isBackendMode()) {
28
+			$output = $this->renderForBackend();
29
+		}
30 30
 
31
-        return $output;
32
-    }
31
+		return $output;
32
+	}
33 33
 
34
-    /**
35
-     * @return string
36
-     */
37
-    protected function renderForBackend()
38
-    {
39
-        // Initialize url parameters array.
40
-        $urlParameters = array(
41
-            $this->getModuleLoader()->getParameterPrefix() => array(
42
-                'controller' => 'Content',
43
-                'action' => 'edit',
44
-                'matches' => array('uid' => $this->object->getUid()),
45
-                'fieldNameAndPath' => $this->getFieldName(),
46
-            ),
47
-        );
34
+	/**
35
+	 * @return string
36
+	 */
37
+	protected function renderForBackend()
38
+	{
39
+		// Initialize url parameters array.
40
+		$urlParameters = array(
41
+			$this->getModuleLoader()->getParameterPrefix() => array(
42
+				'controller' => 'Content',
43
+				'action' => 'edit',
44
+				'matches' => array('uid' => $this->object->getUid()),
45
+				'fieldNameAndPath' => $this->getFieldName(),
46
+			),
47
+		);
48 48
 
49
-        $fieldLabel = Tca::table()->field($this->getFieldName())->getLabel();
50
-        if ($fieldLabel) {
51
-            $fieldLabel = str_replace(':', '', $fieldLabel); // sanitize label
52
-        }
49
+		$fieldLabel = Tca::table()->field($this->getFieldName())->getLabel();
50
+		if ($fieldLabel) {
51
+			$fieldLabel = str_replace(':', '', $fieldLabel); // sanitize label
52
+		}
53 53
 
54
-        return sprintf(
55
-            '<div style="text-align: right" class="pull-right invisible"><a href="%s" class="btn-edit-relation" data-field-label="%s">%s</a></div>',
56
-            $this->getModuleLoader()->getModuleUrl($urlParameters),
57
-            $fieldLabel,
58
-            $this->getIconFactory()->getIcon('actions-add', Icon::SIZE_SMALL)
59
-        );
60
-    }
54
+		return sprintf(
55
+			'<div style="text-align: right" class="pull-right invisible"><a href="%s" class="btn-edit-relation" data-field-label="%s">%s</a></div>',
56
+			$this->getModuleLoader()->getModuleUrl($urlParameters),
57
+			$fieldLabel,
58
+			$this->getIconFactory()->getIcon('actions-add', Icon::SIZE_SMALL)
59
+		);
60
+	}
61 61
 
62
-    /**
63
-     * Returns whether the current mode is Frontend
64
-     *
65
-     * @return bool
66
-     */
67
-    protected function isBackendMode()
68
-    {
69
-        return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend();
70
-        ;
71
-    }
62
+	/**
63
+	 * Returns whether the current mode is Frontend
64
+	 *
65
+	 * @return bool
66
+	 */
67
+	protected function isBackendMode()
68
+	{
69
+		return ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend();
70
+		;
71
+	}
72 72
 }
Please login to merge, or discard this patch.