<?php
/*
	[Phpup.Net!] (C)2009-2011 Phpup.net.
	This is NOT a freeware, use is subject to license terms

	$Id: admin.class.php 2010-08-24 10:42 $
*/
if(!defined('IN_PHPUP')) {
	exit('Access Denied');
}
?>
<?php include ROOT_PATH.'/views/admin/header.php';?>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!--
function addsite(id)
{
	url=site_root+"/index.php?con="+adminpath+"&act=othersitemodify";
	$.get(url,{},
	function(data){
		$('#dialog').html(data);
	});
	$('#blurdiv').show();
	$('#blurdiv').height($(document).height());
	$('#dialog').dialog('open');
	$('#dialog').dialog({
		title:'添加网站',
		width: 600,
		height:500,
		buttons: {},
		close:function(){$('#blurdiv').hide();$('#dialog').html('');}
	});
}
function modifycate(id)
{
	url="index.php?con="+adminpath+"&act=othersitemodify&updateid="+id;
		$.get(url,{},
		function(data){
			$('#dialog').html(data);
		});
		$('#blurdiv').show();
		$('#blurdiv').height($(document).height());
		$('#dialog').dialog('open');
		$('#dialog').dialog({
			title:'修改网站',
			width: 600,
			height:500,
			buttons: {},
			close:function(){$('#blurdiv').hide();$('#dialog').html('');}
		});
}
function parseMysitecateData(data)
{
	var objdata=data;
	if(objdata.dotype=='add')
	{
		var  img = objdata.img?'<img src="'+objdata.img+'" height="60px" >':'';
		var  istop =  objdata.istop == 1?"是":"否";
		var  recommend =  objdata.recommend == 1?"是":"否";
		var  sitename  = "<span style='color:"+objdata.color+";"+objdata.font+"'>"+objdata.sitename+"</span>";

		$('#othersite').append('<TR class="tr1" id="othersite'+objdata.id+'"><TD id="sitename-"'+objdata.id+' style="text-align:center;" >'+sitename+'</TD><TD  id="url-"'+objdata.id+' style="text-align:center;" >'+objdata.url+'</TD><TD  id="sort-"'+objdata.id+' style="text-align:center;" >'+objdata.sort+'</TD><TD  id="img-"'+objdata.id+' style="text-align:center;" >'+img+'</TD><TD  id="cate-"'+objdata.id+' style="text-align:center;" >'+objdata.cate+'</TD><TD  id="istop-"'+objdata.id+' style="text-align:center;" >'+istop+'</TD><TD  id="recommend-"'+objdata.id+' style="text-align:center;" >'+recommend+'</TD><td align="center" ><A HREF="javascript:deleteVal(\'catelist\',\''+objdata.id+'\',\'cate'+objdata.id+'\')">删除</A> <a href="javascript:modifycate('+objdata.id+')">修改</a></td></TR>');
		Dialog_close();
	}
	else
	{
		var  img = objdata.img?'<img src="'+objdata.img+'" width="60px" >':'';
		var  istop =  objdata.istop == 1?"是":"否";
		var  recommend =  objdata.recommend == 1?"是":"否";
		var  sitename  = "<span style='color:"+objdata.color+";"+objdata.font+"'>"+objdata.sitename+"</span>";
		$('#sitename-'+objdata.id).html(sitename);
		$('#url-'+objdata.id).html(objdata.url);
		if(img)
		{
			$('#img-'+objdata.id).html(img);
		}
		$('#cate-'+objdata.id).html(objdata.cate);
		$('#sort-'+objdata.id).html(objdata.sort);
		$('#istop-'+objdata.id).html(istop);
		$('#recommend-'+objdata.id).html(recommend);
		Dialog_close();
	}
}
function othersite2othersite()
{

	var boo = confirm('同步数据，会将本地的数据覆盖，您确定这样做吗？')

	if(boo)
	{
		var  url="index.php?con="+adminpath+"&act=othersite2othersite"; 
		$.get(url,function(data){
		
			if(data == "true")
			{
					alert("同步成功！");
					location.reload();
			}else{
					alert("同步失败！");
			}
		});

	}
}

