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

switch($loc) {
	case 'm'	: $skin_loc = '모바일'; $n_css = "now_green"; break;
	default		: $skin_loc = 'PC'; $n_css = 'now_blue'; break;
}

//Default Basic
$set_basic = 'basic';
$setting['head_skin'] = $setting['head_skin'] ? $setting['head_skin'] : $set_basic;
$setting['view_skin'] = $setting['view_skin'] ? $setting['view_skin'] : $set_basic;
$setting['view_good'] = $setting['view_good'] ? $setting['view_good'] : $set_basic;
$setting['cmt_skin'] = $setting['cmt_skin'] ? $setting['cmt_skin'] : $set_basic;
$setting['write_skin'] = $setting['write_skin'] ? $setting['write_skin'] : $set_basic;
$setting['btn_skin'] = $setting['btn_skin'] ? $setting['btn_skin'] : $set_basic;
$setting['sign_skin'] = $setting['sign_skin'] ? $setting['sign_skin'] : $set_basic;
$setting['star_skin'] = $setting['star_skin'] ? $setting['star_skin'] : $set_basic;
$setting['poll_skin'] = $setting['poll_skin'] ? $setting['poll_skin'] : $set_basic;
$setting['related_skin'] = $setting['related_skin'] ? $setting['related_skin'] : $set_basic;
$setting['tag_skin'] = $setting['tag_skin'] ? $setting['tag_skin'] : $set_basic;
$setting['preview_skin'] = $setting['preview_skin'] ? $setting['preview_skin'] : $set_basic;
$setting['view_sns'] = $setting['view_sns'] ? $setting['view_sns'] : $set_basic;
$setting['cmt_sns'] = $setting['cmt_sns'] ? $setting['cmt_sns'] : $set_basic;

//Default None
$set_none = 'none';
$setting['addon_skin'] = $setting['addon_skin'] ? $setting['addon_skin'] : $set_none;
$setting['linked_skin'] = $setting['linked_skin'] ? $setting['linked_skin'] : $set_none;
$setting['info_skin'] = $setting['info_skin'] ? $setting['info_skin'] : $set_none;
$setting['deco_list'] = $setting['deco_list'] ? $setting['deco_list'] : $set_none;
$setting['deco_view'] = $setting['deco_view'] ? $setting['deco_view'] : $set_none;
$setting['deco_write'] = $setting['deco_write'] ? $setting['deco_write'] : $set_none;
$setting['attach_skin'] = $setting['attach_skin'] ? $setting['attach_skin'] : $set_none;

//Default Else
$setting['cmt_rows'] = $setting['cmt_rows'] ? $setting['cmt_rows'] : 0;

//Default Mobile
if($loc == "m") {
	$setting['list_skin'] = $setting['list_skin'] ? $setting['list_skin'] : 'basic-m';
	$setting['list_rows'] = $setting['list_rows'] ? $setting['list_rows'] : '';
} else {
	$setting['list_skin'] = $setting['list_skin'] ? $setting['list_skin'] : $set_basic;
}

$setting['cate_skin'] = $setting['cate_skin'] ? $setting['cate_skin'] : $set_basic;
$setting['page_skin'] = $setting['page_skin'] ? $setting['page_skin'] : $set_basic;

?>

