<?php
|
//af_Loader::import('/core/BaseController');
|
/**
|
* 后台通用控制器 加了rbac
|
* Class AdminCommonController
|
*/
|
class System_Controller_Web extends System_Controller_Base{
|
|
public $layout = APP_ROOT.'/modules/Admin/views/layout/adminLayout.phtml';
|
public $defaultMsgTemplate = 'common/showmsg.phtml';
|
public $config = array();
|
/**
|
* @var boolean 是否开启用户验证 authenticate
|
*/
|
public $doAuth = true;
|
/**
|
* @var bool 是否检查权限
|
*/
|
public $checkAuthorization = true;
|
|
/**
|
* @var string 当前请求的权限节点
|
*/
|
public $currentRequest = '';
|
|
public function init(){
|
parent::init();
|
// $currentRequest = '/' . strtolower( implode('/', [
|
/// $this->_request->module,
|
// $this->_request->controller,
|
// $this->_request->action,
|
// ]) );
|
// $this->getView()->currentRequest = $currentRequest;
|
// if($this->checkAuthorization && $this->userInfo){
|
// $rbacManage = \Core\ServiceLocator::getInstance()->get('rbacManage');
|
// if( ! $rbacManage->isAdmin( $this->userInfo['name'] ) ) {
|
// $authInfo = $rbacManage->checkAuthorization($this->userInfo['id'], $currentRequest);
|
// if ($authInfo == false) {
|
// throw new \Exception('没有节点访问权限');
|
// }
|
// }
|
//}
|
}
|
|
public function setLayout($layout = ''){
|
$this->layout = $layout;
|
}
|
|
/**
|
* 返回正确提示
|
* @param string $content [description]
|
* @param boolean $is_json [description]
|
* @return [type] [description]
|
*/
|
public function showSuccess($content = '', $is_json = false){
|
return $this->showMessage($content, 200, $is_json);
|
}
|
|
/**
|
* 返回错误信息
|
* @param string $content [description]
|
* @param integer $code [description]
|
* @param boolean $is_json [description]
|
* @return [type] [description]
|
*/
|
public function showError($content = '', $code = 400, $is_json = false){
|
return $this->showMessage($content, $code, $is_json);
|
}
|
|
/**
|
* 返回信息
|
* @param string $content [description]
|
* @param integer $code [description]
|
* @param boolean $is_json [description]
|
* @return [type] [description]
|
*/
|
public function showMessage($content = '', $code = 200, $is_json = false){
|
$return_msg = array('code' => $code, 'content' => $content);
|
if($is_json){
|
$return_msg = json_encode($return_msg);
|
}
|
return $return_msg;
|
}
|
|
/**
|
* 发送数据
|
* @param array $arr [description]
|
* @param boolean $is_json [description]
|
* @return [type] [description]
|
*/
|
public function send($arr = array(), $is_json = true){
|
$return_data = $arr;
|
if($is_json){
|
$return_data = json_encode($arr);
|
}
|
return $return_data;
|
}
|
|
/**
|
* 向DataTable发送数据
|
* @param [type] $data [description]
|
* @return [type] [description]
|
*/
|
public function sendToDataTable($data){
|
return json_encode($data, JSON_UNESCAPED_UNICODE);
|
}
|
|
}
|