<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EditPost.aspx.cs" Inherits="Admin_EditPost" %>

<%@ Register Assembly="Controls" Namespace="Spaces.Controls" TagPrefix="cc1" %>

<%@ Register TagPrefix="FTB" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %>
<%@ Import Namespace="Spaces" %>
<html runat="server" id="myhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=urf-8">
    <title><%=Globals.Text["EditPost_Title"]%></title>
    <link rel="StyleSheet" href="<%=Globals.ApplicationPath %>/Include/base.css">
    <script src="<%=Globals.ScriptPath %>/dialog.js" type="text/javascript"></script>
    <script src="<%=Globals.ApplicationPath %>/Include/js/base.js" type="text/javascript"></script>
    <script src="<%=Globals.ApplicationPath %>/Include/js/publish_img.js" type="text/javascript"></script>
    <script src="<%=Globals.ScriptPath %>/admin_editPost.js" type="text/javascript"></script>

    <script src="<%=Globals.ApplicationPath %>/Include/js/net_secure.js" type="text/javascript"></script>
    <script src="<%=Globals.ApplicationPath %>/Include/js/AddBlogCategory_Soap.js" type="text/javascript"></script>
   
    <script type="text/javascript" src="<%=Globals.ApplicationPath %>/Include/FCKeditor/fckeditor.js"></script>
   
    <style type="text/css">