<!--초기값 : 숨김-->
<div class="none">
	<!--addon default-->
	<textarea name="addon_css_default" id="addon_css_default">
		<?=amina_skin("css", "addon", "addon_css", $setting['addon_skin'], $setting['addon_css'], $setting['addon_set'])?>
	</textarea>
	<textarea name="addon_set_default" id="addon_set_default">
		<?=amina_skin("set", "addon", "addon_set", $setting['addon_skin'], $setting['addon_css'], $setting['addon_set'])?>
	</textarea>

	<!--info default-->
	<textarea name="info_css_default" id="info_css_default">
		<?=amina_skin("css", "info", "info_css", $setting['info_skin'], $setting['info_css'], $setting['info_set'])?>
	</textarea>
	<textarea name="info_set_default" id="info_set_default">
		<?=amina_skin("set", "info", "info_set", $setting['info_skin'], $setting['info_css'], $setting['info_set'])?>
	</textarea>

	<!--cate default-->
	<textarea name="cate_css_default" id="cate_css_default">
		<?=amina_skin("css", "cate", "cate_css", $setting['cate_skin'], $setting['cate_css'])?>
	</textarea>

	<!--head default-->
	<textarea name="head_css_default" id="head_css_default">
		<?=amina_skin("css", "head", "head_css", $setting['head_skin'], $setting['head_css'])?>
	</textarea>

	<!--list default-->
	<textarea name="list_css_default" id="list_css_default">
		<?=amina_skin("css", "list", "list_css", $setting['list_skin'], $setting['list_css'], $setting['list_set'])?>
	</textarea>
	<textarea name="list_set_default" id="list_set_default">
		<?=amina_skin("set", "list", "list_set", $setting['list_skin'], $setting['list_css'], $setting['list_set'])?>
	</textarea>

	<!--view default-->
	<textarea name="view_css_default" id="view_css_default">
		<?=amina_skin("css", "view", "view_css", $setting['view_skin'], $setting['view_css'], $setting['view_set'])?>
	</textarea>
	<textarea name="view_set_default" id="view_set_default">
		<?=amina_skin("set", "view", "view_set", $setting['view_skin'], $setting['view_css'], $setting['view_set'])?>
	</textarea>

	<!--attach default-->
	<textarea name="attach_css_default" id="attach_css_default">
		<?=amina_skin("css", "attach", "attach_css", $setting['attach_skin'], $setting['attach_css'], $setting['attach_set'])?>
	</textarea>
	<textarea name="attach_set_default" id="attach_set_default">
		<?=amina_skin("set", "attach", "attach_set", $setting['attach_skin'], $setting['attach_css'], $setting['attach_set'])?>
	</textarea>

	<!--sign default-->
	<textarea name="sign_css_default" id="sign_css_default">
		<?=amina_skin("css", "sign", "sign_css", $setting['sign_skin'], $setting['sign_css'], $setting['sign_set'])?>
	</textarea>
	<textarea name="sign_set_default" id="sign_set_default">
		<?=amina_skin("set", "sign", "sign_set", $setting['sign_skin'], $setting['sign_css'], $setting['sign_set'])?>
	</textarea>

	<? if($loc != "m") { ?>
		<!--linked default-->
		<textarea name="linked_css_default" id="linked_css_default">
			<?=amina_skin("css", "linked", "linked_css", $setting['linked_skin'], $setting['linked_css'])?>
		</textarea>
	<? } ?>

	<!--cmt default-->
	<textarea name="cmt_css_default" id="cmt_css_default">
		<?=amina_skin("css", "cmt", "cmt_css", $setting['cmt_skin'], $setting['cmt_css'])?>
	</textarea>

	<!--page default-->
	<textarea name="page_css_default" id="page_css_default">
		<?=amina_skin("css", "page", "page_css", $setting['page_skin'], $setting['page_css'])?>
	</textarea>

	<!--tag default-->
	<textarea name="tag_css_default" id="tag_css_default">
		<?=amina_skin("css", "tag", "tag_css", $setting['tag_skin'], $setting['tag_css'], $setting['tag_set'])?>
	</textarea>

	<textarea name="tag_set_default" id="tag_set_default">
		<?=amina_skin("set", "tag", "tag_set", $setting['tag_skin'], $setting['tag_css'], $setting['tag_set'])?>
	</textarea>

	<!--write default-->
	<textarea name="write_css_default" id="write_css_default">
		<?=amina_skin("css", "write", "write_css", $setting['write_skin'], $setting['write_css'], $setting['write_set'])?>
	</textarea>

	<textarea name="write_set_default" id="write_set_default">
		<?=amina_skin("set", "write", "write_set", $setting['write_skin'], $setting['write_css'], $setting['write_set'])?>
	</textarea>

	<!--btn default-->
	<textarea name="btn_css_default" id="btn_css_default">
		<?=amina_skin("css", "btn", "btn_css", $setting['btn_skin'], $setting['btn_css'])?>
	</textarea>
</div>

<form id="amina_setup" name="fboardform" method="post" action="<?=AMINA_URL?>/admin.update.php" enctype="multipart/form-data">
<input type="hidden" name="opt" value="<?=$opt?>">
<input type="hidden" name="bo_table" value="<?=$bo_table?>">
<input type="hidden" name="loc" value="<?=$loc?>">

