Index: t3lib/class.t3lib_arraybrowser.php =================================================================== --- t3lib/class.t3lib_arraybrowser.php (revision 8742) +++ t3lib/class.t3lib_arraybrowser.php (revision ) @@ -1,29 +1,29 @@ Configuration') @@ -74,15 +61,15 @@ * @subpackage t3lib * @see SC_mod_tools_config_index::main() */ -class t3lib_arrayBrowser { +class t3lib_arrayBrowser { - var $expAll = FALSE; // If set, will expand all (depthKeys is obsolete then) (and no links are applied) + 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 $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 $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 $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 $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 $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 $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. + var $varName = ''; // Set var name here if you want links to the variable name. /** * Make browsable tree @@ -94,57 +81,63 @@ * @return string HTML for the tree * @see SC_mod_tools_config_index::main() */ - function tree($arr, $depth_in, $depthData) { + function tree($arr, $depth_in, $depthData) { - $HTML=''; + $HTML = ''; - $a=0; + $a = 0; - if ($depth_in) {$depth_in = $depth_in.'.';} + if ($depth_in) { + $depth_in = $depth_in . '.'; + } - $c=count($arr); + $c = count($arr); foreach ($arr as $key => $value) { $a++; - $depth = $depth_in.$key; + $depth = $depth_in . $key; $goto = 'a' . substr(md5($depth), 0, 6); $deeper = (is_array($arr[$key]) && ($this->depthKeys[$depth] || $this->expAll)) ? 1 : 0; $PM = 'join'; - $LN = ($a==$c)?'blank':'line'; + $LN = ($a == $c) ? 'blank' : 'line'; - $BTM = ($a==$c)?'bottom':''; + $BTM = ($a == $c) ? 'bottom' : ''; - $PM = is_array($arr[$key]) ? ($deeper ? 'minus':'plus') : 'join'; + $PM = is_array($arr[$key]) ? ($deeper ? 'minus' : 'plus') : 'join'; - $HTML.=$depthData; + $HTML .= $depthData; - $theIcon=''; + $theIcon = ''; - if ($PM=='join') { + if ($PM == 'join') { - $HTML.=$theIcon; + $HTML .= $theIcon; } else { - $HTML.= + $HTML .= - ($this->expAll ? '' : '') . + ($this->expAll ? '' : '') . - $theIcon. + $theIcon . - ($this->expAll ? '' : ''); + ($this->expAll ? '' : ''); } $label = $key; - $HTML.= $this->wrapArrayKey($label,$depth,!is_array($arr[$key]) ? $arr[$key] : ''); + $HTML .= $this->wrapArrayKey($label, $depth, !is_array($arr[$key]) ? $arr[$key] : ''); - if (!is_array($arr[$key])) { + if (!is_array($arr[$key])) { $theValue = $arr[$key]; - if ($this->fixedLgd) { + if ($this->fixedLgd) { - $imgBlocks = ceil(1+strlen($depthData)/77); + $imgBlocks = ceil(1 + strlen($depthData) / 77); -// debug($imgBlocks); + // debug($imgBlocks); - $lgdChars = 68-ceil(strlen('['.$key.']')*0.8)-$imgBlocks*3; + $lgdChars = 68 - ceil(strlen('[' . $key . ']') * 0.8) - $imgBlocks * 3; - $theValue = $this->fixed_lgd($theValue,$lgdChars); + $theValue = $this->fixed_lgd($theValue, $lgdChars); } - if ($this->searchKeys[$depth]) { + if ($this->searchKeys[$depth]) { - $HTML.='='.$this->wrapValue($theValue,$depth).''; + $HTML .= '=' . $this->wrapValue($theValue, $depth) . ''; } else { - $HTML.='='.$this->wrapValue($theValue,$depth); + $HTML .= '=' . $this->wrapValue($theValue, $depth); } } - $HTML.='
'; + $HTML .= '
'; - if ($deeper) { + if ($deeper) { - $HTML.=$this->tree($arr[$key], $depth, $depthData.''); + $HTML .= $this->tree($arr[$key], $depth, $depthData . ''); } } return $HTML; @@ -157,7 +150,7 @@ * @param string Depth path * @return string Title string, htmlspecialchars()'ed */ - function wrapValue($theValue,$depth) { + function wrapValue($theValue, $depth) { $wrappedValue = ''; if (strlen($theValue) > 0) { $wrappedValue = '' . htmlspecialchars($theValue) . ''; @@ -173,19 +166,20 @@ * @param string The value for the array entry. * @return string Title string, htmlspecialchars()'ed */ - function wrapArrayKey($label,$depth,$theValue) { + function wrapArrayKey($label, $depth, $theValue) { // Protect label: $label = htmlspecialchars($label); // If varname is set: if ($this->varName && !$this->dontLinkVar) { - $variableName = $this->varName.'[\''.str_replace('.','\'][\'',$depth).'\'] = '.(!t3lib_div::testInt($theValue) ? '\''.addslashes($theValue).'\'' : $theValue).'; '; + $variableName = $this->varName . '[\'' . str_replace('.', '\'][\'', $depth) . '\'] = ' . + (!t3lib_div::testInt($theValue) ? '\'' . addslashes($theValue) . '\'' : $theValue) . '; '; $label = '' . $label . ''; } // Return: - return '['.$label.']'; + return '[' . $label . ']'; } /** @@ -197,26 +191,30 @@ * @param array Key array, for first call pass empty array * @return array */ - function getSearchKeys($keyArr, $depth_in, $searchString, $keyArray) { + function getSearchKeys($keyArr, $depth_in, $searchString, $keyArray) { - $c=count($keyArr); + $c = count($keyArr); - if ($depth_in) {$depth_in = $depth_in.'.';} + if ($depth_in) { + $depth_in = $depth_in . '.'; + } foreach ($keyArr as $key => $value) { - $depth=$depth_in.$key; + $depth = $depth_in . $key; $deeper = is_array($keyArr[$key]); - if ($this->regexMode) { + if ($this->regexMode) { - if (preg_match('/'.$searchString.'/',$keyArr[$key]) || ($this->searchKeysToo && preg_match('/'.$searchString.'/',$key))) { $this->searchKeys[$depth]=1; } + if (preg_match('/' . $searchString . '/', $keyArr[$key]) || ($this->searchKeysToo && preg_match('/' . $searchString . '/', $key))) { + $this->searchKeys[$depth] = 1; + } } else { if ((!$deeper && stristr($keyArr[$key], $searchString)) || ($this->searchKeysToo && stristr($key, $searchString))) { $this->searchKeys[$depth] = 1; } } - if ($deeper) { + if ($deeper) { $cS = count($this->searchKeys); $keyArray = $this->getSearchKeys($keyArr[$key], $depth, $searchString, $keyArray); - if ($cS != count($this->searchKeys)) { + if ($cS != count($this->searchKeys)) { - $keyArray[$depth]=1; + $keyArray[$depth] = 1; } } } @@ -230,10 +228,10 @@ * @param integer Max number of chars * @return string Processed string */ - function fixed_lgd($string,$chars) { + function fixed_lgd($string, $chars) { - if ($chars >= 4) { + if ($chars >= 4) { - if(strlen($string)>$chars) { + if (strlen($string) > $chars) { - return substr($string, 0, $chars-3).'...'; + return substr($string, 0, $chars - 3) . '...'; } } return $string; @@ -247,22 +245,22 @@ * @return array Output depth_key array with entries added/removed based on $arr * @see SC_mod_tools_config_index::main() */ - function depthKeys($arr,$settings) { + function depthKeys($arr, $settings) { - $tsbrArray=array(); + $tsbrArray = array(); foreach ($arr as $theK => $theV) { - $theKeyParts = explode('.',$theK); + $theKeyParts = explode('.', $theK); - $depth=''; + $depth = ''; - $c=count($theKeyParts); + $c = count($theKeyParts); - $a=0; + $a = 0; foreach ($theKeyParts as $p) { $a++; - $depth.=($depth?'.':'').$p; + $depth .= ($depth ? '.' : '') . $p; - $tsbrArray[$depth]= ($c==$a) ? $theV : 1; + $tsbrArray[$depth] = ($c == $a) ? $theV : 1; } } // Modify settings foreach ($tsbrArray as $theK => $theV) { - if ($theV) { + if ($theV) { $settings[$theK] = 1; } else { unset($settings[$theK]); @@ -272,7 +270,7 @@ } } -if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_arraybrowser.php']) { +if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_arraybrowser.php']) { include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_arraybrowser.php']); } ?> \ No newline at end of file