OfficeXP_menu_class(OOP版)

老婷吖_5724

老婷吖_5724

2016-06-21

1698人浏览

原创

/**
* 仿officexp风格的左边版面列表    
* --------------------------------------------------------------------------------
* blood 于 2/19/2002 4:47:11 pm 加贴在 visual basic
*
* 徐祖宁(唠叨) 移植于 3/2/2002
* oop 版
*
*/

class frame {
  function run() {
    global $php_self;
    echo


Menu Sample
<script language="JavaScript"> <br/>if (window != top) top.location.href = location.href;<br/></script>

  

        
    
    
  

EOD;
  }
}

class About {
  function run() {
    echo







关于此菜单




说明,此菜单程序只能使用在IE 5以上的版本使用,NetSpace下不能使用,推荐使用IE 6正式中文版


EOD;
  }
}

class Page {
  function run($id1) {
    global $id;
    echo







欢迎访问 $id


EOD;
  }
}

class Menu {
  var $MenuOn = 0;                              //定义分类菜单数目
  var $MenuBackColor = "lightgrey";             //定义分类菜单背景颜色
  var $MenuFontSize = "9pt";                    //定义分类菜单字体
  var $MenuBarHeight = 20;                      //定义分类菜单高度
  var $ItemTextColor = "#000000";               //定义分类菜单项目文字颜色
  var $ItemBackColor = "lightgrey";             //定义分类菜单项目背景颜色
  var $TopMenuHeight = 0;                       //定义分类菜单与顶部的间距
  var $SelectedItemDarkBorder = "#08246B";      //定义分类菜单项目在鼠标移动到上面时的暗边框颜色
  var $SelectedItemLightBorder = "#08246B";     //定义分类菜单项目在鼠标移动到上面时的亮边框颜色
  var $SelectedItemBackgroundColor = "#B5BED6"; //定义分类菜单项目在鼠标移动到上面时的背景颜色
  var $menuSubSectionBackColor = "darkgray";    //定义二级菜单背景颜色
  var $menuSubSectionFontColor = "black";       //定义二级菜单菜单字体颜色
  var $defTarget = "main";                      //定义菜单项目超连接默认目标框架

/**
* menuStartSection($Seq, $Label)
*   制作分类菜单
*   $Seq = 分类菜单序列号,使用菜单序列号控制启动是显示顺序
*   $Label = 分类菜单标题
*/
function menuStartSection($SectionSeq, $SectionName) {
  $menuBackColor = $this->menuBackColor;
  $MenuBarHeight = $this->MenuBarHeight;
  $MenuFontSize = $this->MenuFontSize;
  $menuSection = $this->menuSection;
  $ItemBackColor = $this->ItemBackColor;
  $mh = $this->MenuBarHeight-2;
  echo

360智脑
360智脑

一款AI工具,主要用于360旗下ChatGPT类产品,适合需要提升相关任务效率的用户。

下载


  




  

$SectionName



  



EOD;
}

/**
* menuSectionAsItem($Label, $Description, $URL, $Target="")
*   制作带超连接的分类菜单,类似菜单项目,可以直接使用
*   $Label = 分类菜单标题
*   $Description = 分类菜单简介
*   $URL = 超连接地址
*   $Target = 超连接目标框架,默认为$defTarget
*/
function menuSectionAsItem($SectionSeq, $SectionName, $SectionDesc, $URL, $target="") {
  $menuBackColor = $this->menuBackColor;
  $MenuBarHeight = $this->MenuBarHeight;

  if($target == "") $target = $this->defTarget;
  $URL = $this->buildURL($URL);
  $mh = $this->MenuBarHeight-2;
  echo



  




  

$SectionName



  


EOD;
}

/**
* 将超连接中的空格替换为+号
*/
function buildURL($inURL) {
  return str_replace(" ","+",$inURL);
}
/**
* 输出javascript脚本
*/
function scriptOut() {
  $dh = $this->TopMenuHeight+($this->MenuBarHeight * $this->menuOn);
  echo
<script language="javascript"><br/>var AvailHeight&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// &#23450;&#20041;&#21487;&#21033;&#29992;&#30340;&#39640;&#24230;<br/>var LastSection&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// &#23450;&#20041;&#23558;&#35201;&#25171;&#24320;&#30340;&#33756;&#21333;&#20851;&#38381;<br/>var ThisSection&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// &#23450;&#20041;&#24403;&#21069;&#38656;&#35201;&#25171;&#24320;&#30340;&#33756;&#21333;<br/>var timerDelay=15&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// &#23450;&#20041;&#24182;&#35774;&#32622;&#24310;&#26102;<br/>var menuActive=false&nbsp;&nbsp;// &#27979;&#23450;&#24403;&#21069;&#27963;&#21160;&#30340;&#33756;&#21333;<br/>var VisibleHeight&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// &#23450;&#20041;&#26174;&#31034;&#39640;&#24230;&#65292;&#30830;&#23450;&#26159;&#21542;&#26174;&#31034;&#28378;&#21160;&#26465;<br/>var AniRatio&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// &#23450;&#20041;&#33756;&#21333;&#26174;&#31034;&#28369;&#21160;&#30340;&#36895;&#24230;<br/><br/>function getSizing() {<br/>&nbsp;&nbsp;// &#33756;&#21333;&#25171;&#24320;&#26102;&#24471;&#21040;&#30340;&#21487;&#21033;&#29992;&#30340;&#39640;&#24230;<br/>&nbsp;&nbsp;AvailHeight=document.body.clientHeight-$dh<br/>&nbsp;&nbsp;if(AvailHeight<=0) {<br/>&nbsp;&nbsp;&nbsp;&nbsp;LastSection.style.display='none';<br/>&nbsp;&nbsp;}else {<br/>&nbsp;&nbsp;&nbsp;&nbsp;// &#25913;&#21464;&#33756;&#21333;&#26174;&#31034;&#28369;&#21160;&#36895;&#24230;&#30340;&#27604;&#29575;<br/>&nbsp;&nbsp;&nbsp;&nbsp;AniRatio=0.75;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// &#35774;&#23450;&#36895;&#24230;<br/>&nbsp;&nbsp;&nbsp;&nbsp;if (AvailHeight>200) {AniRatio=0.667;}&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;if (AvailHeight>500) {AniRatio=0.5;}&nbsp;&nbsp;&nbsp;&nbsp;// &#26681;&#25454;&#21487;&#21033;&#29992;&#39640;&#24230;&#35843;&#25972;&#36895;&#24230;<br/>&nbsp;&nbsp;&nbsp;&nbsp;LastSection.style.height=AvailHeight;<br/>&nbsp;&nbsp;&nbsp;&nbsp;LastSection.style.overflow='visible';<br/>&nbsp;&nbsp;&nbsp;&nbsp;LastSection.style.display='';<br/>&nbsp;&nbsp;&nbsp;&nbsp;VisibleHeight=parseInt(LastSection.clientHeight);<br/>&nbsp;&nbsp;&nbsp;&nbsp;if (VisibleHeight>AvailHeight) {LastSection.style.overflow='auto';}else{LastSection.style.overflow='hidden';};<br/>&nbsp;&nbsp;}<br/>}<br/><br/>function slideMenu() {<br/>&nbsp;&nbsp;// &#33756;&#21333;&#28369;&#21160;&#20989;&#25968;<br/>&nbsp;&nbsp;if(parseInt(LastSection.style.height)>1) {<br/>&nbsp;&nbsp;&nbsp;&nbsp;LastSection.style.height=parseInt(parseInt(LastSection.style.height)*AniRatio);<br/>&nbsp;&nbsp;&nbsp;&nbsp;ThisSection.style.height=AvailHeight-parseInt(LastSection.style.height);<br/>&nbsp;&nbsp;&nbsp;&nbsp;var movetimer=setTimeout("slideMenu()",timerDelay)&nbsp;&nbsp;;<br/>&nbsp;&nbsp;}else {<br/>&nbsp;&nbsp;&nbsp;&nbsp;// &#23436;&#25104;&#33756;&#21333;&#28369;&#21160;&#65292;&#26174;&#31034;&#26032;&#25171;&#24320;&#30340;&#33756;&#21333;&#65292;&#38544;&#34255;&#21069;&#38754;&#20197;&#25171;&#24320;&#30340;&#33756;&#21333;<br/>&nbsp;&nbsp;&nbsp;&nbsp;LastSection.style.display='none';<br/>&nbsp;&nbsp;&nbsp;&nbsp;ThisSection.style.height=AvailHeight;<br/>&nbsp;&nbsp;&nbsp;&nbsp;menuActive=false;<br/>&nbsp;&nbsp;&nbsp;&nbsp;if (VisibleHeight>AvailHeight) {ThisSection.style.overflow='auto';};<br/>&nbsp;&nbsp;&nbsp;&nbsp;ThisSection.style.marginRight=0;<br/>&nbsp;&nbsp;&nbsp;&nbsp;LastSection=ThisSection;<br/>&nbsp;&nbsp;&nbsp;&nbsp;clearTimeout(movetimer);<br/>&nbsp;&nbsp;}<br/>}<br/><br/>function StartSection(theSection) {<br/>&nbsp;&nbsp;// &#24320;&#22987;&#28369;&#21160;&#33756;&#21333;&#65292;&#26816;&#27979;&#26159;&#21542;&#23545;&#33756;&#21333;&#36827;&#34892;&#21333;&#20987;<br/>&nbsp;&nbsp;if(menuActive==false) {<br/>&nbsp;&nbsp;&nbsp;&nbsp;if(LastSection!=theSection) {<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;menuActive=true;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ThisSection=theSection;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LastSection.style.overflow='hidden';<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ThisSection.style.overflow='visible';<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ThisSection.style.display='';<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VisibleHeight=parseInt(ThisSection.clientHeight);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ThisSection.style.overflow='hidden';<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ThisSection.style.display='none';<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ThisSection.style.height=1;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LastSection.style.height=AvailHeight-1;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LastSection.style.display='';<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ThisSection.style.display='';<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;slideMenu()<br/>&nbsp;&nbsp;&nbsp;&nbsp;}<br/>&nbsp;&nbsp;}<br/>}<br/><br/>window.onresize=getSizing<br/>// &#21551;&#21160;&#26102;&#25171;&#24320;&#40664;&#35748;&#30340;&#24207;&#21495;&#20026;&#31532;&#19968;&#20010;&#30340;&#33756;&#21333;<br/>LastSection=document.all.menuSection1;<br/>LastSection.style.display='';<br/>getSizing();<br/></script>
EOD;
}

function run() {
  global $PHP_SELF;
  $MenuFontSize = $this->MenuFontSize;
  $MenuBackColor = $this->MenuBackColor;
  echo


EOD;

  /**
   * 创建菜单
   */
  $this->menuStartSection(2, "代码世界");
  $this->menuAddItem("Joy ASP", "欢迎访问Joy ASP", "$PHP_SELF?key=page&id=Joy ASP");
  $this->menuAddItem("Java 世界", "欢迎访问Java 世界", "$PHP_SELF?key=page&id=Java 世界");
  $this->menuAddItem("DotNet 时代", "欢迎访问DotNet 时代", "$PHP_SELF?key=page&id=DotNet 时代");
  $this->menuAddItem("Visual Basic", "欢迎访问Visual Basic", "$PHP_SELF?key=page&id=Visual Basic");
  $this->menuAddItem("Delphi", "欢迎访问Delphi", "$PHP_SELF?key=page&id=Delphi");
  $this->menuEndSection();

  $this->menuStartSection(3, "开心一刻");
  $this->menuAddItem("传统笑话", "传统笑话", "$PHP_SELF?key=page&id=传统笑话");
  $this->menuAddItem("近代笑话", "近代笑话", "$PHP_SELF?key=page&id=近代笑话");
  $this->menuAddSubSection("儿童类");
  $this->menuAddItem("校园笑话", "校园笑话", "$PHP_SELF?key=page&id=校园笑话");
  $this->menuAddItem("幼儿笑话", "幼儿笑话", "$PHP_SELF?key=page&id=幼儿笑话");
  $this->menuAddItem("少年笑话", "少年笑话", "$PHP_SELF?key=page&id=少年笑话");
  $this->menuAddSubSectionLine();
  $this->menuAddItem("中学时代笑话", "中学时代笑话", "$PHP_SELF?key=page&id=中学时代笑话");
  $this->menuAddSubSection("成人笑话");
  $this->menuAddItem("带颜色的笑话", "带颜色的笑话", "$PHP_SELF?key=page&id=带颜色的笑话");
  $this->menuAddItem("笑话林", "笑话林", "$PHP_SELF?key=page&id=笑话林");
  $this->menuEndSection();

  $this->menuSectionAsItem(3, "菜单简介", "菜单简介", "$PHP_SELF?key=about");

  $this->menuStartSection(1, "个人收藏夹");
  $this->menuAddItem("DotNet 时代", "欢迎访问DotNet 时代", "$PHP_SELF?key=page&id=DotNet 时代");
  $this->menuEndSection();

  // 将个人收藏夹定为启动菜单
  $this->menuOn = 4;
  $this->scriptOut();
  echo "

\n";
}
}

