function listContent($dir, $uri) { $html = "<ul>\n"; if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if (interestingFile($file, $bla)) { //link content if (is_dir($dir . '/' . $file)) { $html .= '<a class="dir" href="' . $uri . $file . '/">' . $file . "</a>\n"; } else { $html .= "<li>" . guessLink($dir . '/' . $file, $uri . $file) . "</li>\n"; } } } } $html .= "</ul>\n"; return $html; }
function getFileList($dir, $searchRegexp) { $allFiles = array(); if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if (interestingFile($file, $searchRegexp)) { if (!is_dir($dir . $file)) { array_push($allFiles, $file); } } } } closedir($dh); return $allFiles; }
function listProjects($path, $dir, $uri) { #$html.= "LIST PROJECTS : $path, $dir, $uri <br/>\n "; if (isset($dir) && $dir == "") { $html = '<div id="projects">'; } else { $html = "<div>"; } if (isset($dir) && $dir != "") { if ($dir == "drafts/") { $html .= '<a href="' . $uri . '" class="title">' . $dir . "</a><ul>\n"; } else { $html .= '<a href="' . $uri . '" class="title">' . $dir . '</a>' . "\n"; } } #print "should be trying to open : ".$path.$dir."<br/>"; if ($dh = opendir($path . $dir)) { //$html.= "opened directory : ".$path.$dir." <br/>"; while (($file = readdir($dh)) !== false) { if (interestingFile($file, $searchRegexp)) { if (is_dir($path . $dir . $file)) { if (file_exists($path . $dir . $file . "/" . $file . BLURB)) { $html .= printBlurb($path . $dir . $file . "/" . $file . BLURB, $file, $uri . $file . '/'); } else { $html .= listProjects($path . $dir, $file . '/', $uri . $file . '/'); } } else { if ($dir == "drafts/") { //Surely it is draft ??? $html .= "<li>" . guessDraftLinkList($path . $dir, $file, $uri) . "</li>\n"; } } } } closedir($dh); } else { $html .= "could not open this file : [" . $path . $dir . "]<br/>"; } if ($dir == "drafts/") { $html .= "</ul>\n"; } $html .= "</div>\n"; return $html; }