<?
$sub_menu = "400400";
include_once("./_common.php");

auth_check($auth[$sub_menu], "r");

$token		= get_token();
include_once("$g4[path]/head.sub.php");
?>
<script type="text/javascript" src="<?=$g4[path]?>/js/sideview.js"></script>
<style type="text/css">
table tr td input	{ padding:3px; border:1px solid #A6A6A6; } 
table tr td select	{ height:26px; cursor:pointer; }

div.submit		{ text-align:center; padding:5px; }
div.submit input	{ border:1px solid #4285F5; cursor:pointer; padding:5px 20px 5px 20px; background:#71A4F8; color:#ffffff; vertical-align:middle; }
div.submit input:hover	{ border:1px solid #FF0000; cursor:pointer; padding:5px 20px 5px 20px; background:#FF4040; color:#ffffff; }
.msg		{ color:#CBCBCB; }

td.line1	{ height:2px; background:#FCAE82; }
td.line2	{ height:1px; background:#FCAE82; }
</style>
<link rel="stylesheet" href="<?=$g4[path]?>/adm/admin.style.css" type="text/css">
<?
$g4[title] = "지음빌더 레이아웃 구성";
include_once ("./admin.head.php");
include_once ("./zm.lib.php");

//-- 게시판 목록 --------------------------------
$board_list	= array();
$rs_boards	= sql_query("select bo_table from $g4[board_table] order by bo_table asc");
for($i = 0; $rd_boards = sql_fetch_array($rs_boards); $i++) {
	//-- 사용중인 게시판은 제외
	$rd_used_board	= sql_fetch("select db_board from $zmb[table_builder_config] where db_board='$rd_boards[bo_table]' and db_link_type='1'");
	if(!$rd_used_board[db_board]) $board_list[]	= $rd_boards[bo_table];
}

//-- 메뉴 정보 ----------------------------------
$tmp_info	= sql_fetch("select * from $zmb[table_builder_config] where db_recno='$recno'");
foreach($tmp_info as $key=>$value) {
	$k	= str_replace("db_", "", $key);
	$mn_info[$k]	= $value;
	if($k == "href") {
		$go_href = zm_conv_url($tmp_info[db_recno]);
		if($value == "#") $go_href = "#";
	}
	if($k == "link_type"){
		if($value == "3") $go_url	= $tmp_info[db_href];
	}
}


//-- 리뉴얼용 스킨 정보 -----------------------
$tmp_info	= sql_fetch("select * from zm_builder_renewal_config where db_org_recno='$recno'");
foreach($tmp_info as $key=>$val){
	$key	= str_replace("db_", "", $key);
	$ren_info[$key]	= $val;
}

unset($tmp_info);


//-- level이 99이면 회원가입 스킨
if($mn_info[level] == "99") {	$mem_skin	= true; } else { $mem_skin = false; }

//-- 해당 메뉴에 딸린 서브 메뉴 있는지 체크 -----
$tmp_sub	= sql_fetch("select * from $zmb[table_builder_config] where db_up_recno='$recno'");
if($tmp_sub[db_recno])	$del	= "no";			//-- 삭제 불가
else					$del	= "ok";			//-- 삭제 가능

$index_skins	= get_skin_dir("zm.index");
$layout_skins	= get_skin_dir("zm.layout");
$topmenu_skins	= get_skin_dir("zm.topmenu");
$bottom_skins	= get_skin_dir("zm.bottom");
$mem_skins		= get_skin_dir("zm.member");
//-- 모바일 스킨
$m_layout_skins	= get_m_skin_dir("zm.layout");
$m_member_skins	= get_m_skin_dir("zm.member");
$m_index_skins	= get_m_skin_dir("zm.index");
$m_topmenu_skins= get_m_skin_dir("zm.topmenu");
$m_bottom_skins	= get_m_skin_dir("zm.bottom");

$colspan	= 3;
?>
<form name="form_menu" method=post onsubmit="return sendData(this)" enctype="multipart/form-data">
<input type="hidden" name="mode" value="update">
<input type="hidden" name="recno" value="<?=$recno?>">
<input type="hidden" name="org_recno" value="<?=$ren_info[org_recno]?>">
<input type="hidden" name="link_type" value="<?=$mn_info[link_type]?>">
<table width=98% cellpadding=0 cellspacing=0 border=0 align="center">
<colgroup width=3% align="center">
<colgroup width=20%>
<colgroup width=77%>
<tr><td colspan='<?=$colspan?>' height=60><br><?=subtitle("메뉴 기본 정보")?></td></tr>
<tr><td colspan='<?=$colspan?>' class='line1'></td></tr>
<tr class='col1 ht'>
    <td></td>
	<td>· 메뉴명</td>
	<td><input name="in_gname" value="<?=$mn_info[group_name]?>" itemname="메뉴명" size="20" disabled></td>
</tr>
<tr class='col1 ht'>
    <td></td>
	<td>· 모바일</td>
	<td><input type="checkbox" name="in_mobile" value="1" <?=($mn_info[mobile])?"checked":""?> disabled></td>
</tr>
<tr class='col1 ht mobile_tr'>
    <td></td>
	<td>· 모바일 메뉴명</td>
	<td><input name="in_m_gname" value="<?=$mn_info[m_group_name]?>" itemname="모바일 메뉴명" size="20" disabled></td>
</tr>
<tr class='col1 ht'>
    <td></td>
	<td>· 메뉴 설명</td>
	<td><input name="in_gname_explain" value="<?=$mn_info[group_explain]?>" size="50" disabled></td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<? if($mn_info[level] == '1') :						//-- index 일 때 ?>
<tr class='col1 ht'>
    <td></td>
	<td>· 더보기</td>
	<td><input type="checkbox" name="in_more" value="1" <?=($mn_info[more])?"checked":""?> disabled></td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<? endif; ?>
<tr class='col1 ht'>
    <td></td>
	<td>· 출력순위</td>
	<td><input name="in_rank" value="<?=$mn_info[rank]?>" size="4" maxlength="3" disabled></td>
</tr>

<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<tr><td colspan='<?=$colspan?>' height=60><br><?=subtitle("TOP MENU & BOTTOM 스킨")?></td></tr>
<tr><td colspan='<?=$colspan?>' class='line1'></td></tr>
<tr class='col1 ht'>
    <td><input type="checkbox" name="chk_all_topmenu" value="1" onclick="if(this.checked) alert('모든 페이지에 적용합니다.');"></td>
	<td>· TOP MENU</td>
	<td><select name="in_topmenu_skin">
		<option value="">사용안함</option>
<?	for($i = 0; $i < count($topmenu_skins); $i++) : ?>
		<option value="<?=$topmenu_skins[$i]?>" <?=($topmenu_skins[$i]==$ren_info[topmenu_skin])?"selected":""?>><?=$topmenu_skins[$i]?></option>
<?	endfor; ?>
		</select>
		<span class="msg">(페이지 상단에 메뉴를 포함한 스킨) <a href="#" onClick="window.open('http://ziumb.tistory.com/31');"><img src="./img/icon_help.gif" align="absmiddle"></a></span>
	</td>
</tr>
<tr class='col1 ht mobile_tr'>
    <td><input type="checkbox" name="chk_all_m_topmenu" value="1" onclick="if(this.checked) alert('모든 모바일 페이지에 적용합니다.');"></td>
	<td>· 모바일 TOP MENU</td>
	<td><select name="in_m_topmenu_skin">
		<option value="">사용안함</option>
<?	for($i = 0; $i < count($m_topmenu_skins); $i++) : ?>
		<option value="<?=$m_topmenu_skins[$i]?>" <?=($m_topmenu_skins[$i]==$ren_info[m_topmenu_skin])?"selected":""?>><?=$m_topmenu_skins[$i]?></option>
<?	endfor; ?>
		</select>
	</td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<tr class='col1 ht'>
    <td><input type="checkbox" name="chk_all_bottom" value="1" onclick="if(this.checked) alert('모든 페이지에 적용합니다.');"></td>
	<td>· BOTTOM</td>
	<td><select name="in_bottom_skin">
		<option value="">사용안함</option>
<?	for($i = 0; $i < count($bottom_skins); $i++) : ?>
		<option value="<?=$bottom_skins[$i]?>" <?=($bottom_skins[$i]==$ren_info[bottom_skin])?"selected":""?>><?=$bottom_skins[$i]?></option>
<?	endfor; ?>
		</select>
		<span class="msg">(페이지 하단에 Copyright 등을 포함한 스킨) <a href="#" onClick="window.open('http://ziumb.tistory.com/31');"><img src="./img/icon_help.gif" align="absmiddle"></a></span>
	</td>
</tr>
<tr class='col1 ht mobile_tr'>
    <td><input type="checkbox" name="chk_all_m_bottom" value="1" onclick="if(this.checked) alert('모든 모바일 페이지에 적용합니다.');"></td>
	<td>· 모바일 BOTTOM</td>
	<td><select name="in_m_bottom_skin">
		<option value="">사용안함</option>
<?	for($i = 0; $i < count($m_bottom_skins); $i++) : ?>
		<option value="<?=$m_bottom_skins[$i]?>" <?=($m_bottom_skins[$i]==$ren_info[m_bottom_skin])?"selected":""?>><?=$m_bottom_skins[$i]?></option>
<?	endfor; ?>
		</select>
	</td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<? if($mn_info[level] == '0') :						//-- index 일 때 ?>
<tr>
	<td colspan='<?=$colspan?>' height=60><br><?=subtitle("INDEX 스킨 선택")?></td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line1'></td></tr>
<tr class='col1 ht'>
    <td></td>
	<td>· INDEX</td>
	<td><select name="in_index_skin">
<?	for($i = 0; $i < count($index_skins); $i++) : ?>
		<option value="<?=$index_skins[$i]?>" <?=($index_skins[$i]==$ren_info[index_skin])?"selected":""?>><?=$index_skins[$i]?></option>
<?	endfor; ?>
		</select>
	</td>
</tr>
<tr class='col1 ht mobile_tr'>
    <td></td>
	<td>· 모바일 INDEX</td>
	<td><select name="in_m_index_skin">
<?	for($i = 0; $i < count($m_index_skins); $i++) : ?>
		<option value="<?=$m_index_skins[$i]?>" <?=($m_index_skins[$i]==$ren_info[m_index_skin])?"selected":""?>><?=$m_index_skins[$i]?></option>
<?	endfor; ?>
		</select>
	</td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>

<? else :											//-- index 아닐 때
//-- Link type에 맞는 Radio 선택
$chk_skin[$mn_info[link_type]]	= "checked";
?>
<?		if($mem_skin) :	//-- 회원가입 스킨 설정 ----------------------------------------------------------- ?>
<tr><td colspan='<?=$colspan?>' height=60><br><?=subtitle("회원가입 스킨")?></td></tr>
<tr><td colspan='<?=$colspan?>' class='line1'></td></tr>
<tr class='col1 ht'>
    <td></td>
	<td>· 레이아웃</td>
	<td><select name="in_layout" onchange="load_layout_page(this.value)">
<?	for($i = 0; $i < count($mem_skins); $i++) : ?>
		<option value="<?=$mem_skins[$i]?>" <?=($mem_skins[$i]==$ren_info[layout_skin])?"selected":""?>><?=$mem_skins[$i]?></option>
<?	endfor; ?>
		</select>
		<a href="#" onClick="window.open('http://ziumb.tistory.com/31');"><img src="./img/icon_help.gif" align="absmiddle"></a>
	</td>
</tr>
<tr class='col1 ht mobile_tr'>
    <td></td>
	<td>· 모바일 레이아웃</td>
	<td>
	<select name="in_m_layout">
<?	for($i = 0; $i < count($m_member_skins); $i++) : ?>
		<option value="<?=$m_member_skins[$i]?>" <?=($m_member_skins[$i]==$ren_info[m_layout_skin])?"selected":""?>><?=$m_member_skins[$i]?></option>
<?	endfor; ?>
	</select>
	<span class="msg">(경로 : /skin.mobile/zm.member/)</span>
	</td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<?		else :			//-- 안 회원가입 스킨 설정 --------------------------------------------------------- ?>
<tr>
	<td colspan='<?=$colspan?>' height=60><br><?=subtitle("버튼에 연결 할 레이아웃/스킨/페이지/URL")?></td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line1'></td></tr>
<tr class='col1 ht'>
    <td></td>
	<td>· 레이아웃</td>
	<td>
	<select name="in_layout" onchange="load_layout_page(this.value, '')">
<?	for($i = 0; $i < count($layout_skins); $i++) : ?>
		<option value="<?=$layout_skins[$i]?>" <?=($layout_skins[$i]==$ren_info[layout_skin])?"selected":""?>><?=$layout_skins[$i]?></option>
<?	endfor; ?>
	</select>
	<a href="#" onClick="window.open('http://ziumb.tistory.com/31#layout');"><img src="./img/icon_help.gif" align="absmiddle"></a>
	<span class="msg">(경로 : /skin/zm.layout/)</span>
	</td>
</tr>
<tr class='col1 ht mobile_tr'>
    <td></td>
	<td>· 모바일 레이아웃</td>
	<td>
	<select name="in_m_layout" onchange="load_layout_page(this.value, 'm')">
<?	for($i = 0; $i < count($m_layout_skins); $i++) : ?>
		<option value="<?=$m_layout_skins[$i]?>" <?=($m_layout_skins[$i]==$ren_info[m_layout_skin])?"selected":""?>><?=$m_layout_skins[$i]?></option>
<?	endfor; ?>
	</select>
	<a href="#" onClick="window.open('http://ziumb.tistory.com/31#layout');"><img src="./img/icon_help.gif" align="absmiddle"></a>
	<span class="msg">(경로 : /skin.mobile/zm.layout/)</span>
	</td>
</tr>
<tr class='col1 ht'>
    <td></td>
	<td>· 게시판 선택</td>
	<td>
	<select name="in_board" onFocus="document.form_menu.rdo_skin[0].checked=true;" disabled>
<?	if($mn_info[link_type]=='1') {
		if($mn_info[board])
			echo "<option value='$mn_info[board]' selected>> $mn_info[board]</option>";
	}
	if(!count($board_list) && !$mn_info[board])
		echo "<option value='' selected>※사용 가능한 게시판이 없습니다.</option>";
?>
<?	for($i = 0; $i < count($board_list); $i++) : ?>
		<option value="<?=$board_list[$i]?>" <?=($board_list[$i]==$mn_info[board])?"selected":""?>><?=$board_list[$i]?></option>
<?	endfor; ?>
		</select>
		<a href="#" onClick="window.open('http://ziumb.tistory.com/31#board');"><img src="./img/icon_help.gif" align="absmiddle"></a>
	</td>
</tr>
<tr class='col1 ht'>
    <td><? if($chk_skin[2]) : ?><input type="radio" name="rdo_skin" value="2" <?=$chk_skin[2]?>><? endif; ?></td>
	<td>· 페이지</td>
	<td><select name="in_layout_pagename" id="in_layout_pagename" onFocus="document.form_menu.rdo_skin[1].checked=true;" style="width:200px;" <?=($chk_skin[2])?"":"disabled"?>>
		</select>
		<span class="msg">(선택한 레이아웃에 포함 된 "page."로 시작 되는 파일)</span><a href="#" onClick="window.open('http://ziumb.tistory.com/31#page');"><img src="./img/icon_help.gif" align="absmiddle"></a>
	</td>
</tr>
<tr class='col1 ht mobile_tr'>
    <td></td>
	<td>· 모바일 페이지</td>
	<td><select name="in_m_layout_pagename" id="in_m_layout_pagename" onFocus="document.form_menu.rdo_skin[1].checked=true;" style="width:200px;" <?=($chk_skin[2])?"":"disabled"?>>
		</select>
		<span class="msg">(선택한 레이아웃에 포함 된 "page."로 시작 되는 파일.)<a href="#" onClick="window.open('http://ziumb.tistory.com/47');"><img src="./img/icon_help.gif" align="absmiddle"></a></span>
	</td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<tr class='col1 ht'>
    <td></td>
	<td>· 연결 URL</td>
	<td><input name="in_url" size="50" value="<?=$go_url?>" onFocus="document.form_menu.rdo_skin[2].checked=true;" disabled></td>
</tr>
<tr class='col1 ht'>
    <td></td>
	<td>· 연결 무시</td>
	<td>해당 메뉴 버튼에는 아무 것도 연결(LINK)하지 않음.</td>
</tr>
<tr class='col1 ht'>
    <td></td>
	<td>· Target</td>
	<td><select name="in_target" disabled>
		<option value="">사용 안함</option>
		<option value="_self" <?=($mn_info[target] == "_self")?"selected":""?>>_self</option>
		<option value="_blank" <?=($mn_info[target] == "_blank")?"selected":""?>>_blank</option>
		<option value="_top" <?=($mn_info[target] == "_top")?"selected":""?>>_top</option>
		<option value="_top" <?=($mn_info[target] == "_parent")?"selected":""?>>_parent</option>
		</select> <span class="msg">(버튼이나 메뉴를 클릭 했을 때 새창 또는 프레임 선택)</span>
	</td>
</tr>
<?		endif;											//-- end mem_skin ?>
<? endif;										//-- end index ?>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<? if($mn_info[level] == '1') :	?>
<tr><td colspan='<?=$colspan?>' height=60><br><?=subtitle("Sub domain")?></td></tr>
<tr><td colspan='<?=$colspan?>' class='line1'></td></tr>
<tr class='col1 ht'>
    <td></td>
	<td>· 이름</td>
	<td>http://<input name="in_subdomain" value="<?=$mn_info[subdomain]?>" size="10" maxlength="40" onBlur="chk_subdomain(this.value);">.<?=$_SERVER[SERVER_NAME]?> <span id="subdomain_msg"></span> <span class="msg">(해당 메뉴로 접근하면 이 주소로 보여집니다.)</span><input type="hidden" id="subdomain_ok" name="subdomain_ok" value="<?=($mn_info[subdomain])?"1":""?>"></td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<? endif; ?>
</table>
<div class="submit"><input type="submit" value="변경내용 적용">
<input type="button" value="목록" onClick="zm_gourl('./zm.builder_renewal.php')"></div>
</form>



<script language="javascript">
function sendData(f) {
	f.action	= "./zm.builder_renewal_process.php";
	f.submit();
}

function load_layout_page(layout, mb){
	$.ajax({
		type: "post",
		url: "./zm.builder_process.php?mode=layout_page&layout="+layout+"&pagename=<?=$mn_info[pagename]?>&m_pagename=<?=$mn_info[m_pagename]?>&mb="+mb,
		success: function(result){
			if(mb == "m") {
				$("#in_m_layout_pagename").html(result);
			}else{
				$("#in_layout_pagename").html(result);
			}
		}
	})
}


$(document).ready(function(){
	load_layout_page("<?=$mn_info[layout_skin]?>", "");
	load_layout_page("<?=$mn_info[m_layout_skin]?>", "m");
})
</script>
<?
include_once ("./admin.tail.php");
?>
</body>
</html>