<!DOCTYPE html>
<html>
<head>
<meta charset="<?php echo $cfg_soft_lang; ?>">
<title><?php echo $cfg_softname; ?></title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="../publics/layui/css/layui.css" media="all" />
<link rel="stylesheet" href="../publics/iconfont/iconfont.css" media="all" />
<link rel="stylesheet" href="css/admin.css" media="all" />
<style>
.layui-form-pane .layui-form-label{width:120px;text-align:right;}
.layui-form-pane .layui-input-block{margin-left:120px;}
</style>
<script language="javascript">
var channelArray = new Array();
<?php
$i = 0;
foreach($channelArray as $k=>$arr)
{
echo "channelArray[$k] = \"{$arr['nid']}\";\r\n";
}
?>

function Nav(){
    if(window.navigator.userAgent.indexOf("MSIE")>=1) return 'IE';
  else if(window.navigator.userAgent.indexOf("Firefox")>=1) return 'FF';
  else return "OT";
}

function SelectTemplets(fname){
   if(document.all){
     var posLeft = window.event.clientY-100;
     var posTop = window.event.clientX-400;
   }
   else{
     var posLeft = 100;
     var posTop = 100;
   }
   window.open("../include/dialog/select_templets.php?f="+fname, "poptempWin", "scrollbars=yes,resizable=yes,statebar=no,width=600,height=400,left="+posLeft+", top="+posTop);
}

function ShowHide(objname)
{
  var obj = document.getElementById(objname);
  if(obj.style.display != "none")
       obj.style.display = "none";
  else {
       if(Nav()=='IE') obj.style.display = "block";
       else obj.style.display = "table-row";
    }
}

function ShowObj(objname)
{
   var obj = document.getElementById(objname);
     if(Nav()=='IE') obj.style.display = "block";
     else obj.style.display = "table";
}

function HideObj(objname){
  var obj = document.getElementById(objname);
    obj.style.display = "none";
}

function ShowItem1(){
  ShowObj('head1'); ShowObj('needset');
  HideObj('head2'); HideObj('adset');
  HideObj('head3'); HideObj('ctset');
}

function ShowItem2(){
  ShowObj('head2'); ShowObj('adset');
  HideObj('head1'); HideObj('needset');
  HideObj('head3'); HideObj('ctset');
}

function ShowItem3(){
  ShowObj('head3'); ShowObj('ctset');
  HideObj('head1'); HideObj('needset');
  HideObj('head2'); HideObj('adset');
}

function CheckTypeDir(){
  var upinyin = document.getElementById('upinyin');
  var tpobj = document.getElementById('typedir');
  if(upinyin.checked) tpobj.style.display = "none";
  else tpobj.style.display = "block";
}

function ParTemplet(obj)
{
  var sevvalue = channelArray[obj.value];
  var tobj = document.getElementById('smclass');
  var tempindex = document.getElementsByName('tempindex');
  var templist = document.getElementsByName('templist');
  var temparticle = document.getElementsByName('temparticle');
  var dfstyle = document.getElementsByName('dfstyle');
  var dfstyleValue = dfstyle[0].value;
  tempindex[0].value = dfstyleValue+"/index_"+sevvalue+".htm";
  templist[0].value = dfstyleValue+"/list_"+sevvalue+".htm";
  temparticle[0].value = dfstyleValue+"/article_"+sevvalue+".htm";
  if(obj.value < 0)
  {
      if(Nav()=='IE') tobj.style.display = "block";
      else tobj.style.display = "block";
  }
  else
  {
      tobj.style.display = "none";
  }
}

function checkSubmit()
{
   if(document.form1.typename.value==""){
          alert("栏目名称不能为空！");
          document.form1.typename.focus();
          return false;
     }
     return true;
}

function CheckPathSet()
{
    var surl = document.getElementById("siteurl");
    var sreid = document.getElementById("reid");
    var mysel = document.getElementById("truepath3");
    if(surl.value!=""){
        if(sreid.value=="0" || sreid.value==""){
            mysel.checked = true;
        }
    }
}

function CheckCross()
{
    var cross2 = document.getElementById('cross2');
    var crossid = document.getElementById('crossid');
    if(cross2.checked) crossid.style.display = 'block';
    else crossid.style.display = 'none';
}

</script>
</head>
<body class="childrenBody">
<div class="x-nav">
	<span class="layui-breadcrumb">
	  <a href="index_body.php">首页</a>
	  <a href="catalog_main.php">栏目管理</a>
	  <a><cite>增加顶级栏目</cite></a>
	</span>
	<a class="layui-btn layui-btn-small refresh" href="javascript:location.replace(location.href);" title="刷新"><i class="iconfont icon-refresh" style="line-height:30px"></i></a>
