<?php
//增加书籍栏目
define('EmpireCMSAdmin','1');
require("../class/connect.php");
require("../class/db_sql.php");
require("../class/functions.php");
$link=db_connect();
$empire=new mysqlquery();
//验证用户
$lur=is_login();
$logininid=$lur['userid'];
$loginin=$lur['username'];
$loginrnd=$lur['rnd'];
$loginlevel=$lur['groupid'];
$loginadminstyleid=$lur['adminstyleid'];
//验证权限
CheckLevel($logininid,$loginin,$classid,"class");
$enews=$_GET['enews'];
if($_GET['from'])
{
	$listclasslink="ListPageClass.php";
}
else
{
	$listclasslink="ListClass.php";
}
$url="<a href=".$listclasslink.">栏目管理</a>&nbsp;>&nbsp;增加书籍栏目";
$zt="";
//初使化数据
$r[myorder]=0;
$r[lencord]=30;
$r['sametitle']=1;
$read="";
//复制栏目
$docopy=$_GET['docopy'];
if($docopy&&$enews=="AddClass")
{
	$copyclass=1;
}
$ecmsfirstpost=1;
$classid=(int)$_GET['classid'];
if($enews=='EditClass')
{
	$filepass=$classid;
}
else
{
	$filepass=ReturnTranFilepass();
}
//修改栏目
if($enews=="EditClass"||$copyclass)
{
	$ecmsfirstpost=0;
	if($copyclass)
	{
		$thisdo="复制";
	}
	else
	{
		$thisdo="修改";
	}
	$read="";
	$r=$empire->fetch1("select * from {$dbtbpre}enewsclass where classid='$classid'");
	$url="<a href=".$listclasslink.">管理栏目</a>&nbsp;>&nbsp;".$thisdo."栏目：".$r[classname];
	//栏目目录
	$mycr=GetPathname($r[classpath]);
	$pripath=$mycr[1];
	$classpath=$mycr[0];
	$read="";
	//复制栏目
	if($copyclass)
	{
		$r[classname].="(1)";
		$classpath.="1";
		$read="";
    }
}
//系统模型
$m_sql=$empire->query("select mid,mname,usemod from {$dbtbpre}enewsmod where mid=1 order by myorder,mid");
while($m_r=$empire->fetch($m_sql))
{
	if(empty($m_r[usemod]))
	{
		if($m_r[mid]==$r[modid])
		{$m_d=" selected";}
		else
		{$m_d="";}
		$mod_options.="<option value=".$m_r[mid].$m_d.">".$m_r[mname]."</option>";
	}
	//列表模板
	$listtemp_options.="<option value=0 style='background:#99C4E3'>请选择静态书籍列表模板</option>";
	$dtlisttemp_options.="<option value=0 style='background:#99C4E3'>请选择动态书籍列表模板</option>";
	$lt_sql=$empire->query("select tempid,tempname from ".GetTemptb("enewslisttemp")." where classid=1");
	while($lt_r=$empire->fetch($lt_sql))
	{
		//静态
		if($lt_r[tempid]==$r[listtempid])
		{$lt_d=" selected";}
		else
		{$lt_d="";}
		$listtemp_options.="<option value=".$lt_r[tempid].$lt_d."> |-".$lt_r[tempname]."</option>";
		//动态
		if($lt_r[tempid]==$r[dtlisttempid])
		{$lt_dt=" selected";}
		else
		{$lt_dt="";}
		$dtlisttemp_options.="<option value=".$lt_r[tempid].$lt_dt."> |-".$lt_r[tempname]."</option>";
	}
	//搜索模板
	$searchtemp.="<option value=0 style='background:#99C4E3'>".$m_r[mname]."</option>";
	$st_sql=$empire->query("select tempid,tempname from ".GetTemptb("enewssearchtemp")." where modid='$m_r[mid]'");
	while($st_r=$empire->fetch($st_sql))
	{
		if($st_r[tempid]==$r[searchtempid])
		{$st_d=" selected";}
		else
		{$st_d="";}
		$searchtemp.="<option value=".$st_r[tempid].$st_d."> |-".$st_r[tempname]."</option>";
	}
	//书封面模板
	$newstemp_options.="<option value=0 style='background:#99C4E3'>请选择静态书籍内容模板</option>";
	$dtnewstemp_options.="<option value=0 style='background:#99C4E3'>请选择动态书籍内容模板</option>";
	$nt_sql=$empire->query("select tempid,tempname from ".GetTemptb("enewsnewstemp")." where classid=1");
	while($nt_r=$empire->fetch($nt_sql))
	{
		//静态
		if($nt_r[tempid]==$r[newstempid])
		{$nt_d=" selected";}
		else
		{$nt_d="";}
		$newstemp_options.="<option value=".$nt_r[tempid].$nt_d."> |-".$nt_r[tempname]."</option>";
		//动态
		if($nt_r[tempid]==$r[dtnewstempid])
		{$nt_dt=" selected";}
		else
		{$nt_dt="";}
		$dtnewstemp_options.="<option value=".$nt_r[tempid].$nt_dt."> |-".$nt_r[tempname]."</option>";
	}
}

