Changeset 34748 for trunk/dvodist/www-util/ipp.php
- Timestamp:
- Nov 30, 2012, 10:04:15 AM (14 years ago)
- Location:
- trunk/dvodist
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
www-util/ipp.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dvodist
-
Property svn:ignore
set to
Makefile
-
Property svn:ignore
set to
-
trunk/dvodist/www-util/ipp.php
r33986 r34748 1 1 <?php 2 2 3 global $realroot; 4 $realroot = "/dvodist"; 3 global $rootdir; 5 4 6 5 function head ($title) { … … 34 33 } 35 34 35 // generate the menu based on the text file 36 36 function menulines ($source, $root, $append, $project) { 37 37 … … 43 43 if (count($line) < 2) continue; 44 44 45 // allow load of other menu files 45 46 if (count($line) == 2) { 46 47 $value = trim($line[0]); … … 51 52 continue; 52 53 } 54 55 // blithly skip lines with invalid entries 53 56 if (count($line) != 5) continue; 54 57 … … 73 76 } 74 77 75 global $r ealroot;78 global $rootdir; 76 79 77 80 // hi-lite the current page (use select-style, not style) 78 81 $thisname = $_SERVER[SCRIPT_NAME]; 79 $page = $r ealroot. $base;82 $page = $rootdir . $base; 80 83 if ($page == $thisname) { 81 84 $style = trim($line[1]); … … 117 120 118 121 function dirlist ($source) { 122 if (!file_exists($source)) return; 123 119 124 $file = fopen ($source, "r"); 120 125 echo "<table class=\"dirlist\">\n"; … … 135 140 // } 136 141 137 if (count($line) != 4) continue; 138 139 $name = trim($line[0]); 140 $type = trim($line[1]); 141 $style = trim($line[2]); 142 $info = trim($line[3]); 142 if ((count($line) != 4) && (count($line) != 5)) continue; 143 144 // support both the old and new style tables: 145 // old: name | type | style | info 146 // new: name | link | type | style | info 147 148 if (count($line) == 4) { 149 echo "count = 4<br>\n"; 150 $name = trim($line[0]); 151 $type = trim($line[1]); 152 $style = trim($line[2]); 153 $info = trim($line[3]); 154 $link = $name; 155 } 156 if (count($line) == 5) { 157 echo "count = 5<br>\n"; 158 $name = trim($line[0]); 159 $link = trim($line[1]); 160 $type = trim($line[2]); 161 $style = trim($line[3]); 162 $info = trim($line[4]); 163 } 143 164 144 165 switch ($type) { … … 158 179 } 159 180 181 function parse_dirlist ($input) { 182 echo "<table class=\"dirlist\">\n"; 183 184 $inlist = explode ("\n", $input); 185 $Ninlist = count($inlist); 186 for ($i = 0; $i < $Ninlist; $i++) { 187 $inline = trim ($inlist[$i], "@ \t"); 188 $line = explode (":", $inline); 189 if (ereg ('^[:blank:]*#', $line[0])) continue; 190 if (count($line) < 2) continue; 191 192 if ((count($line) != 4) && (count($line) != 5)) continue; 193 194 // support both the old and new style tables: 195 // old: name | type | style | info 196 // new: name | link | type | style | info 197 198 if (count($line) == 4) { 199 $name = trim($line[0]); 200 $type = trim($line[1]); 201 $style = trim($line[2]); 202 $info = trim($line[3]); 203 $link = $name; 204 } 205 if (count($line) == 5) { 206 $name = trim($line[0]); 207 $link = trim($line[1]); 208 $type = trim($line[2]); 209 $style = trim($line[3]); 210 $info = trim($line[4]); 211 } 212 213 switch ($type) { 214 case 'plain': 215 echo "<tr class=\"$style\"><td>$name</td><td>$info</td></tr>\n"; 216 break; 217 case 'dir': 218 echo "<tr class=\"$style\"><td><a class=\"$style\" href=\"$name\">$name</a></td><td>$info</td></tr>\n"; 219 break; 220 default: 221 echo "<tr class=\"$style\"><td><a class=\"$style\" href=\"$name\">$name</a></td><td>$info</td></tr>\n"; 222 break; 223 } 224 } 225 echo "</table>\n"; 226 } 227 160 228 function verbatim ($source) { 229 if (!file_exists($source)) return; 230 161 231 $file = fopen ($source, "r"); 162 232 … … 165 235 // loop over the lines in the file and generate lines in the menu 166 236 while ($line = fgets ($file, 1024)) { 237 echo "line: $line<br>\n"; 167 238 if (strlen($line) < 2) { 168 239 if (!$addbreak) { … … 176 247 $addbreak = 0; 177 248 } 249 fclose ($file); 250 } 251 252 // lines which start with @ are processed by 'dirlist', all others are processed by Markdown 253 function do_markdown ($source) { 254 if (!file_exists($source)) return; 255 256 $file = fopen ($source, "r"); 257 258 // loop over the lines in the file and generate lines in the menu 259 $to_markdwn = ""; 260 $to_dirlist = ""; 261 while ($line = fgets ($file, 1024)) { 262 // echo "line: $line"; 263 if (!strncmp($line, "@", 1)) { 264 if ($to_markdwn) { 265 // echo "<b> start markdown</b><br>\n"; 266 $my_html = Markdown($to_markdwn); 267 echo "$my_html"; 268 $to_markdwn = ""; 269 } 270 $to_dirlist .= $line; 271 } else { 272 if ($to_dirlist) { 273 // echo "<b> start dirlist</b><br>\n"; 274 parse_dirlist($to_dirlist); 275 $to_dirlist = ""; 276 } 277 $to_markdwn .= $line; 278 } 279 } 280 // echo "end of lines<br>\n"; 281 // echo "to_markdwn: $to_markdwn\n"; 282 // echo "<br>\n"; 283 // echo "to_dirlist: $to_dirlist\n"; 284 // echo "<br>\n"; 285 286 if ($to_markdwn) { 287 $my_html = Markdown($to_markdwn); 288 echo "$my_html"; 289 $to_markdwn = ""; 290 } 291 if ($to_dirlist) { 292 parse_dirlist($to_dirlist); 293 $to_dirlist = ""; 294 } 178 295 fclose ($file); 179 296 }
Note:
See TracChangeset
for help on using the changeset viewer.
