1、修改admin/addclass.PHP文件,大约在1153行,<input type="submit" name="submit" value="提交">
的前面增加:<?PHP if($docopy) { ?><input type="checkBox" name="copyzlm" value="1" checked>复制子栏目 <? }?>
2、修改admin/emsclass.PHP文件,大约在52行,将“AddClass($_POST,$logininID,$loginin);”修改为“cAddClass($_POST,$loginin);”
3、将以下代码拷贝到class/userfun.PHP中。
function cAddClass($add,$userID,$username){
global $empire,$dbtbpre;
if($add[copyzlm]=='1'){
cAddClass1($add,$username);
$r = $empire->fetch1( "select * from {$dbtbpre}enewsclass order by classID desc limit 1" );
$bsql=$empire->query("select * from {$dbtbpre}enewsclass where bclassID='$add[classID]' and bclassID<>'0'");
while($br=$empire->fetch($bsql)){
$br[copyzlm]='1';
$br[bclassID]=$r[classID];
$br[pripath]=$r[classpath];
$br[classpath]=strrchr($br[classpath],'/');
if($br[islast]==0){
$brr=$br;
cAddClass($brr,$username);//递归
}else{
cAddClass1($br,$username,'1');
}
}
}else{
AddClass($add,$username);
}
}
//增加栏目
function cAddClass1($add,$zz=0){
global $empire,$dbtbpre;
//增加外部栏目
if($add[eCMSclasstype])
{
AdDWbClass($add,$username);
}
$add[classpath]=trim($add[classpath]);
if(!$add[classname]||!$add[classpath]||!$add[modID])
{
printerror("EmptyClass","");
}
if($add[islast]&&(!$add[newstempID]||!$add[ListtempID]))
{
printerror("LastMustChange","");
}
// *** 作权限
CheckLevel($userID,$classID,"class");
if($zz==0){
$add=DoPostClassVar($add);
}
//目录已存在
if(strchr($add[classpath],".")||strchr($add[classpath],"/")||strchr($add[classpath],""))
{
// printerror("badpath","");
}
$classpath=$add[pripath].$add[classpath];
if(file_exists("../../".$classpath))
{
printerror("ReClasspath","");
}
//取得表名
$tabler=GetModtable($add[modID]);
$tabler[tID]=(int)$tabler[tID];
//增加大栏目
if(!$add[islast])
{
if(empty($add[bclassID]))//主栏目
{
$son;
$feather;
}
else//中级栏目
{
//取得上一级父栏目
$r=$empire->fetch1("select featherclass,islast,wburl from {$dbtbpre}enewsclass where classID='$add[bclassID]'");
if($r[islast])//是否终极栏目
{
printerror("BclassNotLast","");
}
if($r[wburl])
{
printerror("BclassNotWb","");
}
if(empty($r[featherclass]))
{
$r[featherclass]="|";
}
$featherclass=$r[featherclass].$add[bclassID]."|";
$son;
}
//建立目录
CreateClasspath($classpath);
$sql=$empire->query("insert into {$dbtbpre}enewsclass(bclassID,classname,is_zt,sonclass,lencord,link_num,newstempID,onclick,ListtempID,featherclass,classpath,classtype,newspath,filename,filetype,openpl,openadd,newline,hotline,goodline,classurl,groupID,myorder,filename_qz,hotplline,modID,checked,docheckuser,checkuser,firstline,bname,isList,searchtempID,tID,tbname,maxnum,checkpl,down_num,online_num,Listorderf,Listorder,reorderf,reorder,intro,classimg,jstempID,addinfofen,Listdt,showclass,showdt,checkqadd,qaddList,qaddgroupID,qaddshowkey,adminqinfo,doctime,classpagekey,dtListtempID,classtempID,nreclass,nreinfo,nreJs,nottobq,ipath,addreinfo,haddList,sameTitle,definfoVoteID,wburl,qeditchecked,wapstyleID,repreinfo,pltempID,cgroupID) values($add[bclassID],'$add[classname]','$sonclass',$add[lencord],$add[link_num],$add[newstempID],$add[ListtempID],'$featherclass',$add[islast],'$classpath','$add[classtype]','$add[newspath]',$add[filename],'$add[filetype]',$add[openpl],$add[openadd],$add[newline],$add[hotline],$add[goodline],'$add[classurl]',$add[groupID],$add[myorder],'$add[filename_qz]',$add[hotplline],$add[modID],$add[checked],$add[docheckuser],'$add[checkuser]',$add[firstline],'$add[bname]',$add[isList],$add[searchtempID],$tabler[tID],'$tabler[tbname]',$add[maxnum],$add[checkpl],$add[down_num],$add[online_num],'$add[Listorderf]','$add[Listorder]','$add[reorderf]','$add[reorder]','$add[intro]','$add[classimg]',$add[jstempID],$add[addinfofen],$add[Listdt],$add[showclass],$add[showdt],$add[checkqadd],$add[qaddList],'$add[qaddgroupID]',$add[qaddshowkey],$add[adminqinfo],$add[doctime],'$add[classpagekey]','$add[dtListtempID]','$add[classtempID]',$add[nreclass],$add[nreinfo],$add[nreJs],$add[nottobq],'$add[ipath]',$add[addreinfo],$add[haddList],$add[sameTitle],$add[definfoVoteID],'',$add[qeditchecked],$add[wapstyleID],'$add[repreinfo]','$add[pltempID]','$add[cgroupID]');");
$lastID=$empire->lastID();
//副表
$empire->query("replace into {$dbtbpre}enewsclassadd(classID,classtext) values('$lastID','".addslashes($add[classtext])."');");
TogNotReClass(1);
GetClass();
if($add[isList]==0||$add[isList]==2)
{
$classtemp=$add[isList]==2?GetClasstext($lastID):GetClasstemp($add['classtempID']);
NewsBq($lastID,$classtemp,1);
}
DelListEnews();//删除缓存文件
GetSearch($add[modID]);//更新缓存
if($sql){
insert_dolog("classID=".$lastID."<br>classname=".$add[classname]);// *** 作日志
// printerror("AddClassSuccess","AddClass.PHP?enews=AddClass&from=$add[from]");
}
else{
printerror("DbError","");
}
}
//增加终级栏目
else
{
//文件前缀
$add[filename_qz]=RepfilenameQz($add[filename_qz]);
if(empty($add[bclassID]))//主类别为终级栏目时
{
$son;
$feather;
}
else//子栏目
{
//取得上一级父栏目
$r=$empire->fetch1("select featherclass,wburl from {$dbtbpre}enewsclass where classID='$add[bclassID]'");
//是否终极类别
if($r[islast])
{
printerror("BclassNotLast","");
}
if(empty($r[featherclass])){
$r[featherclass]="|";
}
$featherclass=$r[featherclass].$add[bclassID]."|";
$son;
}
//建立栏目目录
CreateClasspath($classpath);
$sql=$empire->query("insert into {$dbtbpre}enewsclass(bclassID,'".addslashes($add[classtext])."');");
//修改父栏目的子栏目
if($add[bclassID])
{
$b_r=$empire->fetch1("select sonclass,featherclass from {$dbtbpre}enewsclass where classID='$add[bclassID]'");
if(empty($b_r[sonclass]))
{
$b_r[sonclass]="|";
}
$new_sonclass=$b_r[sonclass].$lastID."|";
$update=$empire->query("update {$dbtbpre}enewsclass set sonclass='$new_sonclass' where classID='$add[bclassID]'");
//更改父类别的父栏目的子栏目
$where=ReturnClass($b_r[featherclass]);
if(empty($where)){
$where="classID=0";
}
$bsql=$empire->query("select sonclass,classID from {$dbtbpre}enewsclass where ".$where);
while($br=$empire->fetch($bsql))
{
if(empty($br[sonclass]))
{
$br[sonclass]="|";
}
$new_sonclass=$br[sonclass].$lastID."|";
$update=$empire->query("update {$dbtbpre}enewsclass set sonclass='$new_sonclass' where classID='$br[classID]'");
}
}
DelListEnews();//删除缓存文件
TogNotReClass(1);
GetClass();
GetSearch($add[modID]);//更新缓存
if($sql){
insert_dolog("classID=".$lastID."<br>classname=".$add[classname]);// *** 作日志
// printerror("AddLastClassSuccess","history.go(-1)");
}
}
}
上面代码,只有函数cAddClass是我写的,下面的函数cAddClass是对wf原来的函数AddClass稍作修改拷贝过来的,放到userfun.PHP文件中目的是不对classfun.PHP文件作改动。
好了,复制栏目试试看
总结
以上是内存溢出为你收集整理的帝国cms复制栏目时同时复制子栏目全部内容,希望文章能够帮你解决帝国cms复制栏目时同时复制子栏目所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)