<?php

$page = 15;
$share = function()
{
	$array = array();
	$info = Dever::db('poster/template')->state();
	if($info)
	{
		$array += $info;
	}
	return $array;
};

return array
(
	# 表名
	'name' => 'live',
	# 显示给用户看的名称
	'lang' => '直播视频管理',
	'order' => 99,
	# 数据结构
	'struct' => array
	(
		'id' 		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> 'ID',
			'default' 	=> '',
			'desc' 		=> '',
			'match' 	=> 'is_numeric',
		),
		
		'name'		=> array
		(
			'type' 		=> 'varchar-80',
			'name' 		=> '标题',
			'default' 	=> '',
			'desc' 		=> '标题',
			'match' 	=> 'is_string',
			'update'	=> 'text',
			'list'		=> true,
		),

  		'pic_cover'		=> array
		(
			'type' 		=> 'varchar-150',
			'name' 		=> '封面图-4:3比例的图片',
			'default' 	=> '',
			'desc' 		=> '封面图',
			'match' 	=> 'option',
			'update'	=> 'image',
			'key' 		=> '1',
			'place'		=> '150',
		),

		'link'		=> array
		(
			'type' 		=> 'varchar-800',
			'name' 		=> '直播推流地址',
			'default' 	=> '',
			'desc' 		=> '直播推流地址',
			'match' 	=> 'is_string',
			'update'	=> 'text',
			'list'		=> true,
		),

		'num_add_user'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '手动增加在线人数',
			'default' 	=> '0',
			'desc' 		=> '手动增加在线人数',
			'match' 	=> 'option',
			'update'	=> 'text',
		),

		'num_user'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '在线人数',
			'default' 	=> '0',
			'desc' 		=> '在线人数',
			'match' 	=> 'option',
			'search'	=> 'order',
		),

		'num_add_view'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '手动增加浏览量pv数',
			'default' 	=> '0',
			'desc' 		=> '请填写手动增加浏览量pv',
			'match' 	=> 'option',
			'update'	=> 'text',
		),

		'num_view'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '浏览量pv',
			'default' 	=> '0',
			'desc' 		=> '请填写浏览量pv',
			'match' 	=> 'option',
			'search'	=> 'order',
			//'list'		=> '{num_view}+{num_add_view}',
		),
		
		'num_up'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '喜欢数',
			'default' 	=> '0',
			'desc' 		=> '请填写喜欢数',
			'match' 	=> 'option',
			//'search'	=> 'order',
			'list'		=> '"在线人数:{num_user}+{num_add_user}<br />喜欢数:{num_up}<br />浏览量:{num_view}+{num_add_view}<br />评论数:{num_comment}<br />"',
			'list_name'	=> '统计数字',
		),

		'num_comment'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '评论数',
			'default' 	=> '0',
			'desc' 		=> '请填写评论数',
			'search'	=> 'order',
			'match' 	=> 'option',
			//'list'		=> true,
		),

		'content'		=> array
		(
			'type' 		=> 'text-255',
			'name' 		=> '内容介绍',
			'default' 	=> '',
			'desc' 		=> '请输入内容',
			'match' 	=> 'is_string',
			'update'	=> 'editor',
			'key' 		=> 1,
			'media'		=> 5,
		),

		'state'		=> array
		(
			'type' 		=> 'tinyint-1',
			'name' 		=> '状态',
			'default' 	=> '1',
			'desc' 		=> '请选择状态',
			'match' 	=> 'is_numeric',
		),

		'admin_founder'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '创建人',
			'default' 	=> '1',
			'desc' 		=> '创建人',
			'match' 	=> 'is_numeric',
		),

		'admin_editor'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '操作人',
			'default' 	=> '1',
			'desc' 		=> '操作人',
			'match' 	=> 'is_numeric',
		),

		'sdate'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '开始时间',
			'match' 	=> 'is_numeric',
			'desc' 		=> '',
			'update'	=> 'date',
			'callback'	=> 'maketime',
			'list'		=> 'date("Y-m-d H:i:s", {sdate})',
		),

		'pdate'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '发布时间',
			'match' 	=> 'is_numeric',
			'desc' 		=> '',
			'update'	=> 'date',
			'callback'	=> 'maketime',
			'list'		=> 'date("Y-m-d H:i:s", {pdate})',
		),

		'share'		=> array
		(
			'type' 		=> 'text-255',
			'name' 		=> '分享海报-选择海报库中的海报',
			'default' 	=> '',
			'desc' 		=> '分享海报',
			'match' 	=> 'option',
			'update'	=> 'checkbox',
			'option'	=> $share,
		),

		'udate'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '更新时间',
			'match' 	=> array('is_numeric', time()),
			'desc' 		=> '',
		),

		'cdate'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '录入时间',
			'match' 	=> array('is_numeric', time()),
			'desc' 		=> '',
			# 只有insert时才生效
			'insert'	=> true,
		),
	),

	# 索引
	'index' => array
	(
		'version' => 1,
		
		1 => array
		(
			'i1' => 'uid,cate_id',
		)
	),
	
	# 管理功能
	'manage' => array
	(
		//'insert' => false,
		# 列表
		/*
		'list_button' => array
		(
			'list' => array('评论列表', '"comment&search_option_data_id={id}&oper_parent=article"'),
		),
		*/
	),

	# request 请求接口定义
	'request' => array
	(
		'getAll' => array
		(
			# 匹配的正则或函数 选填项
			'option' => array
			(
				'cate_id' => 'yes',
				'cate_ids' => array('yes-cate_id', 'in'),
				'id' => 'yes',
			),
			'type' => 'all',
			'order' => array('id' => 'desc'),
			'page' => array($page, 'list'),
			'col' => '*',
		),

		# 获取默认主题,按照置顶和时间排序的
		'default' => array
		(
			# 匹配的正则或函数 选填项
			'option' => array
			(
				'cate_id' => 'yes',
				'uid' => 'yes',
			),
			'type' => 'all',
			'order' => array('id' => 'desc'),
			'page' => array($page, 'list'),
			'col' => '*',
		),

		# 获取最新主题
		'new' => array
		(
			# 匹配的正则或函数 选填项
			'option' => array
			(
				'name' => array('yes', 'like'),
				'cate_id' => 'yes',
				'uid' => 'yes',
			),
			'type' => 'all',
			'order' => array('id', 'desc'),
			'page' => array($page, 'list'),
			'col' => '*',
		),
		
		# 获取热门主题
		'hot' => array
		(
			# 匹配的正则或函数 选填项
			'option' => array
			(
				'cate_id' => 'yes',
				'uid' => 'yes',
			),
			'type' => 'all',
			'order' => array('num_view`+`num_add_view' => 'desc', 'id' => 'desc'),
			'page' => array($page, 'list'),
			'col' => '*',
		),

		# 获取冷门主题
		'cold' => array
		(
			# 匹配的正则或函数 选填项
			'option' => array
			(
				'cate_id' => 'yes',
				'uid' => 'yes',
			),
			'type' => 'all',
			'order' => array('num_view`+`num_add_view' => 'asc', 'id' => 'desc'),
			'page' => array($page, 'list'),
			'col' => '*',
		),


		
		# 更新浏览量
		'addView' => array
		(
			'type' => 'update',
			'where' => array
			(
				'id' => 'yes',
			),
			'set' => array
			(
				'num_view' => array('1', '+='),
			),
		),
		
		# 更新回复数
		'addComment' => array
		(
			'type' => 'update',
			'where' => array
			(
				'id' => 'yes',
			),
			'set' => array
			(
				'num_comment' => array('1', '+='),
			),
		),
		
		# 更新点赞数
		'addUp' => array
		(
			'type' => 'update',
			'where' => array
			(
				'id' => 'yes',
			),
			'set' => array
			(
				'num_up' => array('1', '+='),
			),
		),
		
		# 更新点赞数
		'desUp' => array
		(
			'type' => 'update',
			'where' => array
			(
				'id' => 'yes',
			),
			'set' => array
			(
				'num_up' => array('1', '-='),
			),
		),
	),
);