00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 class t3lib_arrayBrowser {
00078 var $expAll = FALSE;
00079 var $dontLinkVar = FALSE;
00080 var $depthKeys = array();
00081 var $searchKeys = array();
00082 var $fixedLgd=1;
00083 var $regexMode=0;
00084 var $searchKeysToo=FALSE;
00085 var $varName='';
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 function tree($arr, $depth_in, $depthData) {
00098 $HTML='';
00099 $a=0;
00100
00101 if ($depth_in) {$depth_in = $depth_in.'.';}
00102
00103 $c=count($arr);
00104 reset($arr);
00105 while (list($key,)=each($arr)) {
00106 $a++;
00107 $depth = $depth_in.$key;
00108 $goto = substr(md5($depth),0,6);
00109
00110 $deeper = (is_array($arr[$key]) && ($this->depthKeys[$depth] || $this->expAll)) ? 1 : 0;
00111 $PM = 'join';
00112 $LN = ($a==$c)?'blank':'line';
00113 $BTM = ($a==$c)?'bottom':'';
00114 $PM = is_array($arr[$key]) ? ($deeper ? 'minus':'plus') : 'join';
00115
00116
00117 $HTML.=$depthData;
00118 $theIcon='<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/ol/'.$PM.$BTM.'.gif','width="18" height="16"').' align="top" border="0" alt="" />';
00119 if ($PM=='join') {
00120 $HTML.=$theIcon;
00121 } else {
00122 $HTML.=
00123 ($this->expAll ? '' : '<a name="'.$goto.'" href="'.htmlspecialchars('index.php?node['.$depth.']='.($deeper?0:1).'#'.$goto).'">').
00124 $theIcon.
00125 ($this->expAll ? '' : '</a>');
00126 }
00127
00128 $label = $key;
00129 $HTML.= $this->wrapArrayKey($label,$depth,!is_array($arr[$key]) ? $arr[$key] : '');
00130
00131 if (!is_array($arr[$key])) {
00132 $theValue = $arr[$key];
00133 if ($this->fixedLgd) {
00134 $imgBlocks = ceil(1+strlen($depthData)/77);
00135
00136 $lgdChars = 68-ceil(strlen('['.$key.']')*0.8)-$imgBlocks*3;
00137 $theValue = $this->fixed_lgd($theValue,$lgdChars);
00138 }
00139 if ($this->searchKeys[$depth]) {
00140 $HTML.='=<span style="color:red;">'.$this->wrapValue($theValue,$depth).'</span>';
00141 } else {
00142 $HTML.='='.$this->wrapValue($theValue,$depth);
00143 }
00144 }
00145 $HTML.='<br />';
00146
00147 if ($deeper) {
00148 $HTML.=$this->tree($arr[$key], $depth, $depthData.'<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/ol/'.$LN.'.gif','width="18" height="16"').' align="top" alt="" />');
00149 }
00150 }
00151 return $HTML;
00152 }
00153
00154
00155
00156
00157
00158
00159
00160
00161 function wrapValue($theValue,$depth) {
00162 return '<b>'.htmlspecialchars($theValue).'</b>';
00163 }
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 function wrapArrayKey($label,$depth,$theValue) {
00174
00175
00176 $label = htmlspecialchars($label);
00177
00178
00179 if ($this->varName && !$this->dontLinkVar) {
00180 $variableName = $this->varName.'[\''.str_replace('.','\'][\'',$depth).'\'] = '.(!t3lib_div::testInt($theValue) ? '\''.addslashes($theValue).'\'' : $theValue).'; ';
00181 $label = '<a href="'.htmlspecialchars('index.php?varname='.$variableName.'#varname').'">'.$label.'</a>';
00182 }
00183
00184
00185 return '['.$label.']';
00186 }
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197 function getSearchKeys($keyArr, $depth_in, $searchString, $keyArray) {
00198 reset($keyArr);
00199 $c=count($keyArr);
00200 if ($depth_in) {$depth_in = $depth_in.'.';}
00201 while (list($key,)=each($keyArr)) {
00202 $depth=$depth_in.$key;
00203 $deeper = is_array($keyArr[$key]);
00204
00205 if ($this->regexMode) {
00206 if (ereg($searchString,$keyArr[$key]) || ($this->searchKeysToo && ereg($searchString,$key))) { $this->searchKeys[$depth]=1; }
00207 } else {
00208 if (stristr($keyArr[$key],$searchString) || ($this->searchKeysToo && stristr($key,$searchString))) { $this->searchKeys[$depth]=1; }
00209 }
00210
00211 if ($deeper) {
00212 $cS = count($this->searchKeys);
00213 $keyArray = $this->getSearchKeys($keyArr[$key], $depth, $searchString, $keyArray);
00214 if ($cS != count($this->searchKeys)) {
00215 $keyArray[$depth]=1;
00216 }
00217 }
00218 }
00219 return $keyArray;
00220 }
00221
00222
00223
00224
00225
00226
00227
00228
00229 function fixed_lgd($string,$chars) {
00230 if ($chars >= 4) {
00231 if(strlen($string)>$chars) {
00232 return substr($string, 0, $chars-3).'...';
00233 }
00234 }
00235 return $string;
00236 }
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246 function depthKeys($arr,$settings) {
00247 $tsbrArray=array();
00248 reset($arr);
00249 while(list($theK,$theV)=each($arr)) {
00250 $theKeyParts = explode('.',$theK);
00251 $depth='';
00252 $c=count($theKeyParts);
00253 $a=0;
00254 while(list(,$p)=each($theKeyParts)) {
00255 $a++;
00256 $depth.=($depth?'.':'').$p;
00257 $tsbrArray[$depth]= ($c==$a) ? $theV : 1;
00258 }
00259 }
00260
00261 reset($tsbrArray);
00262 while(list($theK,$theV)=each($tsbrArray)) {
00263 if ($theV) {
00264 $settings[$theK] = 1;
00265 } else {
00266 unset($settings[$theK]);
00267 }
00268 }
00269 return $settings;
00270 }
00271 }
00272
00273 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_arraybrowser.php']) {
00274 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_arraybrowser.php']);
00275 }
00276 ?>