I improved the script php_manual_prefs.js provided with the extended chm-version to better hilight user comments and code samples as I found those in the original version too dull (gray). Note that this all cannot be done using stylesheets only as the code samples in the chm-docs do not have any distinct classes etc and can only be parsed with a script. What I added to the original script follows. The timeouts are used because the page is not loaded right at once so we have to wait for complete loading. The colors (aColorMap) can be customized. This also improves navigation links positioning in short pages, so instead of directly following contents they are now bottom-aligned. This fix needs some extra styles so they follow the code, along with some general styles.
setTimeout("AddStyles(); window.focus();", 50);
//-----------
var D, TimerId, oNav, oPage;
function AddStyles(){
D=document; ChangeExamples(); ChangeNotes();
}
function ChangeExamples(){
var aDivs, DivNo, oDiv, aSpans, SpanNo, oSpan, aColorMap, Color, aCodes;
aColorMap=[];
aColorMap['#007700']='yellow';
aColorMap['#0000bb']='white';
aColorMap['#dd0000']='yellow';
aColorMap['#ff8000']='Aqua';
//aColorMap['']='';
//Scan examples
aDivs=D.getElementsByTagName('DIV');
for(DivNo=0; DivNo<aDivs.length; DivNo++){
oDiv=aDivs[DivNo];
if (oDiv.className!='examplecode') continue;
//Change colors
oDiv.style.backgroundColor='black';
oDiv.style.backgroundImage='none';
//oDiv.style.color='white';
aSpans=oDiv.getElementsByTagName('SPAN');
for(SpanNo=0; SpanNo<aSpans.length; SpanNo++){
oSpan=aSpans[SpanNo];
Color=oSpan.style.color;
oSpan.style.color=aColorMap[Color];
if (Color=='#dd0000') oSpan.style.backgroundColor='DarkRed';
oSpan.style.fontFamily='Lucida Console';
}
aCodes=oDiv.getElementsByTagName('CODE');
for(SpanNo=0; SpanNo<aCodes.length; SpanNo++){
oSpan=aCodes[SpanNo];
oSpan.style.color='yellow';
oSpan.style.fontFamily='Lucida Console';
}
}
}
function ChangeNotes(){
var oNotes, oDiv, aDivs, DivNo, oP, aPs;
oNotes=D.getElementById('pageNotes');
if (!oNotes){
setTimeout('ChangeNotes();', 100); return;
}
aDivs=oNotes.getElementsByTagName('DIV');
for(DivNo=0; DivNo<aDivs.length; DivNo++){
oDiv=aDivs[DivNo];
aPs=oDiv.getElementsByTagName('P');
oP=aPs[0];
oP.style.backgroundColor='DarkGreen';
oP.style.color='yellow';
oP.style.marginBottom='0px';
oP=aPs[1];
oP.style.backgroundColor='LightYellow';
oP.firstChild.style.fontFamily='Lucida Console';
//oP.firstChild.style.fontSize='12px';
oP.style.border='1px solid DarkGreen';
oP.style.borderTopWidth='0px';
}
//return;
oNav=D.getElementById('pageNav');
oPage=D.getElementById('pageContent');
AlignNav(); window.onresize=AlignNav;
}
function AlignNav(){
var Pos, NavBottom, Diff;
Pos=AbsPos(oNav);
NavBottom=Pos[1]+oNav.offsetHeight;
Diff=oPage.offsetHeight-NavBottom;
if (Diff!=0) oNav.style.top=(Diff+oNav.style.posTop)+'px';
}
function AbsPos(O, Parent){
var X=0, Y=0, Next;
Next=O; if (Parent==null) Parent=D;
while (Next!=null && Next!==Parent){
Y+=Next.offsetTop; X+=Next.offsetLeft; Next=Next.offsetParent;
}
return [X, Y];
}
//----------
This is to be added in style.css:
Body{
font-family: Verdana;
font-size: 80%;
height: 100%;
}
P{
text-align:justify;
}
#pageContent{
height: 100%;
}
#pageNav {
position:relative;
}
.literal{
background-color: LightCyan;
}
TR.question TD{
background:LightYellow;
}
TR.answer TD{
background:#F0FFF0;
}
关于本手册
Table of Contents
手册的格式
《PHP 参考手册》提供了多种不同格式的版本,它们可以分为两组:在线阅读版本和可下载包。
Note: 有些出版商可能已经出版了本手册的一些印刷版本,但不推荐使用它们,因为 PHP 参考手册更新得非常快,这些印刷版本的内容很快将过时。
可以访问 » PHP.net 网站及其众多的镜像站点来在线阅读《PHP 参考手册》。为了保证最佳的访问速度,应该选择地理位置最接近的镜像站点。PHP 手册的 HTML 版本既有纯 HTML 版(便于打印的),也有看上去和感觉上和 PHP 站点上的手册一样的版本。
和绝大多数离线格式的手册相比,在线阅读版本有两个显著的优点,即它集成了用户注释,并且可以使用其中的 » URL 快捷方式快速进入手册中想阅读的部分;但是,它的明显的缺点是必须保持一直在线来阅读。
目前,《PHP 参考手册》提供多种离线阅读格式,最适合于自己的格式取决于所使用的操作系统和个人的阅读习惯。关于《PHP 参考手册》如何被制作成如此多的版本,请查阅本附录中“如何生成手册的各种格式”一节。
跨平台性最好的格式是 HTML 格式格式。HTML 格式提供了两种方式:一种只有一个很大的 HTML 文件;另一种方式是每一节分成一个独立文件,它们形成一个包含有几千个文件的文件包。我们提供的是这两种版本的压缩包,需要使用解压缩工具解压出压缩包中的文件。
对于 Windows 平台,我们利用了 Windows 的超文本帮助应用程序结合本手册的 HTML 格式,形成了本手册的 Windows 超文本帮助版本。该版本提供手册的全文搜索、完整的索引以及书签功能。很多 Windows 平台下流行的 PHP 集成开发环境也集成了该版本的手册,以给开发者提供最方便快捷的参考。CHM 阅读器也有 Linux 版本,可以到 » xCHM 或 » GnoCHM 网站了解更多信息。
同时,PHP 手册也有» 扩展 CHM 版本提供下载。它更新的速度比较慢,但是提供了附加的功能。由于制作帮助页面时采用的技术的特殊性,它只可在 Microsoft Windows 下工作。
关于本手册
21-Aug-2007 08:38
