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

//Action
$action = 'list';

//CSS Load
if(!defined('AMINA_CSS')) include_once(AMINA_PATH.'/css.php');

// Link Reset
if($sca) $qstr2 .= '&sca='.urlencode($sca);
$qstr2 = $qstr2.$frame_opt;

$is_admin_href = (!$frame && ($is_checkbox || $admin_href)) ? true : false;
if($write_href) {
	if($sca) $write_href .= '&sca='.urlencode($sca);
	$write_href = $write_href.$frame_opt.$search_opt;
}
$rss_href = $rss_href ? AMINA_URL.'/rss.php?bo_table='.$bo_table : '';
$write_href = $write_href ? $write_href :  "javascript:alert('로그인을 하지 않았거나 권한이 없는 레벨입니다.');";
$amina_href = AMINA_URL.'/admin.dashboard.php?bo_table='.$bo_table;

$no_list = '게시물이 없습니다.';

//Deco List
$is_deco_list = ($amina['deco_list'] && $amina['deco_list'] != 'none') ? true : false;

echo '<div id="as-list-wrap">'."\n"; //리스트 전체 영역

if($is_deco_list) {

}

//Setting
if(!$amina['list_skin']) { 
	if($is_admin) {
		alert('아미나 스킨을 설정합니다.', AMINA_URL.'/admin.dashboard.php?bo_table='.$bo_table.'&loc=pc');
	} else {
		alert('아미나 스킨 설정을 해주셔야 사용가능합니다.');
	}
} else { 
	if($amina['addon_skin'] && $amina['addon_skin'] != "none") {
		$addon_skin_path = AMINA_PATH.'/skin/addon/'.$amina['addon_skin'];
		$addon_skin_url = AMINA_URL.'/skin/addon/'.$amina['addon_skin'];
		echo '<div id="as-list-addon">'."\n";
		include($addon_skin_path.'/addon.skin.php');
		echo '</div>'."\n";
	}

	if($amina['tag_board'] && $bo_table == $amina['tag_board']) {
		include(AMINA_PATH.'/tag.list.php');
	} else {
		//bo_type
		if(file_exists($list_skin_path.'/list.rows.php')) {
			include($list_skin_path.'/list.rows.php');
		} else {
			switch($amina['bo_type']) {
				case '1'	: include_once (AMINA_PATH.'/list.linked.php'); break;
				case '2'	: include_once (AMINA_PATH.'/list.1vs1.php'); break;
				default		: include_once (AMINA_PATH.'/list.rows.php'); break;
			}
		}
	}

	if($amina['info_skin'] && $amina['info_skin'] != "none") { //Addon Skin
		$info_skin_path = AMINA_PATH.'/skin/info/'.$amina['info_skin'];
		$info_skin_url = AMINA_URL.'/skin/info/'.$amina['info_skin'];
		echo '<div id="as-list-info">'."\n";
		include($info_skin_path.'/info.skin.php');
		echo '</div>'."\n";
	}

	if($is_deco_list) {
		echo '<link rel="stylesheet" href="'.AMINA_URL.'/skin/deco/list/'.$amina['deco_list'].'.css">'."\n"; //데코 CSS
		echo '<div class="deco-list">'."\n"; //전체 데코 시작
		echo '<div class="deco-list-head-back"><div class="deco-list-head-front"><div class="deco-list-head"></div></div></div>'."\n"; //데코 상단
		echo '<div class="deco-list-body-back"><div class="deco-list-body-front">'."\n"; //데코 중단 시작
	}

	if($is_category) { //Category
		$cate_skin_path = AMINA_PATH.'/skin/cate/'.$amina['cate_skin'];
		$cate_skin_url = AMINA_URL.'/skin/cate/'.$amina['cate_skin'];
		echo '<div id="as-list-cate">'."\n";
		include($cate_skin_path.'/cate.skin.php');
		echo '</div>'."\n";
	}

?>
	<div id="as-list">
		<form id="fboardlist" name="fboardlist" method="post" data-ajax="false">
		<input type="hidden" name="bo_table" value="<?php echo $bo_table; ?>">
		<input type="hidden" name="sfl"  value="<?php echo $sfl; ?>">
		<input type="hidden" name="stx"  value="<?php echo $stx; ?>">
		<input type="hidden" name="spt"  value="<?php echo $spt; ?>">
		<input type="hidden" name="page" value="<?php echo $page; ?>">
		<input type="hidden" name="frame" value="<?php echo $frame; ?>">
		<input type="hidden" name="bo_linked" value="<?php echo $bo_linked; ?>">
		<input type="hidden" name="bo_it" value="<?php echo $bo_it; ?>">
		<input type="hidden" name="bo_all" value="<?php echo $bo_all; ?>">
		<input type="hidden" name="bo_row" value="<?php echo $bo_row; ?>">
		<input type="hidden" name="bm" value="<?php echo $bm; ?>">
		<input type="hidden" name="sw"   value="">
		<?php
			if($is_tag_cloud) { //Tag Cloud
				include(AMINA_PATH.'/tag.cloud.php'); 
				$total_count = 0;
			} else { //List Skin
				$list_skin_path = AMINA_PATH.'/skin/list/'.$amina['list_skin'];
				$list_skin_url = AMINA_URL.'/skin/list/'.$amina['list_skin'];
				include($list_skin_path.'/list.skin.php'); 
			}
		?>
		</form>
	</div>

	<div id="as-list-btn">
	<?php //Btn Skin
		$stx_str = $reset_stx ? '' : $stx;
		$sfl_str = $reset_stx ? '' : $sfl;
		include ($btn_skin_path.'/btn.skin.php');
	?>
	</div>

	<div id="as-list-paging">
	<?php //Page Skin
		$page_skin_path = AMINA_PATH.'/skin/page/'.$amina['page_skin'];
		$page_skin_url = AMINA_URL.'/skin/page/'.$amina['page_skin'];
		$page_rows = $amina['page_rows'] ? $amina['page_rows'] : $config['cf_write_pages'];
		include($page_skin_path.'/page.skin.php');
	?>
	</div>
<?php } ?>

