function imce_create_tree in IMCE 6
Same name and namespace in other branches
- 6.2 inc/imce.page.inc \imce_create_tree()
- 7 inc/imce.page.inc \imce_create_tree()
Create directory tree.
1 call to imce_create_tree()
- imce_content in inc/
page.inc - Content of the file browser.
File
- inc/
page.inc, line 944
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 = variable_get('file_downloads', '') == FILE_DOWNLOADS_PRIVATE && !user_access('administer imce(execute PHP)') ? t('Directory root') : file_directory_path();
$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);
}