cvs: phpdoc /chm chm_settings.php common.php make_chm.php make_chm_fancy.php
| From: | Derick Rethans | Date: | Sun, 11 May 2003 20:00:23 +0000 |
| Subject: | cvs: phpdoc /chm chm_settings.php common.php make_chm.php make_chm_fancy.php | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969353353@lists.php.net to get a copy of this message | ||
derick Sun May 11 16:00:23 2003 EDT
Added files:
/phpdoc/chm chm_settings.php common.php
Modified files:
/phpdoc/chm make_chm.php make_chm_fancy.php
Log:
- Committing Moriyoshi's fixes and my own tweaks to make the Japanese CHM
finally display correctly.
#- Atleast it works on my system now ;)
Index: phpdoc/chm/make_chm.php diff -u phpdoc/chm/make_chm.php:1.17 phpdoc/chm/make_chm.php:1.18 --- phpdoc/chm/make_chm.php:1.17 Mon Apr 28 16:56:23 2003 +++ phpdoc/chm/make_chm.php Sun May 11 16:00:23 2003 @@ -9,118 +9,13 @@ See make_chm.README for information about this system. */ -// Used directories and files -$HTML_PATH = getenv("PHP_HELP_COMPILE_DIR"); -$FANCY_PATH = getenv("PHP_HELP_COMPILE_FANCYDIR"); -$LANGUAGE = getenv("PHP_HELP_COMPILE_LANG"); +include_once('common.php'); +include_once('chm_settings.php'); + $INDEX_IN_HTML = "index.html"; -$INTERNAL_CHARSET = "UTF-8"; -$DEFAULT_FONT = "Arial,10,0"; if (empty($FANCY_PATH)) { $FANCY_PATH = $HTML_PATH; } -// Array to manual code -> HTML Help Code conversion -// Code list: http://www.helpware.net/htmlhelp/hh_info.htm -// Charset list: http://www.microsoft.com/globaldev/nlsweb/default.asp -// Language code: http://www.unicode.org/unicode/onlinedat/languages.html -$LANGUAGES = array( - "tw" => array( - "langcode" => "0x404 Traditional Chinese", - "preferred_charset" => "CP950", - "preferred_font" => $DEFAULT_FONT - ), - "cs" => array( - "langcode" => "0x405 Czech", - "preferred_charset" => "Windows-1250", - "preferred_font" => $DEFAULT_FONT - ), - "de" => array( - "langcode" => "0x407 German (Germany)", - "preferred_charset" => "Windows-1252", - "preferred_font" => $DEFAULT_FONT - ), - "en" => array( - "langcode" => "0x809 English (United Kingdom)", - "preferred_charset" => "Windows-1252", - "preferred_font" => $DEFAULT_FONT - ), - "es" => array( - "langcode" => "0xc0a Spanish (International Sort)", - "preferred_charset" => "Windows-1252", - "preferred_font" => $DEFAULT_FONT - ), - "fr" => array( - "langcode" => "0x40c French (France)", - "preferred_charset" => "Windows-1252", - "preferred_font" => $DEFAULT_FONT - ), - "fi" => array( - "langcode" => "0x40b Finnish", - "preferred_charset" => "Windows-1252", - "preferred_font" => $DEFAULT_FONT - ), - "hu" => array( - "langcode" => "0x40e Hungarian", - "preferred_charset" => "Windows-1250", - "preferred_font" => $DEFAULT_FONT - ), - "it" => array( - "langcode" => "0x410 Italian (Italy)", - "preferred_charset" => "Windows-1252", - "preferred_font" => $DEFAULT_FONT - ), - "ja" => array( - "langcode" => "0x411 Japanese", - "preferred_charset" => "CP932", - "preferred_font" => "lr oSVbN,10,0" - ), - "kr" => array( - "langcode" => "0x412 Korean", - "preferred_charset" => "CP949", - "preferred_font" => $DEFAULT_FONT - ), - "nl" => array( - "langcode" => "0x413 Dutch (Netherlands)", - "preferred_charset" => "Windows-1252", - "preferred_font" => $DEFAULT_FONT - ), - "pl" => array( - "langcode" => "0x415 Polish", - "preferred_charset" => "Windows-1250", - "preferred_font" => $DEFAULT_FONT - ), - "pt_BR" => array( - "langcode" => "0x416 Portuguese (Brazil)", - "preferred_charset" => "Windows-1252", - "preferred_font" => $DEFAULT_FONT - ), - "ro" => array( - "langcode" => "0x418 Romanian", - "preferred_charset" => "Windows-1250", - "preferred_font" => $DEFAULT_FONT - ), - "sk" => array( - "langcode" => "0x41b Slovak", - "preferred_charset" => "Windows-1250", - "preferred_font" => $DEFAULT_FONT - ), - "sl" => array( - "langcode" => "0x424 Slovenian", - "preferred_charset" => "Windows-1250", - "preferred_font" => $DEFAULT_FONT - ), - "sv" => array( - "langcode" => "0x41d Swedish", - "preferred_charset" => "Windows-1252", - "preferred_font" => $DEFAULT_FONT - ), - "zh" => array( - "langcode" => "0x804 Simplified Chinese", - "preferred_charset" => "CP936", - "preferred_font" => $DEFAULT_FONT - ) -); - // Files on the top level of the TOC $MAIN_FILES = array( "getting-started.html", @@ -132,18 +27,6 @@ "appendixes.html" ); -// backwards compatibility -if (!function_exists("file_get_contents")) { - function file_get_contents($file) - { - $cnt = file($file); - if ($cnt !== false) { - return join('', $cnt); - } - return false; - } -} - // Header for index and toc $HEADER = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> @@ -152,7 +35,7 @@ <!-- Sitemap 1.0 --> </head> <body> - <object typre="text/site properties"> + <object type="text/site properties"> <param name="Window Styles" value="0x800227"> </object> <ul>'; @@ -254,7 +137,6 @@ fputs_wrapper($project, "Compiled file=php_manual_$LANGUAGE.chm\n"); fputs_wrapper($project, "Contents file=php_manual_$LANGUAGE.hhc\n"); fputs_wrapper($project, "Index file=php_manual_$LANGUAGE.hhk\n"); - fputs_wrapper($project, "Default Font={$LANGUAGES[$LANGUAGE]['preferred_font']}\n"); fputs_wrapper($project, "Default Window=phpdoc\n"); fputs_wrapper($project, "Default topic=$FANCY_PATH\\$FIRST_PAGE\n"); fputs_wrapper($project, "Display compile progress=Yes\n"); @@ -273,6 +155,7 @@ } fputs_wrapper($project, "Title=$MANUAL_TITLE\n"); + fputs_wrapper($project, "Default Font={$LANGUAGES[$LANGUAGE]['preferred_font']}\n"); // Define the phpdoc window style (adds more functionality) fputs_wrapper($project, "\n[WINDOWS]\nphpdoc=\"$MANUAL_TITLE\",\"php_manual_$LANGUAGE.hhc\",\"php_manual_$LANGUAGE.hhk\"," . @@ -350,62 +233,4 @@ } } // findDeeperLinks() function end - -function fputs_wrapper($fp, $str) -{ - fputs($fp, convertCharset($str)); -} - -// Return a file joined on one line -function oneLiner($filename) -{ - global $INTERNAL_CHARSET; - - $buf = preg_replace("/[\r|\n]{1,2}/U", " ", file_get_contents($filename)); - $charset = detectDocumentCharset($buf); - - if ($charset === false) $charset = "UTF-8"; - - if ($charset != $INTERNAL_CHARSET) { - if (function_exists("iconv")) { - $buf = iconv($charset, $INTERNAL_CHARSET, $buf); - } elseif (function_exists("mb_convert_encoding")) { - $buf = mb_convert_encoding($buf, $INTERNAL_CHARSET, $charset); - } elseif (preg_match("/^UTF-?8$/i", $INTERNAL_CHARSET) && preg_match("/^(ISO-8859-1|WINDOWS-1252)$/i", $charset)) { - $buf = utf8_encode($buf); - } else { - die("charset conversion function is not available."); - } - } - return $buf; -} - -function convertCharset($buf) -{ - global $LANGUAGE, $LANGUAGES, $INTERNAL_CHARSET; - - $charset = $LANGUAGES[$LANGUAGE]['preferred_charset']; - - if ($charset != $INTERNAL_CHARSET) { - if (function_exists("iconv")) { - $buf = iconv($INTERNAL_CHARSET, "$charset//TRANSLIT", $buf); - } elseif (function_exists("mb_convert_encoding")) { - $buf = mb_convert_encoding($buf, $charset, $INTERNAL_CHARSET); - } elseif (preg_match("/^UTF-?8$/i", $INTERNAL_CHARSET) && preg_match("/^(ISO-8859-1|WINDOWS-1252)$/i", $charset)) { - $buf = utf8_decode($buf); - } else { - die("$LANGUAGE locale is not supported."); - } - } - return $buf; -} // oneLiner() function end - -// Returns the name of character set in the given document -function detectDocumentCharset($doc) -{ - if (preg_match("/<META\\s+HTTP-EQUIV=\"CONTENT-TYPE\"\\s+CONTENT=\"TEXT\\/HTML;\\s+CHARSET=([\\w\\d-]*)\"\\s*>/iU", $doc, $reg)) { - return $reg[1]; - } - return false; -} ?> Index: phpdoc/chm/make_chm_fancy.php diff -u phpdoc/chm/make_chm_fancy.php:1.5 phpdoc/chm/make_chm_fancy.php:1.6 --- phpdoc/chm/make_chm_fancy.php:1.5 Fri Aug 30 12:04:32 2002 +++ phpdoc/chm/make_chm_fancy.php Sun May 11 16:00:23 2003 @@ -7,20 +7,20 @@ to put here in CVS. */ +include_once('common.php'); +include_once('chm_settings.php'); + // This script takes much time to run set_time_limit(0); // Get ENV vars from the system -$htmldir = getenv("PHP_HELP_COMPILE_DIR"); -$fancydir = getenv("PHP_HELP_COMPILE_FANCYDIR"); -$language = getenv("PHP_HELP_COMPILE_LANG"); $original_index = "index.html"; // How many files were processed $counter = 0; // Open the directory, and do the work on all HTML files -$handle = opendir($htmldir); +$handle = opendir($HTML_PATH); while (false !== ($filename = readdir($handle))) { if (strpos($filename, ".html") && ($filename != "fancy-index.html")) { fancy_design($filename); @@ -29,29 +29,30 @@ closedir($handle); // Look for CHM index file (snap-downloader, cvs-usr with/without lang-support) -if (false == ($content = join("", @file("make_chm_index_$language.html")))) { - if (false == ($content = join("", @file("$language/make_chm_index_$language.html")))) { - if (false == ($content = join("", @file("$htmldir/../$language/make_chm_index_$language.html")))) { - $content = join("", @file("en/make_chm_index_en.html")); - } +if (false == ($content = oneLiner("make_chm_index_$LANGUAGE.html"))) { + if (false == ($content = oneLiner("$LANGUAGE/make_chm_index_$LANGUAGE.html"))) { + if (false == ($content = oneLiner("$HTML_PATH/../$LANGUAGE/make_chm_index_$LANGUAGE.html"))) { + $content = oneLiner("en/make_chm_index_en.html"); + } } } // Make GENTIME the actual date/time $content = str_replace("[GENTIME]", date("D M d H:i:s Y"), $content); $content = str_replace("[PUBTIME]", $publication_date, $content); -$fp = fopen("$fancydir/fancy-index.html", "w"); -fputs($fp, $content); +$content = setDocumentCharset($content, $LANGUAGES[$LANGUAGE]['mime_charset_name']); +$fp = fopen("$FANCY_PATH/fancy-index.html", "w"); +fputs_wrapper($fp, $content); fclose($fp); -copy("chm/make_chm_style.css", "$fancydir/style.css"); -copy("chm/make_chm_spc.gif", "$fancydir/spacer.gif"); +copy("chm/make_chm_style.css", "$FANCY_PATH/style.css"); +copy("chm/make_chm_spc.gif", "$FANCY_PATH/spacer.gif"); // Three files added (fancy-index.html, style.css and spacer.gif) $counter += 3; echo "\nConverting ready...\n"; -echo "Total number of files written in $fancydir directory: $counter\n\n"; +echo "Total number of files written in $FANCY_PATH directory: $counter\n\n"; /***********************************************************************/ /* End of script lines, one main function follows */ @@ -60,10 +61,10 @@ // Convert one file from HTML => fancy HTML function fancy_design($fname) { - global $htmldir, $fancydir, $counter, $original_index, $publication_date; + global $HTML_PATH, $FANCY_PATH, $LANGUAGE, $LANGUAGES, $counter, $original_index, $publication_date; - // Get the contents of the file from $htmldir - $content = join("", file("$htmldir/$fname")); + // Get the contents of the file from $HTML_PATH + $content = oneLiner("$HTML_PATH/$fname"); // CSS file linking $content = preg_replace("|</HEAD|", '<LINK REL="stylesheet" HREF="style.css"></HEAD', $content); @@ -119,13 +120,14 @@ } - // Print out that new file to $fancydir - $fp = fopen("$fancydir/$fname", "w"); - fputs($fp, $content); + // Print out that new file to $FANCY_PATH + $fp = fopen("$FANCY_PATH/$fname", "w"); + $content = setDocumentCharset($content, $LANGUAGES[$LANGUAGE]['mime_charset_name']); + fputs_wrapper($fp, $content); fclose($fp); // Print out a message to see the progress - echo "$fancydir/$fname ready...\n"; + echo "$FANCY_PATH/$fname ready...\n"; $counter++; } // fancy_design() function end Index: phpdoc/chm/chm_settings.php +++ phpdoc/chm/chm_settings.php <?php $DEFAULT_FONT = "Arial,10,0"; // Array to manual code -> HTML Help Code conversion // Code list: http://www.helpware.net/htmlhelp/hh_info.htm // Charset list: http://www.microsoft.com/globaldev/nlsweb/default.asp // Language code: http://www.unicode.org/unicode/onlinedat/languages.html // MIME preferred charset list: http://www.iana.org/assignments/character-sets $LANGUAGES = array( "tw" => array( "langcode" => "0x404 Traditional Chinese", "preferred_charset" => "CP950", "mime_charset_name" => "Big5", "preferred_font" => $DEFAULT_FONT ), "cs" => array( "langcode" => "0x405 Czech", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => $DEFAULT_FONT, ), "de" => array( "langcode" => "0x407 German (Germany)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => $DEFAULT_FONT, ), "en" => array( "langcode" => "0x809 English (United Kingdom)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => $DEFAULT_FONT ), "es" => array( "langcode" => "0xc0a Spanish (International Sort)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => $DEFAULT_FONT ), "fr" => array( "langcode" => "0x40c French (France)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => $DEFAULT_FONT ), "fi" => array( "langcode" => "0x40b Finnish", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => $DEFAULT_FONT ), "hu" => array( "langcode" => "0x40e Hungarian", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => $DEFAULT_FONT ), "it" => array( "langcode" => "0x410 Italian (Italy)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => $DEFAULT_FONT ), "ja" => array( "langcode" => "0x411 Japanese", "preferred_charset" => "CP932", "mime_charset_name" => "csWindows31J", "preferred_font" => "lr oSVbN,10,0" ), "kr" => array( "langcode" => "0x412 Korean", "preferred_charset" => "CP949", "mime_charset_name" => "EUC-KR", "preferred_font" => $DEFAULT_FONT ), "nl" => array( "langcode" => "0x413 Dutch (Netherlands)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => $DEFAULT_FONT ), "pl" => array( "langcode" => "0x415 Polish", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => $DEFAULT_FONT ), "pt_BR" => array( "langcode" => "0x416 Portuguese (Brazil)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => $DEFAULT_FONT ), "ro" => array( "langcode" => "0x418 Romanian", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => $DEFAULT_FONT ), "sk" => array( "langcode" => "0x41b Slovak", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => $DEFAULT_FONT ), "sl" => array( "langcode" => "0x424 Slovenian", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => $DEFAULT_FONT ), "sv" => array( "langcode" => "0x41d Swedish", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => $DEFAULT_FONT ), "zh" => array( "langcode" => "0x804 Simplified Chinese", "preferred_charset" => "CP936", "mime_charset_name" => "gb2312", "preferred_font" => $DEFAULT_FONT ) ); ?> Index: phpdoc/chm/common.php +++ phpdoc/chm/common.php <?php // Used directories and files $HTML_PATH = getenv("PHP_HELP_COMPILE_DIR"); $FANCY_PATH = getenv("PHP_HELP_COMPILE_FANCYDIR"); $LANGUAGE = getenv("PHP_HELP_COMPILE_LANG"); $INTERNAL_CHARSET = "UTF-8"; // backwards compatibility if (!function_exists("file_get_contents")) { function file_get_contents($file) { $cnt = file($file); if ($cnt !== false) { return join('', $cnt); } return false; } } // Return a file joined on one line function oneLiner($filename) { global $INTERNAL_CHARSET; $buf = preg_replace("/[\r|\n]{1,2}/U", " ", file_get_contents($filename)); $charset = detectDocumentCharset($buf); if ($charset === false) $charset = "UTF-8"; if ($charset != $INTERNAL_CHARSET) { if (function_exists("iconv")) { $buf = iconv($charset, $INTERNAL_CHARSET, $buf); } elseif (function_exists("mb_convert_encoding")) { $buf = mb_convert_encoding($buf, $INTERNAL_CHARSET, $charset); } elseif (preg_match("/^UTF-?8$/i", $INTERNAL_CHARSET) && preg_match("/^(ISO-8859-1|WINDOWS-1252)$/i", $charset)) { $buf = utf8_encode($buf); } else { die("charset conversion function is not available."); } } return $buf; } function fputs_wrapper($fp, $str) { fputs($fp, convertCharset($str)); } function convertCharset($buf) { global $LANGUAGE, $LANGUAGES, $INTERNAL_CHARSET; $charset = $LANGUAGES[$LANGUAGE]['preferred_charset']; if ($charset != $INTERNAL_CHARSET) { if (function_exists("iconv")) { $buf = iconv($INTERNAL_CHARSET, "$charset//TRANSLIT", $buf); } elseif (function_exists("mb_convert_encoding")) { $buf = mb_convert_encoding($buf, $charset, $INTERNAL_CHARSET); } elseif (preg_match("/^UTF-?8$/i", $INTERNAL_CHARSET) && preg_match("/^(ISO-8859-1|WINDOWS-1252)$/i", $charset)) { $buf = utf8_decode($buf); } else { die("$LANGUAGE locale is not supported."); } } return $buf; } // oneLiner() function end // Returns the name of character set in the given document function detectDocumentCharset($doc) { if (preg_match("/<META\\s+HTTP-EQUIV=\"CONTENT-TYPE\"\\s+CONTENT=\"TEXT\\/HTML;\\s+CHARSET=([\\w\\d-]*)\"\\s*>/iU", $doc, $reg)) { return $reg[1]; } return false; } function setDocumentCharset($doc, $charset) { return preg_replace("/(<META\\s+HTTP-EQUIV=\"CONTENT-TYPE\"\\s+CONTENT=\"TEXT\\/HTML;\\s+CHARSET=)([\\w\\d-]*)(\"\\s*>)/iU", "\$1$charset\$3", $doc); } ?>
Index: phpdoc/chm/make_chm.php diff -u phpdoc/chm/make_chm.php:1.17 phpdoc/chm/make_chm.php:1.18 --- phpdoc/chm/make_chm.php:1.17 Mon Apr 28 16:56:23 2003 +++ phpdoc/chm/make_chm.php Sun May 11 16:00:23 2003 @@ -9,118 +9,13 @@ See make_chm.README for information about this system. */ -// Used directories and files -$HTML_PATH = getenv("PHP_HELP_COMPILE_DIR"); -$FANCY_PATH = getenv("PHP_HELP_COMPILE_FANCYDIR"); -$LANGUAGE = getenv("PHP_HELP_COMPILE_LANG"); +include_once('common.php'); +include_once('chm_settings.php'); + $INDEX_IN_HTML = "index.html"; -$INTERNAL_CHARSET = "UTF-8"; -$DEFAULT_FONT = "Arial,10,0"; if (empty($FANCY_PATH)) { $FANCY_PATH = $HTML_PATH; } -// Array to manual code -> HTML Help Code conversion -// Code list: http://www.helpware.net/htmlhelp/hh_info.htm -// Charset list: http://www.microsoft.com/globaldev/nlsweb/default.asp -// Language code: http://www.unicode.org/unicode/onlinedat/languages.html -$LANGUAGES = array( - "tw" => array( - "langcode" => "0x404 Traditional Chinese", - "preferred_charset" => "CP950", - "preferred_font" => $DEFAULT_FONT - ), - "cs" => array( - "langcode" => "0x405 Czech", - "preferred_charset" => "Windows-1250", - "preferred_font" => $DEFAULT_FONT - ), - "de" => array( - "langcode" => "0x407 German (Germany)", - "preferred_charset" => "Windows-1252", - "preferred_font" => $DEFAULT_FONT - ), - "en" => array( - "langcode" => "0x809 English (United Kingdom)", - "preferred_charset" => "Windows-1252", - "preferred_font" => $DEFAULT_FONT - ), - "es" => array( - "langcode" => "0xc0a Spanish (International Sort)", - "preferred_charset" => "Windows-1252", - "preferred_font" => $DEFAULT_FONT - ), - "fr" => array( - "langcode" => "0x40c French (France)", - "preferred_charset" => "Windows-1252", - "preferred_font" => $DEFAULT_FONT - ), - "fi" => array( - "langcode" => "0x40b Finnish", - "preferred_charset" => "Windows-1252", - "preferred_font" => $DEFAULT_FONT - ), - "hu" => array( - "langcode" => "0x40e Hungarian", - "preferred_charset" => "Windows-1250", - "preferred_font" => $DEFAULT_FONT - ), - "it" => array( - "langcode" => "0x410 Italian (Italy)", - "preferred_charset" => "Windows-1252", - "preferred_font" => $DEFAULT_FONT - ), - "ja" => array( - "langcode" => "0x411 Japanese", - "preferred_charset" => "CP932", - "preferred_font" => "lr oSVbN,10,0" - ), - "kr" => array( - "langcode" => "0x412 Korean", - "preferred_charset" => "CP949", - "preferred_font" => $DEFAULT_FONT - ), - "nl" => array( - "langcode" => "0x413 Dutch (Netherlands)", - "preferred_charset" => "Windows-1252", - "preferred_font" => $DEFAULT_FONT - ), - "pl" => array( - "langcode" => "0x415 Polish", - "preferred_charset" => "Windows-1250", - "preferred_font" => $DEFAULT_FONT - ), - "pt_BR" => array( - "langcode" => "0x416 Portuguese (Brazil)", - "preferred_charset" => "Windows-1252", - "preferred_font" => $DEFAULT_FONT - ), - "ro" => array( - "langcode" => "0x418 Romanian", - "preferred_charset" => "Windows-1250", - "preferred_font" => $DEFAULT_FONT - ), - "sk" => array( - "langcode" => "0x41b Slovak", - "preferred_charset" => "Windows-1250", - "preferred_font" => $DEFAULT_FONT - ), - "sl" => array( - "langcode" => "0x424 Slovenian", - "preferred_charset" => "Windows-1250", - "preferred_font" => $DEFAULT_FONT - ), - "sv" => array( - "langcode" => "0x41d Swedish", - "preferred_charset" => "Windows-1252", - "preferred_font" => $DEFAULT_FONT - ), - "zh" => array( - "langcode" => "0x804 Simplified Chinese", - "preferred_charset" => "CP936", - "preferred_font" => $DEFAULT_FONT - ) -); - // Files on the top level of the TOC $MAIN_FILES = array( "getting-started.html", @@ -132,18 +27,6 @@ "appendixes.html" ); -// backwards compatibility -if (!function_exists("file_get_contents")) { - function file_get_contents($file) - { - $cnt = file($file); - if ($cnt !== false) { - return join('', $cnt); - } - return false; - } -} - // Header for index and toc $HEADER = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> @@ -152,7 +35,7 @@ <!-- Sitemap 1.0 --> </head> <body> - <object typre="text/site properties"> + <object type="text/site properties"> <param name="Window Styles" value="0x800227"> </object> <ul>'; @@ -254,7 +137,6 @@ fputs_wrapper($project, "Compiled file=php_manual_$LANGUAGE.chm\n"); fputs_wrapper($project, "Contents file=php_manual_$LANGUAGE.hhc\n"); fputs_wrapper($project, "Index file=php_manual_$LANGUAGE.hhk\n"); - fputs_wrapper($project, "Default Font={$LANGUAGES[$LANGUAGE]['preferred_font']}\n"); fputs_wrapper($project, "Default Window=phpdoc\n"); fputs_wrapper($project, "Default topic=$FANCY_PATH\\$FIRST_PAGE\n"); fputs_wrapper($project, "Display compile progress=Yes\n"); @@ -273,6 +155,7 @@ } fputs_wrapper($project, "Title=$MANUAL_TITLE\n"); + fputs_wrapper($project, "Default Font={$LANGUAGES[$LANGUAGE]['preferred_font']}\n"); // Define the phpdoc window style (adds more functionality) fputs_wrapper($project, "\n[WINDOWS]\nphpdoc=\"$MANUAL_TITLE\",\"php_manual_$LANGUAGE.hhc\",\"php_manual_$LANGUAGE.hhk\"," . @@ -350,62 +233,4 @@ } } // findDeeperLinks() function end - -function fputs_wrapper($fp, $str) -{ - fputs($fp, convertCharset($str)); -} - -// Return a file joined on one line -function oneLiner($filename) -{ - global $INTERNAL_CHARSET; - - $buf = preg_replace("/[\r|\n]{1,2}/U", " ", file_get_contents($filename)); - $charset = detectDocumentCharset($buf); - - if ($charset === false) $charset = "UTF-8"; - - if ($charset != $INTERNAL_CHARSET) { - if (function_exists("iconv")) { - $buf = iconv($charset, $INTERNAL_CHARSET, $buf); - } elseif (function_exists("mb_convert_encoding")) { - $buf = mb_convert_encoding($buf, $INTERNAL_CHARSET, $charset); - } elseif (preg_match("/^UTF-?8$/i", $INTERNAL_CHARSET) && preg_match("/^(ISO-8859-1|WINDOWS-1252)$/i", $charset)) { - $buf = utf8_encode($buf); - } else { - die("charset conversion function is not available."); - } - } - return $buf; -} - -function convertCharset($buf) -{ - global $LANGUAGE, $LANGUAGES, $INTERNAL_CHARSET; - - $charset = $LANGUAGES[$LANGUAGE]['preferred_charset']; - - if ($charset != $INTERNAL_CHARSET) { - if (function_exists("iconv")) { - $buf = iconv($INTERNAL_CHARSET, "$charset//TRANSLIT", $buf); - } elseif (function_exists("mb_convert_encoding")) { - $buf = mb_convert_encoding($buf, $charset, $INTERNAL_CHARSET); - } elseif (preg_match("/^UTF-?8$/i", $INTERNAL_CHARSET) && preg_match("/^(ISO-8859-1|WINDOWS-1252)$/i", $charset)) { - $buf = utf8_decode($buf); - } else { - die("$LANGUAGE locale is not supported."); - } - } - return $buf; -} // oneLiner() function end - -// Returns the name of character set in the given document -function detectDocumentCharset($doc) -{ - if (preg_match("/<META\\s+HTTP-EQUIV=\"CONTENT-TYPE\"\\s+CONTENT=\"TEXT\\/HTML;\\s+CHARSET=([\\w\\d-]*)\"\\s*>/iU", $doc, $reg)) { - return $reg[1]; - } - return false; -} ?> Index: phpdoc/chm/make_chm_fancy.php diff -u phpdoc/chm/make_chm_fancy.php:1.5 phpdoc/chm/make_chm_fancy.php:1.6 --- phpdoc/chm/make_chm_fancy.php:1.5 Fri Aug 30 12:04:32 2002 +++ phpdoc/chm/make_chm_fancy.php Sun May 11 16:00:23 2003 @@ -7,20 +7,20 @@ to put here in CVS. */ +include_once('common.php'); +include_once('chm_settings.php'); + // This script takes much time to run set_time_limit(0); // Get ENV vars from the system -$htmldir = getenv("PHP_HELP_COMPILE_DIR"); -$fancydir = getenv("PHP_HELP_COMPILE_FANCYDIR"); -$language = getenv("PHP_HELP_COMPILE_LANG"); $original_index = "index.html"; // How many files were processed $counter = 0; // Open the directory, and do the work on all HTML files -$handle = opendir($htmldir); +$handle = opendir($HTML_PATH); while (false !== ($filename = readdir($handle))) { if (strpos($filename, ".html") && ($filename != "fancy-index.html")) { fancy_design($filename); @@ -29,29 +29,30 @@ closedir($handle); // Look for CHM index file (snap-downloader, cvs-usr with/without lang-support) -if (false == ($content = join("", @file("make_chm_index_$language.html")))) { - if (false == ($content = join("", @file("$language/make_chm_index_$language.html")))) { - if (false == ($content = join("", @file("$htmldir/../$language/make_chm_index_$language.html")))) { - $content = join("", @file("en/make_chm_index_en.html")); - } +if (false == ($content = oneLiner("make_chm_index_$LANGUAGE.html"))) { + if (false == ($content = oneLiner("$LANGUAGE/make_chm_index_$LANGUAGE.html"))) { + if (false == ($content = oneLiner("$HTML_PATH/../$LANGUAGE/make_chm_index_$LANGUAGE.html"))) { + $content = oneLiner("en/make_chm_index_en.html"); + } } } // Make GENTIME the actual date/time $content = str_replace("[GENTIME]", date("D M d H:i:s Y"), $content); $content = str_replace("[PUBTIME]", $publication_date, $content); -$fp = fopen("$fancydir/fancy-index.html", "w"); -fputs($fp, $content); +$content = setDocumentCharset($content, $LANGUAGES[$LANGUAGE]['mime_charset_name']); +$fp = fopen("$FANCY_PATH/fancy-index.html", "w"); +fputs_wrapper($fp, $content); fclose($fp); -copy("chm/make_chm_style.css", "$fancydir/style.css"); -copy("chm/make_chm_spc.gif", "$fancydir/spacer.gif"); +copy("chm/make_chm_style.css", "$FANCY_PATH/style.css"); +copy("chm/make_chm_spc.gif", "$FANCY_PATH/spacer.gif"); // Three files added (fancy-index.html, style.css and spacer.gif) $counter += 3; echo "\nConverting ready...\n"; -echo "Total number of files written in $fancydir directory: $counter\n\n"; +echo "Total number of files written in $FANCY_PATH directory: $counter\n\n"; /***********************************************************************/ /* End of script lines, one main function follows */ @@ -60,10 +61,10 @@ // Convert one file from HTML => fancy HTML function fancy_design($fname) { - global $htmldir, $fancydir, $counter, $original_index, $publication_date; + global $HTML_PATH, $FANCY_PATH, $LANGUAGE, $LANGUAGES, $counter, $original_index, $publication_date; - // Get the contents of the file from $htmldir - $content = join("", file("$htmldir/$fname")); + // Get the contents of the file from $HTML_PATH + $content = oneLiner("$HTML_PATH/$fname"); // CSS file linking $content = preg_replace("|</HEAD|", '<LINK REL="stylesheet" HREF="style.css"></HEAD', $content); @@ -119,13 +120,14 @@ } - // Print out that new file to $fancydir - $fp = fopen("$fancydir/$fname", "w"); - fputs($fp, $content); + // Print out that new file to $FANCY_PATH + $fp = fopen("$FANCY_PATH/$fname", "w"); + $content = setDocumentCharset($content, $LANGUAGES[$LANGUAGE]['mime_charset_name']); + fputs_wrapper($fp, $content); fclose($fp); // Print out a message to see the progress - echo "$fancydir/$fname ready...\n"; + echo "$FANCY_PATH/$fname ready...\n"; $counter++; } // fancy_design() function end Index: phpdoc/chm/chm_settings.php +++ phpdoc/chm/chm_settings.php <?php $DEFAULT_FONT = "Arial,10,0"; // Array to manual code -> HTML Help Code conversion // Code list: http://www.helpware.net/htmlhelp/hh_info.htm // Charset list: http://www.microsoft.com/globaldev/nlsweb/default.asp // Language code: http://www.unicode.org/unicode/onlinedat/languages.html // MIME preferred charset list: http://www.iana.org/assignments/character-sets $LANGUAGES = array( "tw" => array( "langcode" => "0x404 Traditional Chinese", "preferred_charset" => "CP950", "mime_charset_name" => "Big5", "preferred_font" => $DEFAULT_FONT ), "cs" => array( "langcode" => "0x405 Czech", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => $DEFAULT_FONT, ), "de" => array( "langcode" => "0x407 German (Germany)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => $DEFAULT_FONT, ), "en" => array( "langcode" => "0x809 English (United Kingdom)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => $DEFAULT_FONT ), "es" => array( "langcode" => "0xc0a Spanish (International Sort)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => $DEFAULT_FONT ), "fr" => array( "langcode" => "0x40c French (France)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => $DEFAULT_FONT ), "fi" => array( "langcode" => "0x40b Finnish", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => $DEFAULT_FONT ), "hu" => array( "langcode" => "0x40e Hungarian", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => $DEFAULT_FONT ), "it" => array( "langcode" => "0x410 Italian (Italy)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => $DEFAULT_FONT ), "ja" => array( "langcode" => "0x411 Japanese", "preferred_charset" => "CP932", "mime_charset_name" => "csWindows31J", "preferred_font" => "lr oSVbN,10,0" ), "kr" => array( "langcode" => "0x412 Korean", "preferred_charset" => "CP949", "mime_charset_name" => "EUC-KR", "preferred_font" => $DEFAULT_FONT ), "nl" => array( "langcode" => "0x413 Dutch (Netherlands)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => $DEFAULT_FONT ), "pl" => array( "langcode" => "0x415 Polish", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => $DEFAULT_FONT ), "pt_BR" => array( "langcode" => "0x416 Portuguese (Brazil)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => $DEFAULT_FONT ), "ro" => array( "langcode" => "0x418 Romanian", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => $DEFAULT_FONT ), "sk" => array( "langcode" => "0x41b Slovak", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => $DEFAULT_FONT ), "sl" => array( "langcode" => "0x424 Slovenian", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => $DEFAULT_FONT ), "sv" => array( "langcode" => "0x41d Swedish", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => $DEFAULT_FONT ), "zh" => array( "langcode" => "0x804 Simplified Chinese", "preferred_charset" => "CP936", "mime_charset_name" => "gb2312", "preferred_font" => $DEFAULT_FONT ) ); ?> Index: phpdoc/chm/common.php +++ phpdoc/chm/common.php <?php // Used directories and files $HTML_PATH = getenv("PHP_HELP_COMPILE_DIR"); $FANCY_PATH = getenv("PHP_HELP_COMPILE_FANCYDIR"); $LANGUAGE = getenv("PHP_HELP_COMPILE_LANG"); $INTERNAL_CHARSET = "UTF-8"; // backwards compatibility if (!function_exists("file_get_contents")) { function file_get_contents($file) { $cnt = file($file); if ($cnt !== false) { return join('', $cnt); } return false; } } // Return a file joined on one line function oneLiner($filename) { global $INTERNAL_CHARSET; $buf = preg_replace("/[\r|\n]{1,2}/U", " ", file_get_contents($filename)); $charset = detectDocumentCharset($buf); if ($charset === false) $charset = "UTF-8"; if ($charset != $INTERNAL_CHARSET) { if (function_exists("iconv")) { $buf = iconv($charset, $INTERNAL_CHARSET, $buf); } elseif (function_exists("mb_convert_encoding")) { $buf = mb_convert_encoding($buf, $INTERNAL_CHARSET, $charset); } elseif (preg_match("/^UTF-?8$/i", $INTERNAL_CHARSET) && preg_match("/^(ISO-8859-1|WINDOWS-1252)$/i", $charset)) { $buf = utf8_encode($buf); } else { die("charset conversion function is not available."); } } return $buf; } function fputs_wrapper($fp, $str) { fputs($fp, convertCharset($str)); } function convertCharset($buf) { global $LANGUAGE, $LANGUAGES, $INTERNAL_CHARSET; $charset = $LANGUAGES[$LANGUAGE]['preferred_charset']; if ($charset != $INTERNAL_CHARSET) { if (function_exists("iconv")) { $buf = iconv($INTERNAL_CHARSET, "$charset//TRANSLIT", $buf); } elseif (function_exists("mb_convert_encoding")) { $buf = mb_convert_encoding($buf, $charset, $INTERNAL_CHARSET); } elseif (preg_match("/^UTF-?8$/i", $INTERNAL_CHARSET) && preg_match("/^(ISO-8859-1|WINDOWS-1252)$/i", $charset)) { $buf = utf8_decode($buf); } else { die("$LANGUAGE locale is not supported."); } } return $buf; } // oneLiner() function end // Returns the name of character set in the given document function detectDocumentCharset($doc) { if (preg_match("/<META\\s+HTTP-EQUIV=\"CONTENT-TYPE\"\\s+CONTENT=\"TEXT\\/HTML;\\s+CHARSET=([\\w\\d-]*)\"\\s*>/iU", $doc, $reg)) { return $reg[1]; } return false; } function setDocumentCharset($doc, $charset) { return preg_replace("/(<META\\s+HTTP-EQUIV=\"CONTENT-TYPE\"\\s+CONTENT=\"TEXT\\/HTML;\\s+CHARSET=)([\\w\\d-]*)(\"\\s*>)/iU", "\$1$charset\$3", $doc); } ?>