<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<title>管理我的分类</title>
<link href="newskin.css" rel="stylesheet" type="text/css">
<script language='javascript'src='main.js'></script>
<script language="javascript" src="../include/dedeajax2.js"></script>
<script language="javascript">
<!--
//增加类目
function AddnewType(){
  var taget_obj = $Obj('typeList');
  var typename = $Obj('typename').value;
  var rank = $Obj('rank').value;
  var channelid = 1;
  if(typename==''){
    alert("类目名称不能为空！");
    return false;
  }
  if($Obj('channelid02')){
  	if($Obj('channelid02').checked) channelid = 2;
  }
  var errMsg = "网络通信出错！<br>[<a href='javascript:ReLoadList(0)'><u>重新加载类目列表</u></a>]";
  var myajax = new DedeAjax(taget_obj,true,true,"",errMsg,"正在处理...");
  myajax.SendGet("archives_type_action.php?dopost=addnew&typename="+typename+"&channelid="+channelid+"&rank="+rank);
  $Obj('rank').value++;
  $Obj('typename').value = "";
}

//更新类目
function UpdateType(tid){
  var taget_obj = $Obj('typeList');
  var typename = $Obj('typename'+tid).value;
  var rank = $Obj('rank'+tid).value;
  if(typename==''){
    alert("类目名称不能为空！");
    return false;
  }
  var errMsg = "网络通信出错！<br>[<a href='javascript:ReLoadList(0)'><u>重新加载类目列表</u></a>]";
  var myajax = new DedeAjax(taget_obj,true,true,"-",errMsg,"正在处理...");
  myajax.SendGet("archives_type_action.php?dopost=update&aid="+tid+"&typename="+typename+"&rank="+rank);
}

//删除类目
function DelType(tid){
  var taget_obj = $Obj('typeList');
  var typename = $Obj('typename'+tid).value;
  if(!window.confirm('你确定要删除分类：'+typename+' 吗？')){ return false; }
  var errMsg = "网络通信出错！<br>[<a href='javascript:ReLoadList(0)'><u>重新加载类目列表</u></a>]";
  var myajax = new DedeAjax(taget_obj,true,true,"",errMsg,"正在处理...");
  myajax.SendGet("archives_type_action.php?dopost=del&aid="+tid);
}

//重载类目
function ReLoadList(orderby){
  var taget_obj = $Obj('typeList');
  var errMsg = "网络通信出错！<br>[<a href='javascript:ReLoadList(0)'><u>重新加载类目列表</u></a>]";
  var myajax = new DedeAjax(taget_obj,true,true,"",errMsg,"正在加载中...");
  myajax.SendGet("archives_type_action.php?dopost=reload&orderby="+orderby);
}
-->
</script>	
</head>
<body leftmargin="0" topmargin="0">
<div align="center">
<?php  include(dirname(__FILE__)."/head.htm"); ?>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="160" height="299" valign="top"> 
      <?php include(dirname(__FILE__)."/menu.php");?>
    </td>
    <td width="10">&nbsp;</td>
    <td  valign="top"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-bottom:3px">
          <tr> 
          <td background="img/nnnbg.gif" height="26" class="gdt2">
		  <strong>　&nbsp;管理我的分类：</strong>		  </td>
          </tr>
	 </table>
      <table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#D9EDC0">
        <tr bgcolor="#F2F9E6"> 
          <td height="22" colspan="2" style="padding-left:6px;">增加新的分类：</td>
        </tr>
        <tr> 
          <td width="20%" height="22" bgcolor="#FFFFFF" style="padding-left:6px;">分类名称：</td>
          <td width="80%" height="22" bgcolor="#FFFFFF" style="padding-left:6px;">
		  <input name="typename" type="text" id="typename" style="width:150px">
		  </td>
        </tr>
        <tr> 
          <td height="22" bgcolor="#FFFFFF" style="padding-left:6px;">内容类型：</td>
          <td height="22" bgcolor="#FFFFFF" style="padding-left:6px;">
		        <input name="channelid" id="channelid01" type="radio" value="1" checked>
            文章 
            <?php  if($cfg_mb_album=='是'){ ?>
            <input type="radio" id="channelid02" name="channelid" value="2">
            图集
            <?php  } ?>
		</td>
        </tr>
        <tr> 
          <td height="22" bgcolor="#FFFFFF" style="padding-left:6px;">排序级别：</td>
          <td height="22" bgcolor="#FFFFFF" style="padding-left:6px;">
		  <input name="rank" type="text" id="rank" style="width:80px" value="<?php echo $nrank?>">
          <input type="button" name="bt" value="增加" style="width:50px" onClick="AddnewType()">
		  </td>
        </tr>
        <tr bgcolor="#F2F9E6"> 
          <td height="22" colspan="2" style="padding-left:6px;">已有分类管理： </td>
        </tr>
        <tr> 
          <td height="380" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding-left:6px;padding-top:6px">
		  <span id="typeList">
		  <table width="98%" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC" style='margin-bottom:10px'>
       <tr align="center" bgcolor="#FBFCD1"> 
            <td width="11%">ID</td>
            <td width="32%">分类名称</td>
            <td width="15%"><a href='javascript:ReLoadList(1)'><u>内容类型</u></a></td>
             <td width="18%"><a href='javascript:ReLoadList(0)'><u>排序级别</u></a></td>
             <td>操作</td>
            </tr>
		<?php 
	$dsql->SetQuery("Select * From #@__member_arctype where memberid='".$cfg_ml->M_ID."' order by rank desc");
  $dsql->Execute();
  while($row = $dsql->GetObject()){
  	if($row->channelid==1){ $cktype = " 文章 "; }
  	else{ $cktype = " <font color='#3C9636'>图集<font> "; }
  	echo "<tr align='center' bgcolor='#FFFFFF' onMouseMove=\"javascript:this.bgColor='#EFEFEF';\" onMouseOut=\"javascript:this.bgColor='#FFFFFF';\">\r\n";
  	echo "<td>{$row->aid}</td>\r\n";
    echo "<td><input name='typename{$row->aid}' type='text' id='typename{$row->aid}' style='width:150px' value='{$row->typename}'></td>\r\n";
    echo "<td>{$cktype}</td>\r\n";
    echo "<td><input name='rank{$row->aid}' type='text' id='rank{$row->aid}' style='width:60px' value='{$row->rank}'></td>\r\n";
    echo "<td>［<a href='#' onclick='UpdateType({$row->aid})'>更新</a>］［<a href='#' OnClick='DelType({$row->aid})'>删除</a>］</td>\r\n</tr>\r\n";
  }
		?>
    </table>
			</span>
			</td>
        </tr>
      </table> </td>
  </tr>
</table>
<?php 
if(isset($dsql) && is_object($dsql)) $dsql->Close();
include(dirname(__FILE__)."/foot.htm");
?>
</div>
</body>
</html>
