1 | <?php |
||
33 | class TCAService |
||
34 | { |
||
35 | /** |
||
36 | * @var array |
||
37 | */ |
||
38 | protected $tca = []; |
||
39 | |||
40 | /** |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $visibilityAffectingFields = []; |
||
44 | |||
45 | /** |
||
46 | * TCAService constructor. |
||
47 | * @param null $TCA |
||
48 | */ |
||
49 | 32 | public function __construct($TCA = null) |
|
53 | |||
54 | /** |
||
55 | * @return integer |
||
56 | */ |
||
57 | 4 | protected function getTime() |
|
61 | |||
62 | /** |
||
63 | * Checks if a record is "enabled" |
||
64 | * |
||
65 | * A record is considered "enabled" if |
||
66 | * - it is not hidden |
||
67 | * - it is not deleted |
||
68 | * - as a page it is not set to be excluded from search |
||
69 | * |
||
70 | * @param string $table The record's table name |
||
71 | * @param array $record The record to check |
||
72 | * @return bool TRUE if the record is enabled, FALSE otherwise |
||
73 | */ |
||
74 | 17 | public function isEnabledRecord($table, $record) |
|
88 | |||
89 | /** |
||
90 | * Checks whether a end time field exists for the record's table and if so |
||
91 | * determines if a time is set and whether that time is in the past, |
||
92 | * making the record invisible on the website. |
||
93 | * |
||
94 | * @param string $table The table name. |
||
95 | * @param array $record An array with record fields that may affect visibility. |
||
96 | * @return bool True if the record's end time is in the past, FALSE otherwise. |
||
97 | */ |
||
98 | 2 | public function isEndTimeInPast($table, $record) |
|
109 | |||
110 | /** |
||
111 | * This method can be used to check if there is a configured key in |
||
112 | * |
||
113 | * $GLOBALS['TCA']['mytable']['ctrl']['enablecolumns'] |
||
114 | * |
||
115 | * Example: |
||
116 | * |
||
117 | * $GLOBALS['TCA']['mytable']]['ctrl']['enablecolumns']['fe_group'] = 'mygroupfield' |
||
118 | * |
||
119 | * ->isEnableColumn('mytable', 'fe_group') will return true, because 'mygroupfield' is |
||
120 | * configured as column. |
||
121 | * |
||
122 | * @params string $table |
||
123 | * @param string $columnName |
||
124 | * @return bool |
||
125 | */ |
||
126 | public function isEnableColumn($table, $columnName) |
||
133 | |||
134 | /** |
||
135 | * Checks whether a start time field exists for the record's table and if so |
||
136 | * determines if a time is set and whether that time is in the future, |
||
137 | * making the record invisible on the website. |
||
138 | * |
||
139 | * @param string $table The table name. |
||
140 | * @param array $record An array with record fields that may affect visibility. |
||
141 | * @return bool True if the record's start time is in the future, FALSE otherwise. |
||
142 | */ |
||
143 | 2 | public function isStartTimeInFuture($table, $record) |
|
154 | |||
155 | |||
156 | /** |
||
157 | * Checks whether a hidden field exists for the current table and if so |
||
158 | * determines whether it is set on the current record. |
||
159 | * |
||
160 | * @param string $table The table name. |
||
161 | * @param array $record An array with record fields that may affect visibility. |
||
162 | * @return bool True if the record is hidden, FALSE otherwise. |
||
163 | */ |
||
164 | 4 | public function isHidden($table, $record) |
|
175 | |||
176 | /** |
||
177 | * Makes sure that "empty" frontend group fields are always the same value. |
||
178 | * |
||
179 | * @param string $table The record's table name. |
||
180 | * @param array $record the record array. |
||
181 | * @return array The cleaned record |
||
182 | */ |
||
183 | 3 | public function normalizeFrontendGroupField($table, $record) |
|
195 | |||
196 | /** |
||
197 | * Compiles a list of visibility affecting fields of a table so that it can |
||
198 | * be used in SQL queries. |
||
199 | * |
||
200 | * @param string $table Table name to retrieve visibility affecting fields for |
||
201 | * @return string Comma separated list of field names that affect the visibility of a record on the website |
||
202 | */ |
||
203 | 6 | public function getVisibilityAffectingFieldsByTable($table) |
|
228 | } |
||
229 |