|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2010-2011 Xavier Perseguers <typo3@perseguers.ch> 00006 * (c) 2010-2011 Steffen Kamper <steffen@typo3.org> 00007 * All rights reserved 00008 * 00009 * This script is part of the TYPO3 project. The TYPO3 project is 00010 * free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * The GNU General Public License can be found at 00016 * http://www.gnu.org/copyleft/gpl.html. 00017 * A copy is found in the textfile GPL.txt and important notices to the license 00018 * from the author is found in LICENSE.txt distributed with these scripts. 00019 * 00020 * 00021 * This script is distributed in the hope that it will be useful, 00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00024 * GNU General Public License for more details. 00025 * 00026 * This copyright notice MUST APPEAR in all copies of the script! 00027 ***************************************************************/ 00028 00029 /** 00030 * Contains CONTENT class object. 00031 * 00032 * $Id: class.tslib_content.php 7905 2010-06-13 14:42:33Z ohader $ 00033 * @author Xavier Perseguers <typo3@perseguers.ch> 00034 * @author Steffen Kamper <steffen@typo3.org> 00035 */ 00036 class tslib_content_Content extends tslib_content_Abstract { 00037 00038 /** 00039 * Rendering the cObject, CONTENT 00040 * 00041 * @param array Array of TypoScript properties 00042 * @return string Output 00043 */ 00044 public function render($conf = array()) { 00045 $theValue = ''; 00046 00047 $originalRec = $GLOBALS['TSFE']->currentRecord; 00048 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!! 00049 $GLOBALS['TSFE']->recordRegister[$originalRec]++; 00050 } 00051 00052 $conf['table'] = isset($conf['table.']) 00053 ? trim($this->cObj->stdWrap($conf['table'], $conf['table.'])) 00054 : trim($conf['table']); 00055 $tablePrefix = t3lib_div::trimExplode('_', $conf['table'], TRUE); 00056 if (t3lib_div::inList('pages,tt,fe,tx,ttx,user,static', $tablePrefix[0])) { 00057 00058 $renderObjName = $conf['renderObj'] 00059 ? $conf['renderObj'] 00060 : '<' . $conf['table']; 00061 $renderObjKey = $conf['renderObj'] 00062 ? 'renderObj' 00063 : ''; 00064 $renderObjConf = $conf['renderObj.']; 00065 00066 $slide = isset($conf['slide.']) 00067 ? intval($this->cObj->stdWrap($conf['slide'], $conf['slide.'])) 00068 : intval($conf['slide']); 00069 if (!$slide) { 00070 $slide = 0; 00071 } 00072 00073 $slideCollect = isset($conf['slide.']['collect.']) 00074 ? intval($this->cObj->stdWrap($conf['slide.']['collect'], $conf['slide.']['collect.'])) 00075 : intval($conf['slide.']['collect']); 00076 if (!$slideCollect) { 00077 $slideCollect = 0; 00078 } 00079 00080 $slideCollectReverse = isset($conf['slide.']['collectReverse.']) 00081 ? intval($this->cObj->stdWrap($conf['slide.']['collectReverse'], $conf['slide.']['collectReverse.'])) 00082 : intval($conf['slide.']['collectReverse']); 00083 $slideCollectReverse = $slideCollectReverse ? TRUE : FALSE; 00084 00085 $slideCollectFuzzy = isset($conf['slide.']['collectFuzzy.']) 00086 ? intval($this->cObj->stdWrap($conf['slide.']['collectFuzzy'], $conf['slide.']['collectFuzzy.'])) 00087 : intval($conf['slide.']['collectFuzzy']); 00088 00089 if ($slideCollectFuzzy) { 00090 $slideCollectFuzzy = TRUE; 00091 } else { 00092 $slideCollectFuzzy = FALSE; 00093 } 00094 00095 if (!$slideCollect) { 00096 $slideCollectFuzzy = TRUE; 00097 }; 00098 00099 $again = FALSE; 00100 00101 do { 00102 $res = $this->cObj->exec_getQuery($conf['table'], $conf['select.']); 00103 if ($error = $GLOBALS['TYPO3_DB']->sql_error()) { 00104 $GLOBALS['TT']->setTSlogMessage($error, 3); 00105 } else { 00106 $this->cObj->currentRecordTotal = $GLOBALS['TYPO3_DB']->sql_num_rows($res); 00107 $GLOBALS['TT']->setTSlogMessage('NUMROWS: ' . $GLOBALS['TYPO3_DB']->sql_num_rows($res)); 00108 $cObj = t3lib_div::makeInstance('tslib_cObj'); 00109 $cObj->setParent($this->cObj->data, $this->cObj->currentRecord); 00110 $this->cObj->currentRecordNumber = 0; 00111 $cobjValue = ''; 00112 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00113 00114 // Versioning preview: 00115 $GLOBALS['TSFE']->sys_page->versionOL($conf['table'], $row, TRUE); 00116 00117 // Language overlay: 00118 if (is_array($row) && $GLOBALS['TSFE']->sys_language_contentOL) { 00119 if ($conf['table'] == 'pages') { 00120 $row = $GLOBALS['TSFE']->sys_page->getPageOverlay($row); 00121 } else { 00122 $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay($conf['table'], $row, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL); 00123 } 00124 } 00125 00126 if (is_array($row)) { // Might be unset in the sys_language_contentOL 00127 // Call hook for possible manipulation of database row for cObj->data 00128 if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content_content.php']['modifyDBRow'])) { 00129 foreach($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content_content.php']['modifyDBRow'] as $_classRef) { 00130 $_procObj = t3lib_div::getUserObj($_classRef); 00131 $_procObj->modifyDBRow($row, $conf['table']); 00132 } 00133 } 00134 00135 if (!$GLOBALS['TSFE']->recordRegister[$conf['table'] . ':' . $row['uid']]) { 00136 $this->cObj->currentRecordNumber++; 00137 $cObj->parentRecordNumber = $this->cObj->currentRecordNumber; 00138 $GLOBALS['TSFE']->currentRecord = $conf['table'] . ':' . $row['uid']; 00139 $this->cObj->lastChanged($row['tstamp']); 00140 $cObj->start($row, $conf['table']); 00141 $tmpValue = $cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey); 00142 $cobjValue .= $tmpValue; 00143 } 00144 } 00145 } 00146 $GLOBALS['TYPO3_DB']->sql_free_result($res); 00147 } 00148 00149 if ($slideCollectReverse) { 00150 $theValue = $cobjValue . $theValue; 00151 } else { 00152 $theValue .= $cobjValue; 00153 } 00154 if ($slideCollect > 0) { 00155 $slideCollect--; 00156 } 00157 if ($slide) { 00158 if ($slide > 0) { 00159 $slide--; 00160 } 00161 $conf['select.']['pidInList'] = $this->cObj->getSlidePids($conf['select.']['pidInList'], $conf['select.']['pidInList.']); 00162 $again = strlen($conf['select.']['pidInList']) ? TRUE : FALSE; 00163 } 00164 } while ($again && (($slide && !strlen($tmpValue) && $slideCollectFuzzy) || ($slide && $slideCollect))); 00165 00166 } 00167 00168 $wrap = isset($conf['wrap.']) 00169 ? $this->cObj->stdWrap($conf['wrap'],$conf['wrap.']) 00170 : $conf['wrap']; 00171 if ($wrap) { 00172 $theValue = $this->cObj->wrap($theValue, $wrap); 00173 } 00174 00175 if (isset($conf['stdWrap.'])) { 00176 $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']); 00177 } 00178 00179 $GLOBALS['TSFE']->currentRecord = $originalRec; // Restore 00180 00181 return $theValue; 00182 00183 } 00184 00185 } 00186 00187 00188 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/content/class.tslib_content_content.php'])) { 00189 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/content/class.tslib_content_content.php']); 00190 } 00191 00192 ?>
1.8.0