<?php
defined ( 'IN_TS' ) or die ( 'Access Denied.' );

$shopid = intval ( $_GET ['id'] );

$strshop = $new ['shop']->find ( 'shop', array (
		'shopid' => $shopid 
) );


if ($strshop == '') {
	header ( "HTTP/1.1 404 Not Found" );
	header ( "Status: 404 Not Found" );
	$title = '404';
	include pubTemplate ( "404" );
	exit ();
}

//卖家
$arrshopuser = aac ( 'user' )->getSimpleUser ( $strshop ['userid'] );

//是否关注
if($TS_USER['userid'] != '' && $TS_USER['userid'] != $arrshopuser['userid']){
	$userid=$arrshopuser['userid'];
	$followNum = $db->once_num_rows("select * from ".dbprefix."user_follow where userid='".$TS_USER['userid']."' and userid_follow='$userid'");
	if($followNum > '0'){
		$arrshopuser['isfollow'] = true;
	}else{
		$arrshopuser['isfollow'] = false;
	}
}else{
	$arrshopuser['isfollow'] = false;
}

// 是否审核
if ($strshop ['isaudit'] == 1 && $TS_USER['isadmin']==0 && $TS_USER['userid']!=$strshop['userid']) {
	tsNotice ( '内容审核中...' );
}

$strshop['content'] = tsDecode($strshop['content']);


// 获取评论
$page = isset ( $_GET ['page'] ) ? intval ( $_GET ['page'] ) : 1;
$url = tsUrl ( 'shop', 'show', array (
		'id' => $shopid,
		'page' => '' 
) );
$lstart = $page * 10 - 10;

$arrComments = $new ['shop']->findAll ( 'shop_comment', array (
		'shopid' => $shopid 
), 'addtime desc', null, $lstart . ',10' );

foreach ( $arrComments as $key => $item ) {
	$arrComment [] = $item;
	$arrComment[$key]['content'] = tsDecode($item['content']);
	$arrComment [$key] ['user'] = aac ( 'user' )->getSimpleUser ( $item ['userid'] );
}

$commentNum = $new ['shop']->findCount ( 'shop_comment', array (
		'shopid' => $shopid 
) );

$pageUrl = pagination ( $commentNum, 10, $page, $url );

// 标签
//$strshop ['tags'] = aac ( 'tag' )->getObjTagByObjid ( 'shop', 'shopid', $strshop ['shopid'] );
$title = $strshop['title'];
include template ( "show" );