goba Sun Jan 14 05:59:12 2001 EDT Added files: /phpdoc make_chm.README make_chm_fancy.php Log: Introducing the fancy version Now we need a .README to know what to do in several cases... Derick please go through these and test the fancy method. I hope you will be happy to see it :))
Index: phpdoc/make_chm.README +++ phpdoc/make_chm.README This is a README file about building the manual in Windows Help File (.chm) format. This README is written by Gabor Hojtsy ([EMAIL PROTECTED]). Contact him, or the phpdoc list if you have any questions or suggestions... Note: Where 'lang' is mentioned in this doc, it is the actual language code of the manual you are compiling, not the 'lang' word itself! ======================================================================= You have two options to build the .chm manual: a) Use only the traditional DSSSL made html manual b) Use a fancy html manual (converted from the DSSSL made html) In both cases you need Microsoft(r) HTML Help Workshop. You can download it freely at: http://msdn.microsoft.com/library/tools/htmlhelp/chm/hh1start.htm You need the complete workshop package install (about 4 Megs). Of cource you need one Microsoft(r) Windows to run that software. Now you need the html manual. You have two alternatives: a) Donwload the actual html manual from http://snaps.php.net/manual/lang/ and untar the distribution in a directory a) Build the html manual yourself using Jade and the other tools needed (how to do it is not in the scope of this README) ======================================================================= You need the .chm manual generator files (from cvs.php.net): make_chm.bat - The only file you need to run yourself. make_chm.php - Auto toc generator. To make the fancy manual additional files needed: make_chm_fancy.php - Convert the normal html files to good looking pages and correct some pages (manual.html, copyright.html) make_chm_index_lang.html - Fancy index. I recommend you to use a fancy index in the language of the actual compiled maunal (look into phpdoc/lang dir if it exists). make_chm_spc.gif - Gif file needed by the fancy pages. make_chm_style.css - This adds some good style to html files. Note that you NEED make_chm.php and make_chm.bat to make the fancy manual too!!!!! Now put the above listed make_chm_* files to one directory. Put the html manual (~1700 files) under a subdir in this directory (eg. html). You need to decide what method to use (normal or fancy). The output .chm file for the tested Hungarian version were nearly in the same size, the fancy manual .chm took 30k more space. This is not significant, as the .chm files are ~1.5Megs in size. ======================================================================= To make manual_lang.chm using the normal HTML pages: Open make_chm.bat in a text editor and make the appropriate modifications. You need to - set PHP_HELP_COMPILER to the full path of hhc.exe on your machine (including hhc.exe). - set PHP_HELP_COMPILE_LANG to the language code of the actual manual (use the code from cvs.php.net, eg. hu) - set PHP_HELP_COMPILE_DIR to the directory of the html manual (eg. html) - substitute D:\progra~1\php402\php.exe with your php.exe path (including php.exe) Now the batch file is ready to run. To compile the normal manual, use the 'normal' command line option (without quotes): make_chm.bat normal It will generate manual_lang.hhp, manual_lang.hhc, index.hhk and compile.bat in the same directory, and call compile.bat to finalize the process and compile manual_lang.chm ======================================================================= To make manual_lang.chm using the fancy style: See make_chm_fancy.bat and make all the modifications described above at make_chm.bat. Note, that you need to substitute the php.exe path in two places in this batch file!!! One more thing you need to set here is the PHP_HELP_COMPILE_FANCYDIR environment variable, which is the container for the directory name where the fancy pages will go. You can decide not to sacrifice any more space for the fancy dir (it takes up 55 megs on my FAT16 system), and set this variable to the same as PHP_HELP_COMPILE_DIR. Then your old HTML files will be rewritten to be fancy ones. In any case make sure that the directory named in PHP_HELP_COMPILE_FANCYDIR exists. I pesonally used "fancy" as the value of this variable (without quotes). Now the batch file is ready to run. To compile the fancy manual, do not add any command line options, run: make_chm.bat It will generate the fancy pages in the directory you specified, copy in the fancy dir the make_chm_index_lang.html as index.html, make_chm_spc.gif as spacer.gif and make_chm_style.css as style.css A date subtitution takes place when copying index.html (the actual date will be printed inside the file), and some more modifications are made to manual.html and copyright.html. After that the same process is done as described above with normal pages. After this process, you will have manual_lang.chm in your language... ======================================================================= Index: phpdoc/make_chm_fancy.php +++ phpdoc/make_chm_fancy.php <?php set_time_limit(0); $htmldir = getenv("PHP_HELP_COMPILE_DIR"); $fancydir = getenv("PHP_HELP_COMPILE_FANCYDIR"); $language = getenv("PHP_HELP_COMPILE_LANG"); $counter = 0; $handle=opendir($htmldir); while (false!==($filename = readdir($handle))) { if (strpos($filename, ".html") && ($filename != "index.html")) { fancy_design($filename); } } closedir($handle); // make GENTIME the actual date/time $content = join("", file("make_chm_index_$language.html")); $content = preg_replace("/\\[GENTIME\\]/", date("D M d H:i:s Y"), $content); $fp = fopen("$fancydir/index.html", "w"); fputs($fp, $content); fclose($fp); copy("make_chm_style.css", "$fancydir/style.css"); copy("make_chm_spc.gif", "$fancydir/spacer.gif"); $counter += 3; echo "Converting ready...\n"; echo "Total number of files written in $fancydir directory: $counter\n\n"; function fancy_design($fname) { global $htmldir, $fancydir, $counter; // get the contents of the file from $htmldir $content = join("", file("$htmldir/$fname")); // css file linking $content = preg_replace("|</HEAD|", '<LINK REL="stylesheet" HREF="style.css"></HEAD', $content); // no margins around $content = preg_replace("/<BODY/", '<BODY TOPMARGIN="0" LEFTMARGIN="0"', $content); // HR dropout $content = preg_replace("/<HR\\s+ALIGN=\"LEFT\"\\s+WIDTH=\"100%\">/", '', $content); // whole page table and backgrounds $wpbegin = '<TABLE BORDER="0" WIDTH="100%" HEIGHT="100%" CELLSPACING="0" CELLPADDING="0"><TR><TD COLSPAN="3">'; $bnavt = '<TABLE BGCOLOR="#CCCCFF" BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%">'; $lnavt = '<TR BGCOLOR="#333366"><TD><IMG SRC="spacer.gif" BORDER="0" WIDTH="1" HEIGHT="1"><BR></TD></TR>'; $space = '<IMG SRC="spacer.gif" WIDTH="10" HEIGHT="1">'; // navheader backgound $content = preg_replace("/<DIV\\s+CLASS=\"NAVHEADER\"\\s+><TABLE(.*)CELLPADDING=\"0\"(.*)<\\/TABLE\\s+><\\/DIV\\s+>/Us", $wpbegin . '<DIV CLASS="NAVHEADER">' . $bnavt . '<TR><TD><TABLE\\1CELLPADDING="3"\\2</TABLE></TD></TR>' . $lnavt . '</TABLE></DIV></TD></TR><TR><TD>' . $space . '</TD><TD HEIGHT="100%" VALIGN="TOP" WIDTH="100%"><BR>', $content); // navfooter backgound $content = preg_replace("/<DIV\\s+CLASS=\"NAVFOOTER\"\\s+><TABLE(.*)CELLPADDING=\"0\"(.*)<\\/TABLE\\s+><\\/DIV\\s+>/Us", '<BR></TD><TD>' . $space . '</TD></TR><TR><TD COLSPAN="3"><DIV CLASS="NAVFOOTER">' . $bnavt . $lnavt . '<TR><TD><TABLE\\1CELLPADDING="3"\\2</TABLE></TD></TR></TABLE></DIV></TD></TR></TABLE>', $content); // fix copyright page fault... if ($fname == "copyright.html") { $content = preg_replace("/&copy;/", "©", $content); $content = preg_replace("/<A\\s+HREF=\"manual.html(.*)\"/U", "<A HREF=\"index.html\"", $content); $content = preg_replace("|(</TH\\s+></TR\\s+>)|", "\\1<TR><TH COLSPAN=\"3\" ALIGN=\"center\"> </TH></TR>", $content); $content = preg_replace("|( </TD\\s+></TR\\s+>)|", "\\1<TR><TD COLSPAN=\"3\" ALIGN=\"center\"> </TD></TR>", $content); } // fix manual.html to look far better... elseif ($fname == "manual.html") { $indexchange = '<TABLE BORDER="0" WIDTH="100%" HEIGHT="100%" CELLSPACING="0" CELLPADDING="0"><TR><TD COLSPAN="3"><DIV CLASS="NAVHEADER"><TABLE BGCOLOR="#CCCCFF" BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%"><TR><TD><TABLE WIDTH="100%" BORDER="0" CELLPADDING="3" CELLSPACING="0"><TR><TH COLSPAN="3">PHP Kézikönyv</TH></TR><TR><TD COLSPAN="3" ALIGN="center"> </TD></TR></TABLE></TD></TR><TR BGCOLOR="#333366"><TD><IMG SRC="spacer.gif" BORDER="0" WIDTH="1" HEIGHT="1"><BR></TD></TR></TABLE> </DIV></TD></TR><TR><TD><IMG SRC="spacer.gif" WIDTH="10" HEIGHT="1"></TD><TD HEIGHT="100%" VALIGN="TOP" WIDTH="100%"><BR>'; $content = preg_replace("/(<DIV\\s+CLASS=\"BOOK\")/", "$indexchange\\1", $content); $content = preg_replace("/(<DIV\\s+CLASS=\"author\").*<HR>/Us", "", $content); preg_match('|<DIV\\s+CLASS="TOC"\\s+><DL\\s+><DT\\s+><B\\s+>(.*)</B\\s+>|U', $content, $match); $content = preg_replace("|(CLASS=\"title\"\\s+><A\\s+NAME=\"manual\"\\s+>).*(</A)|U", "\\1$match[1]\\2", $content); $content = preg_replace("|<DT\\s+><B\\s+>(.*)</B\\s+></DT\\s+>|U", "", $content); } // print out that new file to $fancydir $fp = fopen("$fancydir/$fname", "w"); fputs($fp, $content); fclose($fp); // print out a message to see the progress echo "$fancydir/$fname ready...\n"; $counter++; } ?>