All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
Sql,server传给语句的输入数据验证_[SQL,Server教程]
ASP.NET的一个bug的发现和解决_.net资料_编程技术
十二 Meta标签_[Html教程]
ASP.NET技巧:access下的分页方案_[Asp.Net教程]
菜鸟的最爱,.NET经典代码汇总(二)_.net资料_编程技术
学习网页Web标准:DOCTYPE(文档类型)基础知识_[Html教程]
在GridView数据源为空时也显示表头_[Asp.Net教程]
ASP.NET网络编程中经常会用到的27个函数集_.net资料_编程技术
SQL Server数据库的数据类型_[SQL Server教程]
图片在已知大小容器中的水平垂直居中实例_[Html教程]
Reading number is top 10 pictures
Perfect small Laurie1
Look for from human art net, is good--2
夕阳下的北京街道
The goddess of the single reason2
青春清纯美女大集合1
Beauty Sun Feifei
Shandong jinan is about to dismantle a one hundred-year history of the building
Group of female porn in 《westwards》, uninhibited woman threatened to not the bottom line
A man's favorite things11
Sell the barbecue as says father du breul4
Download software ranking
圣殿祭司的ASP.NET.2.0.开发详解-使用C#
C#编程思想
徐若瑄成名作“魔鬼天使”
Ashlynn Video4
Unix video tutorial6
尖东毒玫瑰B
The cock of the Grosvenor LTD handsome
网络管理员第三版
Unix video tutorial5
终极变速大师Speeder3.26
aaa published in(发表于) 2013/12/24 5:49:48 Edit(编辑)
PHP实例:用PHP实现windows风格的树型菜单_php资料_编程技术

PHP实例:用PHP实现windows风格的树型菜单_php资料_编程技术

PHP实例:用PHP实现windows风格的树型菜单_php资料_编程技术-你的首页-uuhomepage.com
PHP实例:用PHP实现windows风格的树型菜单
以下是一个风格类似windows资源管理器的树型菜单,将下面的脚本包含到你的页面中,另外需要从资源管理器中截取一些gif图片,祥见脚本中的注释,菜单结构文件的格式为:
tree level|item text|item link|link target|last item in subtree
例如
.Demo menu|javascript: alert('This is the demo menu for TreeMenu 1.0');
..目录1
...子目录 1.1
....item 1.1.1|javascript: alert('Item 1.1.1');
....item 1.1.2|javascript: alert('Item 1.1.1');
...item 1.2|javascript: alert('Item 1.2');
...item 1.3|javascript: alert('Item 1.3');
..子目录 2
...item 2.1|javascript: alert('Item 2.1');
...item 2.2|javascript: alert('Item 2.2');
...子目录 2.3
....item 2.3.1|javascript: alert('Item 2.3.1');
....item 2.3.2|javascript: alert('Item 2.3.2');
// file:tremenu.inc
// PHP TreeMenu
/////////////////
// 初始化 //
/////////////////
$treefile = "demomenu.txt";//设置有菜单结构的文件
if(isset($PATH_INFO))
$script = $PATH_INFO;
else
$script = $SCRIPT_NAME;
//以下图片可截取windows资源管理器中的相应位置的图
$img_expand = "tree_expand.gif";//形如资源管理器中可扩展节点+
$img_collapse = "tree_collapse.gif";//形如资源管理器中已扩展节点-
$img_line = "tree_vertline.gif";//形如|
$img_split = "tree_split.gif";//形如|-
$img_end = "tree_end.gif";//形如L
$img_leaf = "tree_leaf.gif";//形如o
$img_spc = "tree_space.gif";//空白图
//以下是菜单处理脚本
$maxlevel=0;
$cnt=0;
$fd = fopen($treefile, "r");
if ($fd==0) die("treemenu.inc : Unable to open file ".$treefile);
while ($buffer = fgets($fd, 4096))
{
$tree[$cnt][0]=strspn($buffer,".");
$tmp=rtrim(substr($buffer,$tree[$cnt][0]));
$node=explode("|",$tmp);
$tree[$cnt][1]=$node[0];
$tree[$cnt][2]=$node[1];
$tree[$cnt][3]=$node[2];
$tree[$cnt][4]=0;
if ($tree[$cnt][0] > $maxlevel) $maxlevel=$tree[$cnt][0];
$cnt++;
}
fclose($fd);
for ($i=0; $i{
$expand[$i]=0;
$visible[$i]=0;
$levels[$i]=0;
}
if ($p!="")
$explevels = explode("|",$p);
$i=0;
while($i{
$expand[$explevels[$i]]=1;
$i++;
}
$lastlevel=$maxlevel;
for ($i=count($tree)-1; $i>=0; $i--)
{
if ( $tree[$i][0] < $lastlevel )
for ($j=$tree[$i][0]+1; $j <= $maxlevel; $j++)
$levels[$j]=0;
if ( $levels[$tree[$i][0]]==0 )
{
$levels[$tree[$i][0]]=1;
$tree[$i][4]=1;
}
else
$tree[$i][4]=0;
$lastlevel=$tree[$i][0];
}
for ($i=0; $i < count($tree); $i++)
if ($tree[$i][0]==1)
$visible[$i]=1;
for ($i=0; $i < count($explevels); $i++)
{
$n=$explevels[$i];
if ( ($visible[$n]==1) && ($expand[$n]==1) )
{
$j=$n+1;
while ( $tree[$j][0] > $tree[$n][0] )
{
if ($tree[$j][0]==$tree[$n][0]+1) $visible[$j]=1;
$j++;
}
}
}
for ($i=0; $i<$maxlevel; $i++)
$levels[$i]=1;
$maxlevel++;
echo "\n";
echo "";
for ($i=0; $i<$maxlevel; $i++)
echo "";
echo "
\n";
$cnt=0;
while ($cnt{
if ($visible[$cnt])
{
echo "";
$i=0;
while ($i<$tree[$cnt][0]-1)
{
if ($levels[$i]==1)
echo "";
else
echo "";
$i++;
}
if ($tree[$cnt][4]==1)
{
echo "";
$levels[$tree[$cnt][0]-1]=0;
}
else
{
echo "";
$levels[$tree[$cnt][0]-1]=1;
}
if ($tree[$cnt+1][0]>$tree[$cnt][0])
{
$i=0; $params="?p=";
while($i{
if ( ($expand[$i]==1) && ($cnt!=$i) || ($expand[$i]==0 && $cnt==$i))
{
$params=$params.$i;
$params=$params."|";
}
$i++;
}
if ($expand[$cnt]==0)
echo "";
else
echo "";
}
else
echo "";
if ($tree[$cnt][2]=="")
echo "".$tree[$cnt][1]."";
else
echo "".$tree[$cnt][1]."";
echo "
\n";
}
$cnt++;
}
echo "\n";
?>



添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.