<?php
require_once(dirname(__FILE__)."/admin_inc.php");
/*******************************************************************************************
' Software name: DJCMS Content Management System
' Version:3.0
' Web: http://www.djcms.net
' Author: 心情(qq:1130731)
' Copyright (C) 2009-2010 DJCMS官方 版权所有
' 法律申明：DJCMS程序所有代码100%原创、未引入任何网上代码,对一切抄袭行为、坚决严肃追究法律责任
'*******************************************************************************************/
viewHead("自定义快捷菜单"."-" .$menuList[3][0]);
$action = getForm("action", "get");
switch ($action) {
	case "modify" : modifyMenu();break;
	default : main();break;
} 
viewFoot();

function main() {
	global $menuList;
	$menuStr = replaceStr(getSelfMenu(intval(getcookie("m_level"))),"|","\n");
?>
<div id="append_parent"></div>
<div class="container" id="cpcontainer">
<!--当前导航-->
<script type="text/JavaScript">if(parent.$('admincpnav')) parent.$('admincpnav').innerHTML='后台首页&nbsp;&raquo;&nbsp;<?php echo $menuList[7][0];?>&nbsp;&raquo;&nbsp;快捷菜单管理';</script>
<table class="tb">
<tr class="thead"><th colspan="2">自定义快捷菜单</th></tr>
<tr><td width="25%">1.格式：菜单名称,菜单链接地址</td>
<td width="75%">2.每个快捷菜单各占一行</td>
</tr>
  <form action="?action=modify" method="post"  >
   
    <tr>
      <td colspan="2"><textarea  name="menustr" style="width:100%;font-family: Arial, Helvetica, sans-serif;font-size: 14px;" rows="20" dataType="Require" msg="请填写内容"><?=$menuStr?></textarea></td>
    </tr>
    <tr>
      <td> <input type="submit" name="Submit" value="修  改" class="btn" /> <input type="button" value="返   回"  class="btn" onClick="javascript:history.go(-1)" /></td><td ></td>
    </tr>
  </form>
</table>
<?php
}

function modifyMenu() {
	global $selfMenuXml,$customMenuXml;
	$menustr=ltrim(getForm("menustr","post"),'\n') ; $menustr=replaceStr($menustr,'\n',"|");
	$path = $selfMenuXml;
	if (intval(getcookie("m_level")) == 1) $path = $customMenuXml;
	fwrite(fopen($path,"wb"), stripslashes($menustr));
	echo "<script>alert('修改成功');top.location.href='index.php';</script>";
}
?>
