<?php
require("../../class/connect.php");
include("../../class/db_sql.php");
include("../../class/config.php");
include("../../class/functions.php");
$link=db_connect();
$empire=new mysqlquery();
$logininid=getcvar('loginuserid');
$loginin=getcvar('loginusername');
$loginrnd=getcvar('loginrnd');
$loginlevel=getcvar('loginlevel');
$editor=1;
is_login($logininid,$loginin,$loginrnd);
//验证权限
CheckLevel($logininid,$loginin,$classid,"f");
$tid=(int)$_GET['tid'];
$tbname=RepPostVar($_GET['tbname']);
if(empty($tid)||empty($tbname))
{
	printerror("ErrorUrl","history.go(-1)");
}
$enews=$_GET['enews'];
$iscj1=" checked";
$r[tobr]=1;
$r[dohtml]=1;
$r[myorder]=0;
$url="数据表:[".$dbtbpre."ecms_".$tbname."]&nbsp;->&nbsp;<a href=ListF.php?tid=$tid&tbname=$tbname>字段管理</a>&nbsp;->&nbsp;新建字段";
//修改字段
if($enews=="EditF")
{
	$fid=(int)$_GET['fid'];
	$url="数据表:[".$dbtbpre."ecms_".$tbname."]&nbsp;->&nbsp;<a href=ListF.php?tid=$tid&tbname=$tbname>字段管理</a>&nbsp;->&nbsp;修改字段";
	$r=$empire->fetch1("select * from {$dbtbpre}enewsf where fid='$fid' and tid='$tid'");
	if(!$r[fid])
	{
		printerror("ErrorUrl","history.go(-1)");
	}
	$oftype="type".$r[ftype];
	$$oftype=" selected";
	$ofform="form".$r[fform];
	$$ofform=" selected";
	if($r[iscj])
	{
		$iscj1=" checked";
		$iscj0="";
	}
	else
	{
		$iscj1="";
		$iscj0=" checked";
	}
}
db_close();
$empire=null;
//风格
$loginadminstyleid=(int)getcvar('loginadminstyleid');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建字段</title>
<link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr>
    <td>位置：<?=$url?></td>
  </tr>
