e/class/userfun.php添加函數(shù)
//批量復(fù)制TAGS到關(guān)鍵詞
function eCopyTag2Key($classid,$id,$newstime){
global $empire,$dbtbpre,$class_r;
$count = count($id); //統(tǒng)計ID數(shù)量
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); //設(shè)置數(shù)組:用,分割tag
$tagc=array_values(array_unique($tagb[$i])); //數(shù)組排重:排除重復(fù)?
for($t=0;$t<count($tagb[$i]);$t++)
{//二級子循環(huán)TAGS數(shù)組輸出
$newtags[$i].= ",".$tagc[$t];
}
$empire->query("update {$dbtbpre}ecms_".$tbname." set keyboard='".trim($newtags[$i],",")."' where id='$id[$i]'");//將新生成的keyboard寫入到表中
}
printerror("已成功將TAGS批量復(fù)制到關(guān)鍵詞字段", "", 1, 0, 1);
}
//加入TAG表
function eInsertTags2($tags,$classid,$id,$newstime){
global $empire,$dbtbpre,$class_r;
$tags = RepPostVar($tags);
//$tag = explode(",", $tags);
$count = count($id); //統(tǒng)計ID數(shù)量
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); //設(shè)置數(shù)組:用,分割tag
$tagc=array_values(array_unique($tagb[$i])); //數(shù)組排重:排除重復(fù)?
for($t=0;$t<count($tagb[$i]);$t++)
{//二級子循環(huán)TAGS數(shù)組輸出
$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])
{//如果有數(shù)據(jù)
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
{//查詢后沒有此數(shù)據(jù),則先更新enewstags表,在數(shù)量上加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表中插入這些數(shù)據(jù)
}
}
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")//列表批量復(fù)制Tags為關(guān)鍵詞
{
$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">備注:多選框藍色為未審核信息;發(fā)布者紅色為會員投稿;信息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="批量復(fù)制TAGS" onClick="document.listform.enews.value='CopyTag2Key';document.listform.action='ecmsinfo.php';"><p>備注:1.先選中要操作的ID,然后在左側(cè)文本框內(nèi)直接輸入多個關(guān)鍵詞,以","隔開;然后點擊批量添加TAGS即可;之后可點擊"批量復(fù)制TAGS"將TAG復(fù)制到關(guān)鍵詞字段.</p><p>2.多選框藍色為未審核信息;發(fā)布者紅色為會員投稿;信息ID粗體為未生成,點擊ID可刷新頁面.</p></font>
</td>
</tr>