Fixed bug #14050: CleanUp - CGL format of t3lib files - t3lib_scbase
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_treeview.php
old mode 100755 (executable)
new mode 100644 (file)
index 0cb95e7..6e05fe5
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (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
  * Contains base class for creating a browsable array/page/folder tree in HTML
  *
  * $Id$
- * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
+ * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
- * @coauthor   René Fritz <r.fritz@colorcube.de>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
+ * @coauthor   René Fritz <r.fritz@colorcube.de>
  */
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
 
 
 
-require_once (PATH_t3lib.'class.t3lib_iconworks.php');
-require_once (PATH_t3lib.'class.t3lib_befunc.php');
-require_once (PATH_t3lib.'class.t3lib_div.php');
 
 
 /**
  * Base class for creating a browsable array/page/folder tree in HTML
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
- * @coauthor   René Fritz <r.fritz@colorcube.de>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
+ * @coauthor   René Fritz <r.fritz@colorcube.de>
  * @package TYPO3
  * @subpackage t3lib
  * @see t3lib_browsetree, t3lib_pagetree, t3lib_foldertree
@@ -537,7 +534,7 @@ class t3lib_treeView {
         * @return      string          Image tag, modified with $attr attributes added.
         */
        function addTagAttributes($icon,$attr)  {
-               return ereg_replace(' ?\/?>$','',$icon).' '.$attr.' />';
+               return preg_replace('/ ?\/?>$/','',$icon).' '.$attr.' />';
        }
 
        /**
@@ -550,7 +547,7 @@ class t3lib_treeView {
         */
        function wrapStop($str,$row)    {
                if ($row['php_tree_stop'])      {
-                       $str.='<span class="typo3-red">+ </span>';
+                       $str .= '<span class="typo3-red"><a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => $row['uid']))) . '" class="typo3-red">+</a> </span>';
                }
                return $str;
        }
@@ -643,7 +640,7 @@ class t3lib_treeView {
         * @return      string          Icon image tag.
         */
        function getRootIcon($rec) {
-               return $this->wrapIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_website.gif','width="18" height="16"').' alt="" />',$rec);
+               return $this->wrapIcon(t3lib_iconWorks::getSpriteIcon('apps-pagetree-root'),$rec);
        }
 
 
@@ -659,7 +656,12 @@ class t3lib_treeView {
                if ($this->iconPath && $this->iconName) {
                        $icon = '<img'.t3lib_iconWorks::skinImg('',$this->iconPath.$this->iconName,'width="18" height="16"').' alt=""'.($this->showDefaultTitleAttribute ? ' title="UID: '.$row['uid'].'"':'').' />';
                } else {
-                       $icon = t3lib_iconWorks::getIconImage($this->table,$row,$this->backPath,'align="top" class="c-recIcon"'.($this->showDefaultTitleAttribute ? ' title="UID: '.$row['uid'].'"':''));
+
+                       $icon = t3lib_iconWorks::getSpriteIconForRecord($this->table, $row, array(
+                               'title' => ($this->showDefaultTitleAttribute ? 'UID: ' . $row['uid'] : $this->getTitleAttrib($row)),
+                               'class' => 'c-recIcon'
+                       ));
+
                }
 
                return $this->wrapIcon($icon,$row);
@@ -763,6 +765,8 @@ class t3lib_treeView {
                $c = $this->getDataCount($res);
                $crazyRecursionLimiter = 999;
 
+               $idH = array();
+
                        // Traverse the records:
                while ($crazyRecursionLimiter>0 && $row = $this->getDataNext($res,$subCSSclass))        {
                        $a++;
@@ -770,9 +774,8 @@ class t3lib_treeView {
 
                        $newID = $row['uid'];
 
-                       if ($newID==0)  {
-                               t3lib_BEfunc::typo3PrintError ('Endless recursion detected', 'TYPO3 has detected an error in the database. Please fix it manually (e.g. using phpMyAdmin) and change the UID of '.$this->table.':0 to a new value.<br /><br />See <a href="http://bugs.typo3.org/view.php?id=3495" target="_blank">bugs.typo3.org/view.php?id=3495</a> to get more information about a possible cause.',0);
-                               exit;
+                       if ($newID == 0) {
+                               throw new RuntimeException('Endless recursion detected: TYPO3 has detected an error in the database. Please fix it manually (e.g. using phpMyAdmin) and change the UID of '.$this->table.':0 to a new value.<br /><br />See <a href="http://bugs.typo3.org/view.php?id=3495" target="_blank">bugs.typo3.org/view.php?id=3495</a> to get more information about a possible cause.');
                        }
 
                        $this->tree[]=array();          // Reserve space.
@@ -860,16 +863,14 @@ class t3lib_treeView {
                        $res = $this->getDataInit($uid);
                        return $this->getDataCount($res);
                } else {
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                                               'count(*)',
-                                               $this->table,
-                                               $this->parentField.'='.$GLOBALS['TYPO3_DB']->fullQuoteStr($uid, $this->table).
-                                                       t3lib_BEfunc::deleteClause($this->table).
-                                                       t3lib_BEfunc::versioningPlaceholderClause($this->table).
-                                                       $this->clause   // whereClauseMightContainGroupOrderBy
-                                       );
-                       $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
-                       return $row[0];
+                       return $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                               'uid',
+                               $this->table,
+                               $this->parentField . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($uid, $this->table) .
+                                       t3lib_BEfunc::deleteClause($this->table) .
+                                       t3lib_BEfunc::versioningPlaceholderClause($this->table) .
+                                       $this->clause   // whereClauseMightContainGroupOrderBy
+                       );
                }
        }