<code><?php<br />/**<br />* 仿OfficeXP风格的左边版面列表  <br />* --------------------------------------------------------------------------------<br />* blood 于 2/19/2002 4:47:11 PM 加贴在 Visual Basic<br />*<br />* 徐祖宁(唠叨) 移植于 3/2/2002<br />* OOP 版<br />*<br />*/<br />class Frame {<br /> function run() {<br /> global $PHP_SELF;<br /> echo <<<EOD<br /><HTML><br /><HEAD><br /><TITLE>Menu Sample</TITLE><br /><SCRIPT LANGUAGE="JavaScript"><br />if (window != top) top.location.href = location.href;<br /></SCRIPT><br /></HEAD><br /> <FRAMESET cols="161,*">  <br /> <FRAME MARGINWIDTH="0" SRC="$PHP_SELF?key=menu" NAME="menu" SCROLLING=no NORESIZE><br /> <FRAME MARGINWIDTH="0" SRC="$PHP_SELF?key=about" NAME="main" scrolling=auto NORESIZE><br /> </FRAMESET><br /></HTML><br />EOD;<br /> }<br />}<br />class About {<br /> function run() {<br /> echo <<<EOD<br /><style><br />body { font-size: 9pt; font-family:"Verdana", "Arial", "宋体"; }<br /></style><br /><body><br /><center><br /><br><br /><br><br />关于此菜单<br /><br><br /><br><br />说明,此菜单程序只能使用在IE 5以上的版本使用,NetSpace下不能使用,推荐使用IE 6正式中文版<br /></center><br /></body><br />EOD;<br /> }<br />}<br />class Page {<br /> function run($id1) {<br /> global $id;<br /> echo <<<EOD<br /><style><br />body { font-size: 9pt; font-family:"Verdana", "Arial", "宋体"; }<br /></style><br /><body><br /><center><br /><br><br /><br><br />欢迎访问 $id<br /></center><br /></body><br />EOD;<br /> }<br />}<br />class Menu {<br /> var $MenuOn = 0; //定义分类菜单数目<br /> var $MenuBackColor = "lightgrey";  //定义分类菜单背景颜色<br /> var $MenuFontSize = "9pt"; //定义分类菜单字体<br /> var $MenuBarHeight = 20; //定义分类菜单高度<br /> var $ItemTextColor = "#000000";  //定义分类菜单项目文字颜色<br /> var $ItemBackColor = "lightgrey";  //定义分类菜单项目背景颜色<br /> var $TopMenuHeight = 0;  //定义分类菜单与顶部的间距<br /> var $SelectedItemDarkBorder = "#08246B"; //定义分类菜单项目在鼠标移动到上面时的暗边框颜色<br /> var $SelectedItemLightBorder = "#08246B";  //定义分类菜单项目在鼠标移动到上面时的亮边框颜色<br /> var $SelectedItemBackgroundColor = "#B5BED6"; //定义分类菜单项目在鼠标移动到上面时的背景颜色<br /> var $menuSubSectionBackColor = "darkgray"; //定义二级菜单背景颜色<br /> var $menuSubSectionFontColor = "black";  //定义二级菜单菜单字体颜色<br /> var $defTarget = "main"; //定义菜单项目超连接默认目标框架<br />/**<br />* menuStartSection($Seq, $Label)<br />*  制作分类菜单<br />*  $Seq = 分类菜单序列号,使用菜单序列号控制启动是显示顺序<br />*  $Label = 分类菜单标题<br />*/<br />function menuStartSection($SectionSeq, $SectionName) {<br /> $menuBackColor = $this->menuBackColor;<br /> $MenuBarHeight = $this->MenuBarHeight;<br /> $MenuFontSize = $this->MenuFontSize;<br /> $menuSection = $this->menuSection;<br /> $ItemBackColor = $this->ItemBackColor;<br /> $mh = $this->MenuBarHeight-2;<br /> echo <<<EOD<br /><table bgcolor="$menuBackColo" border=0 cellspacing=0 cellpadding=0 width="100%" height="1"><br /><tr height="1"><br /> <td bgcolor="white"></td><br /></tr><br /></table><br /><table bgcolor="$menuBackColor" border=1 cellspacing=0 cellpadding=0 bordercolor="$menuBackColor" width="100%" height="$mh"><br /><tr vAlign="center" height="100%"><br /> <td nowrap border=3 width="100%" height="100%" bordercolordark=lightgrey bordercolorlight=lightgrey align=center<br />style="cursor:hand;" title="$SectionName" onmouseover="status='$SectionName';" onmouseout="status='';<br />" onclick="StartSection(menuSection$SectionSeq);">$SectionName</td><br /></tr><br /></table><br /><table border=0 cellspacing=0 cellpadding=0 width="100%" height="1"><br /><tr height="1"><br /> <td bgcolor="Black"></td><br /></tr><br /></table><br /><div name=menuSection$SectionSeq id=menuSection$SectionSeq style="display:'none';overflow:hidden; height:1px;marginRight:0px;"><br /><table bgcolor=$ItemBackColor style="marginRight=0px;" border=1 cellspacing=0 cellpadding=0 bordercolor="$ItemBackColor"<br />width="100%"><br />EOD;<br />}<br />/**<br />* menuAddItem($Label, $Description, $URL, $Target="")<br />*  制作菜单项目<br />*  $Label = 项目标题<br />*  $Description = 项目简介<br />*  $URL = 超连接地址<br />*  $Target = 超连接目标框架,默认为$defTarget<br />*/<br />function menuAddItem($itemLabel, $StatusText, $URL, $target="") {<br /> $SelectedItemDarkBorder = $this->SelectedItemDarkBorder;<br /> $SelectedItemLightBorder = $this->SelectedItemLightBorder;<br /> $SelectedItemBackgroundColor = $this->SelectedItemBackgroundColor;<br /> $ItemTextColor = $this->ItemTextColor;<br /> if($target == "") $target = $this->defTarget;<br /> $URL = $this->buildURL($URL);<br /> echo <<<EOD<br /><tr><br /> <td width="100%" align=left style="cursor:hand;" title="$StatusText" onmouseover="this.borderColorDark='$SelectedItemDarkBorder';<br />this.borderColorLight='$SelectedItemLightBorder'; this.style.backgroundColor='$SelectedItemBackgroundColor';<br />this.style.color='black';status='$StatusText';" onmouseout="this.borderColorDark='';this.borderColorLight='';<br />this.style.backgroundColor='';status='';" onclick="window.open('$URL','$target');"><font color="$ItemTextColor"><br />$itemLabel</font></td><br /></tr><br />EOD;<br />}<br />/**<br />* menuAddSubSection($Label)<br />*  制作二级分类菜单。<br />*  $Label = 二级分类菜单标题<br />*/<br />function menuAddSubSection($ItemLabel) {<br /> $menuSubSectionBackColor = $this->menuSubSectionBackColor;<br /> $menuSubSectionFontColor = $this->menuSubSectionFontColor;<br /> echo <<<EOD<br /><tr bgcolor="$menuSubSectionBackColor"><br /> <td align=center width="100%"><font color="$menuSubSectionFontColor">$ItemLabel</font></td><br /></tr><br />EOD;<br />}<br />/**<br />* menuAddSubSectionLine()<br />*  制作项目分割线,使用高度为2的图片<br />*/<br />function menuAddSubSectionLine() {<br /> echo <<<EOD<br /><tr vAlign="center"><br /> <td align=center width="100%" height="2" bgcolor="white"><br /> <table border=0 cellspacing=0 cellpadding=0 width="100%" height="1"><br />  <tr vAlign="center" height="2"><br />  <td bgcolor="white"></td><br />  </tr><br /> </table><br /> </td><br /></tr><br />EOD;<br />}<br />/**<br />* menuEndSection()<br />*  分类菜单结束<br />*/<br />function menuEndSection() {<br /> echo <<<EOD<br /></table><br /></div><br />EOD;<br />}<br />/**<br />* menuSectionAsItem($Label, $Description, $URL, $Target="")<br />*  制作带超连接的分类菜单,类似菜单项目,可以直接使用<br />*  $Label = 分类菜单标题<br />*  $Description = 分类菜单简介<br />*  $URL = 超连接地址<br />*  $Target = 超连接目标框架,默认为$defTarget<br />*/<br />function menuSectionAsItem($SectionSeq, $SectionName, $SectionDesc, $URL, $target="") {<br /> $menuBackColor = $this->menuBackColor;<br /> $MenuBarHeight = $this->MenuBarHeight;<br /> if($target == "") $target = $this->defTarget;<br /> $URL = $this->buildURL($URL);<br /> $mh = $this->MenuBarHeight-2;<br /> echo <<<EOD<br /><table border=0 cellspacing=0 cellpadding=0 width="100%" height="1"><br /><tr vAlign="center" height="1"><br /> <td bgcolor="white"></td><br /></tr><br /></table><br /><table bgcolor="$menuBackColor" border=1 cellspacing=0 cellpadding=0 bordercolor="$menuBackColor" width="100%" height="Smh"><br /><tr height="100%" vAlign="center"><br /> <td border=3 vAlign="middle" width="100%" height="100%" bordercolordark=lightgrey bordercolorlight=lightgrey align=center<br />style="cursor:hand;" title="$SectionDesc" onmouseover="status='$SectionDesc';" onmouseout="status='';<br />" onclick="window.open('$URL','$target');"><font color="#000000">$SectionName</font></td><br /></tr><br /></table><br /><table border=0 cellspacing=0 cellpadding=0 width="100%" height="1"><br /><tr height="1"><br /> <td bgcolor="Black"></td><br /></tr><br /></table><br />EOD;<br />}<br />/**<br />* 将超连接中的空格替换为+号<br />*/<br />function buildURL($inURL) {<br /> return str_replace(" ","+",$inURL);<br />}<br />/**<br />* 输出javascript脚本<br />*/<br />function scriptOut() {<br /> $dh = $this->TopMenuHeight+($this->MenuBarHeight * $this->menuOn);<br /> echo <<<EOD<br /><script language=javascript><br />var AvailHeight  // 定义可利用的高度<br />var LastSection  // 定义将要打开的菜单关闭<br />var ThisSection  // 定义当前需要打开的菜单<br />var timerDelay=15  // 定义并设置延时<br />var menuActive=false // 测定当前活动的菜单<br />var VisibleHeight  // 定义显示高度,确定是否显示滚动条<br />var AniRatio // 定义菜单显示滑动的速度<br />function getSizing() {<br /> // 菜单打开时得到的可利用的高度<br /> AvailHeight=document.body.clientHeight-$dh<br /> if(AvailHeight<=0) {<br /> LastSection.style.display='none';<br /> }else {<br /> // 改变菜单显示滑动速度的比率<br /> AniRatio=0.75; // 设定速度<br /> if (AvailHeight>200) {AniRatio=0.667;} <br /> if (AvailHeight>500) {AniRatio=0.5;} // 根据可利用高度调整速度<br /> LastSection.style.height=AvailHeight;<br /> LastSection.style.overflow='visible';<br /> LastSection.style.display='';<br /> VisibleHeight=parseInt(LastSection.clientHeight);<br /> if (VisibleHeight>AvailHeight) {LastSection.style.overflow='auto';}else{LastSection.style.overflow='hidden';};<br /> }<br />}<br />function slideMenu() {<br /> // 菜单滑动函数<br /> if(parseInt(LastSection.style.height)>1) {<br /> LastSection.style.height=parseInt(parseInt(LastSection.style.height)*AniRatio);<br /> ThisSection.style.height=AvailHeight-parseInt(LastSection.style.height);<br /> var movetimer=setTimeout("slideMenu()",timerDelay) ;<br /> }else {<br /> // 完成菜单滑动,显示新打开的菜单,隐藏前面以打开的菜单<br /> LastSection.style.display='none';<br /> ThisSection.style.height=AvailHeight;<br /> menuActive=false;<br /> if (VisibleHeight>AvailHeight) {ThisSection.style.overflow='auto';};<br /> ThisSection.style.marginRight=0;<br /> LastSection=ThisSection;<br /> clearTimeout(movetimer);<br /> }<br />}<br />function StartSection(theSection) {<br /> // 开始滑动菜单,检测是否对菜单进行单击<br /> if(menuActive==false) {<br /> if(LastSection!=theSection) {<br /> menuActive=true;<br /> ThisSection=theSection;<br /> LastSection.style.overflow='hidden';<br /> ThisSection.style.overflow='visible';<br /> ThisSection.style.display='';<br /> VisibleHeight=parseInt(ThisSection.clientHeight);<br /> ThisSection.style.overflow='hidden';<br /> ThisSection.style.display='none';<br /> ThisSection.style.height=1;<br /> LastSection.style.height=AvailHeight-1;<br /> LastSection.style.display='';<br /> ThisSection.style.display='';<br /> slideMenu()<br /> }<br /> }<br />}<br />window.onresize=getSizing<br />// 启动时打开默认的序号为第一个的菜单<br />LastSection=document.all.menuSection1;<br />LastSection.style.display='';<br />getSizing();<br /></script><br />EOD;<br />}<br />function run() {<br /> global $PHP_SELF;<br /> $MenuFontSize = $this->MenuFontSize;<br /> $MenuBackColor = $this->MenuBackColor;<br /> echo <<<EOD<br /><style><br />td { font-size: $MenuFontSize; font-family:"Verdana", "Arial", "宋体"; }<br /></style><br /><body leftmargin=0 topmargin=0 rightmargin=0 bgcolor="$MenuBackColor"><br />EOD;<br /> /**<br />  * 创建菜单<br />  */<br /> $this->menuStartSection(2, "代码世界");<br /> $this->menuAddItem("Joy ASP", "欢迎访问Joy ASP", "$PHP_SELF?key=page&id=Joy ASP");<br /> $this->menuAddItem("Java 世界", "欢迎访问Java 世界", "$PHP_SELF?key=page&id=Java 世界");<br /> $this->menuAddItem("DotNet 时代", "欢迎访问DotNet 时代", "$PHP_SELF?key=page&id=DotNet 时代");<br /> $this->menuAddItem("Visual Basic", "欢迎访问Visual Basic", "$PHP_SELF?key=page&id=Visual Basic");<br /> $this->menuAddItem("Delphi", "欢迎访问Delphi", "$PHP_SELF?key=page&id=Delphi");<br /> $this->menuEndSection();<br /> $this->menuStartSection(3, "开心一刻");<br /> $this->menuAddItem("传统笑话", "传统笑话", "$PHP_SELF?key=page&id=传统笑话");<br /> $this->menuAddItem("近代笑话", "近代笑话", "$PHP_SELF?key=page&id=近代笑话");<br /> $this->menuAddSubSection("儿童类");<br /> $this->menuAddItem("校园笑话", "校园笑话", "$PHP_SELF?key=page&id=校园笑话");<br /> $this->menuAddItem("幼儿笑话", "幼儿笑话", "$PHP_SELF?key=page&id=幼儿笑话");<br /> $this->menuAddItem("少年笑话", "少年笑话", "$PHP_SELF?key=page&id=少年笑话");<br /> $this->menuAddSubSectionLine();<br /> $this->menuAddItem("中学时代笑话", "中学时代笑话", "$PHP_SELF?key=page&id=中学时代笑话");<br /> $this->menuAddSubSection("成人笑话");<br /> $this->menuAddItem("带颜色的笑话", "带颜色的笑话", "$PHP_SELF?key=page&id=带颜色的笑话");<br /> $this->menuAddItem("笑话林", "笑话林", "$PHP_SELF?key=page&id=笑话林");<br /> $this->menuEndSection();<br /> $this->menuSectionAsItem(3, "菜单简介", "菜单简介", "$PHP_SELF?key=about");<br /> $this->menuStartSection(1, "个人收藏夹");<br /> $this->menuAddItem("DotNet 时代", "欢迎访问DotNet 时代", "$PHP_SELF?key=page&id=DotNet 时代");<br /> $this->menuEndSection();<br /> // 将个人收藏夹定为启动菜单<br /> $this->menuOn = 4;<br /> $this->scriptOut();<br /> echo "</body>\n";<br />}<br />}<br />class Application {<br /> var $frame;<br /> var $menu;<br /> var $page;<br /> var $about;<br /> function Application() {<br /> $this->frame = new Frame;<br /> $this->about = new About;<br /> $this->page = new Page;<br /> $this->menu = new Menu;<br /> }<br /> function run($key,$id="") {<br /> switch($key) {<br /> case "menu":<br /> $this->menu->run();<br /> break;<br /> case "page":<br /> $this->page->run($id);<br /> break;<br /> case "about":<br /> $this->about->run();<br /> break;<br /> default:<br /> $this->frame->run();<br /> }<br /> }<br />}<br />?><br /><?php<br />/** 运行 **/<br />$app = new Application;<br />$app->run($key,$id);<br />?></code></p>