<?php 
	session_start(); 
	require_once('inc/conn.php');
	require_once('inc/constant.php');
	require_once('inc/ls_syscode.php');
	require_once('inc/check.php');
	$ls_msg="添加文章操作";
	$opendb=new mydb();
	require_once('inc/char_set.php');
	$selectcate=$_GET['selectcate'];

?>
<!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">
		<link href="css/admin.css" rel="stylesheet" type="text/css">
		<script language="JavaScript" src="js/ls.js"></script>
		<title>无标题文档</title>
		<link rel="stylesheet" href="kindeditor-4.1.10/themes/default/default.css" />
<link rel="stylesheet" href="kindeditor-4.1.10/plugins/code/prettify.css" />
<script charset="utf-8" src="kindeditor-4.1.10/kindeditor.js"></script>
<script charset="utf-8" src="kindeditor-4.1.10/lang/zh_CN.js"></script>
<script charset="utf-8" src="kindeditor-4.1.10/plugins/code/prettify.js"></script>
<script>
    KindEditor.ready(function(K) {
        var editor1 = K.create('textarea[name="newsText"]', {
            cssPath : 'kindeditor-4.1.10/plugins/code/prettify.css',
            uploadJson : 'kindeditor-4.1.10/php/upload_json.php',
            fileManagerJson : 'kindeditor-4.1.10/php/file_manager_json.php',
            allowFileManager : true,
            afterCreate : function() {
                var self = this;
                K.ctrl(document, 13, function() {
                    self.sync();
                    K('form[name=example]')[0].submit();
                });
                K.ctrl(self.edit.doc, 13, function() {
                    self.sync();
                    K('form[name=example]')[0].submit();
                });
            }
        });
        prettyPrint();
    });
</script>
	</head>

	<body>
		<table width="96%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#6396d6">
			<tr>
				<td height="18" background="images/admin_bg.gif"><div align="center"><font color="#ffffff"><strong>添加文章</strong></font></div>
				</td>
			</tr>
			<tr>
				<td height="213" valign="top" bgcolor="#dee7ff"><br>
				 <form name="newsform" enctype="multipart/form-data" method="post" action="savenews.php?selectcate=<?=$selectcate?>"  onSubmit="return checkSubmitForm('newsDate,cate,Num,newsTitle','日期,文章分类,序号,文章标题');">
					<input type="hidden" value="insert" name="ls">
					<table border="0" width="90%" align="center">
						<tr>
							<td>提示：<font color="#FF0000"><?php echo $ls_msg; ?></font></td>
							<td align="right"><img src="images/shao.gif">&nbsp;<a href="news.php?selectcate=<?=$selectcate?>"><u>返回</u></a></td>
						</tr>
					</table>
	
    				<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
					 
					  <tr bgcolor="#B9DAFF"> 
						<td height="28" colspan="3"></td>
					  </tr>
					  <tr bgcolor="#f4f4f4"> 
						<td style="padding-left:50px;" width="17%">文章标题：</td>
						<td width="59%"><input type="text" name="newsTitle" id="newsTitle" style="width:300px;"></td>
						<td width="24%">
                        序号：
                          <?
						  	if($selectcate==''){$select_sql2="select Num from ls_news  order by Num desc  limit 1";}
							else
							{$select_sql2="select Num from ls_news where cate='".$selectcate."'  order by Num desc  limit 1" ;}
							//echo $select_sql2;
							$select_query2=$opendb->query($select_sql2);
							$select_rows2_num=mysql_fetch_assoc($select_query2); //总数

						?>
                        <input name="Num" id="Num" type="text" style="width:40px;" value="<?=$select_rows2_num['Num']+5?>" size="6" maxlength="6"></td>

                       
					  </tr>
					  <tr bgcolor="#f4f4f4">
						<td style="padding-left:50px;">文章分类：</td>
						<td ><input type="text" name="cate" id="cate" style="width:300px;" value="<?=$selectcate?>" readonly>
						  <span style="padding-left:20px;">
						  <select name="select2" id="select2"  onchange="newsform.cate.value=this.options[this.selectedIndex].text;newsform.Num.value=this.value;">
							<option value="0">请选择一个类别：</option>
							<?
			$news_sql="SELECT cateName FROM ls_functioncates  where functionName='新闻分类' order by Num ";//count the error by searchtype
			$news_query=$opendb->query($news_sql);
			while($news_rows2=mysql_fetch_assoc($news_query))
		  	{
				$select_sql2="select Num from ls_news where cate='".$news_rows2['cateName']."'  order by Num desc  limit 1";
				//echo $select_sql2;
				$select_query2=$opendb->query($select_sql2);
				$select_rows2_num=mysql_fetch_assoc($select_query2); //总数
				echo "<option value=".($select_rows2_num['Num']+5).">".$news_rows2['cateName']."</option>";
			}

			?>
						  </select>
						</span></td>
						<td >日期：
					    <input name="newsDate" id="newsDate" type="text" style="width:90px;" value="<?=date('y-m-d')?>" size="20"  /></td>
					  </tr>
                      <tr bgcolor="#f4f4f4">
                      		<td style="padding-left:50px;">关键字</td>
                            <td colspan="2"><input type="text" style="width:300px;" name="keywords" />&nbsp;(关键词用英文的【逗号】隔开)</td>
                            
                      </tr>
					  <tr bgcolor="#f4f4f4"> 
						<td style="padding-left:50px;">文章内容：</td>
						<td style="padding-left:50px;">&nbsp;</td>
						<td style="padding-left:50px;"><input type="submit" value="添加文章" />
                        <input type="reset" name="button" id="button" value="重置" /></td>
					  </tr>
					  <tr>
					  	<td colspan="3">
                         <textarea name="newsText" style="width:100%;height:400px;visibility:hidden;"></textarea>
                        </td>
					  </tr>
					  <tr bgcolor="#B9DAFF"> 
						<td height="25" colspan="2" align="center"><input type="submit" value="添加文章">
					    <input type="reset" name="button2" id="button2" value="重置" /></td>
						<td height="25" align="center"><img src="images/shao.gif" alt="" />&nbsp;<a href="news.php?selectcate=<?=$selectcate?>"><u>返回</u></a></td>
					  </tr>
					</table>
					<br />
                 </form>
				</td>
			</tr>
		</table>
	</body>
</html>