XML출력 function getMenuXml($site,$table,$j,$parent,$depth,$uid,$code) { global $g; static $j,$string; $xdepth = $depth+1; $CD=getDbSelect($table,($site?'site='.$site.' and ':'').'depth='.$xdepth.' and parent='.$parent.' and hidden=0 order by gid asc','*'); while($C=db_fetch_array($CD)) { $j++; $code = $code.$C['id'].'/'; $_code = substr($code,0,strlen($code)-1); if ($xdepth==1) { $string .= "\t\n\t"; } else { for ($i = 0; $i < $xdepth; $i++) $string .= "\t"; } $string .= ''."\n"; getMenuXml($site,$table,$j,$C['uid'],$C['depth'],$uid,$code); for ($i = 0; $i < $xdepth; $i++) $string .= "\t"; $string .= ''."\n"; } else { $string .= '" />'."\n"; } if ($xdepth==1) $string .= "\n"; $code = ''; } return $string; } //메뉴->XLS출력 function getMenuXls($site,$table,$j,$parent,$depth,$uid,$mset,$code) { global $g,$r; static $j,$string; $xdepth = $depth+1; $CD=getDbSelect($table,($site?'site='.$site.' and ':'').'depth='.$xdepth.' and parent='.$parent.' order by gid asc','*'); while($C=db_fetch_array($CD)) { $j++; $code = $code.$C['id'].'/'; $_code = substr($code,0,strlen($code)-1); $string .= ''; $string .= ''.$xdepth.''; $string .= ''.($xdepth==1?$C['name']:'').''; $string .= ''.($xdepth==2?$C['name']:'').''; $string .= ''.($xdepth==3?$C['name']:'').''; $string .= ''.($xdepth==4?$C['name']:'').''; $string .= ''.($xdepth==5?$C['name']:'').''; $string .= ''.$C['uid'].''; $string .= ''.$C['id'].''; $string .= ''.RW('c='.$_code).''; $string .= ''.$g['s'].'/index.php?r='.$r.'&c='.$_code.''; $string .= ''.$mset[$C['menutype']].''; $string .= ''.($C['mobile']?'Y':'').''; $string .= ''.($C['target']?'Y':'').''; $string .= ''.($C['hidden']?'Y':'').''; $string .= ''.($C['reject']?'Y':'').''; $string .= ''.($C['redirect']?'Y':'').''; $string .= ''.$C['joint'].''; $string .= ''; if ($C['is_child']) { getMenuXls($site,$table,$j,$C['uid'],$C['depth'],$uid,$mset,$code); } $code = ''; } return $string; } //메뉴->TXT출력 function getMenuTxt($site,$table,$j,$parent,$depth,$uid,$code) { global $g; static $j,$string; $xdepth = $depth+1; $CD=getDbSelect($table,($site?'site='.$site.' and ':'').'depth='.$xdepth.' and parent='.$parent.' order by gid asc','*'); while($C=db_fetch_array($CD)) { $j++; $code = $code.$C['id'].'/'; $_code = substr($code,0,strlen($code)-1); for ($i = 0; $i < $depth; $i++) $string .= "\t"; $string .= '['.$xdepth.']'.($C['hidden']?'[숨김]':'').($C['reject']?'[차단]':'').($C['target']?'[새창]':'').$C['name']." = ".RW('c='.$_code)."\r\n"; if ($C['is_child']) { getMenuTxt($site,$table,$j,$C['uid'],$C['depth'],$uid,$code); } if ($xdepth==1) $string .= "\r\n"; $code = ''; } return $string; } //메뉴->패키지용 function getMenuPackage($site,$table,$j,$parent,$depth,$uid) { global $g; static $j,$string; $xdepth = $depth+1; $CD=getDbSelect($table,($site?'site='.$site.' and ':'').'depth='.$xdepth.' and parent='.$parent.' order by gid asc','*'); while($C=db_fetch_array($CD)) { $_parent = $C['parent'] ? getDbData($table,($site?'site='.$site.' and ':'').'uid='.$C['parent'],'id') : array(); $j++; for ($i = 0; $i < $depth; $i++) $string .= "\t"; $string .= "\tarray('name'=>'".$C['name']."','id'=>'".$C['id']."','menutype'=>'".$C['menutype']."','mobile'=>'".$C['mobile']."','hidden'=>'".$C['hidden']."','target'=>'".$C['target']."','redirect'=>'".$C['redirect']."','joint'=>'".$C['joint']."','layout'=>'".$C['layout']."','imghead'=>'".$C['imghead']."','imgfoot'=>'".$C['imgfoot']."','imgicon'=>'".$C['imgicon']."','addinfo'=>'".$C['addinfo']."','depth'=>'".$C['depth']."','parent'=>'".$_parent['id']."','is_child'=>'".$C['is_child']."','gid'=>'".$C['gid']."',),\r\n"; if ($C['is_child']) { getMenuPackage($site,$table,$j,$C['uid'],$C['depth'],$uid); } } return $string; } if ($type == 'xml') { $filename = 'menu_'.$_HS['id'].'.xml'; $filepath = $g['path_var'].'xml/'.$filename; $fp = fopen($filepath,'w'); fwrite($fp,"\n"); fwrite($fp,"\n\n"); fwrite($fp,"\t\n"); fwrite($fp,getMenuXml($s,$table['s_menu'],0,0,0,0,'')); fwrite($fp,"\n"); fclose($fp); @chmod($filepath,0707); $filesize = filesize($filepath); header("Content-Type: application/octet-stream"); header("Content-Length: " .$filesize); header('Content-Disposition: attachment; filename="'.$filename.'"'); header("Cache-Control: private, must-revalidate"); header("Pragma: no-cache"); header("Expires: 0"); $fp = fopen($filepath, 'rb'); if (!fpassthru($fp)) fclose($fp); exit; } else if($type == 'xls') { header("Content-type: application/vnd.ms-excel;" ); header("Content-Disposition: attachment; filename=menu_".$_HS['id'].".xls" ); header("Content-Description: PHP4 Generated Data" ); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo getMenuXls($s,$table['s_menu'],0,0,0,0,array('','모듈','위젯','코딩'),''); echo ''; echo '
단계1차메뉴2차메뉴3차메뉴4차메뉴5차메뉴고유키(PK)메뉴코드현재주소물리주소메뉴형식모바일새창숨김차단리다이렉트연결주소
'; exit; } else if($type == 'txt') { header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=menu_".$_HS['id'].".txt" ); header("Content-Description: PHP4 Generated Data" ); echo $_HS['name']."-메뉴구조\r\n"; echo "-------------------------------------------------------------------------\r\n\r\n"; echo getMenuTxt($s,$table['s_menu'],0,0,0,0,''); exit; } else if($type == 'package_menu') { header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=var.menu.php" ); header("Content-Description: PHP4 Generated Data" ); echo "\r\n"; exit; } else if($type == 'package_page') { header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=var.page.php" ); header("Content-Description: PHP4 Generated Data" ); echo "'".$R['name']."','id'=>'".$R['id']."','pagetype'=>'".$R['pagetype']."','ismain'=>'".$R['ismain']."','mobile'=>'".$R['mobile']."','category'=>'".$R['category']."','layout'=>'".$R['layout']."','joint'=>'".$R['joint']."','linkedmenu'=>'".$R['linkedmenu']."'),\r\n"; } echo ");\r\n"; echo "?>\r\n"; exit; } ?>