温馨提醒
如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢
本文最后更新于2025年4月25日,已超过 180天没有更新
主要用于帝国cms后台在栏目比较多的情况下,栏目展示过多,采用分页形式。
使用方法:
将下方代码保存为ListEnews.php,并覆盖/e/admin/ListEnews.php文件即可。如果后期觉得不适用了,可以再把官方的文件替换过来即可。
新ListEnews.php文件代码如下:
<?php
define('EmpireCMSAdmin','1');
require("../class/connect.php");
require("../class/db_sql.php");
require("../class/functions.php");
require LoadLang("pub/fun.php");
$link=db_connect();
$empire=new mysqlquery();
//验证用户
$lur=is_login();
$logininid=(int)$lur['userid'];
$loginin=$lur['username'];
$loginrnd=$lur['rnd'];
$loginlevel=$lur['groupid'];
$loginadminstyleid=$lur['adminstyleid'];
//ehash
$ecms_hashur=hReturnEcmsHashStrAll();
//数据表
$changetbs='';
$dh='';
$tbi=0;
$tbsql=$empire->query("select tbname,tname from {$dbtbpre}enewstable order by tid");
while($tbr=$empire->fetch($tbsql))
{
$tbi++;
$changetbs.=$dh.'new ContextItem("'.$tbr['tname'].'",function(){ parent.document.main.location="ListAllInfo.php?tbname='.$tbr['tbname'].$ecms_hashur['ehref'].'"; })';
if($tbi%3==0)
{
$changetbs.=',new ContextSeperator()';
}
$dh=',';
}
$search=$ecms_hashur['ehref'];
$page=(int)$_GET['page'];
$page=RepPIntvar($page);
$start=0;
$line=$public_r['add_hpagenum']?$public_r['add_hpagenum']:10;//每页显示条数
$page_line=12;//每页显示链接数
$offset=$page*$line;//总偏移量
$sql = $empire->query("select classid,classname from {$dbtbpre}enewsclass where bclassid=0 order by myorder asc,classid asc limit $offset,$line");
$num = $empire->gettotal("select count(*) as total from {$dbtbpre}enewsclass where bclassid=0");
$returnpage=_sClassPage($num,$line,$page_line,$start,$page,$search);
function sReturnClassTr($r){
global $class_r;
if($r['islast']) {
return '<tr><td id="pr'.$r[classid].'" class="file" onclick=""><a onclick="tourl(0,'.$r[classid].')" onmouseout="chft(this,0,'.$r[classid].')" onmouseover="chft(this,1,'.$r[classid].')" oncontextmenu="ShRM(this,0,'.$r[classid].',\'\',1)" title="栏目ID:'.$r[classid].'" style="">'.$r[classname].'</a></td></tr>';
}else{
return '<tr><td id="pr'.$r[classid].'" class="menu1" onclick="chengstate('.$r[classid].')"><a onmouseout="chft(this,0,'.$r[classid].')" onmouseover="chft(this,1,'.$r[classid].')" oncontextmenu="ShRM(this,0,'.$r[classid].',\'\',0)" title="栏目ID:'.$r[classid].'" style="">'.$r[classname].'</a></td></tr>';
}
}
function _sClassPage($num,$line,$page_line,$start,$page,$search){
global $fun_r;
if($num<=$line)
{
return '';
}
$search=RepPostStr($search,1);
$url=eReturnSelfPage(0).'?page';
$snum=2;//最小页数
$totalpage=ceil($num/$line);//取得总页数
//上一页
if($page<>0)
{
$pagepr=$page-1;
$prepage='<a href="'.$url.'='.$pagepr.$search.'">'.$fun_r['adminpripage'].'</a>';
}
//下一页
if($page!=$totalpage-1)
{
$pagenex=$page+1;
$nextpage=' <a href="'.$url.'='.$pagenex.$search.'">'.$fun_r['adminnextpage'].'</a>';
}
$returnstr=$prepage.$nextpage;
return $returnstr;
}
//显示无限级栏目缓存
function _sCreateClassCache($bclassid,$exp,$expjs,$expmodjs){
global $empire,$fun_r,$dbtbpre,$public_r,$logininid;
$userid = $logininid;
if(empty($bclassid))
{
$bclassid=0;
$exp='';
$expjs='|-';
$expmodjs='|-';
}
else
{
$exp=' '.$exp;
$expjs=' '.$expjs;
$expmodjs=" ".$expmodjs;
}
$sql=$empire->query("select classid,classname,bclassid,islast,classpath,classurl,listdt,sonclass,tbname,modid,myorder,onclick,openadd,wburl from {$dbtbpre}enewsclass where bclassid='$bclassid' order by myorder,classid");
$listnews='';
$num=$empire->num1($sql);
if($num==0)
{
return $listnews;
}
$listnews.='<table border=0 cellspacing=0 cellpadding=0>';
$i=1;
while($r=$empire->fetch($sql))
{
$classurl=sys_ReturnBqClassUrl($r);
//------ 管理栏目页面 ------
$divonclick="";
$start_tbody="";
$end_tbody="";
$start_tbody1="";
$docinfo="";
$classinfotype='';
//终级栏目
if($r[islast])
{
$img="<a href='#e' onclick=addi(".$r[classid].")><img src='../data/images/txt.gif' border=0></a>";
$bgcolor="#ffffff";
$renewshtml=" <a href='#e' onclick=renews(".$r[classid].",'".$r[tbname]."')>".$fun_r['news']."</a> ";
$docinfo=" <a href='#e' onclick=docinfo(".$r[classid].")>归档</a>";
$classinfotype=" <a href='#e' onclick=ttc(".$r[classid].")>分类</a>";
}
else
{
$img="<img src='../data/images/dir.gif'>";
if(empty($r[bclassid]))
{
$bgcolor="#DBEAF5";
$divonclick=" onMouseUp='turnit(classdiv".$r[classid].");' style='CURSOR:hand'";
$start_tbody="<tbody id='classdiv".$r[classid]."'>";
$end_tbody="</tbody>";
//缩
$start_tbody1="<tbody id='classdiv".$r[classid]."' style='display:none'>";
}
else
{$bgcolor="#ffffff";}
$renewshtml=" <a href='#e' onclick=renews(".$r[classid].",'".$r[tbname]."')>".$fun_r['news']."</a> ";
}
//外部栏目
$classname=$r[classname];
if($r['wburl'])
{
$classname="<font color='#666666'>".$classname." (外部)</font>";
}
$onelistclass="<tr bgcolor='".$bgcolor."' height=25><td><input type=text name=myorder[] value=".$r[myorder]." size=2><input type=hidden name=classid[] value=".$r[classid]."></td><td".$divonclick.">".$exp.$img."</td><td align=center>".$r[classid]."</td><td><input type=checkbox name=reclassid[] value=".$r[classid]."> <a href='".$classurl."' target=_blank>".$classname."</a></td><td align=center>".$r[onclick]."</td><td><a href='#e' onclick=editc(".$r[classid].")>".$fun_r['edit']."</a> <a href='#e' onclick=copyc(".$r[classid].")>".$fun_r['copyclass']."</a> <a href='#e' onclick=delc(".$r[classid].")>".$fun_r['del']."</a></td><td><a href='#e' onclick=relist(".$r[classid].")>".$fun_r['re']."</a>".$renewshtml."<a href='#e' onclick=rejs(".$r[classid].")>JS</a> <a href='#e' onclick=tvurl(".$r[classid].")>调用</a>".$classinfotype.$docinfo."</td></tr>";
if(empty($r['wburl']))
{
//------ 管理信息页面 ------
//链接地址
$infoclassurl='';
//终级栏目
if($r[islast])
{
//最后一个子栏目
if($i==$num)
{$menutype="file1";}
else
{$menutype="file";}
$infoclassname="<a onclick=tourl($r[bclassid],$r[classid]) onmouseout=chft(this,0,$r[classid]) onmouseover=chft(this,1,$r[classid]) oncontextmenu=ShRM(this,".$r[bclassid].",".$r[classid].",'".$infoclassurl."',1)>".$r[classname]."</a>";
$onmouseup="";
}
else
{
//最后一个大栏目
if($i==$num)
{
$menutype="menu3";
$listtype="list1";
$onmouseup="chengstate('".$r[classid]."')";
}
else
{
$menutype="menu1";
$listtype="list";
$onmouseup="chengstate('".$r[classid]."')";
}
$infoclassname="<a onmouseout=chft(this,0,$r[classid]) onmouseover=chft(this,1,$r[classid]) oncontextmenu=ShRM(this,".$r[bclassid].",".$r[classid].",'".$infoclassurl."',0)>".$r[classname]."</a>";
}
$listnews.='<tr><td id="pr'.$r[classid].'" class="'.$menutype.'" onclick="'.$onmouseup.'">'.$infoclassname.'</td></tr>';
//JS颜色
if($r[islast])
{
$jscolor=" style='background:#".$public_r['chclasscolor']."'";
}
else
{
$jscolor="";
}
//------ 投稿 ------
$haveadd=0;
$oldhaveadd=0;
}
//取得子栏目
if(empty($r[islast]))
{
$retr=_sCreateClassCache($r['classid'],$exp,$expjs,$expmodjs,$userid);
if(empty($r['wburl']))
{
$listnews.='<tr id="item'.$r[classid].'" style="display:none"><td class="'.$listtype.'">'.$retr.'</td></tr>';
}
}
$i+=1;
}
$listnews.='</table>';
return $listnews;
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>管理信息</title>
<link href="../data/menu/menu.css" rel="stylesheet" type="text/css">
<script src="../data/menu/menu.js" type="text/javascript"></script>
<script language="javascript" src="../data/rightmenu/context_menu.js"></script>
<script language="javascript" src="../data/rightmenu/ieemu.js"></script>
<style>
/*分页样式*/
.epages{margin:10px 0 0 0;font:11px/12px Tahoma;}
.epages *{vertical-align:middle;}
.epages a{padding:1px 4px 1px;border:1px solid #A6CBE7;margin:0 1px 0 0;text-align:center;text-decoration:none;font:normal 12px/14px verdana;}
.epages a:hover{border:#659B28 1px solid;background:#f3f8ef;text-decoration:none;color:#004c7d}
</style>
<SCRIPT lanuage="JScript">
if(self==top)
{
//self.location.href='admin.php<?=$ecms_hashur['whehref']?>';
}
function chft(obj,ecms,classid){
if(ecms==1)
{
obj.style.fontWeight='bold';
}
else
{
obj.style.fontWeight='';
}
obj.title='栏目ID:'+classid;
}
function goaddclass(){
parent.main.location.href='AddClass.php?enews=AddClass<?=$ecms_hashur['ehref']?>';
}
function tourl(bclassid,classid){
parent.main.location.href="ListNews.php?<?=$ecms_hashur['ehref']?>&bclassid="+bclassid+"&classid="+classid;
}
if(moz) {
extendEventObject();
extendElementModel();
emulateAttachEvent();
}
//右键菜单
function ShRM(obj,bclassid,classid,classurl,showmenu)
{
var eobj,popupoptions;
classurl='<?=$public_r[newsurl]?>e/public/ClassUrl/?classid='+classid;
if(showmenu==1)
{
popupoptions = [
new ContextItem("增加信息",function(){ parent.document.main.location="AddNews.php?<?=$ecms_hashur['ehref']?>&enews=AddNews&bclassid="+bclassid+"&classid="+classid; }),
new ContextSeperator(),
new ContextItem("刷新栏目",function(){ parent.document.main.location="enews.php?<?=$ecms_hashur['href']?>&enews=ReListHtml&classid="+classid; }),
new ContextItem("刷新栏目JS",function(){ parent.document.main.location="ecmschtml.php?<?=$ecms_hashur['href']?>&enews=ReSingleJs&doing=0&classid="+classid; }),
new ContextItem("刷新首页",function(){ parent.document.main.location="ecmschtml.php?enews=ReIndex<?=$ecms_hashur['href']?>"; }),
new ContextSeperator(),
new ContextItem("预览首页",function(){ window.open("../../"); }),
new ContextItem("预览栏目",function(){ window.open(classurl); }),
new ContextSeperator(),
new ContextItem("修改栏目",function(){ parent.document.main.location="AddClass.php?<?=$ecms_hashur['ehref']?>&classid="+classid+"&enews=EditClass"; }),
new ContextItem("增加新栏目",function(){ parent.document.main.location="AddClass.php?enews=AddClass<?=$ecms_hashur['ehref']?>"; }),
new ContextItem("复制栏目",function(){ parent.document.main.location="AddClass.php?<?=$ecms_hashur['ehref']?>&classid="+classid+"&enews=AddClass&docopy=1"; }),
new ContextSeperator(),
new ContextItem("数据更新",function(){ parent.document.main.location="ReHtml/ChangeData.php<?=$ecms_hashur['whehref']?>"; }),
new ContextItem("增加采集节点",function(){ parent.document.main.location="AddInfoClass.php?<?=$ecms_hashur['ehref']?>&enews=AddInfoClass&newsclassid="+classid; }),
new ContextItem("管理附件",function(){ parent.document.main.location="file/ListFile.php?<?=$ecms_hashur['ehref']?>&type=9&classid="+classid; }),
new ContextSeperator()
]
}
else if(showmenu==2)
{
popupoptions = [
<?=$changetbs?>
]
}
else
{
popupoptions = [
new ContextItem("刷新栏目",function(){ parent.document.main.location="enews.php?<?=$ecms_hashur['href']?>&enews=ReListHtml&classid="+classid; }),
new ContextItem("刷新栏目JS",function(){ parent.document.main.location="ecmschtml.php?<?=$ecms_hashur['href']?>&enews=ReSingleJs&doing=0&classid="+classid; }),
new ContextItem("刷新首页",function(){ parent.document.main.location="ecmschtml.php?enews=ReIndex<?=$ecms_hashur['href']?>"; }),
new ContextItem("数据更新",function(){ parent.document.main.location="ReHtml/ChangeData.php<?=$ecms_hashur['whehref']?>"; }),
new ContextSeperator(),
new ContextItem("预览首页",function(){ window.open("../../"); }),
new ContextItem("预览栏目",function(){ window.open(classurl); }),
new ContextSeperator(),
new ContextItem("修改栏目",function(){ parent.document.main.location="AddClass.php?<?=$ecms_hashur['ehref']?>&classid="+classid+"&enews=EditClass"; }),
new ContextItem("增加新栏目",function(){ parent.document.main.location="AddClass.php?enews=AddClass<?=$ecms_hashur['ehref']?>"; }),
new ContextItem("复制栏目",function(){ parent.document.main.location="AddClass.php?<?=$ecms_hashur['ehref']?>&classid="+classid+"&enews=AddClass&docopy=1"; }),
new ContextSeperator()
]
}
ContextMenu.display(popupoptions)
}
</SCRIPT>
</head>
<body bgcolor="#FFCFAD" onLoad="initialize();ContextMenu.intializeContextMenu();">
<table border='0' cellspacing='0' cellpadding='0'>
<tr height=20>
<td id="home"><img src="../data/images/homepage.gif" border=0></td>
<td><a href="#ecms" onclick="parent.main.location.href='ListAllInfo.php<?=$ecms_hashur['whehref']?>';" onmouseout="this.style.fontWeight=''" onmouseover="this.style.fontWeight='bold'" oncontextmenu="ShRM(this,0,0,'',2)"><b>管理信息</b></a></td>
</tr>
</table>
<table border='0' cellspacing='0' cellpadding='0'>
<tbody>
<?php
while ($r=$empire->fetch($sql)) {
echo sReturnClassTr($r);
echo '<tr id="item'.$r[classid].'" style="display:none"><td class="list">'._sCreateClassCache($r['classid']).'</td></tr>';
}
?>
</tbody>
</table>
<div class="epages"><?=$returnpage?></div>
</body>
</html>
<?php
db_close();
$empire=null;
?>
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系客服QQ3387285338进行处理。



评论0+