织梦后台文章管理中增加批量添加tag标签功能(3)

if(!empty($aid)&& empty($qstr))

{

$qstr = $aid;

}

if($qstr=='')

{

ShowMsg("参数无效!", $ENV_GOBACK_URL);

exit();

}

 

if(empty($tags))

{

ShowMsg("必需输入tags标签!", $ENV_GOBACK_URL);

exit();

}

$tags = str_replace(',',',', $tags);

$tagss = explode(',',$tags);

if(empty($tagss)){

ShowMsg("必需输入tags标签!", $ENV_GOBACK_URL);

exit();

}

 

$arcids = ereg_replace('[^0-9,]','',ereg_replace('`',',', $qstr));

$arcids_arr = explode(',', $arcids);

if(empty($arcids_arr)){

ShowMsg("参数无效!", $ENV_GOBACK_URL);

exit();

}

 

foreach($arcids_arr as $id){

/*

* 处理修改后的Tag

*/

$oldtag =GetTags($id);

$oldtags = explode(',',$oldtag);

foreach($tagss as $tag)

{

$tag = trim($tag);

if(isset($tag[255])|| $tag!=stripslashes($tag))

{

continue;

}

if(!in_array($tag,$oldtags))

{

InsertOneTag($tag,$id);

}

}

foreach($oldtags as $tag)

{

if(!in_array($tag,$tagss))

{

$dsql->ExecuteNoneQuery("Delete From `js_taglist` where aid='$id' And tag like '$tag' ");

$dsql->ExecuteNoneQuery("Update `js_tagindex` set total=total-1 where tag like '$tag' ");

}

else

{

$dsql->ExecuteNoneQuery("Update `js_taglist` set `arcrank` = '$arcrank', `typeid` = '$typeid' where tag like '$tag' ");

}

}

}

ShowMsg("成功修改选中文档的tags标签!", $ENV_GOBACK_URL);

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/97caf570b8991caafa87d3525a36f854.html