
<%
/************************************************************@@
  * Program Name	: popup_form_content_modify.jsp
  * Description		: /common/web/documents/form_content_modify/양식 내용(텍스트) 수정
  * Author				: 조용준
  * Create Date		: 2004-12-13
  * History				:
@@************************************************************/
%>
<%@ page contentType="text/html; charset=UTF-8"
	import="kr.co.kihyun.lang.MString" import="kr.co.kihyun.lang.MLong"
	import="kr.co.kihyun.beans.entity.TotDoc"
	import="kr.co.kihyun.text.html.TagFilter"
	import="kr.co.kihyun.lang.StringConverter"
	import="kr.co.kihyun.moumi.Moumi" import="kr.co.kihyun.lang.Encoder"
	import="org.apache.commons.lang.StringEscapeUtils"
	import="javax.jdo.PersistenceManager" import="javax.jdo.Transaction"
	import="kr.co.kihyun.beans.entity.util.*"
	import="kr.co.kihyun.beans.entity.TotDoc"%>
<%@ page import="java.net.URLEncoder"%>
<%@ include file="/totsys/common/inc/sec/secure.inc.jsp"%>
<%
PersistenceManager pm = new MPersistenceManager(PMF.get().getPersistenceManager());
Transaction tx = pm.currentTransaction();

