首页 >后端开发 >php教程 >IcePHP框架中的快速后台中的通用CRUD功能框架(三) 具体业务示例

IcePHP框架中的快速后台中的通用CRUD功能框架(三) 具体业务示例

黄舟
黄舟原创
2016-12-27 09:51:531335浏览

//用于测试CRUD
public function crudTest() {
// @todo:整个功能权限检查

// 创建一个CRUD主表对象
$crud = new SCrud ( 'twh_adminstractor', $this->controller, $this->action );

// 对字段进行配置
$crud->field ( 'sort' )->isAbandon = true;

$crud->field ( 'id' )->title = "编号";

$adm_pwd = $crud->field ( 'adm_pwd' );
$adm_pwd->isPassword = true;
$adm_pwd->encode ( function ($v) {
return md5 ( $v );
} );

$count = $crud->field ( 'count' );
$count->inInsert = false;
$count->inUpdate = false;

$endip = $crud->field ( 'endip' );
$endip->inInsert = false;
$endip->inUpdate = false;

$status = $crud->field ( 'status' );
$status->enum = array (
'0' => '禁用',
'1' => '启用' 
);
$status->title = "状态";
$status->updateType = 'radio';

$createtime = $crud->field ( 'createtime' );
$createtime->isCreated = true;
$createtime->searchType = 'DateRange';
$createtime->decode ( function ($v) {
return date ( 'Y-m-d H:i:s', intval ( $v ) );
} );

$endtime = $crud->field ( 'endtime' );
$endtime->isUpdated = true;
$endtime->searchType = 'DateRange';
$endtime->decode ( function ($v) {
return date ( 'Y-m-d H:i:s', intval ( $v ) );
} );

// 启用被禁止的用户
$enable = $crud->operationRow ( 'Enable' );
$enable->title = "启用";
$enable->filter = function ($row) {
return $row ['status'] == 0 and $row ['id'] != 1;
};
$enable->do = array($this,'doEnable');

// 禁用已经启用的用户
$disable = $crud->operationRow ( 'Disable' );
$disable->title = "禁用";
$disable->filter = function ($row) {
return $row ['status'] == 1 and $row ['id'] != 1;
};
$disable->do=array($this,'doDisable');

// 权限设置
$auth = $crud->operationRow ( 'setAuth' );
$auth->title = "权限管理";
$auth->filter = function ($row) {
return $row ['status'] == 1 and $row ['id'] != 1;
};
$auth->do=array($this,'doSetAuth');


$tOperation=$crud->operationTable('TOperation');
$tOperation->title="表级操作";
$tOperation->do=array($this,'tOperation');

$mOperation=$crud->operationMulti('MOperation');
$mOperation->title="多选操作";
$mOperation->confirm=false;
$mOperation->do=array($this,'mOperation');

$crud->process ( $this->request );
}

public function mOperation(){
echo '测试通用多选操作';
dump($this->request->ids);
return array('msg'=>'执行了一个通用多选操作'); 
}

public function tOperation(){
echo '测试通用表级操作';
return array('msg'=>'执行了一个通用表级操作','go'=>'list');
}

public function doEnable(){
echo '启用一个用户';
return array('msg'=>'启用了一个用户','go'=>'list');
}

public function doDisable(){
echo '禁用一个用户';
return array('msg'=>'禁用了一个用户','go'=>'list');
}

public function doSetAuth(){
echo '设置权限 ';
return array('msg'=>'设置权限,将要跳到另一个地址','go'=>LUrl::ice().'/?c=maintain&a=setAuth');

}



以上代码并不能独立运行,需要整个框架的支持,但开发人员可从中摘取相应的功能

 以上就是IcePHP框架中的快速后台中的通用CRUD功能框架(三) 具体业务示例的内容,更多相关内容请关注PHP中文网(www.php.cn)!

 以上就是IcePHP框架中的快速后台中的通用CRUD功能框架(三) 具体业务示例的内容,更多相关内容请关注PHP中文网(www.php.cn)!


声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn