Conditions | 73 |
Paths | 7752 |
Total Lines | 305 |
Code Lines | 241 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
169 | public function doFind($confirm = true, $msg = '') |
||
170 | { |
||
171 | $lang = $this->lang; |
||
172 | $data = $this->misc->getDatabaseAccessor(); |
||
173 | |||
174 | if (!isset($_REQUEST['term'])) { |
||
175 | $_REQUEST['term'] = ''; |
||
176 | } |
||
177 | |||
178 | if (!isset($_REQUEST['filter'])) { |
||
179 | $_REQUEST['filter'] = ''; |
||
180 | } |
||
181 | |||
182 | $this->printTrail('database'); |
||
183 | $this->printTabs('database', 'find'); |
||
184 | $this->printMsg($msg); |
||
185 | |||
186 | echo '<form action="' . \SUBFOLDER . "/src/views/database.php\" method=\"post\">\n"; |
||
187 | echo '<p><input name="term" value="', htmlspecialchars($_REQUEST['term']), |
||
188 | "\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" />\n"; |
||
189 | // Output list of filters. This is complex due to all the 'has' and 'conf' feature possibilities |
||
190 | echo "<select name=\"filter\">\n"; |
||
191 | echo "\t<option value=\"\"", ('' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$lang['strallobjects']}</option>\n"; |
||
192 | echo "\t<option value=\"SCHEMA\"", ('SCHEMA' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$lang['strschemas']}</option>\n"; |
||
193 | echo "\t<option value=\"TABLE\"", ('TABLE' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$lang['strtables']}</option>\n"; |
||
194 | echo "\t<option value=\"VIEW\"", ('VIEW' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$lang['strviews']}</option>\n"; |
||
195 | echo "\t<option value=\"SEQUENCE\"", ('SEQUENCE' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$lang['strsequences']}</option>\n"; |
||
196 | echo "\t<option value=\"COLUMN\"", ('COLUMN' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$lang['strcolumns']}</option>\n"; |
||
197 | echo "\t<option value=\"RULE\"", ('RULE' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$lang['strrules']}</option>\n"; |
||
198 | echo "\t<option value=\"INDEX\"", ('INDEX' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$lang['strindexes']}</option>\n"; |
||
199 | echo "\t<option value=\"TRIGGER\"", ('TRIGGER' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$lang['strtriggers']}</option>\n"; |
||
200 | echo "\t<option value=\"CONSTRAINT\"", ('CONSTRAINT' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$lang['strconstraints']}</option>\n"; |
||
201 | echo "\t<option value=\"FUNCTION\"", ('FUNCTION' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$lang['strfunctions']}</option>\n"; |
||
202 | echo "\t<option value=\"DOMAIN\"", ('DOMAIN' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$lang['strdomains']}</option>\n"; |
||
203 | if ($conf['show_advanced']) { |
||
204 | echo "\t<option value=\"AGGREGATE\"", ('AGGREGATE' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$lang['straggregates']}</option>\n"; |
||
205 | echo "\t<option value=\"TYPE\"", ('TYPE' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$lang['strtypes']}</option>\n"; |
||
206 | echo "\t<option value=\"OPERATOR\"", ('OPERATOR' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$lang['stroperators']}</option>\n"; |
||
207 | echo "\t<option value=\"OPCLASS\"", ('OPCLASS' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$lang['stropclasses']}</option>\n"; |
||
208 | echo "\t<option value=\"CONVERSION\"", ('CONVERSION' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$lang['strconversions']}</option>\n"; |
||
209 | echo "\t<option value=\"LANGUAGE\"", ('LANGUAGE' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$lang['strlanguages']}</option>\n"; |
||
210 | } |
||
211 | echo "</select>\n"; |
||
212 | echo "<input type=\"submit\" value=\"{$lang['strfind']}\" />\n"; |
||
213 | echo $this->misc->form; |
||
214 | echo "<input type=\"hidden\" name=\"action\" value=\"find\" /></p>\n"; |
||
215 | echo "</form>\n"; |
||
216 | |||
217 | // Default focus |
||
218 | $this->setFocus('forms[0].term'); |
||
219 | |||
220 | // If a search term has been specified, then perform the search |
||
221 | // and display the results, grouped by object type |
||
222 | if ('' != $_REQUEST['term']) { |
||
223 | $rs = $data->findObject($_REQUEST['term'], $_REQUEST['filter']); |
||
224 | if ($rs->recordCount() > 0) { |
||
225 | $curr = ''; |
||
226 | while (!$rs->EOF) { |
||
227 | // Output a new header if the current type has changed, but not if it's just changed the rule type |
||
228 | if ($rs->fields['type'] != $curr) { |
||
229 | // Short-circuit in the case of changing from table rules to view rules; table cols to view cols; |
||
230 | // table constraints to domain constraints |
||
231 | if ('RULEVIEW' == $rs->fields['type'] && 'RULETABLE' == $curr) { |
||
232 | $curr = $rs->fields['type']; |
||
233 | } elseif ('COLUMNVIEW' == $rs->fields['type'] && 'COLUMNTABLE' == $curr) { |
||
234 | $curr = $rs->fields['type']; |
||
235 | } elseif ('CONSTRAINTTABLE' == $rs->fields['type'] && 'CONSTRAINTDOMAIN' == $curr) { |
||
236 | $curr = $rs->fields['type']; |
||
237 | } else { |
||
238 | if ('' != $curr) { |
||
239 | echo "</ul>\n"; |
||
240 | } |
||
241 | |||
242 | $curr = $rs->fields['type']; |
||
243 | echo '<h3>'; |
||
244 | switch ($curr) { |
||
245 | case 'SCHEMA': |
||
246 | echo $lang['strschemas']; |
||
247 | |||
248 | break; |
||
249 | case 'TABLE': |
||
250 | echo $lang['strtables']; |
||
251 | |||
252 | break; |
||
253 | case 'VIEW': |
||
254 | echo $lang['strviews']; |
||
255 | |||
256 | break; |
||
257 | case 'SEQUENCE': |
||
258 | echo $lang['strsequences']; |
||
259 | |||
260 | break; |
||
261 | case 'COLUMNTABLE': |
||
262 | case 'COLUMNVIEW': |
||
263 | echo $lang['strcolumns']; |
||
264 | |||
265 | break; |
||
266 | case 'INDEX': |
||
267 | echo $lang['strindexes']; |
||
268 | |||
269 | break; |
||
270 | case 'CONSTRAINTTABLE': |
||
271 | case 'CONSTRAINTDOMAIN': |
||
272 | echo $lang['strconstraints']; |
||
273 | |||
274 | break; |
||
275 | case 'TRIGGER': |
||
276 | echo $lang['strtriggers']; |
||
277 | |||
278 | break; |
||
279 | case 'RULETABLE': |
||
280 | case 'RULEVIEW': |
||
281 | echo $lang['strrules']; |
||
282 | |||
283 | break; |
||
284 | case 'FUNCTION': |
||
285 | echo $lang['strfunctions']; |
||
286 | |||
287 | break; |
||
288 | case 'TYPE': |
||
289 | echo $lang['strtypes']; |
||
290 | |||
291 | break; |
||
292 | case 'DOMAIN': |
||
293 | echo $lang['strdomains']; |
||
294 | |||
295 | break; |
||
296 | case 'OPERATOR': |
||
297 | echo $lang['stroperators']; |
||
298 | |||
299 | break; |
||
300 | case 'CONVERSION': |
||
301 | echo $lang['strconversions']; |
||
302 | |||
303 | break; |
||
304 | case 'LANGUAGE': |
||
305 | echo $lang['strlanguages']; |
||
306 | |||
307 | break; |
||
308 | case 'AGGREGATE': |
||
309 | echo $lang['straggregates']; |
||
310 | |||
311 | break; |
||
312 | case 'OPCLASS': |
||
313 | echo $lang['stropclasses']; |
||
314 | |||
315 | break; |
||
316 | } |
||
317 | echo '</h3>'; |
||
318 | echo "<ul>\n"; |
||
319 | } |
||
320 | } |
||
321 | |||
322 | switch ($curr) { |
||
323 | case 'SCHEMA': |
||
324 | echo '<li><a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", $this->misc->printVal($rs->fields['name']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
325 | |||
326 | break; |
||
327 | case 'TABLE': |
||
328 | echo '<li>'; |
||
329 | echo "<a href=\"tables.php?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
||
330 | echo '<a href="' . \SUBFOLDER . "/redirect/table?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&table=', |
||
331 | urlencode($rs->fields['name']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
332 | |||
333 | break; |
||
334 | case 'VIEW': |
||
335 | echo '<li>'; |
||
336 | echo "<a href=\"views.php?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
||
337 | echo '<a href="' . \SUBFOLDER . "/redirect/view?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&view=', |
||
338 | urlencode($rs->fields['name']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
339 | |||
340 | break; |
||
341 | case 'SEQUENCE': |
||
342 | echo '<li>'; |
||
343 | echo "<a href=\"sequences.php?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
||
344 | echo "<a href=\"sequences.php?subject=sequence&action=properties&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), |
||
345 | '&sequence=', urlencode($rs->fields['name']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
346 | |||
347 | break; |
||
348 | case 'COLUMNTABLE': |
||
349 | echo '<li>'; |
||
350 | echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
||
351 | echo "<a href=\"tblproperties.php?subject=table&{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.'; |
||
352 | echo "<a href=\"colproperties.php?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&table=', |
||
353 | urlencode($rs->fields['relname']), '&column=', urlencode($rs->fields['name']), '">', |
||
354 | $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
355 | |||
356 | break; |
||
357 | case 'COLUMNVIEW': |
||
358 | echo '<li>'; |
||
359 | echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
||
360 | echo "<a href=\"viewproperties.php?subject=view&{$this->misc->href}&view=", urlencode($rs->fields['relname']), '&schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.'; |
||
361 | echo "<a href=\"colproperties.php?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&view=', |
||
362 | urlencode($rs->fields['relname']), '&column=', urlencode($rs->fields['name']), '">', |
||
363 | $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
364 | |||
365 | break; |
||
366 | case 'INDEX': |
||
367 | echo '<li>'; |
||
368 | echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
||
369 | echo '<a href="' . \SUBFOLDER . "/redirect/table?{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.'; |
||
370 | echo "<a href=\"indexes.php?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&table=', urlencode($rs->fields['relname']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
371 | |||
372 | break; |
||
373 | case 'CONSTRAINTTABLE': |
||
374 | echo '<li>'; |
||
375 | echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
||
376 | echo '<a href="' . \SUBFOLDER . "/redirect/table?{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.'; |
||
377 | echo "<a href=\"constraints.php?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&table=', |
||
378 | urlencode($rs->fields['relname']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
379 | |||
380 | break; |
||
381 | case 'CONSTRAINTDOMAIN': |
||
382 | echo '<li>'; |
||
383 | echo "<a href=\"domains.php?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
||
384 | echo "<a href=\"domains.php?action=properties&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&domain=', urlencode($rs->fields['relname']), '">', |
||
385 | $this->misc->printVal($rs->fields['relname']), '.', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
386 | |||
387 | break; |
||
388 | case 'TRIGGER': |
||
389 | echo '<li>'; |
||
390 | echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
||
391 | echo '<a href="' . \SUBFOLDER . "/redirect/table?{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.'; |
||
392 | echo "<a href=\"triggers.php?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&table=', urlencode($rs->fields['relname']), '">', |
||
393 | $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
394 | |||
395 | break; |
||
396 | case 'RULETABLE': |
||
397 | echo '<li>'; |
||
398 | echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
||
399 | echo '<a href="' . \SUBFOLDER . "/redirect/table?{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.'; |
||
400 | echo "<a href=\"rules.php?subject=table&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&reltype=table&table=', |
||
401 | urlencode($rs->fields['relname']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
402 | |||
403 | break; |
||
404 | case 'RULEVIEW': |
||
405 | echo '<li>'; |
||
406 | echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
||
407 | echo '<a href="' . \SUBFOLDER . "/redirect/view?{$this->misc->href}&view=", urlencode($rs->fields['relname']), '&schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.'; |
||
408 | echo "<a href=\"rules.php?subject=view&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&reltype=view&view=', |
||
409 | urlencode($rs->fields['relname']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
410 | |||
411 | break; |
||
412 | case 'FUNCTION': |
||
413 | echo '<li>'; |
||
414 | echo "<a href=\"functions.php?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
||
415 | echo "<a href=\"functions.php?action=properties&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&function=', |
||
416 | urlencode($rs->fields['name']), '&function_oid=', urlencode($rs->fields['oid']), '">', |
||
417 | $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
418 | |||
419 | break; |
||
420 | case 'TYPE': |
||
421 | echo '<li>'; |
||
422 | echo "<a href=\"types.php?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
||
423 | echo "<a href=\"types.php?action=properties&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&type=', |
||
424 | urlencode($rs->fields['name']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
425 | |||
426 | break; |
||
427 | case 'DOMAIN': |
||
428 | echo '<li>'; |
||
429 | echo "<a href=\"domains.php?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
||
430 | echo "<a href=\"domains.php?action=properties&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&domain=', |
||
431 | urlencode($rs->fields['name']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
432 | |||
433 | break; |
||
434 | case 'OPERATOR': |
||
435 | echo '<li>'; |
||
436 | echo "<a href=\"operators.php?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
||
437 | echo "<a href=\"operators.php?action=properties&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&operator=', |
||
438 | urlencode($rs->fields['name']), '&operator_oid=', urlencode($rs->fields['oid']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
439 | |||
440 | break; |
||
441 | case 'CONVERSION': |
||
442 | echo '<li>'; |
||
443 | echo "<a href=\"conversions.php?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
||
444 | echo "<a href=\"conversions.php?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), |
||
445 | '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
446 | |||
447 | break; |
||
448 | case 'LANGUAGE': |
||
449 | echo "<li><a href=\"languages.php?{$this->misc->href}\">", $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
450 | |||
451 | break; |
||
452 | case 'AGGREGATE': |
||
453 | echo '<li>'; |
||
454 | echo "<a href=\"aggregates.php?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
||
455 | echo "<a href=\"aggregates.php?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', |
||
456 | $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
457 | |||
458 | break; |
||
459 | case 'OPCLASS': |
||
460 | echo '<li>'; |
||
461 | echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
||
462 | echo "<a href=\"opclasses.php?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', |
||
463 | $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
||
464 | |||
465 | break; |
||
466 | } |
||
467 | $rs->moveNext(); |
||
468 | } |
||
469 | echo "</ul>\n"; |
||
470 | |||
471 | echo '<p>', $rs->recordCount(), ' ', $lang['strobjects'], "</p>\n"; |
||
472 | } else { |
||
473 | echo "<p>{$lang['strnoobjects']}</p>\n"; |
||
474 | } |
||
827 |