Conditions | 14 |
Paths | 7 |
Total Lines | 118 |
Code Lines | 80 |
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 |
||
295 | } |
||
296 | |||
297 | echo '<input type="hidden" name="action" value="drop" />'.PHP_EOL; |
||
298 | |||
299 | echo $this->misc->form; |
||
300 | echo "<p><input type=\"checkbox\" id=\"cascade\" name=\"cascade\" /> <label for=\"cascade\">{$this->lang['strcascade']}</label></p>".PHP_EOL; |
||
301 | echo "<input type=\"submit\" name=\"drop\" value=\"{$this->lang['strdrop']}\" />".PHP_EOL; |
||
302 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strcancel']}\" />".PHP_EOL; |
||
303 | echo '</form>'.PHP_EOL; |
||
304 | } else { |
||
305 | if (is_array($_POST['view'])) { |
||
306 | $msg = ''; |
||
307 | $status = $data->beginTransaction(); |
||
308 | if (0 == $status) { |
||
309 | foreach ($_POST['view'] as $s) { |
||
310 | $status = $data->dropView($s, isset($_POST['cascade'])); |
||
311 | if (0 == $status) { |
||
312 | $msg .= sprintf('%s: %s<br />', htmlentities($s, ENT_QUOTES, 'UTF-8'), $this->lang['strviewdropped']); |
||
313 | } else { |
||
314 | $data->endTransaction(); |
||
315 | $this->doDefault(sprintf('%s%s: %s<br />', $msg, htmlentities($s, ENT_QUOTES, 'UTF-8'), $this->lang['strviewdroppedbad'])); |
||
316 | |||
317 | return; |
||
318 | } |
||
319 | } |
||
320 | } |
||
321 | if (0 == $data->endTransaction()) { |
||
322 | // Everything went fine, back to the Default page.... |
||
323 | $this->misc->setReloadBrowser(true); |
||
324 | $this->doDefault($msg); |
||
325 | } else { |
||
326 | $this->doDefault($this->lang['strviewdroppedbad']); |
||
327 | } |
||
328 | } else { |
||
329 | $status = $data->dropView($_POST['view'], isset($_POST['cascade'])); |
||
330 | if (0 == $status) { |
||
331 | $this->misc->setReloadBrowser(true); |
||
332 | $this->doDefault($this->lang['strviewdropped']); |
||
333 | } else { |
||
334 | $this->doDefault($this->lang['strviewdroppedbad']); |
||
335 | } |
||
336 | } |
||
337 | } |
||
338 | } |
||
339 | |||
340 | /** |
||
341 | * Sets up choices for table linkage, and which fields to select for the view we're creating. |
||
342 | * |
||
343 | * @param mixed $msg |
||
344 | */ |
||
345 | public function doSetParamsCreate($msg = '') |
||
346 | { |
||
347 | // Check that they've chosen tables for the view definition |
||
348 | if (!isset($_POST['formTables'])) { |
||
349 | return $this->doWizardCreate($this->lang['strviewneedsdef']); |
||
350 | } |
||
351 | // Initialise variables |
||
352 | $this->coalesceArr($_REQUEST, 'formView', ''); |
||
353 | |||
354 | $this->coalesceArr($_REQUEST, 'formComment', ''); |
||
355 | |||
356 | $this->printTrail('schema'); |
||
357 | $this->printTitle($this->lang['strcreatematviewwiz'], 'pg.matview.create'); |
||
358 | $this->printMsg($msg); |
||
359 | |||
360 | $this->printParamsCreateForm(); |
||
361 | } |
||
362 | |||
363 | /** |
||
364 | * Display a wizard where they can enter a new view. |
||
365 | * |
||
366 | * @param mixed $msg |
||
367 | */ |
||
368 | public function doWizardCreate($msg = '') |
||
369 | { |
||
370 | $this->printTrail('schema'); |
||
371 | $this->printTitle($this->lang['strcreatematviewwiz'], 'pg.matview.create'); |
||
372 | $this->printMsg($msg); |
||
373 | |||
374 | $this->printWizardCreateForm(); |
||
375 | } |
||
376 | |||
377 | /** |
||
378 | * Displays a screen where they can enter a new view. |
||
379 | * |
||
380 | * @param mixed $msg |
||
381 | */ |
||
382 | public function doCreate($msg = '') |
||
383 | { |
||
384 | $data = $this->misc->getDatabaseAccessor(); |
||
385 | |||
386 | $this->coalesceArr($_REQUEST, 'formView', ''); |
||
387 | |||
388 | if (!isset($_REQUEST['formDefinition'])) { |
||
389 | if (isset($_SESSION['sqlquery'])) { |
||
390 | $_REQUEST['formDefinition'] = $_SESSION['sqlquery']; |
||
391 | } else { |
||
392 | $_REQUEST['formDefinition'] = 'SELECT '; |
||
393 | } |
||
394 | } |
||
395 | $this->coalesceArr($_REQUEST, 'formComment', ''); |
||
396 | |||
397 | $this->printTrail('schema'); |
||
398 | $this->printTitle($this->lang['strcreateview'], 'pg.matview.create'); |
||
399 | $this->printMsg($msg); |
||
400 | |||
401 | echo '<form action="'.\SUBFOLDER."/src/views/{$this->view_name}\" method=\"post\">".PHP_EOL; |
||
402 | echo '<table style="width: 100%">'.PHP_EOL; |
||
403 | echo "\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['strname']}</th>".PHP_EOL; |
||
404 | echo "\t<td class=\"data1\"><input name=\"formView\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
||
405 | htmlspecialchars($_REQUEST['formView']), "\" /></td>\n\t</tr>".PHP_EOL; |
||
406 | echo "\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['strdefinition']}</th>".PHP_EOL; |
||
407 | echo "\t<td class=\"data1\"><textarea style=\"width:100%;\" rows=\"10\" cols=\"50\" name=\"formDefinition\">", |
||
408 | htmlspecialchars($_REQUEST['formDefinition']), "</textarea></td>\n\t</tr>".PHP_EOL; |
||
409 | echo "\t<tr>\n\t\t<th class=\"data left\">{$this->lang['strcomment']}</th>".PHP_EOL; |
||
410 | echo "\t\t<td class=\"data1\"><textarea name=\"formComment\" rows=\"3\" cols=\"32\">", |
||
411 | htmlspecialchars($_REQUEST['formComment']), "</textarea></td>\n\t</tr>".PHP_EOL; |
||
412 | echo '</table>'.PHP_EOL; |
||
413 | echo '<p><input type="hidden" name="action" value="save_create" />'.PHP_EOL; |
||
443 |