<?php

/*
	[SupeSite/X-Space] (C)2001-2006 Comsenz Inc.
	TAGÐã¹¦ÄÜ

	$RCSfile: batch.tagshow.php,v $
	$Revision: 1.9 $
	$Date: 2007/02/01 18:33:45 $
*/

include_once('./include/main.inc.php');
include_once(S_ROOT.'./language/batch.lang.php');

dbconnect();

$tagname = empty($_GET['tagname'])?'':trim($_GET['tagname']);
if(empty($tagname)) showxml($blang['parameter_error']);

$html = '<h5><a href="javascript:taghide();" target="_self">'.$blang['close'].'</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">'.$blang['see_more'].'</a></p>';
} else {
	$html .= '<li>'.$blang['not_found_the_tag'].'</li></ul>';
}

$html .= '</div>';

showxml($html);

?>