<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>OOPHP博客系统</title>
	<link rel="stylesheet" type="text/css" media="screen" href="<{$baseUrl}>/public/styles/layout.css" />
<script type="text/javascript" language="Javascript" src="<{$baseUrl}>/public/scripts/jquery.js"></script>
<script language="javascript" type="text/javascript">
//上傳的JS代碼
function uploadImg(id,fileid,formid){
	var formids=formid;
	var formid="#"+formid;
	
	var filepath=$('#uploadfile').val();
	  	if((filepath.indexOf("."))!==-1)  
	  	{		var get=filepath.lastIndexOf(".")+1;  
	         	var filetype=filepath.substring(get,filepath.length); 
	         	var filetype=filetype.toLowerCase();
	  	}
	  	var allow="jpg,gif,bmp,jpeg,png";
		var result=allow.indexOf(filetype);
		
	if(result>=0){
		 oldTarget=$(formid).attr('target');
		 oldAction=$(formid).attr('action');
		 oldOnsubmit=$(formid).attr('onsubmit');
		 $(formid).attr('target','uploadImgFrame');
		 $(formid).attr('action','<{$baseUrl}>/admin/article/upload/fileid/'+fileid);
		 $(formid).attr('onsubmit','');
		
		 $(formid).submit();
		 $(formid).attr('target',oldTarget);
		 $(formid).attr('action',oldAction);
		 $(formid).attr('onsubmit',oldOnsubmit);
		var ids="#fileupload"+id;
		var id=parseFloat(id);
		var cid=id+1;
		var changeid="fileupload"+cid;
		var filed="<p id="+changeid+"><input type=\"file\"  name=\"uploadfile[]\" size=\"30\" id=\"uploadfile\" />图片说明:<input name=\"attachintro[]\" size=\"50\" type=\"text\"><input type=\"button\" name=\"Submit"+cid+"\"  onclick=\"uploadImg('"+cid+"','"+changeid+"','"+formids+"');\" value=\"上传\" /></p>";
		$(ids).after(filed);

	  }else{
		 	alert("对不起,您选择的上传文件不是有效的图片文件！");
		 	return false;
	  }
}

//fck插入图片函数
function InserImg(url){
	var oEditor = FCKeditorAPI.GetInstance('FCKcontent');
	oEditor.InsertHtml("<img src='"+url+"'>");
}


function delAttachment(id,imgname,typeid){
	if(confirm("確定要刪除嗎?")){
	//alert(id);	
	$.post('<{$baseUrl}>/admin/article/delattach/',{'id':id,'imgname':imgname,'typeid':typeid}, function(data) {
	$("#attachment").empty();
	//alert(data);
	$("#attachment").html(data);
	});
	}	
	else{
		return false;	
	}
}

function delImages(filed,url){
	if(confirm("確定要刪除嗎?")){
	//alert(id);	
	var filed="#"+filed;
	$.post('<{$baseUrl}>/admin/article/delimage/',{'url':url}, function(data) {
		$(filed).empty();
	});
	}	
	else{
		return false;	
	}
	
}
function ChangeClass(id){
	var fid="#class"+id;
	var inner="#inner"+id;
	var pid=$(fid).val();
	if(pid!='noid'){
	$.post("<{$baseUrl}>/admin/class/ajax/",{id:pid},
  	function(data){
  		//alert(data);
  		var  strArray=new   Array();   
		strArray=data.split("||||");
		$("#sunid").val(strArray[0]);
    	$(inner).empty();
		$(inner).html(strArray[1]); 
  	})
  }else{
  	$(inner).empty();
  }	
}
	</script>
	</head>

<body>
<div id="navbar">
    <p>你的位置: <a href="<{$baseUrl}>/admin/index/" title="后台首页">后台首页</a> &gt; 编辑日志</p>
</div>
<div class="table-div">
<{section name=ArticleList  loop=$Articleone}>

    <form method="post" enctype="multipart/form-data" id="uploadform" action="<{$baseUrl}>/admin/article/add/">
    <table>
	<thead>
	  <tr>
	    <th class="title" colspan="2">编辑日志</th>
	  </tr>
	</thead>	
	<tbody>
	  <tr>
	    <th style="width:15%;">日志标题</th>
		<td><input type="text" name="title" id="title"  value="<{$Articleone[ArticleList].title}>"  size="80"/> <span class="error">*</span></td>
	  </tr>
	  <tr>
	    <th>日志作者</th>
		<td><input type="text" name="author" id="author" value="<{$Articleone[ArticleList].author}>" size="80"/> <span class="error">*</span></td>
	  </tr>
	 
	  <tr>
	    <th>日志分类</th>
		<td><{$fenleiString}></td>
		<input name="sunid" id="sunid" value="<{$sunid}>" type="hidden">
	  </tr>
	  <tr>
	    <th>是否发布</th>
		<td><select name="show">
		<{if $Articleone[ArticleList].show=='1'}><{/if}>
		<option value="1"  <{if $Articleone[ArticleList].show=='1'}> selected="selected" <{/if}> >已发布</option>
		<option value="0"  <{if $Articleone[ArticleList].show=='0'}> selected="selected" <{/if}> >未发布</option>
		<option value="2"  <{if $Articleone[ArticleList].show=='2'}> selected="selected" <{/if}>>已锁定</option>
		</select></td>
	  </tr>
	   <tr>
	    <th>日志内容</th>
		<td><{$oFCKeditor->create()}></td>
	  </tr>
	 
	   
		<tr>
		
		 <th>已存在文件</th>  
		<td><p id="attachment">
		<{section name=attachlist  loop=$attachs}><img width="100px" height="20px" src="<{$attachs[attachlist].url}>" /> &nbsp;&nbsp;&nbsp;&nbsp; 
    文件说明:<{$attachs[attachlist].attachdesc}>&nbsp;&nbsp;&nbsp;&nbsp; <a onclick="return InserImg('<{$attachs[attachlist].url}>');"  href="#" >插入</a>&nbsp;&nbsp;&nbsp;&nbsp; 
     <a onclick="return delAttachment('<{$attachs[attachlist].id}>','<{$attachs[attachlist].imgname}>','<{$attachs[attachlist].typeid}>');" href="#">删除</a>
     <br/><{/section}></p>	
     </td>
	</tr>
	
	  <tr >
	    <th>日志图片</th>
		<td><p id="fileupload1">
		<input type="file" name="uploadfile[]" size="30" id="uploadfile"  />图片说明:<input name="attachintro[]" size="50" type="text"><input type="button" name="Submit"  onclick="uploadImg('1','fileupload1','uploadform');" value="上传" />
		</p></td>
	  </tr>
	 
	  <tr>
	    <th>标签</th>
		<td><input type="text" name="tag" size="80" value="<{section name=tags  loop=$tagString}><{$tagString[tags].name}>,<{/section}>" /> <span class="error">*</span></td>
	  </tr>
	    <tr>
	    <th>日志未来发布时间</th>
		<td><input type="text" name="showtime" size="80" value="<{$Articleone[ArticleList].showtime}>" /></td>
	  </tr>
	  <input type="hidden" name="id" size="80" value="<{$Articleone[ArticleList].id}>" />
	  <tr>
	    <th colspan="2"><input type="submit" value="编辑日志" class="cmd" /></th>
	  </tr>
	  </tbody>
	</table>
    </form>

<{/section}>

<iframe name="uploadImgFrame" width="0" height="0" frameborder="0" id="uploadImgFrame"></iframe>
</div>
</body>
</html>