//章节内容模板

	$bdtemp_options.="<option value=0 style='background:#99C4E3'>请选择静态章节内容模板</option>";
	$dtbdtemp_options.="<option value=0 style='background:#99C4E3'>请选择静态章节内容模板</option>";
	$bdnt_sql=$empire->query("select tempid,tempname from ".GetTemptb("enewsnewstemp")." where classid=2");
	while($bdnt_r=$empire->fetch($bdnt_sql))
	{
		//静态
		if($bdnt_r[tempid]==$r[bdtempid])
		{$bdnt_d=" selected";}
		else
		{$bdnt_d="";}
		$bdtemp_options.="<option value=".$bdnt_r[tempid].$bdnt_d."> |-".$bdnt_r[tempname]."</option>";
		//动态
		if($bdnt_r[tempid]==$r[dtbdtempid])
		{$bdnt_d=" selected";}
		else
		{$bdnt_d="";}
		$dtbdtemp_options.="<option value=".$bdnt_r[tempid].$bdnt_d."> |-".$bdnt_r[tempname]."</option>";
	}


//当前使用的模板组
$thegid=GetDoTempGid();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="adminstyle/<?=$loginadminstyleid?>/adminstyle.css" type="text/css">
<link id="luna-tab-style-sheet" type="text/css" rel="stylesheet" href="adminstyle/<?=$loginadminstyleid?>/tab.winclassic.css" disabled="disabled" /> 
<title>管理栏目</title>
<!-- the id is not needed. It is used here to be able to change css file at runtime -->
<style type="text/css"> 
   .dynamic-tab-pane-control .tab-page { 
          width:                100%;
 } 
  .dynamic-tab-pane-control .tab-page .dynamic-tab-pane-control .tab-page { 
         height:                150px; 
 } 
  form { 
         margin:        0; 
         padding:        0; 
 } 
  /* over ride styles from webfxlayout */ 
  .dynamic-tab-pane-control h2 { 
         font-size:12px;
		 font-weight:normal;
		 text-align:        center; 
         width:                auto;
		 height:            20; 
 } 
   .dynamic-tab-pane-control h2 a { 
         display:        inline; 
         width:                auto; 
 } 
  .dynamic-tab-pane-control a:hover { 
         background: transparent; 
 } 
  </style>
 <script type="text/javascript" src="../data/images/tabpane.js"></script> <script type="text/javascript"> 
  function setLinkSrc( sStyle ) { 
         document.getElementById( "luna-tab-style-sheet" ).disabled = sStyle != "luna"; 
  
         //document.documentElement.style.background = "";
         //document.body.style.background = sStyle == "webfx" ? "white" : "ThreeDFace"; 
 } 
function chgBg(obj,color){
 if (document.all || document.getElementById)
   obj.style.backgroundColor=color;
 else if (document.layers)
   obj.bgColor=color;
}
  setLinkSrc( "luna" ); 
  </script>
  
<script>
function small_class(mycheck)
{
if(mycheck)
{
document.getElementById('smallclass').style.display="";
document.getElementById('smallclasssetinfo').style.display="";
document.getElementById('smallclasssettemp').style.display="";
document.getElementById('bigclasssettemp').style.display="none";
document.getElementById('bigclasssetclasstext').style.display="none";
document.getElementById('smallcgtoinfo').style.display="";
document.getElementById('smallclassbdinfo').style.display="";
}
else
{
document.getElementById('smallclass').style.display="none";
document.getElementById('smallclasssetinfo').style.display="none";
document.getElementById('smallclasssettemp').style.display="none";
document.getElementById('bigclasssettemp').style.display="";
document.getElementById('bigclasssetclasstext').style.display="";
document.getElementById('smallcgtoinfo').style.display="none";
document.getElementById('smallclassbdinfo').style.display="none";
}
}


