commiting the new tools to make the CHM manual.

#ripped from phpdoc
This commit is contained in:
nlopess
2005-02-10 13:27:26 +00:00
parent d3ab52625d
commit 7cd6a790e0
14 changed files with 849 additions and 1 deletions

1
.gitattributes vendored
View File

@@ -1,4 +1,5 @@
* text=auto !eol
docs/chm/make_chm_spc.gif -text
docs/fop/thryb.ttf -text
docs/fop/thrybi.ttf -text
docs/fop/thryi.ttf -text

3
.gitignore vendored
View File

@@ -1,6 +1,9 @@
docs/*.cache
docs/*.fot
docs/Makefile
docs/chm/*.chm
docs/chm/*.hh?
docs/chm/fancy
docs/config.*
docs/configure
docs/diff

View File

@@ -53,6 +53,9 @@ web: FORCE
pdf: FORCE
${FOP} -xml manual.xml -xsl xsl/fo.xsl -pdf manual.pdf
chm: html
chm/make_chm.bat $(LANG)
test:
$(NSGMLS) -i lang-$(LANG) -s $(XMLDCL) manual.xml

View File

@@ -26,9 +26,18 @@ In order to generate PDF files you need some tools:
To generate the file, just type 'make pdf'
Generate CHM files
==================
In order to generate CHM files you need the Microsoft(r) HTML Help Workshop,
which can be freely downloaded at
http://msdn.microsoft.com/library/en-us/htmlhelp/html/vsconhh1start.asp
Then type 'make chm'. This will run the 'make html' and then build the chm file.
Revision Tracking (for translations):
* make revcheck (this will create revcheck.html)
You should have libxml and autoconf installed in your system.
Read http://php.net/manual/howto/chapter-tools.html for more info.
Read http://doc.php.net/php/dochowto/chapter-tools.php for more info.

3
docs/chm/.cvsignore Executable file
View File

@@ -0,0 +1,3 @@
*.chm
*.hh?
fancy

97
docs/chm/README Executable file
View File

@@ -0,0 +1,97 @@
****************************************************************
** This is a modified version of phpdoc/chm **
****************************************************************
BUILDING THE MANUAL IN WINDOWS HELP FILE (.CHM) FORMAT
Note: Where 'lang' is mentioned in this doc, it is the actual
language code (e.g. en) of the manual you are compiling,
not the 'lang' word itself!
With the herein described tools you're able to build the .chm manual
with two options:
a) Simply build the traditional html manual
b) Make a fancy version of the html manual and build it
=======================================================================
WHAT YOU NEED
* Microsoft(r) HTML Help Workshop.
You can download it freely at:
http://msdn.microsoft.com/library/en-us/htmlhelp/html/vsconhh1start.asp
You need the complete workshop package install (about 4 Megs).
Of course you need Microsoft(r) Windows to run that software :)
* The html manual (build with 'make')
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 are needed:
make_chm_fancy.php - Converts the normal html files to fancy
(good looking) pages
make_chm_index_lang.html - Fancy index. (you find it in phpdoc/lang
dir, if it exists for that language).
make_chm_spc.gif - GIF file needed by the fancy pages.
make_chm_style.css - This adds some good style to html files.
=======================================================================
INSTALLATION
Install Microsoft(r) HTML Help Workshop.
Put the above listed make_chm_* files to one directory.
Open make_chm.bat in a text editor and set the appropriate
environment variables. You need to
- set PHP_PATH to the full path of the CGI php.exe on
your machine (including php.exe).
- 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 when you build it like mentioned in the howto)
- set PHP_HELP_COMPILE_INDEX to the index filename in
the directory you set above. This used to be manual.html
for a long time, but it seems it is now index.html.
The following variable is only needed for the fancy manual:
- set PHP_HELP_COMPILE_FANCYDIR to the directory name where
the fancy pages will go.
You can decide not to sacrifice any more space for the fancy dir
(it takes ~25% more space than the normal html-manual), and set
this variable to the same as PHP_HELP_COMPILE_DIR. Then your old
HTML files will be rewritten to be fancy ones.
=======================================================================
BUILDING THE MANUAL:
Put the html manual (~2100 files) under the subdir specified above in
PHP_HELP_COMPILE_DIR (eg. html).
To compile the NORMAL manual, use the 'normal' command line option:
make_chm normal
To compile the FANCY manual, just run:
make_chm
After this process, you will have smarty_manual_lang.chm...
=======================================================================
The fancy design improvemenets and the .css file is based on
the newsite design(TM) work of Colin Viebrock [colin@easyDNS.com] :)
Written by Gabor Hojtsy (goba@php.net), and adapted by
Thomas Schoefbeck (tom@php.net). Contact them or the phpdoc list
(phpdoc@lists.php.net) if you have any questions or suggestions...
Last modified $Date$

157
docs/chm/chm_settings.php Executable file
View File

@@ -0,0 +1,157 @@
<?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
// Font list: http://www.microsoft.com/office/ork/xp/three/inte03.htm
$LANGUAGES = array(
"hk" => array(
"langcode" => "0xc04 Hong Kong Cantonese",
"preferred_charset" => "CP950",
"mime_charset_name" => "Big5",
"preferred_font" => "MingLiu,10,0"
),
"tw" => array(
"langcode" => "0x404 Traditional Chinese",
"preferred_charset" => "CP950",
"mime_charset_name" => "Big5",
"preferred_font" => "MingLiu,10,0"
),
"cs" => array(
"langcode" => "0x405 Czech",
"preferred_charset" => "Windows-1250",
"mime_charset_name" => "Windows-1250",
"preferred_font" => $DEFAULT_FONT,
),
"da" => array(
"langcode" => "0x406 Danish",
"preferred_charset" => "Windows-1252",
"mime_charset_name" => "Windows-1252",
"preferred_font" => $DEFAULT_FONT,
),
"de" => array(
"langcode" => "0x407 German (Germany)",
"preferred_charset" => "Windows-1252",
"mime_charset_name" => "Windows-1252",
"preferred_font" => $DEFAULT_FONT,
),
"el" => array(
"langcode" => "0x408 Greek",
"preferred_charset" => "Windows-1253",
"mime_charset_name" => "Windows-1253",
"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
),
"he" => array(
"langcode" => "0x40d Hebrew",
"preferred_charset" => "Windows-1255",
"mime_charset_name" => "Windows-1255",
"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" => "MS PGothic,10,0"
),
"kr" => array(
"langcode" => "0x412 Korean",
"preferred_charset" => "CP949",
"mime_charset_name" => "EUC-KR",
"preferred_font" => "Gulim,10,0"
),
"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
),
"ru" => array(
"langcode" => "0x419 Russian",
"preferred_charset" => "Windows-1251",
"mime_charset_name" => "Windows-1251",
"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" => "simsun,10,0"
)
);
?>

75
docs/chm/common.php Executable file
View File

@@ -0,0 +1,75 @@
<?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";
// Return a file joined on one line
function oneLiner($filename, $only_tags = false)
{
global $INTERNAL_CHARSET;
if ($only_tags) {
$buf = @preg_replace("/<([a-zA-Z1-9]+)(>|[^a-zA-Z1-9][^>]*>)/Ue", "preg_replace('/[\r\n]{1,2}/U', ' ', \"<\$1 \$2\")", file_get_contents($filename));
} else {
$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);
}
?>

57
docs/chm/make_chm.bat Executable file
View File

@@ -0,0 +1,57 @@
@echo off
rem !! Please read the make_chm.README file for information
rem !! about how to build a "php_manual_lang.chm" file.
rem Path of the PHP executable
set PHP_PATH=php
rem Path of the Help Compiler command line tool
set PHP_HELP_COMPILER=C:\progra~1\htmlhe~1\hhc.exe
rem The language of the manual to compile
set PHP_HELP_COMPILE_LANG=en
rem The source directory with the original DSSSL made HTML
set PHP_HELP_COMPILE_DIR=html
rem The directory, where the fancy files need to be copied
set PHP_HELP_COMPILE_FANCYDIR=chm\fancy
rem ==========================================================
rem !!!!! DO NOT MODIFY ANYTHING BELOW THIS LINE !!!!!
rem ==========================================================
echo.
rem set PHP_HELP_COMPILE_LANG=%1
if "%1" == "" set PHP_HELP_COMPILE_LANG=en
echo Language choosen: %PHP_HELP_COMPILE_LANG%
if a%2a == anormala goto skipfancy
echo Now generating the fancy manual in %PHP_HELP_COMPILE_FANCYDIR% dir...
IF NOT EXIST %PHP_HELP_COMPILE_FANCYDIR%\NUL md %PHP_HELP_COMPILE_FANCYDIR%
%PHP_PATH% chm\make_chm_fancy.php
goto normal
:skipfancy
set PHP_HELP_COMPILE_FANCYDIR=
echo Skipping fancy manual generation...
:normal
echo Now running the toc and project file generator script...
%PHP_PATH% chm\make_chm.php
echo Compiling the actual helpfile (smarty_manual_%PHP_HELP_COMPILE_LANG%.chm)...
%PHP_HELP_COMPILER% chm\smarty_manual_%PHP_HELP_COMPILE_LANG%.hhp
echo.
echo Cleaning up the directory
del chm\smarty_manual_%PHP_HELP_COMPILE_LANG%.hh?
echo Done!
echo.

219
docs/chm/make_chm.php Executable file
View File

@@ -0,0 +1,219 @@
<?php
/*
PLEASE DO NOT MAKE ANY MAJOR MODIFICATIONS TO THIS CODE!
There is a new script collection on the way to replace
these scripts. Please see the htmlhelp folder for the new
build system.
See make_chm.README for information about this system.
*/
include_once('common.php');
include_once('chm_settings.php');
$INDEX_IN_HTML = "index.html";
if (empty($FANCY_PATH)) { $FANCY_PATH = $HTML_PATH; }
// Files on the top level of the TOC
$MAIN_FILES = array(
'getting.started.html',
'smarty.for.designers.html',
'smarty.for.programmers.html',
'appendixes.html'
);
// Header for index and toc
$HEADER = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<meta name="generator" content="PHP 4 - Auto TOC script">
<!-- Sitemap 1.0 -->
</head>
<body>
<object type="text/site properties">
<param name="Window Styles" value="0x800227">
</object>
<ul>';
makeProjectFile();
makeContentFiles();
// Generate the HTML Help content files
function makeContentFiles()
{
global $LANGUAGE, $MANUAL_TITLE, $HEADER, $MAIN_FILES,
$HTML_PATH, $INDEX_IN_HTML, $FIRST_PAGE;
$toc = fopen("chm/smarty_manual_$LANGUAGE.hhc", "w");
$index = fopen("chm/smarty_manual_$LANGUAGE.hhk", "w");
// Write out file headers
fputs_wrapper($toc, $HEADER);
fputs_wrapper($index, $HEADER);
// Read original index file and drop out newlines
$indexline = oneLiner("$HTML_PATH/$INDEX_IN_HTML");
// Print out the objects, autoparsing won't find
mapAndIndex($MANUAL_TITLE, $FIRST_PAGE, " ", $toc, $index, 21);
// There is a fancy index
if ($FIRST_PAGE != $INDEX_IN_HTML) {
// Find the name of the Table of Contents
preg_match('|CLASS=\"TOC\" *><DL *><DT *><B *>(.*)</B|U', $indexline, $match);
if (empty($match[1])) { // Fallback
$match[1] = "Table of Contents";
}
mapAndIndex($match[1], $INDEX_IN_HTML, " ", $toc, $index, 21);
}
// Find the name of the Preface
preg_match('|<A +HREF="preface.html" *>([^<]*)</A *>|U', $indexline, $match);
if (empty($match[1])) { // Fallback
$match[1] = "Preface";
}
mapAndIndex($match[1], "preface.html", " ", $toc, $index);
// Now autofind the main pages
$MAIN_REGEXP = join("|", $MAIN_FILES);
preg_match_all("![IVX]+\. <A\\s+HREF=\"($MAIN_REGEXP)\"\\s*>([^<]+)</A\\s*>.*</DT\\s*></DL\\s*>(?:</DD\\s*></DL\\s*>)?(?:</DD\\s*><DT\\s*>[IVX]|</DIV)!Ui", $indexline, $matches, PREG_SET_ORDER);
// Go through the main files, and link in subpages
foreach ($matches as $matchinfo) {
mapAndIndex($matchinfo[2], $matchinfo[1], " ", $toc, $index);
fputs_wrapper($toc, "\n <ul>\n");
preg_match_all('!\d+\. <A\\s+HREF="([^"]+)"\\s*>([^<]*)</A\\s*>!iSU', $matchinfo[0], $subpages, PREG_SET_ORDER);
foreach ($subpages as $spinfo) {
mapAndIndex($spinfo[2], $spinfo[1], " ", $toc, $index);
findDeeperLinks($spinfo[1], $toc, $index);
}
fputs_wrapper($toc, "\n </ul>\n");
}
// Write out closing line, and end files
fputs_wrapper($index, " </ul>\n</body>\n</html>");
fputs_wrapper($toc, " </ul>\n</body>\n</html>");
fclose($index);
fclose($toc);
} // makeContentfiles() function end
// Generates the HTML Help project file
function makeProjectFile()
{
global $LANGUAGE, $MANUAL_TITLE, $LANGUAGES,
$HTML_PATH, $FANCY_PATH, $INDEX_IN_HTML,
$FIRST_PAGE;
// Try to find the fancy index file
if (file_exists("$FANCY_PATH/fancy-index.html")) {
$FIRST_PAGE = 'fancy-index.html';
} else {
$FIRST_PAGE = $INDEX_IN_HTML;
}
$FIRST_PAGEP = substr($FANCY_PATH, 4) . "\\$FIRST_PAGE";
// Start writing the project file
$project = fopen("chm/smarty_manual_$LANGUAGE.hhp", "w");
fputs_wrapper($project, "[OPTIONS]\n");
fputs_wrapper($project, "Compatibility=1.1 or later\n");
fputs_wrapper($project, "Compiled file=smarty_manual_$LANGUAGE.chm\n");
fputs_wrapper($project, "Contents file=smarty_manual_$LANGUAGE.hhc\n");
fputs_wrapper($project, "Index file=smarty_manual_$LANGUAGE.hhk\n");
fputs_wrapper($project, "Default Window=smarty\n");
fputs_wrapper($project, "Default topic=$FIRST_PAGEP\n");
fputs_wrapper($project, "Display compile progress=Yes\n");
fputs_wrapper($project, "Full-text search=Yes\n");
// Get the proper language code from the array
fputs_wrapper($project, "Language={$LANGUAGES[$LANGUAGE]["langcode"]}\n");
// Now try to find out how the manual named in the actual language
// this must be in the index.html file as the title (DSSSL generated)
$content = oneLiner("$HTML_PATH/$INDEX_IN_HTML");
if (preg_match("|<TITLE\s*>([^<]*)</TITLE\s*>|U", $content, $found)) {
$MANUAL_TITLE = $found[1];
} else { // Fallback
$MANUAL_TITLE = "Smarty Manual";
}
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]\nsmarty=\"$MANUAL_TITLE\",\"smarty_manual_$LANGUAGE.hhc\",\"smarty_manual_$LANGUAGE.hhk\"," .
"\"$FIRST_PAGEP\",\"$FIRST_PAGEP\",,,,,0x23520,,0x386e,,,,,,,,0\n");
// Write out all the filenames as in FANCY_PATH
fputs_wrapper($project, "\n[FILES]\n");
$handle = opendir($FANCY_PATH);
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
fputs_wrapper($project, substr($FANCY_PATH, 4)."\\$file\n");
}
}
closedir($handle);
fclose($project);
} // makeProjectFile() function end
// Print out a SiteMap object for a file
function mapAndIndex($name, $local, $tabs, $toc, $index, $imgnum = "auto")
{
global $FANCY_PATH;
$name = str_replace('"', '&quot;', $name);
fputs_wrapper($toc, "
$tabs<li><object type=\"text/sitemap\">
$tabs <param name=\"Name\" value=\"$name\">
$tabs <param name=\"Local\" value=\"".substr($FANCY_PATH, 4)."\\$local\">
");
if ($imgnum != "auto") {
fputs_wrapper($toc, "$tabs <param name=\"ImageNumber\" value=\"$imgnum\">\r\n");
}
fputs_wrapper($toc, "$tabs </object>\r\n");
fputs_wrapper($index, "
<li><object type=\"text/sitemap\">
<param name=\"Local\" value=\"".substr($FANCY_PATH, 4)."\\$local\">
<param name=\"Name\" value=\"$name\">
</object></li>
");
} // mapAndIndex() function end
// Process a file, and find any links need to be presented in tree
function findDeeperLinks ($filename, $toc, $index)
{
global $HTML_PATH;
$contents = oneLiner("$HTML_PATH/$filename");
// Find all sublinks
if (preg_match_all("!<DT\\s*><A\\s+HREF=\"(([\\w\\.-]+\\.)+html)(\\#[\\w\\.-]+)?\"\\s*>([^<]*)</A\\s*>!U", $contents, $matches, PREG_SET_ORDER)) {
// Print out the file informations for all the links
fputs_wrapper($toc, "\n <ul>");
foreach ($matches as $onematch) {
$param["html"] = $onematch[1];
if (!empty($onematch[3])) {
$param["html"] .= $onematch[3];
}
$param["title"] = strip_tags($onematch[4]);
mapAndIndex($param["title"], $param["html"], " ", $toc, $index);
}
fputs_wrapper($toc, " </ul>\n");
} else {
echo "no deeper TOC info found in $filename\n";
}
} // findDeeperLinks() function end
?>

131
docs/chm/make_chm_fancy.php Executable file
View File

@@ -0,0 +1,131 @@
<?php
/*
PLEASE DO NOT MAKE ANY MAJOR MODIFICATIONS TO THIS CODE!
There is a new script collection on the way to replace
these scripts. Please be patient while it will be ready
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
$original_index = "index.html";
// How many files were processed
$counter = 0;
// Open the directory, and do the work on all HTML files
$handle = opendir($HTML_PATH);
while (false !== ($filename = readdir($handle))) {
if (strpos($filename, ".html") && ($filename != "fancy-index.html")) {
fancy_design($filename);
}
}
closedir($handle);
// Look for CHM index file (snap-downloader, cvs-usr with/without lang-support)
if (false == ($content = oneLiner("$LANGUAGE/make_chm_index_$LANGUAGE.html", true))) {
$content = oneLiner("en/make_chm_index_en.html", true);
}
// 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);
$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", "$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 $FANCY_PATH directory: $counter\n\n";
/***********************************************************************/
/* End of script lines, one main function follows */
/***********************************************************************/
// Convert one file from HTML => fancy HTML
function fancy_design($fname)
{
global $HTML_PATH, $FANCY_PATH, $LANGUAGE, $LANGUAGES, $counter, $original_index, $publication_date;
// Get the contents of the file from $HTML_PATH
$content = oneLiner("$HTML_PATH/$fname", true);
// 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("/&#38;copy;/", "&copy;", $content);
$content = preg_replace("/<A\\s+HREF=\"$original_index#(authors|translators)\"/U", "<A HREF=\"fancy-index.html\"", $content);
$content = preg_replace("|(</TH\\s*></TR\\s*>)|", "\\1<TR><TH COLSPAN=\"3\" ALIGN=\"center\">&nbsp;</TH></TR>", $content);
$content = preg_replace("|(&nbsp;</TD\\s*></TR\\s*>)|", "\\1<TR><TD COLSPAN=\"3\" ALIGN=\"center\">&nbsp;</TD></TR>", $content);
}
// Fix the original manual index to look far better...
elseif ($fname == "$original_index") {
// Find out manual generation date
if (preg_match('|<P\s+CLASS="pubdate"\s*>([\\d-]+)<BR></P\s*>|U', $content, $match)) {
$publication_date = $match[1];
} else {
$publication_date = 'n/a';
}
// Modify the index file to meet our needs
preg_match('|CLASS=\"title\"\\s*><A\\s+NAME=\"manual\"\\s*>(.*)</A\\s*>(.*)</H1|U', $content, $match);
$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">'.$match[2].'</TH></TR><TR><TD COLSPAN="3" ALIGN="center">&nbsp;</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\\s*>).*(</H1)|U", "\\1$match[1]\\2\\3", $content);
$content = preg_replace("|<DT\\s*><B\\s*>(.*)</B\\s*></DT\\s*>|U", "", $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 "$FANCY_PATH/$fname ready...\n";
$counter++;
} // fancy_design() function end
?>

BIN
docs/chm/make_chm_spc.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

57
docs/chm/make_chm_style.css Executable file
View File

@@ -0,0 +1,57 @@
BODY {
FONT-FAMILY: Verdana,arial,helvetica,sans-serif; FONT-SIZE: 10pt
}
TD {
FONT-FAMILY: Verdana,arial,helvetica,sans-serif; FONT-SIZE: 10pt
}
TH {
FONT-FAMILY: Verdana,arial,helvetica,sans-serif; FONT-SIZE: 10pt
}
P {
MARGIN-BOTTOM: 2pt; MARGIN-TOP: 10pt
}
EM {
FONT-STYLE: italic; FONT-WEIGHT: bold
}
UL {
MARGIN-TOP: 10pt
}
OL {
MARGIN-TOP: 10pt
}
PRE {
FONT-FAMILY: "andale mono", "monotype.com", "courier new", monospace; FONT-SIZE: 10pt
}
A.nav {
COLOR: #000066; TEXT-DECORATION: none; FONT-WEIGHT: bold
}
A.nav:hover {
COLOR: #000066; TEXT-DECORATION: underline; FONT-WEIGHT: bold
}
H1 {
COLOR: #000066; FONT-FAMILY: tahoma,arial,helvetica,sans-serif; FONT-SIZE: 18pt; FONT-WEIGHT: bold; MARGIN-BOTTOM: 5pt
}
H2 {
COLOR: #000066; FONT-FAMILY: tahoma,arial,helvetica,sans-serif; FONT-SIZE: 14pt; FONT-WEIGHT: bold; MARGIN-BOTTOM: 5pt
}
H3 {
COLOR: #000066; FONT-FAMILY: tahoma,arial,helvetica,sans-serif; FONT-SIZE: 12pt; FONT-WEIGHT: bold; MARGIN-BOTTOM: 5pt
}
SMALL {
FONT-FAMILY: arial,helvetica,sans-serif; FONT-SIZE: 8.5pt
}
.tableTitle {
FONT-FAMILY: arial,helvetica,sans-serif; FONT-SIZE: 12pt; FONT-WEIGHT: bold
}
.tableExtras {
COLOR: #ffffff; FONT-FAMILY: arial,helvetica,sans-serif; FONT-SIZE: 8.5pt
}
TABLE.warning, TABLE.caution {
border-color : #B22222;
background-color : #EEE8AA;
border-width : 2;
font : bold normal Arial, Helvetica, sans-serif;
margin : 0;
border-spacing : 0px;
}

36
docs/en/make_chm_index_en.html Executable file
View File

@@ -0,0 +1,36 @@
<HTML>
<!-- $Revision$ -->
<HEAD>
<TITLE>Smarty Manual</TITLE>
<META NAME="HTTP_EQUIV" CONTENT="text/html; charset=ISO-8859-1">
<LINK REL="STYLESHEET" HREF="style.css">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" TOPMARGIN="0" LEFTMARGIN="0">
<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">Smarty Manual</TH></TR><TR><TD
COLSPAN="3" ALIGN="center">&nbsp;</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="MIDDLE" WIDTH="100%"><BR>
<P><TABLE ALIGN="CENTER">
<TR><TD ALIGN="CENTER">
<H1 CLASS="title">Smarty Manual</H1>
<DIV CLASS="author">Monte Ohrt</DIV>
<DIV CLASS="author">Andrei Zmievski</DIV>
</TD></TR></TABLE>
<BR><P ALIGN="CENTER">This file was generated: [GENTIME]<BR>
Go to <A HREF="http://smarty.php.net/download-docs.php">http://smarty.php.net/download-docs.php</A>
to get the actual version.</P>
<BR><P CLASS="copyright" ALIGN="CENTER">Copyright &copy; 2001 - 2005 New Digital Group, Inc.</P>
</TD><TD><IMG SRC="spacer.gif" WIDTH="10" HEIGHT="1"></TD></TR>
<TR><TD COLSPAN="3"><DIV CLASS="NAVFOOTER"><TABLE BGCOLOR="#CCCCFF" BORDER="0"
CELLPADDING="0" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#333366">
<TD><IMG SRC="spacer.gif" BORDER="0" WIDTH="1" HEIGHT="1"><BR></TD></TR>
<TR><TD><TABLE WIDTH="100%" BORDER="0" CELLPADDING="3" CELLSPACING="0">
<TR><TD COLSPAN="3">&nbsp;</TD></TR><TR><TD COLSPAN="3" ALIGN="center">&nbsp;</TD>
</TR></TABLE></TD></TR></TABLE></DIV></TD></TR></TABLE>
</BODY></HTML>