[TASK] Merge submodule workspaces into core
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Generic / Typo3QuerySettings.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Persistence\Generic;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2010-2013 Extbase Team (http://forge.typo3.org/projects/typo3v4-mvc)
8 * Extbase is a backport of TYPO3 Flow. All credits go to the TYPO3 Flow team.
9 * All rights reserved
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 * A copy is found in the textfile GPL.txt and important notices to the license
20 * from the author is found in LICENSE.txt distributed with these scripts.
21 *
22 *
23 * This script is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * This copyright notice MUST APPEAR in all copies of the script!
29 ***************************************************************/
30 /**
31 * Query settings. This class is NOT part of the FLOW3 API.
32 * It reflects the settings unique to TYPO3 4.x.
33 *
34 * @api
35 */
36 class Typo3QuerySettings implements \TYPO3\CMS\Extbase\Persistence\Generic\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 * The language uid for the language overlay.
85 *
86 * @var integer
87 */
88 protected $sysLanguageUid = 0;
89
90 /**
91 * Flag if the the query result should be returned as raw QueryResult.
92 *
93 * @var boolean
94 */
95 protected $returnRawQueryResult = FALSE;
96
97 /**
98 * As long as we use a feature flag ignoreAllEnableFieldsInBe to determine the default behavior, the
99 * initializeObject is responsible for handling that.
100 */
101 public function initializeObject() {
102 /** @var $objectManager \TYPO3\CMS\Extbase\Object\ObjectManager */
103 $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
104 /** @var $configurationManager \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface */
105 $configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
106 if (TYPO3_MODE === 'BE' && $configurationManager->isFeatureEnabled('ignoreAllEnableFieldsInBe')) {
107 $this->setIgnoreEnableFields(TRUE);
108 }
109
110 // Set correct language uid for frontend handling
111 if (isset($GLOBALS['TSFE']) && is_object($GLOBALS['TSFE'])) {
112 $this->setSysLanguageUid($GLOBALS['TSFE']->sys_language_content);
113 } elseif (intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('L'))) {
114 // Set language from 'L' parameter
115 $this->setSysLanguageUid(intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('L')));
116 }
117 }
118
119 /**
120 * Sets the flag if the storage page should be respected for the query.
121 *
122 * @param boolean $respectStoragePage If TRUE the storage page ID will be determined and the statement will be extended accordingly.
123 * @return \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface (fluent interface)
124 * @api
125 */
126 public function setRespectStoragePage($respectStoragePage) {
127 $this->respectStoragePage = $respectStoragePage;
128 return $this;
129 }
130
131 /**
132 * Returns the state, if the storage page should be respected for the query.
133 *
134 * @return boolean TRUE, if the storage page should be respected; otherwise FALSE.
135 */
136 public function getRespectStoragePage() {
137 return $this->respectStoragePage;
138 }
139
140 /**
141 * Sets the pid(s) of the storage page(s) that should be respected for the query.
142 *
143 * @param array $storagePageIds If TRUE the storage page ID will be determined and the statement will be extended accordingly.
144 * @return void
145 * @api
146 */
147 public function setStoragePageIds(array $storagePageIds) {
148 $this->storagePageIds = $storagePageIds;
149 }
150
151 /**
152 * Returns the pid(s) of the storage page(s) that should be respected for the query.
153 *
154 * @return array list of integers that each represent a storage page id
155 */
156 public function getStoragePageIds() {
157 return $this->storagePageIds;
158 }
159
160 /**
161 * Sets the flag if a and language overlay should be performed.
162 *
163 * @param boolean $respectSysLanguage TRUE if a and language overlay should be performed.
164 * @return \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface (fluent interface)
165 * @api
166 */
167 public function setRespectSysLanguage($respectSysLanguage) {
168 $this->respectSysLanguage = $respectSysLanguage;
169 return $this;
170 }
171
172 /**
173 * Returns the state, if a and language overlay should be performed.
174 *
175 * @return boolean TRUE, if a and language overlay should be performed; otherwise FALSE.
176 */
177 public function getRespectSysLanguage() {
178 return $this->respectSysLanguage;
179 }
180
181 /**
182 * Sets the language uid for the language overlay.
183 *
184 * @param integer $sysLanguageUid language uid for the language overlay
185 * @return void
186 * @api
187 */
188 public function setSysLanguageUid($sysLanguageUid) {
189 $this->sysLanguageUid = $sysLanguageUid;
190 }
191
192 /**
193 * Returns the language uid for the language overlay
194 *
195 * @return integer language uid for the language overlay
196 */
197 public function getSysLanguageUid() {
198 return $this->sysLanguageUid;
199 }
200
201 /**
202 * Sets the flag if the visibility in the frontend should be respected.
203 *
204 * @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.
205 * @return \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface (fluent interface)
206 * @deprecated since Extbase 6.0, will be removed in Extbase 6.2. Use setIgnoreEnableFields() and setEnableFieldsToBeIgnored() instead.
207 * @see setIgnoreEnableFields()
208 * @see setEnableFieldsToBeIgnored()
209 * @api
210 */
211 public function setRespectEnableFields($respectEnableFields) {
212 \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
213 $this->setIgnoreEnableFields(!$respectEnableFields);
214 $this->setIncludeDeleted(!$respectEnableFields);
215 return $this;
216 }
217
218 /**
219 * Returns the state, if the visibility settings for the frontend should be respected for the query.
220 *
221 * @return boolean TRUE, if the visibility settings for the frontend should should be respected; otherwise FALSE.
222 * @deprecated since Extbase 6.0, will be removed in Extbase 6.2. Use getIgnoreEnableFields() and getEnableFieldsToBeIgnored() instead.
223 * @see getIgnoreEnableFields()
224 * @see getEnableFieldsToBeIgnored()
225 */
226 public function getRespectEnableFields() {
227 \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
228 return !($this->getIgnoreEnableFields() && $this->getIncludeDeleted());
229 }
230
231 /**
232 * Sets a flag indicating whether all or some enable fields should be ignored. If TRUE, all enable fields are ignored.
233 * If--in addition to this--enableFieldsToBeIgnored is set, only fields specified there are ignored. If FALSE, all
234 * enable fields are taken into account, regardless of the enableFieldsToBeIgnored setting.
235 *
236 * @param boolean $ignoreEnableFields
237 * @see setEnableFieldsToBeIgnored()
238 * @api
239 */
240 public function setIgnoreEnableFields($ignoreEnableFields) {
241 $this->ignoreEnableFields = $ignoreEnableFields;
242 }
243
244 /**
245 * The returned value indicates whether all or some enable fields should be ignored.
246 *
247 * If TRUE, all enable fields are ignored. If--in addition to this--enableFieldsToBeIgnored is set, only fields specified there are ignored.
248 * If FALSE, all enable fields are taken into account, regardless of the enableFieldsToBeIgnored setting.
249 *
250 * @return boolean
251 * @see getEnableFieldsToBeIgnored()
252 */
253 public function getIgnoreEnableFields() {
254 return $this->ignoreEnableFields;
255 }
256
257 /**
258 * An array of column names in the enable columns array (array keys in $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']),
259 * to be ignored while building the query statement. Adding a column name here effectively switches off filtering
260 * by this column. This setting is only taken into account if $this->ignoreEnableFields = TRUE.
261 *
262 * @param array $enableFieldsToBeIgnored
263 * @return void
264 * @see setIgnoreEnableFields()
265 * @api
266 */
267 public function setEnableFieldsToBeIgnored($enableFieldsToBeIgnored) {
268 $this->enableFieldsToBeIgnored = $enableFieldsToBeIgnored;
269 }
270
271 /**
272 * An array of column names in the enable columns array (array keys in $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']),
273 * to be ignored while building the query statement.
274 *
275 * @return array
276 * @see getIgnoreEnableFields()
277 */
278 public function getEnableFieldsToBeIgnored() {
279 return $this->enableFieldsToBeIgnored;
280 }
281
282 /**
283 * Sets the flag if the query should return objects that are deleted.
284 *
285 * @param boolean $includeDeleted
286 * @return void
287 * @api
288 */
289 public function setIncludeDeleted($includeDeleted) {
290 $this->includeDeleted = $includeDeleted;
291 }
292
293 /**
294 * Returns if the query should return objects that are deleted.
295 *
296 * @return boolean
297 */
298 public function getIncludeDeleted() {
299 return $this->includeDeleted;
300 }
301
302 /**
303 * Sets the state, if the QueryResult should be returned unmapped.
304 *
305 * @param boolean $returnRawQueryResult TRUE, if the QueryResult should be returned unmapped; otherwise FALSE.
306 * @return void
307 */
308 public function setReturnRawQueryResult($returnRawQueryResult) {
309 $this->returnRawQueryResult = $returnRawQueryResult;
310 }
311
312 /**
313 * Returns the state, if the QueryResult should be returned unmapped.
314 *
315 * @return boolean TRUE, if the QueryResult should be returned unmapped; otherwise FALSE.
316 */
317 public function getReturnRawQueryResult() {
318 return $this->returnRawQueryResult;
319 }
320 }
321
322 ?>