<table width="100%" class="topmenu">
	<tr><td>
		<a href="blocks.php"><em>自定义区块</em></a><span>|</span>
		<a href="block_file.php" class="on"><em>文件区块</em></a><span>|</span>
		<a href="block_sql.php"><em>SQL区块</em></a>
	</td></tr>
</table>
<table class="sgrid" width="100%" align="center">
	<tr>
		<td class="odd">
			区块调用：<span class="blue">&#123;?block classname="BlockArticleList" filename="block_artilelist" vars="vars" template="template.html"?}</span><br>
			灵动标签：<br><span class="blue">&#123;?eloop name="i" loop="$items" classname="BlockArticleList" filename="block_artilelist" vars="vars"?}<br>...<br>HTML代码<br>...<br>&#123;?/eloop?}</span><br>
			参数说明：<span class="red">classname</span> - 区块类名， <span class="red">filename</span> - 区块处理文件名称，不含后缀， <span class="red">vars</span> - 区块参数，英文,分割， <span class="red">template</span> - 区块的模板文件名， <span class="red">name</span> - 循环中间变量名， <span class="red">loop</span> - 实际内容数组变量
		</td>
  </tr>
</table><br />
<table class="grid" width="100%" align="center">
	<tr>
		<th width="60"></th>
		<th>区块文件</th>
		<th>区块说明</th>
	</tr>
	{?section name=i loop=$blocks?}
	<tr class="rowbg">
		<td align="center"><input type="radio" name="file" value="{?$blocks[i].filename?}"></td>
		<td>{?$blocks[i].filename?}</td>
		<td><div class="show_single" onclick="swapshow(this)">{?$blocks[i].intro?}</div></td>
	</tr>
	{?/section?}
	<tr><th></th><th colspan="2">区块测试和模版调用</th></tr>
	<tr><td></td><td colspan="2">1. 从上面选择一个区块文件</td></tr>
	<tr><td></td><td colspan="2">2. 输入区块参数：<input class="text" type="text" size="60" value='' id="vars"></td></tr>
	<tr><td></td><td colspan="2">3. 输入模版文件：<input class="text" type="text" size="30" value='' id="template"></td></tr>
	<tr><td></td><td colspan="2"><span class="gray">模版文件夹：{?$Saxue.saxue_theme_path?}/blocks/</span></td></tr>
	<tr><td></td><td colspan="2"><input type="button" class="button" value=" 生成 " id="test"></td></tr>
</table>
<table class="grid" width="100%" align="center" id="test">
	<tr>
		<th width="60"></th>
		<th>区块调用</th>
		<th>灵动标签调用</th>
	</tr>
	<tr>
		<td>调用代码</td>
		<td><textarea class="textarea" id="block_temp" rows="5" cols="60" onFocus="this.select()"></textarea></td>
		<td><textarea class="textarea" id="eloop_temp" rows="5" cols="60" onFocus="this.select()"></textarea></td>
	</tr>
	<tr>
		<td>测试数据</td>
		<td><textarea class="textarea" id="block_data" rows="10" cols="60"></textarea></td>
		<td><textarea class="textarea" id="eloop_data" rows="10" cols="60"></textarea></td>
	</tr>
</table>
<br /><br />
<style>.show_single{height:22px;line-height:22px;overflow:hidden;cursor:help}.show_all{max-width:100%;cursor:pointer}</style>
<script type="text/javascript">
function swapshow(obj){
	if (obj.className=='show_single') {
		obj.className='show_all';
	} else {
		obj.className='show_single';
	}
}
$(function(){
	$("#test").click(function() {
		var file=$('input:radio[name="file"]:checked').val();
		if(file==null){
			alert("请选择一个区块文件");
			return false;
		}
		var vars=$('#vars').val();
		if(vars==''){
			alert("请输入区块参数");
			return false;
		}
		var template=$('#template').val();
		$.post("block_file.php", { "dosubmit":'1', "filename":file, "vars":vars, "template":template }, function(data){
			$('#block_temp').val(data.block_temp);
			$('#block_data').val(data.block_data);
			$('#eloop_temp').val(data.eloop_temp);
			$('#eloop_data').val(data.eloop_data);
		}, "json")
	})
})
</script>