/** * Context is an array with these keys: * isExpanded an array of absolute dir names mapped to booleans */ function display($context) { echo $this->pageHeader("View & download files", "files"); $list = listRecursive($_SESSION['dataDir']); $list = sortFilesAlpha($list); $this->displayDownloadForm($list, $context['isExpanded']); echo $this->pageFooter(); }
function displayAllFiles($context) { echo "<h5 class='welcome'>Popular Downloads (<a href='" . makeEventURL('onCall', 'file_browser.php') . "'>all downloads</a>)</h5>\n"; echo "<div class='indent'>\n"; $list = listRecursive($_SESSION['dataDir']); unset($list[MP_DIR_SYSTEM]); unset($list[MP_DIR_WORK]); unset($list[MP_DIR_RAWDATA]); $list = sortFilesAlpha($list); $this->displayDownloadForm($list, $context['isExpanded']); echo "</div>\n"; // end indent }
/** * The original $list is not modified. * Directories and files are sorted separately -- directories always come first. */ function sortFilesAlpha($list) { $d = array(); // dirs $f = array(); // files foreach ($list as $key => $val) { if (is_array($val)) { $d[$key] = sortFilesAlpha($val); } else { $f[$key] = $val; } } ksort($d); ksort($f); return array_merge($d, $f); // This version mixes files and directories /*foreach($list as $el) { if(is_array($el)) $el = sortFilesAlpha($el); } ksort($list); return $list;*/ }