Completed
Push — master ( 5c161a...b70884 )
by Fabien
52:39
created
Classes/View/Grid/Row.php 2 patches
Indentation   +606 added lines, -606 removed lines patch added patch discarded remove patch
@@ -26,610 +26,610 @@
 block discarded – undo
26 26
  */
27 27
 class Row extends AbstractComponentView
28 28
 {
29
-    /**
30
-     * @var array
31
-     */
32
-    protected $columns = [];
33
-
34
-    /**
35
-     * Registry for storing variable values and speed up the processing.
36
-     *
37
-     * @var array
38
-     */
39
-    protected $variables = [];
40
-
41
-    /**
42
-     * @param array $columns
43
-     */
44
-    public function __construct(array $columns = [])
45
-    {
46
-        $this->columns = $columns;
47
-    }
48
-
49
-    /**
50
-     * Render a row to be displayed in the Grid given an Content Object.
51
-     *
52
-     * @param Content $object
53
-     * @param int $rowIndex
54
-     * @return array
55
-     * @throws \Exception
56
-     */
57
-    public function render(Content $object = null, $rowIndex = 0)
58
-    {
59
-        // Initialize returned array
60
-        $output = [];
61
-
62
-        foreach (Tca::grid()->getFields() as $fieldNameAndPath => $configuration) {
63
-            $value = ''; // default is empty at first.
64
-
65
-            $this->computeVariables($object, $fieldNameAndPath);
66
-
67
-            // Only compute the value if it is going to be shown in the Grid. Lost of time otherwise!
68
-            if (in_array($fieldNameAndPath, $this->columns)) {
69
-                // Fetch value
70
-                if (Tca::grid()->hasRenderers($fieldNameAndPath)) {
71
-                    $value = '';
72
-                    $renderers = Tca::grid()->getRenderers($fieldNameAndPath);
73
-
74
-                    // if is relation has one
75
-                    foreach ($renderers as $rendererClassName => $rendererConfiguration) {
76
-                        /** @var $rendererObject \Fab\Vidi\Grid\ColumnRendererInterface */
77
-                        $rendererObject = GeneralUtility::makeInstance($rendererClassName);
78
-                        $value .= $rendererObject
79
-                            ->setObject($object)
80
-                            ->setFieldName($fieldNameAndPath)
81
-                            ->setRowIndex($rowIndex)
82
-                            ->setFieldConfiguration($configuration)
83
-                            ->setGridRendererConfiguration($rendererConfiguration)
84
-                            ->render();
85
-                    }
86
-                } else {
87
-                    $value = $this->resolveValue($object, $fieldNameAndPath);
88
-                    $value = $this->processValue($value, $object, $fieldNameAndPath); // post resolve processing.
89
-                }
90
-
91
-                // Possible formatting given by configuration. @see TCA['grid']
92
-                $value = $this->formatValue($value, $configuration);
93
-
94
-                // Here, there is the chance to further "decorate" the value for inline editing, localization, ...
95
-                if ($this->willBeEnriched()) {
96
-                    $localizedStructure = $this->initializeLocalizedStructure($value);
97
-
98
-                    if ($this->isEditable()) {
99
-                        $localizedStructure = $this->addEditableMarkup($localizedStructure);
100
-                    }
101
-
102
-                    if ($this->isLocalized()) {
103
-                        $localizedStructure = $this->addLocalizationMarkup($localizedStructure);
104
-                    }
105
-
106
-                    if ($this->hasIcon()) {
107
-                        $localizedStructure = $this->addSpriteIconMarkup($localizedStructure);
108
-                    }
109
-
110
-                    $value = $this->flattenStructure($localizedStructure);
111
-                }
112
-
113
-                // Final wrap given by configuration. @see TCA['grid']
114
-                $value = $this->wrapValue($value, $configuration);
115
-            }
116
-
117
-            $output[$this->getFieldName()] = $value;
118
-        }
119
-
120
-        $output['DT_RowId'] = 'row-' . $object->getUid();
121
-        $output['DT_RowClass'] = sprintf('%s_%s', $object->getDataType(), $object->getUid());
122
-
123
-        return $output;
124
-    }
125
-
126
-    /**
127
-     * Flatten the localized structure to render the final value
128
-     *
129
-     * @param array $localizedStructure
130
-     * @return string
131
-     */
132
-    protected function flattenStructure(array $localizedStructure)
133
-    {
134
-        // Flatten the structure.
135
-        $value = '';
136
-        foreach ($localizedStructure as $structure) {
137
-            $value .= sprintf(
138
-                '<div class="%s">%s</div>',
139
-                $structure['status'] !== LocalizationStatus::LOCALIZED ? 'invisible' : '',
140
-                $structure['value']
141
-            );
142
-        }
143
-        return $value;
144
-    }
145
-
146
-    /**
147
-     * Store some often used variable values and speed up the processing.
148
-     *
149
-     * @param Content $object
150
-     * @param string $fieldNameAndPath
151
-     * @return void
152
-     */
153
-    protected function computeVariables(Content $object, $fieldNameAndPath)
154
-    {
155
-        $this->variables = [];
156
-        $this->variables['dataType'] = $this->getFieldPathResolver()->getDataType($fieldNameAndPath);
157
-        $this->variables['fieldName'] = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
158
-        $this->variables['fieldNameAndPath'] = $fieldNameAndPath;
159
-        $this->variables['object'] = $object;
160
-    }
161
-
162
-    /**
163
-     * Tell whether the object will be decorated / wrapped such as
164
-     *
165
-     * @param string $value
166
-     * @return array
167
-     */
168
-    protected function initializeLocalizedStructure($value)
169
-    {
170
-        $localizedStructure[] = [
171
-            'value' => empty($value) && $this->isEditable() ? $this->getEmptyValuePlaceholder() : $value,
172
-            'status' => empty($value) ? LocalizationStatus::EMPTY_VALUE : LocalizationStatus::LOCALIZED,
173
-            'language' => 0,
174
-            'languageFlag' => $defaultLanguage = $this->getLanguageService()->getDefaultFlag(),
175
-        ];
176
-
177
-        if ($this->isLocalized()) {
178
-            foreach ($this->getLanguageService()->getLanguages() as $language) {
179
-                // Make sure the language is allowed for the current Backend User.
180
-                if ($this->isLanguageAllowedForBackendUser($language)) {
181
-                    $resolvedObject = $this->getResolvedObject();
182
-                    $fieldName = $this->getFieldName();
183
-
184
-                    if ($this->getLanguageService()->hasLocalization($resolvedObject, $language['uid'])) {
185
-                        $localizedValue = $this->getLanguageService()->getLocalizedFieldName($resolvedObject, $language['uid'], $fieldName);
186
-                        $status = LocalizationStatus::LOCALIZED;
187
-
188
-                        // Replace blank value by something more meaningful for the End User.
189
-                        if (empty($localizedValue)) {
190
-                            $status = LocalizationStatus::EMPTY_VALUE;
191
-                            $localizedValue = $this->isEditable() ? $this->getEmptyValuePlaceholder() : '';
192
-                        }
193
-                    } else {
194
-                        $localizedValue = sprintf(
195
-                            '<a href="%s" style="color: black">%s</a>',
196
-                            $this->getLocalizedUri($language['uid']),
197
-                            $this->getLabelService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:create_translation')
198
-                        );
199
-                        $status = LocalizationStatus::NOT_YET_LOCALIZED;
200
-                    }
201
-
202
-                    // Feed structure.
203
-                    $localizedStructure[] = [
204
-                        'value' => $localizedValue,
205
-                        'status' => $status,
206
-                        'language' => (int)$language['uid'],
207
-                        'languageFlag' => $language['flag'],
208
-                    ];
209
-                }
210
-            }
211
-        }
212
-
213
-        return $localizedStructure;
214
-    }
215
-
216
-    /**
217
-     * @param array $language
218
-     * @return bool
219
-     */
220
-    protected function isLanguageAllowedForBackendUser(array $language)
221
-    {
222
-        return $this->getBackendUser()->checkLanguageAccess($language['uid']);
223
-    }
224
-
225
-    /**
226
-     * Returns a placeholder when the value is empty.
227
-     *
228
-     * @return string
229
-     */
230
-    protected function getEmptyValuePlaceholder()
231
-    {
232
-        return sprintf(
233
-            '<i>%s</i>',
234
-            $this->getLabelService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:start_editing')
235
-        );
236
-    }
237
-
238
-    /**
239
-     * Tell whether the object will be decorated (or wrapped) for inline editing, localization purpose.
240
-     *
241
-     * @return bool
242
-     */
243
-    protected function willBeEnriched()
244
-    {
245
-        $willBeEnriched = false;
246
-
247
-        if ($this->fieldExists()) {
248
-            $willBeEnriched = $this->isEditable() || $this->hasIcon() || $this->isLocalized();
249
-        }
250
-
251
-        return $willBeEnriched;
252
-    }
253
-
254
-    /**
255
-     * Tell whether the field in the context will be prepended by an icon.
256
-     *
257
-     * @return bool
258
-     */
259
-    protected function hasIcon()
260
-    {
261
-        $dataType = $this->getDataType();
262
-        return Tca::table($dataType)->getLabelField() === $this->getFieldName();
263
-    }
264
-
265
-    /**
266
-     * Tell whether the field in the context will be prepended by an icon.
267
-     *
268
-     * @return bool
269
-     */
270
-    protected function isLocalized()
271
-    {
272
-        $object = $this->getObject();
273
-        $fieldName = $this->getFieldName();
274
-        $dataType = $this->getDataType();
275
-        $fieldNameAndPath = $this->getFieldNameAndPath();
276
-
277
-        return $this->getLanguageService()->hasLanguages()
278
-        && Tca::grid($object)->isLocalized($fieldNameAndPath)
279
-        && Tca::table($dataType)->field($fieldName)->isLocalized();
280
-    }
281
-
282
-    /**
283
-     * Add some markup to have the content editable in the Grid.
284
-     *
285
-     * @param array $localizedStructure
286
-     * @return array
287
-     */
288
-    protected function addEditableMarkup(array $localizedStructure)
289
-    {
290
-        $dataType = $this->getDataType();
291
-        $fieldName = $this->getFieldName();
292
-
293
-        foreach ($localizedStructure as $index => $structure) {
294
-            if ($structure['status'] !== LocalizationStatus::NOT_YET_LOCALIZED) {
295
-                $localizedStructure[$index]['value'] = sprintf(
296
-                    '<span class="%s" data-language="%s">%s</span>',
297
-                    Tca::table($dataType)->field($fieldName)->isTextArea() ? 'editable-textarea' : 'editable-textfield',
298
-                    $structure['language'],
299
-                    $structure['value']
300
-                );
301
-            }
302
-        }
303
-        return $localizedStructure;
304
-    }
305
-
306
-    /**
307
-     * Add some markup related to the localization.
308
-     *
309
-     * @param array $localizedStructure
310
-     * @return array
311
-     */
312
-    protected function addLocalizationMarkup(array $localizedStructure)
313
-    {
314
-        foreach ($localizedStructure as $index => $structure) {
315
-            $localizedStructure[$index]['value'] = sprintf(
316
-                '<span>%s %s</span>',
317
-                empty($structure['languageFlag']) ? '' : $this->getIconFactory()->getIcon('flags-' . $structure['languageFlag'], Icon::SIZE_SMALL),
318
-                $structure['value']
319
-            );
320
-        }
321
-        return $localizedStructure;
322
-    }
323
-
324
-    /**
325
-     * Add some markup related to the prepended icon.
326
-     *
327
-     * @param array $localizedStructure
328
-     * @return array
329
-     */
330
-    protected function addSpriteIconMarkup(array $localizedStructure)
331
-    {
332
-        $object = $this->getObject();
333
-
334
-        foreach ($localizedStructure as $index => $structure) {
335
-            $recordData = [];
336
-
337
-            $enablesMethods = array('Hidden', 'Deleted', 'StartTime', 'EndTime');
338
-            foreach ($enablesMethods as $enableMethod) {
339
-                $methodName = 'get' . $enableMethod . 'Field';
340
-
341
-                // Fetch possible hidden filed.
342
-                $enableField = Tca::table($object)->$methodName();
343
-                if ($enableField) {
344
-                    $recordData[$enableField] = $object[$enableField];
345
-                }
346
-            }
347
-
348
-            // Get Enable Fields of the object to render the sprite with overlays.
349
-            $localizedStructure[$index]['value'] = sprintf(
350
-                '%s %s',
351
-                $this->getIconFactory()->getIconForRecord($object->getDataType(), $recordData, Icon::SIZE_SMALL),
352
-                $structure['value']
353
-            );
354
-        }
355
-
356
-        return $localizedStructure;
357
-    }
358
-
359
-    /**
360
-     * Return whether the field given by the context is editable.
361
-     *
362
-     * @return boolean
363
-     */
364
-    protected function isEditable()
365
-    {
366
-        $fieldNameAndPath = $this->getFieldNameAndPath();
367
-        $dataType = $this->getDataType();
368
-        $fieldName = $this->getFieldName();
369
-
370
-        return Tca::grid()->isEditable($fieldNameAndPath)
371
-        && Tca::table($dataType)->hasField($fieldName)
372
-        && Tca::table($dataType)->field($fieldName)->hasNoRelation(); // relation are editable through Renderers only.
373
-    }
374
-
375
-    /**
376
-     * Return the appropriate URI to create the translation.
377
-     *
378
-     * @param int $language
379
-     * @return string
380
-     */
381
-    protected function getLocalizedUri($language)
382
-    {
383
-        // Transmit recursive selection parameter.
384
-        $parameterPrefix = $this->getModuleLoader()->getParameterPrefix();
385
-        $parameters = GeneralUtility::_GP($parameterPrefix);
386
-
387
-        $additionalParameters = array(
388
-            $this->getModuleLoader()->getParameterPrefix() => array(
389
-                'controller' => 'Content',
390
-                'action' => 'localize',
391
-                'format' => 'json',
392
-                'hasRecursiveSelection' => isset($parameters['hasRecursiveSelection']) ? (int)$parameters['hasRecursiveSelection'] : 0,
393
-                'fieldNameAndPath' => $this->getFieldNameAndPath(),
394
-                'language' => $language,
395
-                'matches' => array(
396
-                    'uid' => $this->getObject()->getUid(),
397
-                ),
398
-            ),
399
-        );
400
-
401
-        return $this->getModuleLoader()->getModuleUrl($additionalParameters);
402
-    }
403
-
404
-    /**
405
-     * Compute the value for the Content object according to a field name.
406
-     *
407
-     * @param Content $object
408
-     * @param string $fieldNameAndPath
409
-     * @return string
410
-     */
411
-    protected function resolveValue(Content $object, $fieldNameAndPath)
412
-    {
413
-        // Get the first part of the field name and
414
-        $fieldName = $this->getFieldPathResolver()->stripFieldName($fieldNameAndPath);
415
-
416
-        $value = $object[$fieldName];
417
-
418
-        // Relation but contains no data.
419
-        if (is_array($value) && empty($value)) {
420
-            $value = '';
421
-        } elseif ($value instanceof Content) {
422
-            $fieldNameOfForeignTable = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
423
-
424
-            // true means the field name does not contains a path. "title" vs "metadata.title"
425
-            // Fetch the default label
426
-            if ($fieldNameOfForeignTable === $fieldName) {
427
-                $foreignTable = Tca::table($object->getDataType())->field($fieldName)->getForeignTable();
428
-                $fieldNameOfForeignTable = Tca::table($foreignTable)->getLabelField();
429
-            }
430
-
431
-            $value = $object[$fieldName][$fieldNameOfForeignTable];
432
-        }
433
-
434
-        return $value;
435
-    }
436
-
437
-    /**
438
-     * Check whether a string contains HTML tags.
439
-     *
440
-     * @param string $string the content to be analyzed
441
-     * @return boolean
442
-     */
443
-    protected function hasHtml($string)
444
-    {
445
-        $result = false;
446
-
447
-        // We compare the length of the string with html tags and without html tags.
448
-        if (strlen($string) !== strlen(strip_tags($string))) {
449
-            $result = true;
450
-        }
451
-        return $result;
452
-    }
453
-
454
-    /**
455
-     * Check whether a string contains potential XSS.
456
-     *
457
-     * @param string $string the content to be analyzed
458
-     * @return boolean
459
-     */
460
-    protected function isClean($string)
461
-    {
462
-        // @todo implement me!
463
-        $result = true;
464
-        return $result;
465
-    }
466
-
467
-    /**
468
-     * Process the value
469
-     *
470
-     * @todo implement me as a processor chain to be cleaner implementation wise. Look out at the performance however!
471
-     *       e.g DefaultValueGridProcessor, TextAreaGridProcessor, ...
472
-     *
473
-     * @param string $value
474
-     * @param Content $object
475
-     * @param string $fieldNameAndPath
476
-     * @return string
477
-     * @throws InvalidKeyInArrayException
478
-     */
479
-    protected function processValue($value, Content $object, $fieldNameAndPath)
480
-    {
481
-        // Set default value if $field name correspond to the label of the table
482
-        $fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
483
-        if (Tca::table($object->getDataType())->getLabelField() === $fieldName && empty($value)) {
484
-            $value = sprintf('[%s]', $this->getLabelService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title'));
485
-        }
486
-
487
-        // Sanitize the value in case of "select" or "radio button".
488
-        if (is_scalar($value)) {
489
-            $fieldType = Tca::table($object->getDataType())->field($fieldNameAndPath)->getType();
490
-            if ($fieldType !== FieldType::TEXTAREA) {
491
-                $value = htmlspecialchars($value);
492
-            } elseif ($fieldType === FieldType::TEXTAREA && !$this->isClean($value)) {
493
-                $value = htmlspecialchars($value); // Avoid bad surprise, converts characters to HTML.
494
-            } elseif ($fieldType === FieldType::TEXTAREA && !$this->hasHtml($value)) {
495
-                $value = nl2br($value);
496
-            }
497
-        }
498
-
499
-        return $value;
500
-    }
501
-
502
-    /**
503
-     * Possible value formatting.
504
-     *
505
-     * @param string $value
506
-     * @param array $configuration
507
-     * @return string
508
-     * @throws \InvalidArgumentException
509
-     */
510
-    protected function formatValue($value, array $configuration)
511
-    {
512
-        if (empty($configuration['format'])) {
513
-            return $value;
514
-        }
515
-        $className = $configuration['format'];
516
-
517
-        /** @var FormatterInterface $formatter */
518
-        $formatter = GeneralUtility::makeInstance($className);
519
-        $value = $formatter->format($value);
520
-
521
-        return $value;
522
-    }
523
-
524
-    /**
525
-     * Possible value wrapping.
526
-     *
527
-     * @param string $value
528
-     * @param array $configuration
529
-     * @return string
530
-     */
531
-    protected function wrapValue($value, array $configuration)
532
-    {
533
-        if (!empty($configuration['wrap'])) {
534
-            $parts = explode('|', $configuration['wrap']);
535
-            $value = implode($value, $parts);
536
-        }
537
-        return $value;
538
-    }
539
-
540
-    /**
541
-     * Tell whether the field in the context really exists.
542
-     *
543
-     * @return bool
544
-     */
545
-    protected function fieldExists()
546
-    {
547
-        if ($this->variables['hasField'] === null) {
548
-            $dataType = $this->getDataType();
549
-            $fieldName = $this->getFieldName();
550
-            $this->variables['hasField'] = Tca::table($dataType)->hasField($fieldName);
551
-        }
552
-        return $this->variables['hasField'];
553
-    }
554
-
555
-    /**
556
-     * @return string
557
-     */
558
-    protected function getDataType()
559
-    {
560
-        return $this->variables['dataType'];
561
-    }
562
-
563
-    /**
564
-     * @return string
565
-     */
566
-    protected function getFieldName()
567
-    {
568
-        return $this->variables['fieldName'];
569
-    }
570
-
571
-    /**
572
-     * @return string
573
-     */
574
-    protected function getFieldNameAndPath()
575
-    {
576
-        return $this->variables['fieldNameAndPath'];
577
-    }
578
-
579
-    /**
580
-     * @return Content
581
-     */
582
-    protected function getObject()
583
-    {
584
-        return $this->variables['object'];
585
-    }
586
-
587
-    /**
588
-     * @return Content
589
-     * @throws \InvalidArgumentException
590
-     */
591
-    protected function getResolvedObject()
592
-    {
593
-        if (empty($this->variables['resolvedObject'])) {
594
-            $object = $this->getObject();
595
-            $fieldNameAndPath = $this->getFieldNameAndPath();
596
-            $this->variables['resolvedObject'] = $this->getContentObjectResolver()->getObject($object, $fieldNameAndPath);
597
-        }
598
-        return $this->variables['resolvedObject'];
599
-    }
600
-
601
-    /**
602
-     * @return FieldPathResolver|object
603
-     * @throws \InvalidArgumentException
604
-     */
605
-    protected function getFieldPathResolver()
606
-    {
607
-        return GeneralUtility::makeInstance(FieldPathResolver::class);
608
-    }
609
-
610
-    /**
611
-     * @return ContentObjectResolver|object
612
-     * @throws \InvalidArgumentException
613
-     */
614
-    protected function getContentObjectResolver()
615
-    {
616
-        return GeneralUtility::makeInstance(ContentObjectResolver::class);
617
-    }
618
-
619
-    /**
620
-     * @return \TYPO3\CMS\Core\Localization\LanguageService
621
-     */
622
-    protected function getLabelService()
623
-    {
624
-        return $GLOBALS['LANG'];
625
-    }
626
-
627
-    /**
628
-     * @return LanguageService|object
629
-     * @throws \InvalidArgumentException
630
-     */
631
-    protected function getLanguageService()
632
-    {
633
-        return GeneralUtility::makeInstance(LanguageService::class);
634
-    }
29
+	/**
30
+	 * @var array
31
+	 */
32
+	protected $columns = [];
33
+
34
+	/**
35
+	 * Registry for storing variable values and speed up the processing.
36
+	 *
37
+	 * @var array
38
+	 */
39
+	protected $variables = [];
40
+
41
+	/**
42
+	 * @param array $columns
43
+	 */
44
+	public function __construct(array $columns = [])
45
+	{
46
+		$this->columns = $columns;
47
+	}
48
+
49
+	/**
50
+	 * Render a row to be displayed in the Grid given an Content Object.
51
+	 *
52
+	 * @param Content $object
53
+	 * @param int $rowIndex
54
+	 * @return array
55
+	 * @throws \Exception
56
+	 */
57
+	public function render(Content $object = null, $rowIndex = 0)
58
+	{
59
+		// Initialize returned array
60
+		$output = [];
61
+
62
+		foreach (Tca::grid()->getFields() as $fieldNameAndPath => $configuration) {
63
+			$value = ''; // default is empty at first.
64
+
65
+			$this->computeVariables($object, $fieldNameAndPath);
66
+
67
+			// Only compute the value if it is going to be shown in the Grid. Lost of time otherwise!
68
+			if (in_array($fieldNameAndPath, $this->columns)) {
69
+				// Fetch value
70
+				if (Tca::grid()->hasRenderers($fieldNameAndPath)) {
71
+					$value = '';
72
+					$renderers = Tca::grid()->getRenderers($fieldNameAndPath);
73
+
74
+					// if is relation has one
75
+					foreach ($renderers as $rendererClassName => $rendererConfiguration) {
76
+						/** @var $rendererObject \Fab\Vidi\Grid\ColumnRendererInterface */
77
+						$rendererObject = GeneralUtility::makeInstance($rendererClassName);
78
+						$value .= $rendererObject
79
+							->setObject($object)
80
+							->setFieldName($fieldNameAndPath)
81
+							->setRowIndex($rowIndex)
82
+							->setFieldConfiguration($configuration)
83
+							->setGridRendererConfiguration($rendererConfiguration)
84
+							->render();
85
+					}
86
+				} else {
87
+					$value = $this->resolveValue($object, $fieldNameAndPath);
88
+					$value = $this->processValue($value, $object, $fieldNameAndPath); // post resolve processing.
89
+				}
90
+
91
+				// Possible formatting given by configuration. @see TCA['grid']
92
+				$value = $this->formatValue($value, $configuration);
93
+
94
+				// Here, there is the chance to further "decorate" the value for inline editing, localization, ...
95
+				if ($this->willBeEnriched()) {
96
+					$localizedStructure = $this->initializeLocalizedStructure($value);
97
+
98
+					if ($this->isEditable()) {
99
+						$localizedStructure = $this->addEditableMarkup($localizedStructure);
100
+					}
101
+
102
+					if ($this->isLocalized()) {
103
+						$localizedStructure = $this->addLocalizationMarkup($localizedStructure);
104
+					}
105
+
106
+					if ($this->hasIcon()) {
107
+						$localizedStructure = $this->addSpriteIconMarkup($localizedStructure);
108
+					}
109
+
110
+					$value = $this->flattenStructure($localizedStructure);
111
+				}
112
+
113
+				// Final wrap given by configuration. @see TCA['grid']
114
+				$value = $this->wrapValue($value, $configuration);
115
+			}
116
+
117
+			$output[$this->getFieldName()] = $value;
118
+		}
119
+
120
+		$output['DT_RowId'] = 'row-' . $object->getUid();
121
+		$output['DT_RowClass'] = sprintf('%s_%s', $object->getDataType(), $object->getUid());
122
+
123
+		return $output;
124
+	}
125
+
126
+	/**
127
+	 * Flatten the localized structure to render the final value
128
+	 *
129
+	 * @param array $localizedStructure
130
+	 * @return string
131
+	 */
132
+	protected function flattenStructure(array $localizedStructure)
133
+	{
134
+		// Flatten the structure.
135
+		$value = '';
136
+		foreach ($localizedStructure as $structure) {
137
+			$value .= sprintf(
138
+				'<div class="%s">%s</div>',
139
+				$structure['status'] !== LocalizationStatus::LOCALIZED ? 'invisible' : '',
140
+				$structure['value']
141
+			);
142
+		}
143
+		return $value;
144
+	}
145
+
146
+	/**
147
+	 * Store some often used variable values and speed up the processing.
148
+	 *
149
+	 * @param Content $object
150
+	 * @param string $fieldNameAndPath
151
+	 * @return void
152
+	 */
153
+	protected function computeVariables(Content $object, $fieldNameAndPath)
154
+	{
155
+		$this->variables = [];
156
+		$this->variables['dataType'] = $this->getFieldPathResolver()->getDataType($fieldNameAndPath);
157
+		$this->variables['fieldName'] = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
158
+		$this->variables['fieldNameAndPath'] = $fieldNameAndPath;
159
+		$this->variables['object'] = $object;
160
+	}
161
+
162
+	/**
163
+	 * Tell whether the object will be decorated / wrapped such as
164
+	 *
165
+	 * @param string $value
166
+	 * @return array
167
+	 */
168
+	protected function initializeLocalizedStructure($value)
169
+	{
170
+		$localizedStructure[] = [
171
+			'value' => empty($value) && $this->isEditable() ? $this->getEmptyValuePlaceholder() : $value,
172
+			'status' => empty($value) ? LocalizationStatus::EMPTY_VALUE : LocalizationStatus::LOCALIZED,
173
+			'language' => 0,
174
+			'languageFlag' => $defaultLanguage = $this->getLanguageService()->getDefaultFlag(),
175
+		];
176
+
177
+		if ($this->isLocalized()) {
178
+			foreach ($this->getLanguageService()->getLanguages() as $language) {
179
+				// Make sure the language is allowed for the current Backend User.
180
+				if ($this->isLanguageAllowedForBackendUser($language)) {
181
+					$resolvedObject = $this->getResolvedObject();
182
+					$fieldName = $this->getFieldName();
183
+
184
+					if ($this->getLanguageService()->hasLocalization($resolvedObject, $language['uid'])) {
185
+						$localizedValue = $this->getLanguageService()->getLocalizedFieldName($resolvedObject, $language['uid'], $fieldName);
186
+						$status = LocalizationStatus::LOCALIZED;
187
+
188
+						// Replace blank value by something more meaningful for the End User.
189
+						if (empty($localizedValue)) {
190
+							$status = LocalizationStatus::EMPTY_VALUE;
191
+							$localizedValue = $this->isEditable() ? $this->getEmptyValuePlaceholder() : '';
192
+						}
193
+					} else {
194
+						$localizedValue = sprintf(
195
+							'<a href="%s" style="color: black">%s</a>',
196
+							$this->getLocalizedUri($language['uid']),
197
+							$this->getLabelService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:create_translation')
198
+						);
199
+						$status = LocalizationStatus::NOT_YET_LOCALIZED;
200
+					}
201
+
202
+					// Feed structure.
203
+					$localizedStructure[] = [
204
+						'value' => $localizedValue,
205
+						'status' => $status,
206
+						'language' => (int)$language['uid'],
207
+						'languageFlag' => $language['flag'],
208
+					];
209
+				}
210
+			}
211
+		}
212
+
213
+		return $localizedStructure;
214
+	}
215
+
216
+	/**
217
+	 * @param array $language
218
+	 * @return bool
219
+	 */
220
+	protected function isLanguageAllowedForBackendUser(array $language)
221
+	{
222
+		return $this->getBackendUser()->checkLanguageAccess($language['uid']);
223
+	}
224
+
225
+	/**
226
+	 * Returns a placeholder when the value is empty.
227
+	 *
228
+	 * @return string
229
+	 */
230
+	protected function getEmptyValuePlaceholder()
231
+	{
232
+		return sprintf(
233
+			'<i>%s</i>',
234
+			$this->getLabelService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:start_editing')
235
+		);
236
+	}
237
+
238
+	/**
239
+	 * Tell whether the object will be decorated (or wrapped) for inline editing, localization purpose.
240
+	 *
241
+	 * @return bool
242
+	 */
243
+	protected function willBeEnriched()
244
+	{
245
+		$willBeEnriched = false;
246
+
247
+		if ($this->fieldExists()) {
248
+			$willBeEnriched = $this->isEditable() || $this->hasIcon() || $this->isLocalized();
249
+		}
250
+
251
+		return $willBeEnriched;
252
+	}
253
+
254
+	/**
255
+	 * Tell whether the field in the context will be prepended by an icon.
256
+	 *
257
+	 * @return bool
258
+	 */
259
+	protected function hasIcon()
260
+	{
261
+		$dataType = $this->getDataType();
262
+		return Tca::table($dataType)->getLabelField() === $this->getFieldName();
263
+	}
264
+
265
+	/**
266
+	 * Tell whether the field in the context will be prepended by an icon.
267
+	 *
268
+	 * @return bool
269
+	 */
270
+	protected function isLocalized()
271
+	{
272
+		$object = $this->getObject();
273
+		$fieldName = $this->getFieldName();
274
+		$dataType = $this->getDataType();
275
+		$fieldNameAndPath = $this->getFieldNameAndPath();
276
+
277
+		return $this->getLanguageService()->hasLanguages()
278
+		&& Tca::grid($object)->isLocalized($fieldNameAndPath)
279
+		&& Tca::table($dataType)->field($fieldName)->isLocalized();
280
+	}
281
+
282
+	/**
283
+	 * Add some markup to have the content editable in the Grid.
284
+	 *
285
+	 * @param array $localizedStructure
286
+	 * @return array
287
+	 */
288
+	protected function addEditableMarkup(array $localizedStructure)
289
+	{
290
+		$dataType = $this->getDataType();
291
+		$fieldName = $this->getFieldName();
292
+
293
+		foreach ($localizedStructure as $index => $structure) {
294
+			if ($structure['status'] !== LocalizationStatus::NOT_YET_LOCALIZED) {
295
+				$localizedStructure[$index]['value'] = sprintf(
296
+					'<span class="%s" data-language="%s">%s</span>',
297
+					Tca::table($dataType)->field($fieldName)->isTextArea() ? 'editable-textarea' : 'editable-textfield',
298
+					$structure['language'],
299
+					$structure['value']
300
+				);
301
+			}
302
+		}
303
+		return $localizedStructure;
304
+	}
305
+
306
+	/**
307
+	 * Add some markup related to the localization.
308
+	 *
309
+	 * @param array $localizedStructure
310
+	 * @return array
311
+	 */
312
+	protected function addLocalizationMarkup(array $localizedStructure)
313
+	{
314
+		foreach ($localizedStructure as $index => $structure) {
315
+			$localizedStructure[$index]['value'] = sprintf(
316
+				'<span>%s %s</span>',
317
+				empty($structure['languageFlag']) ? '' : $this->getIconFactory()->getIcon('flags-' . $structure['languageFlag'], Icon::SIZE_SMALL),
318
+				$structure['value']
319
+			);
320
+		}
321
+		return $localizedStructure;
322
+	}
323
+
324
+	/**
325
+	 * Add some markup related to the prepended icon.
326
+	 *
327
+	 * @param array $localizedStructure
328
+	 * @return array
329
+	 */
330
+	protected function addSpriteIconMarkup(array $localizedStructure)
331
+	{
332
+		$object = $this->getObject();
333
+
334
+		foreach ($localizedStructure as $index => $structure) {
335
+			$recordData = [];
336
+
337
+			$enablesMethods = array('Hidden', 'Deleted', 'StartTime', 'EndTime');
338
+			foreach ($enablesMethods as $enableMethod) {
339
+				$methodName = 'get' . $enableMethod . 'Field';
340
+
341
+				// Fetch possible hidden filed.
342
+				$enableField = Tca::table($object)->$methodName();
343
+				if ($enableField) {
344
+					$recordData[$enableField] = $object[$enableField];
345
+				}
346
+			}
347
+
348
+			// Get Enable Fields of the object to render the sprite with overlays.
349
+			$localizedStructure[$index]['value'] = sprintf(
350
+				'%s %s',
351
+				$this->getIconFactory()->getIconForRecord($object->getDataType(), $recordData, Icon::SIZE_SMALL),
352
+				$structure['value']
353
+			);
354
+		}
355
+
356
+		return $localizedStructure;
357
+	}
358
+
359
+	/**
360
+	 * Return whether the field given by the context is editable.
361
+	 *
362
+	 * @return boolean
363
+	 */
364
+	protected function isEditable()
365
+	{
366
+		$fieldNameAndPath = $this->getFieldNameAndPath();
367
+		$dataType = $this->getDataType();
368
+		$fieldName = $this->getFieldName();
369
+
370
+		return Tca::grid()->isEditable($fieldNameAndPath)
371
+		&& Tca::table($dataType)->hasField($fieldName)
372
+		&& Tca::table($dataType)->field($fieldName)->hasNoRelation(); // relation are editable through Renderers only.
373
+	}
374
+
375
+	/**
376
+	 * Return the appropriate URI to create the translation.
377
+	 *
378
+	 * @param int $language
379
+	 * @return string
380
+	 */
381
+	protected function getLocalizedUri($language)
382
+	{
383
+		// Transmit recursive selection parameter.
384
+		$parameterPrefix = $this->getModuleLoader()->getParameterPrefix();
385
+		$parameters = GeneralUtility::_GP($parameterPrefix);
386
+
387
+		$additionalParameters = array(
388
+			$this->getModuleLoader()->getParameterPrefix() => array(
389
+				'controller' => 'Content',
390
+				'action' => 'localize',
391
+				'format' => 'json',
392
+				'hasRecursiveSelection' => isset($parameters['hasRecursiveSelection']) ? (int)$parameters['hasRecursiveSelection'] : 0,
393
+				'fieldNameAndPath' => $this->getFieldNameAndPath(),
394
+				'language' => $language,
395
+				'matches' => array(
396
+					'uid' => $this->getObject()->getUid(),
397
+				),
398
+			),
399
+		);
400
+
401
+		return $this->getModuleLoader()->getModuleUrl($additionalParameters);
402
+	}
403
+
404
+	/**
405
+	 * Compute the value for the Content object according to a field name.
406
+	 *
407
+	 * @param Content $object
408
+	 * @param string $fieldNameAndPath
409
+	 * @return string
410
+	 */
411
+	protected function resolveValue(Content $object, $fieldNameAndPath)
412
+	{
413
+		// Get the first part of the field name and
414
+		$fieldName = $this->getFieldPathResolver()->stripFieldName($fieldNameAndPath);
415
+
416
+		$value = $object[$fieldName];
417
+
418
+		// Relation but contains no data.
419
+		if (is_array($value) && empty($value)) {
420
+			$value = '';
421
+		} elseif ($value instanceof Content) {
422
+			$fieldNameOfForeignTable = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
423
+
424
+			// true means the field name does not contains a path. "title" vs "metadata.title"
425
+			// Fetch the default label
426
+			if ($fieldNameOfForeignTable === $fieldName) {
427
+				$foreignTable = Tca::table($object->getDataType())->field($fieldName)->getForeignTable();
428
+				$fieldNameOfForeignTable = Tca::table($foreignTable)->getLabelField();
429
+			}
430
+
431
+			$value = $object[$fieldName][$fieldNameOfForeignTable];
432
+		}
433
+
434
+		return $value;
435
+	}
436
+
437
+	/**
438
+	 * Check whether a string contains HTML tags.
439
+	 *
440
+	 * @param string $string the content to be analyzed
441
+	 * @return boolean
442
+	 */
443
+	protected function hasHtml($string)
444
+	{
445
+		$result = false;
446
+
447
+		// We compare the length of the string with html tags and without html tags.
448
+		if (strlen($string) !== strlen(strip_tags($string))) {
449
+			$result = true;
450
+		}
451
+		return $result;
452
+	}
453
+
454
+	/**
455
+	 * Check whether a string contains potential XSS.
456
+	 *
457
+	 * @param string $string the content to be analyzed
458
+	 * @return boolean
459
+	 */
460
+	protected function isClean($string)
461
+	{
462
+		// @todo implement me!
463
+		$result = true;
464
+		return $result;
465
+	}
466
+
467
+	/**
468
+	 * Process the value
469
+	 *
470
+	 * @todo implement me as a processor chain to be cleaner implementation wise. Look out at the performance however!
471
+	 *       e.g DefaultValueGridProcessor, TextAreaGridProcessor, ...
472
+	 *
473
+	 * @param string $value
474
+	 * @param Content $object
475
+	 * @param string $fieldNameAndPath
476
+	 * @return string
477
+	 * @throws InvalidKeyInArrayException
478
+	 */
479
+	protected function processValue($value, Content $object, $fieldNameAndPath)
480
+	{
481
+		// Set default value if $field name correspond to the label of the table
482
+		$fieldName = $this->getFieldPathResolver()->stripFieldPath($fieldNameAndPath);
483
+		if (Tca::table($object->getDataType())->getLabelField() === $fieldName && empty($value)) {
484
+			$value = sprintf('[%s]', $this->getLabelService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title'));
485
+		}
486
+
487
+		// Sanitize the value in case of "select" or "radio button".
488
+		if (is_scalar($value)) {
489
+			$fieldType = Tca::table($object->getDataType())->field($fieldNameAndPath)->getType();
490
+			if ($fieldType !== FieldType::TEXTAREA) {
491
+				$value = htmlspecialchars($value);
492
+			} elseif ($fieldType === FieldType::TEXTAREA && !$this->isClean($value)) {
493
+				$value = htmlspecialchars($value); // Avoid bad surprise, converts characters to HTML.
494
+			} elseif ($fieldType === FieldType::TEXTAREA && !$this->hasHtml($value)) {
495
+				$value = nl2br($value);
496
+			}
497
+		}
498
+
499
+		return $value;
500
+	}
501
+
502
+	/**
503
+	 * Possible value formatting.
504
+	 *
505
+	 * @param string $value
506
+	 * @param array $configuration
507
+	 * @return string
508
+	 * @throws \InvalidArgumentException
509
+	 */
510
+	protected function formatValue($value, array $configuration)
511
+	{
512
+		if (empty($configuration['format'])) {
513
+			return $value;
514
+		}
515
+		$className = $configuration['format'];
516
+
517
+		/** @var FormatterInterface $formatter */
518
+		$formatter = GeneralUtility::makeInstance($className);
519
+		$value = $formatter->format($value);
520
+
521
+		return $value;
522
+	}
523
+
524
+	/**
525
+	 * Possible value wrapping.
526
+	 *
527
+	 * @param string $value
528
+	 * @param array $configuration
529
+	 * @return string
530
+	 */
531
+	protected function wrapValue($value, array $configuration)
532
+	{
533
+		if (!empty($configuration['wrap'])) {
534
+			$parts = explode('|', $configuration['wrap']);
535
+			$value = implode($value, $parts);
536
+		}
537
+		return $value;
538
+	}
539
+
540
+	/**
541
+	 * Tell whether the field in the context really exists.
542
+	 *
543
+	 * @return bool
544
+	 */
545
+	protected function fieldExists()
546
+	{
547
+		if ($this->variables['hasField'] === null) {
548
+			$dataType = $this->getDataType();
549
+			$fieldName = $this->getFieldName();
550
+			$this->variables['hasField'] = Tca::table($dataType)->hasField($fieldName);
551
+		}
552
+		return $this->variables['hasField'];
553
+	}
554
+
555
+	/**
556
+	 * @return string
557
+	 */
558
+	protected function getDataType()
559
+	{
560
+		return $this->variables['dataType'];
561
+	}
562
+
563
+	/**
564
+	 * @return string
565
+	 */
566
+	protected function getFieldName()
567
+	{
568
+		return $this->variables['fieldName'];
569
+	}
570
+
571
+	/**
572
+	 * @return string
573
+	 */
574
+	protected function getFieldNameAndPath()
575
+	{
576
+		return $this->variables['fieldNameAndPath'];
577
+	}
578
+
579
+	/**
580
+	 * @return Content
581
+	 */
582
+	protected function getObject()
583
+	{
584
+		return $this->variables['object'];
585
+	}
586
+
587
+	/**
588
+	 * @return Content
589
+	 * @throws \InvalidArgumentException
590
+	 */
591
+	protected function getResolvedObject()
592
+	{
593
+		if (empty($this->variables['resolvedObject'])) {
594
+			$object = $this->getObject();
595
+			$fieldNameAndPath = $this->getFieldNameAndPath();
596
+			$this->variables['resolvedObject'] = $this->getContentObjectResolver()->getObject($object, $fieldNameAndPath);
597
+		}
598
+		return $this->variables['resolvedObject'];
599
+	}
600
+
601
+	/**
602
+	 * @return FieldPathResolver|object
603
+	 * @throws \InvalidArgumentException
604
+	 */
605
+	protected function getFieldPathResolver()
606
+	{
607
+		return GeneralUtility::makeInstance(FieldPathResolver::class);
608
+	}
609
+
610
+	/**
611
+	 * @return ContentObjectResolver|object
612
+	 * @throws \InvalidArgumentException
613
+	 */
614
+	protected function getContentObjectResolver()
615
+	{
616
+		return GeneralUtility::makeInstance(ContentObjectResolver::class);
617
+	}
618
+
619
+	/**
620
+	 * @return \TYPO3\CMS\Core\Localization\LanguageService
621
+	 */
622
+	protected function getLabelService()
623
+	{
624
+		return $GLOBALS['LANG'];
625
+	}
626
+
627
+	/**
628
+	 * @return LanguageService|object
629
+	 * @throws \InvalidArgumentException
630
+	 */
631
+	protected function getLanguageService()
632
+	{
633
+		return GeneralUtility::makeInstance(LanguageService::class);
634
+	}
635 635
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
             $output[$this->getFieldName()] = $value;
118 118
         }
119 119
 
120
-        $output['DT_RowId'] = 'row-' . $object->getUid();
120
+        $output['DT_RowId'] = 'row-'.$object->getUid();
121 121
         $output['DT_RowClass'] = sprintf('%s_%s', $object->getDataType(), $object->getUid());
122 122
 
123 123
         return $output;
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
         foreach ($localizedStructure as $index => $structure) {
315 315
             $localizedStructure[$index]['value'] = sprintf(
316 316
                 '<span>%s %s</span>',
317
-                empty($structure['languageFlag']) ? '' : $this->getIconFactory()->getIcon('flags-' . $structure['languageFlag'], Icon::SIZE_SMALL),
317
+                empty($structure['languageFlag']) ? '' : $this->getIconFactory()->getIcon('flags-'.$structure['languageFlag'], Icon::SIZE_SMALL),
318 318
                 $structure['value']
319 319
             );
320 320
         }
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 
337 337
             $enablesMethods = array('Hidden', 'Deleted', 'StartTime', 'EndTime');
338 338
             foreach ($enablesMethods as $enableMethod) {
339
-                $methodName = 'get' . $enableMethod . 'Field';
339
+                $methodName = 'get'.$enableMethod.'Field';
340 340
 
341 341
                 // Fetch possible hidden filed.
342 342
                 $enableField = Tca::table($object)->$methodName();
Please login to merge, or discard this patch.
Classes/View/MenuItem/MassDeleteMenuItem.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -17,35 +17,35 @@
 block discarded – undo
17 17
  */
18 18
 class MassDeleteMenuItem extends AbstractComponentView
19 19
 {
20
-    /**
21
-     * Renders a "mass delete" menu item to be placed in the grid menu.
22
-     *
23
-     * @return string
24
-     * @throws \InvalidArgumentException
25
-     */
26
-    public function render()
27
-    {
28
-        return sprintf(
29
-            '<li><a href="%s" class="dropdown-item mass-delete" >%s %s</a>',
30
-            $this->getMassDeleteUri(),
31
-            $this->getIconFactory()->getIcon('actions-edit-delete', Icon::SIZE_SMALL),
32
-            $this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:delete')
33
-        );
34
-    }
20
+	/**
21
+	 * Renders a "mass delete" menu item to be placed in the grid menu.
22
+	 *
23
+	 * @return string
24
+	 * @throws \InvalidArgumentException
25
+	 */
26
+	public function render()
27
+	{
28
+		return sprintf(
29
+			'<li><a href="%s" class="dropdown-item mass-delete" >%s %s</a>',
30
+			$this->getMassDeleteUri(),
31
+			$this->getIconFactory()->getIcon('actions-edit-delete', Icon::SIZE_SMALL),
32
+			$this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:delete')
33
+		);
34
+	}
35 35
 
36
-    /**
37
-     * @return string
38
-     * @throws \InvalidArgumentException
39
-     */
40
-    protected function getMassDeleteUri()
41
-    {
42
-        $additionalParameters = array(
43
-            $this->getModuleLoader()->getParameterPrefix() => array(
44
-                'controller' => 'Content',
45
-                'action' => 'delete',
46
-                'format' => 'json',
47
-            ),
48
-        );
49
-        return $this->getModuleLoader()->getModuleUrl($additionalParameters);
50
-    }
36
+	/**
37
+	 * @return string
38
+	 * @throws \InvalidArgumentException
39
+	 */
40
+	protected function getMassDeleteUri()
41
+	{
42
+		$additionalParameters = array(
43
+			$this->getModuleLoader()->getParameterPrefix() => array(
44
+				'controller' => 'Content',
45
+				'action' => 'delete',
46
+				'format' => 'json',
47
+			),
48
+		);
49
+		return $this->getModuleLoader()->getModuleUrl($additionalParameters);
50
+	}
51 51
 }
Please login to merge, or discard this patch.
Classes/View/MenuItem/ExportXmlMenuItem.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -17,20 +17,20 @@
 block discarded – undo
17 17
  */
18 18
 class ExportXmlMenuItem extends AbstractComponentView
19 19
 {
20
-    /**
21
-     * Renders an "xml export" item to be placed in the menu.
22
-     * Only the admin is allowed to export for now as security is not handled.
23
-     *
24
-     * @return string
25
-     * @throws \InvalidArgumentException
26
-     */
27
-    public function render()
28
-    {
29
-        $result = sprintf(
30
-            '<li><a href="#" class="dropdown-item export-xml" data-format="xml">%s %s</a></li>',
31
-            $this->getIconFactory()->getIcon('mimetypes-text-html', Icon::SIZE_SMALL),
32
-            $this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:export-xml')
33
-        );
34
-        return $result;
35
-    }
20
+	/**
21
+	 * Renders an "xml export" item to be placed in the menu.
22
+	 * Only the admin is allowed to export for now as security is not handled.
23
+	 *
24
+	 * @return string
25
+	 * @throws \InvalidArgumentException
26
+	 */
27
+	public function render()
28
+	{
29
+		$result = sprintf(
30
+			'<li><a href="#" class="dropdown-item export-xml" data-format="xml">%s %s</a></li>',
31
+			$this->getIconFactory()->getIcon('mimetypes-text-html', Icon::SIZE_SMALL),
32
+			$this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:export-xml')
33
+		);
34
+		return $result;
35
+	}
36 36
 }
Please login to merge, or discard this patch.
Classes/View/MenuItem/DividerMenuItem.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@
 block discarded – undo
16 16
  */
17 17
 class DividerMenuItem extends AbstractComponentView
18 18
 {
19
-    /**
20
-     * Renders a "divider" menu item to be placed in the grid menu.
21
-     *
22
-     * @return string
23
-     */
24
-    public function render()
25
-    {
26
-        return ' <li><hr class="dropdown-divider"></li>';
27
-    }
19
+	/**
20
+	 * Renders a "divider" menu item to be placed in the grid menu.
21
+	 *
22
+	 * @return string
23
+	 */
24
+	public function render()
25
+	{
26
+		return ' <li><hr class="dropdown-divider"></li>';
27
+	}
28 28
 }
Please login to merge, or discard this patch.
Classes/View/MenuItem/MassEditMenuItem.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -17,18 +17,18 @@
 block discarded – undo
17 17
  */
18 18
 class MassEditMenuItem extends AbstractComponentView
19 19
 {
20
-    /**
21
-     * Renders a "mass edit" menu item to be placed in the grid menu.
22
-     *
23
-     * @return string
24
-     * @throws \InvalidArgumentException
25
-     */
26
-    public function render()
27
-    {
28
-        return sprintf(
29
-            '<li><a href="#" class="dropdown-item mass-edit">%s %s (not implemented)</a></li>',
30
-            $this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL),
31
-            $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:edit')
32
-        );
33
-    }
20
+	/**
21
+	 * Renders a "mass edit" menu item to be placed in the grid menu.
22
+	 *
23
+	 * @return string
24
+	 * @throws \InvalidArgumentException
25
+	 */
26
+	public function render()
27
+	{
28
+		return sprintf(
29
+			'<li><a href="#" class="dropdown-item mass-edit">%s %s (not implemented)</a></li>',
30
+			$this->getIconFactory()->getIcon('actions-document-open', Icon::SIZE_SMALL),
31
+			$this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:edit')
32
+		);
33
+	}
34 34
 }
Please login to merge, or discard this patch.
Classes/View/MenuItem/ExportXlsMenuItem.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -17,20 +17,20 @@
 block discarded – undo
17 17
  */
18 18
 class ExportXlsMenuItem extends AbstractComponentView
19 19
 {
20
-    /**
21
-     * Renders a "xls export" item to be placed in the menu.
22
-     * Only the admin is allowed to export for now as security is not handled.
23
-     *
24
-     * @return string
25
-     * @throws \InvalidArgumentException
26
-     */
27
-    public function render()
28
-    {
29
-        $result = sprintf(
30
-            '<li><a href="#" class="dropdown-item export-xls" data-format="xls">%s %s</a></li>',
31
-            $this->getIconFactory()->getIcon('mimetypes-excel', Icon::SIZE_SMALL),
32
-            $this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:export-xls')
33
-        );
34
-        return $result;
35
-    }
20
+	/**
21
+	 * Renders a "xls export" item to be placed in the menu.
22
+	 * Only the admin is allowed to export for now as security is not handled.
23
+	 *
24
+	 * @return string
25
+	 * @throws \InvalidArgumentException
26
+	 */
27
+	public function render()
28
+	{
29
+		$result = sprintf(
30
+			'<li><a href="#" class="dropdown-item export-xls" data-format="xls">%s %s</a></li>',
31
+			$this->getIconFactory()->getIcon('mimetypes-excel', Icon::SIZE_SMALL),
32
+			$this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:export-xls')
33
+		);
34
+		return $result;
35
+	}
36 36
 }
Please login to merge, or discard this patch.
Classes/View/MenuItem/ExportCsvMenuItem.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -17,20 +17,20 @@
 block discarded – undo
17 17
  */
18 18
 class ExportCsvMenuItem extends AbstractComponentView
19 19
 {
20
-    /**
21
-     * Renders a "csv export" item to be placed in the menu.
22
-     * Only the admin is allowed to export for now as security is not handled.
23
-     *
24
-     * @return string
25
-     * @throws \InvalidArgumentException
26
-     */
27
-    public function render()
28
-    {
29
-        $result = sprintf(
30
-            '<li><a href="#" class="dropdown-item export-csv" data-format="csv">%s %s</a></li>',
31
-            $this->getIconFactory()->getIcon('mimetypes-text-csv', Icon::SIZE_SMALL),
32
-            $this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:export-csv')
33
-        );
34
-        return $result;
35
-    }
20
+	/**
21
+	 * Renders a "csv export" item to be placed in the menu.
22
+	 * Only the admin is allowed to export for now as security is not handled.
23
+	 *
24
+	 * @return string
25
+	 * @throws \InvalidArgumentException
26
+	 */
27
+	public function render()
28
+	{
29
+		$result = sprintf(
30
+			'<li><a href="#" class="dropdown-item export-csv" data-format="csv">%s %s</a></li>',
31
+			$this->getIconFactory()->getIcon('mimetypes-text-csv', Icon::SIZE_SMALL),
32
+			$this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:export-csv')
33
+		);
34
+		return $result;
35
+	}
36 36
 }
Please login to merge, or discard this patch.
Classes/View/MenuItem/ClipboardMenuItem.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -19,45 +19,45 @@
 block discarded – undo
19 19
  */
20 20
 class ClipboardMenuItem extends AbstractComponentView
21 21
 {
22
-    /**
23
-     * Renders a "mass delete" menu item to be placed in the grid menu.
24
-     *
25
-     * @return string
26
-     */
27
-    public function render()
28
-    {
29
-        $output = '';
30
-        if ($this->getMediaModule()->hasFolderTree()) {
31
-            $output = sprintf(
32
-                '<li><a href="%s" class="clipboard-save" >%s %s</a>',
33
-                $this->getSaveInClipboardUri(),
34
-                $this->getIconFactory()->getIcon('actions-document-paste-after', Icon::SIZE_SMALL),
35
-                $this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:save')
36
-            );
37
-        }
38
-        return $output;
39
-    }
22
+	/**
23
+	 * Renders a "mass delete" menu item to be placed in the grid menu.
24
+	 *
25
+	 * @return string
26
+	 */
27
+	public function render()
28
+	{
29
+		$output = '';
30
+		if ($this->getMediaModule()->hasFolderTree()) {
31
+			$output = sprintf(
32
+				'<li><a href="%s" class="clipboard-save" >%s %s</a>',
33
+				$this->getSaveInClipboardUri(),
34
+				$this->getIconFactory()->getIcon('actions-document-paste-after', Icon::SIZE_SMALL),
35
+				$this->getLanguageService()->sL('LLL:EXT:vidi/Resources/Private/Language/locallang.xlf:save')
36
+			);
37
+		}
38
+		return $output;
39
+	}
40 40
 
41
-    /**
42
-     * @return string
43
-     */
44
-    protected function getSaveInClipboardUri()
45
-    {
46
-        $additionalParameters = array(
47
-            $this->getModuleLoader()->getParameterPrefix() => array(
48
-                'controller' => 'Clipboard',
49
-                'action' => 'save',
50
-                'format' => 'json',
51
-            ),
52
-        );
53
-        return $this->getModuleLoader()->getModuleUrl($additionalParameters);
54
-    }
41
+	/**
42
+	 * @return string
43
+	 */
44
+	protected function getSaveInClipboardUri()
45
+	{
46
+		$additionalParameters = array(
47
+			$this->getModuleLoader()->getParameterPrefix() => array(
48
+				'controller' => 'Clipboard',
49
+				'action' => 'save',
50
+				'format' => 'json',
51
+			),
52
+		);
53
+		return $this->getModuleLoader()->getModuleUrl($additionalParameters);
54
+	}
55 55
 
56
-    /**
57
-     * @return MediaModule|object
58
-     */
59
-    protected function getMediaModule()
60
-    {
61
-        return GeneralUtility::makeInstance(MediaModule::class);
62
-    }
56
+	/**
57
+	 * @return MediaModule|object
58
+	 */
59
+	protected function getMediaModule()
60
+	{
61
+		return GeneralUtility::makeInstance(MediaModule::class);
62
+	}
63 63
 }
Please login to merge, or discard this patch.
Classes/Signal/AfterFindContentObjectsSignalArguments.php 1 patch
Indentation   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -17,187 +17,187 @@
 block discarded – undo
17 17
  */
18 18
 class AfterFindContentObjectsSignalArguments
19 19
 {
20
-    /**
21
-     * @var string
22
-     */
23
-    protected $dataType;
24
-
25
-    /**
26
-     * @var array
27
-     */
28
-    protected $contentObjects;
29
-
30
-    /**
31
-     * @var Matcher
32
-     */
33
-    protected $matcher;
34
-
35
-    /**
36
-     * @var Order
37
-     */
38
-    protected $order;
39
-
40
-    /**
41
-     * @var int
42
-     */
43
-    protected $limit;
44
-
45
-    /**
46
-     * @var int
47
-     */
48
-    protected $offset;
49
-
50
-    /**
51
-     * @var bool
52
-     */
53
-    protected $hasBeenProcessed;
54
-
55
-    /**
56
-     * @var int
57
-     */
58
-    protected $numberOfObjects = 0;
59
-
60
-    /**
61
-     * @param array $contentObjects
62
-     * @return $this
63
-     */
64
-    public function setContentObjects($contentObjects)
65
-    {
66
-        $this->contentObjects = $contentObjects;
67
-        return $this;
68
-    }
69
-
70
-    /**
71
-     * @return array
72
-     */
73
-    public function getContentObjects()
74
-    {
75
-        return $this->contentObjects;
76
-    }
77
-
78
-    /**
79
-     * @param string $dataType
80
-     * @return $this
81
-     */
82
-    public function setDataType($dataType)
83
-    {
84
-        $this->dataType = $dataType;
85
-        return $this;
86
-    }
87
-
88
-    /**
89
-     * @return string
90
-     */
91
-    public function getDataType()
92
-    {
93
-        return $this->dataType;
94
-    }
95
-
96
-    /**
97
-     * @param boolean $hasBeenProcessed
98
-     * @return $this
99
-     */
100
-    public function setHasBeenProcessed($hasBeenProcessed)
101
-    {
102
-        $this->hasBeenProcessed = $hasBeenProcessed;
103
-        return $this;
104
-    }
105
-
106
-    /**
107
-     * @return boolean
108
-     */
109
-    public function getHasBeenProcessed()
110
-    {
111
-        return $this->hasBeenProcessed;
112
-    }
113
-
114
-    /**
115
-     * @param int $limit
116
-     * @return $this
117
-     */
118
-    public function setLimit($limit)
119
-    {
120
-        $this->limit = $limit;
121
-        return $this;
122
-    }
123
-
124
-    /**
125
-     * @return int
126
-     */
127
-    public function getLimit()
128
-    {
129
-        return $this->limit;
130
-    }
131
-
132
-    /**
133
-     * @param Matcher $matcher
134
-     * @return $this
135
-     */
136
-    public function setMatcher($matcher)
137
-    {
138
-        $this->matcher = $matcher;
139
-        return $this;
140
-    }
141
-
142
-    /**
143
-     * @return Matcher
144
-     */
145
-    public function getMatcher()
146
-    {
147
-        return $this->matcher;
148
-    }
149
-
150
-    /**
151
-     * @return Order
152
-     */
153
-    public function getOrder()
154
-    {
155
-        return $this->order;
156
-    }
157
-
158
-    /**
159
-     * @param Order $order
160
-     * @return $this
161
-     */
162
-    public function setOrder($order)
163
-    {
164
-        $this->order = $order;
165
-        return $this;
166
-    }
167
-
168
-    /**
169
-     * @param int $numberOfObjects
170
-     * @return $this
171
-     */
172
-    public function setNumberOfObjects($numberOfObjects)
173
-    {
174
-        $this->numberOfObjects = $numberOfObjects;
175
-        return $this;
176
-    }
177
-
178
-    /**
179
-     * @return int
180
-     */
181
-    public function getNumberOfObjects()
182
-    {
183
-        return $this->numberOfObjects;
184
-    }
185
-
186
-    /**
187
-     * @param int $offset
188
-     * @return $this
189
-     */
190
-    public function setOffset($offset)
191
-    {
192
-        $this->offset = $offset;
193
-        return $this;
194
-    }
195
-
196
-    /**
197
-     * @return int
198
-     */
199
-    public function getOffset()
200
-    {
201
-        return $this->offset;
202
-    }
20
+	/**
21
+	 * @var string
22
+	 */
23
+	protected $dataType;
24
+
25
+	/**
26
+	 * @var array
27
+	 */
28
+	protected $contentObjects;
29
+
30
+	/**
31
+	 * @var Matcher
32
+	 */
33
+	protected $matcher;
34
+
35
+	/**
36
+	 * @var Order
37
+	 */
38
+	protected $order;
39
+
40
+	/**
41
+	 * @var int
42
+	 */
43
+	protected $limit;
44
+
45
+	/**
46
+	 * @var int
47
+	 */
48
+	protected $offset;
49
+
50
+	/**
51
+	 * @var bool
52
+	 */
53
+	protected $hasBeenProcessed;
54
+
55
+	/**
56
+	 * @var int
57
+	 */
58
+	protected $numberOfObjects = 0;
59
+
60
+	/**
61
+	 * @param array $contentObjects
62
+	 * @return $this
63
+	 */
64
+	public function setContentObjects($contentObjects)
65
+	{
66
+		$this->contentObjects = $contentObjects;
67
+		return $this;
68
+	}
69
+
70
+	/**
71
+	 * @return array
72
+	 */
73
+	public function getContentObjects()
74
+	{
75
+		return $this->contentObjects;
76
+	}
77
+
78
+	/**
79
+	 * @param string $dataType
80
+	 * @return $this
81
+	 */
82
+	public function setDataType($dataType)
83
+	{
84
+		$this->dataType = $dataType;
85
+		return $this;
86
+	}
87
+
88
+	/**
89
+	 * @return string
90
+	 */
91
+	public function getDataType()
92
+	{
93
+		return $this->dataType;
94
+	}
95
+
96
+	/**
97
+	 * @param boolean $hasBeenProcessed
98
+	 * @return $this
99
+	 */
100
+	public function setHasBeenProcessed($hasBeenProcessed)
101
+	{
102
+		$this->hasBeenProcessed = $hasBeenProcessed;
103
+		return $this;
104
+	}
105
+
106
+	/**
107
+	 * @return boolean
108
+	 */
109
+	public function getHasBeenProcessed()
110
+	{
111
+		return $this->hasBeenProcessed;
112
+	}
113
+
114
+	/**
115
+	 * @param int $limit
116
+	 * @return $this
117
+	 */
118
+	public function setLimit($limit)
119
+	{
120
+		$this->limit = $limit;
121
+		return $this;
122
+	}
123
+
124
+	/**
125
+	 * @return int
126
+	 */
127
+	public function getLimit()
128
+	{
129
+		return $this->limit;
130
+	}
131
+
132
+	/**
133
+	 * @param Matcher $matcher
134
+	 * @return $this
135
+	 */
136
+	public function setMatcher($matcher)
137
+	{
138
+		$this->matcher = $matcher;
139
+		return $this;
140
+	}
141
+
142
+	/**
143
+	 * @return Matcher
144
+	 */
145
+	public function getMatcher()
146
+	{
147
+		return $this->matcher;
148
+	}
149
+
150
+	/**
151
+	 * @return Order
152
+	 */
153
+	public function getOrder()
154
+	{
155
+		return $this->order;
156
+	}
157
+
158
+	/**
159
+	 * @param Order $order
160
+	 * @return $this
161
+	 */
162
+	public function setOrder($order)
163
+	{
164
+		$this->order = $order;
165
+		return $this;
166
+	}
167
+
168
+	/**
169
+	 * @param int $numberOfObjects
170
+	 * @return $this
171
+	 */
172
+	public function setNumberOfObjects($numberOfObjects)
173
+	{
174
+		$this->numberOfObjects = $numberOfObjects;
175
+		return $this;
176
+	}
177
+
178
+	/**
179
+	 * @return int
180
+	 */
181
+	public function getNumberOfObjects()
182
+	{
183
+		return $this->numberOfObjects;
184
+	}
185
+
186
+	/**
187
+	 * @param int $offset
188
+	 * @return $this
189
+	 */
190
+	public function setOffset($offset)
191
+	{
192
+		$this->offset = $offset;
193
+		return $this;
194
+	}
195
+
196
+	/**
197
+	 * @return int
198
+	 */
199
+	public function getOffset()
200
+	{
201
+		return $this->offset;
202
+	}
203 203
 }
Please login to merge, or discard this patch.