</table>
<form name="form1" method="post" action="../enews.php">
  <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
    <tr> 
      <td height="25" colspan="2" class="header">增加数据表( 
        <?=$dbtbpre?>
        ecms_ 
        <?=$tbname?>
        )字段 
        <input name="fid" type="hidden" id="fid" value="<?=$fid?>"> <input name="enews" type="hidden" id="enews" value="<?=$enews?>"> 
        <input name="oldfform" type="hidden" id="oldfform" value="<?=$r[fform]?>"> 
        <input name="oldf" type="hidden" id="oldf" value="<?=$r[f]?>"> <input name="tbname" type="hidden" id="tbname" value="<?=$tbname?>"> 
        <input name="tid" type="hidden" id="tid" value="<?=$tid?>"> <input name="oldfvalue" type="hidden" id="oldfvalue" value="<?=htmlspecialchars(stripSlashes($r[fvalue]))?>"> 
        <input name="oldiskey" type="hidden" id="oldiskey" value="<?=$r[iskey]?>"> 
        <input name="oldsavetxt" type="hidden" id="oldsavetxt" value="<?=$r[savetxt]?>"> 
        <input name="oldisonly" type="hidden" id="oldisonly" value="<?=$r[isonly]?>">
        <input name="oldlinkfieldval" type="hidden" id="oldlinkfieldval" value="<?=$r[linkfieldval]?>"> 
      </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="25%" height="25">字段名</td>
      <td width="75%" height="25"><input name="f" type="text" id="f" value="<?=$r[f]?>"> 
        <font color="#666666">(比如：&quot;title&quot;)</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">字段标识</td>
      <td height="25"><input name="fname" type="text" id="fname" value="<?=$r[fname]?>"> 
        <font color="#666666">(比如：&quot;标题&quot;)</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">字段属性</td>
      <td height="25"> 
        <input name="iskey" type="checkbox" value="1"<?=$r[iskey]==1?' checked':''?>>
        索引 
        <input name="isonly" type="checkbox" value="1"<?=$r[isonly]==1?' checked':''?>>
        唯一
        <input name="savetxt" type="checkbox" id="savetxt" value="1"<?=$r[savetxt]==1?' checked':''?>>
        内容存文本 <font color="#666666">(存文本对“newstext”字段有效)</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">字段类型</td>
      <td height="25"><select name="ftype" id="select">
          <option value="VARCHAR"<?=$typeVARCHAR?>>字符型0-255字节(VARCHAR)</option>
          <option value="TEXT"<?=$typeTEXT?>>小型字符型(TEXT)</option>
          <option value="MEDIUMTEXT"<?=$typeMEDIUMTEXT?>>中型字符型(MEDIUMTEXT)</option>
          <option value="LONGTEXT"<?=$typeLONGTEXT?>>大型字符型(LONGTEXT)</option>
          <option value="TINYINT"<?=$typeTINYINT?>>小数值型(TINYINT)</option>
          <option value="SMALLINT"<?=$typeSMALLINT?>>中数值型(SMALLINT)</option>
          <option value="INT"<?=$typeINT?>>大数值型(INT)</option>
          <option value="BIGINT"<?=$typeBIGINT?>>超大数值型(BIGINT)</option>
          <option value="FLOAT"<?=$typeFLOAT?>>数值浮点型(FLOAT)</option>
          <option value="DOUBLE"<?=$typeDOUBLE?>>数值双精度型(DOUBLE)</option>
        </select>
        字段长度 
        <input name="flen" type="text" id="flen" value="<?=$r[flen]?>" size="6"> 
      </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">输入表单显示元素</td>
      <td height="25"><select name="fform" id="fform">
          <option value="text"<?=$formtext?>>单行文本框(text)</option>
          <option value="password"<?=$formpassword?>>密码框(password)</option>
          <option value="select"<?=$formselect?>>下拉框(select)</option>
          <option value="radio"<?=$formradio?>>单选框(radio)</option>
          <option value="checkbox"<?=$formcheckbox?>>复选框(checkbox)</option>
          <option value="textarea"<?=$formtextarea?>>多行文本框(textarea)</option>
          <option value="img"<?=$formimg?>>图片(img)</option>
          <option value="flash"<?=$formflash?>>FLASH文件(flash)</option>
          <option value="file"<?=$formfile?>>文件(file)</option>
          <option value="date"<?=$formdate?>>日期(date)</option>
          <option value="color"<?=$formcolor?>>颜色(color)</option>
		  <option value="linkfield"<?=$formlinkfield?>>选择模型字段(linkfield)</option>
        </select> </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td rowspan="2" valign="top">初始值</td>
      <td height="25"> <textarea name="fvalue" cols="65" rows="8" id="fvalue"><?=htmlspecialchars(stripSlashes(str_replace("|","\r\n",$r[fvalue])))?></textarea></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25"><font color="#666666">(多个值用&quot;回车&quot;格开,对radio,select元素有效)</font></td>
    </tr>
	<tr bgcolor="#FFFFFF">
      <td height="25">选择模型字段设置</td>
      <td height="25"><input name="linkfieldval" type="text" id="linkfieldval" value="<?=$r[linkfieldval]?>">
        <input name="samedata" type="checkbox" id="samedata" value="1"<?=$r[samedata]==1?' checked':''?>>
        数据同步 <font color="#666666">(格式：表.字段，如：news.title)</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">前台显示设定</td>
      <td height="25"><input name="tobr" type="checkbox" id="tobr" value="1"<?=$r[tobr]==1?' checked':''?>>
        将回车替换成换行符, 
        <input name="dohtml" type="checkbox" id="dohtml" value="1"<?=$r[dohtml]==1?' checked':''?>>
        支持html代码</td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">显示顺序</td>
      <td height="25"><input name="myorder" type="text" id="myorder" value="<?=$r[myorder]?>" size="6"> 
        <font color="#666666">(数字越小越前面)</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" valign="top">输入表单替换html代码<br> <font color="#666666">(增加字段时请留空)</font></td>
      <td height="25"><textarea name="fhtml" cols="65" rows="10" id="fhtml"><?=htmlspecialchars(stripSlashes($r[fhtml]))?></textarea></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">是否采集项</td>
      <td height="25">是 
        <input name="iscj" type="radio" value="1"<?=$iscj1?>>
        否 
        <input name="iscj" type="radio" value="0"<?=$iscj0?>></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" valign="top">投稿表单替换html代码<br> <font color="#666666">(增加字段时请留空)</font></td>
      <td height="25"><textarea name="qfhtml" cols="65" rows="10" id="qfhtml"><?=htmlspecialchars(stripSlashes($r[qfhtml]))?></textarea></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" valign="top">注释：</td>
      <td height="25"><textarea name="fzs" cols="65" rows="10" id="fzs"><?=stripSlashes($r[fzs])?></textarea></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">&nbsp;</td>
      <td height="25"><input type="submit" name="Submit" value="提交"> <input type="reset" name="Submit2" value="重置"></td>
    </tr>
  </table>
</form>
</body>
</html>
