插件的一些调整
This commit is contained in:
@@ -12,7 +12,12 @@ use app\common\controller\Addons;
|
|||||||
|
|
||||||
class Admin extends Addons{
|
class Admin extends Addons{
|
||||||
|
|
||||||
|
public function lists(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function setting(){
|
public function setting(){
|
||||||
|
$this->setMeta('第三方登录设置');
|
||||||
$this->template('admin/login');
|
$this->template('admin/login');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ class Test extends Addons {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function headertest(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function install(){
|
public function install(){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ class Content extends Admin {
|
|||||||
if (IS_POST) {
|
if (IS_POST) {
|
||||||
$result = $this->model->save($this->param);
|
$result = $this->model->save($this->param);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
|
//记录行为
|
||||||
|
action_log('add_content', 'content', $result, session('auth_user.uid'));
|
||||||
return $this->success("添加成功!", url('admin/content/index', array('model_id' => $this->modelInfo['id'])));
|
return $this->success("添加成功!", url('admin/content/index', array('model_id' => $this->modelInfo['id'])));
|
||||||
} else {
|
} else {
|
||||||
return $this->error($this->model->getError(), url('admin/content/add', array('model_id' => $this->modelInfo['id'])));
|
return $this->error($this->model->getError(), url('admin/content/add', array('model_id' => $this->modelInfo['id'])));
|
||||||
@@ -100,6 +102,8 @@ class Content extends Admin {
|
|||||||
if (IS_POST) {
|
if (IS_POST) {
|
||||||
$result = $this->model->save($this->param, array('id'=> $id));
|
$result = $this->model->save($this->param, array('id'=> $id));
|
||||||
if ($result !== false) {
|
if ($result !== false) {
|
||||||
|
//记录行为
|
||||||
|
action_log('update_content', 'content', $result, session('auth_user.uid'));
|
||||||
return $this->success("更新成功!", url('admin/content/index', array('model_id' => $this->modelInfo['id'])));
|
return $this->success("更新成功!", url('admin/content/index', array('model_id' => $this->modelInfo['id'])));
|
||||||
} else {
|
} else {
|
||||||
return $this->error($this->model->getError(), url('admin/content/edit', array('model_id' => $this->modelInfo['id'], 'id' => $id)));
|
return $this->error($this->model->getError(), url('admin/content/edit', array('model_id' => $this->modelInfo['id'], 'id' => $id)));
|
||||||
@@ -142,6 +146,8 @@ class Content extends Admin {
|
|||||||
$result = $this->model->where($map)->delete();
|
$result = $this->model->where($map)->delete();
|
||||||
|
|
||||||
if (false !== $result) {
|
if (false !== $result) {
|
||||||
|
//记录行为
|
||||||
|
action_log('delete_content', 'content', $result, session('auth_user.uid'));
|
||||||
return $this->success("删除成功!");
|
return $this->success("删除成功!");
|
||||||
} else {
|
} else {
|
||||||
return $this->error("删除失败!");
|
return $this->error("删除失败!");
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class InitHook {
|
|||||||
foreach ($list as $key => $value) {
|
foreach ($list as $key => $value) {
|
||||||
$route[$value['rule']] = $value['url'];
|
$route[$value['rule']] = $value['url'];
|
||||||
}
|
}
|
||||||
$list = db('Model')->field("name,id")->select();
|
$list = db('Model')->column('id,name');
|
||||||
foreach ($list as $key => $value) {
|
foreach ($list as $key => $value) {
|
||||||
$route["admin/" . $value['name'] . "/index"] = "admin/content/index?model_id=" . $value['id'];
|
$route["admin/" . $value['name'] . "/index"] = "admin/content/index?model_id=" . $value['id'];
|
||||||
$route["admin/" . $value['name'] . "/add"] = "admin/content/add?model_id=" . $value['id'];
|
$route["admin/" . $value['name'] . "/add"] = "admin/content/add?model_id=" . $value['id'];
|
||||||
@@ -67,6 +67,7 @@ class InitHook {
|
|||||||
$route["user/" . $value['name'] . "/del"] = "user/content/del?model_id=" . $value['id'];
|
$route["user/" . $value['name'] . "/del"] = "user/content/del?model_id=" . $value['id'];
|
||||||
$route["user/" . $value['name'] . "/status"] = "user/content/status?model_id=" . $value['id'];
|
$route["user/" . $value['name'] . "/status"] = "user/content/status?model_id=" . $value['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$route["list/:id"] = "index/content/category";
|
$route["list/:id"] = "index/content/category";
|
||||||
\think\Route::rule($route);
|
\think\Route::rule($route);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,8 +218,4 @@ class Admin extends Base {
|
|||||||
$this->assign('extend_menu', array('管理插件' => $menu));
|
$this->assign('extend_menu', array('管理插件' => $menu));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setMeta($title = '') {
|
|
||||||
$this->assign('meta_title', $title);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,6 +137,17 @@ class Base extends \think\Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title 后台设置title
|
||||||
|
* @description 设置后台页面的title
|
||||||
|
* @Author molong
|
||||||
|
* @DateTime 2017-06-21
|
||||||
|
* @param string $title 标题名称
|
||||||
|
*/
|
||||||
|
protected function setMeta($title = '') {
|
||||||
|
$this->assign('meta_title', $title);
|
||||||
|
}
|
||||||
|
|
||||||
//request信息
|
//request信息
|
||||||
protected function requestInfo() {
|
protected function requestInfo() {
|
||||||
$this->param = $this->request->param();
|
$this->param = $this->request->param();
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace app\common\model;
|
|||||||
* Class AuthGroupModel
|
* Class AuthGroupModel
|
||||||
* @author molong <molong@tensent.cn>
|
* @author molong <molong@tensent.cn>
|
||||||
*/
|
*/
|
||||||
class Addons extends \app\common\model\Base {
|
class Addons extends Base {
|
||||||
|
|
||||||
protected $auto = array('status', 'isinstall', 'update_time');
|
protected $auto = array('status', 'isinstall', 'update_time');
|
||||||
protected $insert = array('create_time');
|
protected $insert = array('create_time');
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class Hooks extends Base {
|
|||||||
$this->error = "未实现{$addons_name}插件的入口文件";
|
$this->error = "未实现{$addons_name}插件的入口文件";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$methods = array_diff(get_class_methods($addons_class), get_class_methods('\app\common\controller\Addons'));
|
$methods = $this->getMethods($addons_class);
|
||||||
$methods = array_diff($methods, array('install', 'uninstall'));
|
$methods = array_diff($methods, array('install', 'uninstall'));
|
||||||
foreach ($methods as $item) {
|
foreach ($methods as $item) {
|
||||||
$info = $this->where('name', $item)->find();
|
$info = $this->where('name', $item)->find();
|
||||||
@@ -121,4 +121,42 @@ class Hooks extends Base {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getMethods($classname, $access = null) {
|
||||||
|
$class = new \ReflectionClass($classname);
|
||||||
|
$methods = $class->getMethods();
|
||||||
|
$returnArr = array();
|
||||||
|
foreach ($methods as $value) {
|
||||||
|
if ("\\" . $value->class == $classname) {
|
||||||
|
if ($access != null) {
|
||||||
|
$methodAccess = new \ReflectionMethod($classname, $value->name);
|
||||||
|
switch ($access) {
|
||||||
|
case 'public':
|
||||||
|
if ($methodAccess->isPublic()) {
|
||||||
|
array_push($returnArr, $value->name);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'protected':
|
||||||
|
if ($methodAccess->isProtected()) {
|
||||||
|
array_push($returnArr, $value->name);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'private':
|
||||||
|
if ($methodAccess->isPrivate()) {
|
||||||
|
array_push($returnArr, $value->name);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'final':
|
||||||
|
if ($methodAccess->isFinal()) {
|
||||||
|
array_push($returnArr, $value->name);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
array_push($returnArr, $value->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $returnArr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ return array(
|
|||||||
'admin/logout' => 'admin/index/logout',
|
'admin/logout' => 'admin/index/logout',
|
||||||
|
|
||||||
// 变量传入index模块的控制器和操作方法
|
// 变量传入index模块的控制器和操作方法
|
||||||
'addons/:mc/:ac' => 'index/addons/execute', // 静态地址和动态地址结合
|
'plugs/:mc/:ac' => 'index/addons/execute', // 静态地址和动态地址结合
|
||||||
'usera/:mc/:ac' => 'user/addons/execute', // 静态地址和动态地址结合
|
'user/plugs/:mc/:ac' => 'user/addons/execute', // 静态地址和动态地址结合
|
||||||
'admina/:mc/:ac' => 'admin/addons/execute', // 静态地址和动态地址结合
|
'admin/plugs/:mc/:ac' => 'admin/addons/execute', // 静态地址和动态地址结合
|
||||||
);
|
);
|
||||||
Reference in New Issue
Block a user