<?php
if(empty($op)) $op='list';
?>
  <!--- content -->
  <div class="neir">
    <div class="top">音乐专集</div>
      <div class="content">
		<div class="main_nav">
			<ul>
				<li class="<?php if($op=='ds'){ echo 'nava_4';}else{ echo 'navb_5';}?>"><a href="?ac=topic&op=ds">待审专集</a></li>
				<li class="<?php if($op=='list'){ echo 'nava_4';}else{ echo 'navb_5';}?>"><a href="?ac=topic&op=list">专集列表</a></li>
			</ul>
			<div class="action"><a href="?ac=topic&op=add">创建专集</a></div>
		</div>
		<div class="main_nav2">
<?php 
if($op=="add"){
      $name='';
      $cid='';
      $tags='';
      $pic='';
      $yname='';
      $jiesao='';
      $year=date('Y');
      $diqu='';
      $yuyan='';
      $fxgs='';
      $classname='';
      $do='add';
   if(!empty($id)){
      global $db;
      $row=$db->getrow("select * from ".Getdbname('topic')." where CS_ID=".$id."");
      if($row){
          $class=$db->getrow("select * from ".Getdbname('class')." where CS_ID=".$row['CS_CID']."");
          $name=$row['CS_Name'];
          $cid=$row['CS_CID'];
          $tags=$row['CS_Tags'];
          $year=$row['CS_Year'];
          $diqu=$row['CS_Diqu'];
          $yuyan=$row['CS_Yuyan'];
          $fxgs=$row['CS_Fxgs'];
          $pic=$row['CS_Pic'];
          $yname=$row['CS_AliasName'];
          $jiesao=$row['CS_Content'];
          $classname=$class['CS_Name'];
          $fid=$class['CS_FID'];
          $do='edit&id='.$id;
       }
   }
?>
<script type="text/javascript" charset="utf-8" src="../public/editor/kindeditor.js"></script>
<script type="text/javascript"> KE.show({
	id : 'CS_Content',
	resizeMode : 1,
	allowPreviewEmoticons : false,
	allowUpload : false,
	items : [
	'source', '|', 'fontsize', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
	'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
	'insertunorderedlist', '|', 'image', 'link', 'unlink']
	});
function MM_jumpMenu(selObj,restore){
         var ary = ''; 
         var str = ''; 
         var id = selObj.options[selObj.selectedIndex].value; 
<?php 
      $sqlclass="select * from ".Getdbname('class')." where CS_FID<>0 and CS_SID=1";
      $results=$db->query($sqlclass);
	if($results){
	while ($row3=$db->fetch_array($results)){
?>
	 ary=ary+'<?php echo $row3['CS_FID']?>|<?php echo $row3['CS_ID']?>|<?php echo $row3['CS_Name']?>$$$';
<?php
 	}
	}
?>
        strs=ary.split('$$$');
        for ( var i=0 ; i < strs.length-1 ; ++i ) {
              strss=strs[i].split('|');
             if(strss[0]==id){
                   str=str+'<option value="'+strss[1]+'">'+strss[2]+'</option>';
             }
        }
		if(str==''){
           str='<option value="0">该分类没有风格</option>';
		}
        var strr = '<select name="CS_FID" id="CS_FID">'+str+'</select>'; 
        document.getElementById('CS_FG').innerHTML=strr;
}
</script>
<script language="javascript">
$(document).ready(function(){
	$("#adddj").click(function(){
		var CS_Name=$("#CS_Name").val();
		var CS_CID=$("#CS_CID").val();
		var CS_Tags=$("#CS_Tags").val();
		var CS_Pic=$("#CS_Pic").val();
		var CS_AliasName=$("#CS_AliasName").val();
		var re = /^[a-z0-9]*$/gi
	if(CS_Name==""){
		$("#CS_Name").css("border","1px solid red");
		$("#Msg").text("出错了，请填写专集名称！").css("color","red");
                alert("请填写专集名称！");
		return false;
		}
	else if(CS_AliasName==""){
		$("#CS_AliasName").css("border","1px solid red");
		$("#Msg").text("出错了，请填写英文别名！").css("color","red");
                alert("请填写英文别名！");
		return false;
		}
	else if(re.test(CS_AliasName)==false){
		$("#CS_AliasName").css("border","1px solid red");
		$("#Msg").text("英文别名必须是数字或字母组成！").css("color","red");
                alert("英文别名必须是数字或字母组成！");
		return false;
		}
	else if(CS_CID=="0"){
		$("#Msg").text("出错了，请选择专集分类！").css("color","red");
                alert("请选择专集分类！");
		return false;
		}
	else if(CS_Tags==""){
		$("#Msg").text("出错了，请选择专集标签！").css("color","red");
                alert("请选择专集标签！");
                Popsboxif('选择标签',530,380,'../public/tags.php?f=form.CS_Tags');
		return false;
		}
	else if(CS_Pic==""){
		$("#Msg").text("出错了，请上传专集封面！").css("color","red");
                alert("请上传专集封面！");
		return false;
		}
	});
});
</script>
	<form action="do.php?ac=topic&op=<?php echo $do?>" id="form" name="form" method="post">
	<table class="user_mod_list" cellpadding="0" cellspacing="0"><input type="hidden" class="user_reg_input" name="CS_Pic" id="CS_Pic" value="<?php echo $pic?>">
		<tr><td height='45'><span class="t"><i>*</i>专集封面：</span><span class="button-main"><span><button type="button" onclick="Popsboxif('上传专集封面',470,100,'uppic.php?ac=topic');">上传封面</button></span></span><span class="reg_msg" id="sid_info">请先上传封面。</span></td></tr>
		<tr><td height='45'><span class="t"><i>*</i>专集分区：</span><span class="select"><select name="CS_CID" id="CS_CID" onchange="MM_jumpMenu(this,0)">
<option value="0">--请选择--</option>
<?php 
      $sqlc="select * from ".Getdbname('class')." where CS_FID=0 and CS_SID=1";
      $results=$db->query($sqlc);
	if($results){
	   while ($row1=$db->fetch_array($results)){
             if($row1['CS_ID']==$cid){
                    echo '<option value="'.$row1['CS_ID'].'" selected>'.$row1['CS_Name'].'</option>';
             }else{
                    echo '<option value="'.$row1['CS_ID'].'">'.$row1['CS_Name'].'</option>';
             }
           }
        }
?>
</select></span><span class="reg_msg" id="cid_info">请选择专集的分区。</span></td></tr>
		<tr><td height='45'><span class="t">专集风格：</span><span class="select" id="CS_FG"><select name="CS_FID" id="CS_FID"><?php if($fid==0){echo '<option value="0">--请选择--</option>';}else{echo '<option value="'.$cid.'">'.$classname.'</option>';}?></select></span><span class="reg_msg" id="sid_info">请选择专集的风格，可以留空。</span></td></tr>
		<tr><td height='45'><span class="t"><i>*</i>专集名称：</span><input type="text" class="user_reg_input" id="CS_Name" name="CS_Name" value="<?php echo $name?>"><span class="reg_msg" id="title_info">请输入专集的名称。</span></td></tr>
		<tr><td height='45'><span class="t"><i>*</i>英文名称：</span><input type="text" class="user_reg_input" id="CS_AliasName" name="CS_AliasName" value="<?php echo $yname?>"><span class="reg_msg" id="title_info">请输入专集的英文名称。</span></td></tr>
		<tr><td height='45'><span class="t"><i>*</i>专集标签：</span><input type="text" class="user_reg_input" id="CS_Tags" value="<?php echo $tags?>" name="CS_Tags" style="cursor:hand;" onclick="Popsboxif('选择标签',530,380,'../public/tags.php?f=form.CS_Tags');" readonly/><span class="reg_msg" id="tags_info">多个标签，请用英文逗号隔开。</span></td></tr>
		<tr><td height='45'><span class="t">发行公司：</span><input type="text" class="user_100_input" id="CS_Fxgs" name="CS_Fxgs" value="<?php echo $fxgs?>">
<span class="g">语言：</span>
<span class="select"><select name="CS_Yuyan"><option value="国语" <?php if($yuyan=="国语"){echo 'selected';}?>>国语</option><option value="粤语" <?php if($yuyan=="粤语"){echo 'selected';}?>>粤语</option><option value="英语" <?php if($yuyan=="英语"){echo 'selected';}?>>英语</option><option value="日语" <?php if($yuyan=="日语"){echo 'selected';}?>>日语</option><option value="韩语" <?php if($yuyan=="韩语"){echo 'selected';}?>>韩语</option><option value="其他" <?php if($yuyan=="其他"){echo 'selected';}?>>其他</option></select></span>
<span class="g">地区：</span>
<span class="select"><select name="CS_Diqu"><option value="大陆" <?php if($diqu=="大陆"){echo 'selected';}?>>大陆</option><option value="港台" <?php if($diqu=="港台"){echo 'selected';}?>>港台</option><option value="欧美" <?php if($diqu=="欧美"){echo 'selected';}?>>欧美</option><option value="日韩" <?php if($diqu=="日韩"){echo 'selected';}?>>日韩</option><option value="其他" <?php if($diqu=="其他"){echo 'selected';}?>>其他</option></select></span>
<span class="g">年份：</span><input type="text" class="user_50_input" name="CS_Year" value="<?php echo $year?>" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"></td></tr>
		<tr><td style="clear:both; height:120px;"><span class="t">专集介绍：</span><textarea style="width:450px; height:120px;" id="CS_Content" name="CS_Content"><?php echo $jiesao?></textarea></td></tr>
	</table>
	<div style="padding-top:10px;margin-left:150px;"><span class="button-main"><span><button type="submit" id="adddj" >确定发布</button></span></span><div id="Msg"></div></div>
	</form>

<?php 
}elseif($op=="music"){ 
   $row=$db->getrow("select * from ".Getdbname('topic')." where CS_ID=".$id."");
   if($row){
      $music=$db->getRow("select count(CS_ID) as rc from ".Getdbname('dance')." where CS_TID=".$id."");
      $musicnum=$music['rc'];
      $name=$row['CS_Name'];
   }else{
      $musicnum=0;
      $name='';
   }
?>
				<div class="album_list">
					<div class="album_list_lt">
						<h2>您的已审核歌曲</h2>
						<ol id="ListSongLeft">
<?php
	global $db;
	$sqlw="select * from ".Getdbname('dance')." where cs_yid=0 and cs_user='".$cscms_name."' order by cs_addtime desc";
	$rs=$db->query($sqlw);
	$num=$db->num_rows($rs);
	for($i=0;$i<$num;$i++){
		$row=$db->fetch_array($rs);
           echo '<li><input type="checkbox" name="checkbox" value="'.$row['CS_ID'].'" /><a href="'.LinkUrl('play','dance','id',$row['CS_CID'],$row['CS_ID']).'" target="p" title="'.$row['CS_Name'].'">'.$row['CS_Name'].'</a></li>';
	}
?>
						</ol>
					</div>
					<div class="album_list_md">
						<ul>
							<li><span class="button-main"><span><button type="submit" onclick="clk('addzj','ListSongLeft','<?php echo $id?>');">移进 &gt;&gt;</button></span></span></li>
							<li><span class="button-main"><span><button type="submit" onclick="clk('delzj','ListSongRight','<?php echo $id?>');" >&lt;&lt; 移出</button></span></span></li>
						</ul>
					</div>
					<div class="album_list_rt">
						<h2><?php echo $name?> <span id="count">(<?php echo $musicnum?>首)</span></h2>
						<ol id="ListSongRight">
<?php
	global $db;
	$sqlw="select * from ".Getdbname('dance')." where cs_tid=".$id." order by cs_addtime desc";
	$rs=$db->query($sqlw);
	$num=$db->num_rows($rs);
	for($i=0;$i<$num;$i++){
		$row=$db->fetch_array($rs);
                if($row){
                   echo '<li><input type="checkbox" name="checkbox" value="'.$row['CS_ID'].'" /><a href="'.LinkUrl('play','dance','id',$row['CS_CID'],$row['CS_ID']).'" target="p" title="'.$row['CS_Name'].'">'.$row['CS_Name'].'</a></li>';
                }
	}
?>
						</ol>
					</div>
				</div>


<?php }else{ ?>
			<ul>
			       <li class='<?php if(empty($id)) echo 'nav2a_4';?>'><a href="?ac=topic&op=<?php echo $op?>">全部专集</a></li>
<?php
	global $db;
	$sqlw="select * from ".Getdbname('class')." where cs_sid=1 order by CS_sid desc";
	$rs=$db->query($sqlw);
	$num=$db->num_rows($rs);
	$nums=7;
	if($num<$nums){
		$j=$num;
	}else{
		$j=$nums;
	}
	for($i=0;$i<$j;$i++){
		$rowc=$db->fetch_array($rs);
                if($id==$rowc['CS_ID']){
                      $CSS="nav2a_4";
                }else{
                      $CSS="";
                }
           echo '<li class="'.$CSS.'"><a href="?ac=topic&op='.$op.'&id='.$rowc['CS_ID'].'">'.$rowc["CS_Name"].'</a></li>';
	}
?> 
			</ul>
		</div>
		<div class="album">
<?php
        $j=1;
	$sql="select * from ".Getdbname('topic')." where cs_user='".$cscms_name."'";
        if(!empty($id)) $sql.=' and cs_cid='.$id;
        if($op=='list'){
              $sql.=' and cs_yid=0';
        }else{
              $sql.=' and cs_yid=1';
        }
        $sql.=' order by cs_addtime desc';
		$Arr=getuserpage($sql,"8");//sql,每页显示条数
		$result=$db->query($Arr[2]);
		$numdate="a";
		if($result){
			while ($row = $db ->fetch_array($result)){
		        $numdate="b";
                        $class=$db->getrow("select * from ".Getdbname('class')." where CS_ID=".$row['CS_CID']."");
                        $musicnum=$db->getRow("select count(CS_ID) as rc from ".Getdbname('dance')." where CS_TID=".$row['CS_ID']."");
?>
			<dl>
						
				<dt><div><a href="<?php echo LinkUrl('show','zj','id',$row['CS_CID'],$row['CS_ID'])?>" title="<?php echo $row['CS_Name']?>"><img src="<?php echo piclink('topic',$row['CS_Pic'])?>" width="100" height="100" alt="<?php echo $row['CS_Name']?>" /></a></div></dt>
				<dd>
					<strong><a href="<?php echo LinkUrl('show','zj','id',$row['CS_CID'],$row['CS_ID'])?>"><?php echo $row['CS_Name']?></a></strong><br />
					分类：<?php echo $class['CS_Name']?><br />
					年份：<?php echo $row['CS_Year']?><br />
					歌曲：<?php echo $musicnum['rc']?>首<br />
					更新：<?php echo datetime($row['CS_AddTime'])?><br />
					<a href="?ac=topic&op=music&id=<?php echo $row['CS_ID']?>">加歌</a> | <a href="?ac=topic&op=add&id=<?php echo $row['CS_ID']?>">修改</a> | <a onclick="return confirm('确定要删除吗？');" href="javascript:topicdel(<?php echo $row['CS_ID']?>)">删除</a>
				</dd>
			</dl>
<?php
                        $j=$j+1;
	                }
                }
        if($numdate=="a") echo '<li>没有相关记录!</li>';
?>
		</div>
		<div class="page">
		<div class="pages">
                       <?php echo $Arr[0];?>
                </div>
<?php } ?>
      </div>
      </div>
    <div class="end"></div>
  </div>