<table border=0 class="admin_head">
<tr>
<th><h2 class="sub_title left">▶ <?=$skin_loc?> 목록 스킨</h2></th>
<td><?=$amina_btn?></td>
</tr>
</table>

<table border=0 class="admin_tbl">
<colgroup>
	<col class="w20">
	<col class="w100">
</colgroup>
<?
	//분별 설정 내역
	$c_list = array();
	if(!$is_amina_setup) {
		if($loc == "m") {
			$c_result = sql_query(" select id, sca from {$g5['amina_skin']} where bo_table = '$bo_table' and (skin_type = '2' or skin_type = '3') order by skin_type, sca", false);
		} else {
			$c_result = sql_query(" select id, sca from {$g5['amina_skin']} where bo_table = '$bo_table' and (skin_type = '0' or skin_type = '1') order by skin_type, sca", false);
		}
		$i = 0;
		while ($c_row = sql_fetch_array($c_result)) { 
			$c_list[$i] = $c_row;
			$i++;
		}
	}

	if(count($c_list) > 0) {
?>
<tr>
<th>*</th>
<td><b>분류별설정</b></td>
<td>
	<p><input type=text name='sca' size=22 value='<?=$sca?>'> &nbsp; 개별설정 분류 입력</P>
	<table border=1 class="set_tbl">
	<colgroup>
		<col class="w35">
		<col class="w140">
		<col class="w120">
	</colgroup>

	<? for($i=0;$i < count($c_list); $i++) { 

		if($i == 0) {
			$ca_name = "전체(공통)";
		} else {
			$ca_name = $c_list[$i]['sca'];
		}

		if($sca == $c_list[$i]['sca']) {
			$c_now = "▶";
			$tr_now = " class=\"{$n_css}\"";
		} else {
			$tr_now = "";
			$c_now = $i + 1;
		}
		
		$e_href = AMINA_URL."/admin.dashboard.php?bo_table=".$bo_table."&loc=".$loc."&sca=".urlencode($c_list[$i]['sca']);
		$d_href = AMINA_URL."/admin.update.php?id=".$c_list[$i]['id']."&mode=d&bo_table=".$bo_table."&loc=".$loc."&sca=".urlencode($c_list[$i]['sca']);
	?>
	<tr <?=$tr_now?>>
	<th><?=$c_now?> </th>
	<td><a href="<?=$e_href?>"><b><?=$ca_name?></b></a></td>
	<td><a href="<?=$e_href?>">불러오기</a></td>
	<td>
		<? if($i == 0) { ?>
			<a>전체(공통)만 그룹저장 가능</a>
		<? } else { ?>
			<a href="javascript:amina_del('<?=$d_href?>');">삭제하기</a>
		<? } ?>
	</td>
	</tr>
	<? } ?>
	</table>
</td>
</tr>
<? }?>

<tr>
<th><?=get_chk("chk_cate", $loc, $sca)?></th>
<td><b>카테고리탭</b></td>
<td>
	<?=amina_skin("skin", "cate", "cate_skin", $setting['cate_skin'], "cate_css")?> &nbsp; 분류
	&nbsp; - &nbsp; 컬러셋 <span id="cate_css"></span>
    <script> amina_load('cate', 'cate'); </script>
</td>
</tr>

<tr>
<th><?=get_chk("chk_head", $loc, $sca)?></th>
<td><b>헤드스타일</b></td>
<td>
	<?=amina_skin("skin", "head", "head_skin", $setting['head_skin'], "head_css")?> &nbsp; 헤드
	&nbsp; - &nbsp; 컬러셋 <span id="head_css"></span>
    <script> amina_load('head'); </script>
</td>
</tr>

<tr>
<th><?=get_chk("chk_list", $loc, $sca)?></th>
<td><b>목록스킨</b></td>
<td>
	<?=amina_skin("skin", "list", "list_skin", $setting['list_skin'], "list_css", "list_set")?> &nbsp; 목록
	&nbsp; - &nbsp; 컬러셋 <span id="list_css"></span>
	<? if($loc == "m") { ?>
	&nbsp; - &nbsp;	목록수 <input type=text name='list_rows' size=4 numeric value='<?=$setting['list_rows']?>'> 개씩	
	<? } ?>
	<span id="list_set"></span>
    <script> amina_load('list', 'list'); </script>
