<?php

/*

		用户主题设置

*/

//载入全局配置和函数包
require_once dirname(__FILE__).'/../include/global.php';
require_once(dirname(__FILE__)."/../include/cacher.php");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $_G['product']['charset'];?>" />
<title>更换主题 - Powered By VeryIDE</title>

<?php

echo loader_style(array(VI_BASE."style/dialog.css",VI_BASE."style/ui.css"),$_G['product']['charset'],$_G['product']['version']);

echo loader_script(array(VI_BASE."js/mo.js",VI_BASE."js/mo.ui.js",VI_BASE."js/mo.ajax.js"),"utf-8",$_G['product']['version']);

echo '<script type="text/javascript">'.System :: reader_config().'</script>';

echo loader_script(array(VI_BASE."js/serv.dialog.js",VI_BASE."js/serv.upload.js"),"utf-8",$_G['product']['version']);

?>

</head>

<body>

	<div id="wrapper">
	
	<?php
	
	//菜单处理
	$action = getgpc('action');
	$jump = getgpc('jump');
	
	//连接数据库
	System :: connect();
	
	//动作处理
	switch ($action){
		
		case "update":
			
			//配置
			$config = $_POST['config'];
			$config = format_json( fix_json( $config ) );
				
			//更新数据
			$sql="UPDATE `sys:admin` SET config='".$config."' WHERE id=".$_SESSION['Manager']['id'];			
			System :: $db -> execute( $sql );
			
			//缓存系统用户
			Cached :: table( 'system', 'sys:admin', array( 'jsonde' => array('config') ) );
			
			$_G['project']['message']="成功修改用户偏好!";
			
			echo '<div id="state">你刚刚更改了个人偏好，请刷新查看最新效果：<input name="submit" onclick=\'parent.location.reload(true)\' type="button" class="submit" value="刷新此页面" /></div>';
		
		break;
		
	}
	
	//
	$sql="SELECT * FROM `sys:admin` WHERE id=".$_SESSION['Manager']['id'];
	$row = System :: $db -> getOne( $sql );
	
	if( $row ){
		
		//配置
        	$config = fix_json( $row['config'] );
		
	}else{
		
		$_G['project']['message']="未找到指定用户!";
		
	}
	
	//关闭数据库
	System :: connect();
	
	?>

	<form action="?" method="post">

	<table cellpadding="0" cellspacing="0" class="form">
		<tbody>
		<tr><td colspan="2" class="section"><strong>用户界面</strong></td></tr>
		
		<tr>
		<td width="60"><strong>界面主题：</strong></td>
		<td>
			<label><input type="radio" class="radio" name="config[ui-model]" value="modern">摩登现代</label>
			<label><input type="radio" class="radio" name="config[ui-model]" value="classic">怀旧经典</label>
		</td>
	    </tr>
	    </tbody>
	    
	    <tbody id="adv_classic">
	
		<tr>
		<td width="60"><strong>菜单设置：</strong></td>
		<td>
		    <label><input type="radio" class="radio" name="config[ui-menu]" value="open">全部展开</label>
		    <label><input type="radio" class="radio" name="config[ui-menu]" value="close">全部关闭</label>
		    <label><input type="radio" class="radio" name="config[ui-menu]" value="auto">自动处理</label>
		</td>
	    </tr>
	
		<tr>
		<td><strong>默认风格：</strong></td>
		<td>
		    <label><input type="radio" class="radio" name="config[ui-theme]" value="simple">简洁风格</label>
		    <label><input type="radio" class="radio" name="config[ui-theme]" value="cloud">蓝天白云</label>
		    <label><input type="radio" class="radio" name="config[ui-theme]" value="moving">云彩飘动（动画）</label>
		</td>
	    </tr>
	    
	    </tbody>
	    
	    <tbody id="adv_modern">

		<tr>
			<td><strong>背景图片：</strong></td>
			<td>
				<input name="config[bg-image]" type="hidden" class="text" size="65" value="<?php echo $config["bg-image"];?>" />
		<script type="text/javascript">
		new Serv.Upload("_file_","<?php echo $config["bg-image"];?>",{'format':['<?php echo implode("','",$_G['upload']['image']);?>'],'again':false,'recovery':true,'input':false,'callback':function(o){ Mo("input[name='config[bg-image]']").value(o["value"]); }});
		</script>
			</td>
		</tr>
		
		</tbody>
		
		<tbody>

		<tr><td colspan="2" class="section"><strong>圣诞气氛</strong></td></tr>

		<tr>
			<td width="60"><strong>圣诞帽子：</strong></td>
			<td>
				<label><input type="radio" class="radio" name="config[ui-head]" value="Y">带上帽子</label>
				<label><input type="radio" class="radio" name="config[ui-head]" value="N">不带帽子</label>
			</td>
		</tr>

		<tr>
			<td><strong>雪花效果：</strong></td>
			<td>
				<label><input type="radio" class="radio" name="config[ui-snow]" value="Y">雪花效果</label>
				<label><input type="radio" class="radio" name="config[ui-snow]" value="N">禁用效果</label>
			</td>
		</tr>

		<tr><td colspan="2" class="section"><strong>服务扩展</strong></td></tr>

		<tr>
			<td><strong>云输入法：</strong></td>
			<td>
				<label><input type="radio" class="radio" name="config[ext-input]" value="" />禁用服务</label>

				<label><input type="radio" class="radio" name="config[ext-input]" value="wubi" />五笔输入</label>

				<label><input type="radio" class="radio" name="config[ext-input]" value="pinyin" />拼音输入</label>

				<label><input type="radio" class="radio" name="config[ext-input]" value="yingwen" />英文输入</label>
			</td>
		</tr>
		
		<tr class="nobr">
			<td><strong></strong></td>
			<td>
				<input type="submit" name="Submit" value="保存更改" class="submit" />
				<input type="hidden" name="action" id="action" value="update" />
			</td>
		</tr>
		
		</tbody>

	</table>

	<script type='text/javascript'>
	
		//广告形式
		function doModel(){
			var val = Mo("input[name='config[ui-model]']").value();
			switch( val.toString() ){
				//代码广告
				case 'classic':	
					Mo("#adv_classic").show();
					Mo("#adv_modern").hide();
				break;
				
				//自定义
				case 'modern':
					Mo("#adv_modern").show();
					Mo("#adv_classic").hide();
				break;
			}			
		};		
		
		
		Mo("input[name='config[ui-model]']").bind('click', doModel ).value("<?php echo $config["ui-model"];?>");
		doModel();
		
		Mo("input[name='config[ui-menu]']").value("<?php echo $config["ui-menu"];?>");
		Mo("input[name='config[ui-theme]']").value("<?php echo $config["ui-theme"];?>");
		Mo("input[name='config[ui-effect]']").value("<?php echo $config["ui-effect"];?>");
		
		Mo("input[name='config[ui-head]']").value("<?php echo $config["ui-head"];?>");
		Mo("input[name='config[ui-snow]']").value("<?php echo $config["ui-snow"];?>");
		Mo("input[name='config[ext-input]']").value("<?php echo $config["ext-input"];?>");
		
		//主框架载入事件
		Serv.Manager.Loaded();
	
	</script>

	</form>

	</div>
	
</body>
</html>