<?php
/*
|--------------------------------------------------------------------------
| config.php 后台配置信息
|--------------------------------------------------------------------------
*/
# 定义几个常用的选项
$option = array
(
	1 => '启用',
	2 => '失效',
);

# 定义图片选择器的内容 key为id,value为显示的样式
$template = array
(
	1 => '<span class="color theme-1"></span>',
	2 => '<span class="color theme-2"></span>',
	3 => '<span class="color theme-3"></span>',
	4 => '<span class="color theme-4"></span>',
	5 => '<span class="color theme-5"></span>',
	6 => '<span class="color theme-6"></span>',
	7 => '<span class="color theme-7"></span>',
	8 => '<span class="color theme-8"></span>',
);

$selector = 'selector';
/*
if(Dever::$global['base'] != 'default')
{
	$selector = 'hidden';
}
*/

return array
(
	# 表名
	'name' => 'config',
	# 显示给用户看的名称
	'lang' => '后台个性化',
	'order' => 10,
	# 数据结构
	'struct' => array
	(
		'id' 		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '配置ID',
			'default' 	=> '',
			'desc' 		=> '',
			'match' 	=> 'is_numeric',
			'search'	=> 'order',
			'list'		=> true,
		),
		
		'name'		=> array
		(
			'type' 		=> 'varchar-32',
			'name' 		=> '配置名',
			'default' 	=> '',
			'desc' 		=> '请输入配置名',
			'match' 	=> 'is_string',
			'update'	=> 'text',
			'search'	=> 'fulltext',
			'list'		=> true,
			'edit'		=> true,
		),

		# 测试关联其他表字段 项目-表-字段 这里仅仅是测试
		/*
		'manage-admin-username'		=> array
		(
			# 必填,两个表之间的关联字段,第一个为当前表的,第二个为关联表的
			'sync'		=> array('id', 'config'),
			'default' 	=> '',
			'name' 		=> '管理员',
			'desc' 		=> '管理员',
			'match' 	=> 'option',
			'update'	=> 'text',
			'search'	=> 'fulltext',
			'list'		=> true,
		),
		*/
		
		'template'		=> array
		(
			'type' 		=> 'int-1',
			'name' 		=> '后台模板',
			'default' 	=> '1',
			'desc' 		=> '请选择后台模板',
			'match' 	=> 'is_numeric',
			'option' 	=> $template,
			//'update'	=> $selector,//图片选择器 注意跟select/radio不同哦
		),
		
		'title'		=> array
		(
			'type' 		=> 'varchar-32',
			'name' 		=> '后台title',
			'default' 	=> '',
			'desc' 		=> '请输入后台title',
			'match' 	=> 'option',
			'update'	=> 'text',
			'search'	=> 'fulltext',
			'list'		=> true,
		),
		
		'info'		=> array
		(
			'type' 		=> 'varchar-40',
			'name' 		=> '控制台欢迎标题',
			'default' 	=> '',
			'desc' 		=> '请输入控制台欢迎标题',
			'match' 	=> 'option',
			'update'	=> 'text',
		),
		
		'content'		=> array
		(
			'type' 		=> 'text-255',
			'name' 		=> '控制台欢迎内容',
			'default' 	=> '',
			'desc' 		=> '请输入控制台欢迎内容',
			'match' 	=> 'option',
			'update'	=> 'editor',
			//'strip'		=> false,//默认是开启strip_tags过滤的,这里可以加上这个来取消过滤
		),
		'state'		=> array
		(
			'type' 		=> 'tinyint-1',
			'name' 		=> '状态',
			'default' 	=> '1',
			'desc' 		=> '请选择状态',
			'match' 	=> 'is_numeric',
			//'option' 	=> $option,
			//'update'	=> 'radio',
			//'list'		=> true,
		),
		
		'cdate'		=> array
		(
			'type' 		=> 'int-11',
			'name' 		=> '录入时间',
			'match' 	=> array('is_numeric', time()),
			'desc' 		=> '',
			# 只有insert时才生效
			'insert'	=> true,
			'list'		=> 'date("Y-m-d H:i:s", {cdate})',
		),
	),
	
	# 更新表结构
	/*
	'alter' => array
	(
		1 => array
		(
			array('add', 'info', 'info', 'varchar-40  控制台欢迎标题'),
			array('add', 'content', 'content', 'text-255  控制台欢迎内容'),
		),
		
		2 => array
		(
			array('add', 'template', 'template', 'int-1 1 模板'),
		),
		'version' => 2,
	),
	*/

	# 默认值
	'default' => array
	(
		'col' => 'name,state,cdate',
		'value' => array
		(
			'"默认配置",1,' . time(),
		),
	),

	# request 请求接口定义
	'request' => array
	(
		# all 取所有数据
		'all' => array
		(
			# 匹配的正则或函数 选填项
			'option' => array
			(
				'name' => 'yes',
			),
			'type' => 'all',
			'order' => array('id', 'desc'),
			'col' => '*|id',
		),
		
		# 取一条正常的数据
		'info' => array
		(
			# 匹配的正则或函数 选填项
			'where' => array
			(
				'id' => 'yes',
				'state' => 1,
			),
			'type' => 'one',
		),
	),
);