You are here

function imce_tree_html in IMCE 6

Same name and namespace in other branches
  1. 6.2 inc/imce.page.inc \imce_tree_html()
  2. 7 inc/imce.page.inc \imce_tree_html()

Return tree html. This is not themable because it is complex and needs to be in a proper format for js processing.

1 call to imce_tree_html()
imce_create_tree in inc/page.inc
Create directory tree.

File

inc/page.inc, line 983

Code

function imce_tree_html(&$imce, $paths, $q = '?', $prefix = '', $eprefix = '') {
  unset($paths[':access:'], $paths[':active:']);
  $html = '';
  foreach ($paths as $arg => $children) {
    $path = $prefix . $arg;
    $earg = rawurlencode($arg);
    $epath = $eprefix . $earg;
    if (isset($children[':access:']) || imce_directory_info($path, $imce)) {
      $a = '<a href="' . $imce['url'] . $q . 'dir=' . $epath . '" title="' . $epath . '" class="folder' . (isset($children[':active:']) ? ' active' : '') . '">' . $earg . '</a>';
    }
    else {
      $a = '<a title="' . $epath . '" class="folder disabled">' . $earg . '</a>';
    }
    $ul = imce_tree_html($imce, $children, $q, $path . '/', $epath . '/');
    $html .= '<li class="' . ($ul ? 'expanded' : (isset($children[':active:']) ? 'leaf' : '')) . '">' . $a . $ul . '</li>';
  }
  if ($html) {
    $html = '<ul>' . $html . '</ul>';
  }
  return $html;
}