[TASK][WIP] Move non class code back to source files
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Generic / Typo3QuerySettings.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
6 * All rights reserved
7 *
8 * This class is a backport of the corresponding class of FLOW3.
9 * All credits go to the v5 team.
10 *
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Query settings. This class is NOT part of the FLOW3 API.
29 * It reflects the settings unique to TYPO3 4.x.
30 *
31 * @package Extbase
32 * @subpackage Persistence
33 * @version $Id$
34 * @api
35 */
36 class Tx_Extbase_Persistence_Typo3QuerySettings implements Tx_Extbase_Persistence_QuerySettingsInterface {
37
38 /**
39 * Flag if the storage page should be respected for the query.
40 *
41 * @var boolean
42 */
43 protected $respectStoragePage = TRUE;
44
45 /**
46 * the pid(s) of the storage page(s) that should be respected for the query.
47 *
48 * @var array
49 */
50 protected $storagePageIds = array();
51
52 /**
53 * A flag indicating whether all or some enable fields should be ignored. If TRUE, all enable fields are ignored.
54 * If--in addition to this--enableFieldsToBeIgnored is set, only fields specified there are ignored. If FALSE, all
55 * enable fields are taken into account, regardless of the enableFieldsToBeIgnored setting.
56 *
57 * @var boolean
58 */
59 protected $ignoreEnableFields = FALSE;
60
61 /**
62 * An array of column names in the enable columns array (array keys in $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']),
63 * to be ignored while building the query statement
64 *
65 * @var array
66 */
67 protected $enableFieldsToBeIgnored = array();
68
69 /**
70 * Flag whether deleted records should be included in the result set.
71 *
72 * @var boolean
73 */
74 protected $includeDeleted = FALSE;
75
76 /**
77 * Flag if the sys_language_uid should be respected (default is TRUE).
78 *
79 * @var boolean
80 */
81 protected $respectSysLanguage = TRUE;
82
83 /**
84 * Flag if the the query result should be returned as raw QueryResult.
85 *
86 * @var boolean
87 */
88 protected $returnRawQueryResult = FALSE;
89
90 /**
91 * As long as we use a feature flag ignoreAllEnableFieldsInBe to determine the default behavior, the
92 * initializeObject is responsible for handling that.
93 */
94 public function initializeObject() {
95 /** @var $objectManager Tx_Extbase_Object_ObjectManager */
96 $objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
97 /** @var $configurationManager Tx_Extbase_Configuration_ConfigurationManagerInterface */
98 $configurationManager = $objectManager->get('Tx_Extbase_Configuration_ConfigurationManagerInterface');
99 if (TYPO3_MODE === 'BE' && $configurationManager->isFeatureEnabled('ignoreAllEnableFieldsInBe')) {
100 $this->setIgnoreEnableFields(TRUE);
101 }
102 }
103
104 /**
105 * Sets the flag if the storage page should be respected for the query.
106 *
107 * @param boolean $respectStoragePage If TRUE the storage page ID will be determined and the statement will be extended accordingly.
108 * @return Tx_Extbase_Persistence_QuerySettingsInterface (fluent interface)
109 * @api
110 */
111 public function setRespectStoragePage($respectStoragePage) {
112 $this->respectStoragePage = $respectStoragePage;
113 return $this;
114 }
115
116 /**
117 * Returns the state, if the storage page should be respected for the query.
118 *
119 * @return boolean TRUE, if the storage page should be respected; otherwise FALSE.
120 */
121 public function getRespectStoragePage() {
122 return $this->respectStoragePage;
123 }
124
125 /**
126 * Sets the pid(s) of the storage page(s) that should be respected for the query.
127 *
128 * @param array $respectStoragePage If TRUE the storage page ID will be determined and the statement will be extended accordingly.
129 * @return Tx_Extbase_Persistence_QuerySettingsInterface instance of $this to allow method chaining
130 * @api
131 */
132 public function setStoragePageIds(array $storagePageIds) {
133 $this->storagePageIds = $storagePageIds;
134 }
135
136 /**
137 * Returns the pid(s) of the storage page(s) that should be respected for the query.
138 *
139 * @return array list of integers that each represent a storage page id
140 */
141 public function getStoragePageIds() {
142 return $this->storagePageIds;
143 }
144
145 /**
146 * Sets the flag if a and language overlay should be performed.
147 *
148 * @param boolean $respectEnableFields TRUE if a and language overlay should be performed.
149 * @return Tx_Extbase_Persistence_QuerySettingsInterface (fluent interface)
150 * @api
151 */
152 public function setRespectSysLanguage($respectSysLanguage) {
153 $this->respectSysLanguage = $respectSysLanguage;
154 return $this;
155 }
156
157 /**
158 * Returns the state, if a and language overlay should be performed.
159 *
160 * @return boolean TRUE, if a and language overlay should be performed; otherwise FALSE.
161 */
162 public function getRespectSysLanguage() {
163 return $this->respectSysLanguage;
164 }
165
166 /**
167 * Sets the flag if the visibility in the frontend should be respected.
168 *
169 * @param boolean $respectEnableFields TRUE if the visibility in the frontend should be respected. If TRUE, the "enable fields" of TYPO3 will be added to the query statement.
170 * @return Tx_Extbase_Persistence_QuerySettingsInterface (fluent interface)
171 * @deprecated since Extbase 6.0, will be removed in Extbase 6.2. Use setIgnoreEnableFields() and setEnableFieldsToBeIgnored() instead.
172 * @see setIgnoreEnableFields()
173 * @see setEnableFieldsToBeIgnored()
174 * @api
175 */
176 public function setRespectEnableFields($respectEnableFields) {
177 t3lib_div::logDeprecatedFunction();
178 $this->setIgnoreEnableFields(!$respectEnableFields);
179 $this->setIncludeDeleted(!$respectEnableFields);
180 return $this;
181 }
182
183 /**
184 * Returns the state, if the visibility settings for the frontend should be respected for the query.
185 *
186 * @return boolean TRUE, if the visibility settings for the frontend should should be respected; otherwise FALSE.
187 * @deprecated since Extbase 6.0, will be removed in Extbase 6.2. Use getIgnoreEnableFields() and getEnableFieldsToBeIgnored() instead.
188 * @see getIgnoreEnableFields()
189 * @see getEnableFieldsToBeIgnored()
190 */
191 public function getRespectEnableFields() {
192 t3lib_div::logDeprecatedFunction();
193 return !($this->getIgnoreEnableFields() && $this->getIncludeDeleted());
194 }
195
196 /**
197 * Sets a flag indicating whether all or some enable fields should be ignored. If TRUE, all enable fields are ignored.
198 * If--in addition to this--enableFieldsToBeIgnored is set, only fields specified there are ignored. If FALSE, all
199 * enable fields are taken into account, regardless of the enableFieldsToBeIgnored setting.
200 *
201 * @param boolean $ignoreEnableFields
202 * @see setEnableFieldsToBeIgnored()
203 * @api
204 */
205 public function setIgnoreEnableFields($ignoreEnableFields) {
206 $this->ignoreEnableFields = $ignoreEnableFields;
207 }
208
209 /**
210 * The returned value indicates whether all or some enable fields should be ignored.
211 *
212 * If TRUE, all enable fields are ignored. If--in addition to this--enableFieldsToBeIgnored is set, only fields specified there are ignored.
213 * If FALSE, all enable fields are taken into account, regardless of the enableFieldsToBeIgnored setting.
214 *
215 * @return boolean
216 * @see getEnableFieldsToBeIgnored()
217 */
218 public function getIgnoreEnableFields() {
219 return $this->ignoreEnableFields;
220 }
221
222 /**
223 * An array of column names in the enable columns array (array keys in $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']),
224 * to be ignored while building the query statement. Adding a column name here effectively switches off filtering
225 * by this column. This setting is only taken into account if $this->ignoreEnableFields = TRUE.
226 *
227 * @param array $enableFieldsToBeIgnored
228 * @return void
229 * @see setIgnoreEnableFields()
230 * @api
231 */
232 public function setEnableFieldsToBeIgnored($enableFieldsToBeIgnored) {
233 $this->enableFieldsToBeIgnored = $enableFieldsToBeIgnored;
234 }
235
236 /**
237 * An array of column names in the enable columns array (array keys in $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']),
238 * to be ignored while building the query statement.
239 *
240 * @return array
241 * @see getIgnoreEnableFields()
242 */
243 public function getEnableFieldsToBeIgnored() {
244 return $this->enableFieldsToBeIgnored;
245 }
246
247 /**
248 * Sets the flag if the query should return objects that are deleted.
249 *
250 * @param boolean $includeDeleted
251 * @return void
252 * @api
253 */
254 public function setIncludeDeleted($includeDeleted) {
255 $this->includeDeleted = $includeDeleted;
256 }
257
258 /**
259 * Returns if the query should return objects that are deleted.
260 *
261 * @return boolean
262 */
263 public function getIncludeDeleted() {
264 return $this->includeDeleted;
265 }
266
267 /**
268 * Sets the state, if the QueryResult should be returned unmapped.
269 *
270 * @var boolean $returnRawQueryResult TRUE, if the QueryResult should be returned unmapped; otherwise FALSE.
271 * @return void
272 */
273 public function setReturnRawQueryResult($returnRawQueryResult) {
274 $this->returnRawQueryResult = $returnRawQueryResult;
275 }
276
277 /**
278 * Returns the state, if the QueryResult should be returned unmapped.
279 *
280 * @return boolean TRUE, if the QueryResult should be returned unmapped; otherwise FALSE.
281 */
282 public function getReturnRawQueryResult() {
283 return $this->returnRawQueryResult;
284 }
285
286 }
287
288 ?>