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