forked from tkaplar/nb-codeigniter-autocomplete
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cigen.php
287 lines (245 loc) · 12.3 KB
/
cigen.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<html>
<head>
<?php
function prep_path($path) {
return str_replace("\\", "/", $path);
}
function preVar($param, $exit = false) {
echo '<pre>';
var_dump($param);
echo '</pre>';
if ($exit)
exit;
}
function directory_map($source_dir, $directory_depth = 0, $hidden = FALSE) {
if ($fp = @opendir($source_dir)) {
$filedata = array();
$new_depth = $directory_depth - 1;
$source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
while (FALSE !== ($file = readdir($fp))) {
if (!trim($file, '.') OR ( $hidden == FALSE && $file[0] == '.')) {
continue;
}
if (($directory_depth < 1 OR $new_depth > 0) && @is_dir($source_dir . $file)) {
$filedata[$file] = directory_map($source_dir . $file . DIRECTORY_SEPARATOR, $new_depth, $hidden);
} else {
$filedata[] = $file;
}
}
closedir($fp);
return $filedata;
}
return FALSE;
}
function addClassForText($dirArray, $outText, $skipThisFiles) {
foreach ($dirArray as $key => $value) {
if (is_array($value)) {
$outText = addClassForText($value, $outText, $skipThisFiles);
} else {
if (!in_array($value, $skipThisFiles)) {
$value = str_replace('.php', '', $value);
$outText.="* @property " . ucfirst($value) . ' $' . strtolower($value) . "\n";
}
}
}
return $outText;
}
function addClassForArray($dirArray, $outArray, $skipThisFiles) {
foreach ($dirArray as $key => $value) {
if (is_array($value)) {
$outArray = addClassForText($value, $outArray, $skipThisFiles);
} else {
if (!in_array($value, $skipThisFiles)) {
$value = str_replace('.php', '', $value);
$outArray[] = ucfirst($value);
}
}
}
return $outArray;
}
$absPath = prep_path(getcwd());
$currentDir = NULL;
$currentDirA = explode("/", $absPath);
$currentDir = @end($currentDirA);
?>
<title><?php echo ($currentDir != NULL) ? $currentDir . ' - ' : ''; echo (isset($_GET['autorefresh']) && intval($_GET['autorefresh']) > 0) ? 'R:'.$_GET['autorefresh'].' -' : ''; ?> CodeIgniter - AUTO-TEMPLATE</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="NetBeans CodeIgniter autocompleter"/>
<meta name="keywords" content="netbeans ci autocompleter" />
<meta name="author" content="Tomas Kaplar"/>
<?php if (isset($_GET['autorefresh']) && intval($_GET['autorefresh']) > 0) { ?>
<meta http-equiv="refresh" content="<?php echo intval($_GET['autorefresh']); ?>">
<?php }
?>
<style type="text/css">
body {
font-family: "Courier New", Courier, monospace;
font-size: 15px;
color: #666;
line-height: 23px;
}
</style>
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB90LBhIUMCcaW3sAAAdOSURBVFhHtZZ7jJTlFcZ/553Z3dmb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7m1KLRvcMZDW+jMcV81umz+zNTZljI1OrLTPPrJUTx4//vdMXgCiTU2oatm7u/Yc2/6j+zX9yDDb+Ksl+qHqTZm8CpxSjVyaN+XjYPKIYPPM2+0ra9dq/dmzK6D7/6Y/Ay4kALFLbZQNuZFPPrmwfN/u3b+84cONeeVlpanSpc/NqRw79sBgHgCdWnbHscrJ22pTtrzl7rkytbp65+zq6sfFmNNX81wXLRcvPv7nmgN/OllXu+1aurr6c29tfmfHrsNHjqzWnhN7+eWXr2XhXzsZ0/FEmRAIAAAAAElFTkSuQmCC"/>
</head>
<?php
$default_auto_refresh = 30;
$this_file_name = pathinfo(__FILE__, PATHINFO_BASENAME);
$index_file_name = 'index.php';
$index_file = FALSE;
$applicationPath = FALSE;
$skipThisFiles = array('index.html');
if (file_exists($index_file_name)) {
$index_file = file_get_contents($index_file_name);
} else {
die('File ' . $index_file_name . ' not exist. Please put this file (' . $this_file_name . ') into codeigniter project root!');
}
// get application path from index.php
if ($index_file !== FALSE) {
//$application_folder = 'application';
$pos1 = strpos($index_file, '$application_folder') + strlen('$application_folder');
$pos2 = strpos($index_file, ";", $pos1);
$applicationPath = trim(str_replace("\"", "'", substr($index_file, $pos1, $pos2 - $pos1)), "'= \t\n\r\0\x0B");
$absPath .= prep_path(DIRECTORY_SEPARATOR);
$absApplicationPath = prep_path($absPath . $applicationPath . DIRECTORY_SEPARATOR);
echo 'Project path: ' . $currentDir . '<br>';
echo 'Project abs path: ' . $absPath . '<br>';
echo 'Application path: ' . $applicationPath . '<br>';
echo 'Application abs path: ' . $absApplicationPath . '<br>';
$ci_path = prep_path('system' . DIRECTORY_SEPARATOR . 'core');
echo 'CodeIgniter core path: ' . $ci_path . '<br>';
echo str_repeat("-", 100) . '<br>';
echo '<br>';
$dir_model = directory_map($absApplicationPath . 'models');
$dir_lib = directory_map($absApplicationPath . 'libraries');
$dir_core = directory_map($absApplicationPath . 'core');
// preVar($dir_model);
// preVar($dir_lib);
// preVar($dir_core);
$outputFirst = "";
$output = "<?php \n//Last update " . date('d.m.Y, H:i', time()) . "\n\n";
$output .= "/** \n";
$outputFirst .= '
* @property CI_DB_active_record $db
* @property CI_DB_forge $dbforge
* @property CI_Benchmark $benchmark
* @property CI_Cache $cache
* @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_Image_lib $image_lib
* @property CI_Input $input
* @property CI_Lang $lang
* @property CI_Loader $load
* @property CI_Log $log
* @property CI_Migration $migration
* @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_Security $security
* @property CI_Sha1 $sha1
* @property CI_Utf8 $utf8
* @property CI_Table $table
* @property CI_Trackback $trackbackv
* @property CI_Typography $typography
* @property CI_Unit_test $unit_test
* @property CI_Upload $upload
* @property CI_URI $uri
* @property CI_DB_utility $dbutil
* @property CI_User_agent $user_agent
* @property CI_Validation $validation
* @property CI_Xmlrpc $xmlrpc
* @property CI_Xmlrpcs $xmlrpcs
* @property CI_Zip $zip';
$arrayCoreClass = addClassForArray($dir_core, array(), $skipThisFiles);
foreach ($arrayCoreClass as $value) {
$value2 = str_replace('MY_', 'CI_', $value);
$outputFirst = str_replace($value2, $value, $outputFirst);
}
$output.=$outputFirst;
$output.="\n" . addClassForText($dir_model, '', $skipThisFiles);
$output.=str_replace('my_', '', addClassForText($dir_lib, '', $skipThisFiles));
$output.="*/" . "\n";
$output.="class CI_Controller {
/**
* @access public
* @return CI_Controller
*
*/
function get_instance() {}
};";
$output.="\n\n\n";
$output .='class CI_DB_Driver {
/**
* Execute the query
*
* Accepts an SQL string as input and returns a result object upon
* successful execution of a "read" type query. Returns boolean TRUE
* upon successful execution of a "write" type query. Returns boolean
* FALSE upon failure, and if the $db_debug variable is set to TRUE
* will raise an error.
*
* @access public
* @param string An SQL query string
* @param array An array of binding data
* @return CI_DB_mysql_result
*/
function query() {}
/**
* Execute the query
*
* Accepts an SQL string as input and returns a result object upon
* successful execution of a "read" type query. Returns boolean TRUE
* upon successful execution of a "write" type query. Returns boolean
* FALSE upon failure, and if the $db_debug variable is set to TRUE
* will raise an error.
*
* @access public
* @param string An SQL query string
* @param array An array of binding data
* @return CI_DB_mysql_result
*/
function get() {}
};
';
$output .= "/** \n\n";
$output.= substr(addClassForText($dir_model, '', $skipThisFiles), 0, -2);
$output.='
* @property CI_DB_active_record $db
* @property CI_DB_forge $dbforge
* @property CI_Config $config
* @property CI_Loader $load
* @property CI_Session $session';
$output.="\n*/" . "\n\n";
$output.="class CI_Model {}; \n";
$output.='/**
* @return CI_Controller
*/
function get_instance() {}';
$res = file_put_contents($absPath . 'CI_AUTOCOMPLETE.php', $output);
if ($res) {
echo "Operation succeed... <br>This is your Auto Complete File: <b>" . $absPath . "CI_AUTOCOMPLETE.php</b>";
} else {
echo 'Operation Error';
}
echo '<br><br>' . str_repeat("-", 100) . '<br>';
?>
<form action="<?php echo $this_file_name; ?>" method="get">
<input type="number" name="autorefresh" value="<?php echo (isset($_GET['autorefresh']) && intval($_GET['autorefresh']) > 0) ? intval($_GET['autorefresh']) : $default_auto_refresh ?>" style="width: 50px;"/> s
<input type="submit" value="set Auto Refresh"/>
</form>
<?php
} else {
die('Cannot get application path from ' . $index_file_name . '.');
}
?>
</html>