<?php
	if($is_deco_list) {
		echo '</div></div>'."\n"; //중간 데코 끝
		echo '<div class="deco-list-tail-back"><div class="deco-list-tail-front"><div class="deco-list-tail"></div></div></div>'."\n"; //하단 데코
		echo '</div>'."\n"; //전체 데코 것
	}
?>
</div>

<?php if ($is_checkbox) { ?>
<script>
function all_checked(sw) {
    var f = document.fboardlist;

    for (var i=0; i<f.length; i++) {
        if (f.elements[i].name == "chk_wr_id[]")
            f.elements[i].checked = sw;
    }
}
function check_confirm(str) {
    var f = document.fboardlist;
    var chk_count = 0;

    for (var i=0; i<f.length; i++) {
        if (f.elements[i].name == "chk_wr_id[]" && f.elements[i].checked)
            chk_count++;
    }

    if (!chk_count) {
        alert(str + "할 게시물을 하나 이상 선택하세요.");
        return false;
    }
    return true;
}
// 선택한 게시물 삭제
function select_delete() {
    var f = document.fboardlist;

    str = "삭제";
    if (!check_confirm(str))
        return;

    if (!confirm("선택한 게시물을 정말 "+str+" 하시겠습니까?\n\n한번 "+str+"한 자료는 복구할 수 없습니다"))
        return;

    f.action = "<?php echo AMINA_URL; ?>/delete_all.php";
    f.submit();
}
// 선택한 게시물 복사 및 이동
function select_copy(sw) {
    var f = document.fboardlist;

    if (sw == "copy")
        str = "복사";
    else
        str = "이동";
                       
    if (!check_confirm(str))
        return;

    var sub_win = window.open("", "move", "left=50, top=50, width=500, height=550, scrollbars=1");

    f.sw.value = sw;
    f.target = "move";
    f.action = "<?php echo AMINA_URL; ?>/move.php";
    f.submit();
}
</script>
<?php } ?>
<!-- 게시판 목록 끝 -->