write.php 内容提交页面

作者:root
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<base href=<?php ECHO BASE_URL;?> />
<?php  echo $this->js;echo $this->css ?>
<!-- <script src="styles/default/template/js/oakeditor.js" charset="utf-8"></script> 
<script src="styles/default/template/js/framebox.js" charset="utf-8"></script> -->
</head>
<body>
    <div>
        <form id="form1" name="form1" method="post" action="" onsubmit="return data_check()">
        <p><input type="text" name="title" placeholder='标 题' style='width:100%;' /></p>
        <p><input type="text" name="keyword" value='关键字' style='width:100%;' /></p>
        <input name="id" type="hidden" value="<?php echo $this->id;?>" />
        <input name="pid" type="hidden" value="<?php echo $this->pid;?>" />
        <textarea  rows="20" cols ="60" id="editor" name="body"></textarea>
         <p><input type="submit" name="Submit" value="提交" /></p>
        </form>
    </div>
 	<div id =output></div>
<script>
window.onload=function(){
/* 配置富文本编辑器 */
oakedit=new oak.editor({
	csspath:'<?php echo $this->path.'css/'?>',
	toolbar:[['source'],['bold','italic','|','textcolor','bgcolor','RemoveFormat'],['textsize'],['insertunorderedlist','insertorderedlist',
    'indent','outdent','justifyleft','justifycenter','justifyright'],['createimg','createlink','unlink','table','InsertHorizontalRule','undo','redo'],['code']],
	height:'250px',
	id:document.form1.id.value,
	pid:document.form1.pid.value
});
/* 安装插件 */
srchtml = '<?php echo $this->path.'js/'?>'+'upfile.html';
oakedit.plug(oak.ExecCommand);
oakedit.plug(frameBox,{width:'600px',height:'500px',src:srchtml,css:'sam'});
oakedit.render('#editor');
/* 跟随iframe变化,改变编辑区高度 */
document.addEventListener('reSize',function(e){oakedit.editnode.style.minHeight = oakedit.editnode.offsetHeight+e.reHeight+'px';});
};
/* 给父窗口发送信息,含提交的数据 */
function data_check(e){
    var a={},n = document.form1.querySelectorAll('input,textarea');
	a.user="<?php echo $this->auth->session['username']; ?>";
    for(i=0;i< n.length;i++){
        if(n[i].value.length < 1) return false;
	    a[n[i].getAttribute('name')]=n[i].value;
	    a['type']='submit';
	}
	if(window.parent){
		window.parent.postMessage(JSON.stringify(a),"*");
	}
}
/* 给父窗口发信息,让其设置框架标题 */
window.parent.postMessage(JSON.stringify({'id':document.form1.id.value,'type':'onload'}),"*");
/* 删除上传的无用文件及目录 */
window.addEventListener('unload',function(e){
    var form1data = new FormData(document.form1);
    form1data.append('file_check','1');
    var ajaxInit = {
	        method: "POST",
  			credentials: "include",	
  			body: form1data,
    };
    setTimeout(fetch(document.URL,ajaxInit),200);
});
</script>
</body>
</html>