<%@ Page Language="C#" EnableViewState="false" AutoEventWireup="true" CodeBehind="AddNews.aspx.cs" Inherits="Forum.Web.Admin.Body.AddNews" %>
<%@ Register assembly="Editor2" namespace="Editor2" tagprefix="cc1" %>
<%@ Register assembly="Forum.Control" namespace="Forum.Control" tagprefix="cc11" %>

<html>
<head id="Head1" runat="server">
    <title></title>
    <link href="../styles/dntmanager.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.list_tu {
	height: 120px;
	width: 120px;
	float: left;
	display: block;
	margin-right: 15px;
	margin-top: 15px;
	border: 1px solid #729FD8;
}
.apDiv1 {
	position:static;
	height:20px;
	z-index:1;
	margin-top: -20px;
}
.apDiv1 div {
	background-color: #B3CBEA;
	height: 20px;
	text-align: center;
	line-height: 20px;
	cursor:pointer;
	float: left;
	width: 120px;
}
#jiatu_ {
	float: left;
	margin-top: 15px;
	padding-top: 60px;
}
#jiatu_ img {
	cursor:pointer;
}
.list_tu img {
	height: 100px;
	width: 120px;
}
.list_tu div {
	background-color: #FFFFFF;
	line-height: 20px;
	height: 20px;
	width: 120px;
}
.list_tu span {
	cursor:pointer;
}
.list_tu span:hover {
	color: #FF0000;
}
</style>
</head>
<script src="../js/public.js" type="text/javascript"></script>
<body  class="ContentBody">
<form id="form2" runat="server">
<asp:TextBox ID="TextBox1" runat="server" Width="672px" style=" display:none;"></asp:TextBox>
    <cc11:Hint ID="Hint1" runat="server" HintImageUrl="../" />
    	<div class="ManagerForm">
		<fieldset>
		    <legend style="background:url(../images/icons/icon30.jpg) no-repeat 6px 50%;">添加/修改文章</legend>
<div class="MainDiv">
<table width="100%" border="0" cellpadding="0" cellspacing="0" 
                             style="width: 100%; padding-right: 5px;">
<tr>
                                 <td height="40" align="right" style="padding-right: 5px">
                                   所属分类:</td>
    <td>
                  &nbsp; 
     <asp:DropDownList ID="f_mululist" runat="server">
                     </asp:DropDownList>
        </td>
      </tr>
                             <tr>
                                 <td height="40" align="right" style="padding-right: 5px">
                                     标题:</td>
                               <td>
 &nbsp;
 <select name="BriefTopic" id="f_huati" runat="server">
            <option value="">选择话题</option>
			<option value="[图文]">[图文]</option>
			<option value="[组图]">[组图]</option>
			<option value="[新闻]">[新闻]</option>
			<option value="[推荐]">[推荐]</option>
			<option value="[注意]">[注意]</option>
			<option value="[转载]">[转载]</option>
          </select>
<cc11:TextBox ID="f_name"   HintInfo="英文汉字均可,不能为空" runat="server" Width="210px" onblur="InData(this.value);"></cc11:TextBox>
                               <span style="display:none;"><input id="Text2" style="width: 12px" type="text" /></span></td>
        </tr>
                             <tr>
                                 <td width="100" height="40" align="right" style="padding-right: 5px; width:100px">
                                   标题显示颜色:</td>
                               <td>
		 &nbsp;                        <select id="f_color" runat="server">
		<option value="">请选择颜色</option>
<option style="background-color:#FF0000;color: #FF0000" value='#FF0000'>#FF0000</option>
<option style="background-color:#0000FF;color: #0000FF" value="#0000FF">#0000FF</option>
<option style="background-color:#008800;color: #008800" value="#008800">#008800</option>
<option style="background-color:#FFFF00;color: #FFFF00" value="#FFFF00">#FFFF00</option>
<option style="background-color:#9900FF;color: #9900FF" value="#9900FF">#9900FF</option>
<option style="background-color:#808080;color: #808080" value="#808080">#808080</option>
<option style="background-color:#00FFFF;color: #00FFFF" value="#00FFFF">#00FFFF</option>
<option style="background-color:#998566;color: #998566" value="#998566">#998566</option>
<option style="background-color:#FFCC00;color: #FFCC00" value="#FFCC00">#FFCC00</option>
      </select>                                     </td>
        </tr>
                             <tr>
                                 <td height="40" align="right" style="padding-right: 5px">
                                     作者:</td>
                               <td>
 &nbsp;
 <cc11:TextBox ID="f_addname"  runat="server" Width="210px" Text="佚名" ></cc11:TextBox>
                               <select name="font2" onChange="f_addname.value=this.value;">
