You are here

function imce_create_tree in IMCE 6.2

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

Create directory tree.

1 call to imce_create_tree()
imce_content in inc/imce.page.inc
Returns the content of the file browser.

File

inc/imce.page.inc, line 1046
Implements the file browser.

Code

function imce_create_tree(&$imce) {
  $paths = array();

  //rearrange paths as arg0=>arg1=>...
  foreach ($imce['directories'] as $path => $arr) {
    $tmp =& $paths;
    if ($path != '.') {
      $args = explode('/', $path);
      foreach ($args as $arg) {
        if (!isset($tmp[$arg])) {
          $tmp[$arg] = array();
        }
        $tmp =& $tmp[$arg];
      }
      $tmp[':access:'] = TRUE;
    }
    if ("{$path}" == $imce['dir']) {
      $tmp[':active:'] = TRUE;
      foreach ($imce['subdirectories'] as $arg) {
        $tmp[$arg][':access:'] = TRUE;
      }
    }
  }

  //set root branch
  $root = theme('imce_root_text', array(
    'imce' => &$imce,
  ));
  $q = $imce['clean'] ? '?' : '&';
  if (isset($imce['directories']['.'])) {
    $root = '<a href="' . $imce['url'] . $q . 'dir=." title="." class="folder' . ($imce['dir'] == '.' ? ' active' : '') . '">' . $root . '</a>';
  }
  else {
    $root = '<a title="." class="folder disabled">' . $root . '</a>';
  }
  return $root . imce_tree_html($imce, $paths, $q);
}