</td>
</tr>
</table>

<table border=0 class="admin_head">
<tr>
<th><h2 class="sub_title left">▶ <?=$skin_loc?> 내용 스킨</h2></th>
<td> </td>
</tr>
</table>

<table border=0 class="admin_tbl">
<colgroup>
	<col class="w20">
	<col class="w100">
</colgroup>
<tr>
<th><?=get_chk("chk_view", $loc, $sca)?></th>
<td><b>내용스킨</b></td>
<td>
	<p class="bline">
	<?=amina_skin("skin", "view", "view_skin", $setting['view_skin'], "view_css", "view_set")?> &nbsp; 내용
	&nbsp; - &nbsp; 컬러셋 <span id="view_css"></span> <span id="view_set"></span>
    <script> amina_load('view', 'view'); </script>
	</p>

	<p class="bline">
	<?=amina_skin("skin", "good", "view_good", $setting['view_good'])?> &nbsp; 추천
	&nbsp; - &nbsp;	SNS &nbsp;&nbsp; <?=amina_skin("skin", "sns", "view_sns", $setting['view_sns'])?>
	</p>

	<p class="bline">
	<?=amina_skin("skin", "star", "star_skin", $setting['star_skin'])?> &nbsp; 별점
	&nbsp; - &nbsp;	요약글 <?=amina_skin("skin",  "preview", "preview_skin", $setting['preview_skin'])?>
	</p>

	<?=amina_skin("skin", "poll", "poll_skin", $setting['poll_skin'])?> &nbsp; 설문
	&nbsp; - &nbsp;	연동글 <?=amina_skin("skin", "related", "related_skin", $setting['related_skin'])?>
</td>
</tr>

<tr>
<th><?=get_chk("chk_attach", $loc, $sca)?></th>
<td><b>첨부스킨</b></td>
<td>
	<?=amina_skin("skin", "attach", "attach_skin", $setting['attach_skin'], "attach_css", "attach_set")?> &nbsp; 첨부
	&nbsp; - &nbsp; 컬러셋 <span id="attach_css"></span> <span id="attach_set"></span>
    <script> amina_load('attach', 'attach'); </script>
</td>
</tr>

<tr>
<th><?=get_chk("chk_cmt", $loc, $sca)?></th>
<td><b>댓글스킨</b></td>
<td>
	<p class="bline">
	<?=amina_skin("skin", "cmt", "cmt_skin", $setting['cmt_skin'], "cmt_css")?> &nbsp; 댓글
	&nbsp; - &nbsp; 컬러셋 <span id="cmt_css"></span>
    <script> amina_load('cmt'); </script>
	</p>

	<?=amina_skin("skin", "sns", "cmt_sns", $setting['cmt_sns'])?> &nbsp; SNS
	&nbsp; - &nbsp; 페이징 <input type=text name='cmt_rows' size=4 numeric value='<?=$setting['cmt_rows']?>'> 개씩
</td>
</tr>

<tr>
<th><?=get_chk("chk_sign", $loc, $sca)?></th>
<td><b>서명스킨</b></td>
<td>
	<?=amina_skin("skin", "sign", "sign_skin", $setting['sign_skin'], "sign_css", "sign_set")?> &nbsp; 서명
	&nbsp; - &nbsp; 컬러셋 <span id="sign_css"></span> <span id="sign_set"></span>
    <script> amina_load('sign', 'sign'); </script>
</td>
</tr>

<tr>
<th><?=get_chk("chk_tag", $loc, $sca)?></th>
<td><b>관련글스킨</b></td>
<td>
	<?=amina_skin("skin", "tag", "tag_skin", $setting['tag_skin'], "tag_css", "tag_set")?> &nbsp; 관련
	&nbsp; - &nbsp; 컬러셋 <span id="tag_css"></span> <span id="tag_set"></span>
    <script> amina_load('tag', 'tag'); </script>
</td>
</tr>

