<?php
if (! defined ( 'APP_PATH' ) || ! defined ( 'I_PATH' )) {
	exit ( 'Access Denied' );
}

class index extends controllerBase {
	function __construct() {
		parent::__construct ();
		$this->c = syClass ( 'syauser' );
		$this->m = syDB ( 'molds' )->findAll ( array ('isshow' => 1 ), ' orders desc,mid ', 'mid,molds,moldname' );
		$this->funs = syDB ( 'funs' )->findAll ( array ('isshow' => 1 ), null, 'fid,funs,name' );				
		
	}
	function index() {
		$this->display ( "index.html" );
	}
	function headers() {
		$this->a = 'headers';
		$this->display ( "main.html" );
	}
	function main() {
		$this->a = 'main';
		$this->sys = syDB ( 'sysconfig' )->findAll(null,null,'code,value');
		$this->sysconfig_complate = 0;
		foreach ($this->sys as $config)
		{
			if($config['code']=='sysconfig_complate')
			{
				$this->sysconfig_complate=$config['value'];
			}
			if($config['code']=='serviceconfig_compalte')
			{
				$this->serviceconfig_compalte=$config['value'];
			}
			if($config['code']=='set_map')
			{
				$this->set_map=$config['value'];
			}
			if($config['code']=='set_qq')
			{
				$this->set_qq=$config['value'];
			}
			if($config['code']=='set_payment')
			{
				$this->set_payment=$config['value'];
			}
			if($config['code']=='set_logistics')
			{
				$this->set_logistics=$config['value'];
			}
			if($config['code']=='set_phone')
			{
				$this->set_phone=$config['value'];
			}
		}
		$this->display ( "main.html" );
	}
	function left() {
		$this->a = 'left';
		switch ($this->sysParams ( "l", 1 )) {
			case "classtypes" :
				$this->lefttop = '栏目管理';
				if ($this->c->checkgo ( 'ld_classtypes' ))
					$this->leftmenu .= '<li><a href="?c=ld_classtypes" target="main">栏目管理</a></li>';
				if ($this->c->checkgo ( 'ld_classtypes' ))
					$this->leftmenu .= '<li><a href="?c=ld_classtypes&a=add" target="main">添加栏目</a></li>';
				break;
			case "molds" :
				$this->lefttop = '频道管理';
				if ($this->c->checkgo ( 'ld_molds' ))
					$this->leftmenu .= '<li><a href="?c=ld_molds" target="main">频道管理</a></li>';
				//$this->leftmenu .= '<p></p>';
				$this->leftmenu .= '<li><a href="http://www.5545.cn" target="_blank">查看官方更新</a></li>';
				break;
			case "funs" :
				$this->lefttop = '其他管理';
				foreach ( $this->funs as $v ) {
					if ($this->c->checkgo ( 'ld_' . $v ['funs'] ))
						$this->leftmenu .= '<li><a href="admin.php?c=ld_' . $v ['funs'] . '" target="main">' . $v ['name'] . '管理</a></li>';
				}
				if ($this->c->checkgo ( 'ld_funs' ))
					$this->leftmenu .= '<li><a href="?c=ld_funs" target="main">插件安装卸载</a></li>';
				$this->leftmenu .= '<li><a href="http://www.5545.com" target="_blank">查看官方更新</a></li>';
				break;
			case "sys" :
				$this->lefttop = '系统管理';
				if ($this->c->checkgo ( 'ld_sys' ))
					$this->leftmenu .= '<li><a href="?c=ld_sys" target="main">系统设置</a></li>';
				if ($this->c->checkgo ( 'ld_map' ))
					$this->leftmenu .= '<li><a href="?c=ld_map" target="main">公司地图</a></li>';
				if ($this->c->checkgo ( 'ld_map' ))
				if ($this->c->checkgo ( 'ld_map' ))
					$this->leftmenu .= '<li><a href="?c=ld_weibo" target="main">公司微博</a></li>';					
				if ($this->c->checkgo ( 'ld_adminuser' ))
					$this->leftmenu .= '<li><a href="?c=ld_adminuser" target="main">管理员管理</a></li>';
				if ($this->c->checkgo ( 'ld_setting_template' ))
					$this->leftmenu .= '<li><a href="?c=ld_setting_template" target="main">设置模板</a></li>';
				if ($this->c->checkgo ( 'ld_labelcus' ))
					$this->leftmenu .= '<li><a href="?c=ld_labelcus" target="main">自定义模板标签</a></li>';
				if ($this->c->checkgo ( 'ld_labelcus' ))
					$this->leftmenu .= '<li><a href="?c=ld_labelcus&a=custom_index" target="main">自定义页面</a></li>';
				$this->leftmenu .= '<li><a href="?c=ld_label" target="main">模板调用生成器</a></li>';
				//$this->leftmenu .= '<p></p>';
				if ($this->c->checkgo ( 'ld_html' ))
					$this->leftmenu .= '<li><a href="?c=ld_html" target="main">更新静态html</a></li>';
					//$this->leftmenu .= '<p></p>';
				 if ($this->c->checkgo ( 'ld_email' ))
					$this->leftmenu .= '<li><a href="?c=ld_email" target="main">邮件设置</a></li>';
				if ($this->c->checkgo ( 'ld_dbbak' ) || $this->c->checkgo ( 'ld_files' ))
					//$this->leftmenu .= '<p></p>';
				if ($this->c->checkgo ( 'ld_files' ))
					$this->leftmenu .= '<li><a href="?c=ld_files" target="main">清理多余附件</a></li>';
				if ($this->c->checkgo ( 'ld_dbbak' ))
					$this->leftmenu .= '<li><a href="?c=ld_dbbak" target="main">数据备份恢复</a></li>';
				if ($this->c->checkgo ( 'ld_update' ))
					$this->leftmenu .= '<li><a href="?c=ld_update" target="main">在线升级</a></li>';
				//$this->leftmenu .= '<p></p>';
				$this->leftmenu .= '<li><a href="http://www.5545.cn/" target="_blank">求助问答</a></li>';
				break;
			case 'member' :
				$this->lefttop = '会员管理';
				if ($this->c->checkgo ( 'ld_member' ))
					$this->leftmenu .= '<li><a href="?c=ld_member" target="main">会员管理</a></li>';
				if ($this->c->checkgo ( 'ld_member_add' ))
					$this->leftmenu .= '<li><a href="?c=ld_member&a=add" target="main">添加会员</a></li>';
				//$this->leftmenu .= "<p></p>";	
				
				if ($this->c->checkgo ( 'ld_member_glist' ))
					$this->leftmenu .= '<li><a href="?c=ld_member&a=glist" target="main">会员组管理</a></li>';
				if ($this->c->checkgo ( 'ld_member_gadd' ))
					$this->leftmenu .= '<li><a href="?c=ld_member&a=gadd" target="main">添加会员</a></li>';
				//$this->leftmenu .= "<p></p>";
				/*
				if ($this->c->checkgo ( 'ld_member_field' ))
					$this->leftmenu .= '<li><a href="?c=ld_fields&molds=member" target="main">会员字段</a></li>';
					
				*/
				//$this->leftmenu .= "<p></p>";
				if ($this->c->checkgo ( 'ld_member_email' ))
					$this->leftmenu .= '<li><a href="?c=ld_member&a=email" target="main">邮件群发</a></li>';
				break;
			case 'order' :
				$this->lefttop = '订单管理';
				if ($this->c->checkgo ( 'ld_order' ))
					$this->leftmenu .= '<li><a href="?c=ld_order" target="main">订单管理</a></li>';
				if ($this->c->checkgo ( 'ld_payment' ))
					$this->leftmenu .= '<li><a href="?c=ld_payment" target="main">支付方式</a></li>';
				$this->leftmenu .= "<p></p>";
				if ($this->c->checkgo ( 'ld_logistics' ))
					$this->leftmenu .= '<li><a href="?c=ld_logistics" target="main">配送方式</a></li>';
				break;
			case 'field' :
				$this->lefttop = '字段管理';
				if ($this->c->checkgo ( 'ld_field' ))
					$this->leftmenu .= "<li><a href='?c=ld_field' target='main'>字段管理</a></li>";
				break;
			case 'online' :
				$this->lefttop = '在线客服';
				if ($this->c->checkgo ( 'ld_online' ))
					$this->leftmenu .= "<li><a href='?c=ld_online' target='main'>设置客服</a></li>";
				break;
			default :
				$this->lefttop = '内容管理';
				foreach ( $this->m as $v ) {
					if ($v ['molds'] != 'message') {
						if ($this->c->checkgo ( 'ld_' . $v ['molds'], 'add' ))
							$this->leftmenu .= '<li><a href="admin.php?c=ld_' . $v ['molds'] . '&a=add" target="main">添加' . $v ['moldname'] . '</a></li>';
					}
					if ($this->c->checkgo ( 'ld_' . $v ['molds'] . '_', '', 1 ))
						$this->leftmenu .= '<li><a href="admin.php?c=ld_' . $v ['molds'] . '" target="main">' . $v ['moldname'] . '管理</a></li>';
				}
				$this->leftmenu .= '<li><a href="admin.php?c=ld_sys&a=ecache" target="main">更新系统缓存</a></li>';
				break;
		}
		$this->display ( "main.html" );
	}
	function bottom() {
		$this->a = 'bottom';
		$this->display ( "main.html" );
	}

}	