<?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(){
	if($("#formtype").val()=='radio' || $("#formtype").val()=='select' || $("#formtype").val()=='checkbox')
	{
		$("#getoption").css({display:'block'});
	}else{
		$("#getoption").css({display:'none'});
	}
	if($("#formtype").val()=='editor')
	{
		$("#setwh").css({display:'block'});
	}else{
		$("#setwh").css({display:'none'});
	}});
	$(document).ready(function(){$("#preg").val('<?php echo $r['preg'];?>');$("#searchby").val('<?php echo $r['searchby'];?>');$("#searchbyvalue").val('<?php echo $r['searchbyvalue'];?>');$("#formtype").val('<?php echo $r['formtype'];?>')});
</script>
</head>
<body>
<div id="wrap">
	<div class="tab">
		<ul>
			<li><a href="?file=model&action=manage_fields&modelid=<?php echo $r['modelid'];?>">字段管理</a></li>
			<li><a href="javascript:void(0);" class="on">修改字段</a></li>			
		</ul>
	</div>
	<div class="main">
	<fieldset>
		<legend>操作提示</legend>
		1：更多使用说明可参阅 <a href="http://doc.dircms.net/" target="_blank">http://doc.dircms.net/</a>。
	</fieldset>
	<form action="" method="post" name="myform">
	<input type="hidden" name="info[formtype]" value="<?php echo $r['formtype'];?>" id="formtype" />
	<input type="hidden" name="info[modelid]" value="<?php echo $r['modelid'];?>" />
	<input type="hidden" name="do_submit" value="1" />
	<table cellspacing="0" class="sub">
		<tr>
			<td width="200" align="right">字段类型：</td>
			<td>
			<?php echo $r['formtype'];?>
			<span style="display:none" id="setwh">
			宽： <input  type="text" name="info[editorwidth]" size="6" value="<?php echo $r['editorwidth'];?>" class="inputtitle"  /> px 高： <input type="text" name="info[editorheight]"  value="<?php echo $r['editorheight'];?>" size="6" class="inputtitle"/> px
			</span>
			</td>
		</tr>
		<tr>
			<td width="200" align="right">字段别名：</td>
			<td>
			<input type="text" name="info[fieldname]" size="12" value="<?php echo $r['fieldname'];?>" datatype="limit" min="2" max="100" />
			</td>
		</tr>
		<tr>
			<td width="200" align="right">字 段 名：</td>
			<td>
			<input type="text" name="info[name]" size="18" readonly="1" value="<?php echo $r['name'];?>"  />
			</td>
		</tr>
		<tr>
			<td width="200" align="right">表单提示：</td>
			<td>
			<input type="text" name="info[tips]" size="26" value="<?php echo $r['tips'];?>" datatype="limit" min="0" max="100" />
			</td>
		</tr>
		<tr>
			<td width="200" align="right">计量单位：</td>
			<td>
			<input type="text" name="info[danwei]" value="<?php echo $r['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]" value="<?php echo $r['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"><?php echo $r['optionvalue'];?></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"><?php echo htmlspecialchars($r['js']);?></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]" value="<?php echo $r['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="<?php echo $r['minsize'];?>" size="12" />
				-
			<input type="text" name="info[maxsize]" id="maxsize" datatype="number" value="<?php echo $r['maxsize'];?>" size="12" />
			</td>
		</tr>
		<tr>
			<td width="200" align="right">访问权限配置：</td>
			<td>
			<?php if($membergroup)foreach($membergroup as $_membergroup){?>
				<input type="checkbox" class="checkbox" align="middle" name="privilege[]" value="<?php echo $_membergroup['id'];?>" <?php echo ($_membergroup['id']==1||in_array($_membergroup['id'],$privilege))?' checked="checked"':'';?> /> <?php echo $_membergroup['groupname'];?>&nbsp;
			<?php }?>
			</td>
		</tr>
		<tr>
			<td width="200" align="right">显示结果为图片：</td>
			<td>
			<input type="radio" name="info[createimage]" value="1" class="radio" <?php echo $r['createimage']?'checked="checked"':'';?> /> 启用  <input type="radio" name="info[createimage]" value="0" class="radio" <?php echo !$r['createimage']?'checked="checked"':'';?> /> 关闭
			<span>启用后可防止采集，可用于电话等字段</span>
			</td>
		</tr>
		<tr>
			<td width="200" align="right">作为基本信息：</td>
			<td>
			<input type="radio" name="info[isbase]" value="1" class="radio" <?php echo $r['isbase']?'checked="checked"':'';?> /> 启用  <input type="radio" name="info[isbase]" value="0" class="radio" <?php echo !$r['isbase']?'checked="checked"':'';?> /> 关闭
			</td>
		</tr>
		<?php if($r['formtype']!='title'){?>
		<tr>
			<td width="200" align="right">是否参与搜索：</td>
			<td>
			<input type="radio" name="info[issearch]" value="1" class="radio" <?php echo $r['issearch']?'checked="checked"':'';?> /> 启用  <input type="radio" name="info[issearch]" value="0" class="radio" <?php echo !$r['issearch']?'checked="checked"':'';?> /> 关闭
			</td>
		</tr>
		<tr>
			<td width="200" align="right">选择搜索条件：</td>
			<td>
			<select name="info[searchby]" id="searchby" onchange="searchbyy();">
				<option value="0">选择搜索条件</option>
				<option value="eq">等于(=)</option>
				<option value="lt">小于(&lt;)</option>
				<option value="le">小于等于(&lt;=)</option>
				<option value="gt">大于(&gt;)</option>
				<option value="ge">大于等于(&gt;=)</option>
				<option value="ltgt">两者之间(&lt;值&lt;)</option>
				<option value="like">like</option>
			</select>
			&nbsp;
			<span id="betweenvalue" style="display:none">
			在
			<input type="text"   name="searchbymin" datatype="english" value="<?php echo $searchbymin;?>" size="6" />
			
			与
			<input type="text"   name="searchbymax" datatype="english" value="<?php echo $searchbymax;?>" size="6" />
			之间 <span style="color:#FF3300"><img src="images/error.gif" /> 在此输入您在表单中定义的变量</span>
			</span>
			<span id="defualtvalue" style="display:none">
			<input type="text"   name="searchbyvalue" size="12" value="<?php echo $r['searchbyvalue']?>" />
			<span style="color:#FF3300"><img src="images/error.gif" /> 如果该字段参与了搜索,在此输入您在表单中定义的变量</span>
			</span>
			</td>
		</tr>
		<?php }?>
		<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=model&action=manage_fields&modelid=<?php echo $r['modelid'];?>'" value="取消返回" /></td></tr>
	</table>
	</form>

	</div>
</div>
</body>
</html>
<script language="javascript">
function searchbyy()
{
	if(document.getElementById('searchby').value=='ltgt')
	{
		document.getElementById('betweenvalue').style.display='';
		document.getElementById('defualtvalue').style.display='none';
	}
	else if(document.getElementById('searchby').value!=0)
	{
		document.getElementById('betweenvalue').style.display='none';
		document.getElementById('defualtvalue').style.display='';
	}
	else
	{
		document.getElementById('defualtvalue').style.display='none';
	}
}
$(document).ready(function()
{
	if(document.getElementById('searchby').value=='ltgt')
	{
		document.getElementById('betweenvalue').style.display='';
		document.getElementById('defualtvalue').style.display='none';
	}
	else if(document.getElementById('searchby').value!=0)
	{
		document.getElementById('betweenvalue').style.display='none';
		document.getElementById('defualtvalue').style.display='';
	}
	else
	{
		document.getElementById('defualtvalue').style.display='none';
	}
});
</script>