<!--#include file="../Inc/Consts.inc" -->
<!--#include file="../Inc/common.Asp" -->
<!--#include file="Admin_htmlconfig.Asp"-->
<!--#include file="inc/editfunc.Asp"-->
<%If InStr(SsMasterPurview, "|8,") = 0 Then
    response.Write ("<br /><br /><div align=""center""><font style=""color:red; font-size:9pt; "")>您没有管理该模块的权限！</font></div>")
    response.End
End If%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="Images/Admin_style.css">
<script language="javascript" src="Images/Disp.js"></script>
<script src="../tqeditor/TQEditor.js" type="text/javascript"></script>
<script language=javascript>
ie = (document.all)? true:false
if (ie){
function ctlent(eventobject){if(event.ctrlKey && window.event.keyCode==13){this.document.editForm.submit();}}
}
</script>
<%
' Ss简单网站管理系统-开源版 
'晴天设计www.xxzwz.com

Dim Result
Result = request.QueryString("Result")
Dim ID, NewsName, ViewFlag, SortName, SortID, SortPath,rs, sql
Dim NoticeFlag, Source, Content, SeoKeywords, SeoDescription,smallpic
Dim Sorts,tempsort
ID = request.QueryString("ID")
Call NewsEdit()
%>
<br />
<table class="tableBorder" width="95%" border="0" align="center" cellpadding="5" cellspacing="1">
  <form name="editForm" id="editForm" method="post" action="Ss_NewsEdit.asp?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>">
    <tr>
      <th height="22" colspan="2" sytle="line-height:150%">【<%If Result = "Add" or Result="" then%>添加<%ElseIf Result = "Modify" then%>修改<%End If%>新闻】</th>
    </tr>
    <tr>
      <td width="10%" align="right" class="forumRow">新闻标题：</td>
      <td class="forumRowHighlight"><input name="NewsName" type="text" id="NewsName" style="width: 280" value="<%=NewsName%>" maxlength="100">
        是否生效：<input class="check" name="ViewFlag" type="checkbox" value="1" <%if ViewFlag then response.write ("checked")%>>
        是否公告：<input name="NoticeFlag" type="checkbox" value="1" <%if NoticeFlag then response.write ("checked")%>> <font color="red">*</font> <input type="button" name="btn" value="复制标题" title="复制标题到：MetaDescription、MetaKeywords" onclick="CopyWebTitle(document.editForm.NewsName.value);"></td>
    </tr>
    <tr>
      <td width="10%" nowrap align="right" class="forumRow">MetaKeywords：</td>
      <td width="90%" class="forumRowHighlight"><input name="SeoKeywords" type="text" id="SeoKeywords" style="width: 500" value="<%=SeoKeywords%>" maxlength="250"></td>
    </tr>
    <tr>
      <td width="10%" nowrap align="right" class="forumRow">MetaDescription：</td>
      <td width="90%" class="forumRowHighlight"><input name="SeoDescription" type="text" id="SeoDescription" style="width: 500" value="<%=SeoDescription%>" maxlength="250"></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">新闻类别：</td>
      <td class="forumRowHighlight">
      <select name="Sorts">
      <%=SortSelect("NewsSort",0,SortID)%>
      </select><font color="red">*</font></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">新闻来源：</td>
      <td class="forumRowHighlight"><input name="Source" type="text" style="width: 280;" value="<%=Source%>" maxlength="100"> <a href="javascript:" onClick="document.editForm.Source.value='本站'">本站</a>|<a href="javascript:" onClick="document.editForm.Source.value='转载'">转载</a>|<a href="javascript:" onClick="document.editForm.Source.value='不详'">不详</a></td>
    </tr>
    <tr>
      <td align="right" class="forumRow" height="42">形象缩略图：</td>
      <td class="forumRowHighlight"><div style="float:left;width:270px;height:25px;line-height:25px;"><input name="SmallPic" type="text" id="SmallPic" style="width:200px;" value="<%=SmallPic%>"><input type="checkbox" onClick="display('upload1');" id="box1"/><label for='box1'>上传图片</label></div>
		<div id="upload1" style="float:left;display:none;">			
		<iframe frameborder=0 width=290 height=25 scrolling=no src="Ss_upload.asp?action=SmallPic&filetype=1&flag=reload"></iframe>
		</div>
        <font color="red">(选填)</font></td>
    </tr>
    <tr>
      <td align="right" class="forumRow">新闻内容：</td>
      <td class="forumRowHighlight">
