码迷,mamicode.com
首页 > Web开发 > 详细

使得CI在NetBeans 8.0中自动提示CI相关类和方法

时间:2014-08-12 17:46:35      阅读:290      评论:0      收藏:0      [点我收藏+]

标签:http   os   io   文件   for   ar   art   cti   

把这两个文件放到项目文件根目录的nbproject文件夹下面,运行index.php如:http://localhost/你的CI目录/nbproject/index.php,之后重启netbeans。试试写$this->看后面出现什么!哈哈哈

 

index.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(array(filenamechange($filesmodel)), array(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
/**
* @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 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 Msgexpection $msgexpection
*/
class CI_Model {};
?>
 

 

使得CI在NetBeans 8.0中自动提示CI相关类和方法,布布扣,bubuko.com

使得CI在NetBeans 8.0中自动提示CI相关类和方法

标签:http   os   io   文件   for   ar   art   cti   

原文地址:http://my.oschina.net/alkz/blog/300358

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!