class Application {
  var $frame;
  var $menu;
  var $page;
  var $about;
  function Application() {
    $this->frame = new Frame;
    $this->about = new About;
    $this->page = new Page;
    $this->menu = new Menu;
  }
  function run($key,$id="") {
    switch($key) {
      case "menu":
        $this->menu->run();
        break;
      case "page":
        $this->page->run($id);
        break;
      case "about":
        $this->about->run();
        break;
      default:
        $this->frame->run();
    }
  }
}
?>
/** 运行 **/
$app = new Application;
$app->run($key,$id);
?>



相关文章

WPS零基础入门到精通全套教程!
WPS零基础入门到精通全套教程!

全网最新最细最实用WPS零基础入门到精通全套教程!带你真正掌握WPS办公! 内含Excel基础操作、函数设计、数据透视表等

下载

相关标签:

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

相关专题

更多
Go-Zero API开发使用教程
Go-Zero API开发使用教程

本专题聚焦Go-Zero的API开发,拆解.api描述文件的语法结构、路由与分组定义、参数绑定与校验规则,说明统一响应体、JWT鉴权、跨域与接口文档生成的落地方式,并给出网关聚合与接口测试的实践建议。

2026.11.12

140

15

Go-Zero安装与goctl环境配置教程
Go-Zero安装与goctl环境配置教程

