Fixed bug #11937: Do not show E_DEPRECATED messages on productive systems
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_arraybrowser.php
index 796b8e1..cb6dbe9 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
  *
  *
  *   77: class t3lib_arrayBrowser
- *   94:     function tree($arr, $depth_in, $depthData)
- *  155:     function wrapValue($theValue,$depth)
- *  167:     function wrapArrayKey($label,$depth,$theValue)
- *  191:     function getSearchKeys($keyArr, $depth_in, $searchString, $keyArray)
- *  223:     function fixed_lgd($string,$chars)
- *  240:     function depthKeys($arr,$settings)
+ *   96:     function tree($arr, $depth_in, $depthData)
+ *  160:     function wrapValue($theValue,$depth)
+ *  172:     function wrapArrayKey($label,$depth,$theValue)
+ *  196:     function getSearchKeys($keyArr, $depth_in, $searchString, $keyArray)
+ *  228:     function fixed_lgd($string,$chars)
+ *  245:     function depthKeys($arr,$settings)
  *
  * TOTAL FUNCTIONS: 6
  * (This index is automatically created/updated by the extension "extdeveval")
  * @see SC_mod_tools_config_index::main()
  */
 class t3lib_arrayBrowser       {
+       var $expAll = FALSE;                    // If set, will expand all (depthKeys is obsolete then) (and no links are applied)
+       var $dontLinkVar = FALSE;               // If set, the variable keys are not linked.
        var $depthKeys = array();               // Array defining which keys to expand. Typically set from outside from some session variable - otherwise the array will collapse.
        var $searchKeys = array();              // After calling the getSearchKeys function this array is populated with the key-positions in the array which contains values matching the search.
        var $fixedLgd=1;                                // If set, the values are truncated with "..." appended if longer than a certain length.
        var $regexMode=0;                               // If set, search for string with regex, otherwise stristr()
+       var $searchKeysToo=FALSE;               // If set, array keys are subject to the search too.
        var $varName='';                                // Set var name here if you want links to the variable name.
 
        /**
@@ -104,7 +107,7 @@ class t3lib_arrayBrowser    {
                        $depth = $depth_in.$key;
                        $goto = substr(md5($depth),0,6);
 
-                       $deeper = (is_array($arr[$key]) && $this->depthKeys[$depth]) ? 1 : 0;
+                       $deeper = (is_array($arr[$key]) && ($this->depthKeys[$depth] || $this->expAll)) ? 1 : 0;
                        $PM = 'join';
                        $LN = ($a==$c)?'blank':'line';
                        $BTM = ($a==$c)?'bottom':'';
@@ -116,7 +119,10 @@ class t3lib_arrayBrowser   {
                        if ($PM=='join')        {
                                $HTML.=$theIcon;
                        } else {
-                               $HTML.='<a name="'.$goto.'" href="'.htmlspecialchars('index.php?node['.$depth.']='.($deeper?0:1).'#'.$goto).'">'.$theIcon.'</a>';
+                               $HTML.=
+                                       ($this->expAll ? '' : '<a name="'.$goto.'" href="'.htmlspecialchars('index.php?node['.$depth.']='.($deeper?0:1).'#'.$goto).'">').
+                                       $theIcon.
+                                       ($this->expAll ? '' : '</a>');
                        }
 
                        $label = $key;
@@ -131,7 +137,7 @@ class t3lib_arrayBrowser    {
                                        $theValue = $this->fixed_lgd($theValue,$lgdChars);
                                }
                                if ($this->searchKeys[$depth])  {
-                                       $HTML.='=<span style="color:red;">'.$this->wrapValue($theValue,$depth).'</font>';
+                                       $HTML.='=<span style="color:red;">'.$this->wrapValue($theValue,$depth).'</span>';
                                } else {
                                        $HTML.='='.$this->wrapValue($theValue,$depth);
                                }
@@ -170,7 +176,7 @@ class t3lib_arrayBrowser    {
                $label = htmlspecialchars($label);
 
                        // If varname is set:
-               if ($this->varName) {
+               if ($this->varName && !$this->dontLinkVar) {
                        $variableName = $this->varName.'[\''.str_replace('.','\'][\'',$depth).'\'] = '.(!t3lib_div::testInt($theValue) ? '\''.addslashes($theValue).'\'' : $theValue).'; ';
                        $label = '<a href="'.htmlspecialchars('index.php?varname='.$variableName.'#varname').'">'.$label.'</a>';
                }
@@ -197,9 +203,9 @@ class t3lib_arrayBrowser    {
                        $deeper = is_array($keyArr[$key]);
 
                        if ($this->regexMode)   {
-                               if (ereg($searchString,$keyArr[$key]))  {       $this->searchKeys[$depth]=1;    }
+                               if (preg_match('/'.$searchString.'/',$keyArr[$key]) || ($this->searchKeysToo && preg_match('/'.$searchString.'/',$key)))        {       $this->searchKeys[$depth]=1;    }
                        } else {
-                               if (stristr($keyArr[$key],$searchString)      {       $this->searchKeys[$depth]=1;    }
+                               if (stristr($keyArr[$key],$searchString) || ($this->searchKeysToo && stristr($key,$searchString)))      {       $this->searchKeys[$depth]=1;    }
                        }
 
                        if ($deeper)    {