Example #1
0
/**
 * viewdirtree()
 *
 * @param mixed $dir
 * @param mixed $currentpath
 * @return
 */
function viewdirtree($dir, $currentpath)
{
    global $array_dirname, $global_config, $module_file;
    $pattern = !empty($dir) ? '/^(' . nv_preg_quote($dir) . ')\\/([^\\/]+)$/' : '/^([^\\/]+)$/';
    $_dirlist = preg_grep($pattern, array_keys($array_dirname));
    $content = '';
    foreach ($_dirlist as $_dir) {
        $check_allow_upload_dir = nv_check_allow_upload_dir($_dir);
        if (!empty($check_allow_upload_dir)) {
            $class_li = ($_dir == $currentpath or strpos($currentpath, $_dir . '/') !== false) ? 'open collapsable' : 'expandable';
            $style_color = $_dir == $currentpath ? ' style="color:red"' : '';
            $tree = array();
            $tree['class1'] = $class_li;
            $tree['class2'] = nv_set_dir_class($check_allow_upload_dir) . ' pos' . nv_string_to_filename($dir);
            $tree['style'] = $style_color;
            $tree['title'] = $_dir;
            $tree['titlepath'] = basename($_dir);
            $content2 = viewdirtree($_dir, $currentpath);
            $xtpl = new XTemplate('foldlist.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file);
            $xtpl->assign('DIRTREE', $tree);
            if (empty($content2)) {
                $content2 = '<li class="hide">&nbsp;</li>';
            }
            if (!empty($content2)) {
                $xtpl->assign('TREE_CONTENT', $content2);
                $xtpl->parse('tree.tree_content');
            }
            $xtpl->parse('tree');
            $content .= $xtpl->text('tree');
        }
    }
    return $content;
}
Example #2
0
/**
 * viewdirtree()
 * 
 * @param mixed $dir
 * @param mixed $currentpath
 * @return
 */
function viewdirtree($dir, $currentpath)
{
    global $dirlist, $global_config, $module_file;
    $pattern = !empty($dir) ? "/^(" . nv_preg_quote($dir) . ")\\/([^\\/]+)\$/" : "/^([^\\/]+)\$/";
    $_dirlist = preg_grep($pattern, $dirlist);
    $content = "";
    foreach ($_dirlist as $_dir) {
        $check_allow_upload_dir = nv_check_allow_upload_dir($_dir);
        if (!empty($check_allow_upload_dir)) {
            $class_li = ($_dir == $currentpath or strpos($currentpath, $_dir . '/') !== false) ? "open collapsable" : "expandable";
            $style_color = $_dir == $currentpath ? ' style="color:red"' : '';
            $tree = array();
            $tree['class1'] = $class_li;
            $tree['class2'] = nv_set_dir_class($check_allow_upload_dir) . " pos" . nv_string_to_filename($dir);
            $tree['style'] = $style_color;
            $tree['title'] = $_dir;
            $tree['titlepath'] = basename($_dir);
            $content2 = viewdirtree($_dir, $currentpath);
            $xtpl = new XTemplate("foldlist.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file);
            $xtpl->assign("DIRTREE", $tree);
            if (!empty($content2)) {
                $xtpl->assign("TREE_CONTENT", $content2);
                $xtpl->parse('tree.tree_content');
            }
            $xtpl->parse('tree');
            $content .= $xtpl->text('tree');
        }
    }
    return $content;
}
}
$currentpath = htmlspecialchars(trim($nv_Request->get_string('currentpath', 'request', NV_UPLOADS_DIR)), ENT_QUOTES);
echo '<ul id="foldertree" class="filetree">';
echo '<li class="open collapsable"><span ' . ($path == $currentpath ? ' style="color:red"' : '') . ' class="folder" title="' . $path . '">&nbsp;' . $path . '</span>';
echo '<ul>';
$arr_files = @scandir(NV_ROOTDIR . '/' . $path);
foreach ($arr_files as $file) {
    $full_d = NV_ROOTDIR . '/' . $path . '/' . $file;
    if (is_dir($full_d) && !in_array($file, $array_hidefolders) && nv_check_allow_upload_dir($path . '/' . $file)) {
        if ($path . '/' . $file == $currentpath) {
            echo '<li class="open collapsable"><span style="color:red" class="folder" title="' . ($path . '/' . $file) . '">&nbsp;' . $file . '</span>';
        } else {
            echo '<li class="expandable"><span class="folder" title="' . ($path . '/' . $file) . '">&nbsp;' . $file . '</span>';
        }
        echo '<ul>';
        viewdirtree($path . '/' . $file, $currentpath);
        echo '</ul>';
        echo '</li>';
    }
}
echo '</ul>';
echo '</li>';
echo '</ul>';
echo '
<script type="text/javascript">
	$("#foldertree").treeview({
		collapsed: true,
		unique: true,
		persist: "location"
	});
    $("span.folder").contextMenu("folder-menu", {