Small things
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / class.tslib_content.php
index d2ed306..713ec7d 100755 (executable)
@@ -1136,39 +1136,65 @@ class tslib_cObj {
                        $renderObjKey = $conf['renderObj'] ? 'renderObj' : '';
                        $renderObjConf = $conf['renderObj.'];
 
-                       $res = $this->exec_getQuery($conf['table'],$conf['select.']);
-                       if ($error = $GLOBALS['TYPO3_DB']->sql_error()) {
-                               $GLOBALS['TT']->setTSlogMessage($error,3);
-                       } else {
-                               $this->currentRecordTotal = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
-                               $GLOBALS['TT']->setTSlogMessage('NUMROWS: '.$GLOBALS['TYPO3_DB']->sql_num_rows($res));
-                               $cObj =t3lib_div::makeInstance('tslib_cObj');
-                               $cObj->setParent($this->data,$this->currentRecord);
-                               $this->currentRecordNumber=0;
-                               while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
+                       $slide = intval($conf['slide'])?intval($conf['slide']):0;
+                       $slideCollect = intval($conf['slide.']['collect'])?intval($conf['slide.']['collect']):0;
+                       $slideCollectReverse = intval($conf['slide.']['collectReverse'])?true:false;
+                       $slideCollectFuzzy = $slideCollect?(intval($conf['slide.']['collectFuzzy'])?true:false):true;
+                       $again = false;
+
+                       do {
+                               $res = $this->exec_getQuery($conf['table'],$conf['select.']);
+                               if ($error = $GLOBALS['TYPO3_DB']->sql_error()) {
+                                       $GLOBALS['TT']->setTSlogMessage($error,3);
+                               } else {
+                                       $this->currentRecordTotal = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
+                                       $GLOBALS['TT']->setTSlogMessage('NUMROWS: '.$GLOBALS['TYPO3_DB']->sql_num_rows($res));
+                                       $cObj =t3lib_div::makeInstance('tslib_cObj');
+                                       $cObj->setParent($this->data,$this->currentRecord);
+                                       $this->currentRecordNumber=0;
+                                       $cobjValue = '';
+                                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
 
                                                // Versioning preview:
-                                       $GLOBALS['TSFE']->sys_page->versionOL($conf['table'],$row);
+                                               $GLOBALS['TSFE']->sys_page->versionOL($conf['table'],$row);
 
                                                // Language Overlay:
-                                       if ($GLOBALS['TSFE']->sys_language_contentOL)   {
+                                               if (is_array($row) && $GLOBALS['TSFE']->sys_language_contentOL) {
                                                $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay($conf['table'],$row,$GLOBALS['TSFE']->sys_language_content,$GLOBALS['TSFE']->sys_language_contentOL);
+                                               }
+
+                                               if (is_array($row)) { // Might be unset in the sys_language_contentOL
+                                                       if (!$GLOBALS['TSFE']->recordRegister[$conf['table'].':'.$row['uid']]) {
+                                                               $this->currentRecordNumber++;
+                                                               $cObj->parentRecordNumber = $this->currentRecordNumber;
+                                                               $GLOBALS['TSFE']->currentRecord = $conf['table'].':'.$row['uid'];
+                                                               $this->lastChanged($row['tstamp']);
+                                                               $cObj->start($row,$conf['table']);
+                                                               if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries']) { $cobjValue.='<!--DMAILER_SECTION_BOUNDARY_'.intval($row['module_sys_dmail_category']).'-->'; }
+                                                               $tmpValue = $cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
+                                                               $cobjValue .= $tmpValue;
+                                                       }# else debug($GLOBALS['TSFE']->recordRegister,'CONTENT');
+                                               }
                                        }
 
-                                       if (is_array($row))     {       // Might be unset in the sys_language_contentOL
-                                               if (!$GLOBALS['TSFE']->recordRegister[$conf['table'].':'.$row['uid']])  {
-                                                       $this->currentRecordNumber++;
-                                                       $cObj->parentRecordNumber = $this->currentRecordNumber;
-                                                       $GLOBALS['TSFE']->currentRecord = $conf['table'].':'.$row['uid'];
-                                                       $this->lastChanged($row['tstamp']);
-                                                       $cObj->start($row,$conf['table']);
-                                                       if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries'])      { $theValue.='<!--DMAILER_SECTION_BOUNDARY_'.intval($row['module_sys_dmail_category']).'-->'; }
-                                                       $theValue.= $cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
-                                               }# else debug($GLOBALS['TSFE']->recordRegister,'CONTENT');
+                                       if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries']) { $cobjValue.='<!--DMAILER_SECTION_BOUNDARY_END-->'; }
+                               }
+                               if ($slideCollectReverse) {
+                                       $theValue = $cobjValue.$theValue;
+                               } else {
+                                       $theValue .= $cobjValue;
+                               }
+                               if ($slideCollect>0) {
+                                       $slideCollect--;
+                               }
+                               if ($slide) {
+                                       if ($slide>0) {
+                                               $slide--;
                                        }
+                                       $conf['select.']['pidInList'] = $this->getSlidePids($conf['select.']['pidInList'], $conf['select.']['pidInList.']);
+                                       $again = strlen($conf['select.']['pidInList'])?true:false;
                                }
-                               if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries'])      { $theValue.='<!--DMAILER_SECTION_BOUNDARY_END-->'; }
-                       }
+                       } while ($again&&(($slide&&!strlen($tmpValue)&&$slideCollectFuzzy)||($slide&&$slideCollect)));
                }
 
                $theValue = $this->wrap($theValue,$conf['wrap']);
@@ -1228,7 +1254,7 @@ class tslib_cObj {
                                $GLOBALS['TSFE']->sys_page->versionOL($val['table'],$row);
 
                                        // Language Overlay:
-                               if ($GLOBALS['TSFE']->sys_language_contentOL)   {
+                               if (is_array($row) && $GLOBALS['TSFE']->sys_language_contentOL) {
                                        $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay($val['table'],$row,$GLOBALS['TSFE']->sys_language_content,$GLOBALS['TSFE']->sys_language_contentOL);
                                }
 
@@ -1655,7 +1681,7 @@ class tslib_cObj {
                                                if ($conf['noWrapAttr'] || $wrap === 'disabled')        {
                                                        $wrap='';
                                                } else {
-                                                       $wrap=$wrap ? ' wrap="'.trim($fParts[3]).'"' : ' wrap="virtual"';
+                                                       $wrap = $wrap ? ' wrap="'.$wrap.'"' : ' wrap="virtual"';
                                                }
                                                $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], str_replace('\n',chr(10),trim($parts[2])));
                                                $fieldCode=sprintf('<textarea name="%s"'.$elementIdAttribute.' cols="%s" rows="%s"%s'.$addParams.'>%s</textarea>',
@@ -2109,6 +2135,7 @@ class tslib_cObj {
                                $cObj->setParent($this->data,$this->currentRecord);
                                $renderCode='';
                                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($search->result))   {
+                                               // versionOL() here? This is search result displays, is that possible to preview anyway? Or are records selected here already future versions?
                                        $cObj->start($row);
                                        $renderCode.=$cObj->cObjGetSingle($conf['renderObj'], $conf['renderObj.'],'renderObj');
                                }
@@ -2418,6 +2445,36 @@ class tslib_cObj {
         ************************************/
 
        /**
+        * Returns all parents of the given PID (Page UID) list
+        *
+        * @param       string          A list of page Content-Element PIDs (Page UIDs) / stdWrap
+        * @param       array           stdWrap array for the list
+        * @return      string          A list of PIDs
+        * @access private
+        */
+       function getSlidePids($pidList, $pidConf)       {
+               $pidList = trim($this->stdWrap($pidList,$pidConf));
+               if (!strcmp($pidList,''))       {
+                       $pidList = 'this';
+               }
+               if (trim($pidList))     {
+                       $listArr = t3lib_div::intExplode(',',str_replace('this',$GLOBALS['TSFE']->contentPid,$pidList));
+                       $listArr = $this->checkPidArray($listArr);
+               }
+               $pidList = array();
+               if (is_array($listArr)&&count($listArr))        {
+                       foreach ($listArr as $uid)      {
+                               $page = $GLOBALS['TSFE']->sys_page->getPage($uid);
+                               if (!$page['is_siteroot'])      {
+                                       $pidList[] = $page['pid'];
+                               }
+                       }
+               }
+               return implode(',', $pidList);
+       }
+
+
+       /**
         * Creates a link to a netprint application on another website (where the "netprint" extension is running")
         * Related to the extension "netprint"
         *
@@ -6033,7 +6090,7 @@ class tslib_cObj {
        function getTreeList($id,$depth,$begin=0,$dontCheckEnableFields=FALSE,$addSelectFields='',$moreWhereClauses='', $prevId_array=array(), $recursionLevel=0)       {
 
                        // Init vars:
-               $allFields = 'uid,hidden,starttime,endtime,fe_group,extendToSubpages,doktype,php_tree_stop,mount_pid,mount_pid_ol'.$addSelectFields;
+               $allFields = 'uid,hidden,starttime,endtime,fe_group,extendToSubpages,doktype,php_tree_stop,mount_pid,mount_pid_ol,t3ver_state'.$addSelectFields;
                $depth = intval($depth);
                $begin = intval($begin);
                $id = intval($id);
@@ -6070,37 +6127,43 @@ class tslib_cObj {
 
                                // Select sublevel:
                        if ($depth>0)   {
-                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($allFields, 'pages', 'pid='.intval($id).' AND deleted=0 AND doktype!=255 AND doktype!=6'.$moreWhereClauses, '' ,'sorting');
+                               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($allFields, 'pages', 'pid='.intval($id).' AND deleted=0'.$moreWhereClauses, '' ,'sorting');
                                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
-#??                            $GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
+                                       $GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
 
-                                               // Find mount point if any:
-                                       $next_id = $row['uid'];
-                                       $mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($next_id, $row);
-                                               // Overlay mode:
-                                       if (is_array($mount_info) && $mount_info['overlay'])    {
-                                               $next_id = $mount_info['mount_pid'];
-                                               $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery($allFields, 'pages', 'uid='.intval($next_id).' AND deleted=0 AND doktype!=255 AND doktype!=6'.$moreWhereClauses, '' ,'sorting');
-                                               $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2);
-#??                                            $GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
-                                       }
-                                               // Add record:
-                                       if (is_array($row) && ($dontCheckEnableFields || $GLOBALS['TSFE']->checkPagerecordForIncludeSection($row)))     {
-                                                       // Add ID to list:
-                                               if ($begin<=0)  {
-                                                       if ($dontCheckEnableFields || $GLOBALS['TSFE']->checkEnableFields($row))        {
-                                                               $theList.= $next_id.',';
-                                                       }
+                                       if ($row['doktype']==255 || $row['doktype']==6 || $row['t3ver_state']==1)       { unset($row); }        // Doing this after the overlay to make sure changes in the overlay are respected.
+
+                                       if (is_array($row))     {
+                                                       // Find mount point if any:
+                                               $next_id = $row['uid'];
+                                               $mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($next_id, $row);
+                                                       // Overlay mode:
+                                               if (is_array($mount_info) && $mount_info['overlay'])    {
+                                                       $next_id = $mount_info['mount_pid'];
+                                                       $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery($allFields, 'pages', 'uid='.intval($next_id).' AND deleted=0'.$moreWhereClauses, '' ,'sorting');
+                                                       $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2);
+                                                       $GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
+
+                                                       if ($row['doktype']==255 || $row['doktype']==6 || $row['t3ver_state']==1)       { unset($row); }        // Doing this after the overlay to make sure changes in the overlay are respected.
                                                }
-                                                       // Next level:
-                                               if ($depth>1 && !$row['php_tree_stop']) {
-                                                               // Normal mode:
-                                                       if (is_array($mount_info) && !$mount_info['overlay'])   {
-                                                               $next_id = $mount_info['mount_pid'];
+                                                       // Add record:
+                                               if (is_array($row) && ($dontCheckEnableFields || $GLOBALS['TSFE']->checkPagerecordForIncludeSection($row)))     {
+                                                               // Add ID to list:
+                                                       if ($begin<=0)  {
+                                                               if ($dontCheckEnableFields || $GLOBALS['TSFE']->checkEnableFields($row))        {
+                                                                       $theList.= $next_id.',';
+                                                               }
                                                        }
-                                                               // Call recursively, if the id is not in prevID_array:
-                                                       if (!in_array($next_id,$prevId_array))  {
-                                                               $theList.= tslib_cObj::getTreeList($next_id, $depth-1, $begin-1, $dontCheckEnableFields, $addSelectFields, $moreWhereClauses, $prevId_array, $recursionLevel+1);
+                                                               // Next level:
+                                                       if ($depth>1 && !$row['php_tree_stop']) {
+                                                                       // Normal mode:
+                                                               if (is_array($mount_info) && !$mount_info['overlay'])   {
+                                                                       $next_id = $mount_info['mount_pid'];
+                                                               }
+                                                                       // Call recursively, if the id is not in prevID_array:
+                                                               if (!in_array($next_id,$prevId_array))  {
+                                                                       $theList.= tslib_cObj::getTreeList($next_id, $depth-1, $begin-1, $dontCheckEnableFields, $addSelectFields, $moreWhereClauses, $prevId_array, $recursionLevel+1);
+                                                               }
                                                        }
                                                }
                                        }
@@ -6355,7 +6418,7 @@ class tslib_cObj {
                                // removes all pages which are not visible for the user!
                        $listArr = $this->checkPidArray($listArr);
                        if (count($listArr))    {
-                           $query.=' AND '.$table.'.pid IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($listArr)).')';
+                               $query.=' AND '.$table.'.pid IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($listArr)).')';
                                $pid_uid_flag++;
                        } else {
                                $pid_uid_flag=0;                // If not uid and not pid then uid is set to 0 - which results in nothing!!