e/class/userfun.php添加函数
//批量复制TAGS到ref="https://xwenw.com/tag/%e5%85%b3%e9%94%ae%e8%af%8d" target="_blank">关键词
function eCopyTag2Key($classid,$id,$newstime){
global $empire,$dbtbpre,$class_r;
$count = count($id); //统计ID数量
if (empty($count))
{//如果id没选中
printerror("未选择信息ID", "", 1, 0, 1);
}
$classid=(int)$classid;//这一步可省略
$mid=(int)$class_r[$classid][modid];//取modid值,这一步可省略
for($i=0;$i<$count;$i++)
{
$id[$i] = (int)$id[$i];
$tbname=$class_r[$classid][tbname];//获取表名
$r = $empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where id='$id[$i]' limit 1");
$t = $empire->fetch1("select infotags from {$dbtbpre}ecms_".$tbname."_data_".$r['stb']." where id='$id[$i]'");//从信息表中取infotags和keyboard值
$t=array_merge($r,$t);
$taga=$t['infotags'].",".$t['keyboard']; //组合TAGS:在原有的infotags值上加上新keyboard
$tagb[$i] = explode(",",$taga); //设置数组:用,分割tag
$tagc=array_values(array_unique($tagb[$i])); //数组排重:排除重复?
for($t=0;$t<count($tagb[$i]);$t++)
{//二级子循环TAGS数组输出
$newtags[$i].= ",".$tagc[$t];
}
$empire->query("update {$dbtbpre}ecms_".$tbname." set keyboard='".trim($newtags[$i],",")."' where id='$id[$i]'");//将新生成的keyboard写入到表中
}
printerror("已成功将TAGS批量复制到关键词字段", "", 1, 0, 1);
}
//加入TAG表
function eInsertTags2($tags,$classid,$id,$newstime){
global $empire,$dbtbpre,$class_r;
$tags = RepPostVar($tags);
//$tag = explode(",", $tags);
$count = count($id); //统计ID数量
if (empty($count))
{//如果id没选中
printerror("未选择信息ID", "", 1, 0, 1);
}
$classid=(int)$classid;
$mid=(int)$class_r[$classid][modid];//取modid值
for($i=0;$i<$count;$i++)
{
$id[$i] = (int)$id[$i];
$tbname=$class_r[$classid][tbname];//获取表名
$r1 = $empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where id='$id[$i]' limit 1");
$t = $empire->fetch1("select infotags from {$dbtbpre}ecms_".$tbname."_data_".$r1['stb']." where id='$id[$i]'");//从信息表中取infotags和keyboard值
$t=array_merge($r1,$t);
$taga=$t['infotags'].",".$tags; //组合TAGS:在原有的infotags值上加上新tag
$tagb[$i] = explode(",",$taga); //设置数组:用,分割tag
$tagc=array_values(array_unique($tagb[$i])); //数组排重:排除重复?
for($t=0;$t<count($tagb[$i]);$t++)
{//二级子循环TAGS数组输出
$newtags[$i].= ",".$tagc[$t];
$r=$empire->fetch1("select tagid from {$dbtbpre}enewstags where tagname='$tagc[$t]' limit 1");//查询有无同名的tag
if($r[tagid])
{//如果有tagid,即enewstags表中有相同tag
$datar=$empire->fetch1("select tagid,classid,newstime from {$dbtbpre}enewstagsdata where tagid='$r[tagid]' and id='$id[$i]' and mid='$mid' limit 1");//用tagid,id和mid对enewstagsdata进行查询
if($datar[tagid])
{//如果有数据
if($datar[classid]!=$classid||$datar[newstime]!=$newstime)
{//如果classid和newstime不相同
$empire->query("update {$dbtbpre}enewstagsdata set classid='$classid',newstime='$newstime' where tagid='$r[tagid]' and id='$id[$i]' and mid='$mid' limit 1");//则开始更新
}
}
else
{//查询后没有此数据,则先更新enewstags表,在数量上加1
$empire->query("update {$dbtbpre}enewstags set num=num+1 where tagid='$r[tagid]'");
$empire->query("update {$dbtbpre}ecms_".$tbname."_data_".$r1['stb']." set infotags='".trim($newtags[$i],",")."' where id='$id[$i]'");//然后在信息表infotags字段中加上这个新tag,如果按舍得的方法,这一步就可以免了
$empire->query("insert into {$dbtbpre}enewstagsdata(tagid,classid,id,newstime,mid) values('$r[tagid]','$classid','$id[$i]','$newstime','$mid');");//然后在enewstagsdata表中插入这些数据
}
}
else
{//如果没有此tag
$empire->query("update {$dbtbpre}ecms_".$tbname."_data_".$r1['stb']." set infotags='".trim($newtags[$i],",")."' where id='$id[$i]'");//先在信息表中加上此tag,如果按舍得的方法,这一步就可以免了
$empire->query("insert into {$dbtbpre}enewstags(tagname,num,isgood,cid) values('$tagc[$t]',1,0,0);");//在enewstags表中插入新值
$tagid=$empire->lastid();//把这个tagid给取出来
$empire->query("insert into {$dbtbpre}enewstagsdata(tagid,classid,id,newstime,mid) values('$tagid','$classid','$id[$i]','$newstime','$mid');");//既然是没有tagid的,那就在enewstagsdata也得插入新值(不用再查询)
}
}
}
printerror("批量添加TAGS成功", "", 1, 0, 1);
}
eadminecmsInfo.php我加在了123-137行,你们随意
elseif($enews=="CopyTag2Key")//列表批量复制Tags为关键词
{
$classid=$_POST['classid'];
$id=$_POST['id'];
$newstime=time();
eCopyTag2Key($classid,$id,$newstime);
}
elseif($enews=="AddTags_all")//列表批量添加Tags
{
$classid=$_POST['classid'];
$id=$_POST['id'];
$tags=$_POST['add_listtags'];
$newstime=time();
eInsertTags2($tags,$classid,$id,$newstime);
}
e/data/html/list/listinfo.php
<tr>
<td width="68%" height="25">
<font color="#666666">备注:多选框蓝色为未审核信息;发布者红色为会员投稿;信息ID粗体为未生成,点击ID可刷新页面.</font>
</td>
</tr>
改为
<tr>
<td width="68%" height="25">
<font color="#666666"><input type="text" name="add_listtags" id="add_listtags" size="50" value="" />
<input type="submit" name="Submit100" value="批量添加TAGS" onClick="document.listform.enews.value='AddTags_all';document.listform.action='ecmsinfo.php';"> <input type="submit" name="Submit99" value="批量复制TAGS" onClick="document.listform.enews.value='CopyTag2Key';document.listform.action='ecmsinfo.php';"><p>备注:1.先选中要操作的ID,然后在左侧文本框内直接输入多个关键词,以","隔开;然后点击批量添加TAGS即可;之后可点击"批量复制TAGS"将TAG复制到关键词字段.</p><p>2.多选框蓝色为未审核信息;发布者红色为会员投稿;信息ID粗体为未生成,点击ID可刷新页面.</p></font>
</td>
</tr>
评论(0)