1<?php 2// Selects images based on namespace 3function dyn_img_sel($type,$name) { 4 $dir = "./lib/tpl/vu/images/$type/"; 5 $ext = array(1 => ".jpg",2 => ".gif",3 => ".png"); 6 $nc = 1; 7 $file = ""; 8 $img = ""; 9 //Loops for 3 file types and lists if file exists and shows image if it exists. 10 while ($nc <= 3 ) { 11 $file = $dir.$name.$ext[$nc]; 12 $fullimg = trim("./".$file); 13 if (is_file($fullimg)) { break; }; 14 $nc++; 15 clearstatcache(); 16 } 17 $img = $file; 18 $test = trim("./".$img); 19 if (is_file($test)) { 20 } else { 21 $img = $dir."start.gif"; 22 }; 23 switch($type) { 24 case "home": 25 echo "<a href='", DOKU_URL,"doku.php?id=$name'><img class='upperleft' src='$img' /></a>"; 26 break; 27 case "banners": 28 echo "<img class='banner' src='$img' />"; 29 break; 30 } 31} 32// Builds the dynamic links based on the namespaces. 33function dyn_links($ns) { 34 $check = "./data/pages/".$ns; 35 if (is_dir($check)) { 36 $root = $ns; 37 $ns = "/".$ns; 38 } else { 39 $ns = ""; 40 }; 41 $first = "="; 42 $dir = "./data/pages$ns"; 43 $titleref = ""; 44 $titlearr = array(); 45 $ac = 1; 46 if ($handle = opendir($dir)) { 47 while (false !== ($lfile = readdir($handle))) { 48 Switch ($lfile) { 49 case ".": 50 break; 51 case "..": 52 break; 53 case "start.txt": 54 break; 55 case "sidebar.txt": 56 break; 57 default: 58 if (is_dir($dir."/".$lfile)) { 59 break; 60 } else { 61 $ext = strpos($lfile, "."); 62 $fh = fopen($dir."/".$lfile, 'r'); 63 $fr = fread($fh, filesize($dir."/".$lfile)); 64 $begstr = strpos($fr, $first, 0); 65 $begstr = $begstr + 6; 66 $count = strpos($fr, $first, $begstr); 67 $count = $count - $begstr; 68 $title = substr($fr, $begstr, $count); 69 $titleref[$ac] = substr($lfile, 0, $ext); 70 $titlearr[$ac] = $title; 71 $ac++; 72 } 73 } 74 } 75 closedir($handle); 76 if ($ns == "") { 77 echo "<a class='nav' href='doku.php?id=start'>Home</a>"; 78 } else { 79 echo "<a class='nav' href='doku.php?id=start'>Home</a>"; 80 $ssns = stripslashes($root); 81 $uns = strtoupper($ssns); 82 echo "<a class='nav' href='doku.php?id=$ssns'>$uns</a>"; 83 }; 84 for($lc = 1; $lc < $ac; $lc++) { 85 if (isset($root)) { 86 echo "<a class='nav' href='doku.php?id=$root:$titleref[$lc]'>$titlearr[$lc]</a>"; 87 } else { 88 echo "<a class='nav' href='doku.php?id=$titleref[$lc]'>$titlearr[$lc]</a>"; 89 }; 90 } 91 } 92} 93 94?>