<?php 
	require_once('_approot.php');	

	$selectcate=$_GET['selectcate'];
	$page=$_GET['page'];
	$ls_msg="填加博客";
	
	$title_sql = "select * from ls_config";
	$title_query = $opendb->query($title_sql);
	$title_value = mysqli_fetch_assoc($title_query);

?>
<!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/jquery.js"></script>
		<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" />
 <link rel="stylesheet" href="css/style2.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,
			afterBlur: function(){
				this.sync();
			},
            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="100%" border="0" align="center" cellpadding="1" cellspacing="1">
			<tr>
                 <td height="18" style="border-bottom:2px solid #00c0ef; padding-bottom:5px;"><div align="center"><font color="#3c8dbc" style="font-size:16px;">填加博客</font></div>
				</td>
			</tr>
			<tr>
				<td height="213" valign="top"><br>
				 <form name="newsform" enctype="multipart/form-data" method="post" action="saveblog.php?selectcate=<?=$selectcate?>&page=<?=$page?>"  onSubmit="return checkSubmitForm('newsDate,cate,Num,newsTitle','日期,博客分类,序号,博客标题');">
					<input type="hidden" value="insert" name="ls">
					<table border="0" width="98%" align="center">
						<tr>
							<td>提示：<font color="#FF0000"><?php echo $ls_msg; ?></font></td>
							<td align="right"><img src="images/shao.gif">&nbsp;<a href="blog.php?selectcate=<?=$selectcate?>&page=<?=$page?>">返回</a></td>
						</tr>
					</table>
	
    				<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#f0f0ee">
					 
					  <tr bgcolor="#f0f0ee"> 
						<td height="28" colspan="3"></td>
					  </tr>
					  <tr> 
						<td style="padding-left:20px;" width="9%">分类</td>
						<td><input type="text" name="cate" id="cate" style="width:200px;" value="<?=$selectcate==''?'blog':$selectcate?>" readonly />
                          <span style="padding-left:10px;">
                          <select name="select2" id="select2"  onchange="newsform.cate.value=this.options[this.selectedIndex].text;newsform.Num.value=this.value;">
                            <option value="0">请选择类别：</option>
                            <?php 			$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=mysqli_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=mysqli_fetch_assoc($select_query2); //总数
				echo "<option value=".($select_rows2_num['Num']+5).">".$news_rows2['cateName']."</option>";
			}

			?>
                          </select>
                        </span></td>
                        <td width="53%" rowspan="3">
                        	<table border="0" width="98%">
						  <tr>
						    <td width="24%" >标题 Title *</td>
						    <td width="76%"><input name="newsTitle" id="newsTitle" type="text" value="<?php echo $_POST['productTitle'];?>" size="70" /></td>
					      </tr>
						  <tr>
						    <td>关键字 Keywords</td>
						    <td><input name="newsKeywords" id="newsKeywords" type="text" value="<?php echo $_POST['productKeywords'];?>" size="70" /></td>
					      </tr>
						  <tr>
						    <td>描述 Description *</td>
						    <td><textarea name="newsDescription" id="newsDescription" cols="72" rows="3"></textarea></td>
					      </tr>
					    </table><br/><?=$promlv>1?$seo:""?>
                        </td>
					  </tr>
					  <tr>
						<td style="padding-left:20px;" >标题 *</td>
						<td><input type="text" name="newsTitle2" id="newsTitle2" style="width:340px;"  onblur="if($('#cate').val().length > 0){$('#newsTitle').val(this.value+' - '+$('#cate').val()); 
                        $('#newsKeywords').val('<?=$title_value['siteKeywords']?>');}" /></td>
                      </tr>
                      <tr>
                      		<td style="padding-left:20px;">序号</td>
                            <td><?php 						  	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=mysqli_fetch_assoc($select_query2); //总数
						?>
                        <input name="Num" id="Num" type="text" style="width:40px;" value="<?=$select_rows2_num['Num']+5?>" size="6" maxlength="6">
                        <span style="padding-left:50px;">日期：
				        <input name="newsDate" id="newsDate" type="text" style="width:90px;" value="<?=date('y-m-d')?>" size="20"  />
				        </span>
                        </td>
                      </tr>
					  <tr> 
						<td style="padding-left:20px;">内容</td>
						<td width="38%" style="padding-left:20px;">&nbsp;</td>
						<td style="padding-right:20px;" align="right"><button type="submit" value="确定" onClick="
                        if($('#newsText').val().length >= 0){
                        	$('#newsDescription').val($('#newsText').val().substr(0, 86).replace(/<[^>]+>/g,'').replace(/	/g, '').replace(/\n/g, ''));
                        }"/>确定</button>
                        <button type="reset" name="button" id="button" value="重置" />重置</button></td>
					  </tr>
					  <tr>
					  	<td colspan="3">
                        	<textarea name="newsText" id="newsText" style="width:100%;height:350px;visibility:hidden;"></textarea>
                        </td>
					  </tr>
					  <tr bgcolor="#f0f0ee"> 
						<td height="47" colspan="3" align="center"><span style="float:right;"><img src="images/shao.gif" alt="" />&nbsp;<a href="blog.php?selectcate=<?=$selectcate?>">返回</a></span><button type="submit" value="确定" onClick="
                        if($('#newsText').val().length <= 0){
                        	$('#newsDescription').val($('#newsText').val().substr(0, 86).replace(/<[^>]+>/g,'').replace(/	/g, '').replace(/\n/g, ''));
                        }">确定</button>
					    <button type="reset" name="button2" id="button2" value="重置" />重置</button></td>
					  </tr>
					</table>
					<br />
                 </form>
				</td>
			</tr>
		</table>
	</body>
</html>