[BUGFIX] Unset stdWrap of select.pidInList
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / content / class.tslib_content_content.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010-2011 Xavier Perseguers <typo3@perseguers.ch>
6 * (c) 2010-2011 Steffen Kamper <steffen@typo3.org>
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 * A copy is found in the textfile GPL.txt and important notices to the license
18 * from the author is found in LICENSE.txt distributed with these scripts.
19 *
20 *
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
28
29 /**
30 * Contains CONTENT class object.
31 *
32 * @author Xavier Perseguers <typo3@perseguers.ch>
33 * @author Steffen Kamper <steffen@typo3.org>
34 */
35 class tslib_content_Content extends tslib_content_Abstract {
36
37 /**
38 * Rendering the cObject, CONTENT
39 *
40 * @param array Array of TypoScript properties
41 * @return string Output
42 */
43 public function render($conf = array()) {
44 $theValue = '';
45
46 $originalRec = $GLOBALS['TSFE']->currentRecord;
47 if ($originalRec) { // If the currentRecord is set, we register, that this record has invoked this function. It's should not be allowed to do this again then!!
48 $GLOBALS['TSFE']->recordRegister[$originalRec]++;
49 }
50
51 $conf['table'] = isset($conf['table.'])
52 ? trim($this->cObj->stdWrap($conf['table'], $conf['table.']))
53 : trim($conf['table']);
54 $tablePrefix = t3lib_div::trimExplode('_', $conf['table'], TRUE);
55 if (t3lib_div::inList('pages,tt,fe,tx,ttx,user,static', $tablePrefix[0])) {
56
57 $renderObjName = $conf['renderObj']
58 ? $conf['renderObj']
59 : '<' . $conf['table'];
60 $renderObjKey = $conf['renderObj']
61 ? 'renderObj'
62 : '';
63 $renderObjConf = $conf['renderObj.'];
64
65 $slide = isset($conf['slide.'])
66 ? intval($this->cObj->stdWrap($conf['slide'], $conf['slide.']))
67 : intval($conf['slide']);
68 if (!$slide) {
69 $slide = 0;
70 }
71
72 $slideCollect = isset($conf['slide.']['collect.'])
73 ? intval($this->cObj->stdWrap($conf['slide.']['collect'], $conf['slide.']['collect.']))
74 : intval($conf['slide.']['collect']);
75 if (!$slideCollect) {
76 $slideCollect = 0;
77 }
78
79 $slideCollectReverse = isset($conf['slide.']['collectReverse.'])
80 ? intval($this->cObj->stdWrap($conf['slide.']['collectReverse'], $conf['slide.']['collectReverse.']))
81 : intval($conf['slide.']['collectReverse']);
82 $slideCollectReverse = $slideCollectReverse ? TRUE : FALSE;
83
84 $slideCollectFuzzy = isset($conf['slide.']['collectFuzzy.'])
85 ? intval($this->cObj->stdWrap($conf['slide.']['collectFuzzy'], $conf['slide.']['collectFuzzy.']))
86 : intval($conf['slide.']['collectFuzzy']);
87
88 if ($slideCollectFuzzy) {
89 $slideCollectFuzzy = TRUE;
90 } else {
91 $slideCollectFuzzy = FALSE;
92 }
93
94 if (!$slideCollect) {
95 $slideCollectFuzzy = TRUE;
96 };
97
98 $again = FALSE;
99
100 do {
101 $res = $this->cObj->exec_getQuery($conf['table'], $conf['select.']);
102 if ($error = $GLOBALS['TYPO3_DB']->sql_error()) {
103 $GLOBALS['TT']->setTSlogMessage($error, 3);
104 } else {
105 $this->cObj->currentRecordTotal = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
106 $GLOBALS['TT']->setTSlogMessage('NUMROWS: ' . $GLOBALS['TYPO3_DB']->sql_num_rows($res));
107 $cObj = t3lib_div::makeInstance('tslib_cObj');
108 $cObj->setParent($this->cObj->data, $this->cObj->currentRecord);
109 $this->cObj->currentRecordNumber = 0;
110 $cobjValue = '';
111 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
112
113 // Versioning preview:
114 $GLOBALS['TSFE']->sys_page->versionOL($conf['table'], $row, TRUE);
115
116 // Language overlay:
117 if (is_array($row) && $GLOBALS['TSFE']->sys_language_contentOL) {
118 if ($conf['table'] == 'pages') {
119 $row = $GLOBALS['TSFE']->sys_page->getPageOverlay($row);
120 } else {
121 $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay($conf['table'], $row, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL);
122 }
123 }
124
125 if (is_array($row)) { // Might be unset in the sys_language_contentOL
126 // Call hook for possible manipulation of database row for cObj->data
127 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content_content.php']['modifyDBRow'])) {
128 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content_content.php']['modifyDBRow'] as $_classRef) {
129 $_procObj = t3lib_div::getUserObj($_classRef);
130 $_procObj->modifyDBRow($row, $conf['table']);
131 }
132 }
133
134 if (!$GLOBALS['TSFE']->recordRegister[$conf['table'] . ':' . $row['uid']]) {
135 $this->cObj->currentRecordNumber++;
136 $cObj->parentRecordNumber = $this->cObj->currentRecordNumber;
137 $GLOBALS['TSFE']->currentRecord = $conf['table'] . ':' . $row['uid'];
138 $this->cObj->lastChanged($row['tstamp']);
139 $cObj->start($row, $conf['table']);
140 $tmpValue = $cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
141 $cobjValue .= $tmpValue;
142 }
143 }
144 }
145 $GLOBALS['TYPO3_DB']->sql_free_result($res);
146 }
147
148 if ($slideCollectReverse) {
149 $theValue = $cobjValue . $theValue;
150 } else {
151 $theValue .= $cobjValue;
152 }
153 if ($slideCollect > 0) {
154 $slideCollect--;
155 }
156 if ($slide) {
157 if ($slide > 0) {
158 $slide--;
159 }
160 $conf['select.']['pidInList'] = $this->cObj->getSlidePids($conf['select.']['pidInList'], $conf['select.']['pidInList.']);
161 if (isset($conf['select.']['pidInList.'])) {
162 unset($conf['select.']['pidInList.']);
163 }
164 $again = strlen($conf['select.']['pidInList']) ? TRUE : FALSE;
165 }
166 } while ($again && (($slide && !strlen($tmpValue) && $slideCollectFuzzy) || ($slide && $slideCollect)));
167
168 }
169
170 $wrap = isset($conf['wrap.'])
171 ? $this->cObj->stdWrap($conf['wrap'],$conf['wrap.'])
172 : $conf['wrap'];
173 if ($wrap) {
174 $theValue = $this->cObj->wrap($theValue, $wrap);
175 }
176
177 if (isset($conf['stdWrap.'])) {
178 $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
179 }
180
181 $GLOBALS['TSFE']->currentRecord = $originalRec; // Restore
182
183 return $theValue;
184
185 }
186
187 }
188
189
190 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/content/class.tslib_content_content.php'])) {
191 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/content/class.tslib_content_content.php']);
192 }
193
194 ?>