<?

/*
	[SupeSite/X-Space] (C)2001-2006 Comsenz Inc.
	TAG秀功\能

	$RCSfile: batch.tagshow.php,v $
	$Revision: 1.6 $
	$Date: 2006/10/17 07:51:52 $
*/

include_once('./include/main.inc.php');

dbconnect();

$tagname = empty($_GET['tagname'])?'':trim($_GET['tagname']);
if(empty($tagname)) showxml('參數錯誤');

$html = '<h5><a href="javascript:taghide();" target="_self">關閉</a>TAG: '.$tagname.'</h5>
<div class="xspace-ajaxcontent">
<ul style="margin: 0.5em; padding-left: 2.7em; text-indent: -2.7em; list-style: none; line-height: 1.8em;">';

$query = $_SGLOBAL['db']->query('SELECT tagid FROM '.tname('tags').' WHERE tagname=\''.$tagname.'\'');
if($tag = $_SGLOBAL['db']->fetch_array($query)) {
	$query = $_SGLOBAL['db']->query('SELECT st.tagid, i.uid, i.type, i.itemid, i.subject FROM '.tname('spacetags').' st INNER JOIN '.tname('spaceitems').' i ON i.itemid=st.itemid AND i.folder=1 WHERE st.tagid='.$tag['tagid'].' ORDER BY st.dateline DESC LIMIT 0,10');
	while($item = $_SGLOBAL['db']->fetch_array($query)) {
		if($item['type'] == 'news') {
			$item['url'] = geturl('action/viewnews/itemid/'.$item['itemid']);
		} else {
			$item['url'] = geturl('uid/'.$item['uid'].'/action/viewspace/itemid/'.$item['itemid']);
		}
		$html .= '<li>['.$lang[$item['type']].'] <a href="'.$item['url'].'" target="_blank">'.$item['subject'].'</a></li>';
	}
	$html .= '
	</ul>
	<p style="margin: 0; padding: 0.5em; border-top: 1px dotted #EEE; text-align: right;"><a href="'.geturl('action/tag/tagid/'.$tag['tagid']).'" target="_blank">查看更多</a></p>';
} else {
	$html .= '<li>沒有找到該TAG</li></ul>';
}

$html .= '</div>';

showxml($html);