cvs: peardoc / .cvsignore Makefile.in /scripts make-chm.php /scripts/htmlhelp context.gif context_pear.js custom.css pear.css pearsmall.gif
search.gif
| From: | anatoly techtonik | Date: | Sun, 13 Mar 2005 17:47:54 +0000 |
| Subject: | cvs: peardoc / .cvsignore Makefile.in /scripts make-chm.php /scripts/htmlhelp context.gif context_pear.js custom.css pear.css pearsmall.gif search.gif |
||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-5661@lists.php.net to get a copy of this message | ||
techtonik Sun Mar 13 12:47:54 2005 EDT
Added files:
/peardoc/scripts/htmlhelp context.gif context_pear.js custom.css
pear.css pearsmall.gif search.gif
/peardoc/scripts make-chm.php
Modified files:
/peardoc .cvsignore Makefile.in
Log:
* Quick dirty hack for building CHM version of PEAR manual
http://cvs.php.net/diff.php/peardoc/.cvsignore?r1=1.4&r2=1.5&ty=u Index: peardoc/.cvsignore diff -u peardoc/.cvsignore:1.4 peardoc/.cvsignore:1.5 --- peardoc/.cvsignore:1.4 Sat Mar 12 15:31:30 2005 +++ peardoc/.cvsignore Sun Mar 13 12:47:52 2005 @@ -1,6 +1,7 @@ *.ced *.dsl *.xsl +chm html pearweb Makefile http://cvs.php.net/diff.php/peardoc/Makefile.in?r1=1.3&r2=1.4&ty=u Index: peardoc/Makefile.in diff -u peardoc/Makefile.in:1.3 peardoc/Makefile.in:1.4 --- peardoc/Makefile.in:1.3 Sat Mar 12 09:19:10 2005 +++ peardoc/Makefile.in Sun Mar 13 12:47:52 2005 @@ -20,7 +20,7 @@ # # -# $Id: Makefile.in,v 1.3 2005/03/12 14:19:10 techtonik Exp $ +# $Id: Makefile.in,v 1.4 2005/03/13 17:47:52 techtonik Exp $ # VPATH=@srcdir@ @@ -62,6 +62,8 @@ html: html/index.html bightml: @MANUAL@.html pearweb: pearweb/index.php +chm: html chm/pear_manual_@LANG@.hhp + mirror-files: $(DIST_FILES) FORCE: @@ -95,6 +97,9 @@ -$(JADE) $(CATALOG) -d $(PEARWEB_STYLESHEET) -V use-output-dir -t sgml $(srcdir)/phpdocxml.dcl manual.xml @PHP@ -Cq $(srcdir)/colorize.php pearweb pearweb +chm/pear_manual_@LANG@.hhp: + @PHP@ -f scripts/make-chm.php + @MANUAL@.txt: @MANUAL@.html lynx -term=vt100 -nolist -dump file:`pwd`/$< > $@ http://cvs.php.net/co.php/peardoc/scripts/htmlhelp/context_pear.js?r=1.1&p=1 Index: peardoc/scripts/htmlhelp/context_pear.js +++ peardoc/scripts/htmlhelp/context_pear.js /** * PEAR Manual - Windows Help Edition * Set of javascript functions for the context menu * * Copyright (c) 2004 Dieter Raber <d.raber@dwhsoft.de> * * This source code is licensed to the PEAR Group <pear.php.net> * for the use in the Windows Help Edition of their manuals. * * If you wish to use the code in a different project, * please contact the author. * */ // global variables var colOn = '#C8DEBD'; var colOff = '#F0F0F0'; var selText = ''; // support for both document.all and DOM, you never know what M$ comes up with... function get_element(sender) { my_element = !document.getElementById ? document.all.sender : document.getElementById(sender); return my_element; } // link highlighting function hover(sender, col) { sender.style.backgroundColor = col; } // display menu function display_context_menu() { hide(); var menuWidth = 210; var menuHeight = 280; var windowWidthVisible = document.body.offsetWidth -20; var windowHeightVisible = document.body.offsetHeight -20; var eventLeft = event.clientX + document.body.scrollLeft; var eventTop = event.clientY + document.body.scrollTop; var theMenu = get_element('context_menu'); //zwischen Fensterkante und Fensterrand nicht genugend Platz fuer Menu if ((event.clientX < menuWidth) && (eventLeft + menuWidth > windowWidthVisible)) { //Menu wird an rechter Kante ausgerichtet, da Event eher in linker Haelfte des Fensters if (event.clientX < windowWidthVisible - event.clientX) { theMenu.style.left = windowWidthVisible + document.body.scrollLeft - menuWidth; } //linke Kante else { theMenu.style.left = document.body.scrollLeft; } } //Menu geht nach links auf else if (event.clientX + menuWidth > windowWidthVisible) { theMenu.style.left = eventLeft - menuWidth; } //Menu geht nach rechts auf else { theMenu.style.left = eventLeft; } if ((event.clientY < menuHeight) && (eventTop + menuHeight > windowHeightVisible)) { if (event.clientY < windowHeightVisible - event.clientY) { theMenu.style.top = windowHeightVisible + document.body.scrollTop - menuHeight; } else { theMenu.style.top = document.body.scrollTop; } //theMenu.style.top = eventTop - menuHeight / 2; } else if (event.clientY + menuHeight > windowHeightVisible) { theMenu.style.top = eventTop - menuHeight; } else { theMenu.style.top = eventTop; } theMenu.style.left = theMenu.style.left; theMenu.style.top = theMenu.style.top; theMenu.style.visibility = 'visible'; return false; } var ieVers = parseInt(navigator.appVersion.substr(navigator.appVersion.indexOf('MSIE ') + 5, 3)); if (ieVers >= 5.5) { document.oncontextmenu = display_context_menu; } // hide menu function hide() { get_element('context_menu').style.visibility = 'hidden'; } function hide_delay() { if (event.button !=2) { setTimeout('hide()', 200); } } var ieVers = parseInt(navigator.appVersion.substr(navigator.appVersion.indexOf('MSIE ') + 5, 3)); if (ieVers >= 5.5) { document.oncontextmenu = display_context_menu; document.onclick = hide_delay; window.onblur = hide_delay; } // internet searches function find(site) { switch(site) { case 'google': url = selText ? 'http://www.google.com/search?q=' + selText : 'http://www.google.com'; break; case 'pear': url = selText ? 'http://pear.php.net/package-search.php?pkg_name=' + selText + '&bool=AND&submit=Search' : 'http://pear.php.net/'; break; case 'dev': url = selText ? 'http://marc.theaimsgroup.com/?l=pear-dev&w=2&r=1&q=b&s=' + selText : 'http://marc.theaimsgroup.com/?l=pear-dev'; break; case 'general': url = selText ? 'http://marc.theaimsgroup.com/?l=pear-general&w=2&r=1&q=b&s=' + selText : 'http://marc.theaimsgroup.com/?l=pear-general'; break; case 'cvs': url = selText ? 'http://marc.theaimsgroup.com/?l=pear-cvs&w=2&r=1&q=b&s=' + selText : 'http://marc.theaimsgroup.com/?l=pear-cvs'; break; case 'alltheweb': url = selText ? 'http://alltheweb.com/search?avkw=fogg&cat=web&cs=utf-8&q=' + selText + '&_sb_lang=pref' : 'http://alltheweb.com'; break; case 'php': url = selText ? 'http://www.php.net/' + selText : 'http://www.php.net'; break; } var ext_window = window.open(url,'pear_chm_help'); ext_window.focus() } function copy_sel() { toClpbrd = tmpText.createTextRange(); toClpbrd.execCommand("Copy"); } function capture_text() { if(document.selection.createRange().text) { if (event.button == 1) { selText = document.selection.createRange().text; tmpText.value = selText; } } return selText; } document.onmouseup = capture_text; http://cvs.php.net/co.php/peardoc/scripts/htmlhelp/custom.css?r=1.1&p=1 Index: peardoc/scripts/htmlhelp/custom.css +++ peardoc/scripts/htmlhelp/custom.css #context_menu { filter:progid:DXImageTransform.Microsoft.Shadow(color='#CCCCCC', Direction=135, Strength=3); width:210px; border:1px solid #CCCCCC; background-color: #F0F0F0; font: 12px Helvetica, Arial, sans-serif; padding: 0px; position: absolute; left:0px; top:0px; visibility: hidden; } #context_pear { width:25px; background-image:url(green.gif); float:left; padding: 200px 3px 30px 3px; border-right:1px solid #999999; background-color: #339900; } #context_logo { width:24px; height:47px; border:none; } #context_func { width:165px; padding:0px; } #context_func p { margin: 0px; width:165px; padding: 2px 0px 2px 5px; color: #000000; clear:left; cursor:hand; } #context_func img { margin: 0px; width:16px; height:16px; float:left; } #context_func hr { margin: 0px; width:165px; color: #CCCCCC; height: 1px; padding:0px; } h4.chm { font-family: verdana,arial,helvetica,sans-serif; font-size: 95%; font-weight: bold; color: #006600; margin-bottom: 0px; margin-top:10px; } body{ overflow:auto; margin:10px; } #pear_logo_title { width:104px; height:50px; border:none; margin:20px; } http://cvs.php.net/co.php/peardoc/scripts/htmlhelp/pear.css?r=1.1&p=1 Index: peardoc/scripts/htmlhelp/pear.css +++ peardoc/scripts/htmlhelp/pear.css body { margin: 5px; padding: 0px; background-color: white; overflow:auto; } body, td, th { font-family: verdana,arial,helvetica,sans-serif; font-size: 90%; } p { font-family: verdana,arial,helvetica,sans-serif; } th.pack { color: #FFFFFF; background: #009933; text-align: right; } th.others { color: #006600; text-align: left; } td.sidebar_left { font-size: 90%; border-right: 1px dashed #ccc; } td.sidebar_right { font-size: 90%; border-left: 1px dashed #ccc; } em { font-weight: bold; font-style: italic; } hr { border: 0px; height: 1px; background-color: #ccc; } submit { border: 0px; } ..newsDate { font-size: 85%; font-style: italic; color: #66cc66; } ..compact { font-family: arial, helvetica, sans-serif; font-size: 90%; } ..menuWhite { font-family: verdana,arial,helvetica,sans-serif; color: #ffffff; }..menuBlack { font-family: verdana,arial,helvetica,sans-serif; text-decoration: none; font-weight: bold; font-size: 75%; color: #000000; } code, pre, tt { font-family: Courier, "Courier New", monospace; font-size: 90%; } pre.php { border-color: black; border-style: dashed; border-width: 1px; background-color: #eeeeee; padding: 5px; } h1 { font-family: verdana,arial,helvetica,sans-serif; font-size: 140%; font-weight: bold; color: #006600; } h2 { font-family: verdana,arial,helvetica,sans-serif; font-size: 125%; font-weight: bold; color: #006600; } h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 110%; font-weight: bold; color: #006600; } small { font-family: verdana,arial,helvetica,sans-serif; font-size: 75%; } a.small { font-family: verdana,arial,helvetica,sans-serif; font-size: 75%; text-decoration: none; } ..tableTitle { font-family: verdana,arial,helvetica,sans-serif; font-weight: bold; } ..tableExtras { font-family: verdana,arial,helvetica,sans-serif; font-size: 85%; color: #FFFFFF; } input { font-family: verdana,arial,helvetica,sans-serif; } textarea { font-family: verdana,arial,helvetica,sans-serif; } input.small, select.small { font-family: verdana,arial,helvetica,sans-serif; font-size: 75%; } textarea.small { font-family: verdana,arial,helvetica,sans-serif; font-size: 75%; } form { margin-bottom : 0; } ..error { font-weight: bold; color: #900; } ..tip { border: 1px solid #00c; color: #006; background: #eef; padding: 8px; } ..listing li { line-height: 200%; } ..indent { margin-left: 20px; } http://cvs.php.net/co.php/peardoc/scripts/make-chm.php?r=1.1&p=1 Index: peardoc/scripts/make-chm.php +++ peardoc/scripts/make-chm.php <?php /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_0.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Dieter Raber <d.raber@dwhsoft.de> | | anatoly techtonik <techtonik@php.net> | +----------------------------------------------------------------------+ $Id: make-chm.php,v 1.1 2005/03/13 17:47:53 techtonik Exp $ */ /** * Compiles PEAR Manual into Windows HTMLHELP format * * CHM compliler is available only on Windows platforms. * But with the help of this script you can build all necessary * files on Unix machine and later transfer them to Windows station * just to execute compiler and fetch resulting *.chm back. * * So the task can be automated without the need in working * toolchain installed on Windows system. * * If script finishes correctly all necessary files will be located * in chm/ directory by default. All you need to do is to copy this * directory to Windows machine and execute: * HHC.EXE pear_manual_en.hhp */ require_once("File/SearchReplace.php"); error_reporting(E_ALL); $cwd = dirname(__FILE__); $lang = "en"; $ind = "$cwd/../html"; // source directory $chmd = "$cwd/../chm"; // path for HH project files (autopurged) $pref = "pear_manual_$lang"; // for path substitutions $outd = "$chmd/$pref"; // path for html output if (!is_dir("$ind") || !file_exists("$ind/index.html")) { die("Error: To build CHM you need compiled PEAR manual in $ind/ directory"); } /** * Delete a file, or a folder and its contents * * @author Aidan Lister <aidan@php.net> * @version 1.0.2 * @param string $dirname Directory to delete * @return bool Returns TRUE on success, FALSE on failure */ function rmdirr($dirname) { // Sanity check if (!file_exists($dirname)) { return false; } // Simple delete for a file if (is_file($dirname)) { return unlink($dirname); } // Loop through the folder $dir = dir($dirname); while (false !== $entry = $dir->read()) { // Skip pointers if ($entry == '.' || $entry == '..') { continue; } // Recurse rmdirr("$dirname/$entry"); } // Clean up $dir->close(); return rmdir($dirname); } /** * Copy a file, or recursively copy a folder and its contents * * @author Aidan Lister <aidan@php.net> * @version 1.0.1 * @param string $source Source path * @param string $dest Destination path * @return bool Returns TRUE on success, FALSE on failure */ function copyr($source, $dest) { // Simple copy for a file if (is_file($source)) { return copy($source, $dest); } // Make destination directory if (!is_dir($dest)) { mkdir($dest); } // Loop through the folder $dir = dir($source); while (false !== $entry = $dir->read()) { // Skip pointers if ($entry == '.' || $entry == '..') { continue; } // Deep copy directories if ($dest !== "$source/$entry") { copyr("$source/$entry", "$dest/$entry"); } } // Clean up $dir->close(); return true; } echo "Creating directories...\n"; // create target directory (chm/) and copy html files there if (!is_dir($chmd)) { mkdir($chmd); } if (is_dir($outd)) { rmdirr($outd); } echo "Copying files...\n"; copyr($ind, $outd); echo "Filtering...\n"; foreach (glob("$cwd/htmlhelp/*") as $suppfile) { copy($suppfile, "$outd/".basename($suppfile)); } $thtmlfiles = glob("$outd/*.html"); $find_rx = array(); $replace = array(); $find_rx[] = '|</HEAD|ims'; $replace[] = ' <link rel="stylesheet" type="text/css" href="pear.css" /> <link rel="stylesheet" type="text/css" href="custom.css" /> <script type="text/javascript" src="context_pear.js"></script> </HEAD'; $find_rx[] = '|</BODY|is'; $replace[] = ' <div id="context_menu"> <input type="hidden" id="tmpText"> <div id="context_pear"> <img src="context.gif" id="context_logo"> </div> <div id="context_func"> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="history.back(); hide()">Back</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="history.forward(); hide()">Forward</p> <hr /> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" id="copy" onclick="copy_sel(); hide()">Copy</p> <hr /> <img src="search.gif" /> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find(\'pear\'); hide()">PEAR Packages</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find(\'dev\'); hide()">Developer Mailing Lists</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find(\'general\'); hide()">General Mailing List</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find(\'cvs\'); hide()">CVS Commits Mailing List</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find(\'php\'); hide()">PHP Manual</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find(\'google\'); hide()">Google</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find(\'alltheweb\'); hide()">AllTheWeb</p> <hr /> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="window.print(); hide()">Print</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="location.reload(); hide()">Refresh</p> </div> </div> </BODY'; $sr = &new File_SearchReplace( $find_rx, $replace, $thtmlfiles ); $sr->setSearchFunction("preg"); $sr->doSearch(); echo "\nFilter replacements: " . $sr->occurences." ".$sr->last_error; // pull date, copyright from original index.html $index = file_get_contents("$ind/index.html"); preg_match("!pubdate\".*?>(.+?)<!is", $index, $matches); // $matches[1] is Wed Mar 2 20:31:52 JST 2005 list($dw, $m, $d, $time, $l, $Y) = sscanf($matches[1], "%s %s %d %s %s %s"); echo "\nPubdate: " . $date = date("d-m-Y", strtotime("$dw, $d $m $Y $time $l")); preg_match("!©[^<]+!is", $index, $matches); $copy = $matches[0]; echo "\nWriting index..."; $now = date("d-m-Y"); $index_template = <<<DOC <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> PEAR Manual </title> <meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.76b+" /> <meta http-equiv="Content-type" content="text/html; charset=ISO-8859-1" /> <link rel="NEXT" title="Preface" href="preface.html" /> <link rel="stylesheet" type="text/css" href="pear.css" /> <link rel="stylesheet" type="text/css" href="custom.css" /> <script type="text/javascript" src="context_pear.js"></script> </head> <body class="book" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084" alink="#0000FF"> <div style="width:100%; background-color:#339900;"> <a href="http://www.pear.php.net"><img src="pearsmall.gif" id="pear_logo_title" /></a> </div> <div class="BOOK"> <a name="guide" id="guide"></a> <div class="TITLEPAGE"> <h1 class="title"> <a name="guide" id="guide">PEAR Manual</a> </h1> <!-- <div class="author"> Martin Jansen </div> <div class="author"> Tomas V.V. Cox </div> <div class="author"> Alexander Merz </div> --> <span class="collab"><span class="collabname"> <a href="authors.html">List of authors</a> </span><br/></span> <h2 class="EDITEDBY"> Edited by </h2> <div class="editor"> Martin Jansen </div> <div class="editor"> Alexander Merz </div> <p class="pubdate"> $date </p> <h4 class="chm">Windows Help File Edition</h4> <p>Dieter Raber<br /> Anatoly Techtonik<br /> $now</p> <p class="copyright"> <a href="copyright.html">Copyright</a> $copy </p> </div> </div> <div id="context_menu"> <input type="hidden" id="tmpText"/> <div id="context_pear"> <img src="context.gif" id="context_logo"/> </div> <div id="context_func"> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="history.back(); hide()">Back</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="history.forward(); hide()">Forward</p> <hr /> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" id="copy" onclick="copy_sel(); hide()">Copy</p> <hr /> <img src="search.gif" /> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find('pear'); hide()">PEAR Packages</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find('dev'); hide()">Developer Mailing Lists</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find('general'); hide()">General Mailing List</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find('cvs'); hide()">CVS Commits Mailing List</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find('php'); hide()">PHP Manual</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find('google'); hide()">Google</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find('alltheweb'); hide()">AllTheWeb</p> <hr /> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="window.print(); hide()">Print</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="location.reload(); hide()">Refresh</p> </div> </div> </body> </html> DOC; $f = fopen("$outd/index.html", "w"); fwrite($f, $index_template); fclose($f); $hhp_template = "[OPTIONS] Compatibility=1.1 or later Compiled file=pear_manual_$lang.chm Default topic=$pref/index.html Title=PEAR Manual Default Window=Main Full-text search=Yes Enhanced decompilation=Yes [FILES] "; $hhp_template .= implode(" ", str_replace("$chmd/", "", glob("$outd/*"))); $hhp_template .= ' [WINDOWS] Main="PEAR Manual","pear_manual_'.$lang.'.hhc","pear_manual_'.$lang.'.hhk","'.$pref.'/index.html","'.$pref.'/index.html",,,,,0x61560,220,0x306e,[3,3,664,487],0xb0000,,,,,0, '; echo " .1. "; $f = fopen("$chmd/pear_manual_$lang.hhp", "w"); fwrite($f, $hhp_template); fclose($f); echo "\nWriting table of contents..."; // Building TOC // extract TOC from original index.html preg_match("!<dl\s*>.*</dl\s*>!is", $index, $matches); // print_r($matches); $search = array(); $replace = array(); $search[] = "!<(/?)DL\s*>!sm"; $replace[] = "\n".'<${1}ul>'."\n"; $search[] = "!<(/?)DD\s*>!sm"; $replace[] = '<!-- $1 .-->'; $search[] = "!<(/?)DT\s*>!sm"; $replace[] = '<${1}li>'; $search[] = "!<li><B.*?</li>!sm"; $replace[] = ''; // Strip "Table of contents" label $search[] = "!>[^<]*<A\s+HREF=\"(.+?)\"\s*>(.+?)</A\s*>!sme"; $replace[] = "'> <object type=\"text/sitemap\"> <param name=\"Local\" value=\"$pref/$1\"/> <param name=\"Name\" value=\"'.preg_replace('!\s+!sm', ' ', strip_tags('$2')).'\"/> </object>'"; $toc = preg_replace($search, $replace, $matches[0]); // echo $toc; $f = fopen("$chmd/pear_manual_$lang.hhc", "w"); fwrite($f, '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML> <HEAD></HEAD> <BODY> '); fwrite($f, $toc); fwrite($f, " </BODY> </HTML> "); fclose($f); // Build HHK $hhkvalues = array(); foreach ($thtmlfiles as $hfile) { // echo $hfile; $f = fopen($hfile, "r"); $text = fread($f, 2048); fclose($f); preg_match("!<TITLE\s*>(.*?)<!is", $text, $match); if (isset($match[1])) { $fname = basename($hfile); $title = preg_replace("!\s{2,}!ms", " ", trim(str_replace(array(" ", "()"), "", $match[1]))); $title = preg_replace("!(\S+?)(->|::)(\S+)!", "$3 ($1)", $title); if (strlen($title) > 0 && $title{0} !== '-' && $title{0} !== '{' && $title{0} !== '&') { $hhkvalues[0][] = $fname; $hhkvalues[1][] = $title; } } } array_multisort($hhkvalues[1], SORT_ASC, $hhkvalues[0]); $fhk = fopen("$chmd/pear_manual_$lang.hhk", "w"); fwrite($fhk, '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML> <HEAD></HEAD> <BODY> <UL> '); foreach($hhkvalues[0] as $hk => $hv) { fwrite($fhk, " <li><object type=\"text/sitemap\"> <param name=\"Name\" value=\"".$hhkvalues[1][$hk]."\"/> <param name=\"Local\" value=\"$pref/$hv\"/> </object></li> "); } fwrite($fhk, " </UL> </BODY> </HTML> "); fclose($fhk); echo "Done.\n"; echo "\nNow you can follow into \"$chmd\" directory and launch MS HTMLHELP compiler to build CHM"; echo "\n\n HHC.EXE $pref.hhp\n"; ?>
http://cvs.php.net/diff.php/peardoc/.cvsignore?r1=1.4&r2=1.5&ty=u Index: peardoc/.cvsignore diff -u peardoc/.cvsignore:1.4 peardoc/.cvsignore:1.5 --- peardoc/.cvsignore:1.4 Sat Mar 12 15:31:30 2005 +++ peardoc/.cvsignore Sun Mar 13 12:47:52 2005 @@ -1,6 +1,7 @@ *.ced *.dsl *.xsl +chm html pearweb Makefile http://cvs.php.net/diff.php/peardoc/Makefile.in?r1=1.3&r2=1.4&ty=u Index: peardoc/Makefile.in diff -u peardoc/Makefile.in:1.3 peardoc/Makefile.in:1.4 --- peardoc/Makefile.in:1.3 Sat Mar 12 09:19:10 2005 +++ peardoc/Makefile.in Sun Mar 13 12:47:52 2005 @@ -20,7 +20,7 @@ # # -# $Id: Makefile.in,v 1.3 2005/03/12 14:19:10 techtonik Exp $ +# $Id: Makefile.in,v 1.4 2005/03/13 17:47:52 techtonik Exp $ # VPATH=@srcdir@ @@ -62,6 +62,8 @@ html: html/index.html bightml: @MANUAL@.html pearweb: pearweb/index.php +chm: html chm/pear_manual_@LANG@.hhp + mirror-files: $(DIST_FILES) FORCE: @@ -95,6 +97,9 @@ -$(JADE) $(CATALOG) -d $(PEARWEB_STYLESHEET) -V use-output-dir -t sgml $(srcdir)/phpdocxml.dcl manual.xml @PHP@ -Cq $(srcdir)/colorize.php pearweb pearweb +chm/pear_manual_@LANG@.hhp: + @PHP@ -f scripts/make-chm.php + @MANUAL@.txt: @MANUAL@.html lynx -term=vt100 -nolist -dump file:`pwd`/$< > $@ http://cvs.php.net/co.php/peardoc/scripts/htmlhelp/context_pear.js?r=1.1&p=1 Index: peardoc/scripts/htmlhelp/context_pear.js +++ peardoc/scripts/htmlhelp/context_pear.js /** * PEAR Manual - Windows Help Edition * Set of javascript functions for the context menu * * Copyright (c) 2004 Dieter Raber <d.raber@dwhsoft.de> * * This source code is licensed to the PEAR Group <pear.php.net> * for the use in the Windows Help Edition of their manuals. * * If you wish to use the code in a different project, * please contact the author. * */ // global variables var colOn = '#C8DEBD'; var colOff = '#F0F0F0'; var selText = ''; // support for both document.all and DOM, you never know what M$ comes up with... function get_element(sender) { my_element = !document.getElementById ? document.all.sender : document.getElementById(sender); return my_element; } // link highlighting function hover(sender, col) { sender.style.backgroundColor = col; } // display menu function display_context_menu() { hide(); var menuWidth = 210; var menuHeight = 280; var windowWidthVisible = document.body.offsetWidth -20; var windowHeightVisible = document.body.offsetHeight -20; var eventLeft = event.clientX + document.body.scrollLeft; var eventTop = event.clientY + document.body.scrollTop; var theMenu = get_element('context_menu'); //zwischen Fensterkante und Fensterrand nicht genugend Platz fuer Menu if ((event.clientX < menuWidth) && (eventLeft + menuWidth > windowWidthVisible)) { //Menu wird an rechter Kante ausgerichtet, da Event eher in linker Haelfte des Fensters if (event.clientX < windowWidthVisible - event.clientX) { theMenu.style.left = windowWidthVisible + document.body.scrollLeft - menuWidth; } //linke Kante else { theMenu.style.left = document.body.scrollLeft; } } //Menu geht nach links auf else if (event.clientX + menuWidth > windowWidthVisible) { theMenu.style.left = eventLeft - menuWidth; } //Menu geht nach rechts auf else { theMenu.style.left = eventLeft; } if ((event.clientY < menuHeight) && (eventTop + menuHeight > windowHeightVisible)) { if (event.clientY < windowHeightVisible - event.clientY) { theMenu.style.top = windowHeightVisible + document.body.scrollTop - menuHeight; } else { theMenu.style.top = document.body.scrollTop; } //theMenu.style.top = eventTop - menuHeight / 2; } else if (event.clientY + menuHeight > windowHeightVisible) { theMenu.style.top = eventTop - menuHeight; } else { theMenu.style.top = eventTop; } theMenu.style.left = theMenu.style.left; theMenu.style.top = theMenu.style.top; theMenu.style.visibility = 'visible'; return false; } var ieVers = parseInt(navigator.appVersion.substr(navigator.appVersion.indexOf('MSIE ') + 5, 3)); if (ieVers >= 5.5) { document.oncontextmenu = display_context_menu; } // hide menu function hide() { get_element('context_menu').style.visibility = 'hidden'; } function hide_delay() { if (event.button !=2) { setTimeout('hide()', 200); } } var ieVers = parseInt(navigator.appVersion.substr(navigator.appVersion.indexOf('MSIE ') + 5, 3)); if (ieVers >= 5.5) { document.oncontextmenu = display_context_menu; document.onclick = hide_delay; window.onblur = hide_delay; } // internet searches function find(site) { switch(site) { case 'google': url = selText ? 'http://www.google.com/search?q=' + selText : 'http://www.google.com'; break; case 'pear': url = selText ? 'http://pear.php.net/package-search.php?pkg_name=' + selText + '&bool=AND&submit=Search' : 'http://pear.php.net/'; break; case 'dev': url = selText ? 'http://marc.theaimsgroup.com/?l=pear-dev&w=2&r=1&q=b&s=' + selText : 'http://marc.theaimsgroup.com/?l=pear-dev'; break; case 'general': url = selText ? 'http://marc.theaimsgroup.com/?l=pear-general&w=2&r=1&q=b&s=' + selText : 'http://marc.theaimsgroup.com/?l=pear-general'; break; case 'cvs': url = selText ? 'http://marc.theaimsgroup.com/?l=pear-cvs&w=2&r=1&q=b&s=' + selText : 'http://marc.theaimsgroup.com/?l=pear-cvs'; break; case 'alltheweb': url = selText ? 'http://alltheweb.com/search?avkw=fogg&cat=web&cs=utf-8&q=' + selText + '&_sb_lang=pref' : 'http://alltheweb.com'; break; case 'php': url = selText ? 'http://www.php.net/' + selText : 'http://www.php.net'; break; } var ext_window = window.open(url,'pear_chm_help'); ext_window.focus() } function copy_sel() { toClpbrd = tmpText.createTextRange(); toClpbrd.execCommand("Copy"); } function capture_text() { if(document.selection.createRange().text) { if (event.button == 1) { selText = document.selection.createRange().text; tmpText.value = selText; } } return selText; } document.onmouseup = capture_text; http://cvs.php.net/co.php/peardoc/scripts/htmlhelp/custom.css?r=1.1&p=1 Index: peardoc/scripts/htmlhelp/custom.css +++ peardoc/scripts/htmlhelp/custom.css #context_menu { filter:progid:DXImageTransform.Microsoft.Shadow(color='#CCCCCC', Direction=135, Strength=3); width:210px; border:1px solid #CCCCCC; background-color: #F0F0F0; font: 12px Helvetica, Arial, sans-serif; padding: 0px; position: absolute; left:0px; top:0px; visibility: hidden; } #context_pear { width:25px; background-image:url(green.gif); float:left; padding: 200px 3px 30px 3px; border-right:1px solid #999999; background-color: #339900; } #context_logo { width:24px; height:47px; border:none; } #context_func { width:165px; padding:0px; } #context_func p { margin: 0px; width:165px; padding: 2px 0px 2px 5px; color: #000000; clear:left; cursor:hand; } #context_func img { margin: 0px; width:16px; height:16px; float:left; } #context_func hr { margin: 0px; width:165px; color: #CCCCCC; height: 1px; padding:0px; } h4.chm { font-family: verdana,arial,helvetica,sans-serif; font-size: 95%; font-weight: bold; color: #006600; margin-bottom: 0px; margin-top:10px; } body{ overflow:auto; margin:10px; } #pear_logo_title { width:104px; height:50px; border:none; margin:20px; } http://cvs.php.net/co.php/peardoc/scripts/htmlhelp/pear.css?r=1.1&p=1 Index: peardoc/scripts/htmlhelp/pear.css +++ peardoc/scripts/htmlhelp/pear.css body { margin: 5px; padding: 0px; background-color: white; overflow:auto; } body, td, th { font-family: verdana,arial,helvetica,sans-serif; font-size: 90%; } p { font-family: verdana,arial,helvetica,sans-serif; } th.pack { color: #FFFFFF; background: #009933; text-align: right; } th.others { color: #006600; text-align: left; } td.sidebar_left { font-size: 90%; border-right: 1px dashed #ccc; } td.sidebar_right { font-size: 90%; border-left: 1px dashed #ccc; } em { font-weight: bold; font-style: italic; } hr { border: 0px; height: 1px; background-color: #ccc; } submit { border: 0px; } ..newsDate { font-size: 85%; font-style: italic; color: #66cc66; } ..compact { font-family: arial, helvetica, sans-serif; font-size: 90%; } ..menuWhite { font-family: verdana,arial,helvetica,sans-serif; color: #ffffff; }..menuBlack { font-family: verdana,arial,helvetica,sans-serif; text-decoration: none; font-weight: bold; font-size: 75%; color: #000000; } code, pre, tt { font-family: Courier, "Courier New", monospace; font-size: 90%; } pre.php { border-color: black; border-style: dashed; border-width: 1px; background-color: #eeeeee; padding: 5px; } h1 { font-family: verdana,arial,helvetica,sans-serif; font-size: 140%; font-weight: bold; color: #006600; } h2 { font-family: verdana,arial,helvetica,sans-serif; font-size: 125%; font-weight: bold; color: #006600; } h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 110%; font-weight: bold; color: #006600; } small { font-family: verdana,arial,helvetica,sans-serif; font-size: 75%; } a.small { font-family: verdana,arial,helvetica,sans-serif; font-size: 75%; text-decoration: none; } ..tableTitle { font-family: verdana,arial,helvetica,sans-serif; font-weight: bold; } ..tableExtras { font-family: verdana,arial,helvetica,sans-serif; font-size: 85%; color: #FFFFFF; } input { font-family: verdana,arial,helvetica,sans-serif; } textarea { font-family: verdana,arial,helvetica,sans-serif; } input.small, select.small { font-family: verdana,arial,helvetica,sans-serif; font-size: 75%; } textarea.small { font-family: verdana,arial,helvetica,sans-serif; font-size: 75%; } form { margin-bottom : 0; } ..error { font-weight: bold; color: #900; } ..tip { border: 1px solid #00c; color: #006; background: #eef; padding: 8px; } ..listing li { line-height: 200%; } ..indent { margin-left: 20px; } http://cvs.php.net/co.php/peardoc/scripts/make-chm.php?r=1.1&p=1 Index: peardoc/scripts/make-chm.php +++ peardoc/scripts/make-chm.php <?php /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2004 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_0.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Dieter Raber <d.raber@dwhsoft.de> | | anatoly techtonik <techtonik@php.net> | +----------------------------------------------------------------------+ $Id: make-chm.php,v 1.1 2005/03/13 17:47:53 techtonik Exp $ */ /** * Compiles PEAR Manual into Windows HTMLHELP format * * CHM compliler is available only on Windows platforms. * But with the help of this script you can build all necessary * files on Unix machine and later transfer them to Windows station * just to execute compiler and fetch resulting *.chm back. * * So the task can be automated without the need in working * toolchain installed on Windows system. * * If script finishes correctly all necessary files will be located * in chm/ directory by default. All you need to do is to copy this * directory to Windows machine and execute: * HHC.EXE pear_manual_en.hhp */ require_once("File/SearchReplace.php"); error_reporting(E_ALL); $cwd = dirname(__FILE__); $lang = "en"; $ind = "$cwd/../html"; // source directory $chmd = "$cwd/../chm"; // path for HH project files (autopurged) $pref = "pear_manual_$lang"; // for path substitutions $outd = "$chmd/$pref"; // path for html output if (!is_dir("$ind") || !file_exists("$ind/index.html")) { die("Error: To build CHM you need compiled PEAR manual in $ind/ directory"); } /** * Delete a file, or a folder and its contents * * @author Aidan Lister <aidan@php.net> * @version 1.0.2 * @param string $dirname Directory to delete * @return bool Returns TRUE on success, FALSE on failure */ function rmdirr($dirname) { // Sanity check if (!file_exists($dirname)) { return false; } // Simple delete for a file if (is_file($dirname)) { return unlink($dirname); } // Loop through the folder $dir = dir($dirname); while (false !== $entry = $dir->read()) { // Skip pointers if ($entry == '.' || $entry == '..') { continue; } // Recurse rmdirr("$dirname/$entry"); } // Clean up $dir->close(); return rmdir($dirname); } /** * Copy a file, or recursively copy a folder and its contents * * @author Aidan Lister <aidan@php.net> * @version 1.0.1 * @param string $source Source path * @param string $dest Destination path * @return bool Returns TRUE on success, FALSE on failure */ function copyr($source, $dest) { // Simple copy for a file if (is_file($source)) { return copy($source, $dest); } // Make destination directory if (!is_dir($dest)) { mkdir($dest); } // Loop through the folder $dir = dir($source); while (false !== $entry = $dir->read()) { // Skip pointers if ($entry == '.' || $entry == '..') { continue; } // Deep copy directories if ($dest !== "$source/$entry") { copyr("$source/$entry", "$dest/$entry"); } } // Clean up $dir->close(); return true; } echo "Creating directories...\n"; // create target directory (chm/) and copy html files there if (!is_dir($chmd)) { mkdir($chmd); } if (is_dir($outd)) { rmdirr($outd); } echo "Copying files...\n"; copyr($ind, $outd); echo "Filtering...\n"; foreach (glob("$cwd/htmlhelp/*") as $suppfile) { copy($suppfile, "$outd/".basename($suppfile)); } $thtmlfiles = glob("$outd/*.html"); $find_rx = array(); $replace = array(); $find_rx[] = '|</HEAD|ims'; $replace[] = ' <link rel="stylesheet" type="text/css" href="pear.css" /> <link rel="stylesheet" type="text/css" href="custom.css" /> <script type="text/javascript" src="context_pear.js"></script> </HEAD'; $find_rx[] = '|</BODY|is'; $replace[] = ' <div id="context_menu"> <input type="hidden" id="tmpText"> <div id="context_pear"> <img src="context.gif" id="context_logo"> </div> <div id="context_func"> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="history.back(); hide()">Back</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="history.forward(); hide()">Forward</p> <hr /> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" id="copy" onclick="copy_sel(); hide()">Copy</p> <hr /> <img src="search.gif" /> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find(\'pear\'); hide()">PEAR Packages</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find(\'dev\'); hide()">Developer Mailing Lists</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find(\'general\'); hide()">General Mailing List</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find(\'cvs\'); hide()">CVS Commits Mailing List</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find(\'php\'); hide()">PHP Manual</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find(\'google\'); hide()">Google</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find(\'alltheweb\'); hide()">AllTheWeb</p> <hr /> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="window.print(); hide()">Print</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="location.reload(); hide()">Refresh</p> </div> </div> </BODY'; $sr = &new File_SearchReplace( $find_rx, $replace, $thtmlfiles ); $sr->setSearchFunction("preg"); $sr->doSearch(); echo "\nFilter replacements: " . $sr->occurences." ".$sr->last_error; // pull date, copyright from original index.html $index = file_get_contents("$ind/index.html"); preg_match("!pubdate\".*?>(.+?)<!is", $index, $matches); // $matches[1] is Wed Mar 2 20:31:52 JST 2005 list($dw, $m, $d, $time, $l, $Y) = sscanf($matches[1], "%s %s %d %s %s %s"); echo "\nPubdate: " . $date = date("d-m-Y", strtotime("$dw, $d $m $Y $time $l")); preg_match("!©[^<]+!is", $index, $matches); $copy = $matches[0]; echo "\nWriting index..."; $now = date("d-m-Y"); $index_template = <<<DOC <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> PEAR Manual </title> <meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.76b+" /> <meta http-equiv="Content-type" content="text/html; charset=ISO-8859-1" /> <link rel="NEXT" title="Preface" href="preface.html" /> <link rel="stylesheet" type="text/css" href="pear.css" /> <link rel="stylesheet" type="text/css" href="custom.css" /> <script type="text/javascript" src="context_pear.js"></script> </head> <body class="book" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084" alink="#0000FF"> <div style="width:100%; background-color:#339900;"> <a href="http://www.pear.php.net"><img src="pearsmall.gif" id="pear_logo_title" /></a> </div> <div class="BOOK"> <a name="guide" id="guide"></a> <div class="TITLEPAGE"> <h1 class="title"> <a name="guide" id="guide">PEAR Manual</a> </h1> <!-- <div class="author"> Martin Jansen </div> <div class="author"> Tomas V.V. Cox </div> <div class="author"> Alexander Merz </div> --> <span class="collab"><span class="collabname"> <a href="authors.html">List of authors</a> </span><br/></span> <h2 class="EDITEDBY"> Edited by </h2> <div class="editor"> Martin Jansen </div> <div class="editor"> Alexander Merz </div> <p class="pubdate"> $date </p> <h4 class="chm">Windows Help File Edition</h4> <p>Dieter Raber<br /> Anatoly Techtonik<br /> $now</p> <p class="copyright"> <a href="copyright.html">Copyright</a> $copy </p> </div> </div> <div id="context_menu"> <input type="hidden" id="tmpText"/> <div id="context_pear"> <img src="context.gif" id="context_logo"/> </div> <div id="context_func"> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="history.back(); hide()">Back</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="history.forward(); hide()">Forward</p> <hr /> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" id="copy" onclick="copy_sel(); hide()">Copy</p> <hr /> <img src="search.gif" /> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find('pear'); hide()">PEAR Packages</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find('dev'); hide()">Developer Mailing Lists</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find('general'); hide()">General Mailing List</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find('cvs'); hide()">CVS Commits Mailing List</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find('php'); hide()">PHP Manual</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find('google'); hide()">Google</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="find('alltheweb'); hide()">AllTheWeb</p> <hr /> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="window.print(); hide()">Print</p> <p onmouseover="hover(this,colOn)" onmouseout="hover(this,colOff)" onclick="location.reload(); hide()">Refresh</p> </div> </div> </body> </html> DOC; $f = fopen("$outd/index.html", "w"); fwrite($f, $index_template); fclose($f); $hhp_template = "[OPTIONS] Compatibility=1.1 or later Compiled file=pear_manual_$lang.chm Default topic=$pref/index.html Title=PEAR Manual Default Window=Main Full-text search=Yes Enhanced decompilation=Yes [FILES] "; $hhp_template .= implode(" ", str_replace("$chmd/", "", glob("$outd/*"))); $hhp_template .= ' [WINDOWS] Main="PEAR Manual","pear_manual_'.$lang.'.hhc","pear_manual_'.$lang.'.hhk","'.$pref.'/index.html","'.$pref.'/index.html",,,,,0x61560,220,0x306e,[3,3,664,487],0xb0000,,,,,0, '; echo " .1. "; $f = fopen("$chmd/pear_manual_$lang.hhp", "w"); fwrite($f, $hhp_template); fclose($f); echo "\nWriting table of contents..."; // Building TOC // extract TOC from original index.html preg_match("!<dl\s*>.*</dl\s*>!is", $index, $matches); // print_r($matches); $search = array(); $replace = array(); $search[] = "!<(/?)DL\s*>!sm"; $replace[] = "\n".'<${1}ul>'."\n"; $search[] = "!<(/?)DD\s*>!sm"; $replace[] = '<!-- $1 .-->'; $search[] = "!<(/?)DT\s*>!sm"; $replace[] = '<${1}li>'; $search[] = "!<li><B.*?</li>!sm"; $replace[] = ''; // Strip "Table of contents" label $search[] = "!>[^<]*<A\s+HREF=\"(.+?)\"\s*>(.+?)</A\s*>!sme"; $replace[] = "'> <object type=\"text/sitemap\"> <param name=\"Local\" value=\"$pref/$1\"/> <param name=\"Name\" value=\"'.preg_replace('!\s+!sm', ' ', strip_tags('$2')).'\"/> </object>'"; $toc = preg_replace($search, $replace, $matches[0]); // echo $toc; $f = fopen("$chmd/pear_manual_$lang.hhc", "w"); fwrite($f, '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML> <HEAD></HEAD> <BODY> '); fwrite($f, $toc); fwrite($f, " </BODY> </HTML> "); fclose($f); // Build HHK $hhkvalues = array(); foreach ($thtmlfiles as $hfile) { // echo $hfile; $f = fopen($hfile, "r"); $text = fread($f, 2048); fclose($f); preg_match("!<TITLE\s*>(.*?)<!is", $text, $match); if (isset($match[1])) { $fname = basename($hfile); $title = preg_replace("!\s{2,}!ms", " ", trim(str_replace(array(" ", "()"), "", $match[1]))); $title = preg_replace("!(\S+?)(->|::)(\S+)!", "$3 ($1)", $title); if (strlen($title) > 0 && $title{0} !== '-' && $title{0} !== '{' && $title{0} !== '&') { $hhkvalues[0][] = $fname; $hhkvalues[1][] = $title; } } } array_multisort($hhkvalues[1], SORT_ASC, $hhkvalues[0]); $fhk = fopen("$chmd/pear_manual_$lang.hhk", "w"); fwrite($fhk, '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML> <HEAD></HEAD> <BODY> <UL> '); foreach($hhkvalues[0] as $hk => $hv) { fwrite($fhk, " <li><object type=\"text/sitemap\"> <param name=\"Name\" value=\"".$hhkvalues[1][$hk]."\"/> <param name=\"Local\" value=\"$pref/$hv\"/> </object></li> "); } fwrite($fhk, " </UL> </BODY> </HTML> "); fclose($fhk); echo "Done.\n"; echo "\nNow you can follow into \"$chmd\" directory and launch MS HTMLHELP compiler to build CHM"; echo "\n\n HHC.EXE $pref.hhp\n"; ?>