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

//latest_amina 함수가 아닐 경우 옵션값을 다시 불러온다.
if(!$latest_amina) {
	$tab = array();
	$opt = array();
	$opt = amina_query($options);
	$tab[0]['title'] = $board['bo_subject'];
	$tab[0]['href'] = G5_BBS_URL.'/board.php?bo_table='.$bo_id;
}

$opt['list_skin'] = $opt['list_skin'] ? $opt['list_skin'] : 'basic';

if(file_exists(THEMA_PATH.'/latest/list/'.$opt['list_skin'].'/latest.list.php')) {
	$latest_list_path = THEMA_PATH.'/latest/list/'.$opt['list_skin'];
	$latest_list_url = THEMA_URL.'/latest/list/'.$opt['list_skin'];
} else {
	$latest_list_path = AMINA_PATH.'/misc/latest/list/'.$opt['list_skin'];
	$latest_list_url = AMINA_URL.'/misc/latest/list/'.$opt['list_skin'];
}

$opt['list_wrap'] = ($opt['list_wrap'] && !$opt['tab']) ? ' class="'.$opt['list_wrap'].'"' : '';
$opt['tab_id'] = $opt['tab_id'] ? $opt['tab_id'] : $tab_id; //탭타켓
$opt['href_target'] = $opt['target'] ? ' target="'.$opt['target'].'"' : ''; //링크타켓
$opt['start_tab'] = ($opt['start_tab'] > 0) ? $opt['start_tab'] : 0; //탭시작번호
$opt['tab_cnt'] = count($tab); //탭갯수

if($opt['head_skin'] != "none") {

	$opt['head_skin'] = $opt['head_skin'] ? $opt['head_skin'] : 'basic';
	$opt['head'] = ($opt['head'] && !$opt['tab']) ? ' '.$opt['head'] : '';

	if(file_exists(THEMA_PATH.'/latest/head/'.$opt['head_skin'].'/latest.head.php')) {
		$latest_head_path = THEMA_PATH.'/latest/head/'.$opt['head_skin'];
		$latest_head_url = THEMA_URL.'/latest/head/'.$opt['head_skin'];
	} else {
		$latest_head_path = AMINA_PATH.'/misc/latest/head/'.$opt['head_skin'];
		$latest_head_url = AMINA_URL.'/misc/latest/head/'.$opt['head_skin'];
	}	
	
	if(!file_exists($latest_head_path.'/latest.head.php')) {
		echo '<p>'.$opt['head_skin'].' 최근글 헤드스킨 필요</p>';
	} else {
		include($latest_head_path.'/latest.head.php'); 
	}
}

if(!file_exists($latest_list_path.'/latest.list.php')) {
	echo '<p>'.$opt['list_skin'].' 최근글 목록스킨 필요</p>';
} else {

//출력하기
if($opt['list_wrap']) echo '<div'.$opt['list_wrap'].'>';

if($opt['tab_cnt'] > 1) {
	echo '<div id="latest_content_'.$opt['tab_id'].'">';
	echo '<div id="latest_content1_'.$opt['tab_id'].'"><div id="latest_'.$opt['tab_id'].'_first">';
	include($latest_list_path.'/latest.list.php');
	echo '</div></div>'."\n";
	echo '<div id="latest_content2_'.$opt['tab_id'].'" style="display:none;">';
	echo '<div id="latest_'.$opt['tab_id'].'"></div>';
	echo '</div></div>'."\n";
?>
	<?php if($opt['start_tab'] > 0) { 
		list($list_effect, $list_etime) = explode(";", $tab[$opt['start_tab']]['list_effect']);
	?>
		<script>
			aminma_latest_list("<?php echo $opt['tab_cnt']; ?>","<?php echo $opt['tab_id']; ?>",'<?php echo $tab[$opt['start_tab']]['num']; ?>','<?php echo $tab[$opt['start_tab']]['query']; ?>','<?php echo $list_effect; ?>','<?php echo $list_etime; ?>','<?php echo $tab[$opt['start_tab']]['head_type']; ?>','<?php echo $tab[$opt['start_tab']]['head-on']; ?>''<?php echo $tab[$opt['start_tab']]['head_off']; ?>');
		</script>
	<?php } ?>
<?php 
	} else {	
		include($latest_list_path.'/latest.list.php'); 
	} 

if($opt['list_wrap']) echo '</div>'."\n";

} 
?>