| Conditions | 6 |
| Paths | 18 |
| Total Lines | 148 |
| Code Lines | 97 |
| 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 |
||
| 68 | public function doDefault($msg = '', $isTable = true) |
||
| 69 | { |
||
| 70 | $lang = $this->lang; |
||
| 71 | $data = $this->misc->getDatabaseAccessor(); |
||
| 72 | |||
| 73 | $attPre = function (&$rowdata) use ($data) { |
||
| 74 | $rowdata->fields['+type'] = $data->formatType($rowdata->fields['type'], $rowdata->fields['atttypmod']); |
||
| 75 | }; |
||
| 76 | |||
| 77 | if (empty($_REQUEST['column'])) { |
||
| 78 | $msg .= "<br/>{$lang['strnoobjects']}"; |
||
| 79 | } |
||
| 80 | |||
| 81 | $this->printTrail('column'); |
||
| 82 | //$this->printTitle($lang['strcolprop']); |
||
| 83 | $this->printTabs('column', 'properties'); |
||
| 84 | $this->printMsg($msg); |
||
| 85 | |||
| 86 | if (!empty($_REQUEST['column'])) { |
||
| 87 | // Get table |
||
| 88 | $tdata = $data->getTable($this->tableName); |
||
| 89 | // Get columns |
||
| 90 | $attrs = $data->getTableAttributes($this->tableName, $_REQUEST['column']); |
||
| 91 | |||
| 92 | // Show comment if any |
||
| 93 | if (null !== $attrs->fields['comment']) { |
||
| 94 | echo '<p class="comment">', $this->misc->printVal($attrs->fields['comment']), "</p>\n"; |
||
| 95 | } |
||
| 96 | |||
| 97 | $column = [ |
||
| 98 | 'column' => [ |
||
| 99 | 'title' => $lang['strcolumn'], |
||
| 100 | 'field' => Decorator::field('attname'), |
||
| 101 | ], |
||
| 102 | 'type' => [ |
||
| 103 | 'title' => $lang['strtype'], |
||
| 104 | 'field' => Decorator::field('+type'), |
||
| 105 | ], |
||
| 106 | ]; |
||
| 107 | |||
| 108 | if ($isTable) { |
||
| 109 | $column['notnull'] = [ |
||
| 110 | 'title' => $lang['strnotnull'], |
||
| 111 | 'field' => Decorator::field('attnotnull'), |
||
| 112 | 'type' => 'bool', |
||
| 113 | 'params' => ['true' => 'NOT NULL', 'false' => ''], |
||
| 114 | ]; |
||
| 115 | $column['default'] = [ |
||
| 116 | 'title' => $lang['strdefault'], |
||
| 117 | 'field' => Decorator::field('adsrc'), |
||
| 118 | ]; |
||
| 119 | } |
||
| 120 | |||
| 121 | $actions = []; |
||
| 122 | echo $this->printTable($attrs, $column, $actions, $this->table_place, null, $attPre); |
||
| 123 | |||
| 124 | echo "<br />\n"; |
||
| 125 | |||
| 126 | $f_attname = $_REQUEST['column']; |
||
| 127 | $f_table = $this->tableName; |
||
| 128 | $f_schema = $data->_schema; |
||
| 129 | $data->fieldClean($f_attname); |
||
| 130 | $data->fieldClean($f_table); |
||
| 131 | $data->fieldClean($f_schema); |
||
| 132 | $query = "SELECT \"{$f_attname}\", count(*) AS \"count\" FROM \"{$f_schema}\".\"{$f_table}\" GROUP BY \"{$f_attname}\" ORDER BY \"{$f_attname}\""; |
||
| 133 | |||
| 134 | if ($isTable) { |
||
| 135 | // Browse link |
||
| 136 | /* FIXME browsing a col should somehow be a action so we don't |
||
| 137 | * send an ugly SQL in the URL */ |
||
| 138 | |||
| 139 | $navlinks = [ |
||
| 140 | 'browse' => [ |
||
| 141 | 'attr' => [ |
||
| 142 | 'href' => [ |
||
| 143 | 'url' => 'display.php', |
||
| 144 | 'urlvars' => [ |
||
| 145 | 'subject' => 'column', |
||
| 146 | 'server' => $_REQUEST['server'], |
||
| 147 | 'database' => $_REQUEST['database'], |
||
| 148 | 'schema' => $_REQUEST['schema'], |
||
| 149 | 'table' => $this->tableName, |
||
| 150 | 'column' => $_REQUEST['column'], |
||
| 151 | 'return' => 'column', |
||
| 152 | 'query' => $query, |
||
| 153 | ], |
||
| 154 | ], |
||
| 155 | ], |
||
| 156 | 'content' => $lang['strbrowse'], |
||
| 157 | ], |
||
| 158 | 'alter' => [ |
||
| 159 | 'attr' => [ |
||
| 160 | 'href' => [ |
||
| 161 | 'url' => 'colproperties.php', |
||
| 162 | 'urlvars' => [ |
||
| 163 | 'action' => 'properties', |
||
| 164 | 'server' => $_REQUEST['server'], |
||
| 165 | 'database' => $_REQUEST['database'], |
||
| 166 | 'schema' => $_REQUEST['schema'], |
||
| 167 | 'table' => $this->tableName, |
||
| 168 | 'column' => $_REQUEST['column'], |
||
| 169 | ], |
||
| 170 | ], |
||
| 171 | ], |
||
| 172 | 'content' => $lang['stralter'], |
||
| 173 | ], |
||
| 174 | 'drop' => [ |
||
| 175 | 'attr' => [ |
||
| 176 | 'href' => [ |
||
| 177 | 'url' => 'tblproperties.php', |
||
| 178 | 'urlvars' => [ |
||
| 179 | 'action' => 'confirm_drop', |
||
| 180 | 'server' => $_REQUEST['server'], |
||
| 181 | 'database' => $_REQUEST['database'], |
||
| 182 | 'schema' => $_REQUEST['schema'], |
||
| 183 | 'table' => $this->tableName, |
||
| 184 | 'column' => $_REQUEST['column'], |
||
| 185 | ], |
||
| 186 | ], |
||
| 187 | ], |
||
| 188 | 'content' => $lang['strdrop'], |
||
| 189 | ], |
||
| 190 | ]; |
||
| 191 | } else { |
||
| 192 | // Browse link |
||
| 193 | $navlinks = [ |
||
| 194 | 'browse' => [ |
||
| 195 | 'attr' => [ |
||
| 196 | 'href' => [ |
||
| 197 | 'url' => 'display.php', |
||
| 198 | 'urlvars' => [ |
||
| 199 | 'subject' => 'column', |
||
| 200 | 'server' => $_REQUEST['server'], |
||
| 201 | 'database' => $_REQUEST['database'], |
||
| 202 | 'schema' => $_REQUEST['schema'], |
||
| 203 | 'view' => $this->tableName, |
||
| 204 | 'column' => $_REQUEST['column'], |
||
| 205 | 'return' => 'column', |
||
| 206 | 'query' => $query, |
||
| 207 | ], |
||
| 208 | ], |
||
| 209 | ], |
||
| 210 | 'content' => $lang['strbrowse'], |
||
| 211 | ], |
||
| 212 | ]; |
||
| 213 | } |
||
| 214 | |||
| 215 | $this->printNavLinks($navlinks, $this->table_place, get_defined_vars()); |
||
| 216 | } |
||
| 403 |