IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 30, 2012, 10:04:15 AM (14 years ago)
Author:
eugene
Message:

merge from eam/20120905

Location:
trunk/dvodist
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/dvodist

    • Property svn:ignore set to
      Makefile
  • trunk/dvodist/www-util/ipp.php

    r33986 r34748  
    11<?php
    22
    3 global $realroot;
    4 $realroot = "/dvodist";
     3global $rootdir;
    54
    65function head ($title) {
     
    3433}
    3534
     35// generate the menu based on the text file
    3636function menulines ($source, $root, $append, $project) {
    3737
     
    4343    if (count($line) < 2) continue;
    4444
     45    // allow load of other menu files
    4546    if (count($line) == 2) {
    4647      $value = trim($line[0]);
     
    5152      continue;
    5253    }
     54
     55    // blithly skip lines with invalid entries
    5356    if (count($line) != 5) continue;
    5457
     
    7376    }
    7477
    75     global $realroot;
     78    global $rootdir;
    7679
    7780    // hi-lite the current page (use select-style, not style)
    7881    $thisname = $_SERVER[SCRIPT_NAME];
    79     $page = $realroot . $base;
     82    $page = $rootdir . $base;
    8083    if ($page == $thisname) {
    8184      $style = trim($line[1]);
     
    117120
    118121function dirlist ($source) {
     122  if (!file_exists($source)) return;
     123
    119124  $file = fopen ($source, "r");
    120125  echo "<table class=\"dirlist\">\n";
     
    135140    // }
    136141
    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    }
    143164
    144165    switch ($type) {
     
    158179}
    159180
     181function 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
    160228function verbatim ($source) {
     229  if (!file_exists($source)) return;
     230
    161231  $file = fopen ($source, "r");
    162232
     
    165235  // loop over the lines in the file and generate lines in the menu
    166236  while ($line = fgets ($file, 1024)) {
     237    echo "line: $line<br>\n";
    167238    if (strlen($line) < 2) {
    168239      if (!$addbreak) {
     
    176247    $addbreak = 0;
    177248  }
     249  fclose ($file);
     250}
     251
     252// lines which start with @ are processed by 'dirlist', all others are processed by Markdown
     253function 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  }
    178295  fclose ($file);
    179296}
Note: See TracChangeset for help on using the changeset viewer.