<? if($loc != "m") { ?>
<tr>
<th><?=get_chk("chk_linked", $loc, $sca)?></th>
<td><b>연동탭</b></td>
<td>
	<p class="bline">
	<?=amina_skin("skin", "linked", "linked_skin", $setting['linked_skin'], "linked_css")?> &nbsp; 스킨
	&nbsp; - &nbsp; 컬러셋 <span id="linked_css"></span>
    <script> amina_load('linked'); </script>
	</p>
	<p>
		<input type="button" onclick="add_tab();" value=' 탭 추가 ' class="btn_gray">
		&nbsp;
		<input type="button" onclick="del_tab();" value=' 탭 삭제 ' class="btn_gray">
		- 탭아이디 필수, 탭이름에 바(|) 사용 불가
	</p>

	<?
		$linked = amina_array_linked($setting['linked_tab']);
		$linked_cnt = count($linked);
	?>

	<table id="linkedSet" border=1 class="set_tbl">
	<colgroup>
		<col class="w40">
	</colgroup>
	<tr>
	<th>#1</th>
	<td>
		<select name="linked_type[]">
			<option value='1'>댓글용</option>
		</select>
		&nbsp;
		탭아이디 <input type=text name="linked_id[]" size=10 value='comment' readonly>
		&nbsp;
		<? if(!$linked[0]['linked_name']) $linked[0]['linked_name'] = "댓글쓰기"; ?>
		탭이름 <input type=text name='linked_name[]' size=12 value='<?=$linked[0]['linked_name']?>'>
		<input type=hidden name='linked_view[]' value=''>
		<input type=hidden name='linked_post[]' value=''>
		<input type=hidden name='linked_row[]' value=''>
		<input type=hidden name='linked_opt[]' value=''>
	</td>
	</tr>
	<? for($i=1;$i<$linked_cnt;$i++) { ?>
		<tr>
		<th>#<? echo $i + 1;?></th>
		<td>
			<p>
			<select name='linked_type[]'>
			<option value='board'>게시판</option>
			<option value='html' <? if($linked[$i]['linked_type'] == 'html') echo "selected";?>>웹문서</option>
			</select>
			&nbsp; 탭아이디 <input type=text name='linked_id[]' size=10 value='<?=$linked[$i]['linked_id']?>'>
			&nbsp; 탭이름 <input type=text name='linked_name[]' size=12 value='<?=$linked[$i]['linked_name']?>'>
			<select name='linked_view[]'>
			<option value='list'>리스트 연결</option>
			<option value='write' <? if($linked[$i]['linked_view'] == 'write') echo "selected";?>>글쓰기 연결</option>
			</select>
			</p>
			<select name='linked_post[]'>
			<option value=''>관련글</option>
			<option value='all' <? if($linked[$i]['linked_post'] == 'all') echo "selected";?>>전체글</option>
			</select>
			&nbsp; 출력글수 <input type=text name='linked_row[]' size=10 value='<?=$linked[$i]['linked_row']?>'>
			&nbsp; 탭옵션 <input type=text name='linked_opt[]' size=25 value='<?=$linked[$i]['linked_opt']?>'>
		</td>
		</tr>
	<? } ?>
	</table>

	<script>
	    var flen = 0;
	    var linked = <? echo $linked_cnt + 1; ?>;
		function add_tab() {
			var objTbl;
			var objRow;
			var objCell1;
			var objCell2;

			if (document.getElementById)
				objTbl = document.getElementById("linkedSet");
			else
				objTbl = document.all["linkedSet"];

			objRow = objTbl.insertRow(objTbl.rows.length);
			objCell1 = objRow.insertCell(0);
			objCell2 = objRow.insertCell(1);

			objCell1.innerHTML = "#" + linked;
			objCell2.innerHTML = "<select name='linked_type[]'><option value='board'>게시판</option><option value='html'>웹문서</option></select>";
			objCell2.innerHTML += " &nbsp; 탭아이디 <input type=text name='linked_id[]' size=10 value=''>";
			objCell2.innerHTML += " &nbsp; 탭이름 <input type=text name='linked_name[]' size=12 value=''>";
			objCell2.innerHTML += " <select name='linked_view[]'><option value='list'>리스트 연결</option><option value='write'>글쓰기 연결</option></select>";
			objCell2.innerHTML += "<p>";
			objCell2.innerHTML += "<select name='linked_post[]'><option value=''>관련글</option><option value='all'>전체글</option></select>";
			objCell2.innerHTML += " &nbsp; 출력글수 <input type=text name='linked_row[]' size=10 value=''>";
			objCell2.innerHTML += " &nbsp; 탭옵션 <input type=text name='linked_opt[]' size=25 value=''>";
			flen++;
			linked++;
		}

		add_tab();

		function del_tab() {
			// file_length 이하로는 필드가 삭제되지 않아야 합니다.
			var file_length = <? echo $linked_cnt; ?>;
			var objTbl = document.getElementById("linkedSet");
			if (objTbl.rows.length - 1 > file_length) {
				objTbl.deleteRow(objTbl.rows.length - 1);
				flen--;
				linked--;
			}
		}
		</script>
</td>
</tr>
<? } ?>
</table>

