<?php /* Smarty version 2.6.19, created on 2008-09-22 21:18:19
         compiled from article/edit.phtml */ ?>
<!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="<?php echo $this->_tpl_vars['baseUrl']; ?>
/public/styles/layout.css" />
<script type="text/javascript" language="Javascript" src="<?php echo $this->_tpl_vars['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','<?php echo $this->_tpl_vars['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('<?php echo $this->_tpl_vars['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('<?php echo $this->_tpl_vars['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("<?php echo $this->_tpl_vars['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="<?php echo $this->_tpl_vars['baseUrl']; ?>
/admin/index/" title="后台首页">后台首页</a> &gt; 编辑日志</p>
</div>
<div class="table-div">
<?php unset($this->_sections['ArticleList']);
$this->_sections['ArticleList']['name'] = 'ArticleList';
$this->_sections['ArticleList']['loop'] = is_array($_loop=$this->_tpl_vars['Articleone']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
$this->_sections['ArticleList']['show'] = true;
$this->_sections['ArticleList']['max'] = $this->_sections['ArticleList']['loop'];
$this->_sections['ArticleList']['step'] = 1;
$this->_sections['ArticleList']['start'] = $this->_sections['ArticleList']['step'] > 0 ? 0 : $this->_sections['ArticleList']['loop']-1;
if ($this->_sections['ArticleList']['show']) {
    $this->_sections['ArticleList']['total'] = $this->_sections['ArticleList']['loop'];
    if ($this->_sections['ArticleList']['total'] == 0)
        $this->_sections['ArticleList']['show'] = false;
} else
    $this->_sections['ArticleList']['total'] = 0;
if ($this->_sections['ArticleList']['show']):

            for ($this->_sections['ArticleList']['index'] = $this->_sections['ArticleList']['start'], $this->_sections['ArticleList']['iteration'] = 1;
                 $this->_sections['ArticleList']['iteration'] <= $this->_sections['ArticleList']['total'];
                 $this->_sections['ArticleList']['index'] += $this->_sections['ArticleList']['step'], $this->_sections['ArticleList']['iteration']++):
$this->_sections['ArticleList']['rownum'] = $this->_sections['ArticleList']['iteration'];
$this->_sections['ArticleList']['index_prev'] = $this->_sections['ArticleList']['index'] - $this->_sections['ArticleList']['step'];
$this->_sections['ArticleList']['index_next'] = $this->_sections['ArticleList']['index'] + $this->_sections['ArticleList']['step'];
$this->_sections['ArticleList']['first']      = ($this->_sections['ArticleList']['iteration'] == 1);
$this->_sections['ArticleList']['last']       = ($this->_sections['ArticleList']['iteration'] == $this->_sections['ArticleList']['total']);
?>

    <form method="post" enctype="multipart/form-data" id="uploadform" action="<?php echo $this->_tpl_vars['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="<?php echo $this->_tpl_vars['Articleone'][$this->_sections['ArticleList']['index']]['title']; ?>
"  size="80"/> <span class="error">*</span></td>
	  </tr>
	  <tr>
	    <th>日志作者</th>
		<td><input type="text" name="author" id="author" value="<?php echo $this->_tpl_vars['Articleone'][$this->_sections['ArticleList']['index']]['author']; ?>
" size="80"/> <span class="error">*</span></td>
	  </tr>
	 
	  <tr>
	    <th>日志分类</th>
		<td><?php echo $this->_tpl_vars['fenleiString']; ?>
</td>
		<input name="sunid" id="sunid" value="<?php echo $this->_tpl_vars['sunid']; ?>
" type="hidden">
	  </tr>
	  <tr>
	    <th>是否发布</th>
		<td><select name="show">
		<?php if ($this->_tpl_vars['Articleone'][$this->_sections['ArticleList']['index']]['show'] == '1'): ?><?php endif; ?>
		<option value="1"  <?php if ($this->_tpl_vars['Articleone'][$this->_sections['ArticleList']['index']]['show'] == '1'): ?> selected="selected" <?php endif; ?> >已发布</option>
		<option value="0"  <?php if ($this->_tpl_vars['Articleone'][$this->_sections['ArticleList']['index']]['show'] == '0'): ?> selected="selected" <?php endif; ?> >未发布</option>
		<option value="2"  <?php if ($this->_tpl_vars['Articleone'][$this->_sections['ArticleList']['index']]['show'] == '2'): ?> selected="selected" <?php endif; ?>>已锁定</option>
		</select></td>
	  </tr>
	   <tr>
	    <th>日志内容</th>
		<td><?php echo $this->_tpl_vars['oFCKeditor']->create(); ?>
</td>
	  </tr>
	 
	   
		<tr>
		
		 <th>已存在文件</th>  
		<td><p id="attachment">
		<?php unset($this->_sections['attachlist']);
$this->_sections['attachlist']['name'] = 'attachlist';
$this->_sections['attachlist']['loop'] = is_array($_loop=$this->_tpl_vars['attachs']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
$this->_sections['attachlist']['show'] = true;
$this->_sections['attachlist']['max'] = $this->_sections['attachlist']['loop'];
$this->_sections['attachlist']['step'] = 1;
$this->_sections['attachlist']['start'] = $this->_sections['attachlist']['step'] > 0 ? 0 : $this->_sections['attachlist']['loop']-1;
if ($this->_sections['attachlist']['show']) {
    $this->_sections['attachlist']['total'] = $this->_sections['attachlist']['loop'];
    if ($this->_sections['attachlist']['total'] == 0)
        $this->_sections['attachlist']['show'] = false;
} else
    $this->_sections['attachlist']['total'] = 0;
if ($this->_sections['attachlist']['show']):

            for ($this->_sections['attachlist']['index'] = $this->_sections['attachlist']['start'], $this->_sections['attachlist']['iteration'] = 1;
                 $this->_sections['attachlist']['iteration'] <= $this->_sections['attachlist']['total'];
                 $this->_sections['attachlist']['index'] += $this->_sections['attachlist']['step'], $this->_sections['attachlist']['iteration']++):
$this->_sections['attachlist']['rownum'] = $this->_sections['attachlist']['iteration'];
$this->_sections['attachlist']['index_prev'] = $this->_sections['attachlist']['index'] - $this->_sections['attachlist']['step'];
$this->_sections['attachlist']['index_next'] = $this->_sections['attachlist']['index'] + $this->_sections['attachlist']['step'];
$this->_sections['attachlist']['first']      = ($this->_sections['attachlist']['iteration'] == 1);
$this->_sections['attachlist']['last']       = ($this->_sections['attachlist']['iteration'] == $this->_sections['attachlist']['total']);
?><img width="100px" height="20px" src="<?php echo $this->_tpl_vars['attachs'][$this->_sections['attachlist']['index']]['url']; ?>
" /> &nbsp;&nbsp;&nbsp;&nbsp; 
    文件说明:<?php echo $this->_tpl_vars['attachs'][$this->_sections['attachlist']['index']]['attachdesc']; ?>
&nbsp;&nbsp;&nbsp;&nbsp; <a onclick="return InserImg('<?php echo $this->_tpl_vars['attachs'][$this->_sections['attachlist']['index']]['url']; ?>
');"  href="#" >插入</a>&nbsp;&nbsp;&nbsp;&nbsp; 
     <a onclick="return delAttachment('<?php echo $this->_tpl_vars['attachs'][$this->_sections['attachlist']['index']]['id']; ?>
','<?php echo $this->_tpl_vars['attachs'][$this->_sections['attachlist']['index']]['imgname']; ?>
','<?php echo $this->_tpl_vars['attachs'][$this->_sections['attachlist']['index']]['typeid']; ?>
');" href="#">删除</a>
     <br/><?php endfor; endif; ?></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="<?php unset($this->_sections['tags']);
$this->_sections['tags']['name'] = 'tags';
$this->_sections['tags']['loop'] = is_array($_loop=$this->_tpl_vars['tagString']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
$this->_sections['tags']['show'] = true;
$this->_sections['tags']['max'] = $this->_sections['tags']['loop'];
$this->_sections['tags']['step'] = 1;
$this->_sections['tags']['start'] = $this->_sections['tags']['step'] > 0 ? 0 : $this->_sections['tags']['loop']-1;
if ($this->_sections['tags']['show']) {
    $this->_sections['tags']['total'] = $this->_sections['tags']['loop'];
    if ($this->_sections['tags']['total'] == 0)
        $this->_sections['tags']['show'] = false;
} else
    $this->_sections['tags']['total'] = 0;
if ($this->_sections['tags']['show']):

            for ($this->_sections['tags']['index'] = $this->_sections['tags']['start'], $this->_sections['tags']['iteration'] = 1;
                 $this->_sections['tags']['iteration'] <= $this->_sections['tags']['total'];
                 $this->_sections['tags']['index'] += $this->_sections['tags']['step'], $this->_sections['tags']['iteration']++):
$this->_sections['tags']['rownum'] = $this->_sections['tags']['iteration'];
$this->_sections['tags']['index_prev'] = $this->_sections['tags']['index'] - $this->_sections['tags']['step'];
$this->_sections['tags']['index_next'] = $this->_sections['tags']['index'] + $this->_sections['tags']['step'];
$this->_sections['tags']['first']      = ($this->_sections['tags']['iteration'] == 1);
$this->_sections['tags']['last']       = ($this->_sections['tags']['iteration'] == $this->_sections['tags']['total']);
?><?php echo $this->_tpl_vars['tagString'][$this->_sections['tags']['index']]['name']; ?>
,<?php endfor; endif; ?>" /> <span class="error">*</span></td>
	  </tr>
	    <tr>
	    <th>日志未来发布时间</th>
		<td><input type="text" name="showtime" size="80" value="<?php echo $this->_tpl_vars['Articleone'][$this->_sections['ArticleList']['index']]['showtime']; ?>
" /></td>
	  </tr>
	  <input type="hidden" name="id" size="80" value="<?php echo $this->_tpl_vars['Articleone'][$this->_sections['ArticleList']['index']]['id']; ?>
" />
	  <tr>
	    <th colspan="2"><input type="submit" value="编辑日志" class="cmd" /></th>
	  </tr>
	  </tbody>
	</table>
    </form>

<?php endfor; endif; ?>

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