郑晓宇 6 anni fa
commit
6a7859eaef
100 ha cambiato i file con 13982 aggiunte e 0 eliminazioni
  1. 10 0
      .gitignore
  2. 8 0
      .htaccess
  3. 30 0
      Application/Admin/Common/function.php
  4. 1 0
      Application/Admin/Common/index.html
  5. 186 0
      Application/Admin/Conf/config.php
  6. 1 0
      Application/Admin/Conf/index.html
  7. 373 0
      Application/Admin/Controller/AdminController.class.php
  8. 184 0
      Application/Admin/Controller/ArticleClassController.class.php
  9. 394 0
      Application/Admin/Controller/ArticleController.class.php
  10. 335 0
      Application/Admin/Controller/BubbleController.class.php
  11. 96 0
      Application/Admin/Controller/CacheController.class.php
  12. 185 0
      Application/Admin/Controller/ClassController.class.php
  13. 331 0
      Application/Admin/Controller/CommonController.class.php
  14. 68 0
      Application/Admin/Controller/ConfigController.class.php
  15. 449 0
      Application/Admin/Controller/CourseController.class.php
  16. 416 0
      Application/Admin/Controller/CultureDecorateController.class.php
  17. 413 0
      Application/Admin/Controller/CultureDecorateTargetTypeController.class.php
  18. 405 0
      Application/Admin/Controller/CultureDecorateTypeController.class.php
  19. 279 0
      Application/Admin/Controller/CultureFoodController.class.php
  20. 241 0
      Application/Admin/Controller/CulturePetController.class.php
  21. 238 0
      Application/Admin/Controller/CulturePetTypeController.class.php
  22. 248 0
      Application/Admin/Controller/CultureSceneBackgroundController.class.php
  23. 234 0
      Application/Admin/Controller/CultureSceneController.class.php
  24. 234 0
      Application/Admin/Controller/CultureUserController.class.php
  25. 378 0
      Application/Admin/Controller/CustomViewController.class.php
  26. 97 0
      Application/Admin/Controller/EmailController.class.php
  27. 526 0
      Application/Admin/Controller/FractionController.class.php
  28. 64 0
      Application/Admin/Controller/IndexController.class.php
  29. 167 0
      Application/Admin/Controller/IntervalController.class.php
  30. 170 0
      Application/Admin/Controller/LinkController.class.php
  31. 235 0
      Application/Admin/Controller/NavFooterController.class.php
  32. 246 0
      Application/Admin/Controller/NavHeaderController.class.php
  33. 461 0
      Application/Admin/Controller/PowerController.class.php
  34. 188 0
      Application/Admin/Controller/RegionController.class.php
  35. 185 0
      Application/Admin/Controller/RoomController.class.php
  36. 167 0
      Application/Admin/Controller/ScoreController.class.php
  37. 167 0
      Application/Admin/Controller/SemesterController.class.php
  38. 70 0
      Application/Admin/Controller/SeoController.class.php
  39. 109 0
      Application/Admin/Controller/SiteController.class.php
  40. 67 0
      Application/Admin/Controller/SmsController.class.php
  41. 625 0
      Application/Admin/Controller/StudentController.class.php
  42. 167 0
      Application/Admin/Controller/SubjectController.class.php
  43. 456 0
      Application/Admin/Controller/TeacherController.class.php
  44. 252 0
      Application/Admin/Controller/ThemeController.class.php
  45. 314 0
      Application/Admin/Controller/UeditorController.class.php
  46. 360 0
      Application/Admin/Controller/UserController.class.php
  47. 573 0
      Application/Admin/Controller/ViewController.class.php
  48. 167 0
      Application/Admin/Controller/WeekController.class.php
  49. 1 0
      Application/Admin/Controller/index.html
  50. 292 0
      Application/Admin/Lang/zh-cn.php
  51. 33 0
      Application/Admin/Lang/zh-cn/admin.php
  52. 27 0
      Application/Admin/Lang/zh-cn/article.php
  53. 15 0
      Application/Admin/Lang/zh-cn/articleclass.php
  54. 15 0
      Application/Admin/Lang/zh-cn/bubble.php
  55. 33 0
      Application/Admin/Lang/zh-cn/cache.php
  56. 15 0
      Application/Admin/Lang/zh-cn/class.php
  57. 14 0
      Application/Admin/Lang/zh-cn/config.php
  58. 34 0
      Application/Admin/Lang/zh-cn/course.php
  59. 30 0
      Application/Admin/Lang/zh-cn/culturedecorate.php
  60. 30 0
      Application/Admin/Lang/zh-cn/culturedecoratetargettype.php
  61. 28 0
      Application/Admin/Lang/zh-cn/culturedecoratetype.php
  62. 33 0
      Application/Admin/Lang/zh-cn/culturefood.php
  63. 29 0
      Application/Admin/Lang/zh-cn/culturepet.php
  64. 27 0
      Application/Admin/Lang/zh-cn/culturepettype.php
  65. 21 0
      Application/Admin/Lang/zh-cn/culturescene.php
  66. 26 0
      Application/Admin/Lang/zh-cn/culturescenebackground.php
  67. 21 0
      Application/Admin/Lang/zh-cn/customview.php
  68. 17 0
      Application/Admin/Lang/zh-cn/email.php
  69. 32 0
      Application/Admin/Lang/zh-cn/fraction.php
  70. 28 0
      Application/Admin/Lang/zh-cn/index.php
  71. 17 0
      Application/Admin/Lang/zh-cn/interval.php
  72. 24 0
      Application/Admin/Lang/zh-cn/link.php
  73. 37 0
      Application/Admin/Lang/zh-cn/navfooter.php
  74. 37 0
      Application/Admin/Lang/zh-cn/navheader.php
  75. 35 0
      Application/Admin/Lang/zh-cn/power.php
  76. 15 0
      Application/Admin/Lang/zh-cn/region.php
  77. 15 0
      Application/Admin/Lang/zh-cn/room.php
  78. 15 0
      Application/Admin/Lang/zh-cn/score.php
  79. 15 0
      Application/Admin/Lang/zh-cn/semester.php
  80. 33 0
      Application/Admin/Lang/zh-cn/seo.php
  81. 448 0
      Application/Admin/Lang/zh-cn/site.php
  82. 14 0
      Application/Admin/Lang/zh-cn/sms.php
  83. 37 0
      Application/Admin/Lang/zh-cn/student.php
  84. 15 0
      Application/Admin/Lang/zh-cn/subject.php
  85. 30 0
      Application/Admin/Lang/zh-cn/teacher.php
  86. 19 0
      Application/Admin/Lang/zh-cn/theme.php
  87. 28 0
      Application/Admin/Lang/zh-cn/user.php
  88. 61 0
      Application/Admin/Lang/zh-cn/view.php
  89. 15 0
      Application/Admin/Lang/zh-cn/week.php
  90. 71 0
      Application/Admin/Model/AdminModel.class.php
  91. 51 0
      Application/Admin/Model/ArticleClassModel.class.php
  92. 90 0
      Application/Admin/Model/ArticleModel.class.php
  93. 64 0
      Application/Admin/Model/ClassModel.class.php
  94. 17 0
      Application/Admin/Model/CommonModel.class.php
  95. 23 0
      Application/Admin/Model/ConfigModel.class.php
  96. 140 0
      Application/Admin/Model/CourseModel.class.php
  97. 52 0
      Application/Admin/Model/CustomViewModel.class.php
  98. 102 0
      Application/Admin/Model/FractionImportModel.class.php
  99. 91 0
      Application/Admin/Model/FractionModel.class.php
  100. 0 0
      Application/Admin/Model/IntervalModel.class.php

+ 10 - 0
.gitignore

@@ -0,0 +1,10 @@
+*.html.php
+.DS_Store
+.ide
+*.log
+Runtime
+Temp
+temp
+Logs
+logs
+*.lock

+ 8 - 0
.htaccess

@@ -0,0 +1,8 @@
+<IfModule mod_rewrite.c>
+  Options +FollowSymlinks
+  RewriteEngine On
+
+  RewriteCond %{REQUEST_FILENAME} !-d
+  RewriteCond %{REQUEST_FILENAME} !-f
+  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
+</IfModule>

+ 30 - 0
Application/Admin/Common/function.php

@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * 模块方法
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+
+/**
+ * [PowerCacheDelete 后台管理员权限缓存数据清除]
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2017-02-26T23:45:26+0800
+ */
+function PowerCacheDelete()
+{
+	$admin = M('Admin')->getField('id', true);
+	if(!empty($admin))
+	{
+		foreach($admin as $id)
+		{
+			S(C('cache_admin_power_key').$id, null);
+			S(C('cache_admin_left_menu_key').$id, null);
+		}
+	}
+}
+?>

+ 1 - 0
Application/Admin/Common/index.html

@@ -0,0 +1 @@
+ 

+ 186 - 0
Application/Admin/Conf/config.php

@@ -0,0 +1,186 @@
+<?php
+
+/**
+ * 模块配置信息
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+
+return array(
+	// 缓存key列表
+	// 权限缓存存储key
+	'cache_admin_power_key'			=>	'cache_admin_power_',
+
+	// 菜单列表
+	'cache_admin_left_menu_key'		=>	'cache_admin_left_menu_',
+
+	// 设置默认的模板主题
+	'DEFAULT_THEME'       			=>	'Default',
+
+	// 百度编辑器配置信息 ueditor
+	'ueditor_config'				=>	array(
+			// 上传图片配置项
+			// 执行上传图片的action名称
+			'imageActionName'			=>	'uploadimage',
+
+			// 提交的图片表单名称
+			'imageFieldName'			=>	'upfile',
+
+			// 上传大小限制,单位B
+			'imageMaxSize'				=>	MyC('home_max_limit_image', 2048000, true),
+
+			// 上传图片格式显示
+			'imageAllowFiles'			=>	array('.png', '.jpg', '.jpeg', '.gif', '.bmp'),
+
+			// 是否压缩图片,默认是true
+			'imageCompressEnable'		=>	true,
+
+			// 图片压缩最长边限制
+			'imageCompressBorder'		=>	1600,
+
+			// 插入的图片浮动方式
+			'imageInsertAlign'			=>	'none',
+
+			// 图片访问路径前缀
+			'imageUrlPrefix'			=>	'',
+
+			// 上传保存路径,可以自定义保存路径和文件名格式 
+			'imagePathFormat'			=>	__ROOT__.'/Public/Upload/'.I('get.path_type', 'Other').'/image/{yyyy}/{mm}/{dd}/{time}{rand:6}',
+
+
+			// 涂鸦图片上传配置项
+			// 执行上传涂鸦的action名称
+			'scrawlActionName'		=>	'uploadscrawl',
+
+			// 提交的图片表单名称
+			'scrawlFieldName'		=>	'upfile',
+
+			// 上传保存路径,可以自定义保存路径和文件名格式
+			'scrawlPathFormat'		=>	__ROOT__.'/Public/Upload/'.I('get.path_type', 'Other').'/scrawl/{yyyy}/{mm}/{dd}/{time}{rand:6}',
+
+			// 上传大小限制,单位B
+			'scrawlMaxSize'			=>	MyC('home_max_limit_image', 2048000, true),
+
+			// 图片访问路径前缀
+			'scrawlUrlPrefix'		=>	'',
+
+			// 插入的图片浮动方式
+			'scrawlInsertAlign'		=>	'none',
+
+
+			// 截图工具上传
+			// 执行上传截图的action名称
+			'snapscreenActionName'	=>	'uploadimage',
+
+			// 上传保存路径,可以自定义保存路径和文件名格式
+			'snapscreenPathFormat'	=>	__ROOT__.'/Public/Upload/'.I('get.path_type', 'Other').'/screenshot/{yyyy}/{mm}/{dd}/{time}{rand:6}',
+
+			// 图片访问路径前缀
+			'snapscreenUrlPrefix'	=>	'',
+
+			// 插入的图片浮动方式
+			'snapscreenInsertAlign'	=>	'none',
+
+
+			// 抓取远程图片配置
+			// 执行抓取远程图片的action名称
+			'catcherLocalDomain'	=>	array('127.0.0.1', 'localhost', 'img.baidu.com'),
+
+			// 执行抓取远程图片的action名称
+			'catcherActionName'		=>	'catchimage',
+
+			// 提交的图片列表表单名称
+			'catcherFieldName'		=>	'source',
+
+			// 上传保存路径,可以自定义保存路径和文件名格式
+			'catcherPathFormat'		=>	__ROOT__.'/Public/Upload/'.I('get.path_type', 'Other').'/catchimage/{yyyy}/{mm}/{dd}/{time}{rand:6}',
+
+			// 图片访问路径前缀
+			'catcherUrlPrefix'		=>	'',
+
+			// 上传大小限制,单位B
+			'catcherMaxSize'		=>	MyC('home_max_limit_image', 2048000, true),
+
+			// 抓取图片格式显示
+			'catcherAllowFiles'		=>	array('.png', '.jpg', '.jpeg', '.gif', '.bmp'),
+
+
+			// 上传视频配置
+			// 执行上传视频的action名称
+			'videoActionName'		=>	'uploadvideo',
+
+			// 提交的视频表单名称
+			'videoFieldName'		=>	'upfile',
+
+			// 上传保存路径,可以自定义保存路径和文件名格式
+			'videoPathFormat'		=>	__ROOT__.'/Public/Upload/'.I('get.path_type', 'Other').'/video/{yyyy}/{mm}/{dd}/{time}{rand:6}',
+
+			// 视频访问路径前缀
+			'videoUrlPrefix'		=>	'',
+
+			// 上传大小限制,单位B,默认100MB
+			'videoMaxSize'			=>	MyC('home_max_limit_video', 102400000, true),
+
+			// 上传视频格式显示
+			'videoAllowFiles'		=>	array('.flv', '.swf', '.mkv', '.avi', '.rm', '.rmvb', '.mpeg', '.mpg', '.ogg', '.ogv', '.mov', '.wmv', '.mp4', '.webm', '.mp3', '.wav', '.mid'), 
+
+			
+			// 上传文件配置
+			// controller里,执行上传视频的action名称
+			'fileActionName'		=>	'uploadfile',
+
+			// 提交的文件表单名称
+			'fileFieldName'			=>	'upfile',
+
+			// 上传保存路径,可以自定义保存路径和文件名格式
+			'filePathFormat'		=>	__ROOT__.'/Public/Upload/'.I('get.path_type', 'Other').'/file/{yyyy}/{mm}/{dd}/{time}{rand:6}',
+
+			// 文件访问路径前缀
+			'fileUrlPrefix'			=>	'',
+
+			// 上传大小限制,单位B,默认50MB
+			'fileMaxSize'			=>	MyC('home_max_limit_file', 51200000, true),
+
+			// 上传文件格式显示
+			'fileAllowFiles'		=>	array('.png', '.jpg', '.jpeg', '.gif', '.bmp', '.flv', '.swf', '.mkv', '.avi', '.rm', '.rmvb', '.mpeg', '.mpg', '.ogg', '.ogv', '.mov', '.wmv', '.mp4', '.webm', '.mp3', '.wav', '.mid','.rar', '.zip', '.tar', '.gz', '.7z', '.bz2', '.cab', '.iso', '.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', '.pdf', '.txt', '.md', '.xml'),
+
+
+			// 列出指定目录下的图片
+			// 执行图片管理的action名称
+			'imageManagerActionName'=>	'listimage',
+
+			// 指定要列出图片的目录
+			'imageManagerListPath'	=>	__ROOT__.'/Public/Upload/'.I('get.path_type', 'Other').'/image/',
+
+			// 每次列出文件数量
+			'imageManagerListSize'	=>	20,
+
+			// 图片访问路径前缀
+			'imageManagerUrlPrefix'	=>	'',
+
+			// 插入的图片浮动方式
+			'imageManagerInsertAlign'=>	'none',
+
+			// 列出的文件类型
+			'imageManagerAllowFiles'=>	array('.png', '.jpg', '.jpeg', '.gif', '.bmp'),
+
+
+			// 列出指定目录下的文件
+			// 执行文件管理的action名称
+			'fileManagerActionName'	=>	'listfile',
+
+			// 指定要列出文件的目录
+			'fileManagerListPath'	=>	__ROOT__.'/Public/Upload/'.I('get.path_type', 'Other').'/file/',
+
+			// 文件访问路径前缀
+			'fileManagerUrlPrefix'	=>	'',
+
+			// 每次列出文件数量
+			'fileManagerListSize'	=>	20,
+
+			// 列出的文件类型
+			'fileManagerAllowFiles'	=>	array('.png', '.jpg', '.jpeg', '.gif', '.bmp', '.flv', '.swf', '.mkv', '.avi', '.rm', '.rmvb', '.mpeg', '.mpg', '.ogg', '.ogv', '.mov', '.wmv', '.mp4', '.webm', '.mp3', '.wav', '.mid','.rar', '.zip', '.tar', '.gz', '.7z', '.bz2', '.cab', '.iso', '.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', '.pdf', '.txt', '.md', '.xml'),
+		),
+);

+ 1 - 0
Application/Admin/Conf/index.html

@@ -0,0 +1 @@
+ 

+ 373 - 0
Application/Admin/Controller/AdminController.class.php

@@ -0,0 +1,373 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 管理员
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class AdminController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+	}
+
+	/**
+     * [Index 管理员列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 登录校验
+		$this->Is_Login();
+		
+		// 权限校验
+		$this->Is_Power();
+
+		// 参数
+		$param = array_merge($_POST, $_GET);
+
+		// 模型对象
+		$m = M('Admin');
+
+		// 条件
+		$where = $this->GetIndexWhere();
+
+		// 分页
+		$number = MyC('admin_page_number');
+		$page_param = array(
+				'number'	=>	$number,
+				'total'		=>	$m->where($where)->count(),
+				'where'		=>	$param,
+				'url'		=>	U('Admin/Admin/Index'),
+			);
+		$page = new \My\Page($page_param);
+
+		// 获取管理员列表
+		$list = $m->field(array('id', 'username', 'mobile', 'gender', 'login_total', 'login_time', 'add_time'))->where($where)->limit($page->GetPageStarNumber(), $number)->select();
+		
+		$role = M('Role')->field(array('id', 'name'))->where(array('is_enable'=>1))->select();
+		$this->assign('role', $role);
+		$this->assign('param', $param);
+		$this->assign('page_html', $page->GetPageHtml());
+		$this->assign('list', $list);
+		$this->display('Index');
+	}
+
+	/**
+	 * [GetIndexWhere 管理员列表条件]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T22:16:29+0800
+	 */
+	private function GetIndexWhere()
+	{
+		$where = array();
+		if(!empty($_REQUEST['username']))
+		{
+			$where['username'] = array('like', '%'.I('username').'%');
+		}
+		$role_id = empty($_REQUEST['role_id']) ? 0 : intval(I('role_id'));
+		if($role_id > 0)
+		{
+			$where['role_id'] = $role_id;
+		}
+		return $where;
+	}
+
+	/**
+     * [SaveInfo 管理员添加/编辑页面]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function SaveInfo()
+	{
+		// 登录校验
+		$this->Is_Login();
+
+		// 不是操作自己的情况下
+		if(I('id') != $this->admin['id'])
+		{
+			// 权限校验
+			$this->Is_Power();
+		}
+
+		// 用户编辑
+		$id = I('id');
+		if($id > 0)
+		{
+			$user =  M('Admin')->where(array('id'=>$id))->field(array('id', 'username', 'mobile', 'gender', 'role_id'))->find();
+			if(empty($user))
+			{
+				$this->error(L('login_username_no_exist'), U('Admin/Index/Index'));
+			}
+			$this->assign('data', $user);
+		}
+
+		$role = M('Role')->field(array('id', 'name'))->where(array('is_enable'=>1, 'id'=>array('gt', 1)))->select();
+		$this->assign('role', $role);
+		$this->assign('id', $id);
+		$this->assign('common_gender_list', L('common_gender_list'));
+		$this->display('SaveInfo');
+	}
+
+	/**
+     * [Save 管理员添加/编辑]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-07T21:58:19+0800
+     */
+	public function Save()
+	{
+		// 登录校验
+		$this->Is_Login();
+
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 不是操作自己的情况下
+		if(I('id') != $this->admin['id'])
+		{
+			// 权限校验
+			$this->Is_Power();
+		}
+
+		// id为空则表示是新增
+		if(empty($_POST['id']))
+		{
+			$this->AdminAdd();
+		} else {
+			$this->AdminEdit();
+		}
+	}
+
+	/**
+	 * [AdminAdd 管理员添加]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-24T22:44:28+0800
+	 */
+	private function AdminAdd()
+	{
+		$m = D('Admin');
+		if($m->create($_POST, 1))
+		{
+			// 额外数据处理
+			$m->login_salt	=	GetNumberCode(6);
+			$m->login_pwd 	=	LoginPwdEncryption($m->login_pwd, $m->login_salt);
+			$m->add_time	=	time();
+			
+			// 写入数据库
+			if($m->add())
+			{
+				$this->ajaxReturn(L('common_operation_add_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_add_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [AdminEdit 管理员编辑]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-24T22:46:03+0800
+	 */
+	private function AdminEdit()
+	{
+		$m = D('Admin');
+		if($m->create($_POST, 2))
+		{
+			// 不能修改自身所属角色组
+			if(I('id') == $this->admin['id'])
+			{
+				unset($m->role_id);
+			}
+
+			// 有密码,则更新密码
+			if(!empty($_POST['login_pwd']))
+			{
+				$m->login_salt	=	GetNumberCode(6);
+				$m->login_pwd 	=	LoginPwdEncryption($m->login_pwd, $m->login_salt);
+			} else {
+				unset($m->login_pwd);
+			}
+
+			// 移除username,不允许更新用户名
+			unset($m->username);
+
+			// 更新数据库
+			if($m->where(array('id'=>I('id')))->save())
+			{
+				// 编辑自身则退出重新登录
+				if(!empty($_POST['login_pwd']) && I('id') == $this->admin['id'])
+				{
+					session_destroy();
+				}
+
+				$this->ajaxReturn(L('common_operation_edit_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_edit_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [Delete 管理员删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-09T21:13:47+0800
+	 */
+	public function Delete()
+	{
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		$m = D('Admin');
+		if($m->create($_POST, 5))
+		{
+			if($m->delete($id))
+			{
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [LoginInfo 登录页面]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-03T12:55:53+0800
+     */
+	public function LoginInfo()
+	{
+		// 是否已登录
+		if(!empty($_SESSION['admin']))
+		{
+			redirect(U('Admin/Index/Index'));
+		}
+
+		$this->display('LoginInfo');
+	}
+
+	/**
+	 * [Login 管理员登录]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T21:46:49+0800
+	 */
+	public function Login()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 登录业务处理
+		$m = D('Admin');
+		if($m->create($_POST, 4))
+		{
+			// 获取管理员
+			$user = $m->field(array('id', 'username', 'login_pwd', 'login_salt', 'mobile', 'login_total', 'role_id'))->where(array('username'=>I('username')))->find();
+			if(empty($user))
+			{
+				$this->ajaxReturn(L('login_username_no_exist'), -2);
+			}
+
+			// 密码校验
+			$login_pwd = LoginPwdEncryption(I('login_pwd'), $user['login_salt']);
+			if($login_pwd != $user['login_pwd'])
+			{
+				$this->ajaxReturn(L('login_login_pwd_error'), -3);
+			}
+
+			// 校验成功
+			// session存储
+			unset($user['login_pwd'], $user['login_salt']);
+			$_SESSION['admin'] = $user;
+
+			// 返回数据,更新数据库
+			if(!empty($_SESSION['admin']))
+			{
+				$login_salt = GetNumberCode(6);
+				$data = array(
+						'login_salt'	=>	$login_salt,
+						'login_pwd'		=>	LoginPwdEncryption(I('login_pwd'), $login_salt),
+						'login_total'	=>	$user['login_total']+1,
+						'login_time'	=>	time(),
+					);
+				if($m->where(array('id'=>$user['id']))->save($data))
+				{
+					// 清空缓存目录下的数据
+					EmptyDir(C('DATA_CACHE_PATH'));
+
+					$this->ajaxReturn(L('login_login_success'));
+				}
+			}
+
+			// 失败
+			unset($_SESSION['admin']);
+			$this->ajaxReturn(L('login_login_error'), -100);
+		} else {
+			// 自动验证失败
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [Logout 退出]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-05T14:31:23+0800
+	 */
+	public function Logout()
+	{
+		session_destroy();
+		redirect(U('Admin/Admin/LoginInfo'));
+	}
+}
+?>

+ 184 - 0
Application/Admin/Controller/ArticleClassController.class.php

@@ -0,0 +1,184 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 文章分类管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class ArticleClassController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 文章分类列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		$this->assign('common_is_enable_list', L('common_is_enable_list'));
+		$this->display('Index');
+	}
+
+	/**
+	 * [GetNodeSon 获取节点子列表]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T15:19:45+0800
+	 */
+	public function GetNodeSon()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 获取数据
+		$field = array('id', 'name', 'sort', 'is_enable');
+		$data = M('ArticleClass')->field($field)->where(array('pid'=>intval(I('id', 0))))->select();
+		if(!empty($data))
+		{
+			foreach($data as $k=>$v)
+			{
+				$data[$k]['is_son']		=	$this->IsExistSon($v['id']);
+				$data[$k]['ajax_url']	=	U('Admin/ArticleClass/GetNodeSon', array('id'=>$v['id']));
+				$data[$k]['delete_url']	=	U('Admin/ArticleClass/Delete');
+				$data[$k]['json']		=	json_encode($v);
+			}
+		}
+		$msg = empty($data) ? L('common_not_data_tips') : L('common_operation_success');
+		$this->ajaxReturn($msg, 0, $data);
+	}
+
+	/**
+	 * [IsExistSon 节点是否存在子数据]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T15:22:47+0800
+	 * @param    [int]    $id [节点id]
+	 * @return   [string]     [有数据ok, 则no]
+	 */
+	private function IsExistSon($id)
+	{
+		if(!empty($id))
+		{
+			return (M('ArticleClass')->where(array('pid'=>$id))->count() > 0) ? 'ok' : 'no';
+		}
+		return 'no';
+	}
+
+	/**
+	 * [Save 文章分类保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// id为空则表示是新增
+		$m = D('ArticleClass');
+
+		// 公共额外数据处理
+		$m->sort 	=	intval(I('sort'));
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			if($m->create($_POST, 1))
+			{
+				// 额外数据处理
+				$m->add_time	=	time();
+				$m->name 		=	I('name');
+				
+				// 写入数据库
+				if($m->add())
+				{
+					$this->ajaxReturn(L('common_operation_add_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_add_error'), -100);
+				}
+			}
+		} else {
+			// 编辑
+			if($m->create($_POST, 2))
+			{
+				// 额外数据处理
+				$m->name 		=	I('name');
+
+				// 移除 id
+				unset($m->id);
+
+				// 更新数据库
+				if($m->where(array('id'=>I('id')))->save())
+				{
+					$this->ajaxReturn(L('common_operation_edit_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_edit_error'), -100);
+				}
+			}
+		}
+		$this->ajaxReturn($m->getError(), -1);
+	}
+
+	/**
+	 * [Delete 文章分类删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function Delete()
+	{
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		$m = D('ArticleClass');
+		if($m->create($_POST, 5))
+		{
+			if($m->delete(I('id')))
+			{
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+}
+?>

+ 394 - 0
Application/Admin/Controller/ArticleController.class.php

@@ -0,0 +1,394 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 文章管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class ArticleController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 文章列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 参数
+		$param = array_merge($_POST, $_GET);
+
+		// 模型对象
+		$m = M('Article');
+
+		// 条件
+		$where = $this->GetIndexWhere();
+
+		// 分页
+		$number = MyC('admin_page_number');
+		$page_param = array(
+				'number'	=>	$number,
+				'total'		=>	$m->where($where)->count(),
+				'where'		=>	$param,
+				'url'		=>	U('Admin/Article/Index'),
+			);
+		$page = new \My\Page($page_param);
+
+		// 获取列表
+		$list = $this->SetDataHandle($m->where($where)->limit($page->GetPageStarNumber(), $number)->order('id desc')->select());
+
+		// 是否启用
+		$this->assign('common_is_enable_list', L('common_is_enable_list'));
+
+		// 文章分类
+		$this->assign('article_class_list', M('ArticleClass')->field(array('id', 'name'))->where(array('is_enable'=>1))->select());
+
+		// 参数
+		$this->assign('param', $param);
+
+		// 分页
+		$this->assign('page_html', $page->GetPageHtml());
+
+		// 数据列表
+		$this->assign('list', $list);
+
+		// Excel地址
+		$this->assign('excel_url', U('Admin/Article/ExcelExport', $param));
+
+		$this->display('Index');
+	}
+
+	/**
+	 * [ExcelExport excel文件导出]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-10T15:46:00+0800
+	 */
+	public function ExcelExport()
+	{
+		// 条件
+		$where = $this->GetIndexWhere();
+
+		// 读取数据
+		$data = $this->SetDataHandle(M('Article')->where($where)->select());
+
+		// Excel驱动导出数据
+		$excel = new \My\Excel(array('filename'=>'article', 'title'=>L('excel_article_title_list'), 'data'=>$data, 'msg'=>L('common_not_data_tips')));
+		$excel->Export();
+	}
+
+	/**
+	 * [SetDataHandle 数据处理]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-29T21:27:15+0800
+	 * @param    [array]      $data [文章数据]
+	 * @return   [array]            [处理好的数据]
+	 */
+	private function SetDataHandle($data)
+	{
+		if(!empty($data))
+		{
+			$ac = M('ArticleClass');
+			foreach($data as $k=>$v)
+			{
+				// 时间
+				$data[$k]['add_time'] = date('Y-m-d H:i:s', $v['add_time']);
+				$data[$k]['upd_time'] = date('Y-m-d H:i:s', $v['upd_time']);
+
+				// 是否启用
+				$data[$k]['is_enable_text'] = L('common_is_enable_list')[$v['is_enable']]['name'];
+
+				// 文章分类
+				$data[$k]['article_class_name'] = $ac->where(array('id'=>$v['article_class_id']))->getField('name');
+
+				// url
+				$data[$k]['url'] = str_replace('admin.php', 'index.php', U('Home/Article/Index', array('id'=>$v['id'])));
+			}
+		}
+		return $data;
+	}
+
+	/**
+	 * [GetIndexWhere 文章列表条件]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T22:16:29+0800
+	 */
+	private function GetIndexWhere()
+	{
+		$where = array();
+
+		// 模糊
+		if(!empty($_REQUEST['keyword']))
+		{
+			$where[] = array(
+					'title'		=>	array('like', '%'.I('keyword').'%'),
+				);
+		}
+
+		// 是否更多条件
+		if(I('is_more', 0) == 1)
+		{
+			// 等值
+			if(I('is_enable', -1) > -1)
+			{
+				$where['is_enable'] = intval(I('is_enable', 1));
+			}
+			if(I('article_class_id', -1) > -1)
+			{
+				$where['article_class_id'] = intval(I('article_class_id'));
+			}
+
+			// 表达式
+			if(!empty($_REQUEST['time_start']))
+			{
+				$where['add_time'][] = array('gt', strtotime(I('time_start')));
+			}
+			if(!empty($_REQUEST['time_end']))
+			{
+				$where['add_time'][] = array('lt', strtotime(I('time_end')));
+			}
+		}
+		return $where;
+	}
+
+	/**
+	 * [SaveInfo 文章添加/编辑页面]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:37:02+0800
+	 */
+	public function SaveInfo()
+	{
+		// 文章信息
+		if(empty($_REQUEST['id']))
+		{
+			$data = array();
+		} else {
+			$data = M('Article')->find(I('id'));
+			if(!empty($data['content']))
+			{
+				// 静态资源地址处理
+				$data['content'] = ContentStaticReplace($data['content'], 'get');
+			}
+		}
+		$this->assign('data', $data);
+
+		// 是否启用
+		$this->assign('common_is_enable_list', L('common_is_enable_list'));
+
+		// 文章分类
+		$this->assign('article_class_list', M('ArticleClass')->field(array('id', 'name'))->where(array('is_enable'=>1))->select());
+
+		$this->display('SaveInfo');
+	}
+
+	/**
+	 * [Save 文章添加/编辑]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:37:02+0800
+	 */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			$this->Add();
+
+		// 编辑
+		} else {
+			$this->Edit();
+		}
+	}
+
+	/**
+	 * [Add 文章添加]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-18T16:20:59+0800
+	 */
+	private function Add()
+	{
+		// 文章模型
+		$m = D('Article');
+
+		// 数据自动校验
+		if($m->create($_POST, 1))
+		{
+			// 额外数据处理
+			$m->add_time	=	time();
+			$m->upd_time	=	time();
+			$m->title 		=	I('title');
+			
+			// 静态资源地址处理
+			$m->content 	=	ContentStaticReplace($m->content, 'add');
+
+			// 正则匹配文章图片
+			$temp_image		=	$this->MatchContentImage($m->content);
+			$m->image 		=	serialize($temp_image);
+			$m->image_count	=	count($temp_image);
+			
+			// 数据添加
+			if($m->add())
+			{
+				$this->ajaxReturn(L('common_operation_add_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_add_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [Edit 文章编辑]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-17T22:13:40+0800
+	 */
+	private function Edit()
+	{
+		// 文章模型
+		$m = D('Article');
+
+		// 数据自动校验
+		if($m->create($_POST, 2))
+		{
+			// 额外数据处理
+			$m->upd_time	=	time();
+			$m->title 		=	I('title');
+
+			// 静态资源地址处理
+			$m->content 	=	ContentStaticReplace($m->content, 'add');
+
+			// 正则匹配文章图片
+			$temp_image		=	$this->MatchContentImage($m->content);
+			$m->image 		=	serialize($temp_image);
+			$m->image_count	=	count($temp_image);
+
+			// 数据更新
+			if($m->where(array('id'=>I('id')))->save())
+			{
+				$this->ajaxReturn(L('common_operation_edit_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_edit_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [MatchContentImage 正则匹配文章图片]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-22T18:06:53+0800
+	 * @param    [string]         $content [文章内容]
+	 * @return   [array]    			   [文章图片数组(一维)]
+	 */
+	private function MatchContentImage($content)
+	{
+		if(!empty($content))
+		{
+			$pattern = '/<img.*?src=[\'|\"](\/Public\/Upload\/Article\/image\/.*?[\.gif|\.jpg|\.jpeg|\.png|\.bmp])[\'|\"].*?[\/]?>/';
+			preg_match_all($pattern, $content, $match);
+			return empty($match[1]) ? array() : $match[1];
+		}
+		return array();
+	}
+
+	/**
+	 * [Delete 文章删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-15T11:03:30+0800
+	 */
+	public function Delete()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 删除数据
+		if(!empty($_POST['id']))
+		{
+			// 更新
+			if(M('Article')->delete(I('id')))
+			{
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+	}
+
+	/**
+	 * [StateUpdate 状态更新]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-12T22:23:06+0800
+	 */
+	public function StateUpdate()
+	{
+		// 参数
+		if(empty($_POST['id']) || !isset($_POST['state']))
+		{
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+
+		// 数据更新
+		if(M('Article')->where(array('id'=>I('id')))->save(array('is_enable'=>I('state'))))
+		{
+			$this->ajaxReturn(L('common_operation_edit_success'));
+		} else {
+			$this->ajaxReturn(L('common_operation_edit_error'), -100);
+		}
+	}
+}
+?>

+ 335 - 0
Application/Admin/Controller/BubbleController.class.php

@@ -0,0 +1,335 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 冒泡管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2017-03-02T22:48:35+0800
+ */
+class BubbleController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-03-02T22:48:35+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+	 * [Index 冒泡]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-03-02T22:48:35+0800
+	 */
+	public function Index()
+	{
+		// 参数
+		$param = array_merge($_POST, $_GET);
+
+		// 条件
+		$where = $this->GetIndexWhere();
+
+		// 模型
+		$m = M('Mood');
+
+		// 分页
+		$number = MyC('admin_page_number');
+		$page_param = array(
+				'number'	=>	$number,
+				'total'		=>	$m->alias('m')->join('__USER__ AS u ON m.user_id=u.id')->where($where)->count(),
+				'where'		=>	$param,
+				'url'		=>	U('Admin/Bubble/Index'),
+			);
+		$page = new \My\Page($page_param);
+
+		// 查询字段
+		$field = array('m.id', 'm.user_id', 'm.content', 'm.visible', 'm.add_time', 'u.nickname');
+
+		// 数据处理
+		$data = $this->MoodDataHandle($m->alias('m')->join('__USER__ AS u ON m.user_id=u.id')->field($field)->where($where)->limit($page->GetPageStarNumber(), $number)->order('m.id desc')->select());
+		$this->assign('data', $data);
+
+		// 分页
+		$this->assign('page_html', $page->GetPageHtml());
+
+		// 参数
+		$this->assign('param', $param);
+
+		// 基础数据
+		$this->assign('common_user_visible_list', L('common_user_visible_list'));
+		$this->assign('bubble_nav_list', L('bubble_nav_list'));
+
+		$this->display('Index');
+	}
+
+	/**
+	 * [GetIndexWhere 条件]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T22:16:29+0800
+	 */
+	private function GetIndexWhere()
+	{
+		$where = array();
+
+		// 模糊
+		if(!empty($_REQUEST['keyword']))
+		{
+			$like_keyword = array('like', '%'.I('keyword').'%');
+			$where[] = array(
+					'u.nickname'		=>	$like_keyword,
+					'u.mobile'			=>	$like_keyword,
+					'u.email'			=>	$like_keyword,
+					'm.content'			=>	$like_keyword,
+					'_logic'			=>	'or',
+				);
+		}
+
+		// 是否更多条件
+		if(I('is_more', 0) == 1)
+		{
+			// 表达式
+			if(!empty($_REQUEST['time_start']))
+			{
+				$where['m.add_time'][] = array('gt', strtotime(I('time_start')));
+			}
+			if(!empty($_REQUEST['time_end']))
+			{
+				$where['m.add_time'][] = array('lt', strtotime(I('time_end')));
+			}
+		}
+		return $where;
+	}
+
+	/**
+	 * [MoodDataHandle 说说数据处理]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-04-08T20:14:19+0800
+	 * @param    [array]     $data [需要处理的数据]
+	 * @return   [array]           [处理好的说说数据]
+	 */
+	private function MoodDataHandle($data)
+	{
+		if(!empty($data) && is_array($data))
+		{
+			$mp = M('MoodPraise');
+			$mc = M('MoodComments');
+			foreach($data as $k=>&$v)
+			{
+				// 昵称
+				if(empty($v['nickname']))
+				{
+					$v['nickname'] = L('common_bubble_mood_nickname');
+				}
+
+				// 发表时间
+				$v['add_time'] = date('m-d H:i', $v['add_time']);
+
+				// 点赞
+				$v['praise_count'] = $mp->where(array('mood_id'=>$v['id']))->count();
+				$v['praise_list'] = $mp->alias('mp')->join('__USER__ AS u ON u.id=mp.user_id')->field(array('mp.id', 'mp.add_time', 'u.nickname'))->where(array('mp.mood_id'=>$v['id']))->order('id desc')->select();
+
+				// 评论总数
+				$v['comments_count'] = $mc->where(array('mood_id'=>$v['id']))->count();
+
+				// 评论列表
+				$v['comments'] = $this->GetMoodComments($v['id']);
+			}
+		}
+		return $data;
+	}
+
+	/**
+	 * [GetMoodComments 获取说说评论]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-04-10T14:38:00+0800
+	 * @param    [int]       $mood_id [说说id]
+	 * @return   [array]              [评论列表]
+	 */
+	private function GetMoodComments($mood_id)
+	{
+		if(empty($mood_id))
+		{
+			return array();
+		}
+
+		// 评论列表
+		$m = M('MoodComments');
+		$field = array('mc.id', 'mc.user_id', 'mc.content', 'mc.reply_id', 'mc.add_time', 'u.nickname');
+		$where = array('m.id'=>$mood_id, 'mc.reply_id'=>0);
+		$data = $m->alias('mc')->join('__MOOD__ AS m ON mc.mood_id=m.id')->join('__USER__ AS u ON mc.user_id=u.id')->field($field)->where($where)->order('mc.id asc')->select();
+
+		// 回复列表
+		if(!empty($data))
+		{
+			$u = M('User');
+			foreach($data as &$v)
+			{
+				// 评论时间
+				$v['add_time'] = date('m-d H:i', $v['add_time']);
+
+				// 评论内容
+				$v['content'] = str_replace("\n", "<br />", $v['content']);
+
+				$item_where = array('m.id'=>$mood_id, 'mc.parent_id'=>$v['id'], 'reply_id'=>array('gt', 0));
+				$item = $m->alias('mc')->join('__MOOD__ AS m ON mc.mood_id=m.id')->join('__USER__ AS u ON mc.user_id=u.id')->field($field)->where($item_where)->order('mc.id asc')->select();
+				if(!empty($item))
+				{
+					foreach($item as &$vs)
+					{
+						// 评论时间
+						$vs['add_time'] = date('m-d H:i', $vs['add_time']);
+
+						// 评论内容
+						$vs['content'] = str_replace("\n", "<br />", $vs['content']);
+
+						// 被回复的用户
+						if($vs['reply_id'] > 0)
+						{
+							$uid = $m->where(array('id'=>$vs['reply_id']))->getField('user_id');
+							if(!empty($uid))
+							{
+								$user = $u->field(array('id AS reply_user_id', 'nickname AS reply_nickname'))->find($uid);
+								if(empty($user['reply_nickname']))
+								{
+									$user['reply_nickname'] = L('common_bubble_mood_nickname');
+								}
+								$vs = array_merge($vs, $user);
+							}
+						}
+					}
+					$v['item'] = $item;
+				}
+			}
+		}
+		return $data;
+	}
+
+	/**
+	 * [MoodDelete 说说删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function MoodDelete()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 参数
+		$m = M('Mood');
+		$id = I('id');
+
+		// 开启事务
+		$m->startTrans();
+
+		// 数据删除[说说,点赞,评论]
+		$mood_state = $m->where(array('id'=>$id))->delete();
+		$praise_state = M('MoodPraise')->where(array('mood_id'=>$id))->delete();
+		$comments_state = M('MoodComments')->where(array('mood_id'=>$id))->delete();
+		if($mood_state !== false && $praise_state !== false && $comments_state !== false)
+		{
+			// 提交事务
+			$m->commit();
+
+			$this->ajaxReturn(L('common_operation_delete_success'));
+		} else {
+			// 回滚事务
+			$m->rollback();
+
+			$this->ajaxReturn(L('common_operation_delete_error'), -100);
+		}
+	}
+
+	/**
+	 * [MoodPraiseDelete 说说点赞删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function MoodPraiseDelete()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 数据删除
+		if(M('MoodPraise')->delete(I('id')))
+		{
+			$this->ajaxReturn(L('common_operation_delete_success'));
+		} else {
+			$this->ajaxReturn(L('common_operation_delete_error'), -100);
+		}
+	}
+
+	/**
+	 * [MoodCommentsDelete 说说评论删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function MoodCommentsDelete()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 参数
+		$id = I('id');
+
+		// 模型
+		$m = M('MoodComments');
+
+		// 开启事务
+		$m->startTrans();
+
+		// 数据删除
+		$state = $m->where(array('id'=>$id))->delete();
+		$item_state = $m->where(array('parent_id'=>$id))->delete();
+		$reply_state = $m->where(array('reply_id'=>$id))->delete();
+		if($state !== false && $item_state !== false && $reply_state !== false)
+		{
+			// 提交事务
+			$m->commit();
+
+			$this->ajaxReturn(L('common_operation_delete_success'));
+		} else {
+			// 回滚事务
+			$m->rollback();
+
+			$this->ajaxReturn(L('common_operation_delete_error'), -100);
+		}
+	}
+}
+?>

+ 96 - 0
Application/Admin/Controller/CacheController.class.php

@@ -0,0 +1,96 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 缓存管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class CacheController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+	 * [Index 首页]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-02-26T19:13:29+0800
+	 */
+	public function Index()
+	{
+		$this->assign('cache_type_list', L('cache_type_list'));
+		$this->display('Index');
+	}
+
+	/**
+	 * [SiteUpdate 站点缓存更新]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-02-26T19:53:14+0800
+	 */
+	public function SiteUpdate()
+	{
+		// 后台
+		S(C('cache_common_my_config_key'), null);
+		S(C('cache_common_timezone_key'), null);
+		S(C('cache_common_home_nav_header_key'), null);
+		S(C('cache_common_home_nav_footer_key'), null);
+		S(C('cache_common_default_theme_key'), null);
+		PowerCacheDelete();
+
+		// 前台
+		S(C('cache_home_channel_key'), null);
+
+		$this->success(L('common_operation_update_success'));
+	}
+
+	/**
+	 * [TemplateUpdate 模板缓存更新]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-02-26T19:53:14+0800
+	 */
+	public function TemplateUpdate()
+	{
+		// 模板 Cache
+		DelDirFile(CACHE_PATH);
+
+		$this->success(L('common_operation_update_success'));
+	}
+
+	/**
+	 * [ModuleUpdate 模块缓存更新]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-02-26T19:53:14+0800
+	 */
+	public function ModuleUpdate()
+	{
+		$this->success(L('common_operation_update_success'));
+	}
+}
+?>

+ 185 - 0
Application/Admin/Controller/ClassController.class.php

@@ -0,0 +1,185 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 班级管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class ClassController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 班级列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		$this->assign('list', M('Class')->field(array('id', 'name'))->where(array('pid'=>0))->select());
+		$this->assign('common_is_enable_list', L('common_is_enable_list'));
+		$this->display('Index');
+	}
+
+	/**
+	 * [GetNodeSon 获取节点子列表]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T15:19:45+0800
+	 */
+	public function GetNodeSon()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 获取数据
+		$field = array('id', 'pid', 'name', 'sort', 'is_enable');
+		$data = M('Class')->field($field)->where(array('pid'=>intval(I('id', 0))))->select();
+		if(!empty($data))
+		{
+			foreach($data as $k=>$v)
+			{
+				$data[$k]['is_son']		=	$this->IsExistSon($v['id']);
+				$data[$k]['ajax_url']	=	U('Admin/Class/GetNodeSon', array('id'=>$v['id']));
+				$data[$k]['delete_url']	=	U('Admin/Class/Delete');
+				$data[$k]['json']		=	json_encode($v);
+			}
+		}
+		$msg = empty($data) ? L('common_not_data_tips') : L('common_operation_success');
+		$this->ajaxReturn($msg, 0, $data);
+	}
+
+	/**
+	 * [IsExistSon 节点是否存在子数据]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T15:22:47+0800
+	 * @param    [int]    $id [节点id]
+	 * @return   [string]     [有数据ok, 则no]
+	 */
+	private function IsExistSon($id)
+	{
+		if(!empty($id))
+		{
+			return (M('Class')->where(array('pid'=>$id))->count() > 0) ? 'ok' : 'no';
+		}
+		return 'no';
+	}
+
+	/**
+	 * [Save 班级保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// id为空则表示是新增
+		$m = D('Class');
+
+		// 公共额外数据处理
+		$m->sort 	=	intval(I('sort'));
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			if($m->create($_POST, 1))
+			{
+				// 额外数据处理
+				$m->add_time	=	time();
+				$m->name 		=	I('name');
+				
+				// 写入数据库
+				if($m->add())
+				{
+					$this->ajaxReturn(L('common_operation_add_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_add_error'), -100);
+				}
+			}
+		} else {
+			// 编辑
+			if($m->create($_POST, 2))
+			{
+				// 额外数据处理
+				$m->name 		=	I('name');
+
+				// 移除 id
+				unset($m->id);
+
+				// 更新数据库
+				if($m->where(array('id'=>I('id')))->save())
+				{
+					$this->ajaxReturn(L('common_operation_edit_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_edit_error'), -100);
+				}
+			}
+		}
+		$this->ajaxReturn($m->getError(), -1);
+	}
+
+	/**
+	 * [Delete 班级删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function Delete()
+	{
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		$m = D('Class');
+		if($m->create($_POST, 5))
+		{
+			if($m->delete(I('id')))
+			{
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+}
+?>

+ 331 - 0
Application/Admin/Controller/CommonController.class.php

@@ -0,0 +1,331 @@
+<?php
+
+namespace Admin\Controller;
+use Think\Controller;
+
+/**
+ * 管理员
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class CommonController extends Controller
+{
+	// 用户
+	protected $user;
+
+	// 权限
+	protected $power;
+
+	// 左边权限菜单
+	protected $left_menu;
+
+	/**
+	 * [__construt 构造方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:29:53+0800
+	 * @param    [string]       $msg  [提示信息]
+	 * @param    [int]          $code [状态码]
+	 * @param    [mixed]        $data [数据]
+	 */
+	protected function _initialize()
+	{
+		// 配置信息初始化
+		MyConfigInit();
+		
+		// 权限
+		$this->PowerInit();
+
+		// 视图初始化
+		$this->ViewInit();
+	}
+
+	/**
+	 * [ajaxReturn 重写ajax返回方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-07T22:03:40+0800
+	 * @param    [string]       $msg  [提示信息]
+	 * @param    [int]          $code [状态码]
+	 * @param    [mixed]        $data [数据]
+	 * @return   [json]               [json数据]
+	 */
+	protected function ajaxReturn($msg = '', $code = 0, $data = '')
+	{
+		// ajax的时候,success和error错误由当前方法接收
+		if(IS_AJAX)
+		{
+			if(isset($msg['info']))
+			{
+				// success模式下code=0, error模式下code参数-1
+				$result = array('msg'=>$msg['info'], 'code'=>-1, 'data'=>'');
+			}
+		}
+		
+		// 默认情况下,手动调用当前方法
+		if(empty($result))
+		{
+			$result = array('msg'=>$msg, 'code'=>$code, 'data'=>$data);
+		}
+
+		// 错误情况下,防止提示信息为空
+		if($result['code'] != 0 && empty($result['msg']))
+		{
+			$result['msg'] = L('common_operation_error');
+		}
+		exit(json_encode($result));
+	}
+
+	/**
+	 * [Is_Login 登录校验]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:42:35+0800
+	 */
+	protected function Is_Login()
+	{
+		if(empty($_SESSION['admin']))
+		{
+			$this->error(L('common_login_invalid'), U('Admin/Admin/LoginInfo'));
+		} else {
+			// 用户
+			$this->admin = I('session.admin');
+		}
+	}
+
+	/**
+	 * [ViewInit 视图初始化]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:30:06+0800
+	 */
+	public function ViewInit()
+	{
+		// 主题
+		$default_theme = C('DEFAULT_THEME');
+		$this->assign('default_theme', $default_theme);
+
+		// 控制器静态文件状态css,js
+		$module_css = MODULE_NAME.DS.$default_theme.DS.'Css'.DS.CONTROLLER_NAME.'.css';
+		$this->assign('module_css', file_exists(ROOT_PATH.'Public'.DS.$module_css) ? $module_css : '');
+		$module_js = MODULE_NAME.DS.$default_theme.DS.'Js'.DS.CONTROLLER_NAME.'.js';
+		$this->assign('module_js', file_exists(ROOT_PATH.'Public'.DS.$module_js) ? $module_js : '');
+
+		// 权限菜单
+		$this->assign('left_menu', $this->left_menu);
+
+		// 用户
+		$this->assign('admin', $this->admin);
+
+		// 图片host地址
+		$this->assign('image_host', C('IMAGE_HOST'));
+	}
+
+	/**
+	 * [PowerInit 权限初始化]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-19T22:41:20+0800
+	 */
+	private function PowerInit()
+	{
+		// 基础参数
+		$admin_id = isset($_SESSION['admin']['id']) ? intval($_SESSION['admin']['id']) : 0;
+		$role_id = isset($_SESSION['admin']['role_id']) ? intval($_SESSION['admin']['role_id']) : 0;
+
+		// 读取缓存数据
+		$this->left_menu = S(C('cache_admin_left_menu_key').$admin_id);
+		$this->power = S(C('cache_admin_power_key').$admin_id);
+
+		// 缓存没数据则从数据库重新读取
+		if(($role_id > 0 || $admin_id == 1) && empty($this->left_menu))
+		{
+			// 获取一级数据
+			$p = M('Power');
+			if($admin_id == 1)
+			{
+				$field = array('id', 'name', 'control', 'action', 'is_show', 'icon');
+				$this->left_menu = $p->where(array('pid' => 0))->field($field)->order('sort')->select();
+			} else {
+				$field = array('p.id', 'p.name', 'p.control', 'p.action', 'p.is_show', 'p.icon');
+				$this->left_menu = $p->alias('p')->join('__ROLE_POWER__ AS rp ON p.id = rp.power_id')->where(array('rp.role_id' => $role_id, 'p.pid' => 0))->field($field)->order('p.sort')->select();
+			}
+			
+			// 有数据,则处理子级数据
+			if(!empty($this->left_menu))
+			{
+				foreach($this->left_menu as $k=>$v)
+				{
+					// 权限
+					$this->power[$v['id']] = strtolower($v['control'].'_'.$v['action']);
+
+					// 获取子权限
+					if($admin_id == 1)
+					{
+						$item = $p->where(array('pid' => $v['id']))->field($field)->order('sort')->select();
+					} else {
+						$item = $p->alias('p')->join('__ROLE_POWER__ AS rp ON p.id = rp.power_id')->where(array('rp.role_id' => $role_id, 'p.pid' => $v['id']))->field($field)->order('p.sort')->select();
+					}
+
+					// 权限列表
+					if(!empty($item))
+					{
+						foreach($item as $ks=>$vs)
+						{
+							// 权限
+							$this->power[$vs['id']] = strtolower($vs['control'].'_'.$vs['action']);
+
+							// 是否显示视图
+							if($vs['is_show'] == 0)
+							{
+								unset($item[$ks]);
+							}
+						}
+					}
+
+					// 是否显示视图
+					if($v['is_show'] == 1)
+					{
+						// 子级
+						$this->left_menu[$k]['item'] = $item;
+					} else {
+						unset($this->left_menu[$k]);
+					}
+				}
+			}
+			S(C('cache_admin_left_menu_key').$admin_id, $this->left_menu);
+			S(C('cache_admin_power_key').$admin_id, $this->power);
+		}
+	}
+
+	/**
+	 * [Is_Power 是否有权限]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-20T19:18:29+0800
+	 */
+	protected function Is_Power()
+	{
+		// 不需要校验权限的方法
+		$unwanted_power = array('getnodeson');
+		if(!in_array(strtolower(ACTION_NAME), $unwanted_power))
+		{
+			// 角色组权限列表校验
+			if(!in_array(strtolower(CONTROLLER_NAME.'_'.ACTION_NAME), $this->power))
+			{
+				$this->error(L('common_there_is_no_power'));
+			}
+		}
+	}
+
+	/**
+	 * [GetClassList 获取班级列表,二级]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-30T13:26:00+0800
+	 * @return [array] [班级列表]
+	 */
+	protected function GetClassList()
+	{
+		$m = M('Class');
+		$data = $m->field(array('id', 'name'))->where(array('is_enable'=>1, 'pid'=>0))->select();
+		if(!empty($data))
+		{
+			foreach($data as $k=>$v)
+			{
+				$data[$k]['item'] = $m->field(array('id', 'name'))->where(array('is_enable'=>1, 'pid'=>$v['id']))->select();
+			}
+		}
+		return $data;
+	}
+
+	/**
+	 * [GetRoomList 获取教室列表,二级]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-30T13:26:00+0800
+	 * @return [array] [班级列表]
+	 */
+	protected function GetRoomList()
+	{
+		$m = M('Room');
+		$data = $m->field(array('id', 'name'))->where(array('is_enable'=>1, 'pid'=>0))->select();
+		if(!empty($data))
+		{
+			foreach($data as $k=>$v)
+			{
+				$data[$k]['item'] = $m->field(array('id', 'name'))->where(array('is_enable'=>1, 'pid'=>$v['id']))->select();
+			}
+		}
+		return $data;
+	}
+
+	/**
+	 * [MyConfigSave 配置数据保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-02T23:08:19+0800
+	 */
+	protected function MyConfigSave()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 参数校验
+		if(empty($_POST))
+		{
+			$this->error(L('common_param_error'));
+		}
+
+		// 循环保存数据
+		$success = 0;
+		$c = M('Config');
+
+		// 不实例化的字段
+		$no_all = array(
+				'home_footer_info',
+				'home_site_close_reason',
+				'home_email_user_reg',
+				'home_email_user_forget_pwd',
+				'home_email_user_student_binding',
+				'home_email_user_email_binding',
+			);
+
+		// 开始更新数据
+		foreach($_POST as $k=>$v)
+		{
+			if(!in_array($k, $no_all))
+			{
+				$v = I($k);
+			}
+			if($c->where(array('only_tag'=>$k))->save(array('value'=>$v, 'upd_time'=>time())))
+			{
+				$success++;
+			}
+		}
+		if($success > 0)
+		{
+			// 配置信息更新
+			MyConfigInit(1);
+
+			$this->ajaxReturn(L('common_operation_edit_success').'['.$success.']');
+		} else {
+			$this->ajaxReturn(L('common_operation_edit_error'), -100);
+		}
+	}
+}
+?>

+ 68 - 0
Application/Admin/Controller/ConfigController.class.php

@@ -0,0 +1,68 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 配置设置
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class ConfigController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 配置列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 学期
+		$semester_list = M('Semester')->field(array('id', 'name'))->where(array('is_enable'=>1))->order('id desc')->select();
+		$this->assign('semester_list', $semester_list);
+
+		// csv
+		$this->assign('common_excel_charset_list', L('common_excel_charset_list'));
+
+		// 配置信息
+		$data = M('Config')->getField('only_tag,name,describe,value,error_tips');
+		$this->assign('data', $data);
+		
+		$this->display('Index');
+	}
+
+	/**
+	 * [Save 配置数据保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-02T23:08:19+0800
+	 */
+	public function Save()
+	{
+		$this->MyConfigSave();
+	}
+}
+?>

+ 449 - 0
Application/Admin/Controller/CourseController.class.php

@@ -0,0 +1,449 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 教师课程管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class CourseController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 教师课程列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 参数
+		$param = array_merge($_POST, $_GET);
+
+		// 模型对象
+		$m = M('Course');
+
+		// 条件
+		$where = $this->GetIndexWhere();
+
+		// 分页
+		$number = MyC('admin_page_number');
+		$total = $m->alias('AS c')->join(' INNER JOIN __TEACHER__ AS t ON c.teacher_id = t.id INNER JOIN __CLASS__ AS cs ON c.class_id = cs.id INNER JOIN __SUBJECT__ AS s ON c.subject_id = s.id INNER JOIN __WEEK__ AS w ON c.week_id = w.id INNER JOIN __INTERVAL__ AS i ON c.interval_id = i.id')->where($where)->count();
+		$page_param = array(
+				'number'	=>	$number,
+				'total'		=>	$total,
+				'where'		=>	$param,
+				'url'		=>	U('Admin/Fraction/Index'),
+			);
+		$page = new \My\Page($page_param);
+
+		// 获取列表
+		$field = array('c.id', 'c.state', 't.username AS teacher_name', 'cs.name AS class_name', 'cs.pid AS class_pid', 's.name AS subject_name', 'w.name AS week_name', 'i.name AS interval_name', 'c.add_time AS add_time', 'r.pid AS room_pid', 'r.name AS room_name');
+		$list = $this->SetDataHandle($m->alias('AS c')->join(' INNER JOIN __TEACHER__ AS t ON c.teacher_id = t.id INNER JOIN __CLASS__ AS cs ON c.class_id = cs.id INNER JOIN __SUBJECT__ AS s ON c.subject_id = s.id INNER JOIN __WEEK__ AS w ON c.week_id = w.id INNER JOIN __INTERVAL__ AS i ON c.interval_id = i.id INNER JOIN __ROOM__ AS r ON c.room_id = r.id')->where($where)->field($field)->limit($page->GetPageStarNumber(), $number)->select());
+
+		// 数据列表
+		$this->assign('list', $list);
+
+		// 字段
+		$field = array('id', 'name');
+
+		// 条件
+		$where = array('is_enable'=>1);
+
+		// 班级
+		$this->assign('class_list', $this->GetClassList());
+
+		// 教室
+		$this->assign('room_list', $this->GetRoomList());
+
+		// 周天
+		$this->assign('week_list', M('Week')->field($field)->where($where)->select());
+
+		// 科目
+		$this->assign('subject_list', M('Subject')->field($field)->where($where)->select());
+
+		// 时段
+		$this->assign('interval_list', M('Interval')->field($field)->where($where)->select());
+
+		// 参数
+		$this->assign('param', $param);
+
+		// 分页
+		$this->assign('page_html', $page->GetPageHtml());
+
+		// Excel地址
+		$this->assign('excel_url', U('Admin/Course/ExcelExport', $param));
+
+		$this->display('Index');
+	}
+
+	/**
+	 * [ExcelExport excel文件导出]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-10T15:46:00+0800
+	 */
+	public function ExcelExport()
+	{
+		// 条件
+		$where = $this->GetIndexWhere();
+
+		// 读取数据
+		$field = array('c.id', 'c.state', 't.username AS teacher_name', 'cs.name AS class_name', 'cs.pid AS class_pid', 's.name AS subject_name', 'w.name AS week_name', 'i.name AS interval_name', 'c.add_time AS add_time', 'r.pid AS room_pid', 'r.name AS room_name');
+		$data = $this->SetDataHandle(M('Course')->alias('AS c')->join(' INNER JOIN __TEACHER__ AS t ON c.teacher_id = t.id INNER JOIN __CLASS__ AS cs ON c.class_id = cs.id INNER JOIN __SUBJECT__ AS s ON c.subject_id = s.id INNER JOIN __WEEK__ AS w ON c.week_id = w.id INNER JOIN __INTERVAL__ AS i ON c.interval_id = i.id INNER JOIN __ROOM__ AS r ON c.room_id = r.id')->where($where)->field($field)->select());
+
+		// Excel驱动导出数据
+		$excel = new \My\Excel(array('filename'=>'course', 'title'=>L('excel_course_title_list'), 'data'=>$data, 'msg'=>L('common_not_data_tips')));
+		$excel->Export();
+	}
+
+	/**
+	 * [SetDataHandle 数据处理]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-29T21:27:15+0800
+	 * @param    [array]      $data [教师课程数据]
+	 * @return   [array]            [处理好的数据]
+	 */
+	private function SetDataHandle($data)
+	{
+		if(!empty($data))
+		{
+			$c = M('Class');
+			$r = M('Room');
+			foreach($data as $k=>$v)
+			{
+				// 班级
+				if($v['class_pid'] != 0)
+				{
+					$p_name = $c->where(array('id'=>$v['class_pid']))->getField('name');
+					$data[$k]['class_name'] = empty($p_name) ? $v['class_name'] : $p_name.'-'.$v['class_name'];
+				}
+
+				// 教室
+				if($v['room_pid'] != 0)
+				{
+					$p_name = $r->where(array('id'=>$v['room_pid']))->getField('name');
+					$data[$k]['room_name'] = empty($p_name) ? $v['room_name'] : $p_name.'-'.$v['room_name'];
+				}
+
+				// 添加时间
+				$data[$k]['add_time'] = date('Y-m-d H:i:s', $v['add_time']);
+
+				// 状态
+				$data[$k]['state_text'] = L('common_state_list')[$v['state']]['name'];
+			}
+		}
+		return $data;
+	}
+
+	/**
+	 * [GetIndexWhere 教师课程列表条件]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T22:16:29+0800
+	 */
+	private function GetIndexWhere()
+	{
+		$where = array();
+
+		// 学期id
+		$where['c.semester_id'] = MyC('admin_semester_id');
+
+		// 模糊
+		if(!empty($_REQUEST['keyword']))
+		{
+			$where['t.username'] = array('like', '%'.I('keyword').'%');
+		}
+
+		// 是否更多条件
+		if(I('is_more', 0) == 1)
+		{
+			// 等值
+			if(I('class_id', 0) > 0)
+			{
+				$where['c.class_id'] = intval(I('class_id'));
+			}
+			if(I('week_id', 0) > 0)
+			{
+				$where['c.week_id'] = intval(I('week_id'));
+			}
+			if(I('subject_id', 0) > 0)
+			{
+				$where['c.subject_id'] = intval(I('subject_id'));
+			}
+			if(I('interval_id', 0) > 0)
+			{
+				$where['c.interval_id'] = intval(I('interval_id'));
+			}
+			if(I('room_id', 0) > 0)
+			{
+				$where['c.room_id'] = intval(I('room_id'));
+			}
+		}
+		return $where;
+	}
+
+	/**
+	 * [SaveInfo 教师课程添加/编辑页面]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:37:02+0800
+	 */
+	public function SaveInfo()
+	{
+		// 课程信息
+		if(empty($_REQUEST['id']))
+		{
+			$data = array('teacher_id'=>I('teacher_id'));
+			$request_url = U('Admin/Teacher/Index');
+		} else {
+			$data = M('Course')->find(I('id'));
+			$request_url = U('Admin/Course/Index');
+		}
+		$this->assign('request_url', $request_url);
+		$this->assign('data', $data);
+
+		// 字段
+		$field = array('id', 'name');
+
+		// 条件
+		$where = array('is_enable'=>1);
+
+		// 班级
+		$this->assign('class_list', $this->GetClassList());
+
+		// 教室
+		$this->assign('room_list', $this->GetRoomList());
+
+		// 周天
+		$this->assign('week_list', M('Week')->field($field)->where($where)->select());
+
+		// 教师贯通的科目
+		$subject_list = M('TeacherSubject')->alias('AS ts')->join('__SUBJECT__ AS s ON ts.subject_id = s.id')->where(array('ts.teacher_id'=>$data['teacher_id']))->field(array('s.id AS id', 's.name AS name'))->select();
+		$this->assign('subject_list', $subject_list);
+
+		// 时段
+		$this->assign('interval_list', M('Interval')->field($field)->where($where)->select());
+
+		$this->display('SaveInfo');
+	}
+
+	/**
+	 * [Save 教师课程添加/编辑]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:37:02+0800
+	 */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			$this->Add();
+
+		// 编辑
+		} else {
+			$this->Edit();
+		}
+	}
+
+	/**
+	 * [Add 教师课程添加]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-18T16:20:59+0800
+	 */
+	private function Add()
+	{
+		// 教师课程模型
+		$m = D('Course');
+
+		// 数据自动校验
+		if($m->create($_POST, 1))
+		{
+			// 校验数据不能重复添加
+			$this->IsExistData();
+
+			// 额外数据处理
+			$m->add_time	=	time();
+			$m->semester_id	=	MyC('admin_semester_id');
+			
+			// 写入数据库
+			if($m->add())
+			{
+				$this->ajaxReturn(L('common_operation_add_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_add_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [Edit 教师课程编辑]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-17T22:13:40+0800
+	 */
+	private function Edit()
+	{
+		// 教师课程模型
+		$m = D('Course');
+
+		// 数据自动校验
+		if($m->create($_POST, 2))
+		{
+			// 校验数据不能重复添加
+			$this->IsExistData();
+
+			// 移除 id
+			unset($m->id, $m->teacher_id);
+
+			// 更新数据库
+			if($m->where(array('id'=>I('id'), 'teacher_id'=>I('teacher_id')))->save())
+			{
+				$this->ajaxReturn(L('common_operation_edit_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_edit_error'), -100);
+			}
+		}
+	}
+
+	/**
+	 * [IsExistData 校验数据不能重复添加]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-08T22:08:46+0800
+	 */
+	private function IsExistData()
+	{
+		// 课程模型
+		$m = M('Course');
+
+		// 整条数据是否已存在
+		$where = array(
+				'teacher_id'	=>	I('teacher_id'),
+				'class_id'		=>	I('class_id'),
+				'subject_id'	=>	I('subject_id'),
+				'week_id'		=>	I('week_id'),
+				'interval_id'	=>	I('interval_id'),
+				'room_id'		=>	I('room_id'),
+				'semester_id'	=>	MyC('admin_semester_id'),
+			);
+		$temp = $m->where($where)->getField('id');
+		if(!empty($temp))
+		{
+			$this->ajaxReturn(L('common_data_is_exist_error'), -2);
+		}
+
+		// 学期-教室-周天-时段 是否已存在
+		$where = array(
+				'week_id'		=>	I('week_id'),
+				'interval_id'	=>	I('interval_id'),
+				'room_id'		=>	I('room_id'),
+				'semester_id'	=>	MyC('admin_semester_id'),
+			);
+		$temp = $m->where($where)->getField('id');
+		if(!empty($temp))
+		{
+			// 如果编辑的不是当前数据则校验
+			if($temp != I('id'))
+			{
+				$this->ajaxReturn(L('course_room_occupy_tips'), -2);
+			}
+		}
+	}
+
+	/**
+	 * [Delete 教师课程删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-15T11:03:30+0800
+	 */
+	public function Delete()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 参数处理
+		if(empty($_POST['id']))
+		{
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+
+		// 删除数据
+		if(M('Course')->delete(I('id')))
+		{
+			$this->ajaxReturn(L('common_operation_delete_success'));
+		} else {
+			$this->ajaxReturn(L('common_operation_delete_error'), -100);
+		}
+	}
+
+	/**
+	 * [StateUpdate 状态更新]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-12T22:23:06+0800
+	 */
+	public function StateUpdate()
+	{
+		// 参数
+		if(empty($_POST['id']) || !isset($_POST['state']))
+		{
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+
+		// 数据更新
+		if(M('Course')->where(array('id'=>I('id')))->save(array('state'=>I('state'))))
+		{
+			$this->ajaxReturn(L('common_operation_edit_success'));
+		} else {
+			$this->ajaxReturn(L('common_operation_edit_error'), -100);
+		}
+	}
+}
+?>

+ 416 - 0
Application/Admin/Controller/CultureDecorateController.class.php

@@ -0,0 +1,416 @@
+<?php
+namespace Admin\Controller;
+
+/**
+ * 装饰管理
+ * @author   晓宇
+ * @version  0.0.1
+ * @datetime 2019-03-29
+ */
+class CultureDecorateController extends CommonController
+{
+    /**
+     * [_initialize 前置操作-继承公共前置方法]
+     */
+    public function _initialize()
+    {
+        // 调用父类前置方法
+        parent::_initialize();
+
+        // 登录校验
+        $this->Is_Login();
+
+        // 权限校验
+        $this->Is_Power();
+    }
+
+    /**
+     * [Index 装饰列表]
+     */
+    public function Index()
+    {
+        // 参数
+        $param = array_merge($_POST, $_GET);
+
+        // 模型模型
+        $m = D('Culture/CultureDecorate');
+
+        // 条件
+        $where = $this->GetIndexWhere();
+
+        // 分页
+        $number = MyC('admin_page_number');
+        $page_param = array(
+                'number'    =>  $number,
+                'total'     =>  $m->where($where)->count(),
+                'where'     =>  $param,
+                'url'       =>  U('Culture/CultureDecorate/Index'),
+            );
+        $page = new \My\Page($page_param);
+        // 获取列表
+        $field = array('decorate_id', 'decorate_name', 'thumb', 'description', 'decorate_type_id', 'decorate_target_type_id', 'decorate_target_id', 'decorate_target_property_id', 'sale_price', 'created_at', 'updated_at');
+        $list = $this->SetDataHandle($m->field($field)->where($where)->relation("DecorateType")->limit($page->GetPageStarNumber(), $number)->order('decorate_id desc')->select());
+
+        // 参数
+        $this->assign('param', $param);
+
+        // 分页
+        $this->assign('page_html', $page->GetPageHtml());
+
+        // 数据列表
+        $this->assign('list', $list);
+
+        $this->display('Index');
+    }
+
+    /**
+     * [SetDataHandle 数据处理]
+     * @param    [array]      $data [装饰数据]
+     * @return   [array]            [处理好的数据]
+     */
+    private function SetDataHandle($data)
+    {
+
+        foreach ($data as $k => &$value) {
+            //获取装饰对象类型
+            unset($map);
+            $map['decorate_target_type_id'] = $value['decorate_target_type_id'];
+            $target_type = D('Culture/CultureDecorateTargetType')->field("decorate_target_type_name, model, mark")->where($map)->find();
+            $value['decorate_target_type_name'] = $target_type['decorate_target_type_name'];
+            //获取装饰对象
+            if($value['decorate_target_id']){
+                unset($map);
+                $map["{$target_type['mark']}_id"] = $value['decorate_target_id'];
+                $target = D($target_type['model'])->field("{$target_type['mark']}_id, {$target_type['mark']}_name")->where($map)->find();
+                $value['decorate_target_name'] = $target["{$target_type['mark']}_name"];
+                if($value['decorate_target_property_id']){
+                    unset($map);
+                    switch ($target_type['mark']) {
+                        case 'scene':
+                            $map['scene_id'] = $value['decorate_target_property_id'];
+                            $value['decorate_target_property_name'] = D("Culture/CultureScene")->where($map)->getField("scene_name");
+                            break;
+                        case 'pet_type':
+                            $map['pet_id'] = $value['decorate_target_property_id'];
+                            $map['pet_type_id'] = $value['decorate_target_id'];
+                            $value['decorate_target_property_name'] = D("Culture/CulturePet")->where($map)->getField("pet_name");
+                            break;
+                        default:
+                            $value['decorate_target_property_name'] = '';
+                            break;
+                    }
+                }
+                
+            }
+
+        }
+        return $data;
+    }
+
+    /**
+     * [GetIndexWhere 装饰列表条件]
+     */
+    private function GetIndexWhere()
+    {
+        $where = array();
+
+        // 模糊
+        if(!empty($_REQUEST['keyword']))
+        {
+            $like_keyword = array('like', '%'.I('keyword').'%');
+            $where[] = array(
+                    'decorate_name'      =>  $like_keyword,
+                );
+        }
+
+        // 是否更多条件
+        if(I('is_more', 0) == 1)
+        {
+            // 表达式
+            if(!empty($_REQUEST['time_start']))
+            {
+                $where['created_at'][] = array('gt', I('time_start') . ' 00:00:00');
+            }
+            if(!empty($_REQUEST['time_end']))
+            {
+                $where['created_at'][] = array('lt', I('time_end') . ' 23:59:59');
+            }
+        }
+
+        $where['deleted_at'] = ["exp", "is null"];
+
+        return $where;
+    }
+
+    /**
+     * [SaveInfo 装饰添加/编辑页面]
+     */
+    public function SaveInfo()
+    {
+        // 装饰信息
+        $data = empty($_REQUEST['decorate_id']) ? array() : D('Culture/CultureDecorate')->find(I('decorate_id'));
+        $this->assign('data', $data);
+        // 获取装饰类型
+        if($data['decorate_type_id']){
+            $map['decorate_target_type_id'] = $data['decorate_target_type_id'];
+            if($data['decorate_target_id']){
+                $map['decorate_target_id'] = $data['decorate_target_id'];
+            }
+            if($data['decorate_target_property_id']){
+                $map['decorate_target_property_id'] = $data['decorate_target_property_id'];
+            }
+            $decorate_type_list = D("Culture/CultureDecorateType")->field("decorate_type_id, decorate_type_name")->where($map)->select();
+            $this->assign('decorate_type_list', $decorate_type_list);
+        }
+        // 装饰对象类型信息
+        unset($map);
+        $map['deleted_at'] = ["exp", "is null"];
+        $decorate_target_type_list = D('Culture/CultureDecorateTargetType')->field("decorate_target_type_id, decorate_target_type_name")->where($map)->select();
+        $this->assign('decorate_target_type_list', $decorate_target_type_list);
+
+        //获取装饰对象信息
+        if($data['decorate_target_id']){
+            unset($map);
+            $map['decorate_target_type_id'] = $data['decorate_target_type_id'];
+            $target_type = D('Culture/CultureDecorateTargetType')->field("model, mark")->where($map)->find();
+
+            unset($map);
+            $map['deleted_at'] = ["exp", "is null"];
+            $decorate_target_list = D($target_type['model'])->field("{$target_type['mark']}_id as id, {$target_type['mark']}_name as name")->where($map)->select();
+            if($decorate_target_list){
+                $this->assign('decorate_target_list', $decorate_target_list);
+            }
+
+            //获取装饰对象专属信息
+            if($data['decorate_target_property_id']){
+                switch ($target_type['mark']) {
+                    case 'scene':
+                        break;
+                    case 'pet_type':
+                        unset($map);
+                        $map['pet_type_id'] = $target["{$target_type['mark']}_id"];
+                        $decorate_target_property_list = D("Culture/CulturePet")->field("pet_id as id, pet_name as name")->where($map)->select();
+                        if($decorate_target_property_list){
+                            $this->assign('decorate_target_property_list', $decorate_target_property_list);
+                        }
+                        break;
+                    default:
+                        break;
+                }
+            }
+
+        }
+
+        $this->display('SaveInfo');
+    }
+
+    /**
+     * [Save 装饰添加/编辑]
+     */
+    public function Save()
+    {
+        // 是否ajax请求
+        if(!IS_AJAX)
+        {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        // 添加
+        if(empty($_POST['decorate_id']))
+        {
+            $this->Add();
+
+        // 编辑
+        } else {
+            $this->Edit();
+        }
+    }
+
+    /**
+     * [Add 装饰添加]
+     */
+    private function Add()
+    {
+        // 装饰模型
+        $m = D('Culture/CultureDecorate');
+
+        // 数据自动校验
+        if($m->create($_POST, 1))
+        {
+            $m->created_at = date('Y-m-d H:i:s');
+            $m->updated_at = date('Y-m-d H:i:s');
+            // 数据添加
+            if($m->add())
+            {
+                $this->ajaxReturn(L('common_operation_add_success'));
+            } else {
+                echo M()->getLastsql();exit;
+                $this->ajaxReturn(L('common_operation_add_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn($m->getError(), -1);
+        }
+    }
+
+    /**
+     * [Edit 装饰编辑]
+     */
+    private function Edit()
+    {
+        // 装饰模型
+        $m = D('Culture/CultureDecorate');
+
+        // 数据自动校验
+        if($m->create($_POST, 2))
+        {
+            $m->updated_at = date('Y-m-d H:i:s');
+            // 更新数据库
+            if($m->where(array('decorate_id'=>I('decorate_id')))->save())
+            {
+                $this->ajaxReturn(L('common_operation_edit_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_edit_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn($m->getError(), -1);
+        }
+    }
+
+    /**
+     * [Delete 装饰删除]
+     */
+    public function Delete()
+    {
+        // 是否ajax请求
+        if(!IS_AJAX)
+        {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        // 参数处理
+        $id = I('decorate_id');
+
+        // 删除数据
+        if(!empty($id))
+        {
+            // 装饰模型
+            $m = D('Culture/CultureDecorate');
+
+            // 装饰是否存在
+            $scene = $m->where(array('decorate_id'=>$id))->count();
+            if(empty($scene))
+            {
+                $this->ajaxReturn(L('common_user_no_exist_error'), -2);
+            }
+
+            // 删除装饰
+            $update_data['delete'] = date('Y-m-d H:i:s');
+            $state = $m->where(array('decorate_id'=>$id))->save($update_data);
+            if($state !== false)
+            {
+                $this->ajaxReturn(L('common_operation_delete_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_delete_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn(L('common_param_error'), -1);
+        }
+    }
+
+    /**
+     * 获取装饰对象
+     */
+    public function getDecorateTarget()
+    {
+        $decorate_target_type_id = (int) I('decorate_target_type_id');
+        //获取对象表
+        $map['decorate_target_type_id'] = $decorate_target_type_id;
+        $target_type = D('Culture/CultureDecorateTargetType')->field("model, mark")->where($map)->find();
+        unset($map);
+        $map['deleted_at'] = ["exp", "is null"];
+        $list = D($target_type['model'])->field("{$target_type['mark']}_id as id, {$target_type['mark']}_name as name")->where($map)->select();
+        if(!$list){
+            $response_data['code'] = 400;
+            $response_data['msg'] = "暂无数据";
+            echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+            exit();
+        }
+        $response_data['code'] = 0;
+        $response_data['msg'] = "获取成功";
+        $response_data['data'] = $list;
+        echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+        exit();
+    }
+
+    /**
+     * 获取装饰对象专属ID
+     */
+    public function getDecorateTargetProperty()
+    {
+        $decorate_target_type_id = (int) I('decorate_target_type_id');
+        $decorate_target_id = (int) I('decorate_target_id');
+        //获取对象表
+        $map['decorate_target_type_id'] = $decorate_target_type_id;
+        $target_type = D('Culture/CultureDecorateTargetType')->field("model, mark")->where($map)->find();
+        unset($map);
+        $map['deleted_at'] = ["exp", "is null"];
+        $map["{$target_type['mark']}_id"] = $decorate_target_id;
+        $target = D($target_type['model'])->field("{$target_type['mark']}_id, {$target_type['mark']}_name")->where($map)->find();
+        switch ($target_type['mark']) {
+            case 'scene':
+                $list = [];
+                break;
+            case 'pet_type':
+                unset($map);
+                $map['pet_type_id'] = $target["{$target_type['mark']}_id"];
+                $list = D("Culture/CulturePet")->field("pet_id as id, pet_name as name")->where($map)->select();
+                break;
+            default:
+                $list = [];
+                break;
+        }
+        if(count($list) < 1){
+            $response_data['code'] = 400;
+            $response_data['msg'] = "暂无数据";
+            echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+            exit();
+        }
+        $response_data['code'] = 0;
+        $response_data['msg'] = "获取成功";
+        $response_data['data'] = $list;
+        echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+        exit();
+    }
+
+    /**
+     * 获取装饰类型
+     */
+    public function getDecorateType()
+    {
+        $decorate_target_type_id = (int) I('decorate_target_type_id');
+        $decorate_target_id = (int) I('decorate_target_id');
+        $decorate_target_property_id = (int) I('decorate_target_property_id');
+        if(!$decorate_target_type_id){
+            $response_data['code'] = 400;
+            $response_data['msg'] = "暂无数据";
+            echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+            exit();
+        }
+        $map['decorate_target_type_id'] = $decorate_target_type_id;
+        if($decorate_target_id){
+            $map['decorate_target_id'] = $decorate_target_id;
+        }
+        if($decorate_target_property_id){
+            $map['decorate_target_property_id'] = $decorate_target_property_id;
+        }
+        // 装饰类型信息
+        $map['deleted_at'] = ["exp", "is null"];
+        $list = D('Culture/CultureDecorateType')->field("decorate_type_id as id, decorate_type_name as name")->where($map)->select();
+        $response_data['code'] = 0;
+        $response_data['msg'] = "获取成功";
+        $response_data['data'] = $list;
+        echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+        exit();
+    }
+
+}

+ 413 - 0
Application/Admin/Controller/CultureDecorateTargetTypeController.class.php

@@ -0,0 +1,413 @@
+<?php
+namespace Admin\Controller;
+
+/**
+ * 装饰管理
+ * @author   晓宇
+ * @version  0.0.1
+ * @datetime 2019-03-29
+ */
+class CultureDecorateController extends CommonController
+{
+    /**
+     * [_initialize 前置操作-继承公共前置方法]
+     */
+    public function _initialize()
+    {
+        // 调用父类前置方法
+        parent::_initialize();
+
+        // 登录校验
+        $this->Is_Login();
+
+        // 权限校验
+        $this->Is_Power();
+    }
+
+    /**
+     * [Index 装饰列表]
+     */
+    public function Index()
+    {
+        // 参数
+        $param = array_merge($_POST, $_GET);
+
+        // 模型模型
+        $m = D('Culture/CultureDecorate');
+
+        // 条件
+        $where = $this->GetIndexWhere();
+
+        // 分页
+        $number = MyC('admin_page_number');
+        $page_param = array(
+                'number'    =>  $number,
+                'total'     =>  $m->where($where)->count(),
+                'where'     =>  $param,
+                'url'       =>  U('Culture/CultureDecorate/Index'),
+            );
+        $page = new \My\Page($page_param);
+        // 获取列表
+        $field = array('decorate_id', 'decorate_name', 'thumb', 'description', 'decorate_type_id', 'decorate_target_type_id', 'decorate_target_id', 'decorate_target_property_id', 'sale_price', 'created_at', 'updated_at');
+        $list = $this->SetDataHandle($m->field($field)->where($where)->relation("DecorateType")->limit($page->GetPageStarNumber(), $number)->order('decorate_id desc')->select());
+
+        // 参数
+        $this->assign('param', $param);
+
+        // 分页
+        $this->assign('page_html', $page->GetPageHtml());
+
+        // 数据列表
+        $this->assign('list', $list);
+
+        $this->display('Index');
+    }
+
+    /**
+     * [SetDataHandle 数据处理]
+     * @param    [array]      $data [装饰数据]
+     * @return   [array]            [处理好的数据]
+     */
+    private function SetDataHandle($data)
+    {
+
+        foreach ($data as $k => &$value) {
+            //获取装饰对象类型
+            unset($map);
+            $map['decorate_target_type_id'] = $value['decorate_target_type_id'];
+            $target_type = D('Culture/CultureDecorateTargetType')->field("decorate_target_type_name, model, mark")->where($map)->find();
+            $value['decorate_target_type_name'] = $target_type['decorate_target_type_name'];
+            //获取装饰对象
+            if($value['decorate_target_id']){
+                unset($map);
+                $map["{$target_type['mark']}_id"] = $value['decorate_target_id'];
+                $target = D($target_type['model'])->field("{$target_type['mark']}_id, {$target_type['mark']}_name")->where($map)->find();
+                $value['decorate_target_name'] = $target["{$target_type['mark']}_name"];
+                if($value['decorate_target_property_id']){
+                    unset($map);
+                    switch ($target_type['mark']) {
+                        case 'scene':
+                            $map['scene_id'] = $value['decorate_target_property_id'];
+                            $value['decorate_target_property_name'] = D("Culture/CultureScene")->where($map)->getField("scene_name");
+                            break;
+                        case 'pet_type':
+                            $map['pet_id'] = $value['decorate_target_property_id'];
+                            $map['pet_type_id'] = $value['decorate_target_id'];
+                            $value['decorate_target_property_name'] = D("Culture/CulturePet")->where($map)->getField("pet_name");
+                            break;
+                        default:
+                            $value['decorate_target_property_name'] = '';
+                            break;
+                    }
+                }
+                
+            }
+
+        }
+        return $data;
+    }
+
+    /**
+     * [GetIndexWhere 装饰列表条件]
+     */
+    private function GetIndexWhere()
+    {
+        $where = array();
+
+        // 模糊
+        if(!empty($_REQUEST['keyword']))
+        {
+            $like_keyword = array('like', '%'.I('keyword').'%');
+            $where[] = array(
+                    'decorate_name'      =>  $like_keyword,
+                );
+        }
+
+        // 是否更多条件
+        if(I('is_more', 0) == 1)
+        {
+            // 表达式
+            if(!empty($_REQUEST['time_start']))
+            {
+                $where['created_at'][] = array('gt', I('time_start') . ' 00:00:00');
+            }
+            if(!empty($_REQUEST['time_end']))
+            {
+                $where['created_at'][] = array('lt', I('time_end') . ' 23:59:59');
+            }
+        }
+        return $where;
+    }
+
+    /**
+     * [SaveInfo 装饰添加/编辑页面]
+     */
+    public function SaveInfo()
+    {
+        // 装饰信息
+        $data = empty($_REQUEST['decorate_id']) ? array() : D('Culture/CultureDecorate')->find(I('decorate_id'));
+        $this->assign('data', $data);
+        // 获取装饰类型
+        if($data['decorate_type_id']){
+            $map['decorate_target_type_id'] = $data['decorate_target_type_id'];
+            if($data['decorate_target_id']){
+                $map['decorate_target_id'] = $data['decorate_target_id'];
+            }
+            if($data['decorate_target_property_id']){
+                $map['decorate_target_property_id'] = $data['decorate_target_property_id'];
+            }
+            $decorate_type_list = D("Culture/CultureDecorateType")->field("decorate_type_id, decorate_type_name")->where($map)->select();
+            $this->assign('decorate_type_list', $decorate_type_list);
+        }
+        // 装饰对象类型信息
+        unset($map);
+        $map['deleted_at'] = ["exp", "is null"];
+        $decorate_target_type_list = D('Culture/CultureDecorateTargetType')->field("decorate_target_type_id, decorate_target_type_name")->where($map)->select();
+        $this->assign('decorate_target_type_list', $decorate_target_type_list);
+
+        //获取装饰对象信息
+        if($data['decorate_target_id']){
+            unset($map);
+            $map['decorate_target_type_id'] = $data['decorate_target_type_id'];
+            $target_type = D('Culture/CultureDecorateTargetType')->field("model, mark")->where($map)->find();
+
+            unset($map);
+            $map['deleted_at'] = ["exp", "is null"];
+            $decorate_target_list = D($target_type['model'])->field("{$target_type['mark']}_id as id, {$target_type['mark']}_name as name")->where($map)->select();
+            if($decorate_target_list){
+                $this->assign('decorate_target_list', $decorate_target_list);
+            }
+
+            //获取装饰对象专属信息
+            if($data['decorate_target_property_id']){
+                switch ($target_type['mark']) {
+                    case 'scene':
+                        break;
+                    case 'pet_type':
+                        unset($map);
+                        $map['pet_type_id'] = $target["{$target_type['mark']}_id"];
+                        $decorate_target_property_list = D("Culture/CulturePet")->field("pet_id as id, pet_name as name")->where($map)->select();
+                        if($decorate_target_property_list){
+                            $this->assign('decorate_target_property_list', $decorate_target_property_list);
+                        }
+                        break;
+                    default:
+                        break;
+                }
+            }
+
+        }
+
+        $this->display('SaveInfo');
+    }
+
+    /**
+     * [Save 装饰添加/编辑]
+     */
+    public function Save()
+    {
+        // 是否ajax请求
+        if(!IS_AJAX)
+        {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        // 添加
+        if(empty($_POST['decorate_id']))
+        {
+            $this->Add();
+
+        // 编辑
+        } else {
+            $this->Edit();
+        }
+    }
+
+    /**
+     * [Add 装饰添加]
+     */
+    private function Add()
+    {
+        // 装饰模型
+        $m = D('Culture/CultureDecorate');
+
+        // 数据自动校验
+        if($m->create($_POST, 1))
+        {
+            $m->created_at = date('Y-m-d H:i:s');
+            $m->updated_at = date('Y-m-d H:i:s');
+            // 数据添加
+            if($m->add())
+            {
+                $this->ajaxReturn(L('common_operation_add_success'));
+            } else {
+                echo M()->getLastsql();exit;
+                $this->ajaxReturn(L('common_operation_add_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn($m->getError(), -1);
+        }
+    }
+
+    /**
+     * [Edit 装饰编辑]
+     */
+    private function Edit()
+    {
+        // 装饰模型
+        $m = D('Culture/CultureDecorate');
+
+        // 数据自动校验
+        if($m->create($_POST, 2))
+        {
+            $m->updated_at = date('Y-m-d H:i:s');
+            // 更新数据库
+            if($m->where(array('decorate_id'=>I('decorate_id')))->save())
+            {
+                $this->ajaxReturn(L('common_operation_edit_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_edit_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn($m->getError(), -1);
+        }
+    }
+
+    /**
+     * [Delete 装饰删除]
+     */
+    public function Delete()
+    {
+        // 是否ajax请求
+        if(!IS_AJAX)
+        {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        // 参数处理
+        $id = I('decorate_id');
+
+        // 删除数据
+        if(!empty($id))
+        {
+            // 装饰模型
+            $m = D('Culture/CultureDecorate');
+
+            // 装饰是否存在
+            $scene = $m->where(array('decorate_id'=>$id))->count();
+            if(empty($scene))
+            {
+                $this->ajaxReturn(L('common_user_no_exist_error'), -2);
+            }
+
+            // 删除装饰
+            $update_data['delete'] = date('Y-m-d H:i:s');
+            $state = $m->where(array('decorate_id'=>$id))->save($update_data);
+            if($state !== false)
+            {
+                $this->ajaxReturn(L('common_operation_delete_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_delete_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn(L('common_param_error'), -1);
+        }
+    }
+
+    /**
+     * 获取装饰对象
+     */
+    public function getDecorateTarget()
+    {
+        $decorate_target_type_id = (int) I('decorate_target_type_id');
+        //获取对象表
+        $map['decorate_target_type_id'] = $decorate_target_type_id;
+        $target_type = D('Culture/CultureDecorateTargetType')->field("model, mark")->where($map)->find();
+        unset($map);
+        $map['deleted_at'] = ["exp", "is null"];
+        $list = D($target_type['model'])->field("{$target_type['mark']}_id as id, {$target_type['mark']}_name as name")->where($map)->select();
+        if(!$list){
+            $response_data['code'] = 400;
+            $response_data['msg'] = "暂无数据";
+            echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+            exit();
+        }
+        $response_data['code'] = 0;
+        $response_data['msg'] = "获取成功";
+        $response_data['data'] = $list;
+        echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+        exit();
+    }
+
+    /**
+     * 获取装饰对象专属ID
+     */
+    public function getDecorateTargetProperty()
+    {
+        $decorate_target_type_id = (int) I('decorate_target_type_id');
+        $decorate_target_id = (int) I('decorate_target_id');
+        //获取对象表
+        $map['decorate_target_type_id'] = $decorate_target_type_id;
+        $target_type = D('Culture/CultureDecorateTargetType')->field("model, mark")->where($map)->find();
+        unset($map);
+        $map['deleted_at'] = ["exp", "is null"];
+        $map["{$target_type['mark']}_id"] = $decorate_target_id;
+        $target = D($target_type['model'])->field("{$target_type['mark']}_id, {$target_type['mark']}_name")->where($map)->find();
+        switch ($target_type['mark']) {
+            case 'scene':
+                $list = [];
+                break;
+            case 'pet_type':
+                unset($map);
+                $map['pet_type_id'] = $target["{$target_type['mark']}_id"];
+                $list = D("Culture/CulturePet")->field("pet_id as id, pet_name as name")->where($map)->select();
+                break;
+            default:
+                $list = [];
+                break;
+        }
+        if(count($list) < 1){
+            $response_data['code'] = 400;
+            $response_data['msg'] = "暂无数据";
+            echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+            exit();
+        }
+        $response_data['code'] = 0;
+        $response_data['msg'] = "获取成功";
+        $response_data['data'] = $list;
+        echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+        exit();
+    }
+
+    /**
+     * 获取装饰类型
+     */
+    public function getDecorateType()
+    {
+        $decorate_target_type_id = (int) I('decorate_target_type_id');
+        $decorate_target_id = (int) I('decorate_target_id');
+        $decorate_target_property_id = (int) I('decorate_target_property_id');
+        if(!$decorate_target_type_id){
+            $response_data['code'] = 400;
+            $response_data['msg'] = "暂无数据";
+            echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+            exit();
+        }
+        $map['decorate_target_type_id'] = $decorate_target_type_id;
+        if($decorate_target_id){
+            $map['decorate_target_id'] = $decorate_target_id;
+        }
+        if($decorate_target_property_id){
+            $map['decorate_target_property_id'] = $decorate_target_property_id;
+        }
+        // 装饰类型信息
+        $map['deleted_at'] = ["exp", "is null"];
+        $list = D('Culture/CultureDecorateType')->field("decorate_type_id as id, decorate_type_name as name")->where($map)->select();
+        $response_data['code'] = 0;
+        $response_data['msg'] = "获取成功";
+        $response_data['data'] = $list;
+        echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+        exit();
+    }
+
+}

+ 405 - 0
Application/Admin/Controller/CultureDecorateTypeController.class.php

@@ -0,0 +1,405 @@
+<?php
+namespace Admin\Controller;
+
+/**
+ * 装饰类型管理
+ * @author   晓宇
+ * @version  0.0.1
+ * @datetime 2019-03-29
+ */
+class CultureDecorateTypeController extends CommonController
+{
+    /**
+     * [_initialize 前置操作-继承公共前置方法]
+     */
+    public function _initialize()
+    {
+        // 调用父类前置方法
+        parent::_initialize();
+
+        // 登录校验
+        $this->Is_Login();
+
+        // 权限校验
+        $this->Is_Power();
+    }
+
+    /**
+     * [Index 装饰类型列表]
+     */
+    public function Index()
+    {
+        // 参数
+        $param = array_merge($_POST, $_GET);
+
+        // 模型模型
+        $m = D('Culture/CultureDecorateType');
+
+        // 条件
+        $where = $this->GetIndexWhere();
+
+        // 分页
+        $number = MyC('admin_page_number');
+        $page_param = array(
+                'number'    =>  $number,
+                'total'     =>  $m->where($where)->count(),
+                'where'     =>  $param,
+                'url'       =>  U('Culture/CultureDecorateType/Index'),
+            );
+        $page = new \My\Page($page_param);
+        // 获取列表
+        $field = array('decorate_type_id', 'decorate_type_name', 'thumb', 'description', 'decorate_target_type_id', 'decorate_target_id', 'decorate_target_property_id', 'created_at', 'updated_at');
+        $list = $this->SetDataHandle($m->field($field)->where($where)->limit($page->GetPageStarNumber(), $number)->order('decorate_type_id desc')->select());
+
+        // 参数
+        $this->assign('param', $param);
+
+        // 分页
+        $this->assign('page_html', $page->GetPageHtml());
+
+        // 数据列表
+        $this->assign('list', $list);
+
+        $this->display('Index');
+    }
+
+    /**
+     * [SetDataHandle 数据处理]
+     * @param    [array]      $data [装饰类型数据]
+     * @return   [array]            [处理好的数据]
+     */
+    private function SetDataHandle($data)
+    {
+
+        foreach ($data as $k => &$value) {
+            //获取装饰类型对象类型
+            unset($map);
+            $map['decorate_target_type_id'] = $value['decorate_target_type_id'];
+            $target_type = D('Culture/CultureDecorateTargetType')->field("decorate_target_type_name, model, mark")->where($map)->find();
+            $value['decorate_target_type_name'] = $target_type['decorate_target_type_name'];
+            //获取装饰类型对象
+            if($value['decorate_target_id']){
+                unset($map);
+                $map["{$target_type['mark']}_id"] = $value['decorate_target_id'];
+                $target = D($target_type['model'])->field("{$target_type['mark']}_id, {$target_type['mark']}_name")->where($map)->find();
+                $value['decorate_target_name'] = $target["{$target_type['mark']}_name"];
+                if($value['decorate_target_property_id']){
+                    unset($map);
+                    switch ($target_type['mark']) {
+                        case 'scene':
+                            $map['scene_id'] = $value['decorate_target_property_id'];
+                            $value['decorate_target_property_name'] = D("Culture/CultureScene")->where($map)->getField("scene_name");
+                            break;
+                        case 'pet_type':
+                            $map['pet_id'] = $value['decorate_target_property_id'];
+                            $map['pet_type_id'] = $value['decorate_target_id'];
+                            $value['decorate_target_property_name'] = D("Culture/CulturePet")->where($map)->getField("pet_name");
+                            break;
+                        default:
+                            $value['decorate_target_property_name'] = '';
+                            break;
+                    }
+                }
+                
+            }
+
+        }
+        return $data;
+    }
+
+    /**
+     * [GetIndexWhere 装饰类型列表条件]
+     */
+    private function GetIndexWhere()
+    {
+        $where = array();
+
+        // 模糊
+        if(!empty($_REQUEST['keyword']))
+        {
+            $like_keyword = array('like', '%'.I('keyword').'%');
+            $where[] = array(
+                    'decorate_type_name'      =>  $like_keyword,
+                );
+        }
+
+        // 是否更多条件
+        if(I('is_more', 0) == 1)
+        {
+            // 表达式
+            if(!empty($_REQUEST['time_start']))
+            {
+                $where['created_at'][] = array('gt', I('time_start') . ' 00:00:00');
+            }
+            if(!empty($_REQUEST['time_end']))
+            {
+                $where['created_at'][] = array('lt', I('time_end') . ' 23:59:59');
+            }
+        }
+
+        $where['deleted_at'] = ["exp", "is null"];
+        
+        return $where;
+    }
+
+    /**
+     * [SaveInfo 装饰类型添加/编辑页面]
+     */
+    public function SaveInfo()
+    {
+        // 装饰类型信息
+        $data = empty($_REQUEST['decorate_type_id']) ? array() : D('Culture/CultureDecorateType')->find(I('decorate_type_id'));
+        $this->assign('data', $data);
+
+        // 装饰类型对象类型信息
+        unset($map);
+        $map['deleted_at'] = ["exp", "is null"];
+        $decorate_target_type_list = D('Culture/CultureDecorateTargetType')->field("decorate_target_type_id, decorate_target_type_name")->where($map)->select();
+        $this->assign('decorate_target_type_list', $decorate_target_type_list);
+
+        //获取装饰类型对象信息
+        if($data['decorate_target_id']){
+            unset($map);
+            $map['decorate_target_type_id'] = $data['decorate_target_type_id'];
+            $target_type = D('Culture/CultureDecorateTargetType')->field("model, mark")->where($map)->find();
+
+            unset($map);
+            $map['deleted_at'] = ["exp", "is null"];
+            $decorate_target_list = D($target_type['model'])->field("{$target_type['mark']}_id as id, {$target_type['mark']}_name as name")->where($map)->select();
+            if($decorate_target_list){
+                $this->assign('decorate_target_list', $decorate_target_list);
+            }
+
+            //获取装饰类型对象专属信息
+            if($data['decorate_target_property_id']){
+                switch ($target_type['mark']) {
+                    case 'scene':
+                        break;
+                    case 'pet_type':
+                        unset($map);
+                        $map['pet_type_id'] = $target["{$target_type['mark']}_id"];
+                        $decorate_target_property_list = D("Culture/CulturePet")->field("pet_id as id, pet_name as name")->where($map)->select();
+                        if($decorate_target_property_list){
+                            $this->assign('decorate_target_property_list', $decorate_target_property_list);
+                        }
+                        break;
+                    default:
+                        break;
+                }
+            }
+
+        }
+
+        $this->display('SaveInfo');
+    }
+
+    /**
+     * [Save 装饰类型添加/编辑]
+     */
+    public function Save()
+    {
+        // 是否ajax请求
+        if(!IS_AJAX)
+        {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        // 添加
+        if(empty($_POST['decorate_type_id']))
+        {
+            $this->Add();
+
+        // 编辑
+        } else {
+            $this->Edit();
+        }
+    }
+
+    /**
+     * [Add 装饰类型添加]
+     */
+    private function Add()
+    {
+        // 装饰类型模型
+        $m = D('Culture/CultureDecorateType');
+
+        // 数据自动校验
+        if($m->create($_POST, 1))
+        {
+            $m->created_at = date('Y-m-d H:i:s');
+            $m->updated_at = date('Y-m-d H:i:s');
+            // 数据添加
+            if($m->add())
+            {
+                $this->ajaxReturn(L('common_operation_add_success'));
+            } else {
+                echo M()->getLastsql();exit;
+                $this->ajaxReturn(L('common_operation_add_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn($m->getError(), -1);
+        }
+    }
+
+    /**
+     * [Edit 装饰类型编辑]
+     */
+    private function Edit()
+    {
+        // 装饰类型模型
+        $m = D('Culture/CultureDecorateType');
+
+        // 数据自动校验
+        if($m->create($_POST, 2))
+        {
+            $m->updated_at = date('Y-m-d H:i:s');
+            // 更新数据库
+            if($m->where(array('decorate_type_id'=>I('decorate_type_id')))->save())
+            {
+                $this->ajaxReturn(L('common_operation_edit_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_edit_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn($m->getError(), -1);
+        }
+    }
+
+    /**
+     * [Delete 装饰类型删除]
+     */
+    public function Delete()
+    {
+        // 是否ajax请求
+        if(!IS_AJAX)
+        {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        // 参数处理
+        $id = I('decorate_type_id');
+
+        // 删除数据
+        if(!empty($id))
+        {
+            // 装饰类型模型
+            $m = D('Culture/CultureDecorateType');
+
+            // 装饰类型是否存在
+            $scene = $m->where(array('decorate_type_id'=>$id))->count();
+            if(empty($scene))
+            {
+                $this->ajaxReturn(L('common_user_no_exist_error'), -2);
+            }
+
+            // 删除装饰类型
+            $update_data['delete'] = date('Y-m-d H:i:s');
+            $state = $m->where(array('decorate_type_id'=>$id))->save($update_data);
+            if($state !== false)
+            {
+                $this->ajaxReturn(L('common_operation_delete_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_delete_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn(L('common_param_error'), -1);
+        }
+    }
+
+    /**
+     * 获取装饰类型对象
+     */
+    public function getDecorateTarget()
+    {
+        $decorate_target_type_id = (int) I('decorate_target_type_id');
+        //获取对象表
+        $map['decorate_target_type_id'] = $decorate_target_type_id;
+        $target_type = D('Culture/CultureDecorateTargetType')->field("model, mark")->where($map)->find();
+        unset($map);
+        $map['deleted_at'] = ["exp", "is null"];
+        $list = D($target_type['model'])->field("{$target_type['mark']}_id as id, {$target_type['mark']}_name as name")->where($map)->select();
+        if(!$list){
+            $response_data['code'] = 400;
+            $response_data['msg'] = "暂无数据";
+            echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+            exit();
+        }
+        $response_data['code'] = 0;
+        $response_data['msg'] = "获取成功";
+        $response_data['data'] = $list;
+        echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+        exit();
+    }
+
+    /**
+     * 获取装饰类型对象专属ID
+     */
+    public function getDecorateTargetProperty()
+    {
+        $decorate_target_type_id = (int) I('decorate_target_type_id');
+        $decorate_target_id = (int) I('decorate_target_id');
+        //获取对象表
+        $map['decorate_target_type_id'] = $decorate_target_type_id;
+        $target_type = D('Culture/CultureDecorateTargetType')->field("model, mark")->where($map)->find();
+        unset($map);
+        $map['deleted_at'] = ["exp", "is null"];
+        $map["{$target_type['mark']}_id"] = $decorate_target_id;
+        $target = D($target_type['model'])->field("{$target_type['mark']}_id, {$target_type['mark']}_name")->where($map)->find();
+        switch ($target_type['mark']) {
+            case 'scene':
+                $list = [];
+                break;
+            case 'pet_type':
+                unset($map);
+                $map['pet_type_id'] = $target["{$target_type['mark']}_id"];
+                $list = D("Culture/CulturePet")->field("pet_id as id, pet_name as name")->where($map)->select();
+                break;
+            default:
+                $list = [];
+                break;
+        }
+        if(count($list) < 1){
+            $response_data['code'] = 400;
+            $response_data['msg'] = "暂无数据";
+            echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+            exit();
+        }
+        $response_data['code'] = 0;
+        $response_data['msg'] = "获取成功";
+        $response_data['data'] = $list;
+        echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+        exit();
+    }
+
+    /**
+     * 获取装饰类型类型
+     */
+    public function getDecorateTypeType()
+    {
+        $decorate_target_type_id = (int) I('decorate_target_type_id');
+        $decorate_target_id = (int) I('decorate_target_id');
+        $decorate_target_property_id = (int) I('decorate_target_property_id');
+        if(!$decorate_target_type_id){
+            $response_data['code'] = 400;
+            $response_data['msg'] = "暂无数据";
+            echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+            exit();
+        }
+        $map['decorate_target_type_id'] = $decorate_target_type_id;
+        if($decorate_target_id){
+            $map['decorate_target_id'] = $decorate_target_id;
+        }
+        if($decorate_target_property_id){
+            $map['decorate_target_property_id'] = $decorate_target_property_id;
+        }
+        // 装饰类型类型信息
+        $map['deleted_at'] = ["exp", "is null"];
+        $list = D('Culture/CultureDecorateTypeType')->field("decorate_type_type_id as id, decorate_type_type_name as name")->where($map)->select();
+        $response_data['code'] = 0;
+        $response_data['msg'] = "获取成功";
+        $response_data['data'] = $list;
+        echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+        exit();
+    }
+
+}

+ 279 - 0
Application/Admin/Controller/CultureFoodController.class.php

@@ -0,0 +1,279 @@
+<?php
+namespace Admin\Controller;
+
+/**
+ * 食物管理
+ * @author   晓宇
+ * @version  0.0.1
+ * @datetime 2019-03-29
+ */
+class CultureFoodController extends CommonController
+{
+    /**
+     * [_initialize 前置操作-继承公共前置方法]
+     */
+    public function _initialize()
+    {
+        // 调用父类前置方法
+        parent::_initialize();
+
+        // 登录校验
+        $this->Is_Login();
+
+        // 权限校验
+        $this->Is_Power();
+    }
+
+    /**
+     * [Index 食物列表]
+     */
+    public function Index()
+    {
+        // 参数
+        $param = array_merge($_POST, $_GET);
+
+        // 模型模型
+        $m = D('Culture/CultureFood');
+
+        // 条件
+        $where = $this->GetIndexWhere();
+
+        // 分页
+        $number = MyC('admin_page_number');
+        $page_param = array(
+                'number'    =>  $number,
+                'total'     =>  $m->where($where)->count(),
+                'where'     =>  $param,
+                'url'       =>  U('Culture/CultureFood/Index'),
+            );
+        $page = new \My\Page($page_param);
+        // 获取列表
+        $field = array('food_id', 'food_name', 'thumb', 'description', 'sale_price', 'pet_type_id', 'pet_id', 'created_at', 'updated_at');
+        $list = $this->SetDataHandle($m->field($field)->relation('FoodType')->where($where)->limit($page->GetPageStarNumber(), $number)->order('food_id desc')->select());
+
+        // 参数
+        $this->assign('param', $param);
+
+        // 分页
+        $this->assign('page_html', $page->GetPageHtml());
+
+        // 数据列表
+        $this->assign('list', $list);
+
+        $this->display('Index');
+    }
+
+    /**
+     * [SetDataHandle 数据处理]
+     * @param    [array]      $data [食物数据]
+     * @return   [array]            [处理好的数据]
+     */
+    private function SetDataHandle($data)
+    {
+        // 获取宠物类型
+        foreach ($data as $k => &$value) {
+            if($value['pet_type_id']){
+                $value['pet_type_name'] = D("Culture/CulturePetType")->where(["pet_type_id" => $value['pet_type_id']])->getField("pet_type_name");
+            }
+            if($value['pet_id']){
+                $value['pet_name'] = D("Culture/CulturePet")->where(["pet_id" => $value['pet_id']])->getField("pet_name");
+            }            
+        }
+
+        return $data;
+    }
+
+    /**
+     * [GetIndexWhere 食物列表条件]
+     */
+    private function GetIndexWhere()
+    {
+        $where = array();
+
+        // 模糊
+        if(!empty($_REQUEST['keyword']))
+        {
+            $like_keyword = array('like', '%'.I('keyword').'%');
+            $where[] = array(
+                    'food_name'      =>  $like_keyword,
+                );
+        }
+
+        // 是否更多条件
+        if(I('is_more', 0) == 1)
+        {
+            // 表达式
+            if(!empty($_REQUEST['time_start']))
+            {
+                $where['created_at'][] = array('gt', I('time_start') . ' 00:00:00');
+            }
+            if(!empty($_REQUEST['time_end']))
+            {
+                $where['created_at'][] = array('lt', I('time_end') . ' 23:59:59');
+            }
+        }
+        
+        $where['deleted_at'] = ["exp", "is null"];
+
+        return $where;
+    }
+
+    /**
+     * [SaveInfo 食物添加/编辑页面]
+     */
+    public function SaveInfo()
+    {
+        // 食物信息
+        $data = empty($_REQUEST['food_id']) ? array() : D('Culture/CultureFood')->find(I('food_id'));
+        $this->assign('data', $data);
+        // 食物类型信息
+        $map['deleted_at'] = ["exp", "is null"];
+        $pet_types = D('Culture/CulturePetType')->field("pet_type_id, pet_type_name")->where($map)->select();
+        $this->assign('pet_types', $pet_types);
+        if($data['pet_type_id']){
+            // 获取宠物信息
+            $map['pet_type_id'] = $data['pet_type_id'];
+            $pets = D('Culture/CulturePet')->field("pet_id, pet_name")->where($map)->select();
+            $this->assign('pets', $pets);
+        }
+        $this->display('SaveInfo');
+    }
+
+    /**
+     * [Save 食物添加/编辑]
+     */
+    public function Save()
+    {
+        // 是否ajax请求
+        if(!IS_AJAX)
+        {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        // 添加
+        if(empty($_POST['food_id']))
+        {
+            $this->Add();
+
+        // 编辑
+        } else {
+            $this->Edit();
+        }
+    }
+
+    /**
+     * [Add 食物添加]
+     */
+    private function Add()
+    {
+        // 食物模型
+        $m = D('Culture/CultureFood');
+
+        // 数据自动校验
+        if($m->create($_POST, 1))
+        {
+            $m->created_at = date('Y-m-d H:i:s');
+            $m->updated_at = date('Y-m-d H:i:s');
+            // 数据添加
+            if($m->add())
+            {
+                $this->ajaxReturn(L('common_operation_add_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_add_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn($m->getError(), -1);
+        }
+    }
+
+    /**
+     * [Edit 食物编辑]
+     */
+    private function Edit()
+    {
+        // 食物模型
+        $m = D('Culture/CultureFood');
+
+        // 数据自动校验
+        if($m->create($_POST, 2))
+        {
+            $m->updated_at = date('Y-m-d H:i:s');
+            // 更新数据库
+            if($m->where(array('food_id'=>I('food_id')))->save())
+            {
+                $this->ajaxReturn(L('common_operation_edit_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_edit_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn($m->getError(), -1);
+        }
+    }
+
+    /**
+     * [Delete 食物删除]
+     */
+    public function Delete()
+    {
+        // 是否ajax请求
+        if(!IS_AJAX)
+        {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        // 参数处理
+        $id = I('id');
+
+        // 删除数据
+        if(!empty($id))
+        {
+            // 食物模型
+            $m = D('Culture/CultureFood');
+
+            // 食物是否存在
+            $scene = $m->where(array('food_id'=>$id))->count();
+            if(empty($scene))
+            {
+                $this->ajaxReturn(L('common_user_no_exist_error'), -2);
+            }
+
+            // 删除食物
+            $update_data['deleted_at'] = date('Y-m-d H:i:s');
+            $state = $m->where(array('food_id'=>$id))->save($update_data);
+            if($state !== false)
+            {
+                $this->ajaxReturn(L('common_operation_delete_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_delete_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn(L('common_param_error'), -1);
+        }
+    }
+
+    /**
+     * 获取宠物接口
+     */
+    public function getPet()
+    {
+        $pet_type_id = I('pet_type_id');
+        if(!$pet_type_id){
+            $response_data['code'] = 0;
+            $response_data['msg'] = "缺少参数";
+            echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+            exit();
+        }
+
+        $map['pet_type_id'] = $pet_type_id;
+        $map['deleted_at'] = ["exp", "is null"];
+        $pets = D("Culture/CulturePet")->field("pet_id as id, pet_name as name")->where($map)->select();
+
+        $response_data['code'] = 0;
+        $response_data['msg'] = "获取成功";
+        $response_data['data'] = $pets;
+        echo json_encode($response_data, JSON_UNESCAPED_UNICODE);
+        exit();
+
+    }
+
+}

+ 241 - 0
Application/Admin/Controller/CulturePetController.class.php

@@ -0,0 +1,241 @@
+<?php
+namespace Admin\Controller;
+
+/**
+ * 宠物管理
+ * @author   晓宇
+ * @version  0.0.1
+ * @datetime 2019-03-29
+ */
+class CulturePetController extends CommonController
+{
+    /**
+     * [_initialize 前置操作-继承公共前置方法]
+     */
+    public function _initialize()
+    {
+        // 调用父类前置方法
+        parent::_initialize();
+
+        // 登录校验
+        $this->Is_Login();
+
+        // 权限校验
+        $this->Is_Power();
+    }
+
+    /**
+     * [Index 宠物列表]
+     */
+    public function Index()
+    {
+        // 参数
+        $param = array_merge($_POST, $_GET);
+
+        // 模型模型
+        $m = D('Culture/CulturePet');
+
+        // 条件
+        $where = $this->GetIndexWhere();
+
+        // 分页
+        $number = MyC('admin_page_number');
+        $page_param = array(
+                'number'    =>  $number,
+                'total'     =>  $m->where($where)->count(),
+                'where'     =>  $param,
+                'url'       =>  U('Culture/CulturePet/Index'),
+            );
+        $page = new \My\Page($page_param);
+        // 获取列表
+        $field = array('pet_id', 'pet_name', 'thumb', 'description', 'pet_type_id', 'sale_price', 'created_at', 'updated_at');
+        $list = $this->SetDataHandle($m->field($field)->relation('PetType')->where($where)->limit($page->GetPageStarNumber(), $number)->order('pet_id desc')->select());
+
+        // 参数
+        $this->assign('param', $param);
+
+        // 分页
+        $this->assign('page_html', $page->GetPageHtml());
+
+        // 数据列表
+        $this->assign('list', $list);
+
+        $this->display('Index');
+    }
+
+    /**
+     * [SetDataHandle 数据处理]
+     * @param    [array]      $data [宠物数据]
+     * @return   [array]            [处理好的数据]
+     */
+    private function SetDataHandle($data)
+    {
+        return $data;
+    }
+
+    /**
+     * [GetIndexWhere 宠物列表条件]
+     */
+    private function GetIndexWhere()
+    {
+        $where = array();
+
+        // 模糊
+        if(!empty($_REQUEST['keyword']))
+        {
+            $like_keyword = array('like', '%'.I('keyword').'%');
+            $where[] = array(
+                    'pet_name'      =>  $like_keyword,
+                );
+        }
+
+        // 是否更多条件
+        if(I('is_more', 0) == 1)
+        {
+            // 表达式
+            if(!empty($_REQUEST['time_start']))
+            {
+                $where['created_at'][] = array('gt', I('time_start') . ' 00:00:00');
+            }
+            if(!empty($_REQUEST['time_end']))
+            {
+                $where['created_at'][] = array('lt', I('time_end') . ' 23:59:59');
+            }
+        }
+        
+        $where['deleted_at'] = ["exp", "is null"];
+
+        return $where;
+    }
+
+    /**
+     * [SaveInfo 宠物添加/编辑页面]
+     */
+    public function SaveInfo()
+    {
+        // 宠物信息
+        $data = empty($_REQUEST['pet_id']) ? array() : D('Culture/CulturePet')->find(I('pet_id'));
+        $this->assign('data', $data);
+        // 宠物类型信息
+        $map['deleted_at'] = ["exp", "is null"];
+        $pet_type_list = D('Culture/CulturePetType')->field("pet_type_id, pet_type_name")->where($map)->select();
+        $this->assign('pet_type_list', $pet_type_list);
+        // 场景信息
+        $scene_list = D('Culture/CultureScene')->field("scene_id, scene_name")->where($map)->select();
+        $this->assign('scene_list', $scene_list);
+        $this->display('SaveInfo');
+    }
+
+    /**
+     * [Save 宠物添加/编辑]
+     */
+    public function Save()
+    {
+        // 是否ajax请求
+        if(!IS_AJAX)
+        {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        // 添加
+        if(empty($_POST['pet_id']))
+        {
+            $this->Add();
+
+        // 编辑
+        } else {
+            $this->Edit();
+        }
+    }
+
+    /**
+     * [Add 宠物添加]
+     */
+    private function Add()
+    {
+        // 宠物模型
+        $m = D('Culture/CulturePet');
+
+        // 数据自动校验
+        if($m->create($_POST, 1))
+        {
+            $m->created_at = date('Y-m-d H:i:s');
+            $m->updated_at = date('Y-m-d H:i:s');
+            // 数据添加
+            if($m->add())
+            {
+                $this->ajaxReturn(L('common_operation_add_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_add_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn($m->getError(), -1);
+        }
+    }
+
+    /**
+     * [Edit 宠物编辑]
+     */
+    private function Edit()
+    {
+        // 宠物模型
+        $m = D('Culture/CulturePet');
+
+        // 数据自动校验
+        if($m->create($_POST, 2))
+        {
+            $m->updated_at = date('Y-m-d H:i:s');
+            // 更新数据库
+            if($m->where(array('pet_id'=>I('pet_id')))->save())
+            {
+                $this->ajaxReturn(L('common_operation_edit_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_edit_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn($m->getError(), -1);
+        }
+    }
+
+    /**
+     * [Delete 宠物删除]
+     */
+    public function Delete()
+    {
+        // 是否ajax请求
+        if(!IS_AJAX)
+        {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        // 参数处理
+        $id = I('id');
+
+        // 删除数据
+        if(!empty($id))
+        {
+            // 宠物模型
+            $m = D('Culture/CulturePet');
+
+            // 宠物是否存在
+            $scene = $m->where(array('pet_id'=>$id))->count();
+            if(empty($scene))
+            {
+                $this->ajaxReturn(L('common_user_no_exist_error'), -2);
+            }
+
+            // 删除宠物
+            $update_data['deleted_at'] = date('Y-m-d H:i:s');
+            $state = $m->where(array('pet_id'=>$id))->save($update_data);
+            if($state !== false)
+            {
+                $this->ajaxReturn(L('common_operation_delete_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_delete_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn(L('common_param_error'), -1);
+        }
+    }
+
+}

+ 238 - 0
Application/Admin/Controller/CulturePetTypeController.class.php

@@ -0,0 +1,238 @@
+<?php
+namespace Admin\Controller;
+
+/**
+ * 宠物类型管理
+ * @author   晓宇
+ * @version  0.0.1
+ * @datetime 2019-03-29
+ */
+class CulturePetTypeController extends CommonController
+{
+    /**
+     * [_initialize 前置操作-继承公共前置方法]
+     */
+    public function _initialize()
+    {
+        // 调用父类前置方法
+        parent::_initialize();
+
+        // 登录校验
+        $this->Is_Login();
+
+        // 权限校验
+        $this->Is_Power();
+    }
+
+    /**
+     * [Index 宠物类型列表]
+     */
+    public function Index()
+    {
+        // 参数
+        $param = array_merge($_POST, $_GET);
+
+        // 模型模型
+        $m = D('Culture/CulturePetType');
+
+        // 条件
+        $where = $this->GetIndexWhere();
+
+        // 分页
+        $number = MyC('admin_page_number');
+        $page_param = array(
+                'number'    =>  $number,
+                'total'     =>  $m->where($where)->count(),
+                'where'     =>  $param,
+                'url'       =>  U('Culture/CulturePetType/Index'),
+            );
+        $page = new \My\Page($page_param);
+        // 获取列表
+        $field = array('pet_type_id', 'pet_type_name', 'thumb', 'description', 'created_at', 'updated_at');
+        $list = $this->SetDataHandle($m->field($field)->where($where)->limit($page->GetPageStarNumber(), $number)->order('pet_type_id desc')->select());
+
+        // 参数
+        $this->assign('param', $param);
+
+        // 分页
+        $this->assign('page_html', $page->GetPageHtml());
+
+        // 数据列表
+        $this->assign('list', $list);
+
+        $this->display('Index');
+    }
+
+    /**
+     * [SetDataHandle 数据处理]
+     * @param    [array]      $data [宠物类型数据]
+     * @return   [array]            [处理好的数据]
+     */
+    private function SetDataHandle($data)
+    {
+        return $data;
+    }
+
+    /**
+     * [GetIndexWhere 宠物类型列表条件]
+     */
+    private function GetIndexWhere()
+    {
+        $where = array();
+
+        // 模糊
+        if(!empty($_REQUEST['keyword']))
+        {
+            $like_keyword = array('like', '%'.I('keyword').'%');
+            $where[] = array(
+                    'pet_type_name'      =>  $like_keyword,
+                );
+        }
+
+        // 是否更多条件
+        if(I('is_more', 0) == 1)
+        {
+            // 表达式
+            if(!empty($_REQUEST['time_start']))
+            {
+                $where['created_at'][] = array('gt', I('time_start') . ' 00:00:00');
+            }
+            if(!empty($_REQUEST['time_end']))
+            {
+                $where['created_at'][] = array('lt', I('time_end') . ' 23:59:59');
+            }
+        }
+
+        $where['deleted_at'] = ["exp", "is null"];
+
+        return $where;
+    }
+
+    /**
+     * [SaveInfo 宠物类型添加/编辑页面]
+     */
+    public function SaveInfo()
+    {
+        // 宠物类型信息
+        $data = empty($_REQUEST['pet_type_id']) ? array() : D('Culture/CulturePetType')->find(I('pet_type_id'));
+        $this->assign('data', $data);
+
+        // 场景信息
+        $scene_list = D('Culture/CultureScene')->field("scene_id, scene_name")->where($map)->select();
+        $this->assign('scene_list', $scene_list);
+        $this->display('SaveInfo');
+    }
+
+    /**
+     * [Save 宠物类型添加/编辑]
+     */
+    public function Save()
+    {
+        // 是否ajax请求
+        if(!IS_AJAX)
+        {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        // 添加
+        if(empty($_POST['pet_type_id']))
+        {
+            $this->Add();
+
+        // 编辑
+        } else {
+            $this->Edit();
+        }
+    }
+
+    /**
+     * [Add 宠物类型添加]
+     */
+    private function Add()
+    {
+        // 宠物类型模型
+        $m = D('Culture/CulturePetType');
+
+        // 数据自动校验
+        if($m->create($_POST, 1))
+        {
+            $m->created_at = date('Y-m-d H:i:s');
+            $m->updated_at = date('Y-m-d H:i:s');
+            // 数据添加
+            if($m->add())
+            {
+                $this->ajaxReturn(L('common_operation_add_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_add_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn($m->getError(), -1);
+        }
+    }
+
+    /**
+     * [Edit 宠物类型编辑]
+     */
+    private function Edit()
+    {
+        // 宠物类型模型
+        $m = D('Culture/CulturePetType');
+
+        // 数据自动校验
+        if($m->create($_POST, 2))
+        {
+            $m->updated_at = date('Y-m-d H:i:s');
+            // 更新数据库
+            if($m->where(array('pet_type_id'=>I('pet_type_id')))->save())
+            {
+                $this->ajaxReturn(L('common_operation_edit_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_edit_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn($m->getError(), -1);
+        }
+    }
+
+    /**
+     * [Delete 宠物类型删除]
+     */
+    public function Delete()
+    {
+        // 是否ajax请求
+        if(!IS_AJAX)
+        {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        // 参数处理
+        $id = I('id');
+
+        // 删除数据
+        if(!empty($id))
+        {
+            // 宠物类型模型
+            $m = D('Culture/CulturePetType');
+
+            // 宠物类型是否存在
+            $scene = $m->where(array('pet_type_id'=>$id))->count();
+            if(empty($scene))
+            {
+                $this->ajaxReturn(L('common_user_no_exist_error'), -2);
+            }
+
+            // 删除宠物类型
+            $update_data['deleted_at'] = date('Y-m-d H:i:s');
+            $state = $m->where(array('pet_type_id'=>$id))->save($update_data);
+            if($state !== false)
+            {
+                $this->ajaxReturn(L('common_operation_delete_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_delete_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn(L('common_param_error'), -1);
+        }
+    }
+
+}

+ 248 - 0
Application/Admin/Controller/CultureSceneBackgroundController.class.php

@@ -0,0 +1,248 @@
+<?php
+namespace Admin\Controller;
+
+/**
+ * 场景背景管理
+ * @author   晓宇
+ * @version  0.0.1
+ * @datetime 2019-03-29
+ */
+class CultureSceneBackgroundController extends CommonController
+{
+    /**
+     * [_initialize 前置操作-继承公共前置方法]
+     */
+    public function _initialize()
+    {
+        // 调用父类前置方法
+        parent::_initialize();
+
+        // 登录校验
+        $this->Is_Login();
+
+        // 权限校验
+        $this->Is_Power();
+    }
+
+    /**
+     * [Index 场景背景列表]
+     */
+    public function Index()
+    {
+        // 参数
+        $param = array_merge($_POST, $_GET);
+
+        // 模型模型
+        $m = D('Culture/CultureSceneBackground');
+
+        // 条件
+        $where = $this->GetIndexWhere();
+
+        // 分页
+        $number = MyC('admin_page_number');
+        $page_param = array(
+                'number'    =>  $number,
+                'total'     =>  $m->where($where)->count(),
+                'where'     =>  $param,
+                'url'       =>  U('Culture/CultureSceneBackground/Index'),
+            );
+        $page = new \My\Page($page_param);
+        // 获取列表
+        $field = array('scene_background_id', 'scene_background_name', 'thumb', 'description', 'sale_price', 'is_lock', 'is_unlock_buy', 'created_at', 'updated_at');
+        $list = $this->SetDataHandle($m->field($field)->where($where)->limit($page->GetPageStarNumber(), $number)->order('scene_background_id desc')->select());
+
+        // 参数
+        $this->assign('param', $param);
+
+        // 分页
+        $this->assign('page_html', $page->GetPageHtml());
+
+        // 数据列表
+        $this->assign('list', $list);
+
+        $this->display('Index');
+    }
+
+    /**
+     * [SetDataHandle 数据处理]
+     * @param    [array]      $data [场景背景数据]
+     * @return   [array]            [处理好的数据]
+     */
+    private function SetDataHandle($data)
+    {
+        return $data;
+    }
+
+    /**
+     * [GetIndexWhere 场景背景列表条件]
+     */
+    private function GetIndexWhere()
+    {
+        $where = array();
+
+        // 模糊
+        if(!empty($_REQUEST['keyword']))
+        {
+            $like_keyword = array('like', '%'.I('keyword').'%');
+            $where[] = array(
+                    'scene_background_name'      =>  $like_keyword,
+                );
+        }
+
+        // 是否更多条件
+        if(I('is_more', 0) == 1)
+        {
+            // 表达式
+            if(!empty($_REQUEST['time_start']))
+            {
+                $where['created_at'][] = array('gt', I('time_start') . ' 00:00:00');
+            }
+            if(!empty($_REQUEST['time_end']))
+            {
+                $where['created_at'][] = array('lt', I('time_end') . ' 23:59:59');
+            }
+        }
+
+        $where['deleted_at'] = ["exp", "is null"];
+
+        return $where;
+    }
+
+    /**
+     * [SaveInfo 场景背景添加/编辑页面]
+     */
+    public function SaveInfo()
+    {
+        // 场景背景信息
+        $data = empty($_REQUEST['scene_background_id']) ? array() : D('Culture/CultureSceneBackground')->find(I('scene_background_id'));
+        $this->assign('data', $data);
+        // 场景列表
+        $map['deleted_at'] = ["exp", "is null"];
+        $scenes = D("Culture/CultureScene")->where($map)->select();
+        $this->assign('scenes', $scenes);
+        $this->display('SaveInfo');
+    }
+
+    /**
+     * [Save 场景背景添加/编辑]
+     */
+    public function Save()
+    {
+        // 是否ajax请求
+        if(!IS_AJAX)
+        {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        if(isset($_POST['is_lock'])){
+            $_POST['is_lock'] = 1;
+        }else{
+            $_POST['is_lock'] = 0;
+        }
+        if(isset($_POST['is_unlock_buy'])){
+            $_POST['is_unlock_buy'] = 1;
+        }else{
+            $_POST['is_unlock_buy'] = 0;
+        }
+        // 添加
+        if(empty($_POST['scene_background_id']))
+        {
+            $this->Add();
+
+        // 编辑
+        } else {
+            $this->Edit();
+        }
+    }
+
+    /**
+     * [Add 场景背景添加]
+     */
+    private function Add()
+    {
+        // 场景背景模型
+        $m = D('Culture/CultureSceneBackground');
+
+        // 数据自动校验
+        if($m->create($_POST, 1))
+        {
+            $m->created_at = date('Y-m-d H:i:s');
+            $m->updated_at = date('Y-m-d H:i:s');
+            // 数据添加
+            if($m->add())
+            {
+                $this->ajaxReturn(L('common_operation_add_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_add_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn($m->getError(), -1);
+        }
+    }
+
+    /**
+     * [Edit 场景背景编辑]
+     */
+    private function Edit()
+    {
+        // 场景背景模型
+        $m = D('Culture/CultureSceneBackground');
+
+        // 数据自动校验
+        if($m->create($_POST, 2))
+        {
+            $m->updated_at = date('Y-m-d H:i:s');
+            // 更新数据库
+            if($m->where(array('scene_background_id'=>I('scene_background_id')))->save())
+            {
+                $this->ajaxReturn(L('common_operation_edit_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_edit_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn($m->getError(), -1);
+        }
+    }
+
+    /**
+     * [Delete 场景背景删除]
+     */
+    public function Delete()
+    {
+        // 是否ajax请求
+        if(!IS_AJAX)
+        {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        // 参数处理
+        $id = I('id');
+
+        // 删除数据
+        if(!empty($id))
+        {
+            // 场景背景模型
+            $m = D('Culture/CultureSceneBackground');
+
+            // 场景背景是否存在
+            $scene_background = $m->where(array('scene_background_id'=>$id))->count();
+            if(empty($scene_background))
+            {
+                $this->ajaxReturn(L('common_user_no_exist_error'), -2);
+            }
+
+            // 删除场景背景
+            $update_data['deleted_at'] = date('Y-m-d H:i:s');
+            $state = $m->where(array('scene_background_id'=>$id))->save($update_data);
+            if($state !== false)
+            {
+                $this->ajaxReturn(L('common_operation_delete_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_delete_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn(L('common_param_error'), -1);
+        }
+    }
+
+}

+ 234 - 0
Application/Admin/Controller/CultureSceneController.class.php

@@ -0,0 +1,234 @@
+<?php
+namespace Admin\Controller;
+
+/**
+ * 场景管理
+ * @author   晓宇
+ * @version  0.0.1
+ * @datetime 2019-03-29
+ */
+class CultureSceneController extends CommonController
+{
+    /**
+     * [_initialize 前置操作-继承公共前置方法]
+     */
+    public function _initialize()
+    {
+        // 调用父类前置方法
+        parent::_initialize();
+
+        // 登录校验
+        $this->Is_Login();
+
+        // 权限校验
+        $this->Is_Power();
+    }
+
+    /**
+     * [Index 场景列表]
+     */
+    public function Index()
+    {
+        // 参数
+        $param = array_merge($_POST, $_GET);
+
+        // 模型模型
+        $m = D('Culture/CultureScene');
+
+        // 条件
+        $where = $this->GetIndexWhere();
+
+        // 分页
+        $number = MyC('admin_page_number');
+        $page_param = array(
+                'number'    =>  $number,
+                'total'     =>  $m->where($where)->count(),
+                'where'     =>  $param,
+                'url'       =>  U('Culture/CultureScene/Index'),
+            );
+        $page = new \My\Page($page_param);
+        // 获取列表
+        $field = array('scene_id', 'scene_name', 'thumb', 'description', 'sale_price', 'created_at', 'updated_at');
+        $list = $this->SetDataHandle($m->field($field)->where($where)->limit($page->GetPageStarNumber(), $number)->order('scene_id desc')->select());
+
+        // 参数
+        $this->assign('param', $param);
+
+        // 分页
+        $this->assign('page_html', $page->GetPageHtml());
+
+        // 数据列表
+        $this->assign('list', $list);
+
+        $this->display('Index');
+    }
+
+    /**
+     * [SetDataHandle 数据处理]
+     * @param    [array]      $data [场景数据]
+     * @return   [array]            [处理好的数据]
+     */
+    private function SetDataHandle($data)
+    {
+        return $data;
+    }
+
+    /**
+     * [GetIndexWhere 场景列表条件]
+     */
+    private function GetIndexWhere()
+    {
+        $where = array();
+
+        // 模糊
+        if(!empty($_REQUEST['keyword']))
+        {
+            $like_keyword = array('like', '%'.I('keyword').'%');
+            $where[] = array(
+                    'scene_name'      =>  $like_keyword,
+                );
+        }
+
+        // 是否更多条件
+        if(I('is_more', 0) == 1)
+        {
+            // 表达式
+            if(!empty($_REQUEST['time_start']))
+            {
+                $where['created_at'][] = array('gt', I('time_start') . ' 00:00:00');
+            }
+            if(!empty($_REQUEST['time_end']))
+            {
+                $where['created_at'][] = array('lt', I('time_end') . ' 23:59:59');
+            }
+        }
+
+        $where['deleted_at'] = ["exp", "is null"];
+
+        return $where;
+    }
+
+    /**
+     * [SaveInfo 场景添加/编辑页面]
+     */
+    public function SaveInfo()
+    {
+        // 场景信息
+        $data = empty($_REQUEST['id']) ? array() : D('Culture/CultureScene')->find(I('id'));
+        $this->assign('data', $data);
+        $this->display('SaveInfo');
+    }
+
+    /**
+     * [Save 场景添加/编辑]
+     */
+    public function Save()
+    {
+        // 是否ajax请求
+        if(!IS_AJAX)
+        {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        // 添加
+        if(empty($_POST['id']))
+        {
+            $this->Add();
+
+        // 编辑
+        } else {
+            $this->Edit();
+        }
+    }
+
+    /**
+     * [Add 场景添加]
+     */
+    private function Add()
+    {
+        // 场景模型
+        $m = D('Culture/CultureScene');
+
+        // 数据自动校验
+        if($m->create($_POST, 1))
+        {
+            $m->created_at = date('Y-m-d H:i:s');
+            $m->updated_at = date('Y-m-d H:i:s');
+            // 数据添加
+            if($m->add())
+            {
+                $this->ajaxReturn(L('common_operation_add_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_add_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn($m->getError(), -1);
+        }
+    }
+
+    /**
+     * [Edit 场景编辑]
+     */
+    private function Edit()
+    {
+        // 场景模型
+        $m = D('Culture/CultureScene');
+
+        // 数据自动校验
+        if($m->create($_POST, 2))
+        {
+            $m->updated_at = date('Y-m-d H:i:s');
+            // 更新数据库
+            if($m->where(array('scene_id'=>I('id')))->save())
+            {
+                $this->ajaxReturn(L('common_operation_edit_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_edit_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn($m->getError(), -1);
+        }
+    }
+
+    /**
+     * [Delete 场景删除]
+     */
+    public function Delete()
+    {
+        // 是否ajax请求
+        if(!IS_AJAX)
+        {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        // 参数处理
+        $id = I('id');
+
+        // 删除数据
+        if(!empty($id))
+        {
+            // 场景模型
+            $m = D('Culture/CultureScene');
+
+            // 场景是否存在
+            $scene = $m->where(array('scene_id'=>$id))->count();
+            if(empty($scene))
+            {
+                $this->ajaxReturn(L('common_user_no_exist_error'), -2);
+            }
+
+            // 删除场景
+            $update_data['deleted_at'] = date('Y-m-d H:i:s');
+            $state = $m->where(array('scene_id'=>$id))->save($update_data);
+            if($state !== false)
+            {
+                $this->ajaxReturn(L('common_operation_delete_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_delete_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn(L('common_param_error'), -1);
+        }
+    }
+
+}

+ 234 - 0
Application/Admin/Controller/CultureUserController.class.php

@@ -0,0 +1,234 @@
+<?php
+namespace Admin\Controller;
+
+/**
+ * 玩家管理
+ * @author   晓宇
+ * @version  0.0.1
+ * @datetime 2019-03-29
+ */
+class CultureUserController extends CommonController
+{
+    /**
+     * [_initialize 前置操作-继承公共前置方法]
+     */
+    public function _initialize()
+    {
+        // 调用父类前置方法
+        parent::_initialize();
+
+        // 登录校验
+        $this->Is_Login();
+
+        // 权限校验
+        $this->Is_Power();
+    }
+
+    /**
+     * [Index 玩家列表]
+     */
+    public function Index()
+    {
+        // 参数
+        $param = array_merge($_POST, $_GET);
+
+        // 模型模型
+        $m = D('Culture/CultureUser');
+
+        // 条件
+        $where = $this->GetIndexWhere();
+
+        // 分页
+        $number = MyC('admin_page_number');
+        $page_param = array(
+                'number'    =>  $number,
+                'total'     =>  $m->where($where)->count(),
+                'where'     =>  $param,
+                'url'       =>  U('Culture/CultureUser/Index'),
+            );
+        $page = new \My\Page($page_param);
+        // 获取列表
+        $field = array('user_id', 'thumb', 'description', 'sale_price', 'created_at', 'updated_at');
+        $list = $this->SetDataHandle($m->field($field)->where($where)->limit($page->GetPageStarNumber(), $number)->order('user_id desc')->select());
+
+        // 参数
+        $this->assign('param', $param);
+
+        // 分页
+        $this->assign('page_html', $page->GetPageHtml());
+
+        // 数据列表
+        $this->assign('list', $list);
+
+        $this->display('Index');
+    }
+
+    /**
+     * [SetDataHandle 数据处理]
+     * @param    [array]      $data [玩家数据]
+     * @return   [array]            [处理好的数据]
+     */
+    private function SetDataHandle($data)
+    {
+        return $data;
+    }
+
+    /**
+     * [GetIndexWhere 玩家列表条件]
+     */
+    private function GetIndexWhere()
+    {
+        $where = array();
+
+        // 模糊
+        if(!empty($_REQUEST['keyword']))
+        {
+            $like_keyword = array('like', '%'.I('keyword').'%');
+            $where[] = array(
+                    'user_name'      =>  $like_keyword,
+                );
+        }
+
+        // 是否更多条件
+        if(I('is_more', 0) == 1)
+        {
+            // 表达式
+            if(!empty($_REQUEST['time_start']))
+            {
+                $where['created_at'][] = array('gt', I('time_start') . ' 00:00:00');
+            }
+            if(!empty($_REQUEST['time_end']))
+            {
+                $where['created_at'][] = array('lt', I('time_end') . ' 23:59:59');
+            }
+        }
+
+        $where['deleted_at'] = ["exp", "is null"];
+
+        return $where;
+    }
+
+    /**
+     * [SaveInfo 玩家添加/编辑页面]
+     */
+    public function SaveInfo()
+    {
+        // 玩家信息
+        $data = empty($_REQUEST['id']) ? array() : D('Culture/CultureUser')->find(I('id'));
+        $this->assign('data', $data);
+        $this->display('SaveInfo');
+    }
+
+    /**
+     * [Save 玩家添加/编辑]
+     */
+    public function Save()
+    {
+        // 是否ajax请求
+        if(!IS_AJAX)
+        {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        // 添加
+        if(empty($_POST['id']))
+        {
+            $this->Add();
+
+        // 编辑
+        } else {
+            $this->Edit();
+        }
+    }
+
+    /**
+     * [Add 玩家添加]
+     */
+    private function Add()
+    {
+        // 玩家模型
+        $m = D('Culture/CultureUser');
+
+        // 数据自动校验
+        if($m->create($_POST, 1))
+        {
+            $m->created_at = date('Y-m-d H:i:s');
+            $m->updated_at = date('Y-m-d H:i:s');
+            // 数据添加
+            if($m->add())
+            {
+                $this->ajaxReturn(L('common_operation_add_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_add_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn($m->getError(), -1);
+        }
+    }
+
+    /**
+     * [Edit 玩家编辑]
+     */
+    private function Edit()
+    {
+        // 玩家模型
+        $m = D('Culture/CultureUser');
+
+        // 数据自动校验
+        if($m->create($_POST, 2))
+        {
+            $m->updated_at = date('Y-m-d H:i:s');
+            // 更新数据库
+            if($m->where(array('user_id'=>I('id')))->save())
+            {
+                $this->ajaxReturn(L('common_operation_edit_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_edit_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn($m->getError(), -1);
+        }
+    }
+
+    /**
+     * [Delete 玩家删除]
+     */
+    public function Delete()
+    {
+        // 是否ajax请求
+        if(!IS_AJAX)
+        {
+            $this->error(L('common_unauthorized_access'));
+        }
+
+        // 参数处理
+        $id = I('id');
+
+        // 删除数据
+        if(!empty($id))
+        {
+            // 玩家模型
+            $m = D('Culture/CultureUser');
+
+            // 玩家是否存在
+            $user = $m->where(array('user_id'=>$id))->count();
+            if(empty($user))
+            {
+                $this->ajaxReturn(L('common_user_no_exist_error'), -2);
+            }
+
+            // 删除玩家
+            $update_data['deleted_at'] = date('Y-m-d H:i:s');
+            $state = $m->where(array('user_id'=>$id))->save($update_data);
+            if($state !== false)
+            {
+                $this->ajaxReturn(L('common_operation_delete_success'));
+            } else {
+                $this->ajaxReturn(L('common_operation_delete_error'), -100);
+            }
+        } else {
+            $this->ajaxReturn(L('common_param_error'), -1);
+        }
+    }
+
+}

+ 378 - 0
Application/Admin/Controller/CustomViewController.class.php

@@ -0,0 +1,378 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 自定义页面管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class CustomViewController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 文章列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 参数
+		$param = array_merge($_POST, $_GET);
+
+		// 模型对象
+		$m = M('CustomView');
+
+		// 条件
+		$where = $this->GetIndexWhere();
+
+		// 分页
+		$number = MyC('admin_page_number');
+		$page_param = array(
+				'number'	=>	$number,
+				'total'		=>	$m->where($where)->count(),
+				'where'		=>	$param,
+				'url'		=>	U('Admin/CustomView/Index'),
+			);
+		$page = new \My\Page($page_param);
+
+		// 获取列表
+		$list = $this->SetDataHandle($m->where($where)->limit($page->GetPageStarNumber(), $number)->order('id desc')->select());
+
+		// 是否启用
+		$this->assign('common_is_enable_list', L('common_is_enable_list'));
+
+		// 是否包含头部
+		$this->assign('common_is_header_list', L('common_is_header_list'));
+
+		// 是否包含尾部
+		$this->assign('common_is_footer_list', L('common_is_footer_list'));
+
+		// 是否满屏
+		$this->assign('common_is_full_screen_list', L('common_is_full_screen_list'));
+
+		// 参数
+		$this->assign('param', $param);
+
+		// 分页
+		$this->assign('page_html', $page->GetPageHtml());
+
+		// 数据列表
+		$this->assign('list', $list);
+
+		$this->display('Index');
+	}
+
+	/**
+	 * [SetDataHandle 数据处理]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-29T21:27:15+0800
+	 * @param    [array]      $data [文章数据]
+	 * @return   [array]            [处理好的数据]
+	 */
+	private function SetDataHandle($data)
+	{
+		if(!empty($data))
+		{
+			foreach($data as $k=>$v)
+			{
+				// 时间
+				$data[$k]['add_time'] = date('Y-m-d H:i:s', $v['add_time']);
+				$data[$k]['upd_time'] = date('Y-m-d H:i:s', $v['upd_time']);
+
+				// 是否启用
+				$data[$k]['is_enable_text'] = L('common_is_enable_list')[$v['is_enable']]['name'];
+			}
+		}
+		return $data;
+	}
+
+	/**
+	 * [GetIndexWhere 文章列表条件]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T22:16:29+0800
+	 */
+	private function GetIndexWhere()
+	{
+		$where = array();
+
+		// 模糊
+		if(!empty($_REQUEST['keyword']))
+		{
+			$where[] = array(
+					'title'		=>	array('like', '%'.I('keyword').'%'),
+				);
+		}
+
+		// 是否更多条件
+		if(I('is_more', 0) == 1)
+		{
+			// 等值
+			if(I('is_enable', -1) > -1)
+			{
+				$where['is_enable'] = intval(I('is_enable', 1));
+			}
+			if(I('is_header', -1) > -1)
+			{
+				$where['is_header'] = intval(I('is_header'));
+			}
+			if(I('is_footer', -1) > -1)
+			{
+				$where['is_footer'] = intval(I('is_footer'));
+			}
+
+			// 表达式
+			if(!empty($_REQUEST['time_start']))
+			{
+				$where['add_time'][] = array('gt', strtotime(I('time_start')));
+			}
+			if(!empty($_REQUEST['time_end']))
+			{
+				$where['add_time'][] = array('lt', strtotime(I('time_end')));
+			}
+		}
+		return $where;
+	}
+
+	/**
+	 * [SaveInfo 添加/编辑页面]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:37:02+0800
+	 */
+	public function SaveInfo()
+	{
+		// 数据
+		if(empty($_REQUEST['id']))
+		{
+			$data = array();
+		} else {
+			$data = M('CustomView')->find(I('id'));
+			if(!empty($data['content']))
+			{
+				// 静态资源地址处理
+				$data['content'] = ContentStaticReplace($data['content'], 'get');
+			}
+		}
+		$this->assign('data', $data);
+
+		// 是否启用
+		$this->assign('common_is_enable_list', L('common_is_enable_list'));
+
+		// 是否包含头部
+		$this->assign('common_is_header_list', L('common_is_header_list'));
+
+		// 是否包含尾部
+		$this->assign('common_is_footer_list', L('common_is_footer_list'));
+
+		// 是否满屏
+		$this->assign('common_is_full_screen_list', L('common_is_full_screen_list'));
+
+		$this->display('SaveInfo');
+	}
+
+	/**
+	 * [Save 添加/编辑]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:37:02+0800
+	 */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			$this->Add();
+
+		// 编辑
+		} else {
+			$this->Edit();
+		}
+	}
+
+	/**
+	 * [Add 添加]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-18T16:20:59+0800
+	 */
+	private function Add()
+	{
+		// 模型
+		$m = D('CustomView');
+
+		// 数据自动校验
+		if($m->create($_POST, 1))
+		{
+			// 额外数据处理
+			$m->add_time	=	time();
+			$m->upd_time	=	time();
+			$m->title 		=	I('title');
+			
+			// 静态资源地址处理
+			$m->content 	=	ContentStaticReplace($m->content, 'add');
+
+			// 正则匹配文章图片
+			$temp_image		=	$this->MatchContentImage($m->content);
+			$m->image 		=	serialize($temp_image);
+			$m->image_count	=	count($temp_image);
+			
+			// 数据添加
+			if($m->add())
+			{
+				$this->ajaxReturn(L('common_operation_add_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_add_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [Edit 编辑]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-17T22:13:40+0800
+	 */
+	private function Edit()
+	{
+		// 模型
+		$m = D('CustomView');
+
+		// 数据自动校验
+		if($m->create($_POST, 2))
+		{
+			// 静态资源地址处理
+			$m->content 	=	ContentStaticReplace($m->content, 'add');
+
+			// 正则匹配文章图片
+			$temp_image		=	$this->MatchContentImage($m->content);
+			$m->image 		=	serialize($temp_image);
+			$m->image_count	=	count($temp_image);
+			$m->upd_time	=	time();
+			$m->title 		=	I('title');
+
+			// 数据更新
+			if($m->where(array('id'=>I('id')))->save())
+			{
+				$this->ajaxReturn(L('common_operation_edit_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_edit_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [MatchContentImage 正则匹配文章图片]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-22T18:06:53+0800
+	 * @param    [string]         $content [文章内容]
+	 * @return   [array]    			   [文章图片数组(一维)]
+	 */
+	private function MatchContentImage($content)
+	{
+		if(!empty($content))
+		{
+			$pattern = '/<img.*?src=[\'|\"](\/Public\/Upload\/Article\/image\/.*?[\.gif|\.jpg|\.jpeg|\.png|\.bmp])[\'|\"].*?[\/]?>/';
+			preg_match_all($pattern, $content, $match);
+			return empty($match[1]) ? array() : $match[1];
+		}
+		return array();
+	}
+
+	/**
+	 * [Delete 删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-15T11:03:30+0800
+	 */
+	public function Delete()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 删除数据
+		if(!empty($_POST['id']))
+		{
+			// 更新
+			if(M('CustomView')->delete(I('id')))
+			{
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+	}
+
+	/**
+	 * [StateUpdate 状态更新]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-12T22:23:06+0800
+	 */
+	public function StateUpdate()
+	{
+		// 参数
+		if(empty($_POST['id']) || !isset($_POST['state']))
+		{
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+
+		// 数据更新
+		if(M('CustomView')->where(array('id'=>I('id')))->save(array('is_enable'=>I('state'))))
+		{
+			$this->ajaxReturn(L('common_operation_edit_success'));
+		} else {
+			$this->ajaxReturn(L('common_operation_edit_error'), -100);
+		}
+	}
+}
+?>

+ 97 - 0
Application/Admin/Controller/EmailController.class.php

@@ -0,0 +1,97 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 邮箱设置
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class EmailController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 配置列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 配置信息
+		$data = M('Config')->getField('only_tag,name,describe,value,error_tips');
+		$this->assign('data', $data);
+		$type = I('type', 'email');
+		$this->assign('nav_type', $type);
+		if($type == 'email')
+		{
+			$this->display('Index');
+		} else {
+			$this->display('Message');
+		}
+	}
+
+	/**
+	 * [Save 配置数据保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-02T23:08:19+0800
+	 */
+	public function Save()
+	{
+		$this->MyConfigSave();
+	}
+
+	/**
+	 * [EmailTest 邮件测试]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-03-10T15:30:10+0800
+	 */
+	public function EmailTest()
+	{
+		// 验证码公共基础参数
+		$verify_param = array(
+				'expire_time' => MyC('common_verify_expire_time'),
+				'time_interval'	=>	MyC('common_verify_time_interval'),
+			);
+
+		$obj = new \My\Email($verify_param);
+		$email_param = array(
+				'email'		=>	I('email'),
+				'content'	=>	L('email_test_email_send_content'),
+				'title'		=>	MyC('home_site_name').' - '.L('common_operation_test'),
+			);
+		// 发送
+		if($obj->SendHtml($email_param))
+		{
+			$this->ajaxReturn(L('common_send_success'));
+		} else {
+			$this->ajaxReturn(L('common_send_error').'['.$obj->error.']', -100);
+		}
+	}
+}
+?>

+ 526 - 0
Application/Admin/Controller/FractionController.class.php

@@ -0,0 +1,526 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 学生成绩管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class FractionController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 学生成绩列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 参数
+		$param = array_merge($_POST, $_GET);
+
+		// 模型对象
+		$m = M('Fraction');
+
+		// 条件
+		$where = $this->GetIndexWhere();
+
+		// 分页
+		$number = MyC('admin_page_number');
+		$total = $m->alias('f')->join('__STUDENT__ AS s ON s.id = f.student_id')->where($where)->count();
+		$page_param = array(
+				'number'	=>	$number,
+				'total'		=>	$total,
+				'where'		=>	$param,
+				'url'		=>	U('Admin/Fraction/Index'),
+			);
+		$page = new \My\Page($page_param);
+
+		// 获取列表
+		$field = array('s.username', 's.gender', 's.class_id', 'f.score', 'f.subject_id', 'f.score_id', 'f.id', 'f.student_id', 'f.comment', 'f.add_time');
+		$list = $m->alias('f')->join('__STUDENT__ AS s ON s.id = f.student_id')->where($where)->field($field)->limit($page->GetPageStarNumber(), $number)->order('f.id desc')->select();
+		// 数据列表
+		$this->assign('list', $this->SetDataHandle($list));
+
+		// 班级
+		$this->assign('class_list', $this->GetClassList());
+
+		// 学生成绩等级
+		$this->assign('common_fraction_level_list', L('common_fraction_level_list'));
+
+		// 科目
+		$subject_list = M('Subject')->field(array('id', 'name'))->where(array('is_enable'=>1))->select();
+		$this->assign('subject_list', $subject_list);
+
+		// 成绩期号
+		$this->assign('score_list', M('Score')->select());
+
+		// 参数
+		$this->assign('param', $param);
+
+		// 分页
+		$this->assign('page_html', $page->GetPageHtml());
+
+		// Excel导出地址
+		$this->assign('excel_url', U('Admin/Fraction/ExcelExport', $param));
+
+		// Excel导入基础数据
+		$this->assign('excel_import_tips', L('fraction_excel_import_tips'));
+		$this->assign('excel_import_form_url', U('Admin/Fraction/ExcelImport'));
+		$this->assign('excel_import_format_url', U('Admin/Fraction/ExcelExport', ['type'=>'format_download']));
+
+		$this->display('Index');
+	}
+
+	/**
+	 * [ExcelImport excel导入]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-04-06T16:48:56+0800
+	 */
+	public function ExcelImport()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 文件上传校验
+		$error = FileUploadError('excel');
+		if($error !== true)
+		{
+			$this->ajaxReturn($error, -1);
+		}
+
+		// excel驱动
+		$excel = new \My\Excel(array('title'=>L('excel_fraction_import_title_list'), 'msg'=>L('common_not_data_tips')));
+		$data = $excel->Import();
+		if(empty($data))
+		{
+			$this->ajaxReturn(L('common_not_data_tips'), -2);
+		}
+
+		// 学生成绩对象
+		$m = D('FractionImport');
+
+		// 开始处理导入数据
+		$success = 0;
+		$error = array();
+		foreach($data as $k=>$v)
+		{
+			// 数据处理
+			$v = $this->ExcelImportDataDealWith($v);
+
+			// 数据自动校验
+			if($m->create($v, 1) !== false)
+			{
+				// 数据不能重复
+				if($this->IsExistData($v['student_id'], $v['subject_id'], $v['score_id']))
+				{
+					$error[] = $v['username'].' ['.L('common_data_is_exist_error').']';
+				} else {
+					// 写入数据库
+					if($m->add())
+					{
+						$success++;
+					} else {
+						$error[] = $v['username'].' ['.L('common_operation_add_error').']';
+					}
+				}
+			} else {
+				$error[] = $v['username'].' ['.current($m->getError()).']';
+			}
+		}
+		$this->ajaxReturn(L('common_operation_success'), 0, array('success'=>$success, 'error'=>$error));
+	}
+
+	/**
+	 * [ExcelImportDataDealWith 学生成绩excel导入数据处理]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-04-07T12:04:05+0800
+	 * @param    [array]          $data [学生数据]
+	 * @return   [array]                [处理好的数据]
+	 */
+	private function ExcelImportDataDealWith($data)
+	{
+		if(!empty($data) && is_array($data))
+		{
+			// M对象
+			$score = M('Score');
+			$subject = M('Subject');
+			$student = M('Student');
+
+			// 学期号
+			$data['semester_id'] = MyC('admin_semester_id');
+
+			// 数据安全处理
+			foreach($data as $ks=>$vs)
+			{
+				$data[$ks] = I('data.'.$ks, '', '', $data);
+			}
+
+			// 科目
+			if(!empty($data['subject_name']))
+			{
+				$data['subject_id'] = $subject->where(array('name'=>$data['subject_name']))->getField('id');
+				unset($data['subject_name']);
+			}
+
+			// 期号
+			if(!empty($data['score_name']))
+			{
+				$data['score_id'] = $score->where(array('name'=>$data['score_name']))->getField('id');
+				unset($data['score_name']);
+			}
+
+			// 学生
+			if(!empty($data['username']) && isset($data['number']) && isset($data['id_card']))
+			{
+				$data['student_id'] = $student->where(array('username'=>$data['username'], 'number'=>$data['number'], 'id_card'=>$data['id_card'], 'semester_id'=>$data['semester_id']))->getField('id');
+				unset($data['number'], $data['id_card']);
+			}
+
+			// 添加时间
+			if(!empty($data['add_time']))
+			{
+				$data['add_time'] = strtotime($data['add_time']);
+			} else {
+				$data['add_time'] = time();
+			}
+		}
+		return $data;
+	}
+
+	/**
+	 * [ExcelExport excel文件导出]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-10T15:46:00+0800
+	 */
+	public function ExcelExport()
+	{
+		// 类型
+		switch(I('type'))
+		{
+			// 格式下载类型不查询数据,只导出标题格式
+			case 'format_download' :
+				$title = L('excel_fraction_import_title_list');
+				$data = array();
+				break;
+
+			// 默认按照当前条件查询数据
+			default :
+				$title = L('excel_fraction_title_list');
+				$field = array('s.username', 's.gender', 's.class_id', 'f.score', 'f.subject_id', 'f.score_id', 'f.id', 'f.student_id', 'f.comment', 'f.add_time');
+				$data = $this->SetDataHandle(M('Fraction')->alias('f')->join('__STUDENT__ AS s ON s.id = f.student_id')->where($this->GetIndexWhere())->field($field)->select());
+		}		
+
+		// Excel驱动导出数据
+		$excel = new \My\Excel(array('filename'=>'fraction', 'title'=>$title, 'data'=>$data, 'msg'=>L('common_not_data_tips')));
+		$excel->Export();
+	}
+
+	/**
+	 * [GetIndexWhere 学生列表条件]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T22:16:29+0800
+	 */
+	private function GetIndexWhere()
+	{
+		$where = array();
+
+		// 学期id
+		$where['f.semester_id'] = MyC('admin_semester_id');
+
+		// 模糊
+		if(!empty($_REQUEST['keyword']))
+		{
+			$where['s.username'] = array('like', '%'.I('keyword').'%');
+		}
+
+		// 是否更多条件
+		if(I('is_more', 0) == 1)
+		{
+			// 等值
+			if(I('class_id', 0) > 0)
+			{
+				$where['s.class_id'] = intval(I('class_id'));
+			}
+			if(I('score_id', 0) > 0)
+			{
+				$where['f.score_id'] = intval(I('score_id'));
+			}
+			if(I('subject_id', 0) > 0)
+			{
+				$where['f.subject_id'] = intval(I('subject_id'));
+			}
+
+			if(I('score_level', -1) > -1)
+			{
+				$level = L('common_fraction_level_list')[I('score_level')];
+				$where[] = array(
+						array('f.score' => array('egt', $level['min'])),
+						array('f.score' => array('elt', $level['max'])),
+					);
+			}
+		}
+		return $where;
+	}
+
+	/**
+	 * [SetDataHandle 数据处理]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-29T21:27:15+0800
+	 * @param    [array]      $data [学生数据]
+	 * @return   [array]            [处理好的数据]
+	 */
+	private function SetDataHandle($data)
+	{
+		if(!empty($data))
+		{
+			$score = M('Score');
+			$subject = M('Subject');
+			$class = M('Class');
+			$score_level = L('common_fraction_level_list');
+			foreach($data as $k=>$v)
+			{
+				// 班级
+				$tmp_class = $class->field(array('pid', 'name'))->find($v['class_id']);
+				if(!empty($tmp_class))
+				{
+					$p_name = ($tmp_class['pid'] > 0) ? $class->where(array('id'=>$tmp_class['pid']))->getField('name') : '';
+					$data[$k]['class_name'] = empty($p_name) ? $tmp_class['name'] : $p_name.'-'.$tmp_class['name'];
+				} else {
+					$data[$k]['class_name'] = '';
+				}
+				
+				// 科目
+				$data[$k]['subject_name'] = $subject->where(array('id'=>$v['subject_id']))->getField('name');
+
+				// 成绩期号
+				$data[$k]['score_name'] = $score->where(array('id'=>$v['score_id']))->getField('name');
+
+				// 成绩等级
+				foreach($score_level as $level)
+				{
+					if($v['score'] >= $level['min'] && $v['score'] <= $level['max'])
+					{
+						$data[$k]['score_level'] = $level['name'];
+					}
+				}
+				if(!isset($data[$k]['score_level']))
+				{
+					$data[$k]['score_level'] = '';
+				}
+
+				// 添加时间
+				$data[$k]['add_time'] = date('Y-m-d H:i:s', $v['add_time']);
+
+				// 性别
+				$data[$k]['gender'] = L('common_gender_list')[$v['gender']]['name'];
+			}
+		}
+		return $data;
+	}
+
+	/**
+	 * [SaveInfo 学生成绩添加页面]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:37:02+0800
+	 */
+	public function SaveInfo()
+	{
+		// 参数
+		if(empty($_REQUEST['id']))
+		{
+			$this->error(L('common_param_error'));
+		}
+
+		// 学生信息
+		$student = M('Student')->field(array('id', 'username'))->find(I('id'));
+		if(empty($student))
+		{
+			$this->error(L('fraction_student_error'));
+		}
+		$this->assign('student', $student);
+
+		// 成绩
+		$this->assign('score_list', M('Score')->select());
+
+		// 科目
+		$this->assign('subject_list', M('Subject')->select());
+
+		$this->display('SaveInfo');
+	}
+
+	/**
+	 * [Save 学生成绩添加/编辑]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:37:02+0800
+	 */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			$this->Add();
+
+		// 编辑
+		} else {
+			$this->Edit();
+		}
+	}
+
+	/**
+	 * [Add 学生成绩添加]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-18T16:20:59+0800
+	 */
+	private function Add()
+	{
+		// 学生成绩对象
+		$m = D('Fraction');
+
+		// 数据自动校验
+		if($m->create($_POST, 1))
+		{
+			// 数据不能重复
+			if($this->IsExistData(I('student_id'), I('subject_id'), I('score_id')))
+			{
+				$this->ajaxReturn(L('common_data_is_exist_error'), -2);
+			}
+
+			// 额外数据处理
+			$m->add_time	=	time();
+			$m->comment 	=	I('comment');
+
+			// 学期id
+			$m->semester_id	=	MyC('admin_semester_id');
+			
+			// 写入数据库
+			if($m->add())
+			{
+				$this->ajaxReturn(L('common_operation_add_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_add_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [Edit 学生成绩编辑]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-17T22:13:40+0800
+	 */
+	private function Edit()
+	{
+		$this->error(L('common_unauthorized_access'));
+	}
+
+	/**
+	 * [IsExistData 校验数据不能重复添加]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-08T22:08:46+0800
+	 * @return   [boolean] [存在true, 不存在false]
+	 */
+	private function IsExistData($student_id, $subject_id, $score_id)
+	{
+		// 数据是否已存在
+		$where = array(
+				'semester_id'	=>	MyC('admin_semester_id'),
+				'student_id'	=>	$student_id,
+				'subject_id'	=>	$subject_id,
+				'score_id'		=>	$score_id,
+			);
+		$tmp = M('Fraction')->where($where)->getField('id');
+		return !empty($tmp);
+	}
+
+	/**
+	 * [Delete 学生成绩删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:40:29+0800
+	 */
+	public function Delete()
+	{
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 参数是否有误
+		if(empty($_POST['id']))
+		{
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+
+		// 参数处理
+		list($id, $student_id) = (stripos(I('id'), '-') === false) ? array() : explode('-', I('id'));
+
+		// 删除数据
+		if($id != null && $student_id != null)
+		{
+			if(M('Fraction')->where(array('id'=>$id, 'student_id'=>$student_id))->delete())
+			{
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+	}
+}
+?>

+ 64 - 0
Application/Admin/Controller/IndexController.class.php

@@ -0,0 +1,64 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 首页
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class IndexController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+	}
+
+	/**
+	 * [Index 首页]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-05T21:36:13+0800
+	 */
+	public function Index()
+	{
+		$this->display('Index');
+	}
+
+	/**
+	 * [Init 初始化页面]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-05T21:36:41+0800
+	 */
+	public function Init()
+	{
+		$mysql_ver = M()->query('SELECT VERSION() AS `ver`');
+		$data = array(
+				'server_ver'	=>	php_sapi_name(),
+				'php_ver'		=>	PHP_VERSION,
+				'mysql_ver'		=>	isset($mysql_ver[0]['ver']) ? $mysql_ver[0]['ver'] : '',
+				'os_ver'		=>	PHP_OS,
+				'host'			=>	isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : '',
+				'ver'			=>	L('common_application_name').' '.L('common_application_ver'),
+			);
+		$this->assign('data', $data);
+		$this->display('Init');
+	}
+}
+?>

+ 167 - 0
Application/Admin/Controller/IntervalController.class.php

@@ -0,0 +1,167 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 时段管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class IntervalController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 时段列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 是否启用
+		$this->assign('common_is_enable_list', L('common_is_enable_list'));
+		$this->display('Index');
+	}
+
+	/**
+	 * [GetNodeSon 获取节点子列表]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T15:19:45+0800
+	 */
+	public function GetNodeSon()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 获取数据
+		$field = array('id', 'name', 'sort', 'is_enable');
+		$data = M('Interval')->field($field)->where(array('pid'=>intval(I('id', 0))))->select();
+		if(!empty($data))
+		{
+			foreach($data as $k=>$v)
+			{
+				$data[$k]['is_son']		=	'no';
+				$data[$k]['ajax_url']	=	U('Admin/Interval/GetNodeSon', array('id'=>$v['id']));
+				$data[$k]['delete_url']	=	U('Admin/Interval/Delete');
+				$data[$k]['json']		=	json_encode($v);
+			}
+		}
+		$msg = empty($data) ? L('common_not_data_tips') : L('common_operation_success');
+		$this->ajaxReturn($msg, 0, $data);
+	}
+
+	/**
+	 * [Save 时段保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// id为空则表示是新增
+		$m = D('Interval');
+
+		// 公共额外数据处理
+		$m->sort 	=	intval(I('sort'));
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			if($m->create($_POST, 1))
+			{
+				// 额外数据处理
+				$m->add_time	=	time();
+				$m->name 		=	I('name');
+				
+				// 写入数据库
+				if($m->add())
+				{
+					$this->ajaxReturn(L('common_operation_add_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_add_error'), -100);
+				}
+			}
+		} else {
+			// 编辑
+			if($m->create($_POST, 2))
+			{
+				// 额外数据处理
+				$m->name 		=	I('name');
+
+				// 移除 id
+				unset($m->id);
+
+				// 更新数据库
+				if($m->where(array('id'=>I('id')))->save())
+				{
+					$this->ajaxReturn(L('common_operation_edit_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_edit_error'), -100);
+				}
+			}
+		}
+		$this->ajaxReturn($m->getError(), -1);
+	}
+
+	/**
+	 * [Delete 时段删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function Delete()
+	{
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		$m = D('Interval');
+		if($m->create($_POST, 5))
+		{
+			if($m->delete(I('id')))
+			{
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+}
+?>

+ 170 - 0
Application/Admin/Controller/LinkController.class.php

@@ -0,0 +1,170 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 友情链接
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class LinkController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 获取导航列表
+		$list = M('Link')->field(array('id', 'name', 'url', 'describe', 'sort', 'is_enable', 'is_new_window_open'))->order('sort')->select();
+		$this->assign('list', $list);
+
+		// 是否新窗口打开
+		$this->assign('common_is_new_window_open_list', L('common_is_new_window_open_list'));
+
+		// 是否启用
+		$this->assign('common_is_enable_list', L('common_is_enable_list'));
+
+		$this->display('Index');
+	}
+
+	/**
+	 * [Save 数据保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-02-05T20:12:30+0800
+	 */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// id为空则表示是新增
+		$m = D('Link');
+
+		// 公共额外数据处理
+		$m->sort 		=	intval(I('sort'));
+		$m->describe 	=	I('describe');
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			if($m->create($_POST, 1))
+			{
+				// 额外数据处理
+				$m->add_time	=	time();
+				$m->name 		=	I('name');
+				$m->describe 	=	I('describe');
+				
+				// 写入数据库
+				if($m->add())
+				{
+					$this->ajaxReturn(L('common_operation_add_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_add_error'), -100);
+				}
+			}
+		} else {
+			// 编辑
+			if($m->create($_POST, 2))
+			{
+				// 额外数据处理
+				$m->name 		=	I('name');
+				$m->describe 	=	I('describe');
+
+				// 移除 id
+				unset($m->id);
+
+				// 更新数据库
+				if($m->where(array('id'=>I('id')))->save())
+				{
+					$this->ajaxReturn(L('common_operation_edit_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_edit_error'), -100);
+				}
+			}
+		}
+		$this->ajaxReturn($m->getError(), -1);
+	}
+
+	/**
+	 * [Delete 删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-09T21:13:47+0800
+	 */
+	public function Delete()
+	{
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		$m = D('Link');
+		if($m->create($_POST, 4))
+		{
+			if($m->delete($id))
+			{
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [StateUpdate 状态更新]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-12T22:23:06+0800
+	 */
+	public function StateUpdate()
+	{
+		// 参数
+		if(empty($_POST['id']) || !isset($_POST['state']))
+		{
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+
+		// 数据更新
+		if(M('Link')->where(array('id'=>I('id')))->save(array('is_enable'=>I('state'))))
+		{
+			$this->ajaxReturn(L('common_operation_edit_success'));
+		} else {
+			$this->ajaxReturn(L('common_operation_edit_error'), -100);
+		}
+	}
+}
+?>

+ 235 - 0
Application/Admin/Controller/NavFooterController.class.php

@@ -0,0 +1,235 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 底部导航
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class NavFooterController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 导航列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 获取导航列表
+		$this->assign('list', $this->GetNavList());
+
+		// 文章分类
+		$this->assign('article_class_list', M('ArticleClass')->field(array('id', 'name'))->where(array('is_enable'=>1))->select());
+
+		// 自定义页面
+		$this->assign('customview_list', M('CustomView')->field(array('id', 'title'))->where(array('is_enable'=>1))->select());
+
+		// 是否新窗口打开
+		$this->assign('common_is_new_window_open_list', L('common_is_new_window_open_list'));
+
+		// 是否显示
+		$this->assign('common_is_show_list', L('common_is_show_list'));
+
+		$this->display('Index');
+	}
+
+	/**
+	 * [GetNavList 获取数据列表]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T22:16:29+0800
+	 */
+	private function GetNavList()
+	{
+		$m = M('Navigation');
+		$field = array('id', 'name', 'url', 'value', 'data_type', 'sort', 'is_show', 'is_new_window_open');
+		return NavDataDealWith($m->field($field)->where(array('nav_type'=>'footer'))->order('sort')->select());
+	}
+
+	/**
+     * [Save 添加/编辑]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-07T21:58:19+0800
+     */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 请求类型
+		switch(I('data_type'))
+		{
+			// 自定义导航
+			case 'custom':
+				$this->DataSave(5);
+				break;
+
+			// 文章分类导航
+			case 'article_class':
+				$this->DataSave(6);
+				break;
+
+			// 自读页面导航
+			case 'customview':
+				$this->DataSave(7);
+				break;
+		}
+		$this->ajaxReturn(L('common_param_error'), -1);
+	}
+
+	/**
+	 * [DataSave 导航数据保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-02-05T20:12:30+0800
+	 * @param    [int]   $check_type [校验类型]
+	 */
+	private function DataSave($check_type)
+	{
+		$m = D('Navigation');
+
+		// 数据校验
+		if($m->create($_POST, $check_type))
+		{
+			// 非自定义导航数据处理
+			if(empty($_POST['name']))
+			{
+				switch(I('data_type'))
+				{
+					// 文章分类导航
+					case 'article_class':
+						$temp_name = M('ArticleClass')->where(array('id'=>I('value')))->getField('name');
+						break;
+
+					// 自读页面导航
+					case 'customview':
+						$temp_name = M('CustomView')->where(array('id'=>I('value')))->getField('title');
+						break;
+				}
+				// 只截取16个字符
+				$m->name = mb_substr($temp_name, 0, 16, C('DEFAULT_CHARSET'));
+			} else {
+				$m->name 	=	I('name');
+			}
+
+			// 清除缓存
+			S(C('cache_common_home_nav_footer_key'), null);
+
+			// id为空则表示是新增
+			if(empty($_POST['id']))
+			{
+				// 额外数据处理
+				$m->add_time	=	time();
+				$m->nav_type	=	'footer';
+
+				// 写入数据库
+				if($m->add())
+				{
+					$this->ajaxReturn(L('common_operation_add_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_add_error'), -100);
+				}
+			} else {
+				// 数据编辑
+				if($m->where(array('id'=>I('id')))->save())
+				{
+					$this->ajaxReturn(L('common_operation_edit_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_edit_error'), -100);
+				}
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [Delete 删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-09T21:13:47+0800
+	 */
+	public function Delete()
+	{
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		$m = D('Navigation');
+		if($m->create($_POST, 4))
+		{
+			if($m->delete($id))
+			{
+				// 清除缓存
+				S(C('cache_common_home_nav_footer_key'), null);
+				
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [StateUpdate 状态更新]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-12T22:23:06+0800
+	 */
+	public function StateUpdate()
+	{
+		// 参数
+		if(empty($_POST['id']) || !isset($_POST['state']))
+		{
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+
+		// 数据更新
+		if(M('Navigation')->where(array('id'=>I('id')))->save(array('is_show'=>I('state'))))
+		{
+			// 清除缓存
+			S(C('cache_common_home_nav_footer_key'), null);
+
+			$this->ajaxReturn(L('common_operation_edit_success'));
+		} else {
+			$this->ajaxReturn(L('common_operation_edit_error'), -100);
+		}
+	}
+}
+?>

+ 246 - 0
Application/Admin/Controller/NavHeaderController.class.php

@@ -0,0 +1,246 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 顶部导航
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class NavHeaderController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 导航列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 获取导航列表
+		$this->assign('list', $this->GetNavList());
+
+		// 一级分类
+		$this->assign('nav_header_pid_list', M('Navigation')->field(array('id', 'name'))->where(array('is_show'=>1, 'pid'=>0))->select());
+
+		// 文章分类
+		$this->assign('article_class_list', M('ArticleClass')->field(array('id', 'name'))->where(array('is_enable'=>1))->select());
+
+		// 自定义页面
+		$this->assign('customview_list', M('CustomView')->field(array('id', 'title'))->where(array('is_enable'=>1))->select());
+
+		// 是否新窗口打开
+		$this->assign('common_is_new_window_open_list', L('common_is_new_window_open_list'));
+
+		// 是否显示
+		$this->assign('common_is_show_list', L('common_is_show_list'));
+
+		$this->display('Index');
+	}
+
+	/**
+	 * [GetNavList 获取数据列表]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T22:16:29+0800
+	 */
+	private function GetNavList()
+	{
+		$m = M('Navigation');
+		$field = array('id', 'pid', 'name', 'url', 'value', 'data_type', 'sort', 'is_show', 'is_new_window_open');
+		$data = NavDataDealWith($m->field($field)->where(array('nav_type'=>'header', 'pid'=>0))->order('sort')->select());
+		if(!empty($data))
+		{
+			foreach($data as $k=>$v)
+			{
+				$data[$k]['item'] = NavDataDealWith($m->field($field)->where(array('nav_type'=>'header', 'pid'=>$v['id']))->order('sort')->select());
+			}
+		}
+		return $data;
+	}
+
+	/**
+     * [Save 添加/编辑]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-07T21:58:19+0800
+     */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 请求类型
+		switch(I('data_type'))
+		{
+			// 自定义导航
+			case 'custom':
+				$this->DataSave(5);
+				break;
+
+			// 文章分类导航
+			case 'article_class':
+				$this->DataSave(6);
+				break;
+
+			// 自读页面导航
+			case 'customview':
+				$this->DataSave(7);
+				break;
+		}
+		$this->ajaxReturn(L('common_param_error'), -1);
+	}
+
+	/**
+	 * [DataSave 导航数据保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-02-05T20:12:30+0800
+	 * @param    [int]   $check_type [校验类型]
+	 */
+	private function DataSave($check_type)
+	{
+		$m = D('Navigation');
+
+		// 数据校验
+		if($m->create($_POST, $check_type))
+		{
+			// 非自定义导航数据处理
+			if(empty($_POST['name']))
+			{
+				switch(I('data_type'))
+				{
+					// 文章分类导航
+					case 'article_class':
+						$temp_name = M('ArticleClass')->where(array('id'=>I('value')))->getField('name');
+						break;
+
+					// 自读页面导航
+					case 'customview':
+						$temp_name = M('CustomView')->where(array('id'=>I('value')))->getField('title');
+						break;
+				}
+				// 只截取16个字符
+				$m->name = mb_substr($temp_name, 0, 16, C('DEFAULT_CHARSET'));
+			} else {
+				$m->name 	=	I('name');
+			}
+
+			// 清除缓存
+			S(C('cache_common_home_nav_header_key'), null);
+
+			// id为空则表示是新增
+			if(empty($_POST['id']))
+			{
+				// 额外数据处理
+				$m->add_time	=	time();
+				$m->nav_type	=	'header';
+
+				// 写入数据库
+				if($m->add())
+				{
+					$this->ajaxReturn(L('common_operation_add_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_add_error'), -100);
+				}
+			} else {
+				// 数据编辑
+				if($m->where(array('id'=>I('id')))->save())
+				{
+					$this->ajaxReturn(L('common_operation_edit_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_edit_error'), -100);
+				}
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [Delete 删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-09T21:13:47+0800
+	 */
+	public function Delete()
+	{
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		$m = D('Navigation');
+		if($m->create($_POST, 4))
+		{
+			if($m->delete($id))
+			{
+				// 清除缓存
+				S(C('cache_common_home_nav_header_key'), null);
+
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [StateUpdate 状态更新]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-12T22:23:06+0800
+	 */
+	public function StateUpdate()
+	{
+		// 参数
+		if(empty($_POST['id']) || !isset($_POST['state']))
+		{
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+
+		// 数据更新
+		if(M('Navigation')->where(array('id'=>I('id')))->save(array('is_show'=>I('state'))))
+		{
+			// 清除缓存
+			S(C('cache_common_home_nav_header_key'), null);
+
+			$this->ajaxReturn(L('common_operation_edit_success'));
+		} else {
+			$this->ajaxReturn(L('common_operation_edit_error'), -100);
+		}
+	}
+}
+?>

+ 461 - 0
Application/Admin/Controller/PowerController.class.php

@@ -0,0 +1,461 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 权限管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class PowerController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 权限组列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 获取权限列表
+		$m = M('Power');
+		$field = array('id', 'pid', 'name', 'control', 'action', 'sort', 'is_show', 'icon');
+		$list = $m->field($field)->where(array('pid'=>0))->order('sort')->select();
+		if(!empty($list))
+		{
+			foreach($list as $k=>$v)
+			{
+				$item =  $m->field($field)->where(array('pid'=>$v['id']))->order('sort')->select();
+				if(!empty($item))
+				{
+					$list[$k]['item'] = $item;
+				}
+			}
+		}
+		$this->assign('common_is_show_list', L('common_is_show_list'));
+		$this->assign('list', $list);
+		$this->display('Index');
+	}
+
+	/**
+	 * [PowerSave 权限添加/编辑]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-13T21:41:03+0800
+	 */
+	public function PowerSave()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// id为空则表示是新增
+		$m = D('Power');
+
+		// 公共额外数据处理
+		$m->sort 	=	intval(I('sort'));
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			if($m->create($_POST, 1))
+			{
+				// 额外数据处理
+				$m->add_time	=	time();
+				$m->name 		=	I('name');
+				$m->control 	=	I('control');
+				$m->action 		=	I('action');
+				$m->icon 		=	I('icon');
+				
+				// 写入数据库
+				if($m->add())
+				{
+					// 清除用户权限数据
+					PowerCacheDelete();
+
+					$this->ajaxReturn(L('common_operation_add_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_add_error'), -100);
+				}
+			}
+		} else {
+			// 编辑
+			if($m->create($_POST, 2))
+			{
+				// 额外数据处理
+				$m->name 		=	I('name');
+				$m->control 	=	I('control');
+				$m->action 		=	I('action');
+				$m->icon 		=	I('icon');
+
+				// 移除 id
+				unset($m->id);
+
+				// 更新数据库
+				if($m->where(array('id'=>I('id')))->save())
+				{
+					// 清除用户权限数据
+					PowerCacheDelete();
+
+					$this->ajaxReturn(L('common_operation_edit_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_edit_error'), -100);
+				}
+			}
+		}
+		$this->ajaxReturn($m->getError(), -1);
+	}
+
+	/**
+	 * [PowerDelete 权限删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:40:29+0800
+	 */
+	public function PowerDelete()
+	{
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		$m = D('Power');
+		if($m->create($_POST, 5))
+		{
+			if($m->delete(I('id')))
+			{
+				// 清除用户权限数据
+				PowerCacheDelete();
+
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [Role 角色组列表]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:37:02+0800
+	 */
+	public function Role()
+	{
+		$m = M('Role');
+		$list = $m->field(array('id', 'name', 'is_enable', 'add_time'))->select();
+		if(!empty($list))
+		{
+			foreach($list as $k=>$v)
+			{
+				// 关联查询权限和角色数据
+				if($v['id'] == 1)
+				{
+					$list[$k]['item'] = M('Power')->select();
+				} else {
+					$list[$k]['item'] = $m->alias('r')->join('__ROLE_POWER__ AS rp ON rp.role_id = r.id')->join('__POWER__ AS p ON rp.power_id = p.id')->where(array('r.id'=>$v['id']))->field(array('p.id', 'p.name'))->select();
+				}
+			}
+		}
+		$this->assign('list', $list);
+		$this->display('Role');
+	}
+
+	/**
+	 * [RoleSaveInfo 角色组添加/编辑页面]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:37:02+0800
+	 */
+	public function RoleSaveInfo()
+	{
+		// 角色组
+		$role = M('Role')->field(array('id', 'name', 'is_enable'))->find(I('id'));
+		$role_id = isset($role['id']) ? $role['id'] : $this->admin['role_id'];
+		$power = array();
+		if($role_id > 0)
+		{
+			// 权限关联数据
+			$action = empty($_REQUEST['id']) ? array() : M('RolePower')->where(array('role_id'=>$role_id))->getField('power_id', true);
+
+			// 权限列表
+			$m = M('Power');
+			$power_field = array('id', 'name', 'is_show');
+			$power = $m->field($power_field)->where(array('pid'=>0))->order('sort')->select();
+			if(!empty($power))
+			{
+				foreach($power as $k=>$v)
+				{
+					// 是否有权限
+					$power[$k]['is_power'] = in_array($v['id'], $action) ? 'ok' : 'no';
+
+					// 获取子权限
+					$item =  $m->field($power_field)->where(array('pid'=>$v['id']))->order('sort')->select();
+					if(!empty($item))
+					{
+						foreach($item as $ks=>$vs)
+						{
+							$item[$ks]['is_power'] = in_array($vs['id'], $action) ? 'ok' : 'no';
+						}
+						$power[$k]['item'] = $item;
+					}
+				}
+			}
+		}
+		$this->assign('common_is_enable_list', L('common_is_enable_list'));
+		$this->assign('data', $role);
+		$this->assign('power', $power);
+		$this->display('RoleSaveInfo');
+	}
+
+	/**
+	 * [RoleSave 角色组添加/编辑]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:37:02+0800
+	 */
+	public function RoleSave()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			$this->RoleAdd();
+
+		// 编辑
+		} else {
+			if(I('id') == 1)
+			{
+				$this->error(L('common_do_not_operate'), -10);
+			} else {
+				$this->RoleEdit();
+			}
+		}
+	}
+
+	/**
+	 * [RoleAdd 角色添加]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-18T16:20:59+0800
+	 */
+	private function RoleAdd()
+	{
+		// 角色对象
+		$r = M('Role');
+
+		// 数据自动校验
+		if($r->create($_POST, 1))
+		{
+			// 开启事务
+			$r->startTrans();
+
+			// 角色添加
+			$role_data = array(
+					'name'		=>	I('name'),
+					'is_enable'	=>	I('is_enable'),
+					'add_time'	=>	time(),
+				);
+			$role_id = $r->add($role_data);
+
+			// 角色权限关联添加
+			$rp_state = true;
+			if(!empty($_POST['power_id']) && is_array($_POST['power_id']))
+			{
+				// 角色权限关联对象
+				$rp = M('RolePower');
+				foreach($_POST['power_id'] as $power_id)
+				{
+					if(!empty($power_id))
+					{
+						$rp_data = array(
+								'role_id'	=>	$role_id,
+								'power_id'	=>	$power_id,
+								'add_time'	=>	time(),
+							);
+						if(!$rp->add($rp_data))
+						{
+							$rp_state = false;
+							break;
+						}
+					}
+				}
+			}
+			if($role_id && $rp_state)
+			{
+				// 提交事务
+				$r->commit();
+
+				// 清除用户权限数据
+				PowerCacheDelete();
+
+				$this->ajaxReturn(L('common_operation_add_success'));
+			} else {
+				// 回滚事务
+				$r->rollback();
+				$this->ajaxReturn(L('common_operation_add_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [RoleEdit 角色和角色权限关联编辑]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-17T22:13:40+0800
+	 */
+	private function RoleEdit()
+	{
+		// 角色对象
+		$r = M('Role');
+
+		// 数据自动校验
+		if($r->create($_POST, 2))
+		{
+			// 开启事务
+			$r->startTrans();
+
+			// 角色数据更新
+			$role_data = array(
+					'name'		=>	I('name'),
+					'is_enable'	=>	I('is_enable'),
+				);
+			$r_state = ($r->where(array('id'=>I('id')))->save($role_data) !== false);
+
+			// 角色权限关联对象
+			$rp = M('RolePower');
+
+			// 角色id
+			$role_id = I('id');
+
+			// 权限关联数据删除
+			$rp_del_state = $rp->where(array('role_id'=>$role_id))->delete();
+
+			// 权限关联数据添加
+			$rp_state = true;
+			if(!empty($_POST['power_id']))
+			{
+				$power_id_list = explode(',', $_POST['power_id']);
+				foreach($power_id_list as $power_id)
+				{
+					if(!empty($power_id))
+					{
+						$rp_data = array(
+								'role_id'	=>	$role_id,
+								'power_id'	=>	$power_id,
+								'add_time'	=>	time(),
+							);
+						if(!$rp->add($rp_data))
+						{
+							$rp_state = false;
+							break;
+						}
+					}
+				}
+			}
+			if($r_state !== false && $rp_del_state !== false && $rp_state !== false)
+			{
+				// 提交事务
+				$r->commit();
+
+				// 清除用户权限数据
+				PowerCacheDelete();
+
+				$this->ajaxReturn(L('common_operation_edit_success'));
+			} else {
+				// 回滚事务
+				$r->rollback();
+				$this->ajaxReturn(L('common_operation_edit_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [RoleDelete 角色删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-15T11:03:30+0800
+	 */
+	public function RoleDelete()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 参数是否有误
+		if(empty($_POST['id']))
+		{
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+
+		// 角色模型
+		$r = M('Role');
+
+		// 开启事务
+		$r->startTrans();
+
+		// 删除角色
+		$role_state = $r->delete(I('id'));
+		$rp_state = M('RolePower')->where(array('role_id'=>I('id')))->delete();
+		if($role_state !== false && $rp_state !== false)
+		{
+			// 提交事务
+			$r->commit();
+
+			// 清除用户权限数据
+			PowerCacheDelete();
+
+			$this->ajaxReturn(L('common_operation_delete_success'));
+		} else {
+			// 回滚事务
+			$r->rollback();
+			$this->ajaxReturn(L('common_operation_delete_error'), -100);
+		}
+	}
+}
+?>

+ 188 - 0
Application/Admin/Controller/RegionController.class.php

@@ -0,0 +1,188 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 地区管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class RegionController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 地区列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 地区
+		$this->assign('list', M('Region')->field(array('id', 'name'))->select());
+
+		// 是否启用
+		$this->assign('common_is_enable_list', L('common_is_enable_list'));
+		$this->display('Index');
+	}
+
+	/**
+	 * [GetNodeSon 获取节点子列表]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T15:19:45+0800
+	 */
+	public function GetNodeSon()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 获取数据
+		$field = array('id', 'pid', 'name', 'sort', 'is_enable');
+		$data = M('Region')->field($field)->where(array('pid'=>intval(I('id', 0))))->select();
+		if(!empty($data))
+		{
+			foreach($data as $k=>$v)
+			{
+				$data[$k]['is_son']		=	$this->IsExistSon($v['id']);
+				$data[$k]['ajax_url']	=	U('Admin/Region/GetNodeSon', array('id'=>$v['id']));
+				$data[$k]['delete_url']	=	U('Admin/Region/Delete');
+				$data[$k]['json']		=	json_encode($v);
+			}
+		}
+		$msg = empty($data) ? L('common_not_data_tips') : L('common_operation_success');
+		$this->ajaxReturn($msg, 0, $data);
+	}
+
+	/**
+	 * [IsExistSon 节点是否存在子数据]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T15:22:47+0800
+	 * @param    [int]    $id [节点id]
+	 * @return   [string]     [有数据ok, 则no]
+	 */
+	private function IsExistSon($id)
+	{
+		if(!empty($id))
+		{
+			return (M('Region')->where(array('pid'=>$id))->count() > 0) ? 'ok' : 'no';
+		}
+		return 'no';
+	}
+
+	/**
+	 * [Save 地区保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// id为空则表示是新增
+		$m = D('Region');
+
+		// 公共额外数据处理
+		$m->sort 	=	intval(I('sort'));
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			if($m->create($_POST, 1))
+			{
+				// 额外数据处理
+				$m->add_time	=	time();
+				$m->name 		=	I('name');
+				
+				// 写入数据库
+				if($m->add())
+				{
+					$this->ajaxReturn(L('common_operation_add_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_add_error'), -100);
+				}
+			}
+		} else {
+			// 编辑
+			if($m->create($_POST, 2))
+			{
+				// 额外数据处理
+				$m->name 		=	I('name');
+
+				// 移除 id
+				unset($m->id);
+
+				// 更新数据库
+				if($m->where(array('id'=>I('id')))->save())
+				{
+					$this->ajaxReturn(L('common_operation_edit_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_edit_error'), -100);
+				}
+			}
+		}
+		$this->ajaxReturn($m->getError(), -1);
+	}
+
+	/**
+	 * [Delete 地区删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function Delete()
+	{
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		$m = D('Region');
+		if($m->create($_POST, 5))
+		{
+			if($m->delete(I('id')))
+			{
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+}
+?>

+ 185 - 0
Application/Admin/Controller/RoomController.class.php

@@ -0,0 +1,185 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 教室管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class RoomController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 教室列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		$this->assign('list', M('Room')->field(array('id', 'name'))->where(array('pid'=>0))->select());
+		$this->assign('common_is_enable_list', L('common_is_enable_list'));
+		$this->display('Index');
+	}
+
+	/**
+	 * [GetNodeSon 获取节点子列表]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T15:19:45+0800
+	 */
+	public function GetNodeSon()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 获取数据
+		$field = array('id', 'pid', 'name', 'sort', 'is_enable');
+		$data = M('Room')->field($field)->where(array('pid'=>intval(I('id', 0))))->select();
+		if(!empty($data))
+		{
+			foreach($data as $k=>$v)
+			{
+				$data[$k]['is_son']		=	$this->IsExistSon($v['id']);
+				$data[$k]['ajax_url']	=	U('Admin/Room/GetNodeSon', array('id'=>$v['id']));
+				$data[$k]['delete_url']	=	U('Admin/Room/Delete');
+				$data[$k]['json']		=	json_encode($v);
+			}
+		}
+		$msg = empty($data) ? L('common_not_data_tips') : L('common_operation_success');
+		$this->ajaxReturn($msg, 0, $data);
+	}
+
+	/**
+	 * [IsExistSon 节点是否存在子数据]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T15:22:47+0800
+	 * @param    [int]    $id [节点id]
+	 * @return   [string]     [有数据ok, 则no]
+	 */
+	private function IsExistSon($id)
+	{
+		if(!empty($id))
+		{
+			return (M('Room')->where(array('pid'=>$id))->count() > 0) ? 'ok' : 'no';
+		}
+		return 'no';
+	}
+
+	/**
+	 * [Save 教室保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// id为空则表示是新增
+		$m = D('Room');
+
+		// 公共额外数据处理
+		$m->sort 	=	intval(I('sort'));
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			if($m->create($_POST, 1))
+			{
+				// 额外数据处理
+				$m->add_time	=	time();
+				$m->name 		=	I('name');
+				
+				// 写入数据库
+				if($m->add())
+				{
+					$this->ajaxReturn(L('common_operation_add_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_add_error'), -100);
+				}
+			}
+		} else {
+			// 编辑
+			if($m->create($_POST, 2))
+			{
+				// 额外数据处理
+				$m->name 		=	I('name');
+
+				// 移除 id
+				unset($m->id);
+
+				// 更新数据库
+				if($m->where(array('id'=>I('id')))->save())
+				{
+					$this->ajaxReturn(L('common_operation_edit_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_edit_error'), -100);
+				}
+			}
+		}
+		$this->ajaxReturn($m->getError(), -1);
+	}
+
+	/**
+	 * [Delete 教室删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function Delete()
+	{
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		$m = D('Room');
+		if($m->create($_POST, 5))
+		{
+			if($m->delete(I('id')))
+			{
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+}
+?>

+ 167 - 0
Application/Admin/Controller/ScoreController.class.php

@@ -0,0 +1,167 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 成绩分类管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class ScoreController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 成绩列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 是否启用
+		$this->assign('common_is_enable_list', L('common_is_enable_list'));
+		$this->display('Index');
+	}
+
+	/**
+	 * [GetNodeSon 获取节点子列表]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T15:19:45+0800
+	 */
+	public function GetNodeSon()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 获取数据
+		$field = array('id', 'name', 'sort', 'is_enable');
+		$data = M('Score')->field($field)->where(array('pid'=>intval(I('id', 0))))->select();
+		if(!empty($data))
+		{
+			foreach($data as $k=>$v)
+			{
+				$data[$k]['is_son']		=	'no';
+				$data[$k]['ajax_url']	=	U('Admin/Score/GetNodeSon', array('id'=>$v['id']));
+				$data[$k]['delete_url']	=	U('Admin/Score/Delete');
+				$data[$k]['json']		=	json_encode($v);
+			}
+		}
+		$msg = empty($data) ? L('common_not_data_tips') : L('common_operation_success');
+		$this->ajaxReturn($msg, 0, $data);
+	}
+
+	/**
+	 * [Save 成绩保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// id为空则表示是新增
+		$m = D('Score');
+
+		// 公共额外数据处理
+		$m->sort 	=	intval(I('sort'));
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			if($m->create($_POST, 1))
+			{
+				// 额外数据处理
+				$m->add_time	=	time();
+				$m->name 		=	I('name');
+				
+				// 写入数据库
+				if($m->add())
+				{
+					$this->ajaxReturn(L('common_operation_add_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_add_error'), -100);
+				}
+			}
+		} else {
+			// 编辑
+			if($m->create($_POST, 2))
+			{
+				// 额外数据处理
+				$m->name 		=	I('name');
+
+				// 移除 id
+				unset($m->id);
+
+				// 更新数据库
+				if($m->where(array('id'=>I('id')))->save())
+				{
+					$this->ajaxReturn(L('common_operation_edit_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_edit_error'), -100);
+				}
+			}
+		}
+		$this->ajaxReturn($m->getError(), -1);
+	}
+
+	/**
+	 * [Delete 成绩删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function Delete()
+	{
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		$m = D('Score');
+		if($m->create($_POST, 5))
+		{
+			if($m->delete(I('id')))
+			{
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+}
+?>

+ 167 - 0
Application/Admin/Controller/SemesterController.class.php

@@ -0,0 +1,167 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 学期管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class SemesterController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 学期列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 是否启用
+		$this->assign('common_is_enable_list', L('common_is_enable_list'));
+		$this->display('Index');
+	}
+
+	/**
+	 * [GetNodeSon 获取节点子列表]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T15:19:45+0800
+	 */
+	public function GetNodeSon()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 获取数据
+		$field = array('id', 'name', 'sort', 'is_enable');
+		$data = M('Semester')->field($field)->where(array('pid'=>intval(I('id', 0))))->select();
+		if(!empty($data))
+		{
+			foreach($data as $k=>$v)
+			{
+				$data[$k]['is_son']		=	'no';
+				$data[$k]['ajax_url']	=	U('Admin/Semester/GetNodeSon', array('id'=>$v['id']));
+				$data[$k]['delete_url']	=	U('Admin/Semester/Delete');
+				$data[$k]['json']		=	json_encode($v);
+			}
+		}
+		$msg = empty($data) ? L('common_not_data_tips') : L('common_operation_success');
+		$this->ajaxReturn($msg, 0, $data);
+	}
+
+	/**
+	 * [Save 学期保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// id为空则表示是新增
+		$m = D('Semester');
+
+		// 公共额外数据处理
+		$m->sort 	=	intval(I('sort'));
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			if($m->create($_POST, 1))
+			{
+				// 额外数据处理
+				$m->add_time	=	time();
+				$m->name 		=	I('name');
+				
+				// 写入数据库
+				if($m->add())
+				{
+					$this->ajaxReturn(L('common_operation_add_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_add_error'), -100);
+				}
+			}
+		} else {
+			// 编辑
+			if($m->create($_POST, 2))
+			{
+				// 额外数据处理
+				$m->name 		=	I('name');
+
+				// 移除 id
+				unset($m->id);
+
+				// 更新数据库
+				if($m->where(array('id'=>I('id')))->save())
+				{
+					$this->ajaxReturn(L('common_operation_edit_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_edit_error'), -100);
+				}
+			}
+		}
+		$this->ajaxReturn($m->getError(), -1);
+	}
+
+	/**
+	 * [Delete 学期删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function Delete()
+	{
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		$m = D('Semester');
+		if($m->create($_POST, 5))
+		{
+			if($m->delete(I('id')))
+			{
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+}
+?>

+ 70 - 0
Application/Admin/Controller/SeoController.class.php

@@ -0,0 +1,70 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * seo设置
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class SeoController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 配置列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// url模式
+		$this->assign('seo_url_model_list', L('seo_url_model_list'));
+
+		// 文章标题seo方案
+		$this->assign('seo_article_browser_list', L('seo_article_browser_list'));
+
+		// 频道标题seo方案
+		$this->assign('seo_channel_browser_list', L('seo_channel_browser_list'));
+
+		// 配置信息
+		$data = M('Config')->getField('only_tag,name,describe,value,error_tips');
+		$this->assign('data', $data);
+		
+		$this->display('Index');
+	}
+
+	/**
+	 * [Save 配置数据保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-02T23:08:19+0800
+	 */
+	public function Save()
+	{
+		$this->MyConfigSave();
+	}
+}
+?>

+ 109 - 0
Application/Admin/Controller/SiteController.class.php

@@ -0,0 +1,109 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 站点设置
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class SiteController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 配置列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 时区
+		$this->assign('site_timezone_list', L('site_timezone_list'));
+
+		// 站点状态
+		$this->assign('site_site_state_list', L('site_site_state_list'));
+
+		// 是否开启用户注册
+		$this->assign('site_user_reg_state_list', L('site_user_reg_state_list'));
+
+		// 是否开启用户登录
+		$this->assign('site_user_login_state_list', L('site_user_login_state_list'));
+
+		// 获取验证码-开启图片验证码
+		$this->assign('site_img_verify_state_list', L('site_img_verify_state_list'));
+
+		// 配置信息
+		$data = M('Config')->getField('only_tag,name,describe,value,error_tips');
+		$this->assign('data', $data);
+		$this->assign('nav_type', 'site');
+		
+		$this->display('Index');
+	}
+
+	/**
+	 * [Save 配置数据保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-02T23:08:19+0800
+	 */
+	public function Save()
+	{
+		// 站点logo
+		if(isset($_FILES['home_site_logo_img']['error']))
+		{
+			// 文件上传校验
+			$error = FileUploadError('home_site_logo_img');
+			if($error !== true)
+			{
+				$this->ajaxReturn($error, -1);
+			}
+
+			// 文件类型
+			list($type, $suffix) = explode('/', $_FILES['home_site_logo_img']['type']);
+			$path = 'Public/Upload/Home/image/';
+			if(!is_dir($path))
+			{
+				mkdir(ROOT_PATH.$path, 0777, true);
+			}
+			$filename = 'home_logo.'.$suffix;
+			$home_site_logo = $path.$filename;
+			if(move_uploaded_file($_FILES['home_site_logo_img']['tmp_name'], ROOT_PATH.$home_site_logo))
+			{
+				$_POST['home_site_logo'] = '/'.$home_site_logo;
+			}
+		}
+
+		// 站点状态值处理
+		if(!isset($_POST['home_user_reg_state']))
+		{
+			$_POST['home_user_reg_state'] = '';
+		}
+
+		// 基础配置
+		$this->MyConfigSave();
+	}
+}
+?>

+ 67 - 0
Application/Admin/Controller/SmsController.class.php

@@ -0,0 +1,67 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 短信设置
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class SmsController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 配置列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 配置信息
+		$data = M('Config')->getField('only_tag,name,describe,value,error_tips');
+		$this->assign('data', $data);
+		$type = I('type', 'sms');
+		$this->assign('nav_type', $type);
+		if($type == 'sms')
+		{
+			$this->display('Index');
+		} else {
+			$this->display('Message');
+		}
+	}
+
+	/**
+	 * [Save 配置数据保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-02T23:08:19+0800
+	 */
+	public function Save()
+	{
+		$this->MyConfigSave();
+	}
+}
+?>

+ 625 - 0
Application/Admin/Controller/StudentController.class.php

@@ -0,0 +1,625 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 学生管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class StudentController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 学生列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 参数
+		$param = array_merge($_POST, $_GET);
+
+		// 模型对象
+		$m = M('Student');
+
+		// 条件
+		$where = $this->GetIndexWhere();
+
+		// 分页
+		$number = MyC('admin_page_number');
+		$page_param = array(
+				'number'	=>	$number,
+				'total'		=>	$m->where($where)->count(),
+				'where'		=>	$param,
+				'url'		=>	U('Admin/Student/Index'),
+			);
+		$page = new \My\Page($page_param);
+
+		// 获取列表
+		$list = $this->SetDataHandle($m->where($where)->limit($page->GetPageStarNumber(), $number)->order('id desc')->select());
+
+		// 性别
+		$this->assign('common_gender_list', L('common_gender_list'));
+
+		// 学生状态
+		$this->assign('common_student_state_list', L('common_student_state_list'));
+
+		// 缴费状态
+		$this->assign('common_tuition_state_list', L('common_tuition_state_list'));
+
+		// 地区
+		$region_list = M('Region')->field(array('id', 'name'))->where(array('is_enable'=>1))->select();
+		$this->assign('region_list', $region_list);
+
+		// 班级
+		$this->assign('class_list', $this->GetClassList());
+
+		// 参数
+		$this->assign('param', $param);
+
+		// 分页
+		$this->assign('page_html', $page->GetPageHtml());
+
+		// 数据列表
+		$this->assign('list', $list);
+
+		// Excel导出地址
+		$this->assign('excel_url', U('Admin/Student/ExcelExport', $param));
+
+		// Excel导入基础数据
+		$this->assign('excel_import_tips', L('student_excel_import_tips'));
+		$this->assign('excel_import_form_url', U('Admin/Student/ExcelImport'));
+		$this->assign('excel_import_format_url', U('Admin/Student/ExcelExport', ['type'=>'format_download']));
+
+		$this->display('Index');
+	}
+
+	/**
+	 * [ExcelImport excel导入]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-04-06T16:48:56+0800
+	 */
+	public function ExcelImport()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 文件上传校验
+		$error = FileUploadError('excel');
+		if($error !== true)
+		{
+			$this->ajaxReturn($error, -1);
+		}
+
+		// excel驱动
+		$excel = new \My\Excel(array('title'=>L('excel_student_impoet_title_list'), 'msg'=>L('common_not_data_tips')));
+		$data = $excel->Import();
+		if(empty($data))
+		{
+			$this->ajaxReturn(L('common_not_data_tips'), -2);
+		}
+
+		// 学生导入模型
+		$m = D('StudentImport');
+
+		// 开始处理导入数据
+		$success = 0;
+		$error = array();
+		foreach($data as $k=>$v)
+		{
+			// 数据处理
+			$v = $this->ExcelImportDataDealWith($v);
+
+			// 数据自动校验
+			if($m->create($v, 1) !== false)
+			{
+				// 额外数据处理
+				$m->birthday	=	strtotime($v['birthday']);
+				$m->semester_id	=	MyC('admin_semester_id');
+				
+				// 开启事务
+				$m->startTrans();
+
+				// 学生是否已存在编号
+				$number = $m->where(array('id_card'=>I('id_card')))->getField('number');
+
+				// 数据写入
+				$student_id = $m->add();
+
+				// 更新学号
+				if(empty($number))
+				{
+					$number = GenerateStudentNumber($student_id);
+				}
+				$number_state = $m->where(array('id'=>$student_id))->save(array('number'=>$number));
+
+				if($student_id > 0 && $number_state !== false)
+				{
+					// 提交事务
+					$m->commit();
+					$success++;
+				} else {
+					// 回滚事务
+					$m->rollback();
+					$error[] = $v['username'].' ['.L('common_operation_add_error').']';
+				}
+			} else {
+				$error[] = $v['username'].' ['.current($m->getError()).']';
+			}
+		}
+		$this->ajaxReturn(L('common_operation_success'), 0, array('success'=>$success, 'error'=>$error));
+	}
+
+	/**
+	 * [ExcelImportDataDealWith 学生excel导入数据处理]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-04-07T12:04:05+0800
+	 * @param    [array]          $data [学生数据]
+	 * @return   [array]                [处理好的数据]
+	 */
+	private function ExcelImportDataDealWith($data)
+	{
+		if(!empty($data) && is_array($data))
+		{
+			// 数据列表
+			$gender_list = LangValueKeyFlip(L('common_gender_list'), 0);
+			$student_state_list = LangValueKeyFlip(L('common_student_state_list'), 0);
+			$tuition_state_list = LangValueKeyFlip(L('common_tuition_state_list'), 0);
+
+			// M对象
+			$r = M('Region');
+			$c = M('Class');
+
+
+			// 删除n学生编号
+			if(isset($data['number']))
+			{
+				unset($data['number']);
+			}
+
+			// 数据安全处理
+			foreach($data as $ks=>$vs)
+			{
+				$data[$ks] = I('data.'.$ks, '', '', $data);
+			}
+			
+			// 性别
+			if(!empty($data['gender']))
+			{
+				// 性别
+				$data['gender'] = isset($gender_list[$data['gender']]) ? $gender_list[$data['gender']] : $gender_list['default'];
+			}
+
+			// 学生状态
+			if(!empty($data['state']))
+			{
+				$data['state'] = isset($student_state_list[$data['state']]) ? $student_state_list[$data['state']] : $student_state_list['default'];
+			}
+
+			// 缴费状态
+			if(!empty($data['tuition_state']))
+			{
+				$data['tuition_state'] = isset($tuition_state_list[$data['tuition_state']]) ? $tuition_state_list[$data['tuition_state']] : $tuition_state_list['default'];
+			}
+
+			// 地区
+			if(!empty($data['region_name']))
+			{
+				$data['region_id'] = $r->where(array('name'=>$data['region_name']))->getField('id');
+				unset($data['region_name']);
+			}
+
+			// 班级
+			if(!empty($data['class_name']))
+			{
+				if(strpos($data['class_name'], '-') === false)
+				{
+					$temp_class_name = $data['class_name'];
+				} else {
+					$temp_ex = explode('-', $data['class_name']);
+					$temp_class_name = $temp_ex[1];
+				}
+				$data['class_id'] = $c->where(array('name'=>$temp_class_name))->getField('id');
+				unset($data['class_name']);
+			}
+
+			// 添加时间
+			if(!empty($data['add_time']))
+			{
+				$data['add_time'] = strtotime($data['add_time']);
+			} else {
+				$data['add_time'] = time();
+			}
+		}
+		return $data;
+	}
+
+	/**
+	 * [ExcelExport excel文件导出]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-10T15:46:00+0800
+	 */
+	public function ExcelExport()
+	{
+		// 类型
+		switch(I('type'))
+		{
+			// 格式下载类型不查询数据,只导出标题格式
+			case 'format_download' :
+				$title = L('excel_student_impoet_title_list');
+				$data = array();
+				break;
+
+			// 默认按照当前条件查询数据
+			default :
+				$title = L('excel_student_title_list');
+				$data = $this->SetDataHandle(M('Student')->where($this->GetIndexWhere())->select());
+		}
+
+		// Excel驱动导出数据
+		$excel = new \My\Excel(array('filename'=>'student', 'title'=>$title, 'data'=>$data, 'msg'=>L('common_not_data_tips')));
+		$excel->Export();
+	}
+
+	/**
+	 * [SetDataHandle 数据处理]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-29T21:27:15+0800
+	 * @param    [array]      $data [学生数据]
+	 * @return   [array]            [处理好的数据]
+	 */
+	private function SetDataHandle($data)
+	{
+		if(!empty($data))
+		{
+			$c = M('Class');
+			$r = M('Region');
+			foreach($data as $k=>$v)
+			{
+				// 班级
+				$tmp_class = $c->field(array('pid', 'name'))->find($v['class_id']);
+				if(!empty($tmp_class))
+				{
+					$p_name = ($tmp_class['pid'] > 0) ? $c->where(array('id'=>$tmp_class['pid']))->getField('name') : '';
+					$data[$k]['class_name'] = empty($p_name) ? $tmp_class['name'] : $p_name.'-'.$tmp_class['name'];
+				} else {
+					$data[$k]['class_name'] = '';
+				}
+				
+				// 地区
+				$data[$k]['region_name'] = $r->where(array('id'=>$v['region_id']))->getField('name');
+
+				// 出生
+				$data[$k]['birthday'] = date('Y-m-d', $v['birthday']);
+
+				// 报名时间
+				$data[$k]['add_time'] = date('Y-m-d H:i:s', $v['add_time']);
+
+				// 更新时间
+				$data[$k]['upd_time'] = date('Y-m-d H:i:s', $v['upd_time']);
+
+				// 性别
+				$data[$k]['gender'] = L('common_gender_list')[$v['gender']]['name'];
+
+				// 状态
+				$data[$k]['state'] = L('common_student_state_list')[$v['state']]['name'];
+
+				// 缴费状态
+				$data[$k]['tuition_state'] = L('common_tuition_state_list')[$v['tuition_state']]['name'];
+			}
+		}
+		return $data;
+	}
+
+	/**
+	 * [GetIndexWhere 学生列表条件]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T22:16:29+0800
+	 */
+	private function GetIndexWhere()
+	{
+		$where = array();
+
+		// 学期id
+		$where['semester_id'] = MyC('admin_semester_id');
+
+		// 模糊
+		if(!empty($_REQUEST['keyword']))
+		{
+			$like_keyword = array('like', '%'.I('keyword').'%');
+			$where[] = array(
+					'username'		=>	$like_keyword,
+					'id_card'		=>	$like_keyword,
+					'number'		=>	$like_keyword,
+					'tel'			=>	$like_keyword,
+					'my_mobile'		=>	$like_keyword,
+					'parent_mobile'	=>	$like_keyword,
+					'email'			=>	$like_keyword,
+					'_logic'		=>	'or',
+				);
+		}
+
+		// 是否更多条件
+		if(I('is_more', 0) == 1)
+		{
+			// 等值
+			if(I('class_id', 0) > 0)
+			{
+				$where['class_id'] = intval(I('class_id'));
+			}
+			if(I('region_id', 0) > 0)
+			{
+				$where['region_id'] = intval(I('region_id'));
+			}
+			if(I('gender', -1) > -1)
+			{
+				$where['gender'] = intval(I('gender', 0));
+			}
+			if(I('state', -1) > -1)
+			{
+				$where['state'] = intval(I('state', 0));
+			}
+			if(I('tuition_state', -1) > -1)
+			{
+				$where['tuition_state'] = intval(I('tuition_state', 0));
+			}
+
+			// 表达式
+			if(!empty($_REQUEST['time_start']))
+			{
+				$where['birthday'][] = array('gt', strtotime(I('time_start')));
+			}
+			if(!empty($_REQUEST['time_end']))
+			{
+				$where['birthday'][] = array('lt', strtotime(I('time_end')));
+			}
+		}
+		return $where;
+	}
+
+	/**
+	 * [SaveInfo 学生添加/编辑页面]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:37:02+0800
+	 */
+	public function SaveInfo()
+	{
+		// 学生信息
+		$data = empty($_REQUEST['id']) ? array() : M('Student')->find(I('id'));
+		if(!empty($data['birthday']))
+		{
+			$data['birthday'] = date('Y-m-d', $data['birthday']);
+		}
+		$this->assign('data', $data);
+
+		// 地区
+		$region_list = M('Region')->field(array('id', 'name'))->where(array('is_enable'=>1))->select();
+		$this->assign('region_list', $region_list);
+
+		// 班级
+		$this->assign('class_list', $this->GetClassList());
+
+		// 性别
+		$this->assign('common_gender_list', L('common_gender_list'));
+
+		// 学生状态
+		$this->assign('common_student_state_list', L('common_student_state_list'));
+
+		// 缴费状态
+		$this->assign('common_tuition_state_list', L('common_tuition_state_list'));
+
+		$this->display('SaveInfo');
+	}
+
+	/**
+	 * [Save 学生添加/编辑]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:37:02+0800
+	 */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			$this->Add();
+
+		// 编辑
+		} else {
+			$this->Edit();
+		}
+	}
+
+	/**
+	 * [Add 学生添加]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-18T16:20:59+0800
+	 */
+	private function Add()
+	{
+		// 学生模型
+		$m = D('Student');
+
+		// 数据自动校验
+		if($m->create($_POST, 1))
+		{
+			// 额外数据处理
+			$m->add_time	=	time();
+			$m->birthday	=	strtotime($m->birthday);
+			$m->semester_id	=	MyC('admin_semester_id');
+			$m->username 	=	I('username');
+			$m->address 	=	I('address');
+			
+			// 开启事务
+			$m->startTrans();
+
+			// 学生是否已存在编号
+			$number = $m->where(array('id_card'=>I('id_card')))->getField('number');
+
+			// 数据写入
+			$student_id = $m->add();
+
+			// 更新学号
+			if(empty($number))
+			{
+				$number = GenerateStudentNumber($student_id);
+			}
+			$number_state = $m->where(array('id'=>$student_id))->save(array('number'=>$number));
+
+			if($student_id > 0 && $number_state !== false)
+			{
+				// 提交事务
+				$m->commit();
+				$this->ajaxReturn(L('common_operation_add_success'));
+			} else {
+				// 回滚事务
+				$m->rollback();
+				$this->ajaxReturn(L('common_operation_add_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [Edit 学生编辑]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-17T22:13:40+0800
+	 */
+	private function Edit()
+	{
+		// 学生模型
+		$m = D('Student');
+
+		// 数据自动校验
+		if($m->create($_POST, 2))
+		{
+			// 额外数据处理
+			if(!empty($m->birthday))
+			{
+				$m->birthday	=	strtotime($m->birthday);
+			}
+			$m->username 	=	I('username');
+			$m->address 	=	I('address');
+			$m->upd_time	=	time();
+
+			// 移除不能更新的数据
+			unset($m->id_card, $m->number);
+
+			// 更新数据库
+			if($m->where(array('id'=>I('id'), 'id_card'=>I('id_card'), 'number'=>I('number')))->save())
+			{
+				$this->ajaxReturn(L('common_operation_edit_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_edit_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [Delete 学生删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-15T11:03:30+0800
+	 */
+	public function Delete()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 参数处理
+		list($id, $id_card) = (stripos(I('id'), '-') === false) ? array() : explode('-', I('id'));
+
+		// 删除数据
+		if($id != null && $id_card != null)
+		{
+			// 学生模型
+			$s = M('Student');
+
+			// 学生是否存在
+			$student = $s->where(array('id'=>$id, 'id_card'=>$id_card))->getField('id');
+			if(empty($student))
+			{
+				$this->ajaxReturn(L('student_no_exist_error'), -2);
+			}
+
+			// 开启事务
+			$s->startTrans();
+
+			// 删除学生
+			$s_state = $s->where(array('id'=>$id, 'id_card'=>$id_card))->delete();
+
+			// 删除成绩
+			$f_state = M('Fraction')->where(array('student_id'=>$id))->delete();
+			if($s_state !== false && $f_state !== false)
+			{
+				// 提交事务
+				$s->commit();
+
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				// 回滚事务
+				$s->rollback();
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+	}
+}
+?>

+ 167 - 0
Application/Admin/Controller/SubjectController.class.php

@@ -0,0 +1,167 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 科目管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class SubjectController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 科目列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 是否启用
+		$this->assign('common_is_enable_list', L('common_is_enable_list'));
+		$this->display('Index');
+	}
+
+	/**
+	 * [GetNodeSon 获取节点子列表]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T15:19:45+0800
+	 */
+	public function GetNodeSon()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 获取数据
+		$field = array('id', 'name', 'sort', 'is_enable');
+		$data = M('Subject')->field($field)->where(array('pid'=>intval(I('id', 0))))->select();
+		if(!empty($data))
+		{
+			foreach($data as $k=>$v)
+			{
+				$data[$k]['is_son']		=	'no';
+				$data[$k]['ajax_url']	=	U('Admin/Subject/GetNodeSon', array('id'=>$v['id']));
+				$data[$k]['delete_url']	=	U('Admin/Subject/Delete');
+				$data[$k]['json']		=	json_encode($v);
+			}
+		}
+		$msg = empty($data) ? L('common_not_data_tips') : L('common_operation_success');
+		$this->ajaxReturn($msg, 0, $data);
+	}
+
+	/**
+	 * [Save 科目保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// id为空则表示是新增
+		$m = D('Subject');
+
+		// 公共额外数据处理
+		$m->sort 	=	intval(I('sort'));
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			if($m->create($_POST, 1))
+			{
+				// 额外数据处理
+				$m->add_time	=	time();
+				$m->name 		=	I('name');
+				
+				// 写入数据库
+				if($m->add())
+				{
+					$this->ajaxReturn(L('common_operation_add_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_add_error'), -100);
+				}
+			}
+		} else {
+			// 编辑
+			if($m->create($_POST, 2))
+			{
+				// 额外数据处理
+				$m->name 		=	I('name');
+
+				// 移除 id
+				unset($m->id);
+
+				// 更新数据库
+				if($m->where(array('id'=>I('id')))->save())
+				{
+					$this->ajaxReturn(L('common_operation_edit_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_edit_error'), -100);
+				}
+			}
+		}
+		$this->ajaxReturn($m->getError(), -1);
+	}
+
+	/**
+	 * [Delete 科目删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function Delete()
+	{
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		$m = D('Subject');
+		if($m->create($_POST, 5))
+		{
+			if($m->delete(I('id')))
+			{
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+}
+?>

+ 456 - 0
Application/Admin/Controller/TeacherController.class.php

@@ -0,0 +1,456 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 教师管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class TeacherController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 教师列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 参数
+		$param = array_merge($_POST, $_GET);
+
+		// 模型对象
+		$m = M('Teacher');
+
+		// 条件
+		$where = $this->GetIndexWhere();
+
+		// 分页
+		$number = MyC('admin_page_number');
+		$page_param = array(
+				'number'	=>	$number,
+				'total'		=>	$m->where($where)->count(),
+				'where'		=>	$param,
+				'url'		=>	U('Admin/Teacher/Index'),
+			);
+		$page = new \My\Page($page_param);
+
+		// 获取列表
+		$list = $this->SetDataHandle($m->where($where)->limit($page->GetPageStarNumber(), $number)->select());
+
+		// 性别
+		$this->assign('common_gender_list', L('common_gender_list'));
+
+		// 教师状态
+		$this->assign('common_teacher_state_list', L('common_teacher_state_list'));
+
+		// 参数
+		$this->assign('param', $param);
+
+		// 分页
+		$this->assign('page_html', $page->GetPageHtml());
+
+		// 数据列表
+		$this->assign('list', $list);
+
+		// Excel地址
+		$this->assign('excel_url', U('Admin/Teacher/ExcelExport', $param));
+
+		$this->display('Index');
+	}
+
+	/**
+	 * [ExcelExport excel文件导出]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-10T15:46:00+0800
+	 */
+	public function ExcelExport()
+	{
+		// 条件
+		$where = $this->GetIndexWhere();
+
+		// 读取数据
+		$data = $this->SetDataHandle(M('Teacher')->where($where)->select());
+
+		// Excel驱动导出数据
+		$excel = new \My\Excel(array('filename'=>'teacher', 'title'=>L('excel_teacher_title_list'), 'data'=>$data, 'msg'=>L('common_not_data_tips')));
+		$excel->Export();
+	}
+
+	/**
+	 * [SetDataHandle 数据处理]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-29T21:27:15+0800
+	 * @param    [array]      $data [教师数据]
+	 * @return   [array]            [处理好的数据]
+	 */
+	private function SetDataHandle($data)
+	{
+		if(!empty($data))
+		{
+			$ts = M('TeacherSubject');
+			foreach($data as $k=>$v)
+			{
+				// 出生
+				$data[$k]['birthday'] = date('Y-m-d', $v['birthday']);
+
+				// 创建时间
+				$data[$k]['add_time'] = date('Y-m-d H:i:s', $v['add_time']);
+
+				// 更新时间
+				$data[$k]['upd_time'] = date('Y-m-d H:i:s', $v['upd_time']);
+
+				// 性别
+				$data[$k]['gender'] = L('common_gender_list')[$v['gender']]['name'];
+
+				// 状态
+				$data[$k]['state'] = L('common_teacher_state_list')[$v['state']]['name'];
+
+				// 贯通科目
+				$temp = $ts->alias('AS ts')->join('__SUBJECT__ AS s ON ts.subject_id = s.id')->where(array('ts.teacher_id'=>$v['id']))->field(array('s.name AS name'))->getField('name', true);
+				$data[$k]['subject_list'] = empty($temp) ? '' : implode(', ', $temp);
+			}
+		}
+		return $data;
+	}
+
+	/**
+	 * [GetIndexWhere 教师列表条件]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T22:16:29+0800
+	 */
+	private function GetIndexWhere()
+	{
+		$where = array();
+
+		// 模糊
+		if(!empty($_REQUEST['keyword']))
+		{
+			$like_keyword = array('like', '%'.I('keyword').'%');
+			$where[] = array(
+					'username'	=>	$like_keyword,
+					'id_card'	=>	$like_keyword,
+					'tel'		=>	$like_keyword,
+					'mobile'	=>	$like_keyword,
+					'address'	=>	$like_keyword,
+					'email'		=>	$like_keyword,
+					'_logic'	=>	'or',
+				);
+		}
+
+		// 是否更多条件
+		if(I('is_more', 0) == 1)
+		{
+			// 等值
+			if(I('gender', -1) > -1)
+			{
+				$where['gender'] = intval(I('gender', 0));
+			}
+			if(I('state', -1) > -1)
+			{
+				$where['state'] = intval(I('state', 0));
+			}
+
+			// 表达式
+			if(!empty($_REQUEST['time_start']))
+			{
+				$where['birthday'][] = array('gt', strtotime(I('time_start')));
+			}
+			if(!empty($_REQUEST['time_end']))
+			{
+				$where['birthday'][] = array('lt', strtotime(I('time_end')));
+			}
+		}
+		return $where;
+	}
+
+	/**
+	 * [SaveInfo 教师添加/编辑页面]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:37:02+0800
+	 */
+	public function SaveInfo()
+	{
+		// 教师信息
+		$data = empty($_REQUEST['id']) ? array() : M('Teacher')->find(I('id'));
+		if(!empty($data['birthday']))
+		{
+			$data['birthday'] = date('Y-m-d', $data['birthday']);
+
+			// 科目关联数据
+			$data['subject_id'] = M('TeacherSubject')->where(array('teacher_id'=>$data['id']))->getField('subject_id', true);
+		}
+		$this->assign('data', $data);
+
+		// 性别
+		$this->assign('common_gender_list', L('common_gender_list'));
+
+		// 教师状态
+		$this->assign('common_teacher_state_list', L('common_teacher_state_list'));
+
+		// 科目列表
+		$this->assign('subject_list', M('Subject')->field(array('id', 'name'))->where(array('is_enable'=>1))->select());		
+
+		$this->display('SaveInfo');
+	}
+
+	/**
+	 * [Save 教师添加/编辑]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:37:02+0800
+	 */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 贯通科目参数处理
+		if(!empty($_POST['subject_id']))
+		{
+			$_POST['subject_id'] = explode(',', $_POST['subject_id']);
+		} else {
+			$this->ajaxReturn(L('teacher_subject_format'), -2);
+		}
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			$this->Add();
+
+		// 编辑
+		} else {
+			$this->Edit();
+		}
+	}
+
+	/**
+	 * [Add 教师添加]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-18T16:20:59+0800
+	 */
+	private function Add()
+	{
+		// 教师对象
+		$m = D('Teacher');
+
+		// 数据自动校验
+		if($m->create($_POST, 1))
+		{
+			// 额外数据处理
+			$m->add_time	=	time();
+			$m->upd_time	=	time();
+			$m->birthday	=	strtotime($m->birthday);
+			$m->username 	=	I('username');
+			$m->address 	=	I('address');
+
+			// 开启事务
+			$m->startTrans();
+			
+			// 教师写入数据库
+			$teacher_id = $m->add();
+
+			// 添加教师科目关联数据
+			$ts_state = true;
+			$ts = M('TeacherSubject');
+			foreach($_POST['subject_id'] as $subject_id)
+			{
+				if(!empty($subject_id))
+				{
+					$temp_data = array(
+							'teacher_id'	=>	$teacher_id,
+							'subject_id'	=>	$subject_id,
+							'add_time'		=>	time(),
+						);
+					if(!$ts->add($temp_data))
+					{
+						$ts_state = false;
+						break;
+					}
+				}
+			}
+			if($teacher_id && $ts_state)
+			{
+				// 提交事务
+				$m->commit();
+
+				$this->ajaxReturn(L('common_operation_add_success'));
+			} else {
+				// 回滚事务
+				$m->rollback();
+
+				$this->ajaxReturn(L('common_operation_add_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [Edit 教师编辑]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-17T22:13:40+0800
+	 */
+	private function Edit()
+	{
+		// 教师对象
+		$m = D('Teacher');
+
+		// 数据自动校验
+		if($m->create($_POST, 2))
+		{
+			// 额外数据处理
+			if(!empty($m->birthday))
+			{
+				$m->birthday	=	strtotime($m->birthday);
+			}
+			$m->username 	=	I('username');
+			$m->address 	=	I('address');
+			$m->upd_time	=	time();
+
+			// 移除不能更新的数据
+			unset($m->id_card);
+
+			// 开启事务
+			$m->startTrans();
+
+			// 教师id
+			$teacher_id = I('id');
+
+			// 更新教师
+			$t_state = $m->where(array('id'=>$teacher_id, 'id_card'=>I('id_card')))->save();
+
+			// 删除教师科目关联数据
+			$ts = M('TeacherSubject');
+			$ts_state_del = $ts->where(array('teacher_id'=>$teacher_id))->delete();
+
+			// 添加教师科目关联数据
+			$ts_state = true;
+			foreach($_POST['subject_id'] as $subject_id)
+			{
+				if(!empty($subject_id))
+				{
+					$temp_data = array(
+							'teacher_id'	=>	$teacher_id,
+							'subject_id'	=>	$subject_id,
+							'add_time'		=>	time(),
+						);
+					if(!$ts->add($temp_data))
+					{
+						$ts_state = false;
+						break;
+					}
+				}
+			}
+			if($t_state !== false && $ts_state_del !== false && $ts_state !== false)
+			{
+				// 提交事务
+				$m->commit();
+
+				$this->ajaxReturn(L('common_operation_edit_success'));
+			} else {
+				// 回滚事务
+				$m->rollback();
+
+				$this->ajaxReturn(L('common_operation_edit_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [Delete 教师删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-15T11:03:30+0800
+	 */
+	public function Delete()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 参数处理
+		list($id, $id_card) = (stripos(I('id'), '-') === false) ? array() : explode('-', I('id'));
+
+		// 删除数据
+		if($id != null && $id_card != null)
+		{
+			// 教师模型
+			$s = M('Teacher');
+
+			// 教师是否存在
+			$teacher = $s->where(array('id'=>$id, 'id_card'=>$id_card))->getField('id');
+			if(empty($teacher))
+			{
+				$this->ajaxReturn(L('teacher_no_exist_error'), -2);
+			}
+
+			// 开启事务
+			$s->startTrans();
+
+			// 删除教师
+			$t_state = $s->where(array('id'=>$id, 'id_card'=>$id_card))->delete();
+
+			// 删除课程
+			$c_state = M('Course')->where(array('teacher_id'=>$id))->delete();
+			if($t_state !== false && $c_state !== false)
+			{
+				// 提交事务
+				$s->commit();
+
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				// 回滚事务
+				$s->rollback();
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+	}
+}
+?>

+ 252 - 0
Application/Admin/Controller/ThemeController.class.php

@@ -0,0 +1,252 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 主题管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class ThemeController extends CommonController
+{
+	private $html_path;
+	private $static_path;
+
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+
+		// 静态目录和html目录
+		$this->html_path = 'Application'.DS.'Home'.DS.'View'.DS;
+		$this->static_path = 'Public'.DS.'Home'.DS;
+	}
+
+	/**
+     * [Index 列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 导航参数
+		$view_type = I('view_type', 'home');
+		$this->assign('view_type', $view_type);
+
+		// 模板
+		switch($view_type)
+		{
+			// 模板安装
+			case 'upload':
+				$this->display('Upload');
+				break;
+
+			// 当前模板
+			default:
+				// 模板列表
+				$this->assign('data', $this->GetThemeList());
+
+				// 默认主题
+				$theme = S('cache_common_default_theme_data');
+				$this->assign('theme', empty($theme) ? 'Default' : $theme);
+
+				$this->display('Index');
+		}
+	}
+
+	/**
+	 * [GetThemeList 获取模板列表]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-05-10T10:24:40+0800
+	 * @return   [array] [模板列表]
+	 */
+	private function GetThemeList()
+	{
+		$result = array();
+		$dir = 'Application'.DS.'Home'.DS.'View'.DS;
+		if(is_dir($dir))
+		{
+			if($dh = opendir($dir))
+			{
+				$default_preview = 'Public'.DS.'Common'.DS.'Images'.DS.'default-preview.jpg';
+				while(($temp_file = readdir($dh)) !== false)
+				{
+					$config = $dir.$temp_file.DS.'config.json';
+					if(!file_exists($config))
+					{
+						continue;
+					}
+
+					// 读取配置文件
+					$data = json_decode(file_get_contents($config), true);
+					if(!empty($data) && is_array($data))
+					{
+						if(empty($data['name']) || empty($data['ver']) || empty($data['author']))
+						{
+							continue;
+						}
+						$result[] = array(
+							'theme'		=>	$temp_file,
+							'name'		=>	I('data.name', '', '',$data),
+							'ver'		=>	str_replace(array(',',','), ', ', I('data.ver', '', '',$data)),
+							'author'	=>	I('data.author', '', '',$data),
+							'home'		=>	I('data.home', '', '',$data),
+							'preview'	=>	file_exists($dir.$temp_file.DS.'preview.jpg') ? $dir.$temp_file.DS.'preview.jpg' : $default_preview,
+						);
+					}
+				}
+				closedir($dh);
+			}
+		}
+		return $result;
+	}
+
+	/**
+	 * [Save 数据保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-02-05T20:12:30+0800
+	 */
+	public function Save()
+	{
+		// 配置更新
+		$this->MyConfigSave();
+	}
+
+	/**
+	 * [Delete 删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-09T21:13:47+0800
+	 */
+	public function Delete()
+	{
+		// 是否ajax
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 主题
+		$id = I('id');
+
+		// 默认主题
+		$theme = S('cache_common_default_theme_data');
+		$theme = empty($theme) ? 'Default' : $theme;
+
+		// 不能删除正在使用的主题
+		if($theme == $id)
+		{
+			$this->ajaxReturn(L('theme_delete_error'), -2);
+		}
+
+		// 开始删除主题
+		if(DelDirFile($this->html_path.$id, true) && DelDirFile($this->static_path.$id, true))
+		{
+			$this->ajaxReturn(L('common_operation_delete_success'));
+		} else {
+			$this->ajaxReturn(L('common_operation_delete_error'), -100);
+		}
+	}
+
+	/**
+	 * [Upload 模板上传安装]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-05-10T16:27:09+0800
+	 */
+	public function Upload()
+	{
+		// 是否ajax
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 文件上传校验
+		$error = FileUploadError('theme');
+		if($error !== true)
+		{
+			$this->ajaxReturn($error, -1);
+		}
+
+		// 文件格式化校验
+		$type = array('application/zip', 'application/octet-stream');
+		if(!in_array($_FILES['theme']['type'], $type))
+		{
+			$this->ajaxReturn(L('theme_upload_error'), -2);
+		}
+
+		// 开始解压文件
+		$resource = zip_open($_FILES['theme']['tmp_name']);
+		while(($temp_resource = zip_read($resource)) !== false)
+		{
+			if(zip_entry_open($resource, $temp_resource))
+			{
+				// 当前压缩包中项目名称
+				$file = zip_entry_name($temp_resource);
+
+				// 排除临时文件和临时目录
+				if(strpos($file, '/.') === false && strpos($file, '__') === false)
+				{
+					// 拼接路径
+					if(strpos($file, '_Html') !== false)
+					{
+						$file = $this->html_path.$file;
+					} else if(strpos($file, '_Static') !== false)
+					{
+						$file = $this->static_path.$file;
+					} else {
+						continue;
+					}
+					$file = str_replace(array('_Static/', '_Html/'), '', $file);
+
+					// 截取文件路径
+					$file_path = substr($file, 0, strrpos($file, '/'));
+
+					// 路径不存在则创建
+					if(!is_dir($file_path))
+					{
+						mkdir($file_path, 0777, true);
+					}
+
+					// 如果不是目录则写入文件
+					if(!is_dir($file))
+					{
+						// 读取这个文件
+						$file_size = zip_entry_filesize($temp_resource);
+						$file_content = zip_entry_read($temp_resource, $file_size);
+						file_put_contents($file, $file_content);
+					}
+					// 关闭目录项  
+					zip_entry_close($temp_resource);
+				}
+				
+			}
+		}
+		$this->ajaxReturn(L('common_operation_success'));
+	}
+}
+?>

+ 314 - 0
Application/Admin/Controller/UeditorController.class.php

@@ -0,0 +1,314 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 百度编辑器控制器入口
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class UeditorController extends CommonController
+{
+	private $current_action;
+	private $current_config;
+	private $current_result;
+
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+	}
+
+	/**
+     * [Index 附件上传入口]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 配置信息
+		$this->current_config = C('ueditor_config');
+		$this->current_action = isset($_GET['action']) ? trim($_GET['action']) : '';
+
+		switch($this->current_action)
+		{
+			// 配置信息
+			case 'config':
+				$this->current_result =  json_encode($this->current_config);
+				break;
+
+			/* 上传图片 */
+			case 'uploadimage':
+			/* 上传涂鸦 */
+			case 'uploadscrawl':
+			/* 上传视频 */
+			case 'uploadvideo':
+			/* 上传文件 */
+			case 'uploadfile':
+				$this->ActionUpload();
+				break;
+
+			/* 列出图片 */
+			case 'listimage':
+			/* 列出文件 */
+			case 'listfile':
+				$this->ActionList();
+				break;
+
+			/* 抓取远程文件 */
+			case 'catchimage':
+				$this->ActionCrawler();
+				break;
+
+			default:
+				$this->current_result = json_encode(array(
+					'state'=> '请求地址出错'
+				));
+		}
+
+		// 输出结果
+		if(isset($_GET["callback"]))
+		{
+			if(preg_match("/^[\w_]+$/", $_GET["callback"]))
+			{
+				echo htmlspecialchars($_GET["callback"]) . '(' . $this->current_result . ')';
+			} else {
+				echo json_encode(array(
+					'state'=> 'callback参数不合法'
+				));
+			}
+		} else {
+			echo $this->current_result;
+		}
+		exit();
+	}
+
+	/**
+	 * [ActionUpload 上传配置]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-17T22:45:06+0800
+	 */
+	private function ActionUpload()
+	{
+		$base64 = "upload";
+		switch(htmlspecialchars($this->current_action))
+		{
+			case 'uploadimage':
+				$temp_config = array(
+						"pathFormat" => $this->current_config['imagePathFormat'],
+						"maxSize" => $this->current_config['imageMaxSize'],
+						"allowFiles" => $this->current_config['imageAllowFiles']
+					);
+				$field_name = $this->current_config['imageFieldName'];
+				break;
+
+			case 'uploadscrawl':
+				$temp_config = array(
+						"pathFormat" => $this->current_config['scrawlPathFormat'],
+						"maxSize" => $this->current_config['scrawlMaxSize'],
+						"allowFiles" => $this->current_config['scrawlAllowFiles'],
+						"oriName" => "scrawl.png"
+					);
+				$field_name = $this->current_config['scrawlFieldName'];
+				$base64 = "base64";
+				break;
+
+			case 'uploadvideo':
+				$temp_config = array(
+						"pathFormat" => $this->current_config['videoPathFormat'],
+						"maxSize" => $this->current_config['videoMaxSize'],
+						"allowFiles" => $this->current_config['videoAllowFiles']
+					);
+				$field_name = $this->current_config['videoFieldName'];
+				break;
+
+			case 'uploadfile':
+			default:
+				$temp_config = array(
+						"pathFormat" => $this->current_config['filePathFormat'],
+						"maxSize" => $this->current_config['fileMaxSize'],
+						"allowFiles" => $this->current_config['fileAllowFiles']
+					);
+				$field_name = $this->current_config['fileFieldName'];
+		}
+
+		/* 生成上传实例对象并完成上传 */
+		$up = new \My\Uploader($field_name, $temp_config, $base64);
+
+		/**
+		 * 得到上传文件所对应的各个参数,数组结构
+		 * array(
+		 *     "state" => "",          //上传状态,上传成功时必须返回"SUCCESS"
+		 *     "url" => "",            //返回的地址
+		 *     "title" => "",          //新文件名
+		 *     "original" => "",       //原始文件名
+		 *     "type" => ""            //文件类型
+		 *     "size" => "",           //文件大小
+		 * )
+		 */
+
+		// 返回数据
+		$this->current_result = json_encode($up->getFileInfo());
+	}
+
+	/**
+	 * [ActionList 文件列表]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-17T22:55:16+0800
+	 */
+	private function ActionList()
+	{
+		/* 判断类型 */
+		switch($this->current_action)
+		{
+			/* 列出文件 */
+			case 'listfile':
+				$allow_files = $this->current_config['fileManagerAllowFiles'];
+				$list_size = $this->current_config['fileManagerListSize'];
+				$path = $this->current_config['fileManagerListPath'];
+				break;
+
+			/* 列出图片 */
+			case 'listimage':
+			default:
+				$allow_files = $this->current_config['imageManagerAllowFiles'];
+				$list_size = $this->current_config['imageManagerListSize'];
+				$path = $this->current_config['imageManagerListPath'];
+		}
+		$allow_files = substr(str_replace(".", "|", join("", $allow_files)), 1);
+
+		/* 获取参数 */
+		$size = isset($_GET['size']) ? htmlspecialchars($_GET['size']) : $list_size;
+		$start = isset($_GET['start']) ? htmlspecialchars($_GET['start']) : 0;
+		$end = $start + $size;
+
+		/* 获取文件列表 */
+		$path = $_SERVER['DOCUMENT_ROOT'] . (substr($path, 0, 1) == "/" ? "":"/") . $path;
+		$files = $this->GetFilesList($path, $allow_files);
+		if (!count($files)) {
+			$this->current_result =  json_encode(array(
+				"state" => "no match file",
+				"list" => array(),
+				"start" => $start,
+				"total" => count($files)
+			));
+		}
+
+		/* 获取指定范围的列表 */
+		$len = count($files);
+		for ($i = min($end, $len) - 1, $list = array(); $i < $len && $i >= 0 && $i >= $start; $i--)
+		{
+			$list[] = $files[$i];
+		}
+		//倒序
+		//for ($i = $end, $list = array(); $i < $len && $i < $end; $i++){
+		//    $list[] = $files[$i];
+		//}
+
+		/* 返回数据 */
+		$this->current_result = json_encode(array(
+			"state" => "SUCCESS",
+			"list" => $list,
+			"start" => $start,
+			"total" => count($files)
+		));
+	}
+
+	/**
+	 * [GetFilesList 遍历获取目录下的指定类型的文件]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-17T23:24:59+0800
+	 * @param    [string]        $path       	[路径地址]
+	 * @param    [string]        $allow_files 	[允许的文件]
+	 * @param    [array]         &$files     	[数据]
+	 * @return   [array]                     	[数据]
+	 */
+	private function GetFilesList($path, $allow_files, &$files = array())
+	{
+		if(!is_dir($path)) return null;
+		if(substr($path, strlen($path) - 1) != '/') $path .= '/';
+		$handle = opendir($path);
+		while(false !== ($file = readdir($handle)))
+		{
+			if($file != '.' && $file != '..')
+			{
+				$path2 = $path . $file;
+				if(is_dir($path2))
+				{
+					$this->GetFilesList($path2, $allow_files, $files);
+				} else {
+					if(preg_match("/\.(".$allow_files.")$/i", $file))
+					{
+						$files[] = array(
+								'url'=> substr($path2, strlen($_SERVER['DOCUMENT_ROOT'])),
+								'mtime'=> filemtime($path2)
+							);
+					}
+				}
+			}
+		}
+		return $files;
+	}
+
+	/**
+	 * [ActionCrawler 抓取远程文件]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-17T23:08:29+0800
+	 */
+	private function ActionCrawler()
+	{
+		$temp_config = array(
+				"pathFormat" => $this->current_config['catcherPathFormat'],
+				"maxSize" => $this->current_config['catcherMaxSize'],
+				"allowFiles" => $this->current_config['catcherAllowFiles'],
+				"oriName" => "remote.png"
+			);
+		$field_name = $this->current_config['catcherFieldName'];
+
+		/* 抓取远程图片 */
+		$list = array();
+		$source = isset($_POST[$field_name]) ? $_POST[$field_name] : $_GET[$field_name];
+		foreach($source as $imgUrl)
+		{
+			$item = new \My\Uploader($imgUrl, $temp_config, "remote");
+			$info = $item->getFileInfo();
+			array_push($list, array(
+				"state" => $info["state"],
+				"url" => $info["url"],
+				"size" => $info["size"],
+				"title" => htmlspecialchars($info["title"]),
+				"original" => htmlspecialchars($info["original"]),
+				"source" => htmlspecialchars($imgUrl)
+			));
+		}
+
+		/* 返回抓取数据 */
+		$this->current_result = json_encode(array(
+				'state'=> count($list) ? 'SUCCESS':'ERROR',
+				'list'=> $list
+			));
+	}
+}
+?>

+ 360 - 0
Application/Admin/Controller/UserController.class.php

@@ -0,0 +1,360 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 用户管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class UserController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 用户列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 参数
+		$param = array_merge($_POST, $_GET);
+
+		// 模型模型
+		$m = M('User');
+
+		// 条件
+		$where = $this->GetIndexWhere();
+
+		// 分页
+		$number = MyC('admin_page_number');
+		$page_param = array(
+				'number'	=>	$number,
+				'total'		=>	$m->where($where)->count(),
+				'where'		=>	$param,
+				'url'		=>	U('Admin/User/Index'),
+			);
+		$page = new \My\Page($page_param);
+
+		// 获取列表
+		$field = array('id', 'mobile', 'email', 'nickname', 'gender', 'birthday', 'signature', 'describe', 'state', 'add_time', 'upd_time');
+		$list = $this->SetDataHandle($m->field($field)->where($where)->limit($page->GetPageStarNumber(), $number)->order('id desc')->select());
+
+		// 性别
+		$this->assign('common_gender_list', L('common_gender_list'));
+
+		// 用户状态
+		$this->assign('common_user_state_list', L('common_user_state_list'));
+
+		// 参数
+		$this->assign('param', $param);
+
+		// 分页
+		$this->assign('page_html', $page->GetPageHtml());
+
+		// 数据列表
+		$this->assign('list', $list);
+
+		$this->display('Index');
+	}
+
+	/**
+	 * [SetDataHandle 数据处理]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-29T21:27:15+0800
+	 * @param    [array]      $data [用户数据]
+	 * @return   [array]            [处理好的数据]
+	 */
+	private function SetDataHandle($data)
+	{
+		if(!empty($data))
+		{
+			foreach($data as &$v)
+			{
+				// 生日
+				if($v['birthday'] > 0)
+				{
+					$v['birthday'] = date('Y-m-d', $v['birthday']);
+				} 
+
+				// 注册时间
+				$v['add_time'] = date('Y-m-d H:i:s', $v['add_time']);
+
+				// 更新时间
+				$v['upd_time'] = date('Y-m-d H:i:s', $v['upd_time']);
+
+				// 性别
+				$v['gender'] = L('common_gender_list')[$v['gender']]['name'];
+
+				// 状态
+				$v['state_text'] = L('common_user_state_list')[$v['state']]['name'];
+			}
+		}
+		return $data;
+	}
+
+	/**
+	 * [GetIndexWhere 用户列表条件]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T22:16:29+0800
+	 */
+	private function GetIndexWhere()
+	{
+		$where = array();
+
+		// 模糊
+		if(!empty($_REQUEST['keyword']))
+		{
+			$like_keyword = array('like', '%'.I('keyword').'%');
+			$where[] = array(
+					'nickname'		=>	$like_keyword,
+					'mobile'		=>	$like_keyword,
+					'email'		=>	$like_keyword,
+					'_logic'		=>	'or',
+				);
+		}
+
+		// 是否更多条件
+		if(I('is_more', 0) == 1)
+		{
+			// 等值
+			if(I('gender', -1) > -1)
+			{
+				$where['gender'] = intval(I('gender', 0));
+			}
+			if(I('state', -1) > -1)
+			{
+				$where['state'] = intval(I('state', 0));
+			}
+
+			// 表达式
+			if(!empty($_REQUEST['time_start']))
+			{
+				$where['add_time'][] = array('gt', strtotime(I('time_start')));
+			}
+			if(!empty($_REQUEST['time_end']))
+			{
+				$where['add_time'][] = array('lt', strtotime(I('time_end')));
+			}
+		}
+		return $where;
+	}
+
+	/**
+	 * [SaveInfo 用户添加/编辑页面]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:37:02+0800
+	 */
+	public function SaveInfo()
+	{
+		// 用户信息
+		$data = empty($_REQUEST['id']) ? array() : M('User')->find(I('id'));
+		$data['birthday'] = empty($data['birthday']) ? '' : date('Y-m-d', $data['birthday']);
+		$this->assign('data', $data);
+
+		// 性别
+		$this->assign('common_gender_list', L('common_gender_list'));
+
+		// 用户状态
+		$this->assign('common_user_state_list', L('common_user_state_list'));
+
+		$this->display('SaveInfo');
+	}
+
+	/**
+	 * [Save 用户添加/编辑]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-14T21:37:02+0800
+	 */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 用户账户校验
+		if(empty($_POST['mobile']) && empty($_POST['email']))
+		{
+			$this->ajaxReturn(L('user_accounts_param_error'), -1);
+		}
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			$this->Add();
+
+		// 编辑
+		} else {
+			$this->Edit();
+		}
+	}
+
+	/**
+	 * [Add 用户添加]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-18T16:20:59+0800
+	 */
+	private function Add()
+	{
+		// 用户模型
+		$m = D('User');
+
+		// 数据自动校验
+		if($m->create($_POST, 1))
+		{
+			// 额外数据处理
+			$m->salt 		=	GetNumberCode(6);
+			$m->pwd 		=	LoginPwdEncryption(trim(I('pwd')), $m->salt);
+			$m->nickname 	=	I('nickname');
+			$m->signature 	=	I('signature');
+			$m->describe 	=	I('describe');
+			$m->add_time	=	time();
+
+			// 数据添加
+			if($m->add())
+			{
+				$this->ajaxReturn(L('common_operation_add_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_add_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [Edit 用户编辑]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-17T22:13:40+0800
+	 */
+	private function Edit()
+	{
+		// 用户模型
+		$m = D('User');
+
+		// 数据自动校验
+		if($m->create($_POST, 2))
+		{
+			// 额外数据处理
+			if(!empty($m->birthday))
+			{
+				$m->birthday	=	strtotime($m->birthday);
+			}
+			$m->nickname 	=	I('nickname');
+			$m->signature 	=	I('signature');
+			$m->describe 	=	I('describe');
+			$m->upd_time	=	time();
+
+			// 登录密码
+			if(!empty($_POST['pwd']))
+			{
+				$m->salt 	=	GetNumberCode(6);
+				$m->pwd 	=	LoginPwdEncryption(trim(I('pwd')), $m->salt);
+			} else {
+				unset($m->pwd);
+			}
+
+			// 更新数据库
+			if($m->where(array('id'=>I('id')))->save())
+			{
+				$this->ajaxReturn(L('common_operation_edit_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_edit_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [Delete 用户删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-15T11:03:30+0800
+	 */
+	public function Delete()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 参数处理
+		$id = I('id');
+
+		// 删除数据
+		if(!empty($id))
+		{
+			// 用户模型
+			$u = M('User');
+
+			// 用户是否存在
+			$user = $u->where(array('id'=>$id))->getField('id');
+			if(empty($user))
+			{
+				$this->ajaxReturn(L('common_user_no_exist_error'), -2);
+			}
+
+			// 开启事务
+			$u->startTrans();
+
+			// 删除用户
+			$u_state = $u->where(array('id'=>$id))->delete();
+
+			// 删除成绩
+			$us_state = M('UserStudent')->where(array('user_id'=>$id))->delete();
+			if($u_state !== false && $us_state !== false)
+			{
+				// 提交事务
+				$u->commit();
+
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				// 回滚事务
+				$u->rollback();
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+	}
+}
+?>

+ 573 - 0
Application/Admin/Controller/ViewController.class.php

@@ -0,0 +1,573 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 界面管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class ViewController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 参数
+		$type = I('type', 'home');
+
+		// 布局页面类型
+		$this->assign('layout_type', $type);
+
+		// 布局+模块列表
+		$this->assign('data', $this->GetLayoutList());
+
+		// 友情链接
+		$this->assign('link', LayoutLink($type));
+
+		// 文章分类
+		$this->assign('article_class_list', M('ArticleClass')->field(array('id', 'name'))->where(array('is_enable'=>1))->select());
+
+		// 排序
+		$this->assign('common_view_sort_list', L('common_view_sort_list'));
+
+		// 时间
+		$this->assign('common_view_time_list', L('common_view_time_list'));
+
+		// 标题显示样式
+		$this->assign('common_view_title_style_list', L('common_view_title_style_list'));
+
+		// 打开方式
+		$this->assign('common_view_link_open_way_list', L('common_view_link_open_way_list'));
+
+		// 日期格式
+		$this->assign('common_view_date_format_list', L('common_view_date_format_list'));
+
+		$this->display('Index');
+	}
+
+	/**
+	 * [GetLayoutList 获取布局-模块列表]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-02-22T10:15:40+0800
+	 */
+	private function GetLayoutList()
+	{
+		// 布局+模块列表
+		$data = M('Layout')->field(array('id', 'value', 'is_enable'))->where(array('type'=>I('type', 'home')))->order('sort asc, id desc')->select();
+		if(!empty($data))
+		{
+			// 布局模块处理驱动
+			$lay = \My\LayoutModule::SetInstance();
+
+			// 开始处理布局数据
+			foreach($data as $k=>$v)
+			{
+				// 模块
+				$item = M('LayoutModule')->where(array('layout_id'=>$v['id']))->select();
+				if(!empty($item))
+				{
+					foreach($item as $ik=>$iv)
+					{
+						// 参数条件json
+						$temp_json = $iv;
+						if(strlen($temp_json['article_class_id']) > 0)
+						{
+							$temp_json['article_class_id'] = explode(',', $temp_json['article_class_id']);
+						}
+						$iv['json'] = json_encode($temp_json);
+
+						// 获取文章数据
+						$article = LayoutArticleList($lay->GetLayoutMouleWhere($iv), $iv);
+
+						// 模块数据生成
+						$fun = GetViewTitleStyleFun($iv['title_style']);
+						$iv['html'] = method_exists($lay, $fun) ? $lay->$fun($article, $iv) : '';
+
+						// 重新赋值
+						$item[$ik] = $iv;
+					}
+				}
+				$data[$k]['item'] = $item;
+			}
+		}
+		return $data;
+	}
+
+	/**
+	 * [GetLayoutModuleData 获取模块数据-及保存模块数据]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-02-11T21:18:00+0800
+	 */
+	public function GetLayoutModuleData()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 布局模块处理驱动
+		$lay = \My\LayoutModule::SetInstance();
+
+		// 模块模型
+		$m = D('LayoutModule');
+
+		// 数据自动校验
+		if($m->create($_POST, 2))
+		{
+			// 额外数据
+			$m->upd_time	=	time();
+			$m->right_title	=	str_replace(';', ';', I('right_title'));
+			$m->keyword 	=	str_replace(array(';', '—'), array(';', '-'), I('keyword'));
+			$m->name 		=	I('name');
+			$m->right_title =	I('right_title');
+			$m->article_id 	=	I('article_id');
+			$m->keyword 	=	I('keyword');
+
+			// 更新数据库
+			if($m->where(array('id'=>I('id')))->save())
+			{
+				// 获取文章数据
+				$article = LayoutArticleList($lay->GetLayoutMouleWhere($_POST), $_POST);
+
+				// 模块数据生成
+				$fun = GetViewTitleStyleFun(I('title_style'));
+				if(method_exists($lay, $fun))
+				{
+					$html = $lay->$fun($article, $_POST);
+					if(strlen($_POST['article_class_id']) > 0)
+					{
+						$_POST['article_class_id'] = explode(',', $_POST['article_class_id']);
+					}
+					$result = array('html' => $html, 'json' => json_encode($_POST));
+					$this->ajaxReturn(L('common_operation_edit_success'), 0, $result);
+				} else {
+					$this->ajaxReturn(str_replace('{$1}', $fun, L('common_method_exists_error')), -101);
+				}
+			} else {
+				$this->ajaxReturn(L('common_operation_edit_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+
+	/**
+	 * [ModuleAdd 模块添加]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-02-17T16:49:58+0800
+	 */
+	public function ModuleAdd()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 布局类型
+		if(empty($_POST['id']))
+		{
+			$this->ajaxReturn(L('view_module_param_save_tips'), -1);
+		}
+
+		// 数据添加
+		$data = array(
+				'layout_id'		=>	I('id'),
+				'add_time'		=>	time(),
+				'upd_time'		=>	time(),
+			);
+		$id = M('LayoutModule')->add($data);
+		if($id > 0)
+		{
+			$this->ajaxReturn(L('common_operation_add_success'), 0, $id);
+		} else {
+			$this->ajaxReturn(L('common_operation_add_error'), -100);
+		}
+	}
+
+	/**
+	 * [LayoutSave 布局保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-02-17T16:49:58+0800
+	 */
+	public function LayoutSave()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 布局类型
+		if(empty($_POST['type']) || empty($_POST['value']))
+		{
+			$this->ajaxReturn(L('view_layout_param_save_tips'), -1);
+		}
+
+		// 布局数据添加
+		$data = array(
+				'type'		=>	I('type'),
+				'value'		=>	I('value'),
+				'upd_time'	=>	time(),
+			);
+		$layout_id = M('Layout')->add($data);
+		if($layout_id > 0)
+		{
+			$result = array('layout_id' => $layout_id);
+			$module = array('100' => 1, '84' => 2, '48' => 2, '633' => 3, '363' => 3, '336' => 3);
+			if(array_key_exists($data['value'], $module))
+			{
+				$count = $module[$data['value']];
+				for($i=1; $i<=$count; $i++)
+				{
+					// 模块数据添加
+					$temp_field = 'module'.$i.'_id';
+					$temp_module = array(
+							'layout_id'		=>	$layout_id,
+							'add_time'		=>	time(),
+							'upd_time'		=>	time(),
+						);
+					$result[$temp_field] = M('LayoutModule')->add($temp_module);
+				}
+				$module_count = $count;
+			} else {
+				$module_count = 0;
+			}
+			$result['module_count']	=	$module_count;
+			$this->ajaxReturn(L('common_operation_add_success'), 0, $result);
+		} else {
+			$this->ajaxReturn(L('common_operation_add_error'), -100);
+		}
+	}
+
+	/**
+	 * [StateUpdate 状态更新]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-01-12T22:23:06+0800
+	 */
+	public function StateUpdate()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 参数
+		if(empty($_POST['id']) || !isset($_POST['state']))
+		{
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+
+		// 数据更新
+		if(M('Layout')->where(array('id'=>I('id')))->save(array('is_enable'=>I('state'))))
+		{
+			$this->ajaxReturn(L('common_operation_edit_success'));
+		} else {
+			$this->ajaxReturn(L('common_operation_edit_error'), -100);
+		}
+	}
+
+	/**
+	 * [LayoutDelete 布局删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-02-20T13:30:50+0800
+	 */
+	public function LayoutDelete()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 参数
+		if(empty($_POST['id']))
+		{
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+
+		// 布局模型
+		$m = M('Layout');
+
+		// 开启事务
+		$m->startTrans();
+
+		// 删除数据
+		if($m->delete(I('id')) !== false && M('LayoutModule')->where(array('layout_id'=>I('id')))->delete() !== false)
+		{
+			// 提交事务
+			$m->commit();
+			$this->ajaxReturn(L('common_operation_delete_success'));
+		} else {
+			// 回滚事务
+			$m->rollback();
+			$this->ajaxReturn(L('common_operation_delete_error'), -100);
+		}
+	}
+
+	/**
+	 * [ModuleDelete 模块删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-02-20T13:30:50+0800
+	 */
+	public function ModuleDelete()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 参数
+		if(empty($_POST['id']))
+		{
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+
+		if(M('LayoutModule')->delete(I('id')) !== false)
+		{
+			$this->ajaxReturn(L('common_operation_delete_success'));
+		} else {
+			$this->ajaxReturn(L('common_operation_delete_error'), -100);
+		}
+	}
+
+	/**
+	 * [LayoutSortSave 布局排序保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-02-20T16:02:56+0800
+	 */
+	public function LayoutSortSave()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 参数
+		if(empty($_POST['data']) || !is_array($_POST['data']))
+		{
+			$this->ajaxReturn(L('common_param_error'), -1);
+		}
+
+		$success = 0;
+		$failure = 0;
+		$m = M('Layout');
+		foreach($_POST['data'] as $k=>$v)
+		{
+			if($m->where(array('id'=>intval($v)))->save(array('sort'=>$k)))
+			{
+				$success++;
+			} else {
+				$failure++;
+			}
+		}
+		if($success > 0)
+		{
+			$this->ajaxReturn(L('common_operation_success'));
+		} else {
+			$this->ajaxReturn(L('common_operation_error'), -100);
+		}
+	}
+
+	/**
+	 * [LayoutExport 布局数据导出]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-05-11T16:24:34+0800
+	 */
+	public function LayoutExport()
+	{
+		$type = I('type', 'home');
+		$data = M('Layout')->where(array('type'=>$type))->select();
+		if(!empty($data))
+		{
+			$module = M('LayoutModule');
+			foreach($data as &$v)
+			{
+				$v['item'] = $module->where(array('layout_id'=>$v['id']))->select();
+			}
+		}
+
+		// 输出内容
+		header('Content-Type: application/octet-stream');
+		header('Content-Disposition: attachment; filename=layout-'.$type.'.txt');
+		header('Pragma: no-cache');
+		header('Expires: 0');
+		echo serialize($data);
+	}
+
+	/**
+	 * [LayoutImport 布局数据导入]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-05-11T16:43:53+0800
+	 */
+	public function LayoutImport()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 文件上传校验
+		$error = FileUploadError('file');
+		if($error !== true)
+		{
+			$this->ajaxReturn($error, -1);
+		}
+
+		// 文件格式化校验
+		$type = array('text/plain');
+		if(!in_array($_FILES['file']['type'], $type))
+		{
+			$this->ajaxReturn(L('theme_upload_error'), -2);
+		}
+		
+		// 读取文件内容
+		$data = unserialize(file_get_contents($_FILES['file']['tmp_name']));
+
+		// 初始化变量
+		$failure = 0;
+		$del_state = false;
+
+		// 数据导入
+		if(!empty($data) && is_array($data))
+		{
+			// 模型
+			$layout = M('Layout');
+			$module = M('LayoutModule');
+
+			// 开启事务
+			$layout->startTrans();
+
+			// 开始处理数据
+			foreach($data as $v)
+			{
+				// 删除原始数据
+				if($del_state == false && !empty($v['type']))
+				{
+					if(!$this->LayoutImportDelete($layout, $module, $v['type']))
+					{
+						$failure++;
+					}
+					$del_state = true;
+				}
+
+				// 插入模块数据
+				if(!empty($v['item']))
+				{
+					foreach($v['item'] as $vs)
+					{
+						if($module->add($vs) === false)
+						{
+							$failure++;
+						}
+					}
+				}
+
+				// 插入新的布局
+				if($layout->add($v) === false)
+				{
+					$failure++;
+				}
+			}
+		}
+
+		// 状态
+		if($failure == 0)
+		{
+			// 提交事务
+			$layout->commit();
+
+			$this->ajaxReturn(L('common_import_success_name'));
+		} else {
+			// 回滚事务
+			$layout->rollback();
+
+			$this->ajaxReturn(L('common_import_error_name'), -100);
+		}
+	}
+
+	/**
+	 * [LayoutImportDelete 布局导入删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2017-05-11T17:23:58+0800
+	 * @param    [object] 	  $layout [布局模型]
+	 * @param    [object] 	  $module [模块模型]
+	 * @param    [string]     $type [布局类型(home, channel, detail)]
+	 * @return   [boolean]          [成功true, 失败false]
+	 */
+	private function LayoutImportDelete($layout, $module, $type)
+	{
+		$failure = 0;
+		$data = $layout->where(array('type'=>$type))->select();
+		if(!empty($data))
+		{
+			foreach($data as $v)
+			{
+				if($layout->delete($v['id']) === false)
+				{
+					$failure++;
+				}
+				if($module->where(array('layout_id'=>$v['id']))->delete() === false)
+				{
+					$failure++;
+				}
+			}
+		}
+		return ($failure == 0);
+	}
+}
+?>

+ 167 - 0
Application/Admin/Controller/WeekController.class.php

@@ -0,0 +1,167 @@
+<?php
+
+namespace Admin\Controller;
+
+/**
+ * 周管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class WeekController extends CommonController
+{
+	/**
+	 * [_initialize 前置操作-继承公共前置方法]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-03T12:39:08+0800
+	 */
+	public function _initialize()
+	{
+		// 调用父类前置方法
+		parent::_initialize();
+
+		// 登录校验
+		$this->Is_Login();
+
+		// 权限校验
+		$this->Is_Power();
+	}
+
+	/**
+     * [Index 周列表]
+     * @author   Devil
+     * @blog     http://gong.gg/
+     * @version  0.0.1
+     * @datetime 2016-12-06T21:31:53+0800
+     */
+	public function Index()
+	{
+		// 是否启用
+		$this->assign('common_is_enable_list', L('common_is_enable_list'));
+		$this->display('Index');
+	}
+
+	/**
+	 * [GetNodeSon 获取节点子列表]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T15:19:45+0800
+	 */
+	public function GetNodeSon()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// 获取数据
+		$field = array('id', 'name', 'sort', 'is_enable');
+		$data = M('Week')->field($field)->where(array('pid'=>intval(I('id', 0))))->select();
+		if(!empty($data))
+		{
+			foreach($data as $k=>$v)
+			{
+				$data[$k]['is_son']		=	'no';
+				$data[$k]['ajax_url']	=	U('Admin/Week/GetNodeSon', array('id'=>$v['id']));
+				$data[$k]['delete_url']	=	U('Admin/Week/Delete');
+				$data[$k]['json']		=	json_encode($v);
+			}
+		}
+		$msg = empty($data) ? L('common_not_data_tips') : L('common_operation_success');
+		$this->ajaxReturn($msg, 0, $data);
+	}
+
+	/**
+	 * [Save 周保存]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function Save()
+	{
+		// 是否ajax请求
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		// id为空则表示是新增
+		$m = D('Week');
+
+		// 公共额外数据处理
+		$m->sort 	=	intval(I('sort'));
+
+		// 添加
+		if(empty($_POST['id']))
+		{
+			if($m->create($_POST, 1))
+			{
+				// 额外数据处理
+				$m->add_time	=	time();
+				$m->name 		=	I('name');
+				
+				// 写入数据库
+				if($m->add())
+				{
+					$this->ajaxReturn(L('common_operation_add_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_add_error'), -100);
+				}
+			}
+		} else {
+			// 编辑
+			if($m->create($_POST, 2))
+			{
+				// 额外数据处理
+				$m->name 		=	I('name');
+
+				// 移除 id
+				unset($m->id);
+
+				// 更新数据库
+				if($m->where(array('id'=>I('id')))->save())
+				{
+					$this->ajaxReturn(L('common_operation_edit_success'));
+				} else {
+					$this->ajaxReturn(L('common_operation_edit_error'), -100);
+				}
+			}
+		}
+		$this->ajaxReturn($m->getError(), -1);
+	}
+
+	/**
+	 * [Delete 周删除]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-25T22:36:12+0800
+	 */
+	public function Delete()
+	{
+		if(!IS_AJAX)
+		{
+			$this->error(L('common_unauthorized_access'));
+		}
+
+		$m = D('Week');
+		if($m->create($_POST, 5))
+		{
+			if($m->delete(I('id')))
+			{
+				$this->ajaxReturn(L('common_operation_delete_success'));
+			} else {
+				$this->ajaxReturn(L('common_operation_delete_error'), -100);
+			}
+		} else {
+			$this->ajaxReturn($m->getError(), -1);
+		}
+	}
+}
+?>

+ 1 - 0
Application/Admin/Controller/index.html

@@ -0,0 +1 @@
+ 

+ 292 - 0
Application/Admin/Lang/zh-cn.php

@@ -0,0 +1,292 @@
+<?php
+
+/**
+ * 模块语言包
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 学生excel导出标题列表,
+	// 索引对应数据库字段名称,
+	// col对应excel列标记,
+	// type定义excel数据类型
+	'excel_student_title_list'		=>	array(
+			'username'		=>	array(
+					'col' => 'A',
+					'name' => '学生姓名',
+					'type' => 'string',
+				),
+			'number'		=>	array(
+					'col' => 'B',
+					'name' => '学生编号',
+					'type' => 'int',
+				),
+			'id_card'		=>	array(
+					'col' => 'C',
+					'name' => '身份证号码',
+					'type' => 'int',
+				),
+			'gender'		=>	array(
+					'col' => 'D',
+					'name' => '性别',
+					'type' => 'string',
+				),
+			'birthday'		=>	array(
+					'col' => 'E',
+					'name' => '出生年日',
+					'type' => 'string',
+				),
+			'tel'			=>	array(
+					'col' => 'F',
+					'name' => '座机号码',
+					'type' => 'int',
+				),
+			'my_mobile'		=>	array(
+					'col' => 'G',
+					'name' => '学生手机',
+					'type' => 'int',
+				),
+			'parent_mobile'	=>	array(
+					'col' => 'H',
+					'name' => '家长手机',
+					'type' => 'int',
+				),
+			'email'			=>	array(
+					'col' => 'I',
+					'name' => '电子邮箱',
+					'type' => 'string',
+				),
+			'state'			=>	array(
+					'col' => 'J',
+					'name' => '学生状态',
+					'type' => 'string',
+				),
+			'tuition_state'	=>	array(
+					'col' => 'K',
+					'name' => '缴费状态',
+					'type' => 'string',
+				),
+			'class_name'	=>	array(
+					'col' => 'L',
+					'name' => '班级',
+					'type' => 'string',
+				),
+			'region_name'	=>	array(
+					'col' => 'M',
+					'name' => '地区',
+					'type' => 'string',
+				),
+			'address'		=>	array(
+					'col' => 'N',
+					'name' => '详细地址',
+					'type' => 'string',
+				),
+			'add_time'		=>	array(
+					'col' => 'O',
+					'name' => '报名时间',
+					'type' => 'string',
+				),
+		),
+	// 学生excel导出标题列表-导入格式
+	'excel_student_impoet_title_list'		=>	array(
+			'username'		=>	array(
+					'col' => 'A',
+					'name' => '学生姓名',
+					'type' => 'string',
+				),
+			'id_card'		=>	array(
+					'col' => 'B',
+					'name' => '身份证号码',
+					'type' => 'int',
+				),
+			'gender'		=>	array(
+					'col' => 'C',
+					'name' => '性别',
+					'type' => 'string',
+				),
+			'birthday'		=>	array(
+					'col' => 'D',
+					'name' => '出生年日',
+					'type' => 'string',
+				),
+			'tel'			=>	array(
+					'col' => 'E',
+					'name' => '座机号码',
+					'type' => 'int',
+				),
+			'my_mobile'		=>	array(
+					'col' => 'F',
+					'name' => '学生手机',
+					'type' => 'int',
+				),
+			'parent_mobile'	=>	array(
+					'col' => 'G',
+					'name' => '家长手机',
+					'type' => 'int',
+				),
+			'email'			=>	array(
+					'col' => 'H',
+					'name' => '电子邮箱',
+					'type' => 'string',
+				),
+			'state'			=>	array(
+					'col' => 'I',
+					'name' => '学生状态',
+					'type' => 'string',
+				),
+			'tuition_state'	=>	array(
+					'col' => 'J',
+					'name' => '缴费状态',
+					'type' => 'string',
+				),
+			'class_name'	=>	array(
+					'col' => 'K',
+					'name' => '班级',
+					'type' => 'string',
+				),
+			'region_name'	=>	array(
+					'col' => 'L',
+					'name' => '地区',
+					'type' => 'string',
+				),
+			'address'		=>	array(
+					'col' => 'M',
+					'name' => '详细地址',
+					'type' => 'string',
+				),
+			'add_time'		=>	array(
+					'col' => 'N',
+					'name' => '报名时间',
+					'type' => 'string',
+				),
+		),
+
+	// 学生成绩excel导出标题列表
+	'excel_fraction_title_list'		=>	array(
+			'username'		=>	array(
+					'col' => 'A',
+					'name' => '学生姓名',
+					'type' => 'string',
+				),
+			'gender'		=>	array(
+					'col' => 'B',
+					'name' => '性别',
+					'type' => 'string',
+				),
+			'class_name'	=>	array(
+					'col' => 'C',
+					'name' => '班级',
+					'type' => 'string',
+				),
+			'subject_name'	=>	array(
+					'col' => 'D',
+					'name' => '科目',
+					'type' => 'string',
+				),
+			'score_name'	=>	array(
+					'col' => 'E',
+					'name' => '成绩类别',
+					'type' => 'string',
+				),
+			'score'			=>	array(
+					'col' => 'F',
+					'name' => '成绩分数',
+					'type' => 'int',
+				),
+			'score_level'	=>	array(
+					'col' => 'G',
+					'name' => '成绩等级',
+					'type' => 'string',
+				),
+			'comment'		=>	array(
+					'col' => 'H',
+					'name' => '教师点评',
+					'type' => 'string',
+				),
+			'add_time'		=>	array(
+					'col' => 'I',
+					'name' => '录入时间',
+					'type' => 'string',
+				),
+		),
+	// 学生成绩excel导出标题列表-导入格式
+	'excel_fraction_import_title_list'		=>	array(
+			'username'		=>	array(
+					'col' => 'A',
+					'name' => '学生姓名',
+					'type' => 'string',
+				),
+			'number'		=>	array(
+					'col' => 'B',
+					'name' => '学生编号',
+					'type' => 'int',
+				),
+			'id_card'		=>	array(
+					'col' => 'C',
+					'name' => '身份证号码',
+					'type' => 'int',
+				),
+			'subject_name'	=>	array(
+					'col' => 'D',
+					'name' => '科目',
+					'type' => 'string',
+				),
+			'score_name'	=>	array(
+					'col' => 'E',
+					'name' => '成绩类别',
+					'type' => 'string',
+				),
+			'score'			=>	array(
+					'col' => 'F',
+					'name' => '成绩分数',
+					'type' => 'int',
+				),
+			'comment'		=>	array(
+					'col' => 'G',
+					'name' => '教师点评',
+					'type' => 'string',
+				),
+			'add_time'		=>	array(
+					'col' => 'H',
+					'name' => '录入时间',
+					'type' => 'string',
+				),
+		),
+
+	// 教师excel导出标题列表
+	'excel_teacher_title_list'		=>	array(
+			'username'		=>	array('col' => 'A', 'name' => '教师姓名'),
+			'id_card'		=>	array('col' => 'B', 'name' => '身份证号码'),
+			'gender'		=>	array('col' => 'C', 'name' => '性别'),
+			'birthday'		=>	array('col' => 'D', 'name' => '出生年日'),
+			'tel'			=>	array('col' => 'E', 'name' => '联系电话'),
+			'address'		=>	array('col' => 'F', 'name' => '详细地址'),
+			'state'			=>	array('col' => 'G', 'name' => '教师状态'),
+			'subject_list'	=>	array('col' => 'H', 'name' => '贯通科目'),
+			'add_time'		=>	array('col' => 'I', 'name' => '添加时间'),
+		),
+
+	// 教师课程excel导出标题列表
+	'excel_course_title_list'		=>	array(
+			'teacher_name'	=>	array('col' => 'A', 'name' => '教师姓名'),
+			'class_name'	=>	array('col' => 'B', 'name' => '班级'),
+			'subject_name'	=>	array('col' => 'C', 'name' => '科目'),
+			'week_name'		=>	array('col' => 'D', 'name' => '周天'),
+			'interval_name'	=>	array('col' => 'E', 'name' => '时段'),
+			'room_name'		=>	array('col' => 'F', 'name' => '教室'),
+			'state_text'	=>	array('col' => 'G', 'name' => '状态'),
+			'add_time'		=>	array('col' => 'H', 'name' => '添加时间'),
+		),
+
+	// 文章excel导出标题列表
+	'excel_article_title_list'		=>	array(
+			'title'						=>	array('col' => 'A', 'name' => '标题'),
+			'article_class_name'		=>	array('col' => 'B', 'name' => '文章分类'),
+			'is_enable_text'			=>	array('col' => 'C', 'name' => '是否启用'),
+			'content'					=>	array('col' => 'D', 'name' => '内容'),
+			'add_time'					=>	array('col' => 'E', 'name' => '添加时间'),
+		),
+);
+?>

+ 33 - 0
Application/Admin/Lang/zh-cn/admin.php

@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * 模块语言包-管理员
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 登录
+	'login_username_text'				=>	'用户名',
+	'login_login_pwd_text'				=>	'登录密码',
+	'login_username_format'				=>	'用户名格式 5~18 个字符(可以是字母数字下划线)',
+	'login_login_pwd_format'			=>	'密码格式 6~18 个字符',
+	'login_role_id_format'				=>	'请选择所属角色组',
+	'login_button_text'					=>	'登录',
+	'login_forgot_pwd_text'				=>	'忘记密码?',
+	'login_forgot_pwd_tips'				=>	'请联系管理员重置密码',
+	'login_username_no_exist'			=>	'管理员不存在',
+	'login_login_pwd_error'				=>	'密码错误',
+	'login_role_id_error'				=>	'角色不存在',
+	'login_login_error'					=>	'登录失败,请稍后再试!',
+	'login_login_success'				=>	'登录成功',
+
+	// 管理员添加及编辑
+	'login_total_name'					=>	'登录次数',
+	'login_last_time_name'				=>	'最后登录时间',
+	'admin_add_name'					=>	'管理员添加',
+	'admin_edit_name'					=>	'管理员编辑',
+	'admin_view_role_name'				=>	'权限组',
+);
+?>

+ 27 - 0
Application/Admin/Lang/zh-cn/article.php

@@ -0,0 +1,27 @@
+<?php
+
+/**
+ * 模块语言包-文章
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 添加/编辑
+	'article_add_name'					=>	'文章添加',
+	'article_edit_name'					=>	'文章编辑',
+	'article_title_text'				=>	'标题',
+	'article_jump_url_text'				=>	'跳转url地址',
+	'article_content_text'				=>	'内容',
+	'article_class_text'				=>	'文章分类',
+	'article_title_format'				=>	'标题长度 3~60 个字符',
+	'article_jump_url_format'			=>	'跳转url地址格式有误',
+	'article_content_format'			=>	'内容长度最少 50~105000 个字符',
+	'article_content_format_mobile'		=>	'更多编辑功能请使用电脑访问',
+	'article_class_format'				=>	'请选择文章分类',
+	'article_article_class_id_error'	=>	'文章分类id不存在',
+	'article_so_keyword_tips'			=>	'标题关键字',
+	'article_images_upload_format'		=>	'为了站点自适应结构美观,图片尺寸比例:宽度的%'.MyC('common_image_proportion', 56.23, true).' [计算规则 '.MyC('common_image_proportion', 56.23, true).'除以100再乘以宽度] 得到高度',
+);
+?>

+ 15 - 0
Application/Admin/Lang/zh-cn/articleclass.php

@@ -0,0 +1,15 @@
+<?php
+
+/**
+ * 模块语言包-文章分类
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 添加/编辑
+	'articleclass_add_name'					=>	'文章分类添加',
+	'articleclass_edit_name'				=>	'文章分类编辑',
+);
+?>

+ 15 - 0
Application/Admin/Lang/zh-cn/bubble.php

@@ -0,0 +1,15 @@
+<?php
+
+/**
+ * 模块语言包-冒泡
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	'bubble_praise_table_nickname'				=>	'用户',
+	'bubble_praise_table_add_time'				=>	'点赞时间',
+	'bubble_so_keyword_tips'					=>	'昵称/手机/邮箱/说说',
+);
+?>

+ 33 - 0
Application/Admin/Lang/zh-cn/cache.php

@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * 模块语言包-缓存管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 缓存类型列表
+	'cache_type_list'			=>	array(
+			array(
+				'is_enable' => 1,
+				'name' => '站点缓存',
+				'url' => U('Admin/Cache/SiteUpdate'),
+				'desc' => '数据转换后或前台不能正常访问时,可以使用此功能更新所有缓存'
+			),
+			array(
+				'is_enable' => 1,
+				'name' => '模板缓存',
+				'url' => U('Admin/Cache/TemplateUpdate'),
+				'desc' => '当页面显示不正常,可尝试使用此功能修复'
+			),
+			array(
+				'is_enable' => 0,
+				'name' => '模块缓存',
+				'url' => U('Admin/Cache/ModuleUpdate'),
+				'desc' => '更新页面布局与模块后未生效,可尝试使用此功能修复'
+			),
+		),
+);
+?>

+ 15 - 0
Application/Admin/Lang/zh-cn/class.php

@@ -0,0 +1,15 @@
+<?php
+
+/**
+ * 模块语言包-班级
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 添加/编辑
+	'class_add_name'					=>	'班级添加',
+	'class_edit_name'					=>	'班级编辑',
+);
+?>

+ 14 - 0
Application/Admin/Lang/zh-cn/config.php

@@ -0,0 +1,14 @@
+<?php
+
+/**
+ * 模块语言包-配置信息
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 添加/编辑
+	
+);
+?>

+ 34 - 0
Application/Admin/Lang/zh-cn/course.php

@@ -0,0 +1,34 @@
+<?php
+
+/**
+ * 模块语言包-课程
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 添加/编辑
+	'course_add_name'					=>	'课程添加',
+	'course_edit_name'					=>	'课程编辑',
+	'course_class_text'					=>	'班级',
+	'course_week_text'					=>	'周天',
+	'course_subject_text'				=>	'科目',
+	'course_interval_text'				=>	'时段',
+	'course_class_format'				=>	'请选择班级',
+	'course_week_format'				=>	'请选择周天',
+	'course_subject_format'				=>	'请选择科目',
+	'course_interval_format'			=>	'请选择时段',
+	'course_teacher_tips'				=>	'教师不存在',
+	'course_class_tips'					=>	'班级不存在',
+	'course_subject_tips'				=>	'科目不存在',
+	'course_week_tips'					=>	'周天不存在',
+	'course_interval_tips'				=>	'时段不存在',
+	'course_so_keyword_tips'			=>	'教师姓名',
+	'course_teacher_text'				=>	'教师姓名',
+	'course_room_text'					=>	'教室',
+	'course_room_format'				=>	'请选择教室',
+	'course_room_tips'					=>	'教室不存在',
+	'course_room_occupy_tips'			=>	'当前周天时段的教室已被占用',
+);
+?>

+ 30 - 0
Application/Admin/Lang/zh-cn/culturedecorate.php

@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * 模块语言包-养鱼 - 装饰
+ */
+return array(
+    'decorate_add_name'              =>  '装饰添加',
+    'decorate_edit_name'             =>  '装饰编辑',
+    'decorate_so_keyword_tips'       =>  '装饰名称',
+    'decorate_time_start_text'       =>  '起始时间',
+    'decorate_time_end_text'         =>  '结束时间',
+    'decorate_id'                    =>  '装饰ID',
+    'decorate_name'                  =>  '装饰名称',
+    'decorate_type_name'             =>  '装饰类型',
+    'decorate_target_type_name'      =>  '装饰对象类型',
+    'decorate_target_name'           =>  '所属对象',
+    'decorate_target_property_name'  =>  '所属对象专属',
+    'thumb'                          =>  '缩略图',
+    'description'                    =>  '描述',
+    'sale_price'                     =>  '售价',
+    'created_at'                     =>  '创建时间',
+    'updated_at'                     =>  '更新时间',
+    'deleted_at'                     =>  '删除时间',
+
+    //错误提示
+    'decorate_type_format'           =>  '请选择装饰类型',
+    'decorate_target_type_name_format'      =>  '请选择装饰对象类型',
+    'scene_format'                   =>  '请选择场景',
+);
+?>

+ 30 - 0
Application/Admin/Lang/zh-cn/culturedecoratetargettype.php

@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * 模块语言包-养鱼 - 装饰
+ */
+return array(
+    'decorate_add_name'              =>  '装饰添加',
+    'decorate_edit_name'             =>  '装饰编辑',
+    'decorate_so_keyword_tips'       =>  '装饰名称',
+    'decorate_time_start_text'       =>  '起始时间',
+    'decorate_time_end_text'         =>  '结束时间',
+    'decorate_id'                    =>  '装饰ID',
+    'decorate_name'                  =>  '装饰名称',
+    'decorate_type_name'             =>  '装饰类型',
+    'decorate_target_type_name'      =>  '装饰对象类型',
+    'decorate_target_name'           =>  '所属对象',
+    'decorate_target_property_name'  =>  '所属对象专属',
+    'thumb'                          =>  '缩略图',
+    'description'                    =>  '描述',
+    'sale_price'                     =>  '售价',
+    'created_at'                     =>  '创建时间',
+    'updated_at'                     =>  '更新时间',
+    'deleted_at'                     =>  '删除时间',
+
+    //错误提示
+    'decorate_type_format'           =>  '请选择装饰类型',
+    'decorate_target_type_name_format'      =>  '请选择装饰对象类型',
+    'scene_format'                   =>  '请选择场景',
+);
+?>

+ 28 - 0
Application/Admin/Lang/zh-cn/culturedecoratetype.php

@@ -0,0 +1,28 @@
+<?php
+
+/**
+ * 模块语言包-养鱼 - 装饰类型
+ */
+return array(
+    'decorate_type_add_name'              =>  '装饰类型添加',
+    'decorate_type_edit_name'             =>  '装饰类型编辑',
+    'decorate_type_so_keyword_tips'       =>  '装饰类型名称',
+    'decorate_type_time_start_text'       =>  '起始时间',
+    'decorate_type_time_end_text'         =>  '结束时间',
+    'decorate_type_id'                    =>  '装饰类型ID',
+    'decorate_type_name'                  =>  '装饰类型名称',
+    'decorate_target_type_name'      =>  '装饰对象类型',
+    'decorate_target_name'           =>  '所属对象',
+    'decorate_target_property_name'  =>  '所属对象专属',
+    'thumb'                          =>  '缩略图',
+    'description'                    =>  '描述',
+    'created_at'                     =>  '创建时间',
+    'updated_at'                     =>  '更新时间',
+    'deleted_at'                     =>  '删除时间',
+
+    //错误提示
+    'decorate_type_format'           =>  '请选择装饰类型类型',
+    'decorate_target_type_name_format'      =>  '请选择装饰类型对象类型',
+    'scene_format'                   =>  '请选择场景',
+);
+?>

+ 33 - 0
Application/Admin/Lang/zh-cn/culturefood.php

@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * 模块语言包-养鱼 - 食物
+ */
+return array(
+    'food_add_name'                   =>  '食物添加',
+    'food_edit_name'                  =>  '食物编辑',
+    'food_so_keyword_tips'            =>  '食物名称',
+    'food_time_start_text'            =>  '起始时间',
+    'food_time_end_text'              =>  '结束时间',
+    'food_id'                         =>  '食物ID',
+    'food_name'                       =>  '食物名称',
+    'pet_id'                          =>  '宠物ID',
+    'pet_name'                        =>  '宠物名称',
+    'pet_type_id'                     =>  '宠物类型ID',
+    'pet_type_name'                   =>  '宠物类型名称',
+    'thumb'                           =>  '缩略图',
+    'description'                     =>  '描述',
+    'sale_price'                      =>  '售价',
+    'created_at'                      =>  '创建时间',
+    'updated_at'                      =>  '更新时间',
+    'deleted_at'                      =>  '删除时间',
+    'grown_value'                     =>  '成长值',
+    'pre_user_limit_num'              =>  '每个用户限制个数',
+
+    //错误提示
+    'food_format'                =>  '请选择食物类型',
+    'pet_type_format'                =>  '请选择宠物类型',
+    'pet_format'                =>  '请选择类型',
+    'scene_format'                    =>  '请选择场景',
+);
+?>

+ 29 - 0
Application/Admin/Lang/zh-cn/culturepet.php

@@ -0,0 +1,29 @@
+<?php
+
+/**
+ * 模块语言包-养鱼 - 宠物
+ */
+return array(
+    'pet_add_name'                   =>  '宠物添加',
+    'pet_edit_name'                  =>  '宠物编辑',
+    'pet_so_keyword_tips'            =>  '宠物名称',
+    'pet_time_start_text'            =>  '起始时间',
+    'pet_time_end_text'              =>  '结束时间',
+    'pet_id'                         =>  '宠物ID',
+    'pet_name'                       =>  '宠物名称',
+    'pet_type_name'                  =>  '宠物类型',
+    'thumb'                          =>  '缩略图',
+    'description'                    =>  '描述',
+    'sale_price'                     =>  '售价',
+    'created_at'                     =>  '创建时间',
+    'updated_at'                     =>  '更新时间',
+    'deleted_at'                     =>  '删除时间',
+    'scene_name'                     =>  '场景',
+    'grown_value'                    =>  '成长值',
+    'pre_user_limit_num'             =>  '每个用户限制个数',
+
+    //错误提示
+    'pet_type_format'                =>  '请选择宠物类型',
+    'scene_format'                   =>  '请选择场景',
+);
+?>

+ 27 - 0
Application/Admin/Lang/zh-cn/culturepettype.php

@@ -0,0 +1,27 @@
+<?php
+
+/**
+ * 模块语言包-养鱼 - 宠物类型
+ */
+return array(
+    'pet_type_add_name'                   =>  '宠物类型添加',
+    'pet_type_edit_name'                  =>  '宠物类型编辑',
+    'pet_type_so_keyword_tips'            =>  '宠物类型名称',
+    'pet_type_time_start_text'            =>  '起始时间',
+    'pet_type_time_end_text'              =>  '结束时间',
+    'pet_type_id'                         =>  '宠物类型ID',
+    'pet_type_name'                       =>  '宠物类型名称',
+    'thumb'                          =>  '缩略图',
+    'description'                    =>  '描述',
+    'sale_price'                     =>  '售价',
+    'created_at'                     =>  '创建时间',
+    'updated_at'                     =>  '更新时间',
+    'deleted_at'                     =>  '删除时间',
+    'scene_name'                     =>  '场景',
+    'grown_value'                    =>  '成长值',
+
+    //错误提示
+    'pet_type_type_format'                =>  '请选择宠物类型类型',
+    'scene_format'                   =>  '请选择场景',
+);
+?>

+ 21 - 0
Application/Admin/Lang/zh-cn/culturescene.php

@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * 模块语言包-养鱼 - 场景
+ */
+return array(
+    'scene_add_name'                 =>  '场景添加',
+    'scene_edit_name'                =>  '场景编辑',
+    'scene_so_keyword_tips'          =>  '场景名称',
+    'scene_time_start_text'          =>  '起始时间',
+    'scene_time_end_text'            =>  '结束时间',
+    'scene_id'                       =>  '场景ID',
+    'scene_name'                     =>  '场景名称',
+    'thumb'                          =>  '缩略图',
+    'description'                    =>  '描述',
+    'sale_price'                     =>  '售价',
+    'created_at'                     =>  '创建时间',
+    'updated_at'                     =>  '更新时间',
+    'deleted_at'                     =>  '删除时间',
+);
+?>

+ 26 - 0
Application/Admin/Lang/zh-cn/culturescenebackground.php

@@ -0,0 +1,26 @@
+<?php
+
+/**
+ * 模块语言包-养鱼 - 场景背景
+ */
+return array(
+    'scene_background_add_name'                 =>  '场景背景添加',
+    'scene_background_edit_name'                =>  '场景背景编辑',
+    'scene_background_so_keyword_tips'          =>  '场景背景名称',
+    'scene_background_time_start_text'          =>  '起始时间',
+    'scene_background_time_end_text'            =>  '结束时间',
+    'scene_background_id'                       =>  '场景背景ID',
+    'scene_background_name'                     =>  '场景背景名称',
+    'thumb'                          =>  '缩略图',
+    'description'                    =>  '描述',
+    'sale_price'                     =>  '售价',
+    'scene_name'                     =>  '场景名称',
+    'created_at'                     =>  '创建时间',
+    'updated_at'                     =>  '更新时间',
+    'deleted_at'                     =>  '删除时间',
+
+    'is_lock'                     =>  '是否锁定',
+    'is_unlock_buy'                     =>  '是否解锁即拥有',
+
+);
+?>

+ 21 - 0
Application/Admin/Lang/zh-cn/customview.php

@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * 模块语言包-自定义页面
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 添加/编辑
+	'customview_add_name'					=>	'自定义页面添加',
+	'customview_edit_name'					=>	'自定义页面编辑',
+	'customview_title_text'					=>	'标题',
+	'customview_content_text'				=>	'内容',
+	'customview_title_format'				=>	'标题长度 3~60 个字符',
+	'customview_content_format'				=>	'内容长度最少 50~105000 个字符',
+	'customview_content_format_mobile'		=>	'更多编辑功能请使用电脑访问',
+	'customview_so_keyword_tips'			=>	'标题关键字',
+);
+?>

+ 17 - 0
Application/Admin/Lang/zh-cn/email.php

@@ -0,0 +1,17 @@
+<?php
+
+/**
+ * 模块语言包-邮箱设置
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	'email_email_nav_name'			=>	'邮箱设置',
+	'email_message_nav_name'		=>	'消息模板',
+	'email_test_email_text'			=>	'测试接收的邮件地址',
+	'email_test_email_tips'			=>	'请先保存后,再进行测试',
+	'email_test_email_send_content'	=>	'邮件配置-发送测试内容',
+);
+?>

+ 32 - 0
Application/Admin/Lang/zh-cn/fraction.php

@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * 模块语言包-成绩
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 添加/编辑
+	'fraction_add_name'					=>	'成绩添加',
+	'fraction_edit_name'				=>	'成绩编辑',
+	'fraction_score_id_text'			=>	'期号',
+	'fraction_score_id_format'			=>	'请选择成绩期号',
+	'fraction_score_id_error'			=>	'成绩期号有误',
+	'fraction_subject_text'				=>	'科目',
+	'fraction_subject_format'			=>	'请选择科目',
+	'fraction_subject_error'			=>	'科目分类有误',
+	'fraction_score_text'				=>	'成绩',
+	'fraction_score_format'				=>	'分数格式错误,纯数字,不能超过3位',
+	'fraction_student_error'			=>	'该学生不存在',
+	'fraction_username_text'			=>	'学生姓名',
+	'fraction_student_username_format'	=>	'学生真实姓名',
+	'fraction_student_id_error'			=>	'学生信息有误',
+	'fraction_score_level_text'			=>	'等级',
+	'fraction_class_id_text'			=>	'班级',
+	'fraction_comment_text'				=>	'教师点评',
+	'fraction_comment_format'			=>	'教师点评,不能超过255个字符',
+	'fraction_excel_import_tips'		=>	'1、录入时间选填项,留空则使用当前导入时间。<br />2、所有数据字段以文本格式上传,如[ 成绩分数 ]',
+);
+?>

+ 28 - 0
Application/Admin/Lang/zh-cn/index.php

@@ -0,0 +1,28 @@
+<?php
+
+/**
+ * 模块语言包-首页
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 列表
+	'server_ver_nam	'					=>	'服务器信息',
+	'php_ver_name'						=>	'PHP版本',
+	'mysql_ver_name'					=>	'MySQL版本',
+	'os_ver_name'						=>	'操作系统',
+	'host_name'							=>	'当前域名',
+	'ver_name'							=>	'软件版本',
+	'server_ver_name'					=>	'服务器端信息',
+	'ver_to_view_name'					=>	'查看最新版本',
+	'copyright_name'					=>	'版权所有',
+	'originator_name'					=>	'发起人',
+	'research_name'						=>	'研发成员',
+	'ued_name'							=>	'UED',
+	'market_operation'					=>	'市场运作',
+	'os_view_title'						=>	'系统信息',
+	'team_view_title'					=>	'开发团队',
+);
+?>

+ 17 - 0
Application/Admin/Lang/zh-cn/interval.php

@@ -0,0 +1,17 @@
+<?php
+
+/**
+ * 模块语言包-时段
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 添加/编辑
+	'interval_add_name'					=>	'时段添加',
+	'interval_edit_name'				=>	'时段编辑',
+	'interval_name_format'				=>	'时段格式错误 格式如 10:00-11:30',
+	'interval_name_format_tips'			=>	'格式如 10:00-11:30',
+);
+?>

+ 24 - 0
Application/Admin/Lang/zh-cn/link.php

@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * 模块语言包-友情链接
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 公共
+	'link_add_name'						=>	'友情链接添加',
+	'link_edit_name'					=>	'友情链接编辑',
+
+	// 自定义导航
+	'link_name_text'					=>	'名称',
+	'link_name_format'					=>	'名称格式 2~16 个字符',
+	'link_describe_text'				=>	'描述',
+	'link_describe_format'				=>	'描述不能大于60个字符',
+	'link_url_text'						=>	'链接地址',
+	'link_url_text_tips'				=>	'带http://',
+	'link_url_format'					=>	'链接地址格式有误',
+);
+?>

+ 37 - 0
Application/Admin/Lang/zh-cn/navfooter.php

@@ -0,0 +1,37 @@
+<?php
+
+/**
+ * 模块语言包-底部导航
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 公共
+	'navheader_add_name'					=>	'导航添加',
+	'navheader_edit_name'					=>	'导航编辑',
+	'navheader_custom_operation_add'		=>	'自定义',
+	'navheader_article_class_operation_add'	=>	'分类',
+	'navheader_customview_operation_add'	=>	'页面',
+	'navheader_article_class_name_format'	=>	'默认文章分类名称',
+	'navheader_customview_name_format'		=>	'默认自定义页面名称',
+
+	// 自定义导航
+	'navheader_level_text'					=>	'导航级别',
+	'navheader_level_format'				=>	'导航级别选择错误',
+	'navheader_name_text'					=>	'导航名称',
+	'navheader_name_format'					=>	'导航名称格式 2~16 个字符',
+	'navheader_url_text'					=>	'url地址',
+	'navheader_url_text_tips'				=>	'带http://',
+	'navheader_url_format'					=>	'url格式有误',
+
+	// 文章分类导航
+	'navheader_article_class_id_text'		=>	'文章分类',
+	'navheader_article_class_id_format'		=>	'文章分类选择有误',
+
+	// 自定义页面导航
+	'navheader_customview_id_text'			=>	'自定义页面',
+	'navheader_customview_id_format'		=>	'自定义页面选择有误',
+);
+?>

+ 37 - 0
Application/Admin/Lang/zh-cn/navheader.php

@@ -0,0 +1,37 @@
+<?php
+
+/**
+ * 模块语言包-顶部导航
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 公共
+	'navheader_add_name'					=>	'导航添加',
+	'navheader_edit_name'					=>	'导航编辑',
+	'navheader_custom_operation_add'		=>	'自定义',
+	'navheader_article_class_operation_add'	=>	'分类',
+	'navheader_customview_operation_add'	=>	'页面',
+	'navheader_article_class_name_format'	=>	'默认文章分类名称',
+	'navheader_customview_name_format'		=>	'默认自定义页面名称',
+
+	// 自定义导航
+	'navheader_level_text'					=>	'导航级别',
+	'navheader_level_format'				=>	'导航级别选择错误',
+	'navheader_name_text'					=>	'导航名称',
+	'navheader_name_format'					=>	'导航名称格式 2~16 个字符',
+	'navheader_url_text'					=>	'url地址',
+	'navheader_url_text_tips'				=>	'带http://',
+	'navheader_url_format'					=>	'url格式有误',
+
+	// 文章分类导航
+	'navheader_article_class_id_text'		=>	'文章分类',
+	'navheader_article_class_id_format'		=>	'文章分类选择有误',
+
+	// 自定义页面导航
+	'navheader_customview_id_text'			=>	'自定义页面',
+	'navheader_customview_id_format'		=>	'自定义页面选择有误',
+);
+?>

+ 35 - 0
Application/Admin/Lang/zh-cn/power.php

@@ -0,0 +1,35 @@
+<?php
+
+/**
+ * 模块语言包-权限管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 登录
+	'power_level_text'					=>	'栏目级别',
+	'power_name_text'					=>	'权限名称',
+	'power_control_text'				=>	'控制器名称',
+	'power_action_text'					=>	'方法名称',
+	'power_name_format'					=>	'权限名称格式 2~8 个字符之间',
+	'power_control_format'				=>	'控制器名格式 1~30 个字符之间(必须以字母开始,可以是字母数字下划线)',
+	'power_action_format'				=>	'方法名格式 1~30 个字符之间(必须以字母开始,可以是字母数字下划线)',
+	'power_level_format'				=>	'栏目级别选择错误',
+	'power_add_name'					=>	'权限添加',
+	'power_edit_name'					=>	'权限编辑',
+	'power_no_exist_tips'				=>	'权限数据不存在',
+	'power_exist_item_tips'				=>	'该权限存在子级数据',
+	'power_view_have_title'				=>	'拥有权限',
+	'role_view_role_text'				=>	'角色名称',
+	'role_name_format'					=>	'角色名称格式 2~8 个字符之间',
+	'role_no_exist_tips'				=>	'角色数据不存在',
+	'power_level_format'				=>	'栏目级别选择错误',
+	'role_add_name'						=>	'角色添加',
+	'role_edit_name'					=>	'角色编辑',
+	'power_icon_text'					=>	'图标class',
+	'power_icon_format'					=>	'图标格式 0~30 个字符之间',
+	'power_icon_tips'					=>	'参考 [http://amazeui.org/css/icon]',
+);
+?>

+ 15 - 0
Application/Admin/Lang/zh-cn/region.php

@@ -0,0 +1,15 @@
+<?php
+
+/**
+ * 模块语言包-地区
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 登录
+	'region_add_name'					=>	'地区添加',
+	'region_edit_name'					=>	'地区编辑',
+);
+?>

+ 15 - 0
Application/Admin/Lang/zh-cn/room.php

@@ -0,0 +1,15 @@
+<?php
+
+/**
+ * 模块语言包-教室
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 添加/编辑
+	'room_add_name'					=>	'教室添加',
+	'room_edit_name'					=>	'教室编辑',
+);
+?>

+ 15 - 0
Application/Admin/Lang/zh-cn/score.php

@@ -0,0 +1,15 @@
+<?php
+
+/**
+ * 模块语言包-成绩
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 添加/编辑
+	'score_add_name'					=>	'成绩添加',
+	'score_edit_name'				=>	'成绩编辑',
+);
+?>

+ 15 - 0
Application/Admin/Lang/zh-cn/semester.php

@@ -0,0 +1,15 @@
+<?php
+
+/**
+ * 模块语言包-学期
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 添加/编辑
+	'semester_add_name'					=>	'学期添加',
+	'semester_edit_name'				=>	'学期编辑',
+);
+?>

+ 33 - 0
Application/Admin/Lang/zh-cn/seo.php

@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * 模块语言包-seo
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// url模式列表
+	'seo_url_model_list'		=>	array(
+			0 => array('value' => 0, 'name' => '普通模式', 'checked' => true),
+			1 => array('value' => 1, 'name' => 'PATHINFO模式'),
+			2 => array('value' => 2, 'name' => 'REWRITE模式'),
+			3 => array('value' => 3, 'name' => '兼容模式'),
+		),
+
+	// 文章浏览方案列表
+	'seo_article_browser_list'	=>	array(
+			0 => array('value' => 0, 'name' => '文章标题', 'checked' => true),
+			1 => array('value' => 1, 'name' => '文章标题 - 站点名称'),
+			2 => array('value' => 2, 'name' => '文章标题 - 站点标题'),
+		),
+
+	// 频道浏览方案列表
+	'seo_channel_browser_list'	=>	array(
+			0 => array('value' => 0, 'name' => '频道名称', 'checked' => true),
+			1 => array('value' => 1, 'name' => '频道名称 - 站点名称'),
+			2 => array('value' => 2, 'name' => '频道名称 - 站点标题'),
+		),
+);
+?>

+ 448 - 0
Application/Admin/Lang/zh-cn/site.php

@@ -0,0 +1,448 @@
+<?php
+
+/**
+ * 模块语言包-站点设置
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	'site_site_logo_text'			=>	'选择网站logo',
+	
+	// 站点关闭状态列表
+	'site_site_state_list'			=>	array(
+			0 => array('value' => 0, 'name' => '关闭', 'checked' => true),
+			1 => array('value' => 1, 'name' => '开启'),
+		),
+
+	// 是否开启用户注册
+	'site_user_reg_state_list'			=>	array(
+			0 => array('value' => 'sms', 'name' => '短信'),
+			1 => array('value' => 'email', 'name' => '邮箱'),
+		),
+
+	// 是否开启用户登录
+	'site_user_login_state_list'			=>	array(
+			0 => array('value' => 0, 'name' => '关闭'),
+			1 => array('value' => 1, 'name' => '开启', 'checked' => true),
+		),
+
+	// 获取验证码-强制使用图片验证码状态列表
+	'site_img_verify_state_list'		=>	array(
+			0 => array('value' => 0, 'name' => '关闭'),
+			1 => array('value' => 1, 'name' => '开启', 'checked' => true),
+		),
+
+	// 时区
+	'site_timezone_list' => array(
+		'Europe/Andorra' => '欧洲/安道尔(标准时+1)',
+		'Asia/Dubai' => '亚洲/杜拜(标准时+4)',
+		'Asia/Kabul' => '亚洲/喀布尔(标准时+4)',
+		'America/Antigua' => '美洲/安地卡及巴布达(标准时-4)',
+		'America/Anguilla' => '美洲/安圭拉岛(标准时-4)',
+		'Europe/Tirane' => '欧洲/地拉那(标准时+1)',
+		'Asia/Yerevan' => '亚洲/埃里温(标准时+4)',
+		'Africa/Luanda' => '非洲/罗安达(标准时+1)',
+		'America/Argentina/Buenos_Aires' => '美洲/阿根廷/布宜诺斯艾利斯(标准时-3)',
+		'America/Argentina/Catamarca' => '美洲/阿根廷/卡塔马卡(标准时-3)',
+		'America/Argentina/Cordoba' => '美洲/阿根廷/科尔多瓦(标准时-3)',
+		'America/Argentina/Jujuy' => '美洲/阿根廷/胡胡伊(标准时-3)',
+		'America/Argentina/La_Rioja' => '美洲/阿根廷/拉里奥哈(标准时-3)',
+		'America/Argentina/Mendoza' => '美洲/阿根廷/门多萨(标准时-3)',
+		'America/Argentina/Rio_Gallegos' => '美洲/阿根廷/里奥加耶戈斯(标准时-3)',
+		'America/Argentina/Salta' => '美洲/阿根廷/萨尔塔(标准时-3)',
+		'America/Argentina/San_Juan' => '美洲/阿根廷/圣胡安(标准时-3)',
+		'America/Argentina/San_Luis' => '美洲/阿根廷/圣路易斯(标准时-3)',
+		'America/Argentina/Tucuman' => '美洲/阿根廷/图库曼(标准时-3)',
+		'America/Argentina/Ushuaia' => '美洲/阿根廷/乌斯怀亚(标准时-3)',
+		'Pacific/Pago_Pago' => '太平洋/帕果帕果(标准时-11)',
+		'Europe/Vienna' => '欧洲/维也纳(标准时+1)',
+		'Australia/Adelaide' => '澳大利亚/阿德莱德(标准时+10)',
+		'Australia/Brisbane' => '澳大利亚/布里斯班(标准时+10)',
+		'Australia/Broken_Hill' => '澳大利亚/布洛肯希尔(标准时+10)',
+		'Australia/Currie' => '澳大利亚/柯里(标准时+11)',
+		'Australia/Darwin' => '澳大利亚/达尔文(标准时+9)',
+		'Australia/Eucla' => '澳大利亚/尤克拉(标准时+8)',
+		'Australia/Hobart' => '澳大利亚/霍巴特(标准时+11)',
+		'Australia/Lindeman' => '澳大利亚/林德曼(标准时+10)',
+		'Australia/Lord_Howe' => '澳大利亚/豪勋爵岛(标准时+11)',
+		'Australia/Melbourne' => '澳大利亚/墨尔本(标准时+11)',
+		'Australia/Perth' => '澳大利亚/珀斯(标准时+8)',
+		'Australia/Sydney' => '澳大利亚/悉尼(标准时+11)',
+		'America/Aruba' => '美洲/阿鲁巴(标准时-4)',
+		'Europe/Mariehamn' => '欧洲/玛丽港(标准时+2)',
+		'Asia/Baku' => '亚洲/巴库(标准时+4)',
+		'Europe/Sarajevo' => '欧洲/萨拉热窝(标准时+1)',
+		'America/Barbados' => '美洲/巴巴多斯(标准时-4)',
+		'Asia/Dhaka' => '亚洲/达卡(标准时+6)',
+		'Europe/Brussels' => '欧洲/布鲁塞尔(标准时+1)',
+		'Africa/Ouagadougou' => '非洲/瓦加杜古(标准时+0)',
+		'Europe/Sofia' => '欧洲/索非亚(标准时+2)',
+		'Asia/Bahrain' => '亚洲/巴林(标准时+3)',
+		'Africa/Bujumbura' => '非洲/布琼布拉(标准时+2)',
+		'Africa/Porto-Novo' => '非洲/波尔图(标准时+1)',
+		'America/St_Barthelemy' => '美洲/圣巴托洛缪(标准时-4)',
+		'Atlantic/Bermuda' => '大西洋/百慕达(标准时-4)',
+		'Asia/Brunei' => '亚洲/文莱(标准时+8)',
+		'America/La_Paz' => '美洲/拉巴斯(标准时-4)',
+		'America/Kralendijk' => '美洲/博内尔(标准时-4)',
+		'America/Araguaina' => '美洲/阿拉瓜伊纳(标准时-3)',
+		'America/Bahia' => '美洲/巴伊亚(标准时-3)',
+		'America/Belem' => '美洲/贝伦(标准时-3)',
+		'America/Boa_Vista' => '美洲/博阿维斯塔(标准时-4)',
+		'America/Campo_Grande' => '美洲/大坎普(标准时-3)',
+		'America/Cuiaba' => '美洲/库亚巴(标准时-3)',
+		'America/Eirunepe' => '美洲/艾鲁内佩(标准时-5)',
+		'America/Fortaleza' => '美洲/福塔莱萨(标准时-3)',
+		'America/Maceio' => '美洲/马赛约(标准时-3)',
+		'America/Manaus' => '美洲/马瑙斯(标准时-4)',
+		'America/Noronha' => '美洲/奥诺罗尼亚(标准时-2)',
+		'America/Porto_Velho' => '美洲/波多韦柳(标准时-4)',
+		'America/Recife' => '美洲/累西腓(标准时-3)',
+		'America/Rio_Branco' => '美洲/里奥布朗库(标准时-5)',
+		'America/Santarem' => '美洲/桑特莱(标准时-3)',
+		'America/Sao_Paulo' => '美洲/圣保罗(标准时-2)',
+		'America/Nassau' => '美洲/拿骚(标准时-5)',
+		'Asia/Thimphu' => '亚洲/廷布(标准时+6)',
+		'Africa/Gaborone' => '非洲/哈博罗内(标准时+2)',
+		'Europe/Minsk' => '欧洲/明斯克(标准时+3)',
+		'America/Belize' => '美洲/伯利兹(标准时-6)',
+		'America/Atikokan' => '美洲/阿蒂科肯(标准时-5)',
+		'America/Blanc-Sablon' => '美洲/相思(标准时-4)',
+		'America/Cambridge_Bay' => '美洲/剑桥湾(标准时-7)',
+		'America/Creston' => '美洲/克雷斯顿(标准时-7)',
+		'America/Dawson' => '美洲/道森(标准时-8)',
+		'America/Dawson_Creek' => '美洲/道森克里克(标准时-7)',
+		'America/Edmonton' => '美洲/埃德蒙顿(标准时-7)',
+		'America/Glace_Bay' => '美洲/格莱斯贝(标准时-4)',
+		'America/Goose_Bay' => '美洲/鹅湾(标准时-4)',
+		'America/Halifax' => '美洲/哈利法克斯(标准时-4)',
+		'America/Inuvik' => '美洲/伊努维克(标准时-7)',
+		'America/Iqaluit' => '美洲/伊卡瑞特(标准时-5)',
+		'America/Moncton' => '美洲/蒙克顿(标准时-4)',
+		'America/Montreal' => '美洲/蒙特利尔(标准时-5)',
+		'America/Nipigon' => '美洲/尼皮贡(标准时-5)',
+		'America/Pangnirtung' => '美洲/潘尼尔东(标准时-5)',
+		'America/Rainy_River' => '美洲/雨河(标准时-6)',
+		'America/Rankin_Inlet' => '美洲/兰进(标准时-6)',
+		'America/Regina' => '美洲/里贾纳(标准时-6)',
+		'America/Resolute' => '美洲/雷索卢特(标准时-6)',
+		'America/St_Johns' => '美洲/圣约翰斯(标准时-3)',
+		'America/Swift_Current' => '美洲/斯威夫特卡伦特(标准时-6)',
+		'America/Thunder_Bay' => '美洲/桑德湾(标准时-5)',
+		'America/Toronto' => '美洲/加拿大多伦多(标准时-5)',
+		'America/Vancouver' => '美洲/温哥华(标准时-8)',
+		'America/Whitehorse' => '美洲/怀特霍尔斯(标准时-8)',
+		'America/Winnipeg' => '美洲/温尼伯(标准时-6)',
+		'America/Yellowknife' => '美洲/耶洛奈夫(标准时-7)',
+		'Indian/Cocos' => '印度洋/科科斯(标准时+6)',
+		'Africa/Kinshasa' => '非洲/金沙萨(标准时+1)',
+		'Africa/Lubumbashi' => '非洲/卢本巴希(标准时+2)',
+		'Africa/Bangui' => '非洲/班吉(标准时+1)',
+		'Africa/Brazzaville' => '非洲/布拉柴维尔(标准时+1)',
+		'Europe/Zurich' => '欧洲/苏黎世(标准时+1)',
+		'Africa/Abidjan' => '非洲/阿比让(标准时+0)',
+		'Pacific/Rarotonga' => '太平洋/拉罗汤加(标准时-10)',
+		'America/Santiago' => '美洲/圣地亚哥(标准时-3)',
+		'Pacific/Easter' => '太平洋/复活岛(标准时-5)',
+		'Africa/Douala' => '非洲/杜阿拉(标准时+1)',
+		'Asia/Chongqing' => '亚洲/重庆(标准时+8)',
+		'Asia/Harbin' => '亚洲/哈尔滨(标准时+8)',
+		'Asia/Kashgar' => '亚洲/喀什葛尔(标准时+6)',
+		'Asia/Shanghai' => '亚洲/上海(标准时+8)',
+		'Asia/Urumqi' => '亚洲/乌鲁木齐(标准时+6)',
+		'America/Bogota' => '美洲/波哥大(标准时-5)',
+		'America/Costa_Rica' => '美洲/哥斯达黎加(标准时-6)',
+		'America/Havana' => '美洲/哈瓦那(标准时-5)',
+		'Atlantic/Cape_Verde' => '大西洋/佛得角(标准时-1)',
+		'America/Curacao' => '美洲/库拉索岛(标准时-4)',
+		'Indian/Christmas' => '印度/圣诞岛(标准时+7)',
+		'Asia/Nicosia' => '亚洲/尼科西亚(标准时+2)',
+		'Europe/Prague' => '欧洲/布拉格(标准时+1)',
+		'Europe/Berlin' => '欧洲/柏林(标准时+1)',
+		'Europe/Busingen' => '欧洲/布辛根(标准时+1)',
+		'Africa/Djibouti' => '非洲/吉布提(标准时+3)',
+		'Europe/Copenhagen' => '欧洲/哥本哈根(标准时+1)',
+		'America/Dominica' => '美洲/多米尼加(标准时-4)',
+		'America/Santo_Domingo' => '美洲/圣多明各(标准时-4)',
+		'Africa/Algiers' => '非洲/阿尔及尔(标准时+1)',
+		'America/Guayaquil' => '美洲/瓜亚基尔(标准时-5)',
+		'Pacific/Galapagos' => '太平洋/加拉帕戈斯(标准时-6)',
+		'Europe/Tallinn' => '欧洲/塔林(标准时+2)',
+		'Africa/Cairo' => '非洲/开罗(标准时+2)',
+		'Africa/El_Aaiun' => '非洲/阿尤恩(标准时+0)',
+		'Africa/Asmara' => '非洲/阿斯马拉(标准时+3)',
+		'Africa/Ceuta' => '非洲/休达(标准时+1)',
+		'Atlantic/Canary' => '大西洋/加那利(标准时+0)',
+		'Europe/Madrid' => '欧洲/马德里(标准时+1)',
+		'Africa/Addis_Ababa' => '非洲/亚的斯亚贝巴(标准时+3)',
+		'Europe/Helsinki' => '欧洲/赫尔辛基(标准时+2)',
+		'Pacific/Fiji' => '太平洋/斐济(标准时+12)',
+		'Atlantic/Stanley' => '大西洋/赤柱监狱(标准时-3)',
+		'Pacific/Chuuk' => '太平洋/特鲁克(标准时+10)',
+		'Pacific/Kosrae' => '太平洋/科斯雷(标准时+11)',
+		'Pacific/Pohnpei' => '太平洋/波纳佩(标准时+11)',
+		'Atlantic/Faroe' => '大西洋/法罗群岛(标准时+0)',
+		'Europe/Paris' => '欧洲/巴黎(标准时+1)',
+		'Africa/Libreville' => '非洲/利伯维尔(标准时+1)',
+		'Europe/London' => '欧洲/伦敦(标准时+0)',
+		'America/Grenada' => '美洲/格林纳达(标准时-4)',
+		'Asia/Tbilisi' => '亚洲/第比利斯(标准时+4)',
+		'America/Cayenne' => '美洲/卡宴(标准时-3)',
+		'Europe/Guernsey' => '欧洲/格恩西岛(标准时+0)',
+		'Africa/Accra' => '非洲/阿克拉(标准时+0)',
+		'Europe/Gibraltar' => '欧洲/直布罗陀(标准时+1)',
+		'America/Danmarkshavn' => '美洲/丹马沙(标准时+0)',
+		'America/Godthab' => '美洲/哥特哈布(标准时-3)',
+		'America/Scoresbysund' => '美洲/斯科斯比松(标准时-1)',
+		'America/Thule' => '美洲/图勒(标准时-4)',
+		'Africa/Banjul' => '非洲/班珠尔(标准时+0)',
+		'Africa/Conakry' => '非洲/科纳克里(标准时+0)',
+		'America/Guadeloupe' => '美洲/瓜德罗普岛(标准时-4)',
+		'Africa/Malabo' => '非洲/马拉博(标准时+1)',
+		'Europe/Athens' => '欧洲/雅典(标准时+2)',
+		'Atlantic/South_Georgia' => '大西洋/南乔治亚(标准时-2)',
+		'America/Guatemala' => '美洲/危地马拉(标准时-6)',
+		'Pacific/Guam' => '太平洋/关岛(标准时+10)',
+		'Africa/Bissau' => '非洲/比绍(标准时+0)',
+		'America/Guyana' => '美洲/圭亚那(标准时-4)',
+		'Asia/Hong_Kong' => '亚洲/香港(标准时+8)',
+		'America/Tegucigalpa' => '美洲/特古西加尔巴(标准时-6)',
+		'Europe/Zagreb' => '欧洲/萨格勒布(标准时+1)',
+		'America/Port-au-Prince' => '美洲/端口(标准时-5)',
+		'Europe/Budapest' => '欧洲/布达佩斯(标准时+1)',
+		'Asia/Jakarta' => '亚洲/雅加达(标准时+7)',
+		'Asia/Jayapura' => '亚洲/查亚普拉(标准时+9)',
+		'Asia/Makassar' => '亚洲/望加锡(标准时+8)',
+		'Asia/Pontianak' => '亚洲/坤甸(标准时+7)',
+		'Europe/Dublin' => '欧洲/都柏林(标准时+0)',
+		'Asia/Jerusalem' => '亚洲/耶路撒冷(标准时+2)',
+		'Europe/Isle_of_Man' => '欧洲/马恩岛(标准时+0)',
+		'Asia/Kolkata' => '亚洲/加尔各答(标准时+5)',
+		'Indian/Chagos' => '印度/查戈斯群岛(标准时+6)',
+		'Asia/Baghdad' => '亚洲/巴格达(标准时+3)',
+		'Asia/Tehran' => '亚洲/德黑兰(标准时+3)',
+		'Atlantic/Reykjavik' => '大西洋/雷克雅未克(标准时+0)',
+		'Europe/Rome' => '欧洲/罗马(标准时+1)',
+		'Europe/Jersey' => '欧洲/新泽西州(标准时+0)',
+		'America/Jamaica' => '美洲/牙买加(标准时-5)',
+		'Asia/Amman' => '亚洲/安曼(标准时+2)',
+		'Asia/Tokyo' => '亚洲/东京(标准时+9)',
+		'Africa/Nairobi' => '非洲/内罗毕(标准时+3)',
+		'Asia/Bishkek' => '亚洲/比什凯克(标准时+6)',
+		'Asia/Phnom_Penh' => '亚洲/金边(标准时+7)',
+		'Pacific/Enderbury' => '太平洋/恩德伯里(标准时+13)',
+		'Pacific/Kiritimati' => '太平洋/克里斯马斯(标准时+14)',
+		'Pacific/Tarawa' => '太平洋/塔拉瓦(标准时+12)',
+		'Indian/Comoro' => '印度/科莫罗(标准时+3)',
+		'America/St_Kitts' => '美洲/圣基茨(标准时-4)',
+		'Asia/Pyongyang' => '亚洲/平壤(标准时+8)',
+		'Asia/Seoul' => '亚洲/首尔(标准时+9)',
+		'Asia/Kuwait' => '亚洲/科威特(标准时+3)',
+		'America/Cayman' => '美洲/开曼(标准时-5)',
+		'Asia/Almaty' => '亚洲/阿拉木图(标准时+6)',
+		'Asia/Aqtau' => '亚洲/阿克套(标准时+5)',
+		'Asia/Aqtobe' => '亚洲/阿克托别(标准时+5)',
+		'Asia/Oral' => '亚洲/乌拉尔(标准时+5)',
+		'Asia/Qyzylorda' => '亚洲/克孜勒奥尔达(标准时+6)',
+		'Asia/Vientiane' => '亚洲/万象(标准时+7)',
+		'Asia/Beirut' => '亚洲/贝鲁特(标准时+2)',
+		'America/St_Lucia' => '美洲/圣露西亚(标准时-4)',
+		'Europe/Vaduz' => '欧洲/瓦杜兹(标准时+1)',
+		'Asia/Colombo' => '亚洲/科伦坡(标准时+5)',
+		'Africa/Monrovia' => '非洲/蒙罗维亚(标准时+0)',
+		'Africa/Maseru' => '非洲/马塞卢(标准时+2)',
+		'Europe/Vilnius' => '欧洲/维尔纽斯(标准时+2)',
+		'Europe/Luxembourg' => '欧洲/卢森堡(标准时+1)',
+		'Europe/Riga' => '欧洲/里加(标准时+2)',
+		'Africa/Tripoli' => '非洲/的黎波里(标准时+2)',
+		'Africa/Casablanca' => '非洲/卡萨布兰卡(标准时+0)',
+		'Europe/Monaco' => '欧洲/摩纳哥(标准时+1)',
+		'Europe/Chisinau' => '欧洲/基希纳乌(标准时+2)',
+		'Europe/Podgorica' => '欧洲/波多里加(标准时+1)',
+		'America/Marigot' => '美洲/马里戈特(标准时-4)',
+		'Indian/Antananarivo' => '印度/安塔那那利佛(标准时+3)',
+		'Pacific/Kwajalein' => '太平洋/夸贾林(标准时+12)',
+		'Pacific/Majuro' => '太平洋/马朱罗(标准时+12)',
+		'Europe/Skopje' => '欧洲/斯科普里(标准时+1)',
+		'Africa/Bamako' => '非洲/巴马科(标准时+0)',
+		'Asia/Rangoon' => '亚洲/仰光(标准时+6)',
+		'Asia/Choibalsan' => '亚洲/乔巴山(标准时+8)',
+		'Asia/Hovd' => '亚洲/科布多(标准时+7)',
+		'Asia/Ulaanbaatar' => '亚洲/乌兰巴托市(标准时+8)',
+		'Asia/Macau' => '亚洲/澳门(标准时+8)',
+		'Pacific/Saipan' => '太平洋/塞班岛(标准时+10)',
+		'America/Martinique' => '美洲/马提尼克岛(标准时-4)',
+		'Africa/Nouakchott' => '非洲/努瓦克肖特(标准时+0)',
+		'America/Montserrat' => '美洲/蒙特塞拉特岛(标准时-4)',
+		'Europe/Malta' => '欧洲/马耳他(标准时+1)',
+		'Indian/Mauritius' => '印度洋/毛里求斯(标准时+4)',
+		'Indian/Maldives' => '印度/马尔代夫(标准时+5)',
+		'Africa/Blantyre' => '非洲/布兰太尔(标准时+2)',
+		'America/Bahia_Banderas' => '美洲/巴伊亚班德拉斯(标准时-6)',
+		'America/Cancun' => '美洲/坎昆(标准时-5)',
+		'America/Chihuahua' => '美洲/契瓦瓦(标准时-7)',
+		'America/Hermosillo' => '美洲/埃莫西约(标准时-7)',
+		'America/Matamoros' => '美洲/马塔莫罗斯(标准时-6)',
+		'America/Mazatlan' => '美洲/马萨特兰(标准时-7)',
+		'America/Merida' => '美洲/梅里达(标准时-6)',
+		'America/Mexico_City' => '美洲/墨西哥城(标准时-6)',
+		'America/Monterrey' => '美洲/蒙特雷会议(标准时-6)',
+		'America/Ojinaga' => '美洲/Ojinaga(标准时-7)',
+		'America/Santa_Isabel' => '美洲/圣伊莎贝尔(标准时-8)',
+		'America/Tijuana' => '美洲/蒂华纳(标准时-8)',
+		'Asia/Kuala_Lumpur' => '亚洲/吉隆坡(标准时+8)',
+		'Asia/Kuching' => '亚洲/古晋(标准时+8)',
+		'Africa/Maputo' => '非洲/莫桑比克马普托(标准时+2)',
+		'Africa/Windhoek' => '非洲/温得和克(标准时+2)',
+		'Pacific/Noumea' => '太平洋/努美阿(标准时+11)',
+		'Africa/Niamey' => '非洲/尼亚美(标准时+1)',
+		'Pacific/Norfolk' => '太平洋/诺福克(标准时+11)',
+		'Africa/Lagos' => '非洲/拉各斯(标准时+1)',
+		'America/Managua' => '美洲/马那瓜(标准时-6)',
+		'Europe/Amsterdam' => '欧洲/阿姆斯特丹(标准时+1)',
+		'Europe/Oslo' => '欧洲/奥斯陆(标准时+1)',
+		'Asia/Kathmandu' => '亚洲/加德满都(标准时+5)',
+		'Pacific/Nauru' => '太平洋/瑙鲁(标准时+12)',
+		'Pacific/Niue' => '太平洋/纽埃(标准时-11)',
+		'Pacific/Auckland' => '太平洋/奥克兰(标准时+13)',
+		'Pacific/Chatham' => '太平洋/查塔姆(标准时+13)',
+		'Asia/Muscat' => '亚洲/马斯喀特(标准时+4)',
+		'America/Panama' => '美洲/巴拿马(标准时-5)',
+		'America/Lima' => '美洲/利马(标准时-5)',
+		'Pacific/Gambier' => '太平洋/甘比尔(标准时-9)',
+		'Pacific/Marquesas' => '太平洋/马克萨斯(标准时-9)',
+		'Pacific/Tahiti' => '太平洋/塔希提岛(标准时-10)',
+		'Pacific/Port_Moresby' => '太平洋/莫尔兹比港(标准时+10)',
+		'Asia/Manila' => '亚洲/马尼拉(标准时+8)',
+		'Asia/Karachi' => '亚洲/卡拉奇(标准时+5)',
+		'Europe/Warsaw' => '欧洲/华沙(标准时+1)',
+		'America/Miquelon' => '美洲/米克隆的(标准时-3)',
+		'Pacific/Pitcairn' => '太平洋/皮特凯恩(标准时-8)',
+		'America/Puerto_Rico' => '美洲/波多黎各(标准时-4)',
+		'Asia/Gaza' => '亚洲/加沙(标准时+2)',
+		'Asia/Hebron' => '亚洲/希伯伦(标准时+2)',
+		'Atlantic/Azores' => '大西洋/亚速尔群岛(标准时-1)',
+		'Atlantic/Madeira' => '大西洋/马德拉岛(标准时+0)',
+		'Europe/Lisbon' => '欧洲/里斯本(标准时+0)',
+		'Pacific/Palau' => '太平洋/帕劳(标准时+9)',
+		'America/Asuncion' => '美洲/亚松森(标准时-3)',
+		'Asia/Qatar' => '亚洲/卡塔尔(标准时+3)',
+		'Indian/Reunion' => '印度/留尼汪(标准时+4)',
+		'Europe/Bucharest' => '欧洲/布加勒斯特(标准时+2)',
+		'Europe/Belgrade' => '欧洲/贝尔格莱德(标准时+1)',
+		'Asia/Anadyr' => '亚洲/阿纳德尔(标准时+12)',
+		'Asia/Irkutsk' => '亚洲/伊尔库次克(标准时+8)',
+		'Asia/Kamchatka' => '亚洲/堪察加半岛(标准时+12)',
+		'Asia/Khandyga' => '亚洲/Khandyga(标准时+9)',
+		'Asia/Krasnoyarsk' => '亚洲/克拉斯诺亚尔斯克(标准时+7)',
+		'Asia/Magadan' => '亚洲/马加丹(标准时+11)',
+		'Asia/Novokuznetsk' => '亚洲/新库兹涅茨克(标准时+7)',
+		'Asia/Novosibirsk' => '亚洲/新西伯利亚(标准时+7)',
+		'Asia/Omsk' => '亚洲/鄂木斯克(标准时+6)',
+		'Asia/Sakhalin' => '亚洲/萨哈林岛(标准时+11)',
+		'Asia/Ust-Nera' => '亚洲/乌斯(标准时+7)',
+		'Asia/Vladivostok' => '亚洲/符拉迪沃斯托克(标准时+10)',
+		'Asia/Yakutsk' => '亚洲/雅库茨克(标准时+9)',
+		'Asia/Yekaterinburg' => '亚洲/叶卡捷琳堡(标准时+5)',
+		'Europe/Kaliningrad' => '欧洲/加里宁格勒(标准时+2)',
+		'Europe/Moscow' => '欧洲/莫斯科(标准时+3)',
+		'Europe/Samara' => '欧洲/萨马拉(标准时+4)',
+		'Europe/Volgograd' => '欧洲/伏尔加格勒(标准时+3)',
+		'Africa/Kigali' => '非洲/基加利(标准时+2)',
+		'Asia/Riyadh' => '亚洲/利雅得(标准时+3)',
+		'Pacific/Guadalcanal' => '太平洋/瓜达尔卡纳尔岛(标准时+11)',
+		'Indian/Mahe' => '印度/马埃岛(标准时+4)',
+		'Africa/Khartoum' => '非洲/喀土穆(标准时+3)',
+		'Europe/Stockholm' => '欧洲/斯德哥尔摩(标准时+1)',
+		'Asia/Singapore' => '亚洲/新加坡(标准时+8)',
+		'Atlantic/St_Helena' => '大西洋/圣赫勒拿岛(标准时+0)',
+		'Europe/Ljubljana' => '欧洲/卢布尔雅那(标准时+1)',
+		'Arctic/Longyearbyen' => '北极/朗伊尔城(标准时+1)',
+		'Europe/Bratislava' => '欧洲/布拉迪斯拉发(标准时+1)',
+		'Africa/Freetown' => '非洲/弗里敦(标准时+0)',
+		'Europe/San_Marino' => '欧洲/圣马力诺(标准时+1)',
+		'Africa/Dakar' => '非洲/达喀尔(标准时+0)',
+		'Africa/Mogadishu' => '非洲/摩加迪沙(标准时+3)',
+		'America/Paramaribo' => '美洲/帕拉马里博(标准时-3)',
+		'Africa/Juba' => '非洲/朱巴(标准时+3)',
+		'Africa/Sao_Tome' => '非洲/圣多美(标准时+0)',
+		'America/El_Salvador' => '美洲/萨尔瓦多(标准时-6)',
+		'America/Lower_Princes' => '美洲/下王子(标准时-4)',
+		'Asia/Damascus' => '亚洲/大马士革(标准时+2)',
+		'Africa/Mbabane' => '非洲/姆巴巴内(标准时+2)',
+		'America/Grand_Turk' => '美洲/大特克(标准时-4)',
+		'Africa/Ndjamena' => '非洲/恩贾梅纳(标准时+1)',
+		'Indian/Kerguelen' => '印度/凯尔盖朗(标准时+5)',
+		'Africa/Lome' => '非洲/洛美(标准时+0)',
+		'Asia/Bangkok' => '亚洲/曼谷(标准时+7)',
+		'Asia/Dushanbe' => '亚洲/杜尚别(标准时+5)',
+		'Pacific/Fakaofo' => '太平洋/法考福(标准时+13)',
+		'Asia/Dili' => '亚洲/帝力(标准时+9)',
+		'Asia/Ashgabat' => '亚洲/阿什哈巴特(标准时+5)',
+		'Africa/Tunis' => '非洲/突尼斯(标准时+1)',
+		'Pacific/Tongatapu' => '太平洋/汤加塔布(标准时+13)',
+		'Europe/Istanbul' => '欧洲/伊斯坦布尔(标准时+3)',
+		'America/Port_of_Spain' => '美洲/西班牙港(标准时-4)',
+		'Pacific/Funafuti' => '太平洋/富纳富提(标准时+12)',
+		'Asia/Taipei' => '亚洲/台北(标准时+8)',
+		'Africa/Dar_es_Salaam' => '非洲/达累斯萨拉姆(标准时+3)',
+		'Europe/Kiev' => '欧洲/基辅(标准时+2)',
+		'Europe/Simferopol' => '欧洲/辛菲罗波尔(标准时+3)',
+		'Europe/Uzhgorod' => '欧洲/乌日哥罗德(标准时+2)',
+		'Europe/Zaporozhye' => '欧洲/扎波罗热(标准时+2)',
+		'Africa/Kampala' => '非洲/坎帕拉(标准时+3)',
+		'Pacific/Johnston' => '太平洋/约翰斯顿(标准时-10)',
+		'Pacific/Midway' => '太平洋/中途岛(标准时-11)',
+		'Pacific/Wake' => '太平洋/威克岛(标准时+12)',
+		'America/Adak' => '美国/埃达克(标准时-10)',
+		'America/Anchorage' => '美国/安克雷奇(标准时-9)',
+		'America/Boise' => '美国/博伊西(标准时-7)',
+		'America/Chicago' => '美国/芝加哥(标准时-6)',
+		'America/Denver' => '美国/丹佛(标准时-7)',
+		'America/Detroit' => '美国/底特律(标准时-5)',
+		'America/Indiana/Indianapolis' => '美国/印第安纳州/印第安纳波利斯(标准时-5)',
+		'America/Indiana/Knox' => '美国/印第安纳州/诺克斯(标准时-6)',
+		'America/Indiana/Marengo' => '美国/印第安纳州/马伦戈(标准时-5)',
+		'America/Indiana/Petersburg' => '美国/印第安纳州/圣彼得堡(标准时-5)',
+		'America/Indiana/Tell_City' => '美国/印第安纳州/告诉市(标准时-6)',
+		'America/Indiana/Vevay' => '美国/印第安纳州/印第安纳州/Vevay(标准时-5)',
+		'America/Indiana/Vincennes' => '美国/印第安纳州/文森斯(标准时-5)',
+		'America/Indiana/Winamac' => '美国/印第安纳州/威纳马克(标准时-5)',
+		'America/Juneau' => '美国/朱诺(标准时-9)',
+		'America/Kentucky/Louisville' => '美国/肯塔基州/路易斯维尔(标准时-5)',
+		'America/Kentucky/Monticello' => '美国/肯塔基州/蒙蒂塞洛(标准时-5)',
+		'America/Los_Angeles' => '美国/洛杉矶(标准时-8)',
+		'America/Menominee' => '美国/梅诺米尼(标准时-6)',
+		'America/Metlakatla' => '美国/梅特拉卡特拉(标准时-9)',
+		'America/New_York' => '美国/纽约(标准时-5)',
+		'America/Nome' => '美国/诺姆(标准时-9)',
+		'America/North_Dakota/Beulah' => '美国/北达科他州/Beulah(标准时-6)',
+		'America/North_Dakota/Center' => '美国/北达科他州/中心(标准时-6)',
+		'America/North_Dakota/New_Salem' => '美国/北达科他州/新塞勒姆(标准时-6)',
+		'America/Phoenix' => '美国/凤凰城(标准时-7)',
+		'America/Shiprock' => '美国/新墨西哥州/Shiprock(标准时-7)',
+		'America/Sitka' => '美国/锡特卡(标准时-9)',
+		'America/Yakutat' => '美国/亚库塔特(标准时-9)',
+		'Pacific/Honolulu' => '太平洋/檀香山(标准时-10)',
+		'America/Montevideo' => '美洲/蒙得维的亚(标准时-3)',
+		'Asia/Samarkand' => '亚洲/撒马尔罕(标准时+5)',
+		'Asia/Tashkent' => '亚洲/塔什干(标准时+5)',
+		'Europe/Vatican' => '欧洲/梵蒂冈(标准时+1)',
+		'America/St_Vincent' => '美洲/圣文森特(标准时-4)',
+		'America/Caracas' => '美洲/加拉加斯(标准时-4)',
+		'America/Tortola' => '美洲/英属维尔京群岛(标准时-4)',
+		'America/St_Thomas' => '美洲/圣托马斯(标准时-4)',
+		'Asia/Ho_Chi_Minh' => '亚洲/胡志明(标准时+7)',
+		'Pacific/Efate' => '太平洋/埃法特(标准时+11)',
+		'Pacific/Wallis' => '太平洋/瓦利斯(标准时+12)',
+		'Pacific/Apia' => '太平洋/阿皮亚(标准时+14)',
+		'Asia/Aden' => '亚洲/亚丁(标准时+3)',
+		'Indian/Mayotte' => '印度/马约特岛(标准时+3)',
+		'Africa/Johannesburg' => '非洲/约翰内斯堡(标准时+2)',
+		'Africa/Lusaka' => '非洲/卢萨卡(标准时+2)',
+		'Africa/Harare' => '非洲/哈拉雷(标准时+2)',
+	),
+);
+?>

+ 14 - 0
Application/Admin/Lang/zh-cn/sms.php

@@ -0,0 +1,14 @@
+<?php
+
+/**
+ * 模块语言包-短信设置
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	'sms_sms_nav_name'			=>	'短信设置',
+	'sms_message_nav_name'		=>	'消息模板',
+);
+?>

+ 37 - 0
Application/Admin/Lang/zh-cn/student.php

@@ -0,0 +1,37 @@
+<?php
+
+/**
+ * 模块语言包-学生
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 添加/编辑
+	'student_add_name'					=>	'学生添加',
+	'student_edit_name'					=>	'学生编辑',
+	'student_region_text'				=>	'地区',
+	'student_region_format'				=>	'请选择所在地区',
+	'student_region_tips'				=>	'地区有误',
+	'student_username_text'				=>	'学生真实姓名',
+	'student_username_name'				=>	'学生姓名',
+	'student_username_format'			=>	'姓名格式 2~16 个字符',
+	'student_birthday_text'				=>	'出生日期',
+	'student_birthday_format'			=>	'出生日期格式有误',
+	'student_class_text'				=>	'班级',
+	'student_class_format'				=>	'请选择班级',
+	'student_class_tips'				=>	'班级有误',
+	'student_tuition_state_text'		=>	'缴费状态',
+	'student_tuition_state_format'		=>	'请选择缴费状态',
+	'student_no_exist_error'			=>	'该学生不存在',
+	'student_sign_up_name'				=>	'报名时间',
+	'student_so_keyword_tips'			=>	'姓名/编号/身份证/电话/邮箱',
+	'common_operation_fraction'			=>	'录成绩',
+	'student_time_start_text'			=>	'出生开始',
+	'student_time_end_text'				=>	'出生结束',
+	'student_my_mobile_name'			=>	'学生手机',
+	'student_my_mobile_error'			=>	'学生手机格式有误',
+	'student_excel_import_tips'			=>	'1、学生编号由系统自动生成,已存在以往学期中的学生将使用原来的编号。<br />2、报名时间选填项,留空则使用当前导入时间。<br />3、班级二级归类使用[ - ]字符分割。<br />4、所有数据字段以文本格式上传,如[ 身份证号码|电话|报名时间 ]',
+);
+?>

+ 15 - 0
Application/Admin/Lang/zh-cn/subject.php

@@ -0,0 +1,15 @@
+<?php
+
+/**
+ * 模块语言包-科目
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 添加/编辑
+	'subject_add_name'					=>	'科目添加',
+	'subject_edit_name'				=>	'科目编辑',
+);
+?>

+ 30 - 0
Application/Admin/Lang/zh-cn/teacher.php

@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * 模块语言包-教师
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 添加/编辑
+	'teacher_add_name'					=>	'教师添加',
+	'teacher_edit_name'					=>	'教师编辑',
+	'teacher_region_text'				=>	'地区',
+	'teacher_region_format'				=>	'请选择所在地区',
+	'teacher_region_tips'				=>	'地区有误',
+	'teacher_username_text'				=>	'教师真实姓名',
+	'teacher_username_name'				=>	'教师姓名',
+	'teacher_username_format'			=>	'姓名格式 2~16 个字符',
+	'teacher_birthday_text'				=>	'出生日期',
+	'teacher_birthday_format'			=>	'出生日期格式有误',
+	'teacher_no_exist_error'			=>	'该教师不存在',
+	'teacher_so_keyword_tips'			=>	'姓名/身份证/电话/邮箱/地址',
+	'teacher_operation_course'			=>	'添加课程',
+	'teacher_time_start_text'			=>	'出生开始',
+	'teacher_time_end_text'				=>	'出生结束',
+	'teacher_subject_text'				=>	'贯通科目',
+	'teacher_subject_format'			=>	'请至少选择一项科目',
+);
+?>

+ 19 - 0
Application/Admin/Lang/zh-cn/theme.php

@@ -0,0 +1,19 @@
+<?php
+
+/**
+ * 模块语言包-主题管理
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	'theme_nav_home'			=>	'当前主题',
+	'theme_nav_upload'			=>	'主题安装',
+	'theme_upload_tips'			=>	'上传一个zip压缩格式的主题安装包',
+	'theme_upload_error'		=>	'文件格式有误,请上传zip压缩包',
+	'theme_delete_error'		=>	'不能删除正在使用的主题',
+	'theme_author_text'			=>	'作者:',
+	'theme_ver_text'			=>	'适用版本:',
+);
+?>

+ 28 - 0
Application/Admin/Lang/zh-cn/user.php

@@ -0,0 +1,28 @@
+<?php
+
+/**
+ * 模块语言包-用户
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	'user_add_name'					=>	'用户添加',
+	'user_edit_name'				=>	'用户编辑',
+	'user_so_keyword_tips'			=>	'手机/邮箱/昵称',
+	'user_time_start_text'			=>	'起始时间',
+	'user_time_end_text'			=>	'结束时间',
+	'user_nickname_name'			=>	'昵称',
+	'user_birthday_name'			=>	'生日',
+	'user_signature_name'			=>	'个人签名',
+	'user_describe_name'			=>	'个人描述',
+	'user_nickname_format'			=>	'昵称最多 16 个字符',
+	'user_signature_format'			=>	'个人签名最多 168 个字符',
+	'user_describe_format'			=>	'个人描述最多 255 个字符',
+	'user_birthday_format'			=>	'生日格式有误',
+	'user_accounts_param_error'		=>	'至少填写一项手机或邮箱',
+	'user_login_pwd_name'			=>	'登录密码',
+	'user_login_pwd_format'			=>	'登录密码格式 6~18 个字符之间',
+);
+?>

+ 61 - 0
Application/Admin/Lang/zh-cn/view.php

@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * 模块语言包-页面设置
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	'view_name_text'						=>	'模块名称',
+	'view_name_format'						=>	'格式 0~30 个字符之间',
+	'view_right_title_text'					=>	'右标题',
+	'view_right_title_format'				=>	'格式 0~255 个字符之间',
+	'view_right_title_tips'					=>	'标题与链接使用[ ; ]符号隔开<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;格式如 右标题;http://schoolcms.org/',
+	'view_article_id_text'					=>	'指定主题',
+	'view_article_id_placeholder'			=>	'指定文章id',
+	'view_article_id_format'				=>	'半角逗号隔开(以数字开头结尾)格式如 1,2,3',
+	'view_article_id_tips'					=>	'半角逗号隔开(以数字开头结尾)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;格式如 1,2,3<br />指定主题后,其它条件将失效',
+	'view_keyword_text'						=>	'关键字',
+	'view_keyword_format'					=>	'标题包含的关键字 0~255 个字符之间',
+	'view_keyword_tips'						=>	'并且条件使用[ - ]符号<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;格式如 win-unix<br />或条件使用[ | ]符号<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;格式如 win|unix<br />并且+或使用[ ; ]符号隔开<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;格式如 win-unix;win|unix<br />最大255个字符',
+	'view_show_number_text'					=>	'显示条数',
+	'view_show_number_format'				=>	'显示条数 1~1000 数值之间',
+	'view_abstract_number_text'				=>	'摘要字数',
+	'view_abstract_number_tips'				=>	'摘要文字数,默认80',
+	'view_abstract_number_format'			=>	'字数 5~500 数值之间',
+	'view_class_text'						=>	'文章分类',
+	'view_class_format'						=>	'至少选择一个分类',
+	'view_all_class_text'					=>	'全部分类',
+	'view_sort_text'						=>	'排序方式',
+	'view_add_time_text'					=>	'发布时间',
+	'view_upd_time_text'					=>	'更新时间',
+	'view_title_style_text'					=>	'显示样式',
+	'view_link_open_way_text'				=>	'打开方式',
+	'view_date_format_text'					=>	'日期格式',
+	'view_data_cache_time_text'				=>	'数据缓存',
+	'view_data_cache_time_placeholder'		=>	'数据缓存有效时间',
+	'view_data_cache_time_tips'				=>	'数据缓存时间,单位(分钟)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;默认60分钟,0不缓存数据',
+	'view_summary_text'						=>	'自定义',
+	'view_summary_placeholder'				=>	'自定义内容',
+	'view_summary_tips'						=>	'自定义内容后,以上筛选规则将失效(可以是html代码)',
+	'view_sort_type_format'					=>	'排序方式范围值有误',
+	'view_add_time_interval_format'			=>	'发布时间范围值有误',
+	'view_upd_time_interval_format'			=>	'更新时间范围值有误',
+	'view_title_style_format'				=>	'标题显示样式范围值有误',
+	'view_view_link_open_way_format_format'	=>	'打开方式范围值有误',
+	'view_date_format_format'				=>	'日期格式范围值有误',
+
+	'view_layout_param_save_tips'			=>	'布局参数有误',
+	'view_module_param_save_tips'			=>	'模块参数有误',
+	'view_module_edit_title'				=>	'模块编辑',
+
+	'view_nav_home'							=>	'首页',
+	'view_nav_channel'						=>	'频道',
+	'view_nav_detail'						=>	'详情',
+	'view_layout_module_tips'				=>	'浏览器宽度<br />&nbsp;&nbsp;&nbsp;sm:小于641 px<br />&nbsp;&nbsp;&nbsp;md:小于1025 px<br />&nbsp;&nbsp;&nbsp;lg:大于等于1025 px<br /><br />比例布局<br />&nbsp;&nbsp;&nbsp;宽度分割成12块,3块一个小布局<br /><br />[ x ] 代表当前布局所展示模块的数量,可能是一个数值,也有可能是一个布局形式',
+	'view_no_edit_area'						=>	'基础内容区域,不可编辑',
+	'view_layout_import_tips'				=>	'请上传主题数据txt文件',
+);
+?>

+ 15 - 0
Application/Admin/Lang/zh-cn/week.php

@@ -0,0 +1,15 @@
+<?php
+
+/**
+ * 模块语言包-周
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+return array(
+	// 添加/编辑
+	'week_add_name'					=>	'周添加',
+	'week_edit_name'				=>	'周编辑',
+);
+?>

+ 71 - 0
Application/Admin/Model/AdminModel.class.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace Admin\Model;
+use Think\Model;
+
+/**
+ * 管理员模型
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class AdminModel extends CommonModel
+{
+	// 数据自动校验
+	protected $_validate = array(
+		// 登录
+		array('username', 'CheckUserName', '{%login_username_format}', 1, 'function', 4),
+		array('login_pwd', 'CheckLoginPwd', '{%login_login_pwd_format}', 1, 'function', 4),
+
+		// 添加
+		array('username', '', '{%common_username_already_exist}', 1, 'unique', 1),
+		array('login_pwd', 'CheckLoginPwd', '{%login_login_pwd_format}', 1, 'function', 1),
+
+		// 编辑
+		array('login_pwd', 'CheckLoginPwd', '{%login_login_pwd_format}', 2, 'function', 2),
+		
+		// 添加,编辑
+		array('mobile', 'CheckMobile', '{%common_mobile_format_error}', 2, 'function', 3),
+		array('gender', array(0,1,2), '{%common_gender_tips}', 1, 'in', 3),
+		array('role_id', 'IsExistRole', '{%login_role_id_error}', 1, 'callback', 3),
+
+		// 删除
+		array('id', 'IsExistAdmin', '{%login_username_no_exist}', 1, 'callback', 5),
+	);
+
+	/**
+	 * [IsExistRole 角色id是否存在]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-21T22:13:52+0800
+	 * @return [boolean] [存在true, 不存在false]
+	 */
+	public function IsExistRole()
+	{
+		// 当用户操作自身的情况下不需要校验
+		$admin_id = isset($_SESSION['admin']['id']) ? $_SESSION['admin']['id'] : 0;
+		if(I('id') != $admin_id)
+		{
+			$id = $this->db(0)->table('__ROLE__')->where(array('id'=>I('role_id')))->getField('id');
+			return !empty($id);
+		}
+		return true;
+	}
+
+	/**
+	 * [IsExistAdmin 校验管理员是否存在]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T14:09:40+0800
+	 * @return [boolean] [存在true, 不存在false]
+	 */
+	public function IsExistAdmin()
+	{
+		$user = $this->db(0)->where(array('id'=>I('id')))->getField('id');
+		return !empty($user);
+	}
+}
+?>

+ 51 - 0
Application/Admin/Model/ArticleClassModel.class.php

@@ -0,0 +1,51 @@
+<?php
+
+namespace Admin\Model;
+use Think\Model;
+
+/**
+ * 文章分类模型
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class ArticleClassModel extends CommonModel
+{
+	// 数据自动校验
+	protected $_validate = array(
+		// 添加,编辑
+		array('name', 'CheckName', '{%common_name_format}', 1, 'callback', 3),
+		array('is_enable', array(0,1), '{%common_enable_tips}', 1, 'in', 3),
+		array('sort', 'CheckSort', '{%common_sort_error}', 1, 'function', 3),
+
+		// 删除校验是否存在子级
+		array('id', 'IsExistSon', '{%common_is_exist_son_error}', 1, 'callback', 5),
+	);
+
+	/**
+	 * [CheckName 文章分类名称校验]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-13T19:29:30+0800
+	 */
+	public function CheckName()
+	{
+		$len = Utf8Strlen(I('name'));
+		return ($len >= 2 && $len <= 16);
+	}
+
+	/**
+	 * [IsExistSon 校验节点下是否存在子级数据]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T14:09:40+0800
+	 */
+	public function IsExistSon()
+	{
+		return ($this->db(0)->where(array('pid'=>I('id')))->count() == 0);
+	}
+}
+?>

+ 90 - 0
Application/Admin/Model/ArticleModel.class.php

@@ -0,0 +1,90 @@
+<?php
+
+namespace Admin\Model;
+use Think\Model;
+
+/**
+ * 文章模型
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class ArticleModel extends CommonModel
+{
+	// 数据自动校验
+	protected $_validate = array(		
+		// 添加,编辑
+		array('title', 'CheckTitle', '{%article_title_format}', 1, 'callback', 3),
+		array('article_class_id', 'IsExistArticleClassId', '{%article_article_class_id_error}', 1, 'callback', 3),
+		array('title_color', 'CheckTitleColor', '{%common_color_format}', 2, 'callback', 3),
+		array('jump_url', 'CheckJumpUrl', '{%article_jump_url_format}', 2, 'callback', 3),
+		array('is_enable', array(0,1), '{%common_enable_tips}', 1, 'in', 3),
+		array('content', 'CheckContent', '{%article_content_format_mobile}', 1, 'callback', 3),
+	);
+
+	/**
+	 * [CheckTitle 标题校验]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-13T19:29:30+0800
+	 */
+	public function CheckTitle()
+	{
+		$len = Utf8Strlen(I('title'));
+		return ($len >= 3 && $len <= 60);
+	}
+
+	/**
+	 * [IsExistArticleClassId 文章分类是否存在]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T14:09:40+0800
+	 * @return [boolean] [存在true, 不存在false]
+	 */
+	public function IsExistArticleClassId()
+	{
+		$temp = $this->db(0)->table('__ARTICLE_CLASS__')->field(array('id'))->find(I('article_class_id'));
+		return !empty($temp);
+	}
+
+	/**
+	 * [CheckTitleColor 颜色值校验]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-13T15:12:32+0800
+	 */
+	public function CheckTitleColor()
+	{
+		return (preg_match('/'.L('common_regex_color').'/', I('title_color')) == 1) ? true : false;
+	}
+
+	/**
+	 * [CheckJumpUrl 跳转url地址校验]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-13T15:12:32+0800
+	 */
+	public function CheckJumpUrl()
+	{
+		return (preg_match('/'.L('common_regex_url').'/', I('jump_url')) == 1) ? true : false;
+	}
+
+	/**
+	 * [CheckContent 内容校验]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-13T19:29:30+0800
+	 */
+	public function CheckContent()
+	{
+		$len = Utf8Strlen(I('content'));
+		return ($len >= 50 && $len <= 105000);
+	}
+}
+?>

+ 64 - 0
Application/Admin/Model/ClassModel.class.php

@@ -0,0 +1,64 @@
+<?php
+
+namespace Admin\Model;
+use Think\Model;
+
+/**
+ * 班级模型
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class ClassModel extends CommonModel
+{
+	// 数据自动校验
+	protected $_validate = array(
+		// 添加,编辑
+		array('name', 'CheckName', '{%common_name_format}', 1, 'callback', 3),
+		array('is_enable', array(0,1), '{%common_enable_tips}', 1, 'in', 3),
+		array('sort', 'CheckSort', '{%common_sort_error}', 1, 'function', 3),
+		array('pid', 'CheckMyPid', '{%common_pid_eq_myid_format}', 1, 'callback', 2),
+
+		// 删除校验是否存在子级
+		array('id', 'IsExistSon', '{%common_is_exist_son_error}', 1, 'callback', 5),
+	);
+
+	/**
+	 * [CheckName 班级名称校验]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-13T19:29:30+0800
+	 */
+	public function CheckName()
+	{
+		$len = Utf8Strlen(I('name'));
+		return ($len >= 2 && $len <= 16);
+	}
+
+	/**
+	 * [CheckMyPid pid是否是当前节点校验]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-13T19:32:40+0800
+	 */
+	public function CheckMyPid()
+	{
+		return (I('id') != I('pid'));
+	}
+
+	/**
+	 * [IsExistSon 校验节点下是否存在子级数据]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T14:09:40+0800
+	 */
+	public function IsExistSon()
+	{
+		return ($this->db(0)->where(array('pid'=>I('id')))->count() == 0);
+	}
+}
+?>

+ 17 - 0
Application/Admin/Model/CommonModel.class.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace Admin\Model;
+use Think\Model;
+
+/**
+ * 后台公共模型
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class CommonModel extends Model
+{
+	
+}
+?>

+ 23 - 0
Application/Admin/Model/ConfigModel.class.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace Admin\Model;
+use Think\Model;
+
+/**
+ * 配置模型
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class ConfigModel extends CommonModel
+{
+	// 数据自动校验
+	protected $_validate = array(
+		// 添加,编辑
+		array('mobile', 'CheckMobile', '{%common_mobile_format_error}', 2, 'function', 3),
+		array('gender', array(0,1,2), '{%common_gender_tips}', 1, 'in', 3),
+		array('role_id', 'IsExistRole', '{%login_role_id_error}', 1, 'callback', 3),
+	);
+}
+?>

+ 140 - 0
Application/Admin/Model/CourseModel.class.php

@@ -0,0 +1,140 @@
+<?php
+
+namespace Admin\Model;
+use Think\Model;
+
+/**
+ * 教师课程模型
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class CourseModel extends CommonModel
+{
+	// 数据自动校验
+	protected $_validate = array(
+		// 添加,编辑
+		array('teacher_id', 'IsExistTeacher', '{%course_teacher_tips}', 1, 'callback', 3),
+		array('class_id', 'IsExistClass', '{%course_class_tips}', 1, 'callback', 3),
+		array('subject_id', 'IsExistSubject', '{%course_subject_tips}', 1, 'callback', 3),
+		array('week_id', 'IsExistWeek', '{%course_week_tips}', 1, 'callback', 3),
+		array('interval_id', 'IsExistInterval', '{%course_interval_tips}', 1, 'callback', 3),
+		array('room_id', 'IsExistRoom', '{%course_room_tips}', 1, 'callback', 3),
+	);
+
+	/**
+	 * [IsExistTeacher 教师是否存在]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T14:09:40+0800
+	 * @return [boolean] [存在true, 不存在false]
+	 */
+	public function IsExistTeacher()
+	{
+		$temp = $this->db(0)->table('__TEACHER__')->field(array('id'))->find(I('teacher_id'));
+		return !empty($temp);
+	}
+
+	/**
+	 * [IsExistClass 班级id是否存在]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-21T22:13:52+0800
+	 * @return [boolean] [存在true, 不存在false]
+	 */
+	public function IsExistClass()
+	{
+		// 当用户操作自身的情况下不需要校验
+		$class = $this->db(0)->table('__CLASS__')->field(array('id', 'pid'))->find(I('class_id'));
+		if(empty($class))
+		{
+			return false;
+		}
+
+		if($class['pid'] == 0)
+		{
+			// 是否存在子级
+			$count = $this->db(0)->table('__CLASS__')->where(array('pid'=>$class['id']))->count();
+			return ($count == 0);
+		} else {
+			// 父级是否存在
+			$count = $this->db(0)->table('__CLASS__')->where(array('id'=>$class['pid']))->count();
+			return ($count > 0);
+		}
+	}
+
+	/**
+	 * [IsExistRoom 教室id是否存在]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-21T22:13:52+0800
+	 * @return [boolean] [存在true, 不存在false]
+	 */
+	public function IsExistRoom()
+	{
+		// 当用户操作自身的情况下不需要校验
+		$class = $this->db(0)->table('__ROOM__')->field(array('id', 'pid'))->find(I('room_id'));
+		if(empty($class))
+		{
+			return false;
+		}
+
+		if($class['pid'] == 0)
+		{
+			// 是否存在子级
+			$count = $this->db(0)->table('__ROOM__')->where(array('pid'=>$class['id']))->count();
+			return ($count == 0);
+		} else {
+			// 父级是否存在
+			$count = $this->db(0)->table('__ROOM__')->where(array('id'=>$class['pid']))->count();
+			return ($count > 0);
+		}
+	}
+
+	/**
+	 * [IsExistSubject 教师关联的科目是否存在]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T14:09:40+0800
+	 * @return [boolean] [存在true, 不存在false]
+	 */
+	public function IsExistSubject()
+	{
+		$temp = $this->db(0)->table('__TEACHER_SUBJECT__')->alias('AS ts')->join('__SUBJECT__ AS s ON ts.subject_id = s.id')->where(array('s.id'=>I('subject_id')))->field(array('s.id AS id'))->find();
+		return !empty($temp);
+	}
+
+	/**
+	 * [IsExistWeek 周天是否存在]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T14:09:40+0800
+	 * @return [boolean] [存在true, 不存在false]
+	 */
+	public function IsExistWeek()
+	{
+		$temp = $this->db(0)->table('__WEEK__')->field(array('id'))->find(I('week_id'));
+		return !empty($temp);
+	}
+
+	/**
+	 * [IsExistInterval 时段是否存在]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T14:09:40+0800
+	 * @return [boolean] [存在true, 不存在false]
+	 */
+	public function IsExistInterval()
+	{
+		$temp = $this->db(0)->table('__INTERVAL__')->field(array('id'))->find(I('interval_id'));
+		return !empty($temp);
+	}
+}
+?>

+ 52 - 0
Application/Admin/Model/CustomViewModel.class.php

@@ -0,0 +1,52 @@
+<?php
+
+namespace Admin\Model;
+use Think\Model;
+
+/**
+ * 自定义页面模型
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class CustomViewModel extends CommonModel
+{
+	// 数据自动校验
+	protected $_validate = array(		
+		// 添加,编辑
+		array('title', 'CheckTitle', '{%article_title_format}', 1, 'callback', 3),
+		array('is_enable', array(0,1), '{%common_enable_tips}', 1, 'in', 3),
+		array('is_header', array(0,1), '{%common_is_header_tips}', 1, 'in', 3),
+		array('is_footer', array(0,1), '{%common_is_footer_tips}', 1, 'in', 3),
+		array('is_full_screen', array(0,1), '{%common_is_full_screen_tips}', 1, 'in', 3),
+		array('content', 'CheckContent', '{%article_content_format_mobile}', 1, 'callback', 3),
+	);
+
+	/**
+	 * [CheckTitle 标题校验]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-13T19:29:30+0800
+	 */
+	public function CheckTitle()
+	{
+		$len = Utf8Strlen(I('title'));
+		return ($len >= 3 && $len <= 60);
+	}
+
+	/**
+	 * [CheckContent 内容校验]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-13T19:29:30+0800
+	 */
+	public function CheckContent()
+	{
+		$len = Utf8Strlen(I('content'));
+		return ($len >= 50 && $len <= 105000);
+	}
+}
+?>

+ 102 - 0
Application/Admin/Model/FractionImportModel.class.php

@@ -0,0 +1,102 @@
+<?php
+
+namespace Admin\Model;
+use Think\Model;
+
+/**
+ * 成绩导入模型
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class FractionImportModel extends CommonModel
+{
+	// 表名
+	protected $tableName = 'fraction';
+
+	// 开启批量验证状态
+	protected $patchValidate = true;
+
+	// 数据自动校验
+	protected $_validate = array(		
+		// 添加,编辑
+		array('score', 'CheckScore', '{%fraction_score_format}', 1, 'callback', 3),
+		array('score_id', 'IsExistScoreId', '{%fraction_score_id_error}', 1, 'callback', 3),
+		array('subject_id', 'IsExistSubjectId', '{%fraction_subject_error}', 1, 'callback', 3),
+		array('student_id', 'IsExistStudentId', '{%fraction_student_id_error}', 1, 'callback', 3),
+		array('comment', 'CheckComment', '{%fraction_comment_format}', 1, 'callback', 3),
+	);
+
+	/**
+	 * [CheckComment 教师点评校验]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-13T19:29:30+0800
+	 * @param    [string] $value [校验值]
+	 */
+	public function CheckComment($value)
+	{
+		return (Utf8Strlen($value) <= 255);
+	}
+
+	/**
+	 * [CheckScore 分数校验]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-13T19:29:30+0800
+	 * @param    [string] $value [校验值]
+	 */
+	public function CheckScore($value)
+	{
+		return (preg_match('/'.L('common_regex_score').'/', $value) == 1) ? true : false;
+	}
+
+	/**
+	 * [IsExistScoreId 成绩分类id是否存在]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T14:09:40+0800
+	 * @param    [string] $value [校验值]
+	 * @return   [boolean]       [存在true, 不存在false]
+	 */
+	public function IsExistScoreId($value)
+	{
+		$id = $this->db(0)->table('__SCORE__')->where(array('id'=>$value))->getField('id');
+		return !empty($id);
+	}
+
+	/**
+	 * [IsExistSubjectId 科目分类id是否存在]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T14:09:40+0800
+	 * @param    [string] $value [校验值]
+	 * @return   [boolean]       [存在true, 不存在false]
+	 */
+	public function IsExistSubjectId($value)
+	{
+		$id = $this->db(0)->table('__SUBJECT__')->where(array('id'=>$value))->getField('id');
+		return !empty($id);
+	}
+
+	/**
+	 * [IsExistStudentId 学生id是否存在]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T14:09:40+0800
+	 * @param    [string] $value [校验值]
+	 * @return   [boolean]       [存在true, 不存在false]
+	 */
+	public function IsExistStudentId($value)
+	{
+		$id = $this->db(0)->table('__STUDENT__')->where(array('id'=>$value))->getField('id');
+		return !empty($id);
+	}
+}
+?>

+ 91 - 0
Application/Admin/Model/FractionModel.class.php

@@ -0,0 +1,91 @@
+<?php
+
+namespace Admin\Model;
+use Think\Model;
+
+/**
+ * 成绩模型
+ * @author   Devil
+ * @blog     http://gong.gg/
+ * @version  0.0.1
+ * @datetime 2016-12-01T21:51:08+0800
+ */
+class FractionModel extends CommonModel
+{
+	// 数据自动校验
+	protected $_validate = array(		
+		// 添加,编辑
+		array('score', 'CheckScore', '{%fraction_score_format}', 1, 'callback', 3),
+		array('score_id', 'IsExistScoreId', '{%fraction_score_id_error}', 1, 'callback', 3),
+		array('subject_id', 'IsExistSubjectId', '{%fraction_subject_error}', 1, 'callback', 3),
+		array('student_id', 'IsExistStudentId', '{%fraction_student_id_error}', 1, 'callback', 3),
+		array('comment', 'CheckComment', '{%fraction_comment_format}', 1, 'callback', 3),
+	);
+
+	/**
+	 * [CheckComment 教师点评校验]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-13T19:29:30+0800
+	 */
+	public function CheckComment()
+	{
+		return (Utf8Strlen(I('comment')) <= 255);
+	}
+
+	/**
+	 * [CheckScore 分数校验]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-13T19:29:30+0800
+	 */
+	public function CheckScore()
+	{
+		return (preg_match('/'.L('common_regex_score').'/', I('score')) == 1) ? true : false;
+	}
+
+	/**
+	 * [IsExistScoreId 成绩分类id是否存在]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T14:09:40+0800
+	 * @return [boolean] [存在true, 不存在false]
+	 */
+	public function IsExistScoreId()
+	{
+		$id = $this->db(0)->table('__SCORE__')->where(array('id'=>I('score_id')))->getField('id');
+		return !empty($id);
+	}
+
+	/**
+	 * [IsExistSubjectId 科目分类id是否存在]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T14:09:40+0800
+	 * @return [boolean] [存在true, 不存在false]
+	 */
+	public function IsExistSubjectId()
+	{
+		$id = $this->db(0)->table('__SUBJECT__')->where(array('id'=>I('subject_id')))->getField('id');
+		return !empty($id);
+	}
+
+	/**
+	 * [IsExistStudentId 学生id是否存在]
+	 * @author   Devil
+	 * @blog     http://gong.gg/
+	 * @version  0.0.1
+	 * @datetime 2016-12-10T14:09:40+0800
+	 * @return [boolean] [存在true, 不存在false]
+	 */
+	public function IsExistStudentId()
+	{
+		$id = $this->db(0)->table('__STUDENT__')->where(array('id'=>I('student_id')))->getField('id');
+		return !empty($id);
+	}
+}
+?>

+ 0 - 0
Application/Admin/Model/IntervalModel.class.php


Some files were not shown because too many files changed in this diff