[TASK] Remove XCLASS definitions from typo3/
[Packages/TYPO3.CMS.git] / typo3 / class.webpagetree.php
index 92d9141..3742c36 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
 /**
  * Page navigation tree for the Web module
  *
- * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
+ * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
  * XHTML compliant
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @author     Benjamin Mack   <bmack@xnos.org>
  *
  *
@@ -45,7 +45,7 @@
  *  146:     function wrapTitle($title,$row,$bank=0)
  *  165:     function printTree($treeArr = '')
  *  271:     function PMicon($row,$a,$c,$nextCount,$exp)
- *  292:     function PMiconATagWrap($icon, $cmd, $isExpand = true)
+ *  292:     function PMiconATagWrap($icon, $cmd, $isExpand = TRUE)
  *  309:     function getBrowsableTree()
  *  377:     function getTree($uid, $depth=999, $depthData='',$blankLineCode='',$subCSSclass='')
  *
@@ -60,7 +60,7 @@
  * Extension class for the t3lib_browsetree class, specially made
  * for browsing pages in the Web module
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @author     Benjamin Mack   <bmack@xnos.org>
  * @package TYPO3
  * @subpackage core
@@ -72,14 +72,14 @@ class webPageTree extends t3lib_browseTree {
        var $ext_IconMode;
        var $ext_separateNotinmenuPages;
        var $ext_alphasortNotinmenuPages;
-       var $ajaxStatus = false; // Indicates, whether the ajax call was successful, i.e. the requested page has been found
+       var $ajaxStatus = FALSE; // Indicates, whether the ajax call was successful, i.e. the requested page has been found
 
        /**
         * Calls init functions
         *
         * @return      void
         */
