<?php
if( !defined('ISDVBBS') ){
	header('HTTP/1.0 404 Not Found');
	exit;
}
require_once INC_PATH.'DV_Encoding.class.php';
require_once INC_PATH.'dv_code.php';
$_objEnc =& DV_Encoding::GetEncoding($charset);
$_tpl_skinPath = $spaceConfig_System['s_path'];
$_tpl_spaceName = $spaceName;
$_tpl_spaceUrl = $ModHtmlLinked;

	$_keyword = trim($GLOBALS['keyword']);
	$_stype = trim($GLOBALS['stype']);
	$_selType = is_numeric($GLOBALS['sel']) ? intval($GLOBALS['sel']) : 0 ;
	$_dYear = is_numeric($GLOBALS['dy']) ? $GLOBALS['dy'] : '' ;
	$_dMonth = is_numeric($GLOBALS['dm']) ? $GLOBALS['dm'] : '' ;
	$_dDay = is_numeric($GLOBALS['dd']) ? $GLOBALS['dd'] : '' ;

print <<<EOT
		<!-- 主体内容开始  -->
		<div class="MySpqceBody">
EOT;
global $spaceUserInfo;
$GLOBALS['DV_HTML_TITLE'] = "搜索结果 - {$spaceUserInfo['nickname']}的空间";
require printout('space.leftmenu');
print <<<EOT
		<script language="JavaScript" src="space/script/dv_main.js"></script>
		<script language="JavaScript" src="space/script/dv_form.js"></script>
		<script language="JavaScript" src="space/script/form_calendar.js"></script>
		<!-- 主体内容右边区开始 -->
			<div class="Right">
				<div class="TopicBlock">
					<h1>站内搜索</h1>
					<form method="post" name="search_form" action="spacesearch.php" style="display:inline;">
						<h3 style="width:auto; font-size: 12px; font-weight: 100; height: 26px; text-align: left; padding: 2px; margin:0px;">
							<input type="hidden" name="user" value="{$spaceName}" />
							<input type="text" name="keyword" value="{$_keyword}" size="25" />
							<input type="radio" class="radio" name="sel" value="0" checked="true" />标题
							<input type="radio" class="radio" name="sel" value="2" />内容
							<input type="radio" class="radio" name="sel" value="1" />作者
							<select name="stype">
								<option value="-1">选择分类</option>
								<option value="0" selected="true">文章</option>
								<option value="1">收藏</option>
								<option value="2">书签</option>
								<option value="3">交易</option>
								<option value="4">相册</option>
							</select>
						</h3>
						<h3 style="width:auto; font-size: 12px; font-weight: 100; height: 26px; text-align: left; padding: 2px; margin:0px;">
							&nbsp;&nbsp;<select name="dy" onChange="populate(this,this.form.dm,this.form.dd,0);">
								<option value="0">选择年份</option>
							</select>年
							<select name="dm" onChange="populate(this.form.dy,this,this.form.dd,0);">
								<option value="0">选择月份</option>
							</select>月
							<select name="dd">
								<option value="0">选取日期</option>
							</select>日&nbsp;&nbsp;
							<button name="loginsubmit" type="submit" value="true" style="width:80px">立即查询</button>
						</h3>
					</form>
					<script type="text/JavaScript">
						var search_form = document.forms['search_form'];
						try{
							getYears(search_form.dy,search_form.dm,search_form.dd);
							Dv_Form.Set_Select(search_form.dy,'{$_dYear}');
							Dv_Form.Set_Select(search_form.dm,'{$_dMonth}');
							Dv_Form.Set_Select(search_form.dd,'{$_dDay}');
							Dv_Form.Set_Select(search_form.stype,'{$_stype}');
							Dv_Form.Set_Radio(search_form.sel,'{$_selType}');
						} catch(e){
							alert(e.description);
						}
					</script>
				</div>