function changeitem(myfrm)
{var SelectedBigId;
SelectedBigId=myfrm.bclassid.options[myfrm.bclassid.selectedIndex].value;
myfrm.pripath.value=bclass[SelectedBigId][0];
	if(myfrm.enews.value=='EditClass')
	{
		if(!myfrm.ecmsclasstype.value==1)
		{
			myfrm.classpath.focus();
		}
	}
	else
	{
		if(!myfrm.ecmsclasstype[1].checked)
		{
			myfrm.classpath.focus();
		}
	}
}

//检查
function CheckForm(obj)
{
if(obj.classname.value=="")
{
alert("请输入栏目名称");
return false;
}
if(obj.classpath.value=="")
{
alert("请输入栏目目录");
return false;
}

	if(obj.modid.value==0||obj.modid.value=="")
	{
	alert("请选择所属系统模型");
	return false;
	}
	if(obj.listtempid.value==0 && obj.dtlisttempid.value==0)
	{
	alert("请选择列表模板");
	return false;
	}
	if(obj.newstempid.value==0 && obj.dtnewstempid.value==0)
	{
	alert("请选择书籍页模板");
	return false;
	}
	if(obj.bdtempid.value==0 && obj.dtbdtempid.value==0)
	{
	alert("请选择章节内容模板");
	return false;
	}

return true;
}

</script>
</head>

<body>
<table width="100%" border="0" align="center" cellpadding="6" cellspacing="1">
  <tr>
    <td>位置：<?=$url?> </td>
  </tr>
</table>
  <form name="form1" method="post" action="ecmsclass.php" onsubmit="return CheckForm(document.form1);">
  <div class="tab-pane" id="TabPane1"> <script type="text/javascript">