本专题围绕Go-Zero的安装与工具链配置展开,讲清Go版本要求、goctl安装方式、代理镜像、protoc依赖与环境变量设置,说明多版本共存、升级回退与CI流水线安装的做法,并整理安装阶段的常见报错与验证步骤。

2026.11.12

100

15

Go-Zero零基础入门教程
Go-Zero零基础入门教程

本专题整理Go-Zero的入门知识,从框架定位、环境准备到跑通第一个API服务,讲清目录分层、配置加载、日志与中间件的基本用法,并对比Gin、Kratos的差异,帮助Go开发者建立整体认知,判断它是否适合当前项目。

2026.11.12

80

15

Postman身份认证怎么配置
Postman身份认证怎么配置

本专题从实际API接口调试场景出发,讲解Postman身份认证的完整配置流程,包括常见认证协议介绍、授权参数设置、访问令牌填写、OAuth 2.0授权及认证失败排查,帮助用户正确完成接口授权与访问验证。

2026.11.06

160

12

Postman请求头Headers怎么设置
Postman请求头Headers怎么设置

围绕Postman HTTP请求头配置展开,讲解Headers选项的具体使用方式,包括Key和Value参数填写、请求头信息添加、常见Header字段设置及请求头修改方法,帮助用户解决接口调试过程中遇到的请求头配置问题。

