系统开发好以后,你知道系统里有多少个Module不?知道有多少个Action不?
你的RBAC是不是需要用这些数据?你的菜单是不是需要用这些数据?
亲,厌倦了手动录入吗?你找我算是对人了。
代码来源:开源ThinkPHP代码生成器
应用主页:http://rockefys.github.io/commlib//生成模块结构信息 app/分组/模块/方法<br>
public function fetch_module(){<br>
$M = M('Module');<br>
$M->query("truncate table module");<br>
$app = $this->getAppName();<br>
$groups = $this->getGroup();<br>
$n=0;<br>
foreach ($groups as $group) {<br>
$modules = $this->getModule($group);<br>
foreach ($modules as $module) {<br>
$module_name=$app.'://'.$group.'/'.$module;<br>
$functions = $this->getFunction($module_name);<br>
foreach ($functions as $function) {<br>
$data[$n]['app'] = $app;<br>
$data[$n]['group'] = $group;<br>
$data[$n]['module'] = $module;<br>
$data[$n]['function'] = $function;<br>
++$n; }<br>
}<br>
}<br>
$M->addAll($data);<br>
$this->success('所有分组/模块/方法已成功读取到module表中.');<br>
}<br>
protected function getAppName(){<br>
return APP_NAME;<br>
}<br>
<br>
protected function getGroup(){<br>
$result = explode(',',C('APP_GROUP_LIST'));<br>
return $result;<br>
}<br>
<br>
protected function getModule($group){<br>
if(empty($group))return null;<br>
$group_path=LIB_PATH.'Action/'.$group;<br>
if(!is_dir($group_path))return null;<br>
$group_path.='/*.class.php';<br>
$ary_files = glob($group_path);<br>
foreach ($ary_files as $file) {<br>
if (is_dir($file)) {<br>
continue;<br>
}else {<br>
$files[] = basename($file,'Action.class.php');<br>
}<br>
}<br>
return $files;<br>
<br>
}<br>
<br>
protected function getFunction($module){<br>
if(empty($module))return null;<br>
$action=A($module);<br>
$functions=get_class_methods($action);<br>
$inherents_functions = array(<br>
'_initialize','__construct','getActionName','isAjax','display','show','fetch',<br>
'buildHtml','assign','__set','get','__get','__isset',<br>
'__call','error','success','ajaxReturn','redirect','__destruct'<br>
);<br>
<br>
foreach ($functions as $func){<br>
if(!in_array($func, $inherents_functions)){<br>
$customer_functions[]=$func;<br>
}<br>
}<br>
return $customer_functions;<br>
}
module表结构CREATE TABLE `module` (<br>
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,<br>
`name` varchar(45) DEFAULT NULL COMMENT '名称',<br>
`app` varchar(45) DEFAULT NULL COMMENT '项目',<br>
`group` varchar(45) DEFAULT NULL COMMENT '分组',<br>
`module` varchar(45) DEFAULT NULL COMMENT '模块',<br>
`function` varchar(45) DEFAULT NULL COMMENT '方法',<br>
`status` varchar(45) DEFAULT NULL COMMENT '状态',<br>
PRIMARY KEY (`id`)<br>
) ENGINE=InnoDB DEFAULT CHARSET=utf8$$
思路讲解:很简单,
1、根据配置文件获取分组
2、遍历分组下的Action文件夹中的*Action.class.php
3、实例化Action,获取其所有方法,过滤掉tp本身的底层函数,
4、小手一挥,数据到手.
getFunction代码讲解:$action=A($module);<br>
$functions=get_class_methods($action);//获取该类的所有方法<br>
$inherents_functions = array(...);//tp自带的底层函数
AD:真正免费,域名+虚机+企业邮箱=0元

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

MinGW - Windows용 미니멀리스트 GNU
이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.

mPDF
mPDF는 UTF-8로 인코딩된 HTML에서 PDF 파일을 생성할 수 있는 PHP 라이브러리입니다. 원저자인 Ian Back은 자신의 웹 사이트에서 "즉시" PDF 파일을 출력하고 다양한 언어를 처리하기 위해 mPDF를 작성했습니다. HTML2FPDF와 같은 원본 스크립트보다 유니코드 글꼴을 사용할 때 속도가 느리고 더 큰 파일을 생성하지만 CSS 스타일 등을 지원하고 많은 개선 사항이 있습니다. RTL(아랍어, 히브리어), CJK(중국어, 일본어, 한국어)를 포함한 거의 모든 언어를 지원합니다. 중첩된 블록 수준 요소(예: P, DIV)를 지원합니다.

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)
