<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

//FA Icon
$fa = array("cate"=>"tag", "name"=>"user", "date"=>"clock-o", "cmt"=>"+;t", "hit"=>"eye", "good"=>"thumbs-up", "nogood"=>"thumbs-down", "star"=>"", "view"=>"leaf", "down"=>"download");

//Default Value;
$set['subj'][$s] = ($set['subj'][$s] > 0) ? $set['subj'][$s] : $subject_len; //Subject Length
$set['date'][$s] = $set['date'][$s] ? $set['date'][$s] : 1; //Date Type
$set['star_type'][$s] = $set['star_type'][$s] ? $set['star_type'][$s] : 's'; //Star Type
if(!$set['subj_icon'][$s]) $set['subj_icon'][$s] = $set['icon'][$s] ? '1' : 'chevron-circle-right';

//Comment
$is_subj_cmt = ($set['subj_cmt'][$s] && $set['subj_cmt'][$s] != 'none') ? true : false;

//Subj Type
$is_cmt_gul = (($opt['type'] == "newcmt" || $opt['type'] == "cmt") && $set['subj_type'][$s]) ? true : false;

//Rank
$is_rank = ($opt['order'] && $set['rank_icon'][$s] != 'none' && ($opt['type'] != "newgul" && $opt['type'] != "newcmt" && $opt['type'] != "newcmtgul")) ? true : false;

$rank_url = '';
if($is_rank && $set['rank_icon'][$s]) {
	$set['rank_icon'][$s] = $set['rank_icon'][$s] ? $set['rank_icon'][$s] : 'basic';
	$rank_url = AMINA_URL.'/misc/icon/list-rank/'.$set['rank_icon'][$s];
	$rank_ext = (file_exists(AMINA_PATH.'/misc/icon/list-rank/'.$set['rank_icon'][$s].'/1.gif')) ? '.gif' : '.png';
}

//Icon
$icon_url = '';
if(($set['icon'][$s] && $set['icon'][$s] != "none") || ($set['subj_icon'][$s] == 'qa')) {
	$set['icon'][$s] = $set['icon'][$s] ? $set['icon'][$s] : 'basic';
	$icon_url = AMINA_URL.'/misc/icon/list-icon/'.$set['icon'][$s];
	$icon_ext = (file_exists(AMINA_PATH.'/misc/icon/list-icon/'.$set['icon'][$s].'/icon-new.gif')) ? '.gif' : '.png';
}

//Details
$dCount = 0;
if($set['details'][$s]) {
	$dList = explode(";", $set['details'][$s]);
	$dCount = count($dList);
}

