<?php
	!defined('DIRCMS_MANAGE') && exit('Access Denied!');
?>
<!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>
<title>添加字段</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<link rel="stylesheet" type="text/css" href="admin/template/css/style.css" />
<script type="text/javascript" src="images/js/jquery.min.js"></script>
<script src="images/js/check.func.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){checkForm(0);});
$(document).ready(function(){$("#formtype").change(function(){
	if($("#formtype").val()=='radio' || $("#formtype").val()=='select' || $("#formtype").val()=='checkbox')
	{
		$("#getoption").css({display:''});
	}else{
		$("#getoption").css({display:'none'});
	}
	if($("#formtype").val()=='editor')
	{
		$("#setwh").css({display:''});
	}else{
		$("#setwh").css({display:'none'});
	}});
});
</script>
</head>
<body>
<div id="wrap">
	<div class="tab">
		<ul>
			<li><a href="?file=membermodel&action=manage_fields&modelid=<?php echo $modelid;?>">字段管理</a></li>
			<li><a href="javascript:void(0);" class="on">添加字段</a></li>			
		</ul>
	</div>
	<div class="main">
	<fieldset>
		<legend>操作提示</legend>
		1：字段类型添加后不可修改； 2：字段名应由2-30个英文，数字，下划线组成，且不能重复，不可更改 ；3：更多使用说明可参阅 <a href="http://doc.dircms.net/" target="_blank">http://doc.dircms.net/</a>。
	</fieldset>
	<form action="" method="post" name="myform">
	<input type="hidden" name="do_submit" value="1" />
	<input type="hidden" name="info[modelid]" value="<?php echo $modelid;?>" />
	<table cellspacing="0" class="sub">
		<tr>
			<td width="200" align="right">字段类型：</td>
			<td>
			<select name="info[formtype]" id="formtype">
				<option value="text" selected="selected">单行文本</option>
				<option value="password">密码框</option>
				<option value="textarea">多行文本</option>
				<option value="radio">单选按钮</option>
				<option value="checkbox">多选按钮</option>
				<option value="select">下拉框</option>
				<option value="editor">编辑器</option>
				<option value="style">颜色和字型</option>
				<option value="image">单图片上传</option>
				<option value="images">多图片上传</option>
				<option value="file">文件上传</option>
				<option value="_date">日期时间</option>
				<option value="copyfrom">来源</option>
				<option value="author">作者</option>	
				<option value="map">地图</option>
				<option value="vote">在线投票</option>	
				<option value="downurl">下载地址</option>
				<option value="videourl">视频地址</option>		
			</select>
			<span style="display:none" id="setwh">
			宽： <input type="text" name="info[editorwidth]" class="inputtitle" size="8" value="650" datatype="number" /> px 
			高： <input type="text" name="info[editorheight]" class="inputtitle" value="250" size="8" datatype="number"  /> px
			</span>
			</td>
		</tr>
		<tr>
			<td width="200" align="right">字段别名：</td>
			<td>
			<input type="text" name="info[fieldname]" size="12" datatype="limit" min="2" max="100" />
			</td>
		</tr>
		<tr>
			<td width="200" align="right">字 段 名：</td>
			<td>
			<input type="text" name="info[name]" size="18" id="table_name" datatype="table" onblur="$.get('?file=membermodel&action=chkfields&modelid=<?php echo $modelid;?>',{data:this.value},function(data){if(data=='yes'){alert('该字段名已经存在，请更换!');$('#table_name').val('');$('#table_name').focus();}});"  />
			</td>
		</tr>
		<tr>
			<td width="200" align="right">表单提示：</td>
			<td>
			<input type="text" name="info[tips]" size="26" datatype="limit" min="0" max="100" />
			</td>
		</tr>
		<tr>
			<td width="200" align="right">计量单位：</td>
			<td>
			<input type="text" name="info[danwei]" datatype="limit" min="0" max="100"  size="12" />
			<span>如：个，元，吨等，没有请留空</span>
			</td>
		</tr>
		<tr>
			<td width="200" align="right">默 认 值：</td>
			<td>
			<input type="text" name="info[defaultvalue]" datatype="limit" min="0" max="200" size="55" /> <span>多个默认值用 / 隔开</span>
			</td>
		</tr>
		<tr style="display:none" id="getoption">
			<td width="200" align="right">选项列表：</td>
			<td>
			<textarea name="info[optionvalue]" cols="50" rows="8">选项名称1|选项值1<?php echo "\n";?>选项名称2|选项值2</textarea>
			</td>
		</tr>
		<tr>
			<td width="200" align="right">附加属性：</td>
			<td>
			<textarea name="info[js]" datatype="limit" min="0" max="255" cols="50" rows="8"></textarea>
			</td>
		</tr>
		<tr>
			<td width="200" align="right">数据校验：</td>
			<td>
			<select name="info[preg]" id="preg" onchange="javascript:authwh(this);">
				<option value="">不进行校验</option>
				<option value="limit">常用正则</option>
				<option value="limit3_50">3-50个字符</option>
				<option value="userName">用户名</option>
				<option value="usePsw">用户密码</option>
				<option value="number">数字</option>
				<option value="integer">整数</option>
				<option value="english">字母</option>
				<option value="chinese">中文</option>
				<option value="email">E-mail</option>
				<option value="qq">QQ</option>
				<option value="url">超级链接</option>
				<option value="mobile">手机号码</option>
				<option value="phone">电话号码</option>
				<option value="ip">IP地址</option>	
				<option value="map">地图</option>		
			</select>
			<script language="javascript" type="text/javascript">
			function authwh(obj)
			{
				switch(obj.value)
				{
					case 'limit3_50':
						$("#minsize").val(3);
						$("#maxsize").val(50);
						break;
					case 'userName':
						$("#minsize").val(3);
						$("#maxsize").val(30);
						break;
					case 'usePsw':
						$("#minsize").val(3);
						$("#maxsize").val(30);
						break;
					case 'email':
						$("#minsize").val(3);
						$("#maxsize").val(80);
						break;
					case 'qq':
						$("#minsize").val(3);
						$("#maxsize").val(15);
						break;
					case 'mobile':
						$("#minsize").val(10);
						$("#maxsize").val(15);
						break;
					case 'phone':
						$("#minsize").val(3);
						$("#maxsize").val(50);
						break;
					case 'ip':
						$("#minsize").val(12);
						$("#maxsize").val(15);
						break;	
					default:
						$("#minsize").val(0);
						$("#maxsize").val(255);
						break;						
				}
			}
			</script>
			</td>
		</tr>
		<tr>
			<td width="200" align="right">Css样式名：</td>
			<td>
			<input type="text" name="info[css]" datatype="limit" min="0" max="100" size="18"/>
			<span>如：class="样式名"，则输入：样式名</span>
			</td>
		</tr>
		<tr>
			<td width="200" align="right">字符个数取值范围：</td>
			<td>
			<input type="text" name="info[minsize]" id="minsize" datatype="number" value="0" size="12" />
				-
			<input type="text" name="info[maxsize]" id="maxsize" datatype="number" value="255" size="12" />
			</td>
		</tr>
		<tr>
			<td width="200" align="right">作为基本信息：</td>
			<td>
			<input type="radio" name="info[isbase]" value="1" class="radio" checked="checked" /> 启用  <input type="radio" name="info[isbase]" value="0" class="radio" /> 关闭
			</td>
		</tr>
		<tr class="bg2"><td></td><td><input type="button" class="button" onclick="doSubmit(this);" value="保存字段" /> <input type="button" class="button" onclick="window.location.href='<?php echo ADMIN_FILE;?>?file=membermodel&action=manage_fields&modelid=<?php echo $modelid;?>'" value="取消返回" /></td></tr>
	</table>
	</form>

	</div>
</div>
</body>
</html>