<!--
 .codestuff { background-color : #eeeeee; border:solid 1px #000000; padding:5px; font-family: Courier New; font-size: 12px}
               .codestuff .keytype { color : #FF9933; font-weight : normal; }
               .codestuff .keyword { color : #224FFF; font-weight : normal; }
               .codestuff .integer { color : #FF0032; }
               .codestuff .comment { color : #008100; }
               .codestuff .errors { color : #FF0000; font-weight : bold; }
               .codestuff .string { color : #FF0022; }
.input_text1{height:21px;border:1px solid #197B30;background:#f7f5e0}
.input_text2{height:21px;border:1px solid #197B30;background:#eff0f0}

.img_box a{ text-decoration:none; color:#000000}
.arrow_up{background:url("img/arrow_up.gif") #ACD373 no-repeat center;cursor:hand;cursor:pointer;}
.arrow_down{background:url("img/arrow_down.gif") #ACD373 no-repeat center;cursor:hand;cursor:pointer;}
.sort_close{background:url('img/publish_add_sort_close.gif');cursor:hand;cursor:pointer;}
.sort_open{background:url('img/publish_add_sort_open.gif');cursor:hand;cursor:pointer;}
.input{height:21px;BORDER-RIGHT: #197b30 1px solid; BORDER-TOP: #197b30 1px solid; BORDER-LEFT: #197b30 1px solid;  BORDER-BOTTOM: #197b30 1px solid}
.input2{height:21px; background:#eff0f0}
div{margin:0px;}
input{margin:0px;}
body{  
}
-->
</style>

    <script type="text/javascript">
var sState = "iframe";
var sEdit = "PostEditor___Frame";
var lastFormId = 1;
var checkEdit;
function isDigit(s)
{
var patrn=/^[\d]+$/;
if (!patrn.exec(s)) return false
return true
}
//iframe_data
function initForm(_sId){
var sFileUpload = '\
<form id="form' + _sId + '" title="" enctype="multipart/form-data" action="AlbumPost.aspx" method="post" target="iframe_data">\
<input name="filePath" type="hidden" id="filePath' + _sId + '" />\
<input name="fileKey" type="hidden" value="' + _sId + '" />\
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="img_box">\
    <tr>\
      <td style="border:1px solid #000">\
    	<table width="100%"  border="0" cellspacing="0" cellpadding="0">\
          <tr style="background:#7acb17">\
            <td width="106" height="20">&nbsp;<a href="javascript:addArticle(' + _sId + ');">'+Strings.InsertPicture+'</a></td>\
            <td width="2"><img src="img/pic_box_sline.gif" width="2" height="12"></td>\
            <td width="20" align="center"><a href="javascript:clearSelect(' + _sId + ');"><img src="img/del_btn.gif" width="10" height="10" border="0"></a></td>\
          </tr>\
          <tr>\
            <td height="1" colspan="3" bgcolor="#787878"></td>\
          </tr>\
          <tr align="center" valign="middle" bgcolor="#ffffff">\
            <td height="120" colspan="3" id="picShow' + _sId + '" style="background:url(\'\');"><span style="color:#7f7f7f">'+Strings.PictureShearPlate+'</span></td>\
          </tr>\
        </table>\
      </td>\
    </tr>\
    <tr>\
      <td height="1"></td>\
    </tr>\
    <tr>\
      <td style="width:140px"><input name="fileContent" type="file" id="file' + _sId + '" type="file" size="12"   style="width:140px;border:1px solid #000" onchange="javascript:initUpload(this,' + _sId + ');"></td>\
    </tr>\
</table>\
</form>\
';
dw(sFileUpload);
}

function report_upload_ok(front_id, pic_id)
{
	lastFormId = front_id;
	$('picShow' + front_id).innerHTML = "<span style='color:#ff0000;font-weight:bold'>"+Strings.UploadComplete+"</span>";
	replaceStr($('filePath' + front_id).value, '<asp:Literal runat="server" ID="AlbumPath"></asp:Literal>'+pic_id);
	$('form' + front_id).reset();
	if ($('album').value == ''){
		var sp_char = '';
	}
	else{
		var sp_char = ',';
	}
	$('album').value = $('album').value + sp_char + pic_id;	
	postFile(++front_id);

}

function report_upload_error(error_str, front_id)
{
	_error_msg_show(error_str);
	lastFormId = front_id;
}

// 添加分类表单检查
function check_sort_form(){
	if ($('sort_txt').value == ''){
		_error_msg_show(LostCategoryName);
		return;
	}
	//$('typename[]').value = $('sort_txt').value;
	if ($('sort_txt').value.length > 28){
        _error_msg_show(Strings.CategoryNameError);
        return;
    }

	//$('sortForm').submit();
}

// 添加分类框显示切换
function add_sort_switch(){
	if ($('add_sort_txt').style.display == 'none'){
		$('add_sort_txt').style.display = '';
		$('add_sort_desc').style.display = '';
		$('add_sort_switch').className = "sort_close"; 
	}
	else{
		$('add_sort_txt').style.display = 'none';
		$('add_sort_desc').style.display = 'none';
		$('add_sort_switch').className = "sort_open"; 
	}
}
var myEditor='PostEditor';
function check_article_form(){
	var btitle = $('blog_title');
	if (btitle.value == ''){
		_error_msg_show(Strings.LostPostTitle);
		return false;
	}
	else if(btitle.length > 50){
		_error_msg_show(Strings.PostTitleLengthError);
		return false;
	}
	var bbody;
	try{
	  bbody=getEditorObj().EditorDocument.body.innerHTML ;}catch(err){}
    if (bbody && bbody.trim() == ''){
        _error_msg_show(Strings.LostPostBody);
        return false;
    }
	return true;
}
function checkPrice()
{
 var price =$('<%=iptPostPrice.ClientID %>');
	if(!isDigit(price.value))
	{
	
	  _error_msg_show(Strings.PostPriceError);
	 event.keyCode = 0 ;
	}
}
function postFile(_sId){
	var sId = 'form' + _sId;
	if (exist(sId)) {

		if ($(sId).title.length > 0 && seekUse(_sId)) {
			$(sId).submit();
		} else {
			clearSelect(_sId);
			postFile( ++_sId );
		}
	}else{

		//et.save();
		var oForm=$('<%=articleForm.ClientID %>');
		　　//oForm.action='EditPost.aspx?postID=<%=SpacesContext.Current.PostID %>';
			 oForm.target = "iframe_data";
			 oForm.submit();
		//$('article').submit();
	}
} //发布文章
function publish_article(){
	//et.save();
	
	if (check_article_form()){
		save_article();
		if(getSend()<20){
			_error_msg_show(Strings.PublishTimeout.replace(/TIME/g,   (20 - getSend()) ));
			//_error_msg_show('请勿在短时间内多次发送信息 :)<br/> 您需要耐心等待 ' + (20 - getSend()) + ' 秒，就可以发表文章了.');
			return false;
		}
		initSendTime();	
		_error_msg_show(Strings.PostingError, "", 3);
		
		postFile(lastFormId);
	}
}
function save_article(){
	//et.save();
	//if(exist('blog_body_textarea')){
	//	setCopy($('blog_body_textarea').value);
	//}else if(exist('blog_body_area')){
	//	setCopy($('blog_body_area').value);
	//}
	setCopy($(myEditor).value);
}
function publish_draft()
{
	$('act').value = '3';
	publish_article();
}

function article_preview()
{
        if (check_article_form()){
			_confirm_msg_show('不叫你预览，就不叫你预览，因为我还没做呢，哈哈哈哈:)');
			//设置表单　提交表单　到查看页
			//$('<%=articleForm.ClientID %>').submit();
		
        }
}


//检查文档标题
function top_title_switch()
{

	if($('blog_title').value != ''){
		$('top_title').innerHTML = '<span style="font-weight:bold">'+Strings.PostTitle+'&nbsp;-&nbsp' + $('blog_title').value + '</span>';
	}
	else
	{
		$('top_title').innerHTML = '<span style="font-weight:bold;color:#990000">'+Strings.LostPostTitleTip+'</span>';
	}
	ArrowControl('arrow_up','arrow_down','article_title', 'article_title_arrow');
	AreaControl('editerTextArea1','editerTextArea','article_title',myEditor);
	try{
		parent.iframeResize();
	}
	catch(e){}
}	

function img_pool_switch()
{
	ArrowControl('arrow_up','arrow_down','image_upload', 'img_upload_arrow');
	try{
		parent.iframeResize();
	}
	catch(e){}
}

function add_calendar(cal_str)
{
	if($('blog_title').value == ''){
		$('blog_title').value = Strings.Diary+ ' [' + cal_str + ']';
	}
}

function AreaControl(_sCSS, _sCSS_Over, _sNodeName, _tNodeName){
    _this = $(_tNodeName);
    var _o = $(_sNodeName);
    if(_o.style.display == "none") {
        _this.className = _sCSS;
    }
    else {
        _this.className = _sCSS_Over;
    }
} 

function ArrowControl(_sCSS, _sCSS_Over, _sNodeName, _tNodeName) {
	
	if (_tNodeName){
    	var _this = $(_tNodeName);
    }
    else{
    	var _this = event.srcElement;
    }
    var _o = $(_sNodeName);
    if(_o.style.display == "none") {
        _o.style.display = "";
        _this.className = _sCSS;
    }
    else {
        _o.style.display = "none";
        _this.className = _sCSS_Over;
    }
}



    </script>

</head>
<body>
   
        <div align="center">
            <table width="640" border="0" cellspacing="0" cellpadding="0" style="border: 1px solid #FFFFFF; background-color:#ACD373; " >
                <tr>
                    <td onClick="top_title_switch();" style="cursor: hand;">
                        <!-- 分割栏 -->
                        <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ACD373"
                            style="border-bottom: 1px solid #197B30;">
                            <tr>
                                <td width="5">&nbsp;
                                    </td>
                                <td width="10">
                                    <img src="./img/publish_title_spline.gif" width="3" height="28"></td>
                                <td id="top_title">&nbsp;
                                    </td>
                                <td width="1" bgcolor="#FFFFFF">
                                </td>
                                <td width="1" bgcolor="#009900">
                                </td>
                                <td width="17" class="arrow_up" id="article_title_arrow">
                                </td>
                            </tr>
                        </table>
                        <!-- /分割栏 -->
                    </td>
                </tr> 
                <form id="articleForm" runat="server">
                <tr>
                    <td>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr id="article_title">
                                <td width="27" style="background: url('img/publish_blog_2006.gif');" height="168">
                                    <table>
                                        <tr>
                                            <td width="25">
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                                <td valign="top" style="background: url('img/publish_body_bg.gif')" bgcolor="#3333cc" contenteditable="" rowspan="">
                                    <!-- 标题信息表单 -->
                                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                            <td colspan="3" height="2" bgcolor="#a0a0a0">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="3" height="8">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>&nbsp;
                                                </td>
                                            <td>
                                                <table width="100%" border="0" cellspacing="3" cellpadding="0">
                                                    <tr>
                                                        <td>
                                                           <%=Globals.Text["EditPost_ArticalTitle"]%></td>
                                                        <td><input id="album" name="album" type="hidden" value="">
                                                            <input type="text" name="blog_title" id="blog_title" class="input_text1" style="width: 450px"
                                                                maxlength="50" onBlur="changeMaxLen(this, 50)" onKeyUp="changeMaxLen(this, 50)"
                                                                runat="server">
                                                            <a href="javascript:;">
                                                                <img src="img/publish_calendar.gif" width="16" height="18" align="absmiddle" border="0"
                                                                    onclick="add_calendar('<%=DateTime.Now.ToString(Globals.Text["EditPost_DateTimeFormat"]) %>');" title="<%=Globals.Text["EditPost_Now"] %>"></a></td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <%=Globals.Text["EditPost_Category"]%></td>
                                                        <td>
                                                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                                <tr>
                                                                    <td width="10">
                                                                        <select id="blog_class" name="blog_class" style='height: 20px' runat="server">
                                                                        </select>
                                                                       
                                                                    </td>
                                                                    <td>
                                                                        <table border="0" cellspacing="0" cellpadding="0">
                                                                            <tr>
                                                                                <td id="add_sort_txt" style="display: none; background: #99afc2">
                                                                                    <input type="text" id="sort_txt" name="sort_txt" maxlength="24" style="width: 80px;
                                                                                        height: 18px" class="input_text1" onBlur="changeMaxLen(this, 24)" onKeyUp="changeMaxLen(this, 24)"
                                                                                        title="<%=Globals.Text["EditPost_EditCategory"] %>"></td>
                                                                                <td id="add_sort_desc" style="display: none; background: #99afc2">
                                                                                    <a href="javascript:getcheckmsg()" title="<%=Globals.Text["EditPost_AddCategory"] %>">
                                                                                        <img src="img/publish_add_sort_title.gif" width="63" height="18" border="0" align="absmiddle"></a></td>
                                                                                <td class="sort_open" id="add_sort_switch" onClick="add_sort_switch()" title="<%=Globals.Text["EditPost_OpenAndClose"] %>">
                                                                                    <img src="img/null.gif" border="0" width="17">

                                                                                    <script language="javascript" type="text/javascript">
 
 function getResponse()
{
var root =this.req.responseXML;  
if(!root)
root=GetXMLDoc(this.req.responseText);
var msg;
if(root.childNodes[1]&&root.childNodes[1].text)
msg=eval(root.childNodes[1].text);
 else
msg=eval(root.childNodes[0].textContent);
 if(msg[0].id==-1)
 {
 _error_msg_show('error!');
 return ;
 }
  var name=document.getElementById('sort_txt');
var opts=document.getElementById('<%=blog_class.ClientID%>');
 for(var i=0;i<msg.length;i++)
 {

  opts.options[i]=new Option(msg[i].name,msg[i].id);
 if(msg[i].name==name.value)
  opts.options[i].selected;
 
 }
 _error_msg_show(Strings.AddCategoryComplete);
 name.value='';
 add_sort_switch();
}
function getcheckmsg() {
var cname=$('sort_txt').value;
if (cname == ''){
		_error_msg_show(Strings.LostCategoryName);
		return;
	}

	if (cname.length > 28){
        _error_msg_show(Strings.CategoryNameError);
        return;
    }

AddBlogClass(cname,'<%=Globals.ApplicationPath %>/BlogService.asmx');

}


                                                                                    </script>

                                                                               
                                                                                </td>
                                                                            </tr>
                                                                        </table>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="2">
                                                            <img src="img/publish_body_split.gif"></td>
                                                    </tr>
                                                    <tr>
                                                        <td align="right" width="70">
                                                            <%=Globals.Text["EditPost_KeyWord"]%></td>
                                                        <td title="<%=Globals.Text["SelectTags"] %>">
                                                            <asp:TextBox ID="txtTags" runat="server" CssClass="input_text1"></asp:TextBox>&nbsp;<input type=button class="input" onclick="openWindow('<%=Globals.ApplicationPath %>/include/TagSelector.aspx?TagEditor=SelectTags','210','345','<%=Globals.Text["SelectTags"]%>', '<%=Globals.Text["SelectTags"]%>');" value="<%=Globals.Text["btn_Select"]%>"  />
                                                            <%=Globals.Text["EditPost_key"]%>&nbsp;
                                                            <cc1:SelectAllTags ID="hidTags" runat="server"  TagType="BlogTopic" MaxTagNums="50"  ClearCache="true"/>
                                                             <script language="JavaScript" type="text/javascript" src="<%=Globals.ApplicationPath %>/Include/TagEditor.js"></script>
                                                            <script language="javascript">var SelectTags= new TagEditor('SelectTags', '<%=hidTags.ClientID %>', '<%=txtTags.ClientID %>');
                                                            
                                                            </script>
                                                            </td>
                                                    </tr>
                                                    <tr>
                                                        <td width="70" align="right">
                                                            <%=Globals.Text["EditPost_AllowComments"]%></td>
                                                        <td >
                                                            <asp:CheckBox ID="chkEnableComment" runat="server" Checked="True"  />
                                                            &nbsp;&nbsp;&nbsp;
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="right" width="70" style="height: 20px">
                                                            <%=Globals.Text["EditPost_Hide"]%></td>
                                                        <td  style="height: 20px">
                                                            <asp:CheckBox ID="chkIsHide" runat="server"  /></td>
                                                    </tr>

                                                    <tr style="display:none">
                                                        <td align="right" width="70">
                                                            <%=Globals.Text["EditPost_ArticalValue"]%></td>
                                                        <td>
                                                            <input type="text" class="input_text1" name="iptPostPrice" onBlur="changeMaxLen(this, 300)" value="0"
                                                                onkeyup="changeMaxLen(this, 300)" maxlength="300" id="iptPostPrice" runat="server" onKeypress="checkPrice()">&nbsp;
                                                            <asp:DropDownList ID="dropPriceType" runat="server">
                                                                <asp:ListItem Selected="true" Value="1">银豆</asp:ListItem>
                                                                <asp:ListItem Value="2">金豆</asp:ListItem>
                                                                <asp:ListItem Value="3">金砖</asp:ListItem>
                                                            </asp:DropDownList></td>
                                                    </tr>
                                                </table>
                                                
                                            </td>
                                            <td>&nbsp;
                                                </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" style="margin:0px" align="center" bgcolor="#ACD373" > 		<textarea name="PostEditor" id="PostEditor" runat="server" rows="10" cols="80" style="width: 100%; height: 200px"></textarea>
                <script type="text/javascript">
<!--
var oFCKeditor = new FCKeditor( '<%=PostEditor.ClientID %>' ) ;
oFCKeditor.BasePath = '<%=Globals.ApplicationPath %>/include/fckeditor/';
oFCKeditor.Height	= 360 ;
oFCKeditor.Value	= '' ;
oFCKeditor.Width	= '99%' ;
oFCKeditor.Config['CustomConfigurationsPath']  ='<%=Globals.ApplicationPath %>/Include/FCKeditor/fckconfig.js';
//oFCKeditor.Config["AutoDetectLanguage"] = false ;
	//oFCKeditor.Config["DefaultLanguage"]    = "en" ;
oFCKeditor.ReplaceTextarea()  ;
 
//-->
                </script>

                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                 </form>
                  <tr> 
    <td onClick="img_pool_switch()" style="cursor:hand;cursor:pointer;">
      <table width="100%"  border="0" cellspacing="0" cellpadding="0" bgcolor="#ACD373" style="border-bottom:1px solid #808080;">
      <tr>
        <td width="5">&nbsp;</td>
        <td width="10"><img src="img/publish_title_spline.gif" width="3" height="28"></td>
        <td><%=Globals.Text["EditPost_PictureBoard"]%>&nbsp;<span style="color:#7f7f7f"><%=Globals.Text["EditPost_ClickOpen"]%></span></td>
        <td width="1" bgcolor="#FFFFFF"></td>
        <td width="1" bgcolor="#ae9e9e"></td>
        <td width="17" id="img_upload_arrow" class="arrow_up">
      </tr>
    </table></td>
  </tr>
                <tr id="image_upload" style="display: none;">
                    <td>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0" style="background:url('img/publish_body_bg.gif');" >
      <tr>
        <td colspan="9" height="2" bgcolor="#ACD373"></td>
      </tr>
      <tr>
        <td width="30">&nbsp;</td>
        <td width="140">&nbsp;</td>
        <td>&nbsp;</td>
        <td width="140">&nbsp;</td>
        <td>&nbsp;</td>
        <td width="140">&nbsp;</td>
        <td>&nbsp;</td>
        <td width="140">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td rowspan="3" style="background:url('img/publish_body_padline.gif') repeat-y center"></td>
        <td><script>initForm(1);</script></td>
        <td>&nbsp;</td>
        <td><script>initForm(2);</script></td>
        <td>&nbsp;</td>
        <td><script>initForm(3);</script></td>
        <td>&nbsp;</td>
        <td><script>initForm(4);</script></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td colspan="9" height="10"></td>
      </tr>
      <tr>
        <td><script>initForm(5);</script></td>
        <td>&nbsp;</td>
        <td><script>initForm(6);</script></td>
        <td>&nbsp;</td>
        <td><script>initForm(7);</script></td>
        <td>&nbsp;</td>
        <td><script>initForm(8);</script></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td colspan="9" height="10"></td>
      </tr>
	  <tr>
	    <td align="center" colspan="9" style="height: 22px"><%=Globals.Text["EditPost_Tip"]%></td>
	  </tr>
    </table></td>
                </tr>
            </table>
            <table width="640" border="0" cellspacing="0" cellpadding="0" align="center" style="background:url('img/publish_body_bg.gif');">
                <tr>
                    <td height="10" colspan="3">
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        <input name="prview" onClick="article_preview();" value="文章预览" type="button" class="update_btn1" style="display:none">&nbsp;&nbsp;
                        &nbsp;&nbsp;
                        <input name="publish" onClick="publish_article();" value="<%=Globals.Text["EditPost_PublishArtical"] %>"   type="submit" class="input" >
                    </td>
                    <tr>
                    <tr>
                    <td height="10" colspan="3">
                    </td>
                </tr>
            </table>
           
        </div>
 
    <iframe name="iframe_data" id="iframe_data" style="display:none" ></iframe>
    <script type="text/javascript">
     var chkType=<%=SpacesContext.Current.PostID %>;
      if(chkType>0)
      {
       $('publish').value=Strings.UpdateTopic;
      }
function init() {
	try{parent.iframeResize();}catch(e){}
}
	oDIALOG = new dialog();
	oDIALOG.init();
	oDIALOG.event("init");
	oDIALOG.reset();

    if(window.Event)
        	window.onload = init;
	else
        	setTimeout(init, 100);
        	function changeMaxLen(obj,length)
        	{
        	if(obj.length>length)
        	{
        	  var sDialog = new dialog();
	sDialog.init();
sDialog.event(Strings.PostTimeErr,'');
sDialog.button('dialogOk','void 0');
}
        	}
        	init();
</script>
</body>
</html>






