<?php $this->display('header'); ?>

<script src="<?php echo IMG_URL?>js/lib/jquery.uploadify.js" type="text/javascript"></script>
<script src="<?php echo IMG_URL?>js/lib/cmstop.filemanager.js" type="text/javascript"></script>
<script src="<?php echo ADMIN_URL?>tiny_mce/tiny_mce.js" type="text/javascript"></script>
<script src="<?php echo ADMIN_URL?>tiny_mce/editor.js" type="text/javascript"></script>

<script type="text/javascript" src="apps/section/js/data.js"></script>

<style type="text/css">
body {
	padding-left: 6px;
}
#published {
	color:#444444;
	line-height:20px;
	margin:0 10px;
}
</style>
<table width="98%" cellspacing="0" cellpadding="0" border="0" class="table_form">
	<tbody>
		<tr>
			<td><textarea name="data" id="data" wrap="off"><?=$data?></textarea></td>
		</tr>
		<tr>
			<td>
				<input type="submit" class="button_style_2 publish" value="发布"/>
				<span id="published">
				<?php if($published):?>
				最后发布：<?=date('Y年n月j日 G:i',$published)?>
				<?php else:?>
				未发布
				<?php endif;?>
				</span>
			</td>
		</tr>
	</tbody>
</table>

<script type="text/javascript">
var sectionid = "<?=$sectionid?>";
$(function (){
	$('input.publish').click(function (){
		var content = tinyMCE.activeEditor.getContent();
		$.post('?app=section&controller=data&action=saveData&sectionid='+sectionid, {content: content}, function (rs){
			if(rs.state) {
				ct.tips('保存并发布成功');
				$('#published').text('最后发布：'+rs.message);
			}else{
				ct.error(rs.error);
			}
		}, 'json');
	});
});

$('#data').editor('section',{width:ct.innerWidth() - 20,height:ct.innerHeight() - 50,forced_root_block : ''});
</script>
