1、更新内核

2、代码格式化
This commit is contained in:
2016-07-21 14:29:32 +08:00
parent 3cc2c38dc7
commit a72ba86faa
20 changed files with 1214 additions and 1083 deletions

View File

@@ -24,19 +24,19 @@
* )
*
*/
function int_to_string(&$data,$map=array('status'=>array(1=>'正常',-1=>'删除',0=>'禁用',2=>'未审核',3=>'草稿'))) {
if($data === false || $data === null ){
return $data;
}
$data = (array)$data;
foreach ($data as $key => $row){
foreach ($map as $col=>$pair){
if(isset($row[$col]) && isset($pair[$row[$col]])){
$data[$key][$col.'_text'] = $pair[$row[$col]];
}
}
}
return $data;
function intToString(&$data, $map = array('status' => array(1 => '正常', -1 => '删除', 0 => '禁用', 2 => '未审核', 3 => '草稿'))) {
if ($data === false || $data === null) {
return $data;
}
$data = (array) $data;
foreach ($data as $key => $row) {
foreach ($map as $col => $pair) {
if (isset($row[$col]) && isset($pair[$row[$col]])) {
$data[$key][$col . '_text'] = $pair[$row[$col]];
}
}
}
return $data;
}
/**
@@ -45,27 +45,36 @@ function int_to_string(&$data,$map=array('status'=>array(1=>'正常',-1=>'删除
* @return string 状态文字 false 未获取到
* @author huajie <banhuajie@163.com>
*/
function get_status_title($status = null){
if(!isset($status)){
return false;
}
switch ($status){
case -1 : return '已删除'; break;
case 0 : return '禁用'; break;
case 1 : return '正常'; break;
case 2 : return '待审核'; break;
default : return false; break;
}
function getStatusTitle($status = null) {
if (!isset($status)) {
return false;
}
switch ($status) {
case -1:return '已删除';
break;
case 0:return '禁用';
break;
case 1:return '正常';
break;
case 2:return '待审核';
break;
default:return false;
break;
}
}
// 获取数据的状态操作
function show_status_op($status) {
switch ($status){
case 0 : return '启用'; break;
case 1 : return '禁用'; break;
case 2 : return '审核'; break;
default : return false; break;
}
function showStatusOp($status) {
switch ($status) {
case 0:return '启用';
break;
case 1:return '禁用';
break;
case 2:return '审核';
break;
default:return false;
break;
}
}
/**
@@ -74,15 +83,15 @@ function show_status_op($status) {
* @param bool $all 是否返回全部类型
* @author huajie <banhuajie@163.com>
*/
function get_action_type($type, $all = false){
$list = array(
1=>'系统',
2=>'用户',
);
if($all){
return $list;
}
return $list[$type];
function getActionType($type, $all = false) {
$list = array(
1 => '系统',
2 => '用户',
);
if ($all) {
return $list;
}
return $list[$type];
}
/**
@@ -91,16 +100,16 @@ function get_action_type($type, $all = false){
* @param string $field 需要获取的字段
* @author huajie <banhuajie@163.com>
*/
function get_action($id = null, $field = null){
if(empty($id) && !is_numeric($id)){
return false;
}
$list = cache('action_list');
if(empty($list[$id])){
$map = array('status'=>array('gt', -1), 'id'=>$id);
$list[$id] = db('Action')->where($map)->field(true)->find();
}
return empty($field) ? $list[$id] : $list[$id][$field];
function getAction($id = null, $field = null) {
if (empty($id) && !is_numeric($id)) {
return false;
}
$list = cache('action_list');
if (empty($list[$id])) {
$map = array('status' => array('gt', -1), 'id' => $id);
$list[$id] = db('Action')->where($map)->field(true)->find();
}
return empty($field) ? $list[$id] : $list[$id][$field];
}
/**
@@ -110,18 +119,18 @@ function get_action($id = null, $field = null){
* @param string $field 需要返回的字段,不传则返回整个数据
* @author huajie <banhuajie@163.com>
*/
function get_document_field($value = null, $condition = 'id', $field = null){
if(empty($value)){
return false;
}
function getDocumentField($value = null, $condition = 'id', $field = null) {
if (empty($value)) {
return false;
}
//拼接参数
$map[$condition] = $value;
$info = db('Model')->where($map);
if(empty($field)){
$info = $info->field(true)->find();
}else{
$info = $info->value($field);
}
return $info;
//拼接参数
$map[$condition] = $value;
$info = db('Model')->where($map);
if (empty($field)) {
$info = $info->field(true)->find();
} else {
$info = $info->value($field);
}
return $info;
}