<?php
if (!function_exists('jusqQaElapsed')) {
	function jusqQaElapsed($value)
	{
		if (strlen($value) < 12) return '';
		$time = mktime((int)substr($value,8,2),(int)substr($value,10,2),(int)substr($value,12,2),(int)substr($value,4,2),(int)substr($value,6,2),(int)substr($value,0,4));
		$gap = max(0,time()-$time);
		if ($gap < 3600) return max(1,(int)floor($gap/60)).'분 전';
		if ($gap < 86400) return (int)floor($gap/3600).'시간 전';
		if ($gap < 604800) return (int)floor($gap/86400).'일 전';
		return date('Y.m.d',$time);
	}
}
?>
<link rel="stylesheet" href="<?php echo $g['url_module_skin']?>/qa-list.css?v=20260825" type="text/css" />
<div id="bbslist" class="qa-list">
	<div class="qa-head">
		<div><strong>Q&amp;A</strong><p>JusQ 설치와 운영 중 궁금한 점을 질문하고 답변을 나누는 공간입니다.</p></div>
		<?php if($B['uid']&&$my['uid']):?><a class="qa-ask" href="<?php echo $g['bbs_write']?>">질문하기</a><?php endif?>
	</div>

	<div class="info">
		<div class="article">전체 <?php echo number_format($NUM+count($NCD))?>개 · <?php echo $p?>/<?php echo $TPG?>페이지</div>
		<div class="category">
			<?php if($my['admin']):?>
			<a href="<?php echo $g['s']?>/?r=<?php echo $r?>&amp;m=admin&amp;module=<?php echo $m?>&amp;uid=<?php echo $B['uid']?>"><img src="<?php echo $g['img_core']?>/_public/btn_admin.gif" alt="게시판 관리" title="게시판 관리" /></a>
			<?php endif?>
			<?php if($B['category']):$_catexp=explode(',',$B['category']);$_catnum=count($_catexp)?>
			<select aria-label="질문 분류" onchange="document.bbssearchf.cat.value=this.value;document.bbssearchf.submit();">
			<option value="">전체 분류</option>
			<?php for($i=1;$i<$_catnum;$i++):if(!$_catexp[$i])continue;?>
			<option value="<?php echo $_catexp[$i]?>"<?php if($_catexp[$i]==$cat):?> selected="selected"<?php endif?>><?php echo $_catexp[$i]?><?php if($d['theme']['show_catnum']):?> (<?php echo getDbRows($table[$m.'data'],'site='.$s.' and notice=0 and bbs='.$B['uid']." and category='".$_catexp[$i]."'")?>)<?php endif?></option>
			<?php endfor?>
			</select>
			<?php endif?>
		</div>
		<div class="clear"></div>
	</div>

	<div class="qa-items">
	<?php $_qaRows=array_merge($NCD,$RCD);$_qaIndex=0;foreach($_qaRows as $R):?>
		<?php
		$_qaIndex++;
		$_member=$R['mbruid']?getDbData($table['s_mbrdata'],'memberuid='.$R['mbruid'],'photo,point'):array();
		$_photo=!empty($_member['photo'])?$_member['photo']:'0.gif';
		$_answers=(int)$R['comment']+(int)$R['oneline'];
		$_isNotice=$R['notice']?true:false;
		?>
		<article class="qa-item<?php if($_isNotice):?> qa-notice<?php endif?>">
			<div class="qa-avatar hand" onclick="getMemberLayer('<?php echo $R['mbruid']?>',event);"><img src="<?php echo $g['url_root']?>/_var/simbol/<?php echo $_photo?>" alt="<?php echo $R[$_HS['nametype']]?> 심볼" /></div>
			<div class="qa-body">
				<div class="qa-titleline">
					<span class="qa-point"><?php echo $_isNotice?'공지':number_format((int)$_member['point']).'P'?></span>
					<a class="qa-title" href="<?php echo $g['bbs_view'].$R['uid']?>"><?php echo getStrCut($R['subject'],$d['bbs']['sbjcut'],'')?></a>
					<?php if($R['hidden']):?><span class="qa-lock">비밀</span><?php endif?>
				</div>
				<div class="qa-meta">
					<span class="qa-author hand" onclick="getMemberLayer('<?php echo $R['mbruid']?>',event);"><?php echo $R[$_HS['nametype']]?></span>
					<span><?php echo jusqQaElapsed($R['d_regis'])?></span>
					<?php if(getNew($R['d_regis'],$d['bbs']['newtime'])):?><em>new</em><?php endif?>
					<span>분류 : <?php echo $R['category']?$R['category']:'기타'?></span>
					<span>공감(<?php echo number_format((int)$R['score1'])?>)</span>
					<span class="qa-answer<?php if($_answers):?> has-answer<?php endif?>">답변(<?php echo number_format($_answers)?>)</span>
				</div>
			</div>
		</article>
	<?php endforeach?>
	<?php if(!$NUM&&!count($NCD)):?><div class="qa-empty"><strong>아직 등록된 질문이 없습니다.</strong><span><?php echo $my['uid']?'궁금한 점을 첫 질문으로 남겨 보세요.':'로그인하면 새로운 질문을 등록할 수 있습니다.'?></span></div><?php endif?>
	</div>

	<div class="bottom">
		<div class="btnbox1"><?php if($B['uid']&&$my['uid']):?><span class="btn00"><a href="<?php echo $g['bbs_write']?>">질문하기</a></span><?php elseif($B['uid']):?><span class="login-guide">질문 등록은 로그인 후 이용할 수 있습니다.</span><?php endif?></div>
		<div class="btnbox2"><span class="btn00"><a href="<?php echo $g['bbs_reset']?>">전체목록</a></span><span class="btn00"><a href="<?php echo $g['bbs_list']?>">새로고침</a></span></div>
		<div class="clear"></div>
		<div class="pagebox01"><?php echo getPageLink($d['theme']['pagenum'],$p,$TPG,$g['img_core'].'/page/default')?></div>
	</div>

	<div class="searchform"><form name="bbssearchf" action="<?php echo $g['s']?>/">
		<input type="hidden" name="r" value="<?php echo $r?>" /><input type="hidden" name="c" value="<?php echo $c?>" /><input type="hidden" name="m" value="<?php echo $m?>" /><input type="hidden" name="bid" value="<?php echo $bid?>" /><input type="hidden" name="cat" value="<?php echo $cat?>" /><input type="hidden" name="sort" value="<?php echo $sort?>" /><input type="hidden" name="orderby" value="<?php echo $orderby?>" /><input type="hidden" name="recnum" value="<?php echo $recnum?>" /><input type="hidden" name="type" value="<?php echo $type?>" /><input type="hidden" name="iframe" value="<?php echo $iframe?>" /><input type="hidden" name="skin" value="<?php echo $skin?>" />
		<?php if($d['theme']['search']):?><select name="where"><option value="subject|tag"<?php if($where=='subject|tag'):?> selected="selected"<?php endif?>>제목+태그</option><option value="content"<?php if($where=='content'):?> selected="selected"<?php endif?>>본문</option><option value="name"<?php if($where=='name'):?> selected="selected"<?php endif?>>이름</option></select><input type="text" name="keyword" size="30" value="<?php echo $_keyword?>" class="input" /><input type="submit" value="검색" class="btngray" /><?php endif?>
	</form></div>
</div>
