| Conditions | 5 |
| Paths | 5 |
| Total Lines | 120 |
| Code Lines | 75 |
| 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 |
||
| 66 | public function doDefault() |
||
| 67 | { |
||
| 68 | $data = $this->misc->getDatabaseAccessor(); |
||
| 69 | |||
| 70 | $this->printHeader($this->lang['strhistory'], $this->scripts, true, 'header.twig'); |
||
| 71 | |||
| 72 | // Bring to the front always |
||
| 73 | echo "<body onload=\"window.focus();\">\n"; |
||
| 74 | |||
| 75 | echo '<form action="'.\SUBFOLDER."/src/views/history\" method=\"post\">\n"; |
||
| 76 | $this->printConnection('history'); |
||
| 77 | echo '</form><br />'; |
||
| 78 | |||
| 79 | if (!isset($_REQUEST['database'])) { |
||
| 80 | echo "<p>{$this->lang['strnodatabaseselected']}</p>\n"; |
||
| 81 | |||
| 82 | return; |
||
| 83 | } |
||
| 84 | |||
| 85 | if (isset($_SESSION['history'][$_REQUEST['server']][$_REQUEST['database']])) { |
||
| 86 | $history = new \PHPPgAdmin\ArrayRecordSet($_SESSION['history'][$_REQUEST['server']][$_REQUEST['database']]); |
||
| 87 | |||
| 88 | //Kint::dump($history); |
||
| 89 | $columns = [ |
||
| 90 | 'query' => [ |
||
| 91 | 'title' => $this->lang['strsql'], |
||
| 92 | 'field' => Decorator::field('query'), |
||
| 93 | ], |
||
| 94 | 'paginate' => [ |
||
| 95 | 'title' => $this->lang['strpaginate'], |
||
| 96 | 'field' => Decorator::field('paginate'), |
||
| 97 | 'type' => 'yesno', |
||
| 98 | ], |
||
| 99 | 'actions' => [ |
||
| 100 | 'title' => $this->lang['stractions'], |
||
| 101 | ], |
||
| 102 | ]; |
||
| 103 | |||
| 104 | $actions = [ |
||
| 105 | 'run' => [ |
||
| 106 | 'content' => $this->lang['strexecute'], |
||
| 107 | 'attr' => [ |
||
| 108 | 'href' => [ |
||
| 109 | 'url' => 'sql', |
||
| 110 | 'urlvars' => [ |
||
| 111 | 'subject' => 'history', |
||
| 112 | 'nohistory' => 't', |
||
| 113 | 'queryid' => Decorator::field('queryid'), |
||
| 114 | 'paginate' => Decorator::field('paginate'), |
||
| 115 | ], |
||
| 116 | ], |
||
| 117 | 'target' => 'detail', |
||
| 118 | ], |
||
| 119 | ], |
||
| 120 | 'remove' => [ |
||
| 121 | 'content' => $this->lang['strdelete'], |
||
| 122 | 'attr' => [ |
||
| 123 | 'href' => [ |
||
| 124 | 'url' => 'history', |
||
| 125 | 'urlvars' => [ |
||
| 126 | 'action' => 'confdelhistory', |
||
| 127 | 'queryid' => Decorator::field('queryid'), |
||
| 128 | ], |
||
| 129 | ], |
||
| 130 | ], |
||
| 131 | ], |
||
| 132 | ]; |
||
| 133 | |||
| 134 | echo $this->printTable($history, $columns, $actions, 'history-history', $this->lang['strnohistory']); |
||
| 135 | } else { |
||
| 136 | echo "<p>{$this->lang['strnohistory']}</p>\n"; |
||
| 137 | } |
||
| 138 | |||
| 139 | $navlinks = [ |
||
| 140 | 'refresh' => [ |
||
| 141 | 'attr' => [ |
||
| 142 | 'href' => [ |
||
| 143 | 'url' => 'history', |
||
| 144 | 'urlvars' => [ |
||
| 145 | 'action' => 'history', |
||
| 146 | 'server' => $_REQUEST['server'], |
||
| 147 | 'database' => $_REQUEST['database'], |
||
| 148 | ], |
||
| 149 | ], |
||
| 150 | ], |
||
| 151 | 'content' => $this->lang['strrefresh'], |
||
| 152 | ], |
||
| 153 | ]; |
||
| 154 | |||
| 155 | if (isset($_SESSION['history'][$_REQUEST['server']][$_REQUEST['database']]) |
||
| 156 | && count($_SESSION['history'][$_REQUEST['server']][$_REQUEST['database']])) { |
||
|
1 ignored issue
–
show
|
|||
| 157 | $navlinks['download'] = [ |
||
| 158 | 'attr' => [ |
||
| 159 | 'href' => [ |
||
| 160 | 'url' => 'history', |
||
| 161 | 'urlvars' => [ |
||
| 162 | 'action' => 'download', |
||
| 163 | 'server' => $_REQUEST['server'], |
||
| 164 | 'database' => $_REQUEST['database'], |
||
| 165 | ], |
||
| 166 | ], |
||
| 167 | ], |
||
| 168 | 'content' => $this->lang['strdownload'], |
||
| 169 | ]; |
||
| 170 | $navlinks['clear'] = [ |
||
| 171 | 'attr' => [ |
||
| 172 | 'href' => [ |
||
| 173 | 'url' => 'history', |
||
| 174 | 'urlvars' => [ |
||
| 175 | 'action' => 'confclearhistory', |
||
| 176 | 'server' => $_REQUEST['server'], |
||
| 177 | 'database' => $_REQUEST['database'], |
||
| 178 | ], |
||
| 179 | ], |
||
| 180 | ], |
||
| 181 | 'content' => $this->lang['strclearhistory'], |
||
| 182 | ]; |
||
| 183 | } |
||
| 184 | |||
| 185 | $this->printNavLinks($navlinks, 'history-history', get_defined_vars()); |
||
| 186 | } |
||
| 255 |