<?
include(dirname(__FILE__)."/../global.php");




	//连接数据库
    include("../../../include/db.cfg.php");
	//连接数据库
	include("../../../include/cfg.php");
	include("../../../include/file_type.php");
	include("../../../include/js.php");
	
@$job=$submitted_vars['job'];


function tableListSort( $table , $parent_id = 0 , $level = 1 )
   {
     $sql="select * from `$table`  where `parent_id` = {$parent_id} ORDER BY `web_sort_list` ASC";
	 //echo $sql;
    $result=mysql_query($sql);
    while($row=mysql_fetch_array($result))
       {
        $web_sort_id=$row['web_sort_id'];
		
		
						  //根据 module_id 读出 module_name
				  $result_2 = mysql_query("SELECT * FROM `126jz_module` WHERE `module_id` =".$row['module_id']);
				  $module_name=stripslashes(mysql_result($result_2,"0","module_name"));
		
		?>
		
		<form id="form2" name="form2" method="post" action="">
        <tr>
          <td height="34" align="center" bgcolor="#FFFFFF"><input name="module_sort_taxis" type="text" id="module_sort_taxis" value="<?=$row['web_sort_list']?>" size="3" />
            <input name="id" type="hidden" id="id" value="<?=$id?>" />
            <input name="job" type="hidden" id="job" value="modify" /></td>
          <td align="left" bgcolor="#FFFFFF"><?=str_repeat("--", $level-1)?>【<?=$row['web_sort_name']?>】</td>
          <td align="center" bgcolor="#FFFFFF"><?=$module_name?></td>
		  <td align="center" bgcolor="#FFFFFF"><a href="content_list.php?web_sort_id=<?=$web_sort_id;?>&module_id=<?=$row['module_id']?>">文章列表</a></td>
          <td align="center" bgcolor="#FFFFFF"><a href="post.php?web_sort_id=<?=$web_sort_id;?>&module_id=<?=$row['module_id']?>">发布</a>&nbsp;</td>
          
        </tr>
      </form>
		
		
		<?
		//echo "<br>".$sortId."<br>";
		 tableListSort( $table , $web_sort_id, $level + 1 );
      }
}

/*

                $query="SELECT * FROM `126jz_web_sort` ORDER BY `web_sort_list` ASC";
                $result=mysql_query($query);
                $i=0;
                while($row=mysql_fetch_array($result))
                  {
                  $web_sort_id            =    stripslashes($row["web_sort_id"]);
				  $module_id            =    stripslashes($row["module_id"]);
				  $web_sort_list       =    stripslashes($row["web_sort_list"]);
                  $web_sort_name     =    stripslashes( $row["web_sort_name"] );
				  
				  //根据 module_id 读出 module_name
				  $result_2 = mysql_query("SELECT * FROM `126jz_module` WHERE `module_id` =$module_id");
				  $module_name=stripslashes(mysql_result($result_2,"0","module_name"));
                
				formListSort("126jz_web_sort");
				
		$i++;
		}
*/
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<link href="../css.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_popupMsg(msg) { //v1.0
  return confirm(msg);
}
//-->
</script>
</head>

<body>
	<?
	  if( $job == 'del' ){  

	  	  $id  =  $_GET["id"];
		  
	  	    $query="DELETE FROM `link` WHERE `id`='$id' ";
	  	  //echo $query;
	  	    $result=mysql_query($query) or die( mysql_error() );
	  	  //echo $result;
	  	  if($result)
	  	  {
			
			   jsTWinAlert( "成功删除！！" );
	  	  }
	  	  else
	  	  {
	  	    jsTWinAlert( "删除失败！！" );
	  	    jsTWinBack();
	  	    exit();
	  	  }
	
	}elseif( $job == 'modify' ){
	  
                  $id            =    addslashes($_POST["id"]);
				  $link_url            =    addslashes($_POST["link_url"]);
				  $taxis            =    addslashes($_POST["taxis"]);
				  $link_name            =    addslashes($_POST["link_name"]);
  
  //修改数据库

  $query=" UPDATE `link` 
          SET `taxis`='$taxis' , `link_url`='$link_url' , `link_name`='$link_name'
		  WHERE `id`=$id"; 

  //echo $query;		  
  $result=mysql_query($query);
  if($result)
  {
	jsTWinAlert( "修改成功！" );
  }
  else
  {
	jsTWinAlert( "修改失败！" );
  }
  

	}elseif( $job == 'insert' ){  
  
  $web_sort_name         =    addslashes($_POST["web_sort_name"]);
  $module_id         =    addslashes($_POST["module_id"]);
  $parent_id     =    addslashes($_POST["parent_id"]);
  
        /////////记录数据  =====开始
 	$query = "insert into `126jz_web_sort`
                          ( `web_sort_name`,`module_id`,`parent_id` )
                  values
                         ( '".$web_sort_name."','".$module_id."','".$parent_id."' ) ";
	$result = mysql_query($query) or die(mysql_error());
	
    $web_sort_id   = mysql_insert_id();

	mysql_query("UPDATE `126jz_web_sort` 
          SET `web_sort_list`='$web_sort_id'
		  WHERE `web_sort_id`=$web_sort_id");	
	
        /////////记录数据  =====结束


  }
  ?>

<table width="100%"  border="0" cellpadding="3" cellspacing="1" bgcolor="#A4B6D7" class="font">
  <tr>
    <td height="25" align="center" background="../../images/titlebg.jpg" class="font_title">栏目列表</td>
  </tr>
  <tr>
    <td height="30" align="center" bgcolor="#FFFFFF"><table width="90%" border="0" cellpadding="1" cellspacing="1" bgcolor="#A4B6D7">
      <tr>
        <td width="12%" align="center" bgcolor="#FFFFFF"><strong>排 序</strong></td>
        <td width="13%" align="center" bgcolor="#FFFFFF"><strong>栏目名称</strong></td>
        <td width="14%" align="center" bgcolor="#FFFFFF"><strong>模块类型</strong></td>
        <td width="4%" align="center" bgcolor="#FFFFFF"><strong>文章列表</strong></td>
        <td width="4%" align="center" bgcolor="#FFFFFF"><strong>发布信息</strong></td>
      </tr>
      <?
				tableListSort("126jz_web_sort");
		?>
    </table></td>
  </tr>
</table>
</body>
</html>
