PHPmanual.chm

From: Date: Tue, 20 Jun 2000 10:04:36 +0000
Subject: PHPmanual.chm
Groups: php.windows 
Request: Send a blank email to php-windows+get-547@lists.php.net to get a copy of this message
Hello all, This is two scripts to create index and table_of_contents for m$ HTMLhelp project from PHPmanual snapshots ( http://snaps.php.net/manual ). Not so good algorithms, but they works. usage: -- cd php_manual_snapshot php.exe -q toc.php > toc.hhc php.exe -q index.php > index.hhk hhc.exe PHP.hhp and then you can use PHP.chm as context-sensitive help file ------------- OOOOOPSSS....... attachments not allowed in this maillist? not a problem. ---8<----------8<------------ toc.php ---8<---------- <? function parse($fname,$title="",&$files) { $f=fopen($fname,"r"); if (!$f){ print "Error opening $fname!!!!!!"; return 0; } $i=0;$href="";$list="";$toc=0;$files[]=$fname; while(!feof($f)){ $s=fgets($f,255); if($title=="" && preg_match("/>(.*)<\/TITLE/i",$s,$a)){ $title=$a[1];$list[$i++]=$title;$list[$i++]=$fname; }; if($href!="" && preg_match("/>(.*)<\//i",$s,$a)){ if(!in_array($href,&$files)){ $p=parse($href,$a[1],&$files); if($p){ $list[$i++]=$a[1];$list[$i++]=$href.($link==""?"":"#".$link);$list[$i++]=$p; } }; if($href==$fname || !$p){ $list[$i++]=$a[1];$list[$i++]=$href.($link==""?"":"#".$link); }; $href=""; }; if(preg_match("/CLASS=\"TOC\"/i",$s))$toc=1; if($toc==1 && preg_match("/HREF=\"([\.|\w|-]*\.html)#?(.*)\"/i",$s,$a)){ $href=$a[1];$link=$a[2]; }; if($toc==1 && preg_match("/<\/DIV/i",$s)){ $toc=0;fclose($f);return $list; } }; fclose($f);return false; }; function item($item,$tabs="") { $i=0;$li=""; for($i=0;$i<count($item);){ $li .="\t$tabs<LI><OBJECT type=\"text/sitemap\">\n" ."\t$tabs <param name=\"Name\" value=\"".$item[$i++]."\">\n" ."\t$tabs <param name=\"Local\" value=\"".$item[$i++]."\">\n" ."\t$tabs </OBJECT>\n"; if(is_array($item[$i]))$li=$li.$tabs."<UL>\n".item($item[$i++],"\t$tabs")."$tabs</UL>\n"; }; return $li; }; function print_list($list) { $head="<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n" ."<HTML>\n" ."<HEAD>\n" ."<!-- Sitemap 1.0 -->\n" ."</HEAD><BODY>\n" ."<UL>\n"; $items=item($list); $foot="\n</UL>\n</BODY></HTML>"; return $head.$items.$foot; }; $list=parse("manual.html"); print(print_list($list)); ?> ---8<----------8<------------ index.php ---8<---------- <? function parse($f,$fname,&$list){ if(!preg_match("/(^function)|(^control)/",$fname))return; if(feof($f))print("\nError reading $fname!!!!!\n"); while(!feof($f)){ $s=fgets($f,255); if(preg_match("/.*<A/",$s)){ $s=fgets($f,255); if(preg_match("/NAME=\"(.*)\"/",$s,$a)){ $name=$a[1]; if(!preg_match("/[A-Z]{3}\d{4,5}/",$name)){ while(!feof($f) && !preg_match("/>(.+)<\/(A|TT)/",$s,$a))$s=fgets($f,255); $list[]=$a[1]; $list[]=$fname."#".$name; } } } } }; function items($list){ for($i=0;$i<count($list);){ print ("\t<LI><OBJECT type=\"text/sitemap\">\n"); print ("\t <param name=\"Name\" value=\"".$list[$i++]."\">\n"); print ("\t <param name=\"Local\" value=\"".$list[$i++]."\">\n"); print ("\t </OBJECT>\n"); } }; function print_list($list){ print("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n" ."<HTML>\n" ."<HEAD>\n" ."<!-- Sitemap 1.0 -->\n" ."</HEAD><BODY>\n" ."<UL>\n"); items($list); print("</UL>\n</BODY></HTML>"); }; $list=array(); $handle=opendir('.'); while ($file = readdir($handle)) if(preg_match("/.*\.html/",$file)) $flist[]=$file; closedir($handle); sort($flist); for($i=0;$i<count($flist);$i++){ $file=$flist[$i];$F=fopen("$file","r"); if(!$F){ print "Error opening $file!!!!!!";return; }; parse($F,$file,&$list);fclose($F); }; print_list(&$list); ?> ---8<----------8<------------ PHP.hhp ---8<---------- [OPTIONS] Binary Index=No Compatibility=1.1 or later Compiled file=PHP.chm Contents file=toc.hhc Default Window=PHP manual Default topic=manual.html Display compile progress=Yes Index file=Index.hhk Language=0x409 English Title=PHP manual [WINDOWS] PHP manual="PHP manual","toc.hhc","Index.hhk","manual.html","manual.html",,,,,0x43120,,0x187e,[271,372,593,566],,,,,,,0 [FILES] manual.html [INFOTYPES] ============= that's all =====================

« previous php.windows (#547) next »