<option value="" selected>选择作者</option>
<option value="佚名">佚名</option> <option value="本站">本站</option> <option value="不详">不详</option> <option value="未知">未知</option>
</select></td>
        </tr>
                             <tr>
                                 <td height="40" align="right">来源:</td>
                               <td height="50">
 &nbsp;
 <cc11:TextBox  ID="f_laiyuan"  runat="server" Width="210px" Text="本站整理" ></cc11:TextBox>
                               <select name="s_f_laiyuan" onChange="f_laiyuan.value=this.value;">
<option value="" selected>选择来源</option>
 <option value="本站整理">本站整理</option>
 <option value="本站原创">本站原创</option>
 <option value="不详">不详</option>
 <option value="转载">转载</option>
</select></td>
        </tr>
                             <tr>
                                 <td height="40" align="right">描述:</td>
                         <td height="50" style="padding:5px">
                       <cc11:TextBox 
                                          ID="f_shuoming" HintInfo="对主内容的简短说明,120个汉字以内" runat="server" 
                                   Width="400px" Height="80px" 
                                          TextMode="MultiLine"></cc11:TextBox>
                               </td>
        </tr>
                             <tr>
                                 <td height="40" align="right">类型:</td>
                           <td height="50" style="padding:5px">
<select id="f_listtu" name="D1" runat="server" onChange="listtuch(this.value)">
 <option value="0">文章 (支持html+图片)</option>
 <option value="1">图片 (单独的图片展示)</option>
</select>
                               <span style="color:Red;">(对于新闻资讯类信息推荐选择'文章类型'),图片类型是标题图片站形式展示</span>
                               </td>
        </tr>
                             <tr id="yc_1">
                                 <td height="40" align="right"><b>已上传图片:</b></td>
                           <td height="50" style="padding:5px">
<div id="list_content">
</div>
<div id="jiatu_"><img src="../images/album_add.gif" onClick="addimg()"  /></div>
</td>
        </tr>
                             <tr  id="yc_0">
                                 <td height="40" align="right">内容:</td>
                           <td height="50" style="padding:5px">
                   <cc1:HtmlEditor ID="HtmlEditor1" runat="server" Width="600px" 
                                   ResourcesPath="/htmledit/">
                             </cc1:HtmlEditor>                                                    </td>
        </tr>
                             <tr>
                                 <td height="40" align="right">首页缩略图:</td>
                               <td height="50">
 &nbsp;
<cc11:TextBox ID="f_tu"  HintInfo="可为网络地址,如:http://www.jingdiansheji.com/logo.gif" runat="server" 
                                       Width="220" HintShowType="up"></cc11:TextBox>
                                                <cc11:Button 
                                       ID="Button3" runat="server" AutoPostBack="False" 
                                       ButtonImgUrl="../images/arrow_undo.gif" Text=" 浏 览" ValidateForm="False" 
                                       ScriptContent="tu_()" />&nbsp;</td>
        </tr>
                             <tr>
                                 <td height="40" align="right">点击/星级:</td>
                   <td height="50">
                                     &nbsp; 初始点击:
     <cc11:TextBox ID="f_fangwen"    runat="server"   Width="60" Text="0" ></cc11:TextBox>
                                     &nbsp; 
                                     文章星级:
<select name="f_xinji" id="f_xinji" runat="server">
<option value="5">★★★★★</option>
<option value="4">★★★★</option>
<option value="3" selected>★★★</option>
<option value="2">★★</option>
<option value="1">★</option>
</select></td>
        </tr>
                             <tr id="z_fl" >
                                 <td height="40" align="right">其它选项:</td>
                          <td height="50">
                              &nbsp;
                   <input id="f_zhiding" type="checkbox" runat="server"  /><label for="f_zhiding">置顶</label>
                                     <input id="f_jinhua" type="checkbox" runat="server"  /><label for="f_jinhua">推荐</label>   
                                     <input id="f_closepl" type="checkbox" runat="server"  /><label for="f_closepl">禁止发表评论(锁定)</label>  &nbsp; 
                               <input id="f_shenhe" type="checkbox" runat="server"  /><label for="f_shenhe">立即发布</label><span style="color:Red;">（否则审核后才能发布）</span></td>
        </tr>
                             </table>
<script  type="text/javascript">
var list_par=new Array();//选择的图片ID列表
var par_="<%#par_ %>".split('∪');

function listtuch(tu_type)
{
    //var tu_type=hbctl_.GetValueOrTextBySelectID("f_listtu","value");
    if(tu_type==0)
    {
        hbctl_.$("yc_1").style.display="none";
        hbctl_.$("yc_0").style.display="";
    }
    else
    {
        hbctl_.$("yc_1").style.display="";
        hbctl_.$("yc_0").style.display="none";
    }
}
var tu_type_=hbctl_.GetValueOrTextBySelectID("f_listtu","value");
listtuch(tu_type_);

