You are here

function comment_delete_threading_values in Comment Delete 7

Converts threaded comments into associative array of thread strings.

Parameters

array $tree: Associtiave array containing comment threading tree.

string $prefix: Prefix to be prepended to thread strings.

array $threading: Associative array of existing thread strings.

Return value

array Accociative array of comment thread strings.

1 call to comment_delete_threading_values()
comment_delete_threading in ./comment_delete.module
Re-threads comments attached to an entity.

File

./comment_delete.module, line 385
comment_delete.module

Code

function comment_delete_threading_values(array $tree, $prefix = '', array $threading = array(), $init = TRUE) {
  $thread = $init ? '01' : '00';
  uasort($tree, 'comment_delete_threading_sort');
  foreach ($tree as $comment) {
    $string = (!empty($prefix) ? $prefix . '.' : '') . int2vancode(sprintf('%02d', $thread++));
    $threading[$comment['cid']] = $string;
    if (isset($comment['children'])) {
      $children = $comment['children'];
      uasort($children, 'comment_delete_threading_sort');
      $child_threading = comment_delete_threading_values($children, $string, $threading, FALSE);
      $threading += $child_threading;
    }
  }
  return $threading;
}