<textarea id="content" rows="18" cols="100"  name="content" wrap="virtual" onkeydown="ctlent()"><% = Content%></textarea>
<script type="text/javascript" defer> 
 new tqEditor('content', {toolbar:'full',advToolbarMode:true, uploadFieldName:'filedata',imageUploadUrl:'./upload.asp', imageFileTypes:'*.jpg;*.gif;*.png;*.jpeg',directInsertUploadImage:'true'}); 
</script>
      </td>
    </tr>
    <tr>
      <td align="right" class="forumRow"></td>
      <td class="forumRowHighlight"><input accessKey="s" name="submitSaveEdit" type="submit" id="submitSaveEdit" value="(Alt+S)提交"> <input type="button" value="返回前页" onclick="history.back(-1)"></td>
    </tr>
  </form>
</table>
<%
Sub NewsEdit()
    Dim Action, rsRepeat
	Dim Sorts,tempSort
    Action = request.QueryString("Action")
    If Action = "SaveEdit" Then        
        If Len(Trim(request.Form("NewsName")))<3 Then
            response.Write ("<script language='javascript'>alert('请填写新闻名称！');history.back(-1);</script>")
            response.End
        End If
        If Result = "Add" Then
            sql = "select ID,NewsName,ViewFlag,SortID,SortPath,Source,NoticeFlag,Content,SeoKeywords,SeoDescription,smallpic from ["&Datapre&"_News]"
            set rs=db(sql,3)
            rs.addnew
            call savedatas()
            
            rs.update
			ID = rs("ID")
            rs.Close
            Set rs = Nothing
            If ISHTML = 1 Then
                Call htmll("", "", ""&NewName&""&Separated&""&ID&"."&HTMLName&"", "NewsView.Asp", "ID=", ID, "", "")
            End If
        End If
        If Result = "Modify" Then
            sql = "select ID,NewsName,ViewFlag,SortID,SortPath,Source,NoticeFlag,Content,SeoKeywords,SeoDescription,smallPic from ["&Datapre&"_News] where ID="&ID
            set rs=db(sql,3)
            call savedatas()
            rs.update
            rs.Close
            Set rs = Nothing
            If ISHTML = 1 Then
                Call htmll("", "", ""&NewName&""&Separated&""&ID&"."&HTMLName&"", "NewsView.Asp", "ID=", ID, "", "")
            End If
        End If
        If ISHTML = 1 Then
            call Alert( "提交完成，相关静态页面已更新！","Ss_NewsList.asp")
        Else
            call Alert( "提交成功！","Ss_NewsList.asp")
        End If
    Else
        If Result = "Modify" Then
            
            sql = "select ID,NewsName,ViewFlag,SortID,SortPath,Source,NoticeFlag,Content,SeoKeywords,SeoDescription,smallPic from ["&Datapre&"_News] where ID="& ID
            Set rs = db(sql,2)
            If rs.bof And rs.EOF Then
                response.Write ("<center>数据库记录读取错误！</center>")
                response.End
            End If
            NewsName = rs("NewsName")
            ViewFlag = rs("ViewFlag")
            SortName = getSortName("NewsSort",rs("SortID"))
            SortID = rs("SortID")
            SortPath = rs("SortPath")
            Source = rs("Source")
            NoticeFlag = rs("NoticeFlag")            
            Content = rs("Content")
            SeoKeywords = rs("SeoKeywords")
            SeoDescription = rs("SeoDescription")
			smallpic=rs("smallpic")
            rs.Close:Set rs = Nothing
        End If
    End If
End Sub

sub savedatas()
rs("NewsName") = Trim(Request.Form("NewsName"))
            If Request.Form("ViewFlag") = 1 Then
                rs("ViewFlag") = 1
            Else
                rs("ViewFlag") = 0
            End If
			Sorts=Request.Form("Sorts")
            If Sorts = "" Then
                response.Write ("<script language='javascript'>alert('请选择所属分类！');history.back(-1);</script>")
                response.End
            Else
			tempSort=split(Sorts,"|")
                rs("SortID") = tempSort(0)
                rs("SortPath") = tempSort(1)
            End If
            rs("Source") = Trim(Request.Form("Source"))
            If Request.Form("NoticeFlag") = 1 Then
                rs("NoticeFlag") = 1
            Else
                rs("NoticeFlag") = 0
            End If           
            rs("Content") = Trim(Request.Form("Content"))
            rs("SeoKeywords") = Trim(Request.Form("SeoKeywords"))
            rs("SeoDescription") = Trim(Request.Form("SeoDescription"))
			rs("smallpic")= trim(request.Form("smallpic"))
end sub

' Ss简单网站管理系统-开源版 
'晴天设计www.xxzwz.com
%>