- Timestamp:
- Oct 24, 2012, 11:08:11 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20120905/dvodist/www-util/ipp.php
r34543 r34551 34 34 } 35 35 36 // generate the menu based on the text file 36 37 function menulines ($source, $root, $append, $project) { 37 38 … … 43 44 if (count($line) < 2) continue; 44 45 46 // allow load of other menu files 45 47 if (count($line) == 2) { 46 48 $value = trim($line[0]); … … 51 53 continue; 52 54 } 55 56 // blithly skip lines with invalid entries 53 57 if (count($line) != 5) continue; 54 58 … … 158 162 } 159 163 164 function parse_dirlist ($input) { 165 echo "<table class=\"dirlist\">\n"; 166 167 $inlist = explode ("\n", $input); 168 $Ninlist = count($inlist); 169 for ($i = 0; $i < $Ninlist; $i++) { 170 $inline = trim ($inlist[$i], "@ \t"); 171 $line = explode (":", $inline); 172 if (ereg ('^[:blank:]*#', $line[0])) continue; 173 if (count($line) < 2) continue; 174 if (count($line) != 4) continue; 175 176 $name = trim($line[0]); 177 $type = trim($line[1]); 178 $style = trim($line[2]); 179 $info = trim($line[3]); 180 181 switch ($type) { 182 case 'plain': 183 echo "<tr class=\"$style\"><td>$name</td><td>$info</td></tr>\n"; 184 break; 185 case 'dir': 186 echo "<tr class=\"$style\"><td><a class=\"$style\" href=\"$name\">$name</a></td><td>$info</td></tr>\n"; 187 break; 188 default: 189 echo "<tr class=\"$style\"><td><a class=\"$style\" href=\"$name\">$name</a></td><td>$info</td></tr>\n"; 190 break; 191 } 192 } 193 echo "</table>\n"; 194 } 195 160 196 function verbatim ($source) { 161 197 $file = fopen ($source, "r"); … … 180 216 } 181 217 218 // lines which start with @ are processed by 'dirlist', all others are processed by Markdown 182 219 function do_markdown ($source) { 183 220 $file = fopen ($source, "r"); 184 221 185 222 // loop over the lines in the file and generate lines in the menu 186 $ascii = ""; 223 $to_markdwn = ""; 224 $to_dirlist = ""; 187 225 while ($line = fgets ($file, 1024)) { 188 $ascii .= $line; 189 } 190 fclose ($file); 191 $my_html = Markdown($ascii); 192 echo "$my_html"; 226 // echo "line: $line"; 227 if (!strncmp($line, "@", 1)) { 228 if ($to_markdwn) { 229 // echo "<b> start markdown</b><br>\n"; 230 $my_html = Markdown($to_markdwn); 231 echo "$my_html"; 232 $to_markdwn = ""; 233 } 234 $to_dirlist .= $line; 235 } else { 236 if ($to_dirlist) { 237 // echo "<b> start dirlist</b><br>\n"; 238 parse_dirlist($to_dirlist); 239 $to_dirlist = ""; 240 } 241 $to_markdwn .= $line; 242 } 243 } 244 // echo "end of lines<br>\n"; 245 // echo "to_markdwn: $to_markdwn\n"; 246 // echo "<br>\n"; 247 // echo "to_dirlist: $to_dirlist\n"; 248 // echo "<br>\n"; 249 250 if ($to_markdwn) { 251 $my_html = Markdown($to_markdwn); 252 echo "$my_html"; 253 $to_markdwn = ""; 254 } 255 if ($to_dirlist) { 256 parse_dirlist($to_dirlist); 257 $to_dirlist = ""; 258 } 259 fclose ($file); 193 260 } 194 261
Note:
See TracChangeset
for help on using the changeset viewer.