?>
<div class="la-area-list<?php echo $set['list'][$s] ? ' '.$set['list'][$s] : ''; ?>">
	<ul>
	<?php 
		for ($i=$row_start; $i < $row_end; $i++) { 

			//Value
			$wr_post = amina_array_write($list[$i]['wr_10']);
			$wr_icon = amina_array_icon($list[$i]['wr_5']);
			$list[$i]['wr_view_point'] = $wr_icon['po_view_point'];
			$list[$i]['wr_down_point'] = $wr_icon['po_down_point'];
			
			if($is_cmt_gul) {
				$list[$i]['wr_subject'] = $list[$i]['wr_post']; //원글제목
				$cmt_cnt = $list[$i]['wr_post_cmt']; //원글 댓글수
			} else {
				$cmt_cnt = $list[$i]['wr_comment'];
			}

			//Blind & Secret
			$is_blind = false;
			if($list[$i]['wr_9'] == "lock" || $list[$i]['wr_9'] == "shingo") {
				$is_blind = true;
				$list[$i]['wr_subject'] = $list[$i]['wr_content'] = $list[$i]['wr_3'] = '블라인드 처리된 글입니다.';
			} else if ($list[$i]['icon_secret']) {
				$list[$i]['wr_content'] = $list[$i]['wr_3'] = '비밀글입니다.';
			}

			//Href
			$list[$i]['href'] = ($opt['href'] == 'link' && $list[$i]['wr_link1']) ? $list[$i]['link_href'][1] : $list[$i]['href'];
			$a_href = $fbox_w.'href="'.$list[$i]['href'].$fbox_q.$list[$i]['href_cmt'].'"'.$opt['href_target'];

			//Details
			$details_item = '';
			$details_css = 'la-data-first';
			for($k=0; $k < $dCount; $k++) {
				$dItem_var = amina_details($dList[$k], $list[$i], $set['date'][$s], $set['star'][$s], $set['star_type'][$s]);
				$dItem_var = $dItem_var ? amina_icon($fa[$dList[$k]]).$dItem_var : '';
				$details_item .= '<b class="'.$details_css.' la-data-'.$dList[$k].'">'.$dItem_var.'</b>';
				$details_css = 'la-data';
			}

			if($details_item) $details_item = '<span class="la-details">'.$details_item.'</span>';

			//Post Icon
			$post_icon = '';
			if($set['icon'][$s] != "none") {
				$post_icon = $set['subj_icon'][$s];
				if($is_rank) { //Rank
					$post_icon = $rank_url ? '<img src="'.$rank_url.'/'.$list[$i]['wr_rank'].$rank_ext.'" alt="">' : '<span class="la-rank la-rank-'.$list[$i]['wr_rank'].'">'.$list[$i]['wr_rank'].'</span>';
				} else if($post_icon) {
					if($set['subj_icon'][$s] == 'qa') $post_icon = $list[$i]['icon_reply'] ? 'icon-a' : 'icon-q';
					if($is_blind) {
						$post_icon = $icon_url ? 'icon-blind' : 'eye-slash';
					} else if($list[$i]['is_notice']) {
						$post_icon = $icon_url ? 'icon-notice' : 'bell';
					} else if($list[$i]['icon_secret']) {
						$secret_new = $list[$i]['icon_new'] ? '-new' : '';
						$post_icon = $icon_url ? 'icon-secret'.$secret_new : 'lock';
					} else if($list[$i]['icon_new']) {
						$post_icon = $icon_url ? 'icon-new' : 'chevron-circle-right';
					} else if($list[$i]['icon_hot']) {
						$post_icon = $icon_url ? 'icon-hot' : 'thumbs-up';
					} else if($set['attach_icon'][$s]) {
						if($wr_post['video'] == "video") {
							$post_icon = $icon_url ? 'icon-video' : 'video-camera';
						} else if($wr_post['photo'] == "photo") {
							$post_icon = $icon_url ? 'icon-img' : 'picture';
						} else if($wr_post['file'] == "file") {
							$post_icon = $icon_url ? 'icon-file' : 'download';
						}
					}
					$post_icon = $icon_url ? '<img src="'.$icon_url.'/'.$post_icon.$icon_ext.'" alt="" />' : '<i class="fa fa-'.$post_icon.'"></i>';
					$post_icon = ($list[$i]['icon_new'] && $post_icon) ? '<span class="la-new">'.$post_icon.'</span>' : $post_icon;
				}
			}

			//Subject	
			$subject = ($set['subj_cate'][$s] && $list[$i]['ca_name']) ? '['.$list[$i]['ca_name'].'] '.amina_cut($list[$i]['wr_subject'], $set['subj'][$s]) : amina_cut($list[$i]['wr_subject'], $set['subj'][$s]);
			$subject = $list[$i]['is_notice'] ? '<b>'.$subject.'</b>' : $subject;
			if($is_subj_cmt && $cmt_cnt > 0) $subject .= ' <span class="la-subj-cmt">+'.number_format($cmt_cnt).'</span>';
		?>
		<li class="la-box">
			<div class="la-list">
				<a <?php echo $a_href;?>>
					<?php echo $details_item; ?>
					<span class="la-subj"><?php echo $post_icon.$subject; ?></span>
				</a>
			</div>
		</li>
	<?php } ?>
	</ul>
	<div class="clear"></div>
</div>
