| Conditions | 7 |
| Paths | 8 |
| Total Lines | 74 |
| Code Lines | 49 |
| 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 |
||
| 71 | public function doDefault($msg = '') |
||
| 72 | { |
||
| 73 | $lang = $this->lang; |
||
| 74 | |||
| 75 | $this->printTabs('root', 'servers'); |
||
| 76 | $this->printMsg($msg); |
||
| 77 | $group = isset($_GET['group']) ? $_GET['group'] : false; |
||
| 78 | |||
| 79 | $groups = $this->getServersGroups(true, $group); |
||
| 80 | $columns = [ |
||
| 81 | 'group' => [ |
||
| 82 | 'title' => $lang['strgroup'], |
||
| 83 | 'field' => Decorator::field('desc'), |
||
| 84 | 'url' => 'servers?', |
||
| 85 | 'vars' => ['group' => 'id'], |
||
| 86 | ], |
||
| 87 | ]; |
||
| 88 | $actions = []; |
||
| 89 | if ((false !== $group) && (isset($this->conf['srv_groups'][$group])) && ($groups->recordCount() > 0)) { |
||
| 90 | $this->printTitle(sprintf($lang['strgroupgroups'], htmlentities($this->conf['srv_groups'][$group]['desc'], ENT_QUOTES, 'UTF-8'))); |
||
| 91 | } |
||
| 92 | $this->printTable($groups, $columns, $actions, $this->table_place); |
||
| 93 | $servers = $this->misc->getServers(true, $group); |
||
| 94 | |||
| 95 | $columns = [ |
||
| 96 | 'server' => [ |
||
| 97 | 'title' => $lang['strserver'], |
||
| 98 | 'field' => Decorator::field('desc'), |
||
| 99 | 'url' => \SUBFOLDER . '/redirect/server?', |
||
| 100 | 'vars' => ['server' => 'id'], |
||
| 101 | ], |
||
| 102 | 'host' => [ |
||
| 103 | 'title' => $lang['strhost'], |
||
| 104 | 'field' => Decorator::field('host'), |
||
| 105 | ], |
||
| 106 | 'port' => [ |
||
| 107 | 'title' => $lang['strport'], |
||
| 108 | 'field' => Decorator::field('port'), |
||
| 109 | ], |
||
| 110 | 'username' => [ |
||
| 111 | 'title' => $lang['strusername'], |
||
| 112 | 'field' => Decorator::field('username'), |
||
| 113 | ], |
||
| 114 | 'actions' => [ |
||
| 115 | 'title' => $lang['stractions'], |
||
| 116 | ], |
||
| 117 | ]; |
||
| 118 | |||
| 119 | $actions = [ |
||
| 120 | 'logout' => [ |
||
| 121 | 'content' => $lang['strlogout'], |
||
| 122 | 'attr' => [ |
||
| 123 | 'href' => [ |
||
| 124 | 'url' => 'servers', |
||
| 125 | 'urlvars' => [ |
||
| 126 | 'action' => 'logout', |
||
| 127 | 'logoutServer' => Decorator::field('id'), |
||
| 128 | ], |
||
| 129 | ], |
||
| 130 | ], |
||
| 131 | ], |
||
| 132 | ]; |
||
| 133 | |||
| 134 | $svPre = function (&$rowdata) use ($actions) { |
||
| 135 | $actions['logout']['disable'] = empty($rowdata->fields['username']); |
||
| 136 | |||
| 137 | return $actions; |
||
| 138 | }; |
||
| 139 | |||
| 140 | if ((false !== $group) and isset($this->conf['srv_groups'][$group])) { |
||
| 141 | $this->printTitle(sprintf($lang['strgroupservers'], htmlentities($this->conf['srv_groups'][$group]['desc'], ENT_QUOTES, 'UTF-8')), null); |
||
| 142 | $actions['logout']['attr']['href']['urlvars']['group'] = $group; |
||
| 143 | } |
||
| 144 | echo $this->printTable($servers, $columns, $actions, $this->table_place, $lang['strnoobjects'], $svPre); |
||
| 145 | } |
||
| 287 |