function Button1_onclick() {
    //document.getElementById("f_xinji").value=4;
    return jc();
}
function jc()
{
    if(hbctl_.$("f_name").value.length<1)
    {
        alert("请输入文章标题");
        return false;
    }
    var stxt=hbctl_.GetValueOrTextBySelectID("f_mululist","text").toString();

    if(stxt.indexOf("　")==-1)
    {
        alert("该一级分类已有下级分类,请选择其下属分类再提交信息");
        return false;
    }
    onsub_();
}
function InData(value_)
{
    Forum.Web.Admin.Body.AddNews.InData(value_,function(res){
        if(res.value=="1")
        {
            alert("数据库里已经存包含此标题的信息");
        }
    })
}
function onsub_()
{
    var m_id=hbctl_.GetValueOrTextBySelectID("f_mululist","value");//分类ID
    var m_name=hbctl_.GetValueOrTextBySelectID("f_mululist","text");//分类标题
    var f_huati=hbctl_.GetValueOrTextBySelectID("f_huati","value");//转载
    var f_name=hbctl_.$("f_name").value;//标题
    var f_color=hbctl_.GetValueOrTextBySelectID("f_color","value");//标题颜色
    var f_addname=hbctl_.$("f_addname").value;//作者
    var f_laiyuan=hbctl_.$("f_laiyuan").value;//来源
    var f_tu=hbctl_.$("f_tu").value;//图片
    var f_fangwen=hbctl_.$("f_fangwen").value;//初始访问量
    var f_xinji=hbctl_.GetValueOrTextBySelectID("f_xinji","value");//星级
    var f_shuoming=hbctl_.$("f_shuoming").value;//说明
    var f_listtu=hbctl_.GetValueOrTextBySelectID("f_listtu","value");
    
    var f_zhiding=hbctl_.$("f_zhiding").checked?1:0;//置顶
    var f_jinhua=hbctl_.$("f_jinhua").checked?1:0;//推荐
    var f_closepl=hbctl_.$("f_closepl").checked?1:0;//禁止评论
    var f_shenhe=hbctl_.$("f_shenhe").checked?1:0;//是审核通过
    
    var rbody=RIfrBodyHtml();
    
    if(f_listtu==1)//如果是图片类型
    {
        rbody=GetAllImg();
    }
    
    
    var rid=hbctl_.Request("id");
    if(rid=="")
    {
         Forum.Web.Admin.Body.AddNews.AddData(m_id,m_name, f_name,f_color,f_addname,f_laiyuan,f_tu,f_fangwen,f_xinji,f_zhiding,f_jinhua,f_closepl,f_shenhe,f_huati,rbody,f_shuoming,f_listtu,rshow);
    }
    else
    {
         Forum.Web.Admin.Body.AddNews.Editata(rid, m_id,m_name, f_name,f_color,f_addname,f_laiyuan,f_tu,f_fangwen,f_xinji,f_zhiding,f_jinhua,f_closepl,f_shenhe,f_huati,rbody,f_shuoming,f_listtu,rshow);
    }
}
function rshow(res)
{
    if(res)
    {
        var msg=window.confirm("操作成功!是否添加新信息?");
        if(msg)
        {
            window.location="AddNews.aspx";
        }
        else
        {
            var uurl= hbctl_.$('TextBox1').value.toLocaleLowerCase();

            if(uurl.indexOf('newslist2.aspx')!=-1)
            {
                window.location=uurl;
            }
            else
            {
                window.location="NewsList2.aspx";
            }
        }
    }
    else
    {
        alert("操作失败!请刷新页面重新操作");
        window.location="AddNews.aspx";
    }
}
function up1_onclick() {
   tu_();
}
function tu_() {
    var v1=hbctl_.$('f_tu');
	//var galleryscript = '../IfrUpAspx/Ifr.aspx?url=UpPic.aspx?path=UpLoad/News/';
	var galleryscript = '../IfrUpAspx/Ifr.aspx?url=UpPic.aspx?path=DownLoad/&yymmdd=false';

	imgArr = showModalDialog(galleryscript,window,'dialogWidth:350px; dialogHeight:150px;help: no; scroll: no; status: no');
	if (imgArr != null) {
		v1.value=imgArr;
	}
}
var s_mid=<%#mid %>;
function showsdr()
{
    if(s_mid!=-1)
    {
        hbctl_.$("f_mululist").value=s_mid;
    }
}
showsdr();
</script>
<script  type="text/javascript">
function addimg()
{
    //var galleryscript = '../IfrUpAspx/Ifr.aspx?url=UpPic.aspx?tf_xiaotu=true&path=UpLoad/News/';
    //var galleryscript = '../IfrUpAspx/Ifr.aspx?url=UpPic.aspx?tf_xiaotu=true&path=DownLoad/Images/';
    var galleryscript = '../IfrUpAspx/Ifr.aspx?url=UpPic.aspx?tf_xiaotu=true&path=DownLoad/&yymmdd=false';
    //window.open(galleryscript);
	imgArr = showModalDialog(galleryscript,window,'dialogWidth:350px; dialogHeight:150px;help: no; scroll: no; status: no');
	if (imgArr != null) {
		AddImg(imgArr);
		addhtml(imgArr);
	}
}
function addhtml(src_)
{
   var m_src_=src_.toString().split('/');
   var n_filename="m_"+m_src_[2];
   var n_src=m_src_[0]+"/"+m_src_[1]+"/"+n_filename;
   
   var temp_str='<div class="list_tu"><img src="/'+src_+'"><div>&nbsp;&nbsp;&nbsp;<span onclick=shefm("'+src_+'")>[设为封面]</span><span>&nbsp;&nbsp;&nbsp;</span><span onclick=delhtml(this,"'+src_+'")>[删除]</span></div></div>';

   //hbctl_.$('list_content').insertAdjacentHTML("beforeEnd",temp_str);
   hbctl_.insertHtml("beforeEnd", hbctl_.$('list_content'), temp_str);
   
   //alert(GetAllImg());
}
function delhtml(this_,src_)
{
    //alert(document.getElementById("list_content").children[0].children[0].src);
    var obj_=this_.parentElement.parentElement;
   var msg=window.confirm('您确定要删除这张图片吗?');
   if(msg)
   {
	    hbctl_.$("list_content").removeChild(obj_);
	    DelImg(src_);
	    AddNews.delimg(src_,null,null,null,null,null);
	}
}
function shefm(src_)
{
	hbctl_.$("f_tu").value=src_;
}
</script>
<script>
function adddefaultimg()
{
    if(par_.length>0)
    {
        for(var i=0;i<par_.length;i++)
        {
            var indexobj=par_[i];
            if(indexobj.length>5)
            {
                AddImg(indexobj);
                addhtml(indexobj);
            }
        }
    }
}
//判断是否存在于列表中
function InListPar(imgid_)
{
    var rtf_=false;
    
    if (list_par.length>0)
    {
        for(var i=0;i<list_par.length;i++)
        {
            if (list_par[i].toString().toLowerCase()==imgid_.toString().toLowerCase())
            {
                rtf_=true;
                break;
            }
        }
    }
    return rtf_;
}
//将图片添加到列表中
function AddImg(imgid_)
{
    if (list_par.length>0)
    {
        var inimg_=false;
        for(var i=0;i<list_par.length;i++)
        {
            if (list_par[i].toString().toLowerCase()==imgid_.toString().toLowerCase())
            {
                inimg_=true;
                break;
            }
        }
        
        if (!inimg_)
        {
            list_par.push(imgid_);//添加
        }
    }
    else
    {
        list_par.push(imgid_);//添加
    }
}
//将图片从列表中删除
function DelImg(imgid_)
{
    if (list_par.length>0)
    {
        var inimg_=-1;
        for(var i=0;i<list_par.length;i++)
        {
            if (list_par[i].toString().toLowerCase()==imgid_.toString().toLowerCase())
            {
                inimg_=i;
                break;
            }
        }

        if (inimg_!=-1)
        {
            list_par.splice(inimg_,1);//删除数组项
        }
    }
}
function GetAllImg()
{
    var rtxt="";
    if (list_par.length>0)
    {
        for(var i=0;i<list_par.length;i++)
        {
            var indexobj=list_par[i].toString().toLowerCase();
            
            if(indexobj.length>5)
            {
                rtxt+=indexobj+"∪";
            }
        }
        if(rtxt.length>0)
        {
           rtxt= rtxt.substring(0,rtxt.length-1);
        }
    }
    return rtxt;
}
adddefaultimg();

</script>
</div>
		</fieldset>
        <div class="Navbutton">
<span id='sp3'><cc11:Button 
                                       ID="Button4" runat="server" AutoPostBack="False" 
                                       ButtonImgUrl="../images/check_1.gif" Text=" 保存内容" ValidateForm="False" 
                                       ScriptContent="return Button1_onclick()" /></span>
                                       
<span id='sp4' style="display:none;">
<cc11:Button 
                                       ID="Button5" runat="server" AutoPostBack="False" 
                                       ButtonImgUrl="../images/check_1.gif" Text=" 保存内容" ValidateForm="False" 
                                       ScriptContent="return Button2_onclick()" />
</span>
<span id='sp5'>&nbsp;
            <cc11:Button 
                                       ID="Button6" runat="server" AutoPostBack="False" 
                                       ButtonImgUrl="../images/cache_reset.gif" 
                Text=" 取  消" ValidateForm="False" 
                                       ScriptContent="history.go(-1);" /></span>
                                       
        </div>
        </div>
    </form>
</body>
</html>