//-->
</SCRIPT>
<div class="subnav">
	<div class="content-menu ib-a blue line-x">
	<a href="javascript:addsite(0);" class="add fb"><em>添加网站</em></a>
	<a href="javascript:othersite2othersite();" class="add fb"><em>服务器同步</em></a>
	</div>
</div>

<form method="post" action="index.php?con=<?php echo $GLOBALS['setting']['adminpath'];?>&act=listothersite"  name="searchform">
<table width="100%" cellspacing="0" class="search-form">
	<tr>
		<td>
			<div class="explain-col">关键字：<INPUT TYPE="text" NAME="keyword" class="input-text" value="<?php  echo $_REQUEST['keyword']; ?>" > 
		    &nbsp;&nbsp;
			分类：<select name="sitecate" id="sitecate"  >
					<option value="0">请选择</option>
					<?php  foreach($GLOBALS['sitecate'] AS $key => $val){  ?>	
					<option value="<?php  echo  $key; ?>" <?php   if($key == $_REQUEST['sitecate']){ echo "selected";  }  ?>  ><?php  echo  $val['sitecatename']; ?></option>
					<?php  }  ?>
				  </select>	
			&nbsp;&nbsp;
			<input type="submit" value="确定"  class="button" >
</div>
		</td>
	</tr>
</table>
</form>
<div class="table-list">
<TABLE cellpadding="1" cellspacing="1" style="width:100%;">
<thead>
<TR>
	<TH>网站名称</TH>
	<TH width="400px">地址</TH>
	<TH>排序</TH>
	<TH>图片</TH>
	<TH width="100px" >分类</TH>
	<TH width="100px" >置顶</TH>
	<TH width="100px" >推荐</TH>
	<TH>操作</TH>
</TR>
</thead>
<tbody  id="othersite">
<tr id="othersite0"><td colspan="3"></td></tr>
<?php foreach($othersite_info['data'] as $key=>$val){?>

<TR class="tr1" id="othersite<?php echo $val['id'];?>">
	<TD id="sitename-<?php echo $val['id'];?>" style="text-align:center;"  >
	 <span  style="color:<?php  echo $val['color'];  ?>;<?php  echo $val['font'];  ?>" ><?php echo $val['sitename'];?></span> 
	</TD>
	<TD id="url-<?php echo $val['id'];?>" style="text-align:center;"  >
	<?php echo $val['url'];?>
	</TD>
	<TD id="sort-<?php echo $val['id'];?>" style="text-align:center;"  >
	<?php echo $val['sort'];?>
	</TD>
	<TD id="img-<?php echo $val['id'];?>" style="text-align:center;"  >
	 <?php if(!empty($val['img'])){?><img src="<?php echo $val['img'];?>"  height="60px" ><?php }?>  
	</TD>
	<TD id="cate-<?php echo $val['id'];?>" style="text-align:center;"  >
		<?php echo $GLOBALS['sitecate'][$val['cate']]['sitecatename'];?>
	</TD>
	<TD id="istop-<?php echo $val['id'];?>"  style="text-align:center;"  >
	<?php echo $val['istop']?"是":"否";?>
	</TD>

	<TD id="recommend-<?php echo $val['id'];?>"  style="text-align:center;"  >
	<?php echo $val['recommend']?"是":"否";?>
	</TD>

	<td width="170px" align="center">
		<a href="javascript:modifycate('<?php echo $val['id'];?>')">修改</a>
		<A HREF="javascript:deleteVal('othersite','<?php echo $val['id'];?>','othersite<?php echo $val['id'];?>','id')">删除</A>
	</td>
</TR>

<?php }?>
</tbody>
</TABLE>
</div>
<div class="pages" style="padding:10px;text-align:center;"><?php echo $othersite_info['pageinfo'];?></div>
<div id="dialog" style="display:none;"><IMG SRC="<?php echo STATIC_ROOT;?>/views/js/i/032.gif" WIDTH="32" HEIGHT="32" BORDER="0" ALT=""></div>
<div style="z-index: 1000; background-color: rgb(0, 0, 0); visibility: visible; display: none; position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px; width:100%;filter:alpha(opacity=50); opacity: 0.5; -moz-opacity:0.5;" id="blurdiv"></div>
</body>
</html>
