|
一直在ci论坛拿东西,今天送给大家一个代码补全插件,希望大家可以喜欢。这个插件是在某先人的CI_Autocomplete_2.0基础上开发的,思路就是重写CI_Autocomplete_2.0文件,再让netbeans读取。
不多说 代码呈上:
index.php
PHP复制代码
<?php
$filearr = file('CI_Autocomplete_2.0.php');
$startpos = array();
$conpos = 0;
$modpos=0;
getpos ($startpos, $conpos, $modpos, $filearr);
$model = '';
$lib = '';
$resultnames = array();
//getdirfilesname('../application/models');
$filesmodel = ListFiles ('../application/models');
$fileslib = ListFiles ('../application/libraries');
$tets=filenamechange ($filesmodel);
$resultnames = array_merge(filenamechange ($filesmodel), filenamechange ($fileslib));//过滤到index并且得到字符串
//$insertarr=array();
//var_dump($resultnames);
array_splice($filearr, $startpos[0] + 1, $conpos - $startpos[0] - 3, $resultnames);
getpos ($startpos, $conpos, $modpos, $filearr);
$porarr=array_slice($filearr, 3, $conpos-5);
array_splice($filearr, $conpos+3, $modpos - $conpos - 5, $porarr);
$resultstr = "";
for ($i = 0; $i < count($filearr); $i++) {
$temstr = $filearr[$i];
// var_dump($filearr[$i]);
$resultstr.=$temstr;
}
///$resultstr=implode(" ", $filearr);
//var_dump($resultstr);
//写入文件
//file_put_contents ( string filename, string data [, int flags [, resource context]])
if (file_exists('CI_Autocomplete_2.0.php')) {
unlink('CI_Autocomplete_2.0.php');
}
file_put_contents('CI_Autocomplete_2.0.php', $resultstr);
echo '<html><head>';
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><title></title>';
echo '</head><body>';
echo '<p align="center">转换完成!</p></body></html>';
//var_dump($files);
//scandir//();
//var_dump($startpos.' '.$endpos);
//$start=array_search('* @property CI_Zip $zip\n', $filearr);
//array_splice(array,offset,length,array);
//var_dump($start);
//var_dump($filearr);
//var_dump($filearr);
function getdirfilesname ($dir) {
$namearr = scandir($dir);
$namearr = array_diff($namearr, array('..', '.'));
var_dump($namearr);
}
function ListFiles ($dir) {
if ($dh = opendir($dir)) {
$files = Array();
$inner_files = Array();
while ($file = readdir($dh)) {
if ($file != "." && $file != ".." && $file[0] != '.') {
if (is_dir($dir . "/" . $file)) {
$inner_files = ListFiles ($dir . "/" . $file);
if (is_array($inner_files))
$files = array_merge($files, $inner_files);
} else {
// array_push($files, $dir . "/" . $file);
array_push($files, $file);
}
}
}
closedir($dh);
return $files;
}
}
function filenamechange ($filesname, $ucfirst=0) {
$count=count($filesname);
for ($i = 0; $i <$count ; $i++) {
//$startpos=strrpos($filearr[$i],$startstr)===FALSE?continue:
if (strrpos($filesname[$i], 'ndex.html'))
unset($filesname[$i]);
if (isset($filesname[$i])) {
$filesname[$i] = str_ireplace('.php', '', $filesname[$i]);
// $resultnames[$i]['name']=ucfirst($filesname[$i]);
// $resultnames[$i]['value']='$'.$filesname[$i];
if ($ucfirst) {
$resultnames[] = "* @property " . ucfirst($filesname[$i]) . " $" . ucfirst($filesname[$i]) . "\r\n";
}else
$resultnames[] = "* @property " . ucfirst($filesname[$i]) . " $" . strtolower($filesname[$i]) . "\r\n"; //* @property Kslevel $kslevel
// $filesname[$i]=strtr($filesname[$i],'php',' ' );
}
}
return $resultnames;
}
function getpos (&$startpos,&$conpos,&$modpos,$filearr) {
$startstr = '* @property CI_Zip $zip';
$constr = 'class CI_Controller {};';
$modstr='class CI_Model {};';
for ($i = 0; $i < count($filearr); $i++) {//找到位置
//$startpos=strrpos($filearr[$i],$startstr)===FALSE?continue:
if (strrpos($filearr[$i], $startstr) !== FALSE)
$startpos[] = $i;
if (strrpos($filearr[$i], $constr) !== FALSE)
$conpos = $i;
if (strrpos($filearr[$i], $modstr) !== FALSE)
$modpos = $i;
}
//echo 'OK';
}
?>
复制代码
CI_Autocomplete_2.0.php
PHP复制代码
<?php
/**
* @property CI_DB_active_record $db
* @property CI_DB_forge $dbforge
* @property CI_Benchmark $benchmark
* @property CI_Calendar $calendar
* @property CI_Cart $cart
* @property CI_Config $config
* @property CI_Controller $controller
* @property CI_Email $email
* @property CI_Encrypt $encrypt
* @property CI_Exceptions $exceptions
* @property CI_Form_validation $form_validation
* @property CI_Ftp $ftp
* @property CI_Hooks $hooks
* @property CI_Image_lib $image_lib
* @property CI_Input $input
* @property CI_Language $language
* @property CI_Loader $load
* @property CI_Log $log
* @property CI_Model $model
* @property CI_Output $output
* @property CI_Pagination $pagination
* @property CI_Parser $parser
* @property CI_Profiler $profiler
* @property CI_Router $router
* @property CI_Session $session
* @property CI_Sha1 $sha1
* @property CI_Table $table
* @property CI_Trackback $trackback
* @property CI_Typography $typography
* @property CI_Unit_test $unit_test
* @property CI_Upload $upload
* @property CI_URI $uri
* @property CI_User_agent $user_agent
* @property CI_Validation $validation
* @property CI_Xmlrpc $xmlrpc
* @property CI_Xmlrpcs $xmlrpcs
* @property CI_Zip $zip
* @property User_group_m $user_group_m
* @property M_role $m_role
* @property M_1 $m_1
* @property M_kaojuan $m_kaojuan
* @property Ml_shijuan $ml_shijuan
* @property M_makekj $m_makekj
* @property M_kaoshi $m_kaoshi
* @property M_shitimanage $m_shitimanage
* @property Ml_class $ml_class
* @property Ion_auth_model $ion_auth_model
* @property Exam_shiti_duoxuan_data_m $exam_shiti_duoxuan_data_m
* @property Exam_kaojuan_base_m $exam_kaojuan_base_m
* @property Exam_tixing_m $exam_tixing_m
* @property Exam_shititype_m $exam_shititype_m
* @property Exam_shiti_main_m $exam_shiti_main_m
* @property Exam_tiku_m $exam_tiku_m
* @property Exam_class_m $exam_class_m
* @property X_m_1_1 $x_m_1_1
* @property X_m_1_2 $x_m_1_2
* @property Exam_shiti_danxuan_data_m $exam_shiti_danxuan_data_m
* @property Exam_shijuan_base_m $exam_shijuan_base_m
* @property Ion_group_ext_m $ion_group_ext_m
* @property User_department_m $user_department_m
* @property Exam_shijuantype_m $exam_shijuantype_m
* @property Ion_group_m $ion_group_m
* @property Exam_kaojuan_data_m $exam_kaojuan_data_m
* @property Layout $layout
* @property Ion_auth $ion_auth
* @property Level_1_1 $level_1_1
* @property Level $level
* @property Kslevel $kslevel
* @property Msgexpection $msgexpection
*/
class CI_Controller {};
/**
* @property CI_DB_active_record $db
* @property CI_DB_forge $dbforge
* @property CI_Benchmark $benchmark
* @property CI_Calendar $calendar
* @property CI_Cart $cart
* @property CI_Config $config
* @property CI_Controller $controller
* @property CI_Email $email
* @property CI_Encrypt $encrypt
* @property CI_Exceptions $exceptions
* @property CI_Form_validation $form_validation
* @property CI_Ftp $ftp
* @property CI_Hooks $hooks
* @property CI_Image_lib $image_lib
* @property CI_Input $input
* @property CI_Language $language
* @property CI_Loader $load
* @property CI_Log $log
* @property CI_Model $model
* @property CI_Output $output
* @property CI_Pagination $pagination
* @property CI_Parser $parser
* @property CI_Profiler $profiler
* @property CI_Router $router
* @property CI_Session $session
* @property CI_Sha1 $sha1
* @property CI_Table $table
* @property CI_Trackback $trackback
* @property CI_Typography $typography
* @property CI_Unit_test $unit_test
* @property CI_Upload $upload
* @property CI_URI $uri
* @property CI_User_agent $user_agent
* @property CI_Validation $validation
* @property CI_Xmlrpc $xmlrpc
* @property CI_Xmlrpcs $xmlrpcs
* @property CI_Zip $zip
* @property User_group_m $user_group_m
* @property M_role $m_role
* @property M_1 $m_1
* @property M_kaojuan $m_kaojuan
* @property Ml_shijuan $ml_shijuan
* @property M_makekj $m_makekj
* @property M_kaoshi $m_kaoshi
* @property M_shitimanage $m_shitimanage
* @property Ml_class $ml_class
* @property Ion_auth_model $ion_auth_model
* @property Exam_shiti_duoxuan_data_m $exam_shiti_duoxuan_data_m
* @property Exam_kaojuan_base_m $exam_kaojuan_base_m
* @property Exam_tixing_m $exam_tixing_m
* @property Exam_shititype_m $exam_shititype_m
* @property Exam_shiti_main_m $exam_shiti_main_m
* @property Exam_tiku_m $exam_tiku_m
* @property Exam_class_m $exam_class_m
* @property X_m_1_1 $x_m_1_1
* @property X_m_1_2 $x_m_1_2
* @property Exam_shiti_danxuan_data_m $exam_shiti_danxuan_data_m
* @property Exam_shijuan_base_m $exam_shijuan_base_m
* @property Ion_group_ext_m $ion_group_ext_m
* @property User_department_m $user_department_m
* @property Exam_shijuantype_m $exam_shijuantype_m
* @property Ion_group_m $ion_group_m
* @property Exam_kaojuan_data_m $exam_kaojuan_data_m
* @property Layout $layout
* @property Ion_auth $ion_auth
* @property Level_1_1 $level_1_1
* @property Level $level
* @property Kslevel $kslevel
* @property Msgexpection $msgexpection
*/
class CI_Model {};
?>
复制代码
按我的格式和文件名把这两个文件放到项目文件根目录的nbproject文件夹下面,
运行index.php如:http://localhost/CI_IONTH/nbproject/index.php
重启netbeans。试试写$this->看后面出现什么!
项目目录:
自动补全代码:
|
|