tb1 = new WebFXTabPane( document.getElementById( "TabPane1" ) );
</script>
                    
      <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
        <input type=hidden name=enews value=<?=$enews?>>
		<input type=hidden name="is_zt" value=0>
        <tr class="header"> 
          <td height="30" colspan="2">增加书籍栏目</td>
        </tr>
        <tr bgcolor="#FFFFFF"> 
          <td width="23%" height="25">栏目名称</td>
          <td> <input name="classname" type="text" id="classname" value="<?=$r[classname]?>" size="38"> 
            <?
	  if($enews=="AddClass")
	  {
	  ?>
            <input type="button" name="Submit5" value="生成拼音目录" onclick="window.open('GetPinyin.php?hz='+document.form1.classname.value+'&returnform=opener.document.form1.classpath.value','','width=160,height=100');"> 
            <?
	  }
	  ?>*
            <input name="oldbclassid" type="hidden" id="oldbclassid" value="<?=$r[bclassid]?>"> 
            <input name="classid" type="hidden" id="classid" value="<?=$classid?>"> 
            <input name="oldclassname" type="hidden" id="oldclassname" value="<?=$r[classname]?>"> 
            <input name="oldislast" type="hidden" id="oldislast" value="<?=$r[islast]?>"> 
            <input name="filepass" type="hidden" id="filepass" value="<?=$filepass?>"></td>
        </tr>

        <tbody>
          <tr bgcolor="#FFFFFF"> 
            <td height="25" valign="top">栏目存放文件夹 <br><font color="#666666"> (设定之后不能修改)</font>
              <input name="oldclasspath" type="hidden" id="oldclasspath" value="<?=$r[classpath]?>"> 
              <br> <input name="oldcpath" type="hidden" id="oldcpath" value="<?=$classpath?>"></td>
            <td><table border="0" cellspacing="1" cellpadding="3">
                <tr bgcolor="DBEAF5"> 
                  <td>根目录</td>
                  <td>本栏目目录</td>
                  <td bgcolor="DBEAF5">&nbsp;</td>
                </tr>
                <tr> 
                  <td><div align="right">/</div></td>
                  <td><input name="classpath" type="text" id="classpath3" value="<?=$classpath?>" size="16"<?=$read?>></td>
                  <td> <div align="left"> 
                      <input type="button" name="Submit3" value="检测目录" onclick="javascript:window.open('ecmscom.php?enews=CheckPath&classpath='+document.form1.classpath.value,'','width=100,height=100,top=250,left=450');">*
                    </div></td>
                </tr>
              </table></td>
          </tr>
          <input name="modid" type="hidden" id="modid" value="1"></td>
          <tr bgcolor="#FFFFFF"> 
            <td height="25">绑定域名</td>
            <td><input name="classurl" type="text" id="classurl" value="<?=$r[classurl]?>" size="38"> 
              <font color="#666666"> (没有绑定，请留空.以&quot;/&quot;结尾)</font></td>
          </tr>
        </tbody>
        <tr bgcolor="#FFFFFF"> 
          <td height="25" valign="top">页面关键字</td>
          <td><input name="classpagekey" type="text" id="classpagekey" value="<?=$r[classpagekey]?>" size="38"></td>
        </tr>
        <tr bgcolor="#FFFFFF"> 
          <td height="25" valign="top">栏目简介</td>
          <td><textarea name="intro" cols="70" rows="8" id="intro"><?=stripSlashes($r[intro])?></textarea></td>
        </tr>
		<?php
		if($enews=='EditClass')
		{
		?>
        <tr bgcolor="#FFFFFF">
          <td height="25">栏目增加时间</td>
          <td><?=$r['addtime']?date("Y-m-d",$r['addtime']):'---'?></td>
        </tr>
		<?php
		}
		?>
        <tr bgcolor="#FFFFFF"> 
          <td height="25">显示排序</td>
          <td><input name="myorder" type="text" id="myorder" value="<?=$r[myorder]?>"> 
            <font color="#666666">(值越小越前面)</font></td>
        </tr>
        <tr bgcolor="#FFFFFF"> 
          <td>检测书名重复</td>
          <td height="25"><input name="sametitle" type="checkbox" id="sametitle" value="1"<?=$r['sametitle']==1?' checked':''?>>是
          </td>
        </tr>
        <tr bgcolor="#FFFFFF"> 
          <td width="23%" height="25">书籍列表设置</td>
          <td> 
             静态模板：<select name="listtempid" id="listtempid">
              <?=$listtemp_options?>
            </select>
            * 
			 动态模板：<select name="dtlisttempid" id="dtlisttempid">
              <?=$dtlisttemp_options?>
            </select>
			<br>
			模式：<input type="radio" name="cdt" value="0"<?=$r[cdt]==0?' checked':''?>>
            静态
            <input type="radio" name="cdt" value="1"<?=$r[cdt]==1?' checked':''?>>
            动态
			</td>
        </tr>
        <tbody id="smallclasssettemp">
          <tr bgcolor="#FFFFFF"> 
            <td height="25">书籍内容设置</td>
            <td>静态模板：<select name="newstempid" id="newstempid">
                <?=$newstemp_options?>
              </select>
              * 
			   动态模板：<select name="dtnewstempid" id="dtnewstempid">
                <?=$dtnewstemp_options?>
              </select>
			  <br>
			模式：<input type="radio" name="bdt" value="0"<?=$r[bdt]==0?' checked':''?>>
            静态
            <input type="radio" name="bdt" value="1"<?=$r[bdt]==1?' checked':''?>>
            动态
			</td>
          </tr>
		  <tr bgcolor="#FFFFFF"> 
            <td height="25">章节内容设置</td>
            <td>静态模板：<select name="bdtempid" id="bdtempid">
                <?=$bdtemp_options?>
              </select>
              * 
			   动态模板：<select name="dtbdtempid" id="dtbdtempid">
                <?=$dtbdtemp_options?>
              </select>
			  <br>
			模式：<input type="radio" name="ddt" value="0"<?=$r[ddt]==0?' checked':''?>>
            静态
            <input type="radio" name="ddt" value="1"<?=$r[ddt]==1?' checked':''?>>
            动态
			</td>
          </tr>
        </tbody>
        <tr bgcolor="#FFFFFF"> 
          <td height="25">列表每页显示</td>
          <td><input name="lencord" type="text" id="lencord" value="<?=$r[lencord]?>" size="38">
            本书 
            <input name="oldlencord" type="hidden" id="oldlencord3" value="<?=$r[lencord]?>"></td>
        </tr>
        <tbody>
          <tr bgcolor="#FFFFFF" style="display:none"> 
            <td height="25">内容页文件命名形式</td>
            <td>
              命名: 
              <input type="radio" name="filename" value="3">
            </td>
          </tr>
        </tbody>
      </table>
  </div>

  <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
    <tr> 
      <td width="100%" height="30"><div align="center"><strong> 
          <input type="submit" name="Submit" value="提交">
          &nbsp;&nbsp;<input type="reset" name="Submit2" value="重置">
          <input type=hidden name=from value="<?=$_GET['from']?>"></strong></div></td>
    </tr>
  </table>
  </form>
</body>
</html>
<?php
db_close();
$empire=null;
?>