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