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