try{
	/********** get Parameter *************/
	Long docID = MLong.parseLong(MString.checkNull(request.getParameter("docID")),null);
	String gubun = clearXSS(Encoder.toJava(request.getParameter("gubun")),"");

	/*********** doc value *****************/
	String docForm = "";
	if(docID != null){
		TotDoc totDoc = pm.getObjectById(TotDoc.class, docID);
		docForm = totDoc.getForm();
		docForm = TagFilter.convertSingle(docForm);
		docForm = StringConverter.toOneLine(docForm);
	}

%>
<html>
<head>
<title><%=Moumi.getTitle()%></title>
<link rel="stylesheet" href="/totsys/common/css/text.css"
	type="text/css">
<link rel="stylesheet" href="/totsys/common/css/kecttep.css"
	type="text/css">
<script src="/totsys/common/js/rollover.js"></script>
<script type="text/javascript" src="/lib/js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
			tinyMCE.init({
			// General options
			mode : "exact",
			elements : "EditCtrl",
			theme : "advanced",
			plugins : "table",
			language: "ko",
			extended_valid_elements : "td[abbr|align<center?char?justify?left?right|axis|bgcolor|char|charoff|class"
													+"|colspan|dir<ltr?rtl|headers|height|id|lang|nowrap<nowrap|onclick"
													+"|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove"
													+"|onmouseout|onmouseover|onmouseup|rowspan|scope<col?colgroup?row?rowgroup"
													+"|style|title|valign<baseline?bottom?middle?top|width"
													+"|*]",
			setup : function(ed) {
		        ed.makeReadOnly = function(ro) {
		            var t = this, s = t.settings, DOM = tinymce.DOM, d = t.getDoc();
		
		            if(!s.readonly && ro) {
		                if (!tinymce.isIE) {
		                    try {
		                        d.designMode = 'Off';
		                    } catch (ex) {
		                        alert(ex);
		                    }
		                } else {
		                    b = t.getBody();
		                    DOM.hide(b);
		                    b.contentEditable = false;
		                    DOM.show(b);
		                }
		                s.readonly = true;
		            } else if(s.readonly && !ro) {
		                if (!tinymce.isIE) {
		                    try {
		                        d.designMode = 'On';
		                        // Design mode must be set here once again to fix a bug where
		                        // Ctrl+A/Delete/Backspace didn't work if the editor was added using mceAddControl then removed then added again
		                        d.designMode = 'Off';
		                        d.designMode = 'On';
		                    } catch (ex) {
		                        alert(ex);
		                    }
		                } else {
		                    b = t.getBody();
		                    DOM.hide(b);
		                    b.contentEditable = true;
		                    DOM.show(b);
		                }
		                s.readonly = false;
		            }
		        };
		    },
	
			forced_root_block : false,
			force_br_newlines: true,
			force_p_newlines: false,
	
			theme_advanced_buttons1 : "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontselect,fontsizeselect",
			theme_advanced_buttons2 : "",
			theme_advanced_buttons3 : "",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_fonts : "굴림=굴림;굴림체=굴림체;궁서=궁서;궁서체=궁서체;돋움=돋움;돋움체=돋움체;바탕=바탕;바탕체=바탕체"
			});
		</script>
<script language=javascript>
			function docFormContentModify(){
				docFormCM.docFCM.value = tinyMCE.getInstanceById('EditCtrl').getContent();

				if(docFormCM.docFCM.value == ''){
					alert('변경할 문서가 없습니다.\\n 다시 확인하시고 변경하여 주십시요.');
					return;
				}else{
					docFormCM.submit();
					//window.close();
				}
			}
		</script>
</head>

<body style='' bgcolor="#FFFFFF" text="#000000" leftmargin="0"
	topmargin="0" marginwidth="0" marginheight="0">
<table width="950" height="570" border="0" cellspacing="0"
	cellpadding="0">
	<tr>
		<td width="29"><img src="images/popupt_top_left.gif" width="29"
			height="19"></td>
		<td background="images/popupt_top_center.gif" height="19">&nbsp;</td>
		<td width="30"><img src="images/popupt_top_right.gif" width="30"
			height="19"></td>
	</tr>
	<tr>
		<td rowspan="2" background="images/popupt_center_left.gif">&nbsp;</td>
		<td valign="top">
		<table valign="top" width="100%" height="100%" border="0"
			cellpadding="0" cellspacing="0">

			<!-- 뉴타이틀 -->
			<jsp:include page="/totsys/common/inc/title/title.jsp" flush="true" />
			<!-- 뉴타이틀 -->

			<tr>
				<td width="100%" style="padding-top: 15; padding-bottom: 15;">
				<table valign="top" cellSpacing="0" cellPadding="0" border="0"
					width="100%" height="200">
					<tr>
						<td>
						<table width="100%" border="0" cellpadding=0 cellspacing=0
							class=llist1>
							<tr class=bgw1>
								<td colspan=3><br>
								<table cellpadding=0 cellspacing=0 border=0>
									<tr>
										<td><font color="FF6600"><b>&nbsp;&nbsp;※ 아래의
										양식내용(텍스트)을 변경해 주세요. </b></font></td>
									</tr>
									<tr>
										<td height=10></td>
									</tr>
									<tr>
										<td><textarea id="EditCtrl"
											style="width: 100%; height: 18em;">
																	<%if(docID != null){
                                                                                                                                                        //v2. 14.디렉토리 경로 조작(getParameter)_CWE-22/23 : 오탐
																			out.write(StringEscapeUtils.escapeHtml(docForm));
																		}
																	%>
																	</textarea></td>
									</tr>
								</table>
								</td>
							</tr>
						</table>
						<br>

						<table align="center" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td><a href="#"
									onclick="javascript:docFormContentModify();"
									onMouseOut="MM_swapImgRestore()"
									onMouseOver="MM_swapImage('bt_enter1','','images/bt_enter.gif',1)"><img
									src="images/bt_enter.gif" name="bt_enter1" border="0"
									id="bt_enter1"></a></td>
								<td>&nbsp;</td>
								<td><a href="#" onclick="javascript:window.close();"
									onMouseOut="MM_swapImgRestore()"
									onMouseOver="MM_swapImage('bt_cancel3','','images/bt_cancel3.gif',1)"><img
									src="images/bt_cancel3.gif" name="bt_cancel3" border="0"></a></td>
							</tr>
						</table>
						</td>
					</tr>
				</table>
				</td>
			</tr>
			<!-----  내용 들어갈 부분  끝 ---->
		</table>
		</td>
		<td rowspan="2" background="images/popupt_center_right.gif">&nbsp;</td>
	</tr>
	<tr>
		<td height="1" align="center"></td>
	</tr>
	<tr>
		<td><img src="images/popupt_bottom_left.gif" width="29"
			height="24"></td>
		<td background="images/popupt_bottom_center.gif" height="24">&nbsp;</td>
		<td><img src="images/popupt_bottom_right.gif" width="30"
			height="24"></td>
	</tr>
</table>
<form name="docFormCM"
	action="/servlet/kr.co.kihyun.beans.totsys.doc.HttpFormContentModify"
	method="post"><input type="hidden" name="docFCM"> <input
	type="hidden" name="docID" value="<%= docID %>"></form>
</body>
</html>
<%
}catch(Exception ex){
        //38.오류메세지를 통한 정보 노출(getMessage)_CWE-209 : Update by YOUNGJUN,CHO
	//out.println(ex);
	ex.printStackTrace();
	//out.println("<html><body style='overflow=auto' bgcolor='white'><h1>Can't contact servlet runner</h1><br><br>Message : "+ex.getMessage()+"</body></html>");
	//out.println("<META HTTP-EQUIV='refresh' CONTENT='0.1; URL=/error/exception.jsp'>");
        //================================================
}finally{
    if(tx.isActive())
    tx.rollback();
	pm.close();
}
%>
