<?
$C_126cmsadmin_tname = 'sort_config';

include(dirname(__FILE__)."/global.php");



@$job = $submitted_vars["job"];

if($job == "add"){
  $postdb = $_POST['postdb'];
  $postdb['name'] =explode("\r\n",$postdb['name']);
  //print_r($postdb);exit;
  
  //计算当前分类为几级分类
  $class = GetClass($postdb['parentId'],'w6_sort');
  
  for($i=0;$i<count($postdb['name']);$i++){
  	//写入数据库
	$query = "insert into `w6_sort`
            (`mid`,`name`,`parentId`,`class`,`type`,`color`,`hide`,`list`,`SpecialSql`,`list_html`)
            values
            ('".$postdb['mid']."','".$postdb['name'][$i]."','".$postdb['parentId']."','".$class."','".$postdb['type']."','".$postdb['color']."','".$postdb['hide']."','".$postdb['list']."','".$postdb['SpecialSql']."','".$postdb['list_html']."')";
	$result = mysql_query($query) or die(mysql_error());
	if ($result){
		$showmsg .= $postdb['name'][$i]." 栏目添加成功！<br>";
		$formurl = "sort.php";
	}else{
		$showmsg .= $postdb['name'][$i]." 栏目添加失败！<br>";
		$formurl = "sort_add.php";
	}

  }
  include('showmsg.php');
  exit;

}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>后台管理</title>
<link href="css.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
a:link {
	text-decoration: none;
	color: #000000;
}
a:visited {
	text-decoration: none;
	color: #000000;
}
a:hover {
	text-decoration: underline;
	color: #FF0000;
}
a:active {
	text-decoration: none;
	color: #000000;
}
-->
</style></head>

<body>
<div align="center" class="font12">
  <table width="100%"  border="0" cellpadding="3" cellspacing="1" bgcolor="#A4B6D7">
    <tr>
      <td width="100%" height="22" align="center" background="images/titlebg.jpg">&nbsp;</td>
    </tr>
  </table>
  <br />
  <table width="100%" height="25" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
      <td align="left" bgcolor="#FFFFFF">[<a 
      href="sort.php" class="a_bt">栏目管理</a>] 
      [<a 
      href="sort_add.php" class="a_bt">创建栏目</a>] </td>
    </tr>
  </table>
  <br />
  <br />
  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="table">
    <tr>
      <td height="22" align="left" class="head">添加栏目/分类</td>
    </tr>
    <tr>
      <td height="24" align="left">
	  <form id="form1" name="form1" method="post" action="">
	  <table width="99%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC" class="table2">
        <tr>
          <td width="34%" height="28" bgcolor="#FFFFFF">栏目名称 <br />注:要想一次批量创建多个栏目,每个栏目名称换一行.</td>
          <td width="66%" bgcolor="#FFFFFF"><textarea name="postdb[name]" cols="40" rows="5"></textarea></td>
        </tr>
        <tr>
          <td height="28" bgcolor="#FFFFFF">所属分类</td>
          <td bgcolor="#FFFFFF"><select name="postdb[parentId]" id="postdb[parentId]">
              <option value="0" selected="selected">作为根分类</option>
              <?
		  formListSort("w6_sort");
		  ?>
          </select></td>
        </tr>
        <tr>
          <td height="28" bgcolor="#FFFFFF">本栏目归属于哪个模型</td>
          <td bgcolor="#FFFFFF"><select name='postdb[mid]' >
		  <?
		  $sql="select * from `w6_module`";
          $result=mysql_query($sql);
          while($row=mysql_fetch_array($result)){
		  
		  echo "<option value='".$row['module_id']."'>".$row['module_name']."</option>
		  ";
		  
		  }
		  
		  ?>
          </select>          </td>
        </tr>
        <tr>
          <td height="28" bgcolor="#FFFFFF">字体颜色
              <script>
