<?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,"tempvar");
$gid=(int)$_GET['gid'];
$gname=CheckTempGroup($gid);
$urlgname=$gname."&nbsp;->&nbsp;";
$enews=$_GET['enews'];
$cid=$_GET['cid'];
$r[myorder]=0;
$url=$urlgname."<a href=ListTempvar.php?gid=$gid>管理模板变量</a>&nbsp;->&nbsp;增加模板变量";
//修改
if($enews=="EditTempvar")
{
	$varid=(int)$_GET['varid'];
	$r=$empire->fetch1("select myvar,varname,varvalue,classid,isclose,myorder from ".GetDoTemptb("enewstempvar",$gid)." where varid='$varid'");
	$r[varvalue]=htmlspecialchars(stripSlashes($r[varvalue]));
	$url=$urlgname."<a href=ListTempvar.php?gid=$gid>管理模板变量</a>&nbsp;->&nbsp;修改模板变量：".$r[myvar];
}
//分类
$cstr="";
$csql=$empire->query("select classid,classname from {$dbtbpre}enewstempvarclass order by classid");
while($cr=$empire->fetch($csql))
{
	$select="";
	if($cr[classid]==$r[classid])
	{
		$select=" selected";
	}
	$cstr.="<option value='".$cr[classid]."'".$select.">".$cr[classname]."</option>";
}
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="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr>
    <td height="25">位置：<?=$url?></td>
  </tr>
</table>

<form name="form1" method="post" action="ListTempvar.php">
  <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
    <tr class="header"> 
      <td height="25" colspan="2">增加模板变量 
        <input name="enews" type="hidden" id="enews" value="<?=$enews?>"> <input name="add[varid]" type="hidden" id="add[varid]" value="<?=$varid?>"> 
        <input name="add[cid]" type="hidden" id="add[cid]" value="<?=$cid?>">
        <input name="add[gid]" type="hidden" id="add[gid]" value="<?=$gid?>"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="19%" height="25">变量名</td>
      <td width="81%" height="25">[!--temp. 
        <input name="add[myvar]" type="text" id="add[myvar]" value="<?=$r[myvar]?>" size="16">
        --] <font color="#666666">(如：ecms，变量就是[!--temp.ecms--])</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">所属类别</td>
      <td height="25"><select name="add[classid]" id="add[classid]">
          <option value="0">不隶属于任何类别</option>
          <?=$cstr?>
        </select>
        <input type="button" name="Submit6222322" value="管理分类" onclick="window.open('TempvarClass.php');"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">变量标识</td>
      <td height="25"><input name="add[varname]" type="text" id="add[varname]" value="<?=$r[varname]?>">
        <font color="#666666">(如：帝国CMS)</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">是否开启变量</td>
      <td height="25"><input type="radio" name="add[isclose]" value="0"<?=$r[isclose]==0?' checked':''?>>
        是 
        <input type="radio" name="add[isclose]" value="1"<?=$r[isclose]==1?' checked':''?>>
        否<font color="#666666">（开启才会在模板中生效）</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">变量值</td>
      <td height="25"><textarea name="add[varvalue]" cols="90" rows="18" id="add[varvalue]"><?=$r[varvalue]?></textarea></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td height="25">变量排序</td>
      <td height="25"><input name="add[myorder]" type="text" id="add[myorder]" value="<?=$r[myorder]?>" size="6">
        <font color="#666666">(值越大等级越高，可以嵌入更低等级的变量)</font></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>
