<?php
//加载
require_once ("../manager_include.inc");

// 参数取得
$tag = ParamUtil::getRequestString("tag");
$selected_tags = ParamUtil::getRequestString("selected_tags");//##分割的字符串

//查询
$param = array();
$param["tag"] = $tag;
$param["delete_flg"] = false;
$tmp_list = ArticleTagsDat::getList($param);
if(empty($tmp_list)) {
	//添加新标签
	$tmp = new ArticleTagsDat();
	$tmp->tag = $tag;
	$tmp->click_count = 0;
	$tmp->save();
}

//查询所有标签
$param = array();
$param["delete_flg"] = false;
$tag_list = ArticleTagsDat::getList($param, "id", "asc");

ob_start()
?>
<?
	if(!empty($tag_list)) {
		foreach($tag_list as $tagObj) {
			$class_name = "tag";
			if(!empty($selected_tags) && strpos($selected_tags,"##" . $tagObj->tag) !== false) {
				$class_name = "tag_selected";
			}
?>
<p class="<?=$class_name?>" onClick="clickTag('<?=$tagObj->tag?>');"><?=$tagObj->tag?></p>
<?
		}
	}
?>
<?
$html = ob_get_contents();
ob_end_clean();
print json_encode(array("html"=>$html));