<table border=0 class="admin_head">
<tr>
<th><h2 class="sub_title left">▶ <?=$skin_loc?> 기타 스킨</h2></th>
<td> </td>
</tr>
</table>

<table border=0 class="admin_tbl">
<colgroup>
	<col class="w20">
	<col class="w100">
</colgroup>
<tr>
<th><?=get_chk("chk_write", $loc, $sca)?></th>
<td><b>쓰기스킨</b></td>
<td>
	<?=amina_skin("skin", "write", "write_skin", $setting['write_skin'], "write_css", "write_set")?> &nbsp; 쓰기
	&nbsp; - &nbsp; 컬러셋 <span id="write_css"></span> <span id="write_set"></span>
    <script> amina_load('write', 'write'); </script>
</td>
</tr>
<? if($loc != "m") { ?>
	<tr>
	<th><?=get_chk("chk_deco", $loc, $sca)?></th>
	<td><b>데코스킨</b></td>
	<td>
		<?=amina_skin("deco", "list", "deco_list", "", $setting['deco_list'])?>  &nbsp; 목록
		&nbsp; - &nbsp; 글내용 <?=amina_skin("deco", "view", "deco_view", "", $setting['deco_view'])?>
		&nbsp; - &nbsp; 글쓰기 <?=amina_skin("deco", "write", "deco_write", "", $setting['deco_write'])?>
	</td>
	</tr>
<? } ?>
<tr>
<th><?=get_chk("chk_addon", $loc, $sca)?></th>
<td><b>애드온스킨</b></td>
<td>
	<?=amina_skin("skin", "addon", "addon_skin", $setting['addon_skin'], "addon_css", "addon_set")?> &nbsp; 스킨
	&nbsp; - &nbsp; 컬러셋 <span id="addon_css"></span> <span id="addon_set"></span>
    <script> amina_load('addon', 'addon'); </script>
</td>
</tr>

<tr>
<th><?=get_chk("chk_info", $loc, $sca)?></th>
<td><b>정보박스</b></td>
<td>
	<?=amina_skin("skin", "info", "info_skin", $setting['info_skin'], "info_css", "info_set")?> &nbsp; 박스
	&nbsp; - &nbsp; 컬러셋 <span id="info_css"></span> <span id="info_set"></span>
    <script> amina_load('info', 'info'); </script>
</td>
</tr>

<tr>
<th><?=get_chk("chk_btn", $loc, $sca)?></th>
<td><b>버튼스킨</b></td>
<td>
	<?=amina_skin("skin", "btn", "btn_skin", $setting['btn_skin'], "btn_css")?> &nbsp; 버튼
	&nbsp; - &nbsp; 컬러셋 <span id="btn_css"></span>
    <script> amina_load('btn'); </script>
</td>
</tr>

<tr>
<th><?=get_chk("chk_page", $loc, $sca)?></th>
<td><b>페이징스킨</b></td>
<td>
	<?=amina_skin("skin", "page", "page_skin", $setting['page_skin'], "page_css")?> &nbsp; 스킨
	&nbsp; - &nbsp; 컬러셋 <span id="page_css"></span>
    <script> amina_load('page'); </script>
	&nbsp; - &nbsp; 표시 <input type=text name='page_rows' size=4 numeric value='<?=$setting['page_rows']?>'> 개
</td>
</tr>

</table>

<table border=0 class="admin_head no_margin">
<tr>
<th> </th>
<td><?=$amina_btn?></td>
</tr>
</table>
</form>
