Index: phpdoc/make_chm.php diff -u phpdoc/make_chm.php:1.14 phpdoc/make_chm.php:1.15 --- phpdoc/make_chm.php:1.14 Mon Sep 3 12:30:37 2001 +++ phpdoc/make_chm.php Sat Sep 8 11:17:25 2001 @@ -13,19 +13,17 @@ $original_index = getenv("PHP_HELP_COMPILE_INDEX"); // header for index and toc -$header = ' - - - - - - - - +$header = ' + + + + + + + - -
    - '; +
+

    '; MakeProjectFile(); MakeContentFiles(); @@ -43,8 +41,8 @@ $index = fopen("php_manual_$language.hhk", "w"); // Write out file headers - fputs ($toc, $header); - fputs ($index, $header); + fputs($toc, $header); + fputs($index, $header); // Read original index file and drop out newlines $index_a = file("$fancydir/$original_index"); @@ -52,7 +50,7 @@ $ijoin = preg_replace("/[\r|\n]{1,2}/", " ", $ijoin); // Print out the objects, autoparsing won't find - SiteMapObj($manual_title, $indexfile, " ", $toc, 21); + SiteMapObj($manual_title, $indexfile, " ", $toc, 21); IndexObj($manual_title, $indexfile, $index); // Find the name of the Table of Contents @@ -61,7 +59,7 @@ if (empty($match[1])) { // Fallback $match[1] = "Table of Contents"; } - SiteMapObj($match[1], $original_index, " ", $toc, 21); + SiteMapObj($match[1], $original_index, " ", $toc, 21); IndexObj($match[1], $original_index, $index); } @@ -70,18 +68,18 @@ if (empty($match[1])) { // Fallback $match[1] = "Preface"; } - SiteMapObj($match[1], "preface.html", " ", $toc); + SiteMapObj($match[1], "preface.html", " ", $toc); IndexObj($match[1], "preface.html", $index); // Find the name of the Preface/About this Manual - fputs($toc, "\n
      "); + fputs($toc, "\n
        "); preg_match('|(.*)|U', $ijoin, $match); if (empty($match[1])) { // Fallback $match[1]="About this Manual"; } - SiteMapObj($match[1], "preface.html#about", " ", $toc); + SiteMapObj($match[1], "preface.html#about", " ", $toc); IndexObj($match[1], "preface.html#about", $index); - fputs($toc, "
      \n"); + fputs($toc, "
    \n"); // Now autofind the chapters/subchapters $not_closed = 0; @@ -93,7 +91,7 @@ $new_list = 1; if ($not_closed == 1) { - fputs($toc, "\n
\n"); + fputs($toc, "\n \n"); } //preg_match ("/>([IVX]+)\. ([^<]+)/", $index_a[$i+2], $matches); $chapter["title"] = $matches[1]; - SiteMapObj($chapter["title"], $chapter["html"], " ", $toc); + SiteMapObj($chapter["title"], $chapter["html"], " ", $toc); IndexObj($chapter["title"], $chapter["html"], $index); } @@ -112,7 +110,7 @@ if ($new_list == 1) { $new_list = 0; $not_closed = 1; - fputs($toc, "\n \n"); // Link in directly the copyright page $cjoin = join("", file("$fancydir/copyright.html")); @@ -137,12 +135,12 @@ if (empty($match[1])) { // fallback $match[1] = "Copyright"; } - SiteMapObj($match[1], "copyright.html", " ", $toc, 17); + SiteMapObj($match[1], "copyright.html", " ", $toc, 17); IndexObj($match[1], "copyright.html", $index); // Write out closing line, and end files - fputs($index, "\n"); - fputs($toc, "\n"); + fputs($index, " \n\n"); + fputs($toc, " \n\n"); fclose($index); fclose($toc); @@ -225,14 +223,16 @@ global $fancydir; $name = str_replace('"', '"', $name); - fputs($toc, "\n$tabs
  • - $tabs - $tabs "); + fputs($toc, " +$tabs
  • +$tabs +$tabs +"); if ($imgnum != "auto") { - fputs($toc, "\n$tabs "); + fputs($toc, "$tabs \n"); } - fputs($toc, "\n$tabs \n"); + fputs($toc, "$tabs
  • \n"); } // SiteMapObj() function end // Print out an object for an Index file @@ -241,41 +241,47 @@ global $fancydir; $name = str_replace('"', '"', $name); - fputs($index, "\n
  • + fputs($index, " +
  • -
  • "); +
  • +"); } // Process a file, and find any links need to be presented in tree function DoFile ($filename, $toc, $index) { global $fancydir; - fputs($toc, "
      "); $content = file ("$fancydir/$filename"); - for ($i = 0; $i < count ($content); $i++) { - if (ereg (">([^<]+)/", $content[$i+5], $matches); - } elseif($content[$i+2] == $content[$i+4]) { - preg_match ("/>([^<]+)/", $content[$i+7], $matches); - } else { - preg_match ("/>([^<]+)/", $content[$i+3], $matches); + $contents = preg_replace("/[\n|\r]/", " ", join("", $content)); + + // Find all sublinks + if (preg_match_all("!(.+)!U", $contents, $matches, PREG_SET_ORDER)) { + + // Print out the file informations for all the links + fputs($toc, "
        "); + foreach ($matches as $onematch) { + $param["html"] = $onematch[1]; + if (!empty($onematch[3])) { + $param["html"] .= $onematch[3]; } - $param["title"] = $matches[1]; + $param["title"] = strip_tags($onematch[4]); SiteMapObj($param["title"], $param["html"], " ", $toc); IndexObj($param["title"], $param["html"], $index); } - } - fputs($toc, "
      \n"); + fputs($toc, "
    \n"); + + } else { + + // Uncomment this if you want to debug the above pregs + // Note: there are many files normally without deeper + // TOC info, eg. language.expressions.html + + // echo "no deeper TOC info found in $filename\n"; + // return; + + } + } // DoFile() function end ?>