Conditions | 3 |
Paths | 4 |
Total Lines | 149 |
Code Lines | 99 |
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 |
||
25 | public function doDefault($msg = '') |
||
26 | { |
||
27 | $data = $this->misc->getDatabaseAccessor(); |
||
28 | |||
29 | $attPre = function (&$rowdata) use ($data) { |
||
30 | $rowdata->fields['+type'] = $data->formatType($rowdata->fields['type'], $rowdata->fields['atttypmod']); |
||
31 | }; |
||
32 | |||
33 | $this->printTrail($this->subject); |
||
34 | $this->printTabs($this->subject, 'columns'); |
||
35 | $this->printMsg($msg); |
||
36 | |||
37 | // Get view |
||
38 | $vdata = $data->getView($_REQUEST[$this->subject]); |
||
39 | // Get columns (using same method for getting a view) |
||
40 | $attrs = $data->getTableAttributes($_REQUEST[$this->subject]); |
||
41 | |||
42 | // Show comment if any |
||
43 | if (null !== $vdata->fields['relcomment']) { |
||
44 | echo '<p class="comment">', $this->misc->printVal($vdata->fields['relcomment']), "</p>\n"; |
||
45 | } |
||
46 | |||
47 | $columns = [ |
||
48 | 'column' => [ |
||
49 | 'title' => $this->lang['strcolumn'], |
||
50 | 'field' => Decorator::field('attname'), |
||
51 | 'url' => "colproperties?subject=column&{$this->misc->href}&view=" . urlencode($_REQUEST[$this->subject]) . '&', |
||
52 | 'vars' => ['column' => 'attname'], |
||
53 | ], |
||
54 | 'type' => [ |
||
55 | 'title' => $this->lang['strtype'], |
||
56 | 'field' => Decorator::field('+type'), |
||
57 | ], |
||
58 | 'default' => [ |
||
59 | 'title' => $this->lang['strdefault'], |
||
60 | 'field' => Decorator::field('adsrc'), |
||
61 | ], |
||
62 | 'actions' => [ |
||
63 | 'title' => $this->lang['stractions'], |
||
64 | ], |
||
65 | 'comment' => [ |
||
66 | 'title' => $this->lang['strcomment'], |
||
67 | 'field' => Decorator::field('comment'), |
||
68 | ], |
||
69 | ]; |
||
70 | |||
71 | $actions = [ |
||
72 | 'alter' => [ |
||
73 | 'content' => $this->lang['stralter'], |
||
74 | 'attr' => [ |
||
75 | 'href' => [ |
||
76 | 'url' => $this->view_name, |
||
77 | 'urlvars' => [ |
||
78 | 'action' => 'properties', |
||
79 | $this->subject => $_REQUEST[$this->subject], |
||
80 | 'column' => Decorator::field('attname'), |
||
81 | ], |
||
82 | ], |
||
83 | ], |
||
84 | ], |
||
85 | ]; |
||
86 | |||
87 | echo $this->printTable($attrs, $columns, $actions, "{$this->view_name}-{$this->view_name}", null, $attPre); |
||
88 | |||
89 | echo "<br />\n"; |
||
90 | |||
91 | $navlinks = [ |
||
92 | 'browse' => [ |
||
93 | 'attr' => [ |
||
94 | 'href' => [ |
||
95 | 'url' => 'display', |
||
96 | 'urlvars' => [ |
||
97 | 'server' => $_REQUEST['server'], |
||
98 | 'database' => $_REQUEST['database'], |
||
99 | 'schema' => $_REQUEST['schema'], |
||
100 | $this->subject => $_REQUEST[$this->subject], |
||
101 | 'subject' => $this->subject, |
||
102 | 'return' => $this->subject, |
||
103 | ], |
||
104 | ], |
||
105 | ], |
||
106 | 'content' => $this->lang['strbrowse'], |
||
107 | ], |
||
108 | 'select' => [ |
||
109 | 'attr' => [ |
||
110 | 'href' => [ |
||
111 | 'url' => str_replace('properties', 's', $this->view_name), |
||
112 | 'urlvars' => [ |
||
113 | 'action' => 'confselectrows', |
||
114 | 'server' => $_REQUEST['server'], |
||
115 | 'database' => $_REQUEST['database'], |
||
116 | 'schema' => $_REQUEST['schema'], |
||
117 | $this->subject => $_REQUEST[$this->subject], |
||
118 | ], |
||
119 | ], |
||
120 | ], |
||
121 | 'content' => $this->lang['strselect'], |
||
122 | ], |
||
123 | 'drop' => [ |
||
124 | 'attr' => [ |
||
125 | 'href' => [ |
||
126 | 'url' => str_replace('properties', 's', $this->view_name), |
||
127 | 'urlvars' => [ |
||
128 | 'action' => 'confirm_drop', |
||
129 | 'server' => $_REQUEST['server'], |
||
130 | 'database' => $_REQUEST['database'], |
||
131 | 'schema' => $_REQUEST['schema'], |
||
132 | $this->subject => $_REQUEST[$this->subject], |
||
133 | ], |
||
134 | ], |
||
135 | ], |
||
136 | 'content' => $this->lang['strdrop'], |
||
137 | ], |
||
138 | 'alter' => [ |
||
139 | 'attr' => [ |
||
140 | 'href' => [ |
||
141 | 'url' => $this->view_name, |
||
142 | 'urlvars' => [ |
||
143 | 'action' => 'confirm_alter', |
||
144 | 'server' => $_REQUEST['server'], |
||
145 | 'database' => $_REQUEST['database'], |
||
146 | 'schema' => $_REQUEST['schema'], |
||
147 | $this->subject => $_REQUEST[$this->subject], |
||
148 | ], |
||
149 | ], |
||
150 | ], |
||
151 | 'content' => $this->lang['stralter'], |
||
152 | ], |
||
153 | ]; |
||
154 | $this->prtrace($this->view_name); |
||
155 | if ($this->view_name === 'materializedviewproperties') { |
||
156 | $navlinks['refresh'] = [ |
||
157 | 'attr' => [ |
||
158 | 'href' => [ |
||
159 | 'url' => $this->view_name, |
||
160 | 'urlvars' => [ |
||
161 | 'action' => 'refresh', |
||
162 | 'server' => $_REQUEST['server'], |
||
163 | 'database' => $_REQUEST['database'], |
||
164 | 'schema' => $_REQUEST['schema'], |
||
165 | $this->subject => $_REQUEST[$this->subject], |
||
166 | ], |
||
167 | ], |
||
168 | ], |
||
169 | 'content' => $this->lang['strrefresh'], |
||
170 | ]; |
||
171 | } |
||
172 | |||
173 | $this->printNavLinks($navlinks, "{$this->view_name}-{$this->view_name}", get_defined_vars()); |
||
174 | } |
||
297 |