- $indent_array[$parent] = 0;
-
- /* now the children, checking each thread portion for
- ),(, and space, adjusting the level and space values
- to get the indent level
- */
- $level = 0;
- $spaces = array();
- $spaces_total = 0;
- $indent = 0;
- $fake = FALSE;
- for ($k=1;$k<(count($thread_new[$i]))-1;$k++) {
- $chars = count_chars($thread_new[$i][$k], 1);
- if (isset($chars['40'])) { /* testing for ( */
- $level = $level + $chars['40'];
- }
- if (isset($chars['41'])) { /* testing for ) */
- $level = $level - $chars['41'];
- $spaces[$level] = 0;
- /* if we were faking lets stop, this portion
- of the thread is over
- */
- if ($level == $cutoff) {
- $fake = FALSE;
- }
- }
- if (isset($chars['32'])) { /* testing for space */
- if (!isset($spaces[$level])) {
- $spaces[$level] = 0;
- }
- $spaces[$level] = $spaces[$level] + $chars['32'];
- }
- for ($x=0;$x<=$level;$x++) {
- if (isset($spaces[$x])) {
- $spaces_total = $spaces_total + $spaces[$x];
- }
- }
- $indent = $level + $spaces_total;
- /* must have run into a message that broke the thread
- so we are adjusting for that portion
- */
- if ($fake == TRUE) {
- $indent = $indent +1;
- }
- if (preg_match("/(\d+)/", $thread_new[$i][$k], $regs)) {
- $child = $regs[1];
- }
- /* the thread must be broken if $indent == 0
- so indent the message once and start faking it
- */
- if ($indent == 0) {
- $indent = 1;
- $fake = TRUE;
- $cutoff = $level;
- }
- /* dont need abs but if indent was negative
- errors would occur
- */
- $indent_array[$child] = abs($indent);
- $spaces_total = 0;