插件的一些调整
This commit is contained in:
@@ -51,7 +51,7 @@ class InitHook {
|
||||
foreach ($list as $key => $value) {
|
||||
$route[$value['rule']] = $value['url'];
|
||||
}
|
||||
$list = db('Model')->field("name,id")->select();
|
||||
$list = db('Model')->column('id,name');
|
||||
foreach ($list as $key => $value) {
|
||||
$route["admin/" . $value['name'] . "/index"] = "admin/content/index?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'] . "/status"] = "user/content/status?model_id=" . $value['id'];
|
||||
}
|
||||
|
||||
$route["list/:id"] = "index/content/category";
|
||||
\think\Route::rule($route);
|
||||
}
|
||||
|
||||
@@ -218,8 +218,4 @@ class Admin extends Base {
|
||||
$this->assign('extend_menu', array('管理插件' => $menu));
|
||||
}
|
||||
}
|
||||
|
||||
protected function setMeta($title = '') {
|
||||
$this->assign('meta_title', $title);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class Base extends \think\Controller {
|
||||
$mc = ucfirst(parse_name($mc, 1));
|
||||
$op = parse_name($op, 1);
|
||||
}
|
||||
|
||||
|
||||
if (!empty($mc) && !empty($op) && !empty($ac)) {
|
||||
$ops = ucwords($op);
|
||||
$class = "\\addons\\{$mc}\\controller\\{$ops}";
|
||||
@@ -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信息
|
||||
protected function requestInfo() {
|
||||
$this->param = $this->request->param();
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace app\common\model;
|
||||
* Class AuthGroupModel
|
||||
* @author molong <molong@tensent.cn>
|
||||
*/
|
||||
class Addons extends \app\common\model\Base {
|
||||
class Addons extends Base {
|
||||
|
||||
protected $auto = array('status', 'isinstall', 'update_time');
|
||||
protected $insert = array('create_time');
|
||||
|
||||
@@ -72,7 +72,7 @@ class Hooks extends Base {
|
||||
$this->error = "未实现{$addons_name}插件的入口文件";
|
||||
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'));
|
||||
foreach ($methods as $item) {
|
||||
$info = $this->where('name', $item)->find();
|
||||
@@ -121,4 +121,42 @@ class Hooks extends Base {
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user