</div>
<form name="form1" action="catalog_add.php" method="post" class="layui-form layui-form-pane">
<input type="hidden" name="dopost" value="save" />
<input type="hidden" name="reid" id="reid" value="<?php echo $id; ?>" />
<input type='hidden' name='topid' id='topid' value='<?php echo $topid; ?>' />
<?php
if($id>0)
{
	echo "  <input type='hidden' name='moresite' value='{$myrow['moresite']}' />\r\n";
	echo "  <input type='hidden' name='siteurl' value='{$myrow['siteurl']}' />\r\n";
	echo "  <input type='hidden' name='sitepath' value='{$myrow['sitepath']}' />\r\n";
}
?>
	<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
		<ul class="layui-tab-title">
			<li class="layui-this">常规选项</li>
			<li>高级选项</li>
			<li>栏目内容</li>
		</ul>
		<div class="layui-tab-content">
			<div class="layui-tab-item layui-show">
				<div class="layui-form-item" pane>
					<label class="layui-form-label">是否支持投稿</label>
					<div class="layui-input-block">
						<input type="radio" name="issend" value="0" title="不支持"<?php if($issend==0) echo " checked ";?>>
						<input type="radio" name="issend" value="1" title="支持"<?php if($issend==1) echo " checked ";?>>
					</div>
				</div>
				<div class="layui-form-item" pane>
					<label class="layui-form-label">是否隐藏栏目</label>
					<div class="layui-input-block">
						<input type="radio" name="ishidden" value="0" title="显示" checked>
						<input type="radio" name="ishidden" value="1" title="隐藏">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">内容模型</label>
					<div class="layui-input-inline">
						<select name="channeltype" id="channeltype" lay-filter="channeltype">
						<?php
						foreach($channelArray as $k=>$arr)
						{
							if($k==$channelid) {
								$nid = $arr['nid'];
								echo "<option value='{$k}' selected>{$arr['typename']}|{$arr['nid']}</option>\r\n";
							}
							else
							{
								echo "<option value='{$k}'>{$arr['typename']}|{$arr['nid']}</option>\r\n";
							}
						}
						?>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">栏目名称</label>
					<div class="layui-input-block">
						<input type="text" name="typename" required lay-verify="required" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">排列顺序</label>
					<div class="layui-input-inline">
						<input type="text" name="sortrank" value="50" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">浏览权限</label>
					<div class="layui-input-inline">
						<select name="corank" id="corank">
						<?php
							$dsql->SetQuery("Select * from `#@__arcrank` where rank >= 0");
							$dsql->Execute('cc');
							while($row = $dsql->GetObject('cc'))
							{
								if($corank==$row->rank) echo "<option value='".$row->rank."' selected>".$row->membername."</option>\r\n";
								else
								{
									//如果上级目录的corank>0，下级必须继承
									if($corank==0)
									{ echo "<option value='".$row->rank."'>".$row->membername."</option>\r\n"; }
								}
							}
						  ?>
						</select>
					</div>
					<div class="layui-form-mid layui-word-aux">
						(仅限制栏目里的文档浏览权限)
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">上级目录</label>
					<div class="layui-input-block">
						<?php
							$pardir = '{cmspath}'.$cfg_arcdir;
							if(!empty($typedir)) $pardir = $typedir.'/';
							$pardir = preg_replace("#\/{1,}#", '/', $pardir);
						?>
						<input type="text" name="nextdir" id="nextdir" value="<?php echo $pardir?>" disabled class="layui-input layui-disabled" />
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">文件保存目录</label>
					<div class="layui-input-block" id="typedir" style="width:30%;float:left;margin-left:0;">
						<input type="text" name="typedir" class="layui-input">
					</div>
					<div class="layui-input-block" style="float:left;margin-left:0;">
						<input type="checkbox" name="upinyin" id="upinyin" title="拼音" value="1" lay-filter="upinyin">
					</div>
				</div>
				<div class="layui-form-item" pane>
					<label class="layui-form-label">目录相对位置</label>
					<div class="layui-input-block">
						<input type="radio" name="referpath" value="parent" title="上级目录" checked>
						<?php
						if($moresite==0){
						?>
						<input type="radio" name="referpath" value="cmspath" title="CMS根目录">
						<input type="radio" name="referpath" value="basepath" title="站点根目录">
						<?php } ?>
					</div>
				</div>
				<div class="layui-form-item" pane>
					<label class="layui-form-label">栏目列表选项</label>
					<div class="layui-input-block">
						<input type="radio" name="isdefault" value="1" title="链接到默认页" checked>
						<input type="radio" name="isdefault" value="0" title="链接到列表第一页">
						<input type="radio" name="isdefault" value="-1" title="使用动态页">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">默认页的名称</label>
					<div class="layui-input-inline">
						<input type="text" name="defaultname" value="index.html" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item" pane>
					<label class="layui-form-label">栏目属性</label>
					<div class="layui-input-block">
						<input type="radio" name="ispart" value="0" title="最终列表栏目(允许栏目发布文档并生成文档列表)" checked>
						<input type="radio" name="ispart" value="1" title="频道封面(不允许发布文档)">
						<input type="radio" name="ispart" value="2" title="外部连接(在'文件保存目录'处填写网址)">
					</div>
				</div>
				<div class="layui-form-item" pane>
					<label class="layui-form-label">栏目交叉</label>
					<div class="layui-input-block">
						<input type="radio" name="cross" value="0" lay-filter="cross" title="不交叉" checked>
						<input type="radio" name="cross" value="1" lay-filter="cross" title="自动获取同名栏目内容">
						<input type="radio" name="cross" value="2" lay-filter="cross" title="手工指定交叉栏目ID(用逗号分开)">
					</div>
				</div>
				<div class="layui-form-item" id="crossid" style="display:none">
					<label class="layui-form-label">交叉栏目ID</label>
					<div class="layui-input-block">
						<input type="text" name="crossid" class="layui-input">
					</div>
				</div>
				<style>

				</style>
				<div class="layui-form-item" id='smclass' style='<?php echo ($channelid<0 ? '' : 'display:none'); ?>'>
					<label class="layui-form-label">绑定小分类</label>
					<div class="layui-input-inline">
						<select name='smalltype[]' class="form-control" multiple='yes' lay-ignore>
							<?php
							$sql = "SELECT * FROM `#@__sys_enum` WHERE egroup LIKE 'infotype' ORDER BY disorder ASC, id DESC ";
							$dsql->Execute('s',$sql);
							while($arr = $dsql->GetArray('s'))
							{
								if($arr['evalue']%500==0) {
									echo "<option value='{$arr['evalue']}'>{$arr['ename']}</option>\r\n";
								}
								else if(preg_match("#\.#", $arr['evalue']))
								{
									echo "<option value='{$arr['evalue']}'> └───{$arr['ename']}</option>\r\n";
								}
								else {
									echo "<option value='{$arr['evalue']}'> └─{$arr['ename']}</option>\r\n";
								}
							}
							?>
						</select>
					</div>
					<div class="layui-form-mid layui-word-aux">
						按 Ctrl 多选，不选系统将调用全部分类，在<a href='stepselect_main.php'>“<u>联动类别管理</u>”</a>中管理
					</div>
				</div>
			</div>
			<div class="layui-tab-item">
				<?php
				if($id==0)
				{
				?>
				<div class="layui-form-item" pane>
					<label class="layui-form-label">多站点支持</label>
					<div class="layui-input-block">
						<input type="radio" name="moresite" value="0" title="不支持" checked>
						<input type="radio" name="moresite" value="1" title="支持">
					</div>
				</div>
				<div class="layui-form-item" style="margin-top:-15px;margin-bottom:0px;">
					<div class="layui-input-block">
						<div class="layui-form-mid layui-word-aux">说明：如果需要绑定二级域名，必须在“系统参数”中设定“支持多站点”。</div>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">绑定域名</label>
					<div class="layui-input-inline">
						<input type="text" name="siteurl" id="siteurl" onChange="CheckPathSet();" class="layui-input">
					</div>
					<div class="layui-form-mid layui-word-aux">
						(需加 http://，一级或二级域名的根网址)
					</div>
				</div>
				<div class="layui-form-item" style="margin-top:-15px;margin-bottom:0px;">
					<div class="layui-input-block">
						<div class="layui-form-mid layui-word-aux">站点根目录：为简化操作，站点根目录与当前栏目目录一致，请注意当前栏目文件保存目录的设置，域名需自行手工绑定到这个目录。</div>
					</div>
				</div>
				<?php
				}
				?>
				<div class="layui-form-item" id="helpvar1" style="display:none;margin-top:-15px;margin-bottom:0px;">
					<div class="layui-input-block">
						<div class="layui-form-mid layui-word-aux">
			  {tid}表示栏目ID，<br>
              {cid}表示频道模型的'名字ID' <font color='#888888'> （
              <?php
              foreach($channelArray as $k=>$arr)
              {
                   echo "{$arr['typename']}({$arr['nid']})、";
              }
             ?>
              ） </font> <br/>
              模板文件的默认位置是放在模板目录 "cms安装目录
              <?php echo $cfg_templets_dir ?>
              " 内。
              <input type='hidden' value='{style}' name='dfstyle' class="pubinputs" />
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">封面模板</label>
					<div class="layui-input-block" style="width:30%;float:left;margin-left:0;">
						<input type="text" name="tempindex" id="tempindex" value="{style}/index_<?php echo $nid?>.htm" class="layui-input">
					</div>
					<div class="layui-input-block" style="float:left;margin-left:-2px;">
						<input type="button" name="set1" value="浏览..." class="layui-btn" onClick="SelectTemplets('form1.tempindex');" />
					</div>
					<div class="layui-form-mid layui-word-aux">
						&nbsp;<a href="javascript:;" onClick="ShowHide('helpvar1')">查看支持变量</a>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">列表模板</label>
					<div class="layui-input-block" style="width:30%;float:left;margin-left:0;">
						<input type="text" name="templist" id="templist" value="{style}/list_<?php echo $nid?>.htm" class="layui-input">
					</div>
					<div class="layui-input-block" style="float:left;margin-left:-2px;">
						<input type="button" name="set3" value="浏览..." class="layui-btn" onClick="SelectTemplets('form1.templist');" />
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">文章模板</label>
					<div class="layui-input-block" style="width:30%;float:left;margin-left:0;">
						<input type="text" name="temparticle" id="temparticle" value="{style}/article_<?php echo $nid?>.htm" class="layui-input">
					</div>
					<div class="layui-input-block" style="float:left;margin-left:-2px;">
						<input type="button" name="set4" value="浏览..." class="layui-btn" onClick="SelectTemplets('form1.temparticle');" />
					</div>
				</div>
				<div class="layui-form-item" id="helpvar2" style="display:none;margin-top:-15px;margin-bottom:0px;">
					<div class="layui-input-block">
						<div class="layui-form-mid layui-word-aux">
							{Y}、{M}、{D} 年月日<br/>
							{timestamp} INT类型的UNIX时间戳<br/>
							{aid} 文章ID<br/>
							{pinyin} 拼音+文章ID<br/>
							{py} 拼音部首+文章ID<br/>
							{typedir} 栏目目录 <br/>
							{cc} 日期+ID混编后用转换为适合的字母 <br/>
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">文章命名规则</label>
					<div class="layui-input-inline" style="width:250px;">
						<input type="text" name="namerule" id="namerule" required lay-verify="required" value="<?php echo $cfg_df_namerule;?>" class="layui-input">
					</div>
					<div class="layui-form-mid layui-word-aux">
						<a href="javascript:;" onClick="ShowHide('helpvar2')">查看支持变量</a>
					</div>
				</div>
				<div class="layui-form-item" id="helpvar3" style="display:none;margin-top:-15px;margin-bottom:0px;">
					<div class="layui-input-block">
						<div class="layui-form-mid layui-word-aux">
							{page} 列表的页码
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">列表命名规则</label>
					<div class="layui-input-inline" style="width:250px;">
						<input type="text" name="namerule2" required lay-verify="required" value="{typedir}/list_{tid}_{page}.html" class="layui-input">
					</div>
					<div class="layui-form-mid layui-word-aux">
						<a href="javascript:;" onClick="ShowHide('helpvar3')">查看支持变量</a>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">SEO标题</label>
					<div class="layui-input-inline">
						<input type="text" name="seotitle" class="layui-input">
					</div>
					<div class="layui-form-mid layui-word-aux">
						(栏目模板里用{dede:field.seotitle /}调用)
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">关键字</label>
					<div class="layui-input-block">
						<input type="text" name="keywords" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">栏目描述</label>
					<div class="layui-input-block">
						<textarea name="description" class='layui-textarea'></textarea>
					</div>
				</div>
			</div>
			<div class="layui-tab-item">
				<div class="layui-form-item layui-form-text">
					<label class="layui-form-label">栏目内容 可在栏目模板中用{dede:field.content/}调用，通常用于企业简介之类的用途。</label>
					<div class="layui-input-block">
						<?php
							GetEditor("content","","450","Default","print","false");
						?>
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-danger">重置</button>
					<a class="layui-btn layui-btn-primary" href="javascript:;" onClick='history.go(-1);'>返回</a>
				</div>
			</div>
		</div>
	</div>
</form>
<script type="text/javascript" src="../publics/layui/layui.js"></script>
<script type="text/javascript" src="js/catalog.js"></script>
</body>
</html>