2026.11.06

140

13

Postman接口请求发送教程
Postman接口请求发送教程

详细介绍Postman接口请求的创建与发送方法,涵盖GET和POST请求、URL配置、请求参数、Headers请求头、Body请求体设置以及响应结果查看,帮助用户掌握Postman接口请求的完整操作流程。

2026.11.06

120

10

DBeaver怎么导入数据
DBeaver怎么导入数据

DBeaver数据导入专题,整理Excel、CSV、SQL、TXT等常见文件的数据导入方法,涵盖目标数据库选择、数据表创建、字段映射、数据类型设置及导入参数配置等操作,帮助用户将本地文件中的数据写入数据库,并了解批量导入、重复数据处理和导入失败等常见问题的解决方法。

2026.11.05

120

12

DBeaver安全防护教程大全
DBeaver安全防护教程大全

DBeaver安全防护专题,围绕数据库连接安全、账号密码保护和访问权限管理展开,整理SSL/TLS加密连接、SSH隧道、数据库凭据保存及证书验证等配置方法,同时介绍敏感信息保护、远程连接风险和高权限账号使用等注意事项,帮助用户提高数据库日常管理的安全性。

2026.11.05

100

12

DBeaver连接创建与配置教程
DBeaver连接创建与配置教程

本专题聚焦DBeaver数据库连接配置与管理,覆盖从新建连接、选择数据库类型到填写连接参数和验证连接的完整流程。针对MySQL、PostgreSQL、SQL Server等常见数据库,整理相应的连接设置方法,并提供驱动缺失、认证失败和连接异常等问题的排查方向。

2026.11.04

120

16

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
Excel 教程
Excel 教程

共162课时 | 45.8万人学习

Pandas 教程
Pandas 教程

共15课时 | 2万人学习

C# 教程
C# 教程

共94课时 | 23万人学习