コード例 #1
0
function blog_publish_months()
{
    $tree = dir_rscandir("{$GLOBALS['smarty']->template_dir}/.posts", false);
    $list = dir_flatten($tree);
    $li = array();
    foreach ($list[2] as $m) {
        $li[] = "\t<li><a href=\"{$m}\">" . substr($m, 1) . "</a></li>\n";
    }
    file_put_contents("{$GLOBALS['smarty']->template_dir}/.months.html", "<ul id=\"months\">\n" . implode("", $li) . "</ul>\n", LOCK_EX);
}
コード例 #2
0
ファイル: lib_dir.php プロジェクト: rcrowley/bashpress
function dir_flatten($tree, $path = "", $depth = 1)
{
    $list = array();
    foreach ($tree as $dir => $subtree) {
        $list[$depth][] = "{$path}/{$dir}";
        if ($subtree) {
            $sublist = dir_flatten($subtree, "{$path}/{$dir}", $depth + 1);
            foreach ($sublist as $d => $l) {
                if (!is_array($list[$d])) {
                    $list[$d] = array();
                }
                $list[$d] = array_merge($list[$d], $l);
            }
        }
    }
    return $list;
}