2 /***************************************************************
5 * (c) 2010 Xavier Perseguers <typo3@perseguers.ch>
6 * (c) 2010 Steffen Kamper <steffen@typo3.org>
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.
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.
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.
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
30 * Contains CONTENT class object.
32 * $Id: class.tslib_content.php 7905 2010-06-13 14:42:33Z ohader $
33 * @author Xavier Perseguers <typo3@perseguers.ch>
34 * @author Steffen Kamper <steffen@typo3.org>
36 class tslib_content_Content
extends tslib_content_Abstract
{
39 * Rendering the cObject, CONTENT
41 * @param array Array of TypoScript properties
42 * @return string Output
44 public function render($conf = array()) {
47 $originalRec = $GLOBALS['TSFE']->currentRecord
;
48 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!!
49 $GLOBALS['TSFE']->recordRegister
[$originalRec]++
;
52 $conf['table'] = isset($conf['table.'])
53 ?
trim($this->cObj
->stdWrap($conf['table'], $conf['table.']))
54 : trim($conf['table']);
55 $tablePrefix = t3lib_div
::trimExplode('_', $conf['table'], TRUE);
56 if (t3lib_div
::inList('pages,tt,fe,tx,ttx,user,static', $tablePrefix[0])) {
58 $renderObjName = $conf['renderObj']
60 : '<' . $conf['table'];
61 $renderObjKey = $conf['renderObj']
64 $renderObjConf = $conf['renderObj.'];
66 $slide = isset($conf['slide.'])
67 ?
intval($this->cObj
->stdWrap($conf['slide'], $conf['slide.']))
68 : intval($conf['slide']);
73 if(isset($conf['slide.'])) {
74 $slideCollect = isset($conf['slide.']['collect.'])
75 ?
intval($this->cObj
->stdWrap($conf['slide.']['collect'], $conf['slide.']['collect.']))
76 : intval($conf['slide.']['collect']);
81 $slideCollectReverse = isset($conf['slide.']['collectReverse.'])
82 ?
intval($this->cObj
->stdWrap($conf['slide.']['collectReverse'], $conf['slide.']['collectReverse.']))
83 : intval($conf['slide.']['collectReverse']);
84 $slideCollectReverse = $slideCollectReverse ?
TRUE : FALSE;
86 $slideCollectFuzzy = isset($conf['slide.']['collectFuzzy.'])
87 ?
intval($this->cObj
->stdWrap($conf['slide.']['collectFuzzy'], $conf['slide.']['collectFuzzy.']))
88 : intval($conf['slide.']['collectFuzzy']);
90 if(!$slideCollectFuzzy) {
91 $slideCollectFuzzy = FALSE;
92 } else if ($slideCollect) {
93 $slideCollectFuzzy = TRUE;
100 $res = $this->cObj
->exec_getQuery($conf['table'], $conf['select.']);
101 if ($error = $GLOBALS['TYPO3_DB']->sql_error()) {
102 $GLOBALS['TT']->setTSlogMessage($error, 3);
104 $this->cObj
->currentRecordTotal
= $GLOBALS['TYPO3_DB']->sql_num_rows($res);
105 $GLOBALS['TT']->setTSlogMessage('NUMROWS: ' . $GLOBALS['TYPO3_DB']->sql_num_rows($res));
106 $cObj = t3lib_div
::makeInstance('tslib_cObj');
107 $cObj->setParent($this->cObj
->data
, $this->cObj
->currentRecord
);
108 $this->cObj
->currentRecordNumber
= 0;
110 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
112 // Versioning preview:
113 $GLOBALS['TSFE']->sys_page
->versionOL($conf['table'], $row, TRUE);
116 if (is_array($row) && $GLOBALS['TSFE']->sys_language_contentOL
) {
117 $row = $GLOBALS['TSFE']->sys_page
->getRecordOverlay($conf['table'], $row, $GLOBALS['TSFE']->sys_language_content
, $GLOBALS['TSFE']->sys_language_contentOL
);
120 if (is_array($row)) { // Might be unset in the sys_language_contentOL
121 // Call hook for possible manipulation of database row for cObj->data
122 if (is_array($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_content_content.php']['modifyDBRow'])) {
123 foreach($this->TYPO3_CONF_VARS
['SC_OPTIONS']['tslib/class.tslib_content_content.php']['modifyDBRow'] as $_classRef) {
124 $_procObj = t3lib_div
::getUserObj($_classRef);
125 $_procObj->modifyDBRow($row, $conf['table']);
129 if (!$GLOBALS['TSFE']->recordRegister
[$conf['table'] . ':' . $row['uid']]) {
130 $this->cObj
->currentRecordNumber++
;
131 $cObj->parentRecordNumber
= $this->cObj
->currentRecordNumber
;
132 $GLOBALS['TSFE']->currentRecord
= $conf['table'] . ':' . $row['uid'];
133 $this->cObj
->lastChanged($row['tstamp']);
134 $cObj->start($row, $conf['table']);
135 $tmpValue = $cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
136 $cobjValue .= $tmpValue;
140 $GLOBALS['TYPO3_DB']->sql_free_result($res);
143 if ($slideCollectReverse) {
144 $theValue = $cobjValue . $theValue;
146 $theValue .= $cobjValue;
148 if ($slideCollect > 0) {
155 $conf['select.']['pidInList'] = $this->cObj
->getSlidePids($conf['select.']['pidInList'], $conf['select.']['pidInList.']);
156 $again = strlen($conf['select.']['pidInList']) ?
TRUE : FALSE;
158 } while ($again && (($slide && !strlen($tmpValue) && $slideCollectFuzzy) ||
($slide && $slideCollect)));
162 $wrap = isset($conf['wrap.'])
163 ?
$this->cObj
->stdWrap($conf['wrap'],$conf['wrap.'])
166 $theValue = $this->cObj
->wrap($theValue, $wrap);
169 if (isset($conf['stdWrap.'])) {
170 $theValue = $this->cObj
->stdWrap($theValue, $conf['stdWrap.']);
173 $GLOBALS['TSFE']->currentRecord
= $originalRec; // Restore
182 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['tslib/content/class.tslib_content_content.php']) {
183 include_once ($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['tslib/content/class.tslib_content_content.php']);