Added feature #13953: Hookrequest - t3lib_page::getRecordOverlay (thanks to Tolleiv...
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_arraybrowser.php
index 01f32be..998b5eb 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
@@ -81,6 +81,7 @@ class t3lib_arrayBrowser      {
        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 +105,7 @@ class t3lib_arrayBrowser    {
                while (list($key,)=each($arr))  {
                        $a++;
                        $depth = $depth_in.$key;
-                       $goto = substr(md5($depth),0,6);
+                       $goto = 'a' . substr(md5($depth), 0, 6);
 
                        $deeper = (is_array($arr[$key]) && ($this->depthKeys[$depth] || $this->expAll)) ? 1 : 0;
                        $PM = 'join';
@@ -119,7 +120,7 @@ class t3lib_arrayBrowser    {
                                $HTML.=$theIcon;
                        } else {
                                $HTML.=
-                                       ($this->expAll ? '' : '<a name="'.$goto.'" href="'.htmlspecialchars('index.php?node['.$depth.']='.($deeper?0:1).'#'.$goto).'">').
+                                       ($this->expAll ? '' : '<a id="' . $goto . '" href="' . htmlspecialchars('index.php?node[' . $depth . ']=' . ($deeper ? 0 : 1) . '#' . $goto) . '">') .
                                        $theIcon.
                                        ($this->expAll ? '' : '</a>');
                        }
@@ -136,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);
                                }
@@ -158,7 +159,11 @@ class t3lib_arrayBrowser   {
         * @return      string          Title string, htmlspecialchars()'ed
         */
        function wrapValue($theValue,$depth)    {
-               return '<b>'.htmlspecialchars($theValue).'</b>';
+               $wrappedValue = '';
+               if (strlen($theValue) > 0) {
+                       $wrappedValue = '<b>' . htmlspecialchars($theValue) . '</b>';
+               }
+               return $wrappedValue;
        }
 
        /**
@@ -177,7 +182,7 @@ class t3lib_arrayBrowser    {
                        // If varname is set:
                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>';
+                       $label = '<a href="index.php?varname=' . urlencode($variableName) . '#varname">' . $label . '</a>';
                }
 
                        // Return:
@@ -202,9 +207,11 @@ 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 ((!$deeper && stristr($keyArr[$key], $searchString)) || ($this->searchKeysToo && stristr($key, $searchString))) {
+                                       $this->searchKeys[$depth] = 1;
+                               }
                        }
 
                        if ($deeper)    {