<?php
	include_once("check_login.php");
	include_once("include/config.php");
	$action = trim($_GET["action"]);
	$page = trim($_GET["page"]);
	$page = $page ? $page : 1;
	$max_per_page = 10;
	$filter_arr = "";
	if(!$hm_arr = get_news($filter_arr))
		show_err("系统中暂无文章，请添加","set_news_new.php");
?>
<!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=utf-8" />
<title>招聘职位列表</title>
<script language = "javascript" src="include/jquery.min.js" type="text/javascript"></script>
<script language="javascript">
$(function(){
	$(".set_main_list li").bind({
		mouseover:function(){
			$("." + $(this).attr("class")).css("background-color","#DDD");
		},
		mouseout:function(){
			$("." + $(this).attr("class")).css("background-color","");
		}
	});
});
</script>
<style type="text/css">
.set_main_list{width:906px; overflow:hidden; margin:0px auto; border-left:#CCC 1px solid;}
 ul{list-style:none; margin:0px; padding:0px;}
.set_main_list li{list-style:none; height:30px; line-height:30px; overflow:hidden; float:left; border-right:#CCC 1px solid; border-bottom:#CCC 1px solid;}
.set_main_title{width:906px; overflow:hidden; margin:0px auto; margin-top:20px; border-left:#CCC 1px solid; border-top:#CCC 1px solid; background-color:#DDD;}
.set_main_title li{list-style:none; height:30px; line-height:30px; float:left; padding:0px; text-align:center; border-right:#CCC 1px solid; border-bottom:#CCC 1px solid;}
</style>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>

<body>
<div class="head_menu"><span class="head_menu_on"><a href="set_news_list.php">文章列表</a></span><a href="set_news_new.php">添加文章</a></div>
<div class="set_main_out">
    <div class="set_main_title">
      <ul>
      	<li style="width:50px;">ID</li>
        <li style="width:50px;">置顶</li>
        <li style="width:100px;">类型</li>
      	<li style="width:400px;">文章标题</li>
        <li style="width:150px;">发布时间</li>
        <li style="width:150px;">操作</li>
      </ul>
    </div>
    <div class="set_main_list">
      <ul>
      <?php
			//计算总页数
			$all_page = ceil(count($hm_arr)/$max_per_page);
			if($page > $all_page)
				$page = $all_page;
			$start = $page ? (($page - 1) * $max_per_page) : 0;
			$filter_arr[] = array("1","$start,$max_per_page",false);
			$hm_arr = get_news($filter_arr);
			foreach($hm_arr as $key => $val){
				echo "<li class=\"li_$val[0]\" style=\"width:50px; text-align:center;\">$val[0]</li>\n";
				if($val[3] > 10)
					$val[3] = "";
				echo "<li class=\"li_$val[0]\" style=\"width:50px; text-align:center;\">$val[3]</li>\n";
				echo "<li class=\"li_$val[0]\" style=\"width:100px; text-align:center;\">" . get_news_type($val[5]) . "</li>\n";
				echo "<li class=\"li_$val[0]\" style=\"width:400px; text-align:center;\">" . stripslashes($val[1]) . "</li>\n";
				echo "<li class=\"li_$val[0]\" style=\"width:150px; text-align:center;\">$val[4]</li>\n";
				echo "<li class=\"li_$val[0]\" style=\"width:150px; text-align:center;\"><span class=\"do_style\" style=\"width:50px;\" onclick=\"location.href='set_news_edit.php?news_id=$val[0]'\">修改</span><span class=\"do_style\" style=\"width:50px;\" onclick=\"if(confirm('确定要删除该文章吗？')) location.href='DEL.php?type=news&id=$val[0]'; else return;\">删除</span></li>";
			}
	  ?>
      </ul>
    </div>
<div id="page" style="width:906px;">
<?php
	for($i = 1;$i <= $all_page;$i++)
		echo $i - $page == 0 ? "<a class=\"now_page\">$i</a>" : "<a class=\"page_span\" href=\"set_news_list.php?page=$i\">$i</a>";
?>
</div>
</div>
</body>
</html>