root/components/contents.php @ 88

Revision 88, 1.1 KB (checked in by dez, 7 years ago)

Updates to library component
contents component now works

Line 
1<?php
2
3function listdir($path, $recurse) {
4    $dirlist = scandir($path);
5    $output = array();
6    foreach($dirlist as $file) {
7        if ($file!="." && $file!="..") {
8            if (!is_dir($path."/".$file)) {
9                $foo = ereg_replace("\.txt", "", $file);
10                if ($foo!=@$lastdir) $output[$foo]=$foo;
11               
12            } else {
13                if ($recurse) $output[$file]=listdir($path."/".$file);
14                else $output[$file]=$file;
15                $lastdir=$file;
16            }
17        }
18    }
19    return $output;
20}
21
22if ($path==$component['path']) {
23
24
25    $dirlist = listdir("static".$component['path'], TRUE);
26
27    $smarty->assign('rootnode', $component['path']);
28    $smarty->assign('dirlist', $dirlist);
29    $output = $smarty->fetch('contents.tpl');
30    $smarty->assign('title', $pathlist[1]);
31    $smarty->assign('body', $output);
32} else {
33    include("static.php");
34    $dirlist = listdir("static".$path, FALSE);
35    $smarty->assign('rootnode', $path);
36print_r($dirlist);
37    $smarty->assign('data', $dirlist);
38    $smarty->assign('level', 0);
39    $output = $smarty->fetch('contents-loop.tpl');
40
41
42    $smarty->assign("secondary", "<div class=\"cbb\"><h3>In this section</h3>".$output."</div>");
43}
44?>
Note: See TracBrowser for help on using the browser.