function foreColor_font(obj)
{
  var arr = showModalDialog('images/selcolor.htm', '', 'dialogWidth:18.5em; dialogHeight:17.5em; status:0');
  if (arr != null) { obj.value=arr;obj.style.color=arr;}
  else  obj.focus();
  
}
          </script></td>
          <td bgcolor="#FFFFFF"><input onclick="foreColor_font(this);" name="postdb[color]" /></td>
        </tr>
        <tr>
          <td height="28" bgcolor="#FFFFFF">隐藏/显示</td>
          <td bgcolor="#FFFFFF"><input type="radio" checked="checked" value="0" name="postdb[hide]" />
            显示
            <input type="radio" value="1" name="postdb[hide]" />
            隐藏</td>
        </tr>
        <tr>
          <td height="28" bgcolor="#FFFFFF">排序值</td>
          <td bgcolor="#FFFFFF"><input maxlength="4" size="5" name="postdb[list]" />
(数字) </td>
        </tr>
        <tr>
          <td height="28" bgcolor="#FFFFFF">设置为大分类/小栏目/单篇文章</td>
          <td bgcolor="#FFFFFF"><input type="radio" name="postdb[type]" value="1"  checked  onclick="SpecialSet('0')">
        大分类(不可发内容) 
        <input type="radio" name="postdb[type]" value="0"  onclick="SpecialSet('0')" >
        小栏目
        <input type="radio" name="postdb[type]" value="3"  onclick="SpecialSet('1')">
        专题
<input type="radio" name="postdb[type]" value="2"  onclick="SpecialSet('0')" >
        单篇文章(一个栏目即一篇文章，适合于作公司联系方式，公司介绍等)
        </td>
        </tr>
<tr  id="SpecialSql_div">
          <td height="28" bgcolor="#FFFFFF">专题栏目sql语句:</td>
          <td bgcolor="#FFFFFF"><textarea name="postdb[SpecialSql]" cols="84" rows="5"></textarea>
            <br />
            当选择专题时在此输入sql语句，sql1与sql2之前用 [||] 隔开，如：<br />
            SELECT * FROM `w6_module_content_45` WHERE `shows` = '1' AND (`title` LIKE '%$fname%' || `news_keywords` LIKE '%$fname%')[||]SELECT * FROM `w6_module_content_45` WHERE 1 AND (`title` LIKE '%$fname%' || `news_keywords` LIKE '%$fname%') AND `shows` = '1' ORDER BY `count` DESC  LIMIT {=star_page=} , $article_page_size;<br />
            sql1 用于取得数据总数，sql2 用于取得具体数据
			
			<SCRIPT LANGUAGE="JavaScript">
<!--
function SpecialSet(t){
	if(t=='0'||t==''){
		document.getElementById("SpecialSql_div").style.display='none';
	}
	else{
		document.getElementById("SpecialSql_div").style.display='';
		v=document.getElementById("postdb[SpecialSql]").value;
		if(v==''||v=='0'){
			document.getElementById("postdb[SpecialSql]").value='SELECT * FROM `w6_module_content_45` WHERE `shows` = \'1\' AND (`title` LIKE \'%$fname%\' || `news_keywords` LIKE \'%$fname%\')[||]SELECT * FROM `w6_module_content_45` WHERE 1 AND (`title` LIKE \'%$fname%\' || `news_keywords` LIKE \'%$fname%\') AND `shows` = \'1\' ORDER BY `count` DESC  LIMIT {=star_page=} , $article_page_size;';
		}
	}
}
SpecialSet('');
//-->
</SCRIPT>

			{=star_page=} 为搜索数据库开始记录数 </td>
        </tr>
<tr>
          <td height="28" bgcolor="#FFFFFF">静态网页表现形式:</td>
          <td bgcolor="#FFFFFF"><p><br />
            列表页:
            <input name="postdb[list_html]" id="list_html" value="html/{$fid}/{$page}.html" size="50" />
            <p>注: 默认样式为 html/{$fid}/{$page}.html ，如要修改其他样式，可在栏目修改中修改。</p>
</td>
        </tr>
        <tr>
          <td height="28" bgcolor="#FFFFFF">&nbsp;</td>
          <td bgcolor="#FFFFFF"><input type="submit" value="提交" name="Submit" />
            <input name="job" type="hidden" id="job" value="add" /></td>
        </tr>
      </table>
        </form>
      </td>
    </tr>
  </table>
  </div>
</body>
</html>
