/**
 * Go to a assigned path, and send the array of file objects with JSON format to client.
 * @param unknown_type $path
 */
function gotoPath($path)
{
    setCurrentPath($path);
    $file = @scandir($path);
    $files = array();
    $dotPattern = '/^(\\.){1,2}$/i';
    $suffixPattern = '/^[^\\.]\\S*(?<=\\.)(\\S+)$|^\\.\\S+(?<=\\.)(\\S+)$/i';
    //Add all files in the current path to the array $files
    foreach ($file as $val) {
        if (!preg_match($dotPattern, $val)) {
            $fullName = $path . '/' . $val;
            $f = new file();
            $f->name = $val;
            $f->type = filetype($fullName);
            $f->fileSize = filesize($fullName);
            $f->accessTime = fileatime($fullName);
            $f->modifyTime = filemtime($fullName);
            $matches = array();
            preg_match($suffixPattern, $val, $matches);
            $f->suffix = @$matches[count($matches) - 1];
            unset($matches);
            $files[] = $f;
        }
    }
    //filters
    //Search filter
    $fk = getSearchKeyword();
    $caseInsensitive = 'true' == $fk[1] ? true : false;
    $files = filtrateFileNameByKeyword($files, $fk[0], $caseInsensitive);
    //Sort filter
    $sc = getSortCriteria();
    $asc = 'true' == $sc[1] ? true : false;
    sortFiles($files, $sc[0], $asc);
    //Suffix and invisible filter
    $f = getFilter();
    $invisible = 'true' == $f[1] ? true : false;
    if (!$invisible) {
        $files = filtrateHidden($files);
    }
    $files = filtrateSuffix($files, $f[0]);
    //Send the file list to the client
    echo json_encode($files);
}
    ?>
<div class="defaultWidth center clear-auto bodycontent bodycontent-index result-page ">
    <div class="contentbox">
    <!-- Nav tabs -->
            <div class="breadcrumbs" xmlns:v="http://rdf.data-vocabulary.org/#">
                <?php 
    if (function_exists('bcn_display')) {
        bcn_display();
    }
    ?>
            </div>
            <span class="search-results">
              
              <?php 
    echo 'Country: ';
    echo getSearchKeyword();
    ?>
 
              <?php 
    echo $query->post_count > 1 ? 'results' : 'result';
    ?>
 (<?php 
    echo $startpost . '-' . $endpost . ' of ' . $query->found_posts;
    ?>
 <?php 
    echo $query->post_count > 1 ? 'items' : 'item';
    ?>
):
            </span>

            <!-- Tab panes -->