<?php if(!defined('master_script')) die();

/*
 * Changes for Pagemap:
 * Changed settings var $hidden_vars.
 * Added title attributes to LI.
 */

// SETTINGS

$root = '';
$hidden_files = $system_data['backend']['hidden files'];

if(!isset($root) || !isset($_GET['path'])) die();
$_GET['path'] = trim($_GET['path'], '/') . '/';

// LIST DIR

if(is_dir($root . $_GET['path'])) {
    $files = scandir($root . $_GET['path']);
    natcasesort($files);
    
    if(count($files) > 2) {
    	echo '<ul>';

    	// Dirs
    	foreach($files as $file) {
    		if(file_exists($root . $_GET['path'] . $file) && $file != '.' && $file != '..' && is_dir($root . $_GET['path'] . $file) && !in_array($file, $hidden_files)) {
				echo '<li title="' . txt('global', 'Klicken Sie, um die Dateigröße abzufragen') . '" class="dir closed"><a class="dir" rel="' . addslashes($_GET['path'] . $file) . '/" onclick="MoreCSS.filetree.loadNextFiletree(this.parentNode)">' . $file . '</a></li>';
    		}
    	}
    	
    	// Files
    	foreach( $files as $file ) {
    		if(file_exists($root . $_GET['path'] . $file) && $file != '.' && $file != '..' && !is_dir($root . $_GET['path'] . $file) && !in_array($file, $hidden_files)) {
    			$ext = preg_replace('/^.*\./', '', $file);
    			echo '<li title="' . txt('global', 'Klicken Sie, um die Dateigröße abzufragen') . '" class="file ' . strtolower($ext) . '"><a class="' . strtolower($ext) . '" rel="' . addslashes($_GET['path'] . $file) . '" onclick="MoreCSS.filetree.loadNextFiletree(this.parentNode)">' . $file . '</a></li>';
    		}
    	}
    	
    	echo '</ul>';
    }
}

?>