<?php
define('EmpireCMSAdmin','1');
require("../class/connect.php");
require("../class/db_sql.php");
require("../class/functions.php");
require("../class/dpfun.php");
require("../data/dbcache/class.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'];

$enews=$_GET['enews'];
$classid=(int)$_GET['classid'];

//验证权限
$doselfinfo=CheckLevel($logininid,$loginin,$classid,"news");
$fun_r['AdminBook']='管理书籍';
//附件验证码

	if(!$doselfinfo['doaddinfo'])//增加权限
	{
		printerror("NotAddInfoLevel","history.go(-1)");
	}
	$filepass=time();
	$word='增加章节(自动识别BOOKid模式)';
	$ecmsfirstpost=1;


//审核
$ecmscheck=(int)$_GET['ecmscheck'];
$addecmscheck='';
$indexchecked=1;
if($ecmscheck)
{
	$addecmscheck='&ecmscheck='.$ecmscheck;
	$indexchecked=0;
}

//导航
$url=AdminReturnBookClass($classid).'&nbsp;>&nbsp;'.$word;
$url2='<a href="ListAllBook.php?tbname=bookname">管理书籍</a>&nbsp;>&nbsp;增加章节(自动识别BOOKid模式)';
//会员组
$sql1=$empire->query("select groupid,groupname from {$dbtbpre}enewsmembergroup order by level");
while($l_r=$empire->fetch($sql1))
{
	$ygroup.="<option value=".$l_r[groupid].">".$l_r[groupname]."</option>";
}
if($enews=="AddNews")
{
	$group=str_replace(" value=".$class_r[$classid][groupid].">"," value=".$class_r[$classid][groupid]." selected>",$ygroup);
}
//初始化数据
$r=array();
$newstime=time();
$r[newstime]=date("Y-m-d H:i:s");
$todaytime=$r[newstime];
$r[checked]=1;
$r[onclick]=0;
$titlefontb="";
$titlefonti="";
$titlefonts="";
$r[dokey]=1;
$titleurl='';
//----------- 特殊模型初始化 -----------
//html编辑器
if($emod_r[2]['editorf']&&$emod_r[2]['editorf']!=',')
{
	include('ecmseditor/infoeditor/fckeditor.php');
}


$writer_sql=$empire->query("select classid,classname from {$dbtbpre}enewsclass where is_zt=0");
while($w_r=$empire->fetch($writer_sql))
{
	$se='';
	if($w_r[classid]==$classid){$se=' selected';}
	$w_class.="<option value='".$w_r[classid]."' ".$se.">".$w_r[classname]."</option>";
}



//当前使用的模板组
$thegid=GetDoTempGid();
$phpmyself=urlencode(eReturnSelfPage(1));
//返回头条和推荐级别名称
$ftnr=ReturnFirsttitleNameList($r['firsttitle'],$r['isgood']);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?=$word?></title>
<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" /> 
<!-- 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 dovoteadd(){
	var i;
	var str="";
	var oldi=0;
	var j=0;
	oldi=parseInt(document.add.v_editnum.value);
	for(i=1;i<=document.add.v_vote_num.value;i++)
	{
		j=i+oldi;
		str=str+"<tr><td width='9%' height=20> <div align=center>"+j+"</div></td><td width='65%'> <div align=center><input type=text name=vote_name[] size=30></div></td><td width='26%'> <div align=center><input type=text name=vote_num[] value=0 size=6></div></td></tr>";
	}
	document.getElementById('addvote').innerHTML="<table width='100%' border=0 cellspacing=1 cellpadding=3>"+str+"</table>";
}

function doSpChangeFile(name,url,filesize,filetype,idvar){
	document.getElementById(idvar).value=url;
	if(document.add.filetype!=null)
	{
		if(document.add.filetype.value=='')
		{
			document.add.filetype.value=filetype;
		}
	}
	if(document.add.filesize!=null)
	{
		if(document.add.filesize.value=='')
		{
			document.add.filesize.value=filesize;
		}
	}
}

function SpOpenChFile(type,field){
	window.open('ecmseditor/FileMain.php?classid=<?=$classid?>&infoid=<?=$id?><?=$addecmscheck?>&filepass=<?=$filepass?>&type='+type+'&sinfo=1&tranfrom=2&field='+field,'','width=700,height=550,scrollbars=yes');
}
</script>
<script src="ecmseditor/fieldfile/setday.js"></script>
<script src="../data/html/postinfo.js"></script>
<script>
function bs(){
	var f=document.add;
	if(f.title.value.length==0){alert("标题还没写");f.title.focus();return false;}
}
function foreColor(){
  if(!Error())	return;
  var arr = showModalDialog("../data/html/selcolor.html", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0");
  if (arr != null) document.add.titlecolor.value=arr;
  else document.add.titlecolor.focus();
}
function FieldChangeColor(obj){
  if(!Error())	return;
  var arr = showModalDialog("../data/html/selcolor.html", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0");
  if (arr != null) obj.value=arr;
  else obj.focus();
}
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000" onload="document.add.title.focus();">
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr> 
    <td width="62%" height="25">位置： 
      <? if($classid){echo $url;}else{echo $url2;}?>
    </td>
    <td width="38%"><div align="right">
      </div></td>
  </tr>
</table>
<form name="add" method="post" enctype="multipart/form-data" action="ecmsbookdata.php" onsubmit="return EmpireCMSInfoPostFun(document.add,'<?=$modid?>');">
<div class="tab-pane" id="TabPane1">
	<script type="text/javascript">
	tb1 = new WebFXTabPane( document.getElementById( "TabPane1" ) );
	</script>
     

		<table width="100%" align="center" cellpadding="3" cellspacing="1" class="tableborder">
			<tr class="header"> 
				<td width="16%" height="25">
					<div align="left">增加章节</div>
				</td>
				<td>
					<input type="submit" name="addnews2" value="提交"> <input type="reset" name="Submit23" value="重置">
					<input type=hidden value="AddBDSB" name=enews>
					<input type=hidden value="<?=$r[username]?>" name=username> 
               </td>
			</tr>
		</table>

	  <table width='100%' align=center cellpadding=3 cellspacing=1 bgcolor='#DBEAF5'>
		<tr>
		  <td width='16%' height=25 bgcolor='ffffff'>栏目ID</td>
		  <td bgcolor='ffffff'>
			<input type=text name="cid" value="<?=$classid?>" size=""> 
			<select name="c_id" id="select7" onchange="document.add.cid.value=document.add.c_id.value">
              <option value=0>选择栏目</option>
		      <?=$w_class?>
            </select>
		  </td>
		</tr>
		<tr>
		  <td width='16%' height=25 bgcolor='ffffff'>书名</td>
		  <td bgcolor='ffffff'>
			<input type=text name=bookname value="" size="30"> <font color="gray">(不得有特殊符号)</font>
		  </td>
		</tr>
		<tr>
		  <td width='16%' height=25 bgcolor='ffffff'>章节标题</td>
		  <td bgcolor='ffffff'>
			<input type=text name=title value="" size="50"> 
		  </td>
		</tr>
		<tr>
		  <td width='16%' height=25 bgcolor='ffffff'>其它选项</td>
		  <td bgcolor='ffffff'>
		    <input name="checked" type="checkbox" value="1" checked>审核 
			<input name="sell" type="checkbox" value="1">
			出售 (<?=$public_r[docnewsnum]?>点/千字 <a href="pay/SetPayFen.php">修改</a>)
		  </td>
		</tr>
		<tr>
		  <td width='16%' height=25 bgcolor='ffffff'>分卷名称</td>
		  <td bgcolor='ffffff'>
			<input type=text name=vname value="" size="60">
		  </td>
		</tr>
		<tr>
		   <td height=25 colspan=2 bgcolor='ffffff'><div align=left>正文</div></td>
		</tr>
	 </table>

	<div style='background-color:#D0D0D0'>
	    <?=ECMS_ShowEditorVar("newstext",$ecmsfirstpost==1?"":stripSlashes($r[newstext]),"BookData","","300","100%")?>
		<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DBEAF5">
          <tr> 
            <td bgcolor="#FFFFFF"> <input name="copyimg" type="checkbox" id="copyimg" value="1">
			远程保存图片
		    </td>
          </tr>
        </table>
	</div>
	<table width='100%' align=center cellpadding=3 cellspacing=1 bgcolor='#DBEAF5'></table>
  </div>


  <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
    <tr>
      <td width="16%">&nbsp;</td>
      <td><input type="submit" name="addnews" value=" 提 交 "> &nbsp;&nbsp;&nbsp;<input type="reset" name="Submit2" value="重置"></td>
    </tr>
  </table>
</form>
<?=$copyclassidshowiframe?>
</body>
</html>
<?php
db_close();
$empire=null;
?>