Added feature #15783: Improve ExtJS skin: Tabs
[Packages/TYPO3.CMS.git] / typo3 / class.webpagetree.php
index 9916bf3..d996f84 100644 (file)
-<?php\r
-/***************************************************************\r
-*  Copyright notice\r
-*\r
-*  (c) 1999-2006 Kasper Skaarhoj (kasperYYYY@typo3.com)\r
-*  All rights reserved\r
-*\r
-*  This script is part of the TYPO3 project. The TYPO3 project is\r
-*  free software; you can redistribute it and/or modify\r
-*  it under the terms of the GNU General Public License as published by\r
-*  the Free Software Foundation; either version 2 of the License, or\r
-*  (at your option) any later version.\r
-*\r
-*  The GNU General Public License can be found at\r
-*  http://www.gnu.org/copyleft/gpl.html.\r
-*  A copy is found in the textfile GPL.txt and important notices to the license\r
-*  from the author is found in LICENSE.txt distributed with these scripts.\r
-*\r
-*\r
-*  This script is distributed in the hope that it will be useful,\r
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-*  GNU General Public License for more details.\r
-*\r
-*  This copyright notice MUST APPEAR in all copies of the script!\r
-***************************************************************/\r
-/**\r
- * Page navigation tree for the Web module\r
- *\r
- * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj\r
- * XHTML compliant\r
- *\r
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>\r
- * @author     Benjamin Mack   <bmack@xnos.org>\r
- *\r
- *\r
- * [CLASS/FUNCTION INDEX of SCRIPT]\r
- *\r
- *\r
- *\r
- *   71: class webPageTree extends t3lib_browseTree\r
- *   81:     function webPageTree()\r
- *   92:     function wrapIcon($icon,&$row)\r
- *  130:     function wrapStop($str,$row)\r
- *  146:     function wrapTitle($title,$row,$bank=0)\r
- *  165:     function printTree($treeArr = '')\r
- *  271:     function PMicon($row,$a,$c,$nextCount,$exp)\r
- *  292:     function PMiconATagWrap($icon, $cmd, $isExpand = true)\r
- *  309:     function getBrowsableTree()\r
- *  377:     function getTree($uid, $depth=999, $depthData='',$blankLineCode='',$subCSSclass='')\r
- *\r
- *\r
- * TOTAL FUNCTIONS: 9\r
- * (This index is automatically created/updated by the extension "extdeveval")\r
- *\r
- */\r
-\r
-\r
-require_once(PATH_t3lib.'class.t3lib_browsetree.php');\r
-\r
-\r
-/**\r
- * Extension class for the t3lib_browsetree class, specially made \r
- * for browsing pages in the Web module\r
- *\r
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>\r
- * @author     Benjamin Mack   <bmack@xnos.org>\r
- * @package TYPO3\r
- * @subpackage core\r
- * @see class t3lib_browseTree\r
- */\r
-class webPageTree extends t3lib_browseTree {\r
-\r
-       var $ext_showPageId;\r
-       var $ext_IconMode;\r
-\r
-       /**\r
-        * Calls init functions\r
-        *\r
-        * @return      void\r
-        */\r
-       function webPageTree() {\r
-               $this->init();\r
-       }\r
-\r
-       /**\r
-        * Wrapping icon in browse tree\r
-        *\r
-        * @param       string          Icon IMG code\r
-        * @param       array           Data row for element.\r
-        * @return      string          Page icon\r
-        */\r
-       function wrapIcon($icon,&$row)  {\r
-                       // If the record is locked, present a warning sign.\r
-               if ($lockInfo=t3lib_BEfunc::isRecordLocked('pages',$row['uid']))        {\r
-                       $aOnClick = 'alert('.$GLOBALS['LANG']->JScharCode($lockInfo['msg']).');return false;';\r
-                       $lockIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.\r
-                               '<img'.t3lib_iconWorks::skinImg('','gfx/recordlock_warning3.gif','width="17" height="12"').' title="'.htmlspecialchars($lockInfo['msg']).'" alt="" />'.\r
-                               '</a>';\r
-               } else $lockIcon = '';\r
-\r
-                       // Add title attribute to input icon tag\r
-               $thePageIcon = $this->addTagAttributes($icon, $this->titleAttrib.'="'.$this->getTitleAttrib($row).'"');\r
-\r
-                       // Wrap icon in click-menu link.\r
-               if (!$this->ext_IconMode)       {\r
-                       $thePageIcon = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon($thePageIcon,'pages',$row['uid'],0,'&bank='.$this->bank);\r
-               } elseif (!strcmp($this->ext_IconMode,'titlelink'))     {\r
-                       $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->treeName.'\');';\r
-                       $thePageIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$thePageIcon.'</a>';\r
-               }\r
-\r
-                       // Wrap icon in a drag/drop span.\r
-               $dragDropIcon = '<span class="dragIcon" id="dragIconID_'.$row['uid'].'">'.$thePageIcon.'</span>';\r
-\r
-                       // Add Page ID:\r
-               $pageIdStr = '';\r
-               if ($this->ext_showPageId) { $pageIdStr = '['.$row['uid'].']&nbsp;'; }\r
-\r
-               return $dragDropIcon.$lockIcon.$pageIdStr;\r
-       }\r
-\r
-       /**\r
-        * Adds a red "+" to the input string, $str, if the field "php_tree_stop" in the $row (pages) is set\r
-        *\r
-        * @param       string          Input string, like a page title for the tree\r
-        * @param       array           record row with "php_tree_stop" field\r
-        * @return      string          Modified string\r
-        * @access private\r
-        */\r
-       function wrapStop($str,$row)    {\r
-               if ($row['php_tree_stop'])      {\r
-                       $str.='<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => $row['uid']))).'" class="typo3-red">+</a> ';\r
-               }\r
-               return $str;\r
-       }\r
-\r
-       /**\r
-        * Wrapping $title in a-tags.\r
-        *\r
-        * @param       string          Title string\r
-        * @param       string          Item record\r
-        * @param       integer         Bank pointer (which mount point number)\r
-        * @return      string\r
-        * @access      private\r
-        */\r
-       function wrapTitle($title,$row,$bank=0) {\r
-               $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->domIdPrefix.$this->getId($row).'\','.$bank.');';\r
-               $CSM = '';\r
-               if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler'])       {\r
-                       $CSM = ' oncontextmenu="return '.htmlspecialchars($GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon('','pages',$row['uid'],0,'&bank='.$this->bank,'',TRUE)).';"';\r
-               }\r
-               $thePageTitle='<a href="#" onclick="'.htmlspecialchars($aOnClick).'"'.$CSM.'>'.$title.'</a>';\r
-\r
-                       // Wrap title in a drag/drop span.\r
-               return '<span class="dragTitle" id="dragTitleID_'.$row['uid'].'">'.$thePageTitle.'</span>';\r
-       }\r
-\r
-       \r
-       /**\r
-        * Compiles the HTML code for displaying the structure found inside the ->tree array\r
-        *\r
-        * @param       array           "tree-array" - if blank string, the internal ->tree array is used.\r
-        * @return      string          The HTML code for the tree\r
-        */\r
-       function printTree($treeArr = '')   {\r
-               $titleLen = intval($this->BE_USER->uc['titleLen']);\r
-               if (!is_array($treeArr))        $treeArr = $this->tree;\r
-\r
-               $out = '\r
-                       <!-- TYPO3 tree structure. -->\r
-                       <ul class="tree">\r
-               ';\r
-\r
-                       // -- evaluate AJAX request\r
-                       // IE takes anchor as parameter\r
-               $PM = t3lib_div::_GP('PM');\r
-               if(($PMpos = strpos($PM, '#')) !== false) { $PM = substr($PM, 0, $PMpos); }\r
-               $PM = explode('_', $PM);\r
-               if(($isAjaxCall = t3lib_div::_GP('ajax')) && is_array($PM) && count($PM)==4)    {\r
-                       if($PM[1])      {\r
-                               $expandedPageUid = $PM[2];\r
-                               $ajaxOutput = '';\r
-                               $invertedDepthOfAjaxRequestedItem = 0; // We don't know yet. Will be set later.\r
-                               $doExpand = true;\r
-                       } else  {\r
-                               $collapsedPageUid = $PM[2];\r
-                               $doCollapse = true;\r
-                       }\r
-               }\r
-\r
-               // we need to count the opened <ul>'s every time we dig into another level, \r
-               // so we know how many we have to close when all children are done rendering\r
-               $closeDepth = array();\r
-\r
-               foreach($treeArr as $k => $v)   {\r
-                       $classAttr = $v['row']['_CSSCLASS'];\r
-                       $uid       = $v['row']['uid'];\r
-                       $idAttr = htmlspecialchars($this->domIdPrefix.$this->getId($v['row']).'_'.$v['bank']);\r
-                       $itemHTML  = '';\r
-\r
-                       // if this item is the start of a new level, \r
-                       // then a new level <ul> is needed, but not in ajax mode\r
-                       if($v['isFirst'] && !($doCollapse) && !($doExpand && $expandedPageUid == $uid)) {\r
-                               $itemHTML = '<ul>';\r
-                       }\r
-\r
-                       // add CSS classes to the list item\r
-                       if($v['hasSub']) { $classAttr .= ($classAttr) ? ' expanded': 'expanded'; }\r
-                       if($v['isLast']) { $classAttr .= ($classAttr) ? ' last' : 'last';        }\r
-\r
-                       $itemHTML .='\r
-                               <li id="'.$idAttr.'"'.($classAttr ? ' class="'.$classAttr.'"' : '').'>'.\r
-                                       $v['HTML'].\r
-                                       $this->wrapTitle($this->getTitleStr($v['row'],$titleLen),$v['row'],$v['bank'])."\n";\r
-\r
-\r
-                       if(!$v['hasSub']) { $itemHTML .= '</li>'; }\r
-\r
-                       // we have to remember if this is the last one\r
-                       // on level X so the last child on level X+1 closes the <ul>-tag\r
-                       if($v['isLast'] && !($doExpand && $expandedPageUid == $uid)) { $closeDepth[$v['invertedDepth']] = 1; }\r
-\r
-\r
-                       // if this is the last one and does not have subitems, we need to close\r
-                       // the tree as long as the upper levels have last items too\r
-                       if($v['isLast'] && !$v['hasSub'] && !$doCollapse && !($doExpand && $expandedPageUid == $uid)) {\r
-                               for ($i = $v['invertedDepth']; $closeDepth[$i] == 1; $i++) {\r
-                                       $closeDepth[$i] = 0;\r
-                                       $itemHTML .= '</ul></li>';\r
-                               }\r
-                       }\r
-\r
-                       // ajax request: collapse\r
-                       if($doCollapse && $collapsedPageUid == $uid) { return $itemHTML; }\r
-\r
-                       // ajax request: expand\r
-                       if($doExpand && $expandedPageUid == $uid) {\r
-                               $ajaxOutput .= $itemHTML;\r
-                               $invertedDepthOfAjaxRequestedItem = $v['invertedDepth'];\r
-                       } elseif($invertedDepthOfAjaxRequestedItem) { \r
-                               if($v['invertedDepth'] < $invertedDepthOfAjaxRequestedItem) {\r
-                                       $ajaxOutput .= $itemHTML;\r
-                               } else {\r
-                                       return $ajaxOutput;\r
-                               }\r
-                       }\r
-\r
-                       $out .= $itemHTML;\r
-               }\r
-\r
-               if($ajaxOutput) { return $ajaxOutput; }\r
-\r
-               // finally close the first ul\r
-               $out .= '</ul>';\r
-               return $out;\r
-       }\r
-\r
-\r
-       /**\r
-        * Generate the plus/minus icon for the browsable tree.\r
-        *\r
-        * @param       array           record for the entry\r
-        * @param       integer         The current entry number\r
-        * @param       integer         The total number of entries. If equal to $a, a "bottom" element is returned.\r
-        * @param       integer         The number of sub-elements to the current element.\r
-        * @param       boolean         The element was expanded to render subelements if this flag is set.\r
-        * @return      string          Image tag with the plus/minus icon.\r
-        * @access private\r
-        * @see t3lib_pageTree::PMicon()\r
-        */\r
-       function PMicon($row,$a,$c,$nextCount,$exp)     {\r
-               $PM   = $nextCount ? ($exp ? 'minus' : 'plus') : 'join';\r
-               $BTM  = ($a == $c) ? 'bottom' : '';\r
-               $icon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.$PM.$BTM.'.gif','width="18" height="16"').' alt="" />';\r
-\r
-               if ($nextCount) {\r
-                       $cmd = $this->bank.'_'.($exp?'0_':'1_').$row['uid'].'_'.$this->treeName;\r
-                       $icon = $this->PMiconATagWrap($icon,$cmd,!$exp);\r
-               }\r
-               return $icon;\r
-       }\r
-\r
-\r
-       /**\r
-        * Wrap the plus/minus icon in a link\r
-        *\r
-        * @param       string          HTML string to wrap, probably an image tag.\r
-        * @param       string          Command for 'PM' get var\r
-        * @return      string          Link-wrapped input string\r
-        * @access private\r
-        */\r
-       function PMiconATagWrap($icon, $cmd, $isExpand = true)  {\r
-               if ($this->thisScript) {\r
-                               // activate dynamic ajax-based tree\r
-                       $js = htmlspecialchars('Tree.load(\''.$cmd.'\', '.intval($isExpand).', this);');\r
-                       return '<a class="pm" onclick="'.$js.'">'.$icon.'</a>';\r
-               } else {\r
-                       return $icon;\r
-               }\r
-       }\r
-\r
-\r
-       /**\r
-        * Will create and return the HTML code for a browsable tree\r
-        * Is based on the mounts found in the internal array ->MOUNTS (set in the constructor)\r
-        *\r
-        * @return      string          HTML code for the browsable tree\r
-        */\r
-       function getBrowsableTree() {\r
-\r
-                       // Get stored tree structure AND updating it if needed according to incoming PM GET var.\r
-               $this->initializePositionSaving();\r
-\r
-                       // Init done:\r
-               $titleLen = intval($this->BE_USER->uc['titleLen']);\r
-               $treeArr = array();\r
-               \r
-                       // Traverse mounts:\r
-               foreach($this->MOUNTS as $idx => $uid)  {\r
-\r
-                               // Set first:\r
-                       $this->bank = $idx;\r
-                       $isOpen = $this->stored[$idx][$uid] || $this->expandFirst;\r
-\r
-                               // Save ids while resetting everything else.\r
-                       $curIds = $this->ids;\r
-                       $this->reset();\r
-                       $this->ids = $curIds;\r
-\r
-                               // Set PM icon for root of mount:\r
-                       $cmd = $this->bank.'_'.($isOpen? "0_" : "1_").$uid.'_'.$this->treeName;\r
-                       $icon='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($isOpen?'minus':'plus').'only.gif').' alt="" />';\r
-                       $firstHtml = $this->PMiconATagWrap($icon,$cmd);\r
-\r
-                               // Preparing rootRec for the mount\r
-                       if ($uid)   {\r
-                               $rootRec = $this->getRecord($uid);\r
-                               $firstHtml.=$this->getIcon($rootRec);\r
-                       } else {\r
-                               // Artificial record for the tree root, id=0\r
-                               $rootRec = $this->getRootRecord($uid);\r
-                               $firstHtml.=$this->getRootIcon($rootRec);\r
-                       }\r
-\r
-                       if (is_array($rootRec)) {\r
-                                       // In case it was swapped inside getRecord due to workspaces.\r
-                               $uid = $rootRec['uid'];\r
-\r
-                                       // Add the root of the mount to ->tree\r
-                               $this->tree[] = array('HTML'=>$firstHtml, 'row'=>$rootRec, 'bank'=>$this->bank, 'hasSub'=>true, 'invertedDepth'=>1000);\r
-\r
-                                       // If the mount is expanded, go down:\r
-                               if ($isOpen)    {\r
-                                               // Set depth:\r
-                                       if ($this->addSelfId) { $this->ids[] = $uid; }\r
-                                       $this->getTree($uid, 999, '', $rootRec['_SUBCSSCLASS']);\r
-                               }\r
-                                       // Add tree:\r
-                               $treeArr=array_merge($treeArr,$this->tree);\r
-                       }\r
-               }\r
-               return $this->printTree($treeArr);\r
-       }\r
-\r
-\r
-       /**\r
-        * Fetches the data for the tree\r
-        *\r
-        * @param       integer         item id for which to select subitems (parent id)\r
-        * @param       integer         Max depth (recursivity limit)\r
-        * @param       string          ? (internal)\r
-        * @return      integer         The count of items on the level\r
-        */\r
-       function getTree($uid, $depth=999, $blankLineCode='', $subCSSclass='') {\r
-\r
-                       // Buffer for id hierarchy is reset:\r
-               $this->buffer_idH = array();\r
-\r
-                       // Init vars\r
-               $depth = intval($depth);\r
-               $HTML = '';\r
-               $a = 0;\r
-\r
-               $res = $this->getDataInit($uid, $subCSSclass);\r
-               $c = $this->getDataCount($res);\r
-               $crazyRecursionLimiter = 999;\r
-\r
-                       // Traverse the records:\r
-               while ($crazyRecursionLimiter > 0 && $row = $this->getDataNext($res,$subCSSclass))      {\r
-                       $a++;\r
-                       $crazyRecursionLimiter--;\r
-                       \r
-                       $newID = $row['uid'];\r
-                       $this->tree[]=array();    // Reserve space.\r
-                       end($this->tree);\r
-                       $treeKey = key($this->tree);    // Get the key for this space\r
-                       $LN = ($a==$c) ? 'blank' : 'line';\r
-\r
-                               // If records should be accumulated, do so\r
-                       if ($this->setRecs) { $this->recs[$row['uid']] = $row; }\r
-\r
-                               // Accumulate the id of the element in the internal arrays\r
-                       $this->ids[]=$idH[$row['uid']]['uid'] = $row['uid'];\r
-                       $this->ids_hierarchy[$depth][] = $row['uid'];\r
-\r
-                               // Make a recursive call to the next level\r
-                       if ($depth > 1 && $this->expandNext($newID) && !$row['php_tree_stop'])  {\r
-                               $nextCount=$this->getTree(\r
-                                       $newID,\r
-                                       $depth-1,\r
-                                       $blankLineCode.','.$LN,\r
-                                       $row['_SUBCSSCLASS']\r
-                               );\r
-                               if (count($this->buffer_idH)) { $idH[$row['uid']]['subrow']=$this->buffer_idH; }\r
-                               $exp = 1; // Set "did expand" flag\r
-                       } else {\r
-                               $nextCount = $this->getCount($newID);\r
-                               $exp = 0; // Clear "did expand" flag\r
-                       }\r
-\r
-                               // Set HTML-icons, if any:\r
-                       if ($this->makeHTML)    {\r
-                               $HTML = $this->PMicon($row,$a,$c,$nextCount,$exp);\r
-                               $HTML.= $this->wrapStop($this->getIcon($row),$row);\r
-                       }\r
-\r
-                               // Finally, add the row/HTML content to the ->tree array in the reserved key.\r
-                       $this->tree[$treeKey] = array(\r
-                               'row'    => $row,\r
-                               'HTML'   => $HTML,\r
-                               'hasSub' => $nextCount&&$this->expandNext($newID),\r
-                               'isFirst'=> $a==1,\r
-                               'isLast' => false,\r
-                               'invertedDepth'=> $depth,\r
-                               'blankLineCode'=> $blankLineCode,\r
-                               'bank' => $this->bank\r
-                       );\r
-               }\r
-\r
-               if($a) { $this->tree[$treeKey]['isLast'] = true; }\r
-\r
-               $this->getDataFree($res);\r
-               $this->buffer_idH = $idH;\r
-               return $c;\r
-       }\r
-}\r
-\r
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.webpagetree.php'])    {\r
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.webpagetree.php']);\r
-}\r
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
+*  All rights reserved
+*
+*  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
+*  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
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+/**
+ * Page navigation tree for the Web module
+ *
+ * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
+ * XHTML compliant
+ *
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
+ * @author     Benjamin Mack   <bmack@xnos.org>
+ *
+ *
+ * [CLASS/FUNCTION INDEX of SCRIPT]
+ *
+ *
+ *
+ *   71: class webPageTree extends t3lib_browseTree
+ *   81:     function webPageTree()
+ *   92:     function wrapIcon($icon,&$row)
+ *  130:     function wrapStop($str,$row)
+ *  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)
+ *  309:     function getBrowsableTree()
+ *  377:     function getTree($uid, $depth=999, $depthData='',$blankLineCode='',$subCSSclass='')
+ *
+ *
+ * TOTAL FUNCTIONS: 9
+ * (This index is automatically created/updated by the extension "extdeveval")
+ *
+ */
+
+
+/**
+ * Extension class for the t3lib_browsetree class, specially made
+ * for browsing pages in the Web module
+ *
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
+ * @author     Benjamin Mack   <bmack@xnos.org>
+ * @package TYPO3
+ * @subpackage core
+ * @see class t3lib_browseTree
+ */
+class webPageTree extends t3lib_browseTree {
+
+       var $ext_showPageId;
+       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
+
+       /**
+        * Calls init functions
+        *
+        * @return      void
+        */
+       function webPageTree() {
+               $this->init();
+       }
+
+       /**
+        * Wrapping icon in browse tree
+        *
+        * @param       string          Icon IMG code
+        * @param       array           Data row for element.
+        * @return      string          Page icon
+        */
+       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).'">'.
+                               t3lib_iconWorks::getSpriteIcon('status-warning-in-use',array('title'=>htmlspecialchars($lockInfo['msg']))).
+                               '</a>';
+               } else $lockIcon = '';
+
+                       // Wrap icon in click-menu link.
+               if (!$this->ext_IconMode)       {
+                       $thePageIcon = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon($thePageIcon,'pages',$row['uid'],0,'&bank='.$this->bank);
+               } elseif (!strcmp($this->ext_IconMode,'titlelink'))     {
+                       $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->treeName.'\');';
+                       $thePageIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$thePageIcon.'</a>';
+               }
+
+                       // Wrap icon in a drag/drop span.
+               $dragDropIcon = '<span class="dragIcon" id="dragIconID_'.$row['uid'].'">'.$thePageIcon.'</span>';
+
+                       // Add Page ID:
+               $pageIdStr = '';
+               if ($this->ext_showPageId) {
+                       $pageIdStr = '<span class="dragId">[' . $row['uid'] . ']</span> ';
+               }
+
+                       // Call stats information hook
+               $stat = '';
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks']))  {
+                       $_params = array('pages',$row['uid']);
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef)  {
+                               $stat.=t3lib_div::callUserFunction($_funcRef,$_params,$this);
+                       }
+               }
+
+               return $dragDropIcon.$lockIcon.$pageIdStr.$stat;
+       }
+
+       /**
+        * Adds a red "+" to the input string, $str, if the field "php_tree_stop" in the $row (pages) is set
+        *
+        * @param       string          Input string, like a page title for the tree
+        * @param       array           record row with "php_tree_stop" field
+        * @return      string          Modified string
+        * @access private
+        */
+       function wrapStop($str,$row)    {
+               if ($row['php_tree_stop'])      {
+                       $str.='<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => $row['uid']))).'" class="typo3-red">+</a> ';
+               }
+               return $str;
+       }
+
+       /**
+        * Wrapping $title in a-tags.
+        *
+        * @param       string          Title string
+        * @param       string          Item record
+        * @param       integer         Bank pointer (which mount point number)
+        * @return      string
+        * @access      private
+        */
+       function wrapTitle($title,$row,$bank=0) {
+                       // Hook for overriding the page title
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.webpagetree.php']['pageTitleOverlay'])) {
+                       $_params = array('title' => &$title, 'row' => &$row);
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.webpagetree.php']['pageTitleOverlay'] as $_funcRef) {
+                               t3lib_div::callUserFunction($_funcRef, $_params, $this);
+                       }
+                       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)).';"';
+               }
+               $thePageTitle='<a href="#" onclick="'.htmlspecialchars($aOnClick).'"'.$CSM.'>'.$title.'</a>';
+
+                       // Wrap title in a drag/drop span.
+               return '<span class="dragTitle" id="dragTitleID_'.$row['uid'].'">'.$thePageTitle.'</span>';
+       }
+
+
+       /**
+        * Compiles the HTML code for displaying the structure found inside the ->tree array
+        *
+        * @param       array           "tree-array" - if blank string, the internal ->tree array is used.
+        * @return      string          The HTML code for the tree
+        */
+       function printTree($treeArr = '')   {
+               $titleLen = intval($this->BE_USER->uc['titleLen']);
+               if (!is_array($treeArr)) {
+                       $treeArr = $this->tree;
+               }
+
+               $out = '
+                       <!-- TYPO3 tree structure. -->
+                       <ul class="tree" id="treeRoot">
+               ';
+
+                       // -- evaluate AJAX request
+                       // IE takes anchor as parameter
+               $PM = t3lib_div::_GP('PM');
+               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 && $PM[2] != 0) {
+                       if($PM[1])      {
+                               $expandedPageUid = $PM[2];
+                               $ajaxOutput = '';
+                               $invertedDepthOfAjaxRequestedItem = 0; // We don't know yet. Will be set later.
+                               $doExpand = true;
+                       } else  {
+                               $collapsedPageUid = $PM[2];
+                               $doCollapse = true;
+                       }
+               }
+
+               // we need to count the opened <ul>'s every time we dig into another level,
+               // so we know how many we have to close when all children are done rendering
+               $closeDepth = array();
+
+               foreach($treeArr as $k => $v)   {
+                       $classAttr = $v['row']['_CSSCLASS'];
+                       $uid       = $v['row']['uid'];
+                       $idAttr = htmlspecialchars($this->domIdPrefix.$this->getId($v['row']).'_'.$v['bank']);
+                       $itemHTML  = '';
+
+                       // 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 = '<ul>';
+                       }
+
+                       // add CSS classes to the list item
+                       if($v['hasSub']) { $classAttr .= ($classAttr) ? ' expanded': 'expanded'; }
+                       if($v['isLast']) { $classAttr .= ($classAttr) ? ' last' : 'last';        }
+
+                       $itemHTML .='
+                               <li id="'.$idAttr.'"'.($classAttr ? ' class="'.$classAttr.'"' : '').'><div class="treeLinkItem">'.
+                                       $v['HTML'].
+                                       $this->wrapTitle($this->getTitleStr($v['row'],$titleLen),$v['row'],$v['bank'])."</div>\n";
+
+
+                       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
+                       if($v['isLast'] && !($doExpand && $expandedPageUid == $uid)) { $closeDepth[$v['invertedDepth']] = 1; }
+
+
+                       // if this is the last one and does not have subitems, we need to close
+                       // the tree as long as the upper levels have last items too
+                       if($v['isLast'] && !$v['hasSub'] && !$doCollapse && !($doExpand && $expandedPageUid == $uid)) {
+                               for ($i = $v['invertedDepth']; $closeDepth[$i] == 1; $i++) {
+                                       $closeDepth[$i] = 0;
+                                       $itemHTML .= '</ul></li>';
+                               }
+                       }
+
+                       // ajax request: collapse
+                       if($doCollapse && $collapsedPageUid == $uid) {
+                               $this->ajaxStatus = true;
+                               return $itemHTML;
+                       }
+
+                       // ajax request: expand
+                       if($doExpand && $expandedPageUid == $uid) {
+                               $ajaxOutput .= $itemHTML;
+                               $invertedDepthOfAjaxRequestedItem = $v['invertedDepth'];
+                       } elseif($invertedDepthOfAjaxRequestedItem) {
+                               if($v['invertedDepth'] < $invertedDepthOfAjaxRequestedItem) {
+                                       $ajaxOutput .= $itemHTML;
+                               } else {
+                                       $this->ajaxStatus = true;
+                                       return $ajaxOutput;
+                               }
+                       }
+
+                       $out .= $itemHTML;
+               }
+
+               if($ajaxOutput) {
+                       $this->ajaxStatus = true;
+                       return $ajaxOutput;
+               }
+
+               // finally close the first ul
+               $out .= '</ul>';
+               return $out;
+       }
+
+
+       /**
+        * Generate the plus/minus icon for the browsable tree.
+        *
+        * @param       array           record for the entry
+        * @param       integer         The current entry number
+        * @param       integer         The total number of entries. If equal to $a, a "bottom" element is returned.
+        * @param       integer         The number of sub-elements to the current element.
+        * @param       boolean         The element was expanded to render subelements if this flag is set.
+        * @return      string          Image tag with the plus/minus icon.
+        * @access private
+        * @see t3lib_pageTree::PMicon()
+        */
+       function PMicon($row,$a,$c,$nextCount,$exp)     {
+               $PM   = $nextCount ? ($exp ? 'minus' : 'plus') : 'join';
+               $BTM  = ($a == $c) ? 'bottom' : '';
+               $icon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.$PM.$BTM.'.gif','width="18" height="16"').' alt="" />';
+
+               if ($nextCount) {
+                       $cmd = $this->bank.'_'.($exp?'0_':'1_').$row['uid'].'_'.$this->treeName;
+                       $icon = $this->PMiconATagWrap($icon,$cmd,!$exp);
+               }
+               return $icon;
+       }
+
+
+       /**
+        * Wrap the plus/minus icon in a link
+        *
+        * @param       string          HTML string to wrap, probably an image tag.
+        * @param       string          Command for 'PM' get var
+        * @return      string          Link-wrapped input string
+        * @access private
+        */
+       function PMiconATagWrap($icon, $cmd, $isExpand = true)  {
+               if ($this->thisScript) {
+                               // activate dynamic ajax-based tree
+                       $js = htmlspecialchars('Tree.load(\''.$cmd.'\', '.intval($isExpand).', this);');
+                       return '<a class="pm" onclick="'.$js.'">'.$icon.'</a>';
+               } else {
+                       return $icon;
+               }
+       }
+
+
+       /**
+        * Will create and return the HTML code for a browsable tree
+        * Is based on the mounts found in the internal array ->MOUNTS (set in the constructor)
+        *
+        * @return      string          HTML code for the browsable tree
+        */
+       function getBrowsableTree() {
+
+                       // Get stored tree structure AND updating it if needed according to incoming PM GET var.
+               $this->initializePositionSaving();
+
+                       // Init done:
+               $titleLen = intval($this->BE_USER->uc['titleLen']);
+               $treeArr = array();
+
+                       // Traverse mounts:
+               foreach($this->MOUNTS as $idx => $uid)  {
+
+                               // Set first:
+                       $this->bank = $idx;
+                       $isOpen = $this->stored[$idx][$uid] || $this->expandFirst || $uid === '0';
+
+                               // Save ids while resetting everything else.
+                       $curIds = $this->ids;
+                       $this->reset();
+                       $this->ids = $curIds;
+
+                               // Set PM icon for root of mount:
+                       $cmd = $this->bank.'_'.($isOpen? "0_" : "1_").$uid.'_'.$this->treeName;
+                               // 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)   {
+                               $rootRec = $this->getRecord($uid);
+                               $firstHtml.=$this->getIcon($rootRec);
+                       } else {
+                               // Artificial record for the tree root, id=0
+                               $rootRec = $this->getRootRecord($uid);
+                               $firstHtml.=$this->getRootIcon($rootRec);
+                       }
+
+                       if (is_array($rootRec)) {
+                                       // In case it was swapped inside getRecord due to workspaces.
+                               $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);
+
+                                       // If the mount is expanded, go down:
+                               if ($isOpen)    {
+                                               // Set depth:
+                                       if ($this->addSelfId) { $this->ids[] = $uid; }
+                                       $this->getTree($uid, 999, '', $rootRec['_SUBCSSCLASS']);
+                               }
+                                       // Add tree:
+                               $treeArr=array_merge($treeArr,$this->tree);
+                       }
+               }
+               return $this->printTree($treeArr);
+       }
+
+
+       /**
+        * Fetches the data for the tree
+        *
+        * @param       integer         item id for which to select subitems (parent id)
+        * @param       integer         Max depth (recursivity limit)
+        * @param       string          ? (internal)
+        * @return      integer         The count of items on the level
+        */
+       function getTree($uid, $depth=999, $blankLineCode='', $subCSSclass='') {
+
+                       // Buffer for id hierarchy is reset:
+               $this->buffer_idH = array();
+
+                       // Init vars
+               $depth = intval($depth);
+               $HTML = '';
+               $a = 0;
+
+               $res = $this->getDataInit($uid, $subCSSclass);
+               $c = $this->getDataCount($res);
+               $crazyRecursionLimiter = 999;
+
+               $inMenuPages = array();
+               $outOfMenuPages = array();
+               $outOfMenuPagesTextIndex = array();
+               while ($crazyRecursionLimiter > 0 && $row = $this->getDataNext($res,$subCSSclass))      {
+                       $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']))        {
+                               $outOfMenuPages[] = $row;
+                               $outOfMenuPagesTextIndex[] = ($row['doktype']>=200 ? 'zzz'.$row['doktype'].'_' : '').$row['title'];
+                       } else {
+                               $inMenuPages[] = $row;
+                       }
+               }
+
+               $label_shownAlphabetically = "";
+               if (count($outOfMenuPages))     {
+                               // Sort out-of-menu pages:
+                       $outOfMenuPages_alphabetic = array();
+                       if ($this->ext_alphasortNotinmenuPages) {
+                               asort($outOfMenuPagesTextIndex);
+                               $label_shownAlphabetically = " (alphabetic)";
+                       }
+                       foreach($outOfMenuPagesTextIndex as $idx => $txt)       {
+                               $outOfMenuPages_alphabetic[] = $outOfMenuPages[$idx];
+                       }
+
+                               // Merge:
+                       $outOfMenuPages_alphabetic[0]['_FIRST_NOT_IN_MENU']=TRUE;
+                       $allRows = array_merge($inMenuPages,$outOfMenuPages_alphabetic);
+               } else {
+                       $allRows = $inMenuPages;
+               }
+
+                       // Traverse the records:
+               foreach ($allRows as $row)      {
+                       $a++;
+
+                       $newID = $row['uid'];
+                       $this->tree[]=array();    // Reserve space.
+                       end($this->tree);
+                       $treeKey = key($this->tree);    // Get the key for this space
+                       $LN = ($a==$c) ? 'blank' : 'line';
+
+                               // If records should be accumulated, do so
+                       if ($this->setRecs) { $this->recs[$row['uid']] = $row; }
+
+                               // Accumulate the id of the element in the internal arrays
+                       $this->ids[]=$idH[$row['uid']]['uid'] = $row['uid'];
+                       $this->ids_hierarchy[$depth][] = $row['uid'];
+
+                               // Make a recursive call to the next level
+                       if ($depth > 1 && $this->expandNext($newID) && !$row['php_tree_stop'])  {
+                               $nextCount=$this->getTree(
+                                       $newID,
+                                       $depth-1,
+                                       $blankLineCode.','.$LN,
+                                       $row['_SUBCSSCLASS']
+                               );
+                               if (count($this->buffer_idH)) { $idH[$row['uid']]['subrow']=$this->buffer_idH; }
+                               $exp = 1; // Set "did expand" flag
+                       } else {
+                               $nextCount = $this->getCount($newID);
+                               $exp = 0; // Clear "did expand" flag
+                       }
+
+                               // Set HTML-icons, if any:
+                       if ($this->makeHTML)    {
+                               if ($row['_FIRST_NOT_IN_MENU']) {
+                                       $HTML = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/line.gif').' alt="" /><br/><img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/line.gif').' alt="" /><i>Not shown in menu'.$label_shownAlphabetically.':</i><br>';
+                               } else {
+                                       $HTML = '';
+                               }
+
+                               $HTML.= $this->PMicon($row,$a,$c,$nextCount,$exp);
+                               $HTML.= $this->wrapStop($this->getIcon($row),$row);
+                       }
+
+                               // Finally, add the row/HTML content to the ->tree array in the reserved key.
+                       $this->tree[$treeKey] = array(
+                               'row'    => $row,
+                               'HTML'   => $HTML,
+                               'hasSub' => $nextCount&&$this->expandNext($newID),
+                               'isFirst'=> $a==1,
+                               'isLast' => false,
+                               'invertedDepth'=> $depth,
+                               'blankLineCode'=> $blankLineCode,
+                               'bank' => $this->bank
+                       );
+               }
+
+               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