-       function webPageTree() {
+       function __construct() {
                $this->init();
        }
 
@@ -90,18 +90,15 @@ class webPageTree extends t3lib_browseTree {
         * @param       array           Data row for element.
         * @return      string          Page icon
         */
-       function wrapIcon($icon,&$row)  {
+       function wrapIcon($thePageIcon, &$row)  {
                        // If the record is locked, present a warning sign.
                if ($lockInfo=t3lib_BEfunc::isRecordLocked('pages',$row['uid']))        {
                        $aOnClick = 'alert('.$GLOBALS['LANG']->JScharCode($lockInfo['msg']).');return false;';
                        $lockIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
-                               '<img'.t3lib_iconWorks::skinImg('','gfx/recordlock_warning3.gif','width="17" height="12"').' title="'.htmlspecialchars($lockInfo['msg']).'" alt="" />'.
+                               t3lib_iconWorks::getSpriteIcon('status-warning-in-use',array('title'=>htmlspecialchars($lockInfo['msg']))).
                                '</a>';
                } else $lockIcon = '';
 
-                       // Add title attribute to input icon tag
-               $thePageIcon = $this->addTagAttributes($icon, $this->titleAttrib.'="'.$this->getTitleAttrib($row).'"');
-
                        // Wrap icon in click-menu link.
                if (!$this->ext_IconMode)       {
                        $thePageIcon = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon($thePageIcon,'pages',$row['uid'],0,'&bank='.$this->bank);
@@ -115,7 +112,9 @@ class webPageTree extends t3lib_browseTree {
 
                        // Add Page ID:
                $pageIdStr = '';
-               if ($this->ext_showPageId) { $pageIdStr = '['.$row['uid'].']&nbsp;'; }
+               if ($this->ext_showPageId) {
+                       $pageIdStr = '<span class="dragId">[' . $row['uid'] . ']</span> ';
+               }
 
                        // Call stats information hook
                $stat = '';
@@ -162,12 +161,9 @@ class webPageTree extends t3lib_browseTree {
                        }
                        unset($_params);
                }
-               
+
                $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->domIdPrefix.$this->getId($row).'\','.$bank.');';
-               $CSM = '';
-               if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler'])       {
-                       $CSM = ' oncontextmenu="'.htmlspecialchars($GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon('','pages',$row['uid'],0,'&bank='.$this->bank,'',TRUE)).';"';
-               }
+               $CSM = ' oncontextmenu="'.htmlspecialchars($GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon('','pages',$row['uid'],0,'&bank='.$this->bank,'',TRUE)).';"';
                $thePageTitle='<a href="#" onclick="'.htmlspecialchars($aOnClick).'"'.$CSM.'>'.$title.'</a>';
 
                        // Wrap title in a drag/drop span.
@@ -195,17 +191,17 @@ class webPageTree extends t3lib_browseTree {
                        // -- evaluate AJAX request
                        // IE takes anchor as parameter
                $PM = t3lib_div::_GP('PM');
-               if(($PMpos = strpos($PM, '#')) !== false) { $PM = substr($PM, 0, $PMpos); }
+               if(($PMpos = strpos($PM, '#')) !== FALSE) { $PM = substr($PM, 0, $PMpos); }
                $PM = explode('_', $PM);
-               if((TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX) && is_array($PM) && count($PM)==4) {
+               if ((TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX) && is_array($PM) && count($PM) == 4 && $PM[2] != 0) {
                        if($PM[1])      {
                                $expandedPageUid = $PM[2];
                                $ajaxOutput = '';
                                $invertedDepthOfAjaxRequestedItem = 0; // We don't know yet. Will be set later.
-                               $doExpand = true;
+                               $doExpand = TRUE;
                        } else  {
                                $collapsedPageUid = $PM[2];
-                               $doCollapse = true;
+                               $doCollapse = TRUE;
                        }
                }
 
@@ -222,7 +218,7 @@ class webPageTree extends t3lib_browseTree {
                        // if this item is the start of a new level,
                        // then a new level <ul> is needed, but not in ajax mode
                        if($v['isFirst'] && !($doCollapse) && !($doExpand && $expandedPageUid == $uid)) {
-                               $itemHTML = '</div><ul>';
+                               $itemHTML = '<ul>';
                        }
 
                        // add CSS classes to the list item
@@ -232,10 +228,10 @@ class webPageTree extends t3lib_browseTree {
                        $itemHTML .='
                                <li id="'.$idAttr.'"'.($classAttr ? ' class="'.$classAttr.'"' : '').'><div class="treeLinkItem">'.
                                        $v['HTML'].
-                                       $this->wrapTitle($this->getTitleStr($v['row'],$titleLen),$v['row'],$v['bank'])."\n";
+                                       $this->wrapTitle($this->getTitleStr($v['row'],$titleLen),$v['row'],$v['bank'])."</div>\n";
 
 
-                       if(!$v['hasSub']) { $itemHTML .= '</div></li>'; }
+                       if(!$v['hasSub']) { $itemHTML .= '</li>'; }
 
                        // we have to remember if this is the last one
                        // on level X so the last child on level X+1 closes the <ul>-tag
@@ -253,7 +249,7 @@ class webPageTree extends t3lib_browseTree {
 
                        // ajax request: collapse
                        if($doCollapse && $collapsedPageUid == $uid) {
-                               $this->ajaxStatus = true;
+                               $this->ajaxStatus = TRUE;
                                return $itemHTML;
                        }
 
@@ -265,7 +261,7 @@ class webPageTree extends t3lib_browseTree {
                                if($v['invertedDepth'] < $invertedDepthOfAjaxRequestedItem) {
                                        $ajaxOutput .= $itemHTML;
                                } else {
-                                       $this->ajaxStatus = true;
+                                       $this->ajaxStatus = TRUE;
                                        return $ajaxOutput;
                                }
                        }
@@ -274,7 +270,7 @@ class webPageTree extends t3lib_browseTree {
                }
 
                if($ajaxOutput) {
-                       $this->ajaxStatus = true;
+                       $this->ajaxStatus = TRUE;
                        return $ajaxOutput;
                }
 
@@ -317,7 +313,7 @@ class webPageTree extends t3lib_browseTree {
         * @return      string          Link-wrapped input string
         * @access private
         */
-       function PMiconATagWrap($icon, $cmd, $isExpand = true)  {
+       function PMiconATagWrap($icon, $cmd, $isExpand = TRUE)  {
                if ($this->thisScript) {
                                // activate dynamic ajax-based tree
                        $js = htmlspecialchars('Tree.load(\''.$cmd.'\', '.intval($isExpand).', this);');
@@ -348,7 +344,7 @@ class webPageTree extends t3lib_browseTree {
 
                                // Set first:
                        $this->bank = $idx;
-                       $isOpen = $this->stored[$idx][$uid] || $this->expandFirst;
+                       $isOpen = $this->stored[$idx][$uid] || $this->expandFirst || $uid === '0';
 
                                // Save ids while resetting everything else.
                        $curIds = $this->ids;
@@ -357,8 +353,11 @@ class webPageTree extends t3lib_browseTree {
 
                                // Set PM icon for root of mount:
                        $cmd = $this->bank.'_'.($isOpen? "0_" : "1_").$uid.'_'.$this->treeName;
-                       $icon='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($isOpen?'minus':'plus').'only.gif').' alt="" />';
-                       $firstHtml = $this->PMiconATagWrap($icon,$cmd,!$isOpen);
+                               // only, if not for uid 0
+                       if ($uid) {
+                               $icon = '<img' . t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/' . ($isOpen ? 'minus' :'plus' ) . 'only.gif') . ' alt="" />';
+                               $firstHtml = $this->PMiconATagWrap($icon, $cmd, !$isOpen);
+                       }
 
                                // Preparing rootRec for the mount
                        if ($uid)   {
@@ -375,7 +374,7 @@ class webPageTree extends t3lib_browseTree {
                                $uid = $rootRec['uid'];
 
                                        // Add the root of the mount to ->tree
-                               $this->tree[] = array('HTML'=>$firstHtml, 'row'=>$rootRec, 'bank'=>$this->bank, 'hasSub'=>true, 'invertedDepth'=>1000);
+                               $this->tree[] = array('HTML'=>$firstHtml, 'row'=>$rootRec, 'bank'=>$this->bank, 'hasSub'=>TRUE, 'invertedDepth'=>1000);
 
                                        // If the mount is expanded, go down:
                                if ($isOpen)    {
@@ -420,8 +419,9 @@ class webPageTree extends t3lib_browseTree {
                        $crazyRecursionLimiter--;
 
                                // Not in menu:
-                               // @TODO: RFC #7370: doktype 2&5 are deprecated since TYPO3 4.2-beta1
-                       if ($this->ext_separateNotinmenuPages && (t3lib_div::inList('5,6',$row['doktype']) || $row['doktype']>=200 || $row['nav_hide']))        {
+                       if ($this->ext_separateNotinmenuPages &&
+                               ($row['doktype'] == t3lib_pageSelect::DOKTYPE_BE_USER_SECTION ||
+                                       $row['doktype'] >= 200 || $row['nav_hide'])) {
                                $outOfMenuPages[] = $row;
                                $outOfMenuPagesTextIndex[] = ($row['doktype']>=200 ? 'zzz'.$row['doktype'].'_' : '').$row['title'];
                        } else {
@@ -498,23 +498,18 @@ class webPageTree extends t3lib_browseTree {
                                'HTML'   => $HTML,
                                'hasSub' => $nextCount&&$this->expandNext($newID),
                                'isFirst'=> $a==1,
-                               'isLast' => false,
+                               'isLast' => FALSE,
                                'invertedDepth'=> $depth,
                                'blankLineCode'=> $blankLineCode,
                                'bank' => $this->bank
                        );
                }
 
-               if($a) { $this->tree[$treeKey]['isLast'] = true; }
+               if($a) { $this->tree[$treeKey]['isLast'] = TRUE; }
 
                $this->getDataFree($res);
                $this->buffer_idH = $idH;
                return $c;
        }
 }
-
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.webpagetree.php'])    {
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.webpagetree.php']);
-}
-
 ?>
\ No newline at end of file