Пример #1
0
//$root = null;
$root = REPOSITORY;
if (!$root) {
    exit("ERROR: Root filesystem directory not set in jqueryFileTree.php");
}
$postDir = rawurldecode($root . (isset($_POST['dir']) ? $_POST['dir'] : null));
// set checkbox if multiSelect set to true
$checkbox = isset($_POST['multiSelect']) && $_POST['multiSelect'] == 'true' ? "<input type='checkbox' />" : null;
$onlyFolders = isset($_POST['onlyFolders']) && $_POST['onlyFolders'] == 'true' ? true : false;
$onlyFiles = isset($_POST['onlyFiles']) && $_POST['onlyFiles'] == 'true' ? true : false;
if (file_exists($postDir)) {
    // get changed files
    $dir = $_POST['dir'];
    $repo = new GitRepository($postDir);
    $repoRoot = $repo->getRepositoryPath();
    $changedFiles = $repo->changedFilesByFileName('.');
    $files = preg_grep('/^([^.])/', scandir($postDir));
    $returnDir = substr($postDir, strlen($root));
    natcasesort($files);
    //if( count($files) > 2 ) { // The 2 accounts for . and ..
    echo "<ul class='jqueryFileTree'>";
    $dir_list = "";
    $file_list = "";
    foreach ($files as $file) {
        $htmlRel = htmlentities($returnDir . $file);
        $htmlName = htmlentities($file);
        $ext = preg_replace('/^.*\\./', '', $file);
        if (file_exists($postDir . $file) && $file != '.' && $file != '..') {
            if (is_dir($postDir . $file) && (!$onlyFiles || $onlyFolders)) {
                $dir_list .= "<li class='directory collapsed'>{$checkbox}<a rel='" . $htmlRel . "/'>" . $htmlName . "</a></li>";
            } else {