|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types = 1); |
|
3
|
|
|
|
|
4
|
|
|
namespace TYPO3\CMS\Backend\View\BackendLayout\Grid; |
|
5
|
|
|
|
|
6
|
|
|
/* |
|
7
|
|
|
* This file is part of the TYPO3 CMS project. |
|
8
|
|
|
* |
|
9
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
10
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
11
|
|
|
* of the License, or any later version. |
|
12
|
|
|
* |
|
13
|
|
|
* For the full copyright and license information, please read the |
|
14
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
15
|
|
|
* |
|
16
|
|
|
* The TYPO3 project - inspiring people to share! |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Grid |
|
21
|
|
|
* |
|
22
|
|
|
* Main rows-and-columns structure representing the rows and columns of |
|
23
|
|
|
* a BackendLayout in object form. Contains getter methods to return rows |
|
24
|
|
|
* and sum of "colspan" values assigned to columns in rows. |
|
25
|
|
|
* |
|
26
|
|
|
* Contains a tree of grid-related objects: |
|
27
|
|
|
* |
|
28
|
|
|
* - Grid |
|
29
|
|
|
* - GridRow |
|
30
|
|
|
* - GridColumn |
|
31
|
|
|
* - GridColumnItem (one per record) |
|
32
|
|
|
* |
|
33
|
|
|
* Accessed in Fluid templates. |
|
34
|
|
|
*/ |
|
35
|
|
|
class Grid extends AbstractGridObject |
|
36
|
|
|
{ |
|
37
|
|
|
/** |
|
38
|
|
|
* @var GridRow[] |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $rows = []; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var bool |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $allowNewContent = true; |
|
46
|
|
|
|
|
47
|
|
|
public function addRow(GridRow $row): void |
|
48
|
|
|
{ |
|
49
|
|
|
$this->rows[] = $row; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @return GridRow[] |
|
54
|
|
|
*/ |
|
55
|
|
|
public function getRows(): iterable |
|
56
|
|
|
{ |
|
57
|
|
|
return $this->rows; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function getColumns(): iterable |
|
61
|
|
|
{ |
|
62
|
|
|
$columns = []; |
|
63
|
|
|
foreach ($this->rows as $gridRow) { |
|
64
|
|
|
$columns += $gridRow->getColumns(); |
|
65
|
|
|
} |
|
66
|
|
|
return $columns; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function isAllowNewContent(): bool |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->allowNewContent; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function setAllowNewContent(bool $allowNewContent): void |
|
75
|
|
|
{ |
|
76
|
|
|
$this->allowNewContent = $allowNewContent; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function getSpan(): int |
|
80
|
|
|
{ |
|
81
|
|
|
if (!isset($this->rows[0]) || $this->backendLayout->getDrawingConfiguration()->getLanguageMode()) { |
|
82
|
|
|
return 1; |
|
83
|
|
|
} |
|
84
|
|
|
$span = 0; |
|
85
|
|
|
foreach ($this->rows[0]->getColumns() ?? [] as $column) { |
|
86
|
|
|
$span += $column->getColSpan(); |
|
87
|
|
|
} |
|
88
|
|
|
return $span ? $span : 1; |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|