No-brainer: Add blanks around OR statement in $BE_USER->getPagePermsClause()
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_positionmap.php
index c851f72..dd564a1 100755 (executable)
@@ -1,22 +1,22 @@
 <?php
 /***************************************************************
 *  Copyright notice
-*  
-*  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
+*
+*  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
-*  This script is part of the TYPO3 project. The TYPO3 project is 
+*  This script is part of the TYPO3 project. The TYPO3 project is
 *  free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
-* 
+*
 *  The GNU General Public License can be found at
 *  http://www.gnu.org/copyleft/gpl.html.
-*  A copy is found in the textfile GPL.txt and important notices to the license 
+*  A copy is found in the textfile GPL.txt and important notices to the license
 *  from the author is found in LICENSE.txt distributed with these scripts.
 *
-* 
+*
 *  This script is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/
-/** 
+/**
  * Contains class for creating a position map.
  *
  * $Id$
  * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
  * XHTML compliant (should be)
  *
- * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  */
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
  *
  *
  *
- *   85: class t3lib_positionMap 
+ *   85: class t3lib_positionMap
  *
  *              SECTION: Page position map:
- *  132:     function positionTree($id,$pageinfo,$perms_clause,$R_URI) 
- *  246:     function JSimgFunc($prefix='')    
- *  276:     function boldTitle($t_code,$dat,$id)      
- *  293:     function onClickEvent($pid,$newPagePID)   
- *  312:     function insertlabel()    
- *  324:     function linkPageTitle($str,$rec) 
- *  335:     function checkNewPageInPid($pid)  
- *  351:     function getModConfig($pid)       
- *  366:     function insertQuadLines($codes,$allBlank=0)      
+ *  132:     function positionTree($id,$pageinfo,$perms_clause,$R_URI)
+ *  246:     function JSimgFunc($prefix='')
+ *  276:     function boldTitle($t_code,$dat,$id)
+ *  293:     function onClickEvent($pid,$newPagePID)
+ *  312:     function insertlabel()
+ *  324:     function linkPageTitle($str,$rec)
+ *  335:     function checkNewPageInPid($pid)
+ *  351:     function getModConfig($pid)
+ *  366:     function insertQuadLines($codes,$allBlank=0)
  *
  *              SECTION: Content element positioning:
- *  404:     function printContentElementColumns($pid,$moveUid,$colPosList,$showHidden,$R_URI) 
- *  440:     function printRecordMap($lines,$colPosArray)      
- *  478:     function wrapColumnHeader($str,$vv)       
- *  492:     function insertPositionIcon($row,$vv,$kk,$moveUid,$pid)   
- *  509:     function onClickInsertRecord($row,$vv,$moveUid,$pid,$sys_lang=0) 
- *  529:     function wrapRecordHeader($str,$row)      
- *  539:     function getRecordHeader($row)    
- *  552:     function wrapRecordTitle($str,$row)       
+ *  404:     function printContentElementColumns($pid,$moveUid,$colPosList,$showHidden,$R_URI)
+ *  442:     function printRecordMap($lines,$colPosArray)
+ *  480:     function wrapColumnHeader($str,$vv)
+ *  494:     function insertPositionIcon($row,$vv,$kk,$moveUid,$pid)
+ *  511:     function onClickInsertRecord($row,$vv,$moveUid,$pid,$sys_lang=0)
+ *  531:     function wrapRecordHeader($str,$row)
+ *  541:     function getRecordHeader($row)
+ *  554:     function wrapRecordTitle($str,$row)
  *
  * TOTAL FUNCTIONS: 17
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
+
+
+
+
+
+
+
+
+
 /**
  * Position map class - generating a page tree / content element list which links for inserting (copy/move) of records.
  * Used for pages / tt_content element wizards of various kinds.
  *
- * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage t3lib
  */
 class t3lib_positionMap {
 
-               // EXTERNAL, static:    
+               // EXTERNAL, static:
        var $moveOrCopy='move';
        var $dontPrintPageInsertIcons=0;
        var $backPath='';
@@ -111,8 +111,8 @@ class t3lib_positionMap {
 
 
 
-       
-       
+
+
        /*************************************
         *
         * Page position map:
@@ -130,8 +130,8 @@ class t3lib_positionMap {
         * @return      string          HTML code for the tree.
         */
        function positionTree($id,$pageinfo,$perms_clause,$R_URI)       {
-               global $LANG;
-               
+               global $LANG, $BE_USER;
+
                        // Make page tree object:
                $t3lib_pageTree = t3lib_div::makeInstance('localPageTree');
                $t3lib_pageTree->init(' AND '.$perms_clause);
@@ -140,11 +140,11 @@ class t3lib_positionMap {
                        // Initialize variables:
                $this->R_URI = $R_URI;
                $this->elUid = $id;
-       
+
                        // Create page tree, in $this->depth levels.
                $t3lib_pageTree->getTree($pageinfo['pid'], $this->depth);
                if (!$this->dontPrintPageInsertIcons)   $code.=$this->JSimgFunc();
-               
+
                        // Initialize variables:
                $saveBlankLineState=array();
                $saveLatestUid=array();
@@ -152,13 +152,13 @@ class t3lib_positionMap {
 
                        // Traverse the tree:
                foreach($t3lib_pageTree->tree as $cc => $dat)   {
-               
+
                                // Make link + parameters.
                        $latestInvDepth=$dat['invertedDepth'];
                        $saveLatestUid[$latestInvDepth]=$dat;
                        if (isset($t3lib_pageTree->tree[$cc-1]))        {
                                $prev_dat = $t3lib_pageTree->tree[$cc-1];
-                               
+
                                        // If current page, subpage?
                                if ($prev_dat['row']['uid']==$id)       {
                                        if (!$this->dontPrintPageInsertIcons && $this->checkNewPageInPid($id) && !($prev_dat['invertedDepth']>$t3lib_pageTree->tree[$cc]['invertedDepth']))     {       // 1) It must be allowed to create a new page and 2) If there are subpages there is no need to render a subpage icon here - it'll be done over the subpages...
@@ -170,7 +170,7 @@ class t3lib_positionMap {
                                                        '</a></span><br />';
                                        }
                                }
-                                       
+
                                if ($prev_dat['invertedDepth']>$t3lib_pageTree->tree[$cc]['invertedDepth'])     {       // If going down
                                        $prevPid = $t3lib_pageTree->tree[$cc]['row']['pid'];
                                } elseif ($prev_dat['invertedDepth']<$t3lib_pageTree->tree[$cc]['invertedDepth'])       {               // If going up
@@ -184,9 +184,9 @@ class t3lib_positionMap {
                                                        '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/newrecord_marker_d.gif','width="281" height="8"').' name="mImgAfter'.$cc.'" border="0" align="top" title="'.$this->insertlabel().'" alt="" />'.
                                                        '</a></span><br />';
                                        }
-       
+
                                        // Then set the current prevPid
-                                       $prevPid = -$prev_dat['row']['pid'];    
+                                       $prevPid = -$prev_dat['row']['pid'];
                                } else {
                                        $prevPid = -$prev_dat['row']['uid'];    // In on the same level
                                }
@@ -200,15 +200,15 @@ class t3lib_positionMap {
                                        '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/newrecord_marker_d.gif','width="281" height="8"').' name="mImg'.$cc.'" border="0" align="top" title="'.$this->insertlabel().'" alt="" />'.
                                        '</a></span><br />';
                        }
-       
+
                                // The line with the icon and title:
                        $t_code='<span class="nobr">'.
                                $dat['HTML'].
-                               $this->linkPageTitle($this->boldTitle(htmlspecialchars(t3lib_div::fixed_lgd($dat['row']['title'],$BE_USER->uc['titleLen'])),$dat,$id),$dat['row']).
+                               $this->linkPageTitle($this->boldTitle(htmlspecialchars(t3lib_div::fixed_lgd_cs($dat['row']['title'],$BE_USER->uc['titleLen'])),$dat,$id),$dat['row']).
                                '</span><br />';
                        $code.=$t_code;
                }
-               
+
                        // If the current page was the last in the tree:
                $prev_dat = end($t3lib_pageTree->tree);
                if ($prev_dat['row']['uid']==$id)       {
@@ -221,7 +221,7 @@ class t3lib_positionMap {
                                        '</a></span><br />';
                        }
                }
-       
+
                for ($a=$latestInvDepth;$a<=$this->depth;$a++)  {
                        $dat = $saveLatestUid[$a];
                        $prevPid = (-$dat['row']['uid']);
@@ -233,7 +233,7 @@ class t3lib_positionMap {
                                        '</a></span><br />';
                        }
                }
-       
+
                return $code;
        }
 
@@ -245,13 +245,13 @@ class t3lib_positionMap {
         */
        function JSimgFunc($prefix='')  {
                $code.=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
-               
-                       var img_newrecord_marker=new Image(); 
+
+                       var img_newrecord_marker=new Image();
                        img_newrecord_marker.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/newrecord'.$prefix.'_marker.gif','',1).'";
-       
-                       var img_newrecord_marker_d=new Image(); 
+
+                       var img_newrecord_marker_d=new Image();
                        img_newrecord_marker_d.src = "'.t3lib_iconWorks::skinImg($this->backPath,'gfx/newrecord'.$prefix.'_marker_d.gif','',1).'";
-       
+
                        function changeImg(name,d)      {       //
                                if (document[name]) {
                                        if (d)  {
@@ -292,10 +292,10 @@ class t3lib_positionMap {
         */
        function onClickEvent($pid,$newPagePID) {
                $TSconfigProp = $this->getModConfig($newPagePID);
-               
+
                if ($TSconfigProp['overrideWithExtension'])     {
                        if (t3lib_extMgm::isLoaded($TSconfigProp['overrideWithExtension']))     {
-                               $onclick = "document.location='".t3lib_extMgm::extRelPath($TSconfigProp['overrideWithExtension']).'mod1/index.php?cmd=crPage&positionPid='.$pid."';";
+                               $onclick = "window.location.href='".t3lib_extMgm::extRelPath($TSconfigProp['overrideWithExtension']).'mod1/index.php?cmd=crPage&positionPid='.$pid."';";
                                return $onclick;
                        }
                }
@@ -409,21 +409,25 @@ class t3lib_positionMap {
                $lines=array();
                while(list($kk,$vv)=each($colPosArray)) {
                        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                                                       '*', 
-                                                       'tt_content', 
+                                                       '*',
+                                                       'tt_content',
                                                        'pid='.intval($pid).
                                                                ($showHidden ? '' : t3lib_BEfunc::BEenableFields('tt_content')).
                                                                ' AND colPos='.intval($vv).
                                                                (strcmp($this->cur_sys_language,'') ? ' AND sys_language_uid='.intval($this->cur_sys_language) : '').
-                                                               t3lib_BEfunc::deleteClause('tt_content'),
-                                                       '', 
+                                                               t3lib_BEfunc::deleteClause('tt_content').
+                                                               t3lib_BEfunc::versioningPlaceholderClause('tt_content'),
+                                                       '',
                                                        'sorting'
                                                );
                        $lines[$kk]=array();
                        $lines[$kk][]=$this->insertPositionIcon('',$vv,$kk,$moveUid,$pid);
                        while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))               {
-                               $lines[$kk][]=$this->wrapRecordHeader($this->getRecordHeader($row),$row);
-                               $lines[$kk][]=$this->insertPositionIcon($row,$vv,$kk,$moveUid,$pid);
+                               t3lib_BEfunc::workspaceOL('tt_content',$row);
+                               if (is_array($row))     {
+                                       $lines[$kk][]=$this->wrapRecordHeader($this->getRecordHeader($row),$row);
+                                       $lines[$kk][]=$this->insertPositionIcon($row,$vv,$kk,$moveUid,$pid);
+                               }
                        }
                        $GLOBALS['TYPO3_DB']->sql_free_result($res);
                }
@@ -441,7 +445,7 @@ class t3lib_positionMap {
                $row1='';
                $row2='';
                $count = t3lib_div::intInRange(count($colPosArray),1);
-               
+
                        // Traverse the columns here:
                foreach($colPosArray as $kk => $vv)     {
                        $row1.='<td align="center" width="'.round(100/$count).'%"><span class="uppercase"><strong>'.
@@ -451,19 +455,19 @@ class t3lib_positionMap {
                                        implode('<br />',$lines[$kk]).
                                        '</td>';
                }
-               
+
                $table = '
-               
+
                <!--
-                       Map of records in columns: 
+                       Map of records in columns:
                -->
                <table border="0" cellpadding="0" cellspacing="1" id="typo3-ttContentList">
                        <tr class="bgColor5">'.$row1.'</tr>
                        <tr>'.$row2.'</tr>
                </table>
-               
+
                ';
-               
+
                return $this->JSimgFunc('2').$table;
        }
 
@@ -516,7 +520,7 @@ class t3lib_positionMap {
 //             $location.='&redirect='.rawurlencode($this->R_URI);             // returns to prev. page
                $location.='&uPT=1&redirect='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));               // This redraws screen
 
-               return 'document.location=\''.$location.'\';return false;';
+               return 'window.location.href=\''.$location.'\';return false;';
        }
 
        /**
@@ -538,7 +542,7 @@ class t3lib_positionMap {
         */
        function getRecordHeader($row)  {
                $line = t3lib_iconWorks::getIconImage('tt_content',$row,$this->backPath,' align="top" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($row,'tt_content')).'"');
-               $line.= t3lib_BEfunc::getRecordTitle('tt_content',$row,1);
+               $line.= t3lib_BEfunc::getRecordTitle('tt_content',$row,TRUE);
                return $this->wrapRecordTitle($line,$row);
        }