EOT;
$_arrSearchResult =& getSearchResult();
if (!empty($_arrSearchResult['ResultSet']) AND is_array($_arrSearchResult['ResultSet'])) {
	require_once INC_PATH.'DV_Encoding.class.php';
	$_objEnc =& DV_Encoding::GetEncoding($charset);
	$_intAbsolutePage = $_arrSearchResult['AbsolutePage'];
	$_intPageSize = $_arrSearchResult['AbsolutePage'];
	print <<<EOT
				<div class="TopicBlock">
					<h1>查询结果</h1>
EOT;
	foreach ($_arrSearchResult['ResultSet'] AS $_index => $_val) {
		//$_tpl_Num = ($_index+1)+$_intAbsolutePage*$_intPageSize;
		$_tpl_Title = $_val['title'].'';
		if( $_tpl_Title === '' ){
			$_tpl_Title = $_val['content'];
		}
		if( $_objEnc->StrLength($_tpl_Title) > 150 ){
			$_tpl_Title = $_objEnc->SubString($_tpl_Title,0,150).'...';
		}
		$_tpl_Title = htmlspecialchars($_tpl_Title);
		$_tpl_StypeName = $lang['spaceStype'][$_val['stype']];
		$_tpl_CatName = '';
		if( !empty($spaceUserCat['result_set']) && is_array($spaceUserCat['result_set']) ){
			foreach( $spaceUserCat['result_set'] as $_val2 ){
				if( $_val2['ucatid'] == $_val['catid'] ){
					$_tpl_CatName = $_val2['ucattitle'];
					break;
				}
			}
		}
		$_val['jointime'] = gmdate('Y-m-d H:i:s', $_val['jointime']+getUserTimeZoneOffset());
		print <<<EOT
					<div style=" margin:0px; padding:0px;height:24px; line-height:24px;width:96%; border-bottom:1px solid #eee;font-family:\"宋体\";"><em style="color:#666;font-style:normal;float:right;text-align:left;">分类:<a href="space.php?{$spaceName}.showchannel.{$_val['stype']}.html" target="_blank">{$_tpl_StypeName}</a>　　  <!--栏目:<a href="space.php?{$spaceName}.showchannel.{$SID}.{$_val['catid']}.html" target="_blank">{$_tpl_CatName}</a> -- 作者:<a href="dispuser.php?id={$_val['userid']}" target="_blank" alt="查看个人资料">{$_val['username']}</a> -- -->发表时间：{$_val['jointime']}</em>{$_tpl_Num} ·<a href="space.php?{$spaceName}.showtopic.{$_val['rootid']}.html" target="_blank">{$_tpl_Title}</a></div>
EOT;
	}//end foreach
	//print_r($_arrSearchResult);
	$_tpl_PageSearch = "user={$spaceName}&stype={$_stype}&sel={$_selType}&keyword=".urlencode($_keyword)."&dy={$_dYear}&dm={$_dMonth}&dd={$_dDay}";
	print <<<EOT
					<div></div>
                </div>
				<div style="height:10px;font-size: 6px;"></div>
				<div class="tag_list">
					<script type="text/JavaScript" src="space/script/pagination.js"></script>
					<h3 style="width: auto; height: 30px; padding:0px; margin: 0px auto;overflow: hidden;">
					<script type="text/JavaScript">
					<!--
						PageList('{$_arrSearchResult['AbsolutePage']}',3,'{$_arrSearchResult['PageSize']}','{$_arrSearchResult['RecordCount']}',"{$_tpl_PageSearch}",1);
					//-->
					</script>
					</h3>
				</div>
EOT;
} else {
	print <<<EOT
				<div class="TopicBlock">
					<h1>查询结果</h1>
					<div style=" margin:0px; padding:0px;height:24px; line-height:24px;width:96%; border-bottom:1px solid #eee;"><em style="color:#ff6600;font-style:normal;float:right">&nbsp;</em>你查看的数据不存在或参数错误！</div>
                </div>
EOT;
}
print <<<EOT
			</div>
			<!-- 主体内容右边区结束 -->
		</div>
		<!-- 主体内容结束  -->
EOT;
?>