Total Complexity | 30 |
Total Lines | 368 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
12 | class AggregatesController extends BaseController |
||
13 | { |
||
14 | public $controller_name = 'AggregatesController'; |
||
15 | |||
16 | /** |
||
17 | * Default method to render the controller according to the action parameter. |
||
18 | */ |
||
19 | public function render() |
||
20 | { |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * Show default list of aggregate functions in the database. |
||
25 | * |
||
26 | * @param mixed $msg |
||
1 ignored issue
–
show
|
|||
27 | */ |
||
28 | public function doDefault($msg = '') |
||
1 ignored issue
–
show
|
|||
29 | { |
||
30 | } |
||
31 | |||
32 | public function doTree() |
||
1 ignored issue
–
show
|
|||
33 | { |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Actually creates the new aggregate in the database. |
||
38 | */ |
||
39 | public function doSaveCreate() |
||
40 | { |
||
41 | $lang = $this->lang; |
||
42 | $data = $this->misc->getDatabaseAccessor(); |
||
43 | // Check inputs |
||
44 | if ('' == trim($_REQUEST['name'])) { |
||
45 | $this->doCreate($lang['straggrneedsname']); |
||
46 | |||
47 | return; |
||
48 | } |
||
49 | if ('' == trim($_REQUEST['basetype'])) { |
||
50 | $this->doCreate($lang['straggrneedsbasetype']); |
||
51 | |||
52 | return; |
||
53 | } |
||
54 | if ('' == trim($_REQUEST['sfunc'])) { |
||
55 | $this->doCreate($lang['straggrneedssfunc']); |
||
56 | |||
57 | return; |
||
58 | } |
||
59 | if ('' == trim($_REQUEST['stype'])) { |
||
60 | $this->doCreate($lang['straggrneedsstype']); |
||
61 | |||
62 | return; |
||
63 | } |
||
64 | |||
65 | $status = $data->createAggregate( |
||
66 | $_REQUEST['name'], |
||
67 | $_REQUEST['basetype'], |
||
68 | $_REQUEST['sfunc'], |
||
69 | $_REQUEST['stype'], |
||
70 | $_REQUEST['ffunc'], |
||
71 | $_REQUEST['initcond'], |
||
72 | $_REQUEST['sortop'], |
||
73 | $_REQUEST['aggrcomment'] |
||
74 | ); |
||
75 | |||
76 | if (0 == $status) { |
||
77 | $this->misc->setReloadBrowser(true); |
||
78 | $this->doDefault($lang['straggrcreated']); |
||
79 | } else { |
||
80 | $this->doCreate($lang['straggrcreatedbad']); |
||
81 | } |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * Displays a screen for create a new aggregate function. |
||
86 | * |
||
87 | * @param mixed $msg |
||
1 ignored issue
–
show
|
|||
88 | */ |
||
89 | public function doCreate($msg = '') |
||
90 | { |
||
91 | $lang = $this->lang; |
||
92 | $data = $this->misc->getDatabaseAccessor(); |
||
93 | |||
94 | if (!isset($_REQUEST['name'])) { |
||
95 | $_REQUEST['name'] = ''; |
||
96 | } |
||
97 | |||
98 | if (!isset($_REQUEST['basetype'])) { |
||
99 | $_REQUEST['basetype'] = ''; |
||
100 | } |
||
101 | |||
102 | if (!isset($_REQUEST['sfunc'])) { |
||
103 | $_REQUEST['sfunc'] = ''; |
||
104 | } |
||
105 | |||
106 | if (!isset($_REQUEST['stype'])) { |
||
107 | $_REQUEST['stype'] = ''; |
||
108 | } |
||
109 | |||
110 | if (!isset($_REQUEST['ffunc'])) { |
||
111 | $_REQUEST['ffunc'] = ''; |
||
112 | } |
||
113 | |||
114 | if (!isset($_REQUEST['initcond'])) { |
||
115 | $_REQUEST['initcond'] = ''; |
||
116 | } |
||
117 | |||
118 | if (!isset($_REQUEST['sortop'])) { |
||
119 | $_REQUEST['sortop'] = ''; |
||
120 | } |
||
121 | |||
122 | if (!isset($_REQUEST['aggrcomment'])) { |
||
123 | $_REQUEST['aggrcomment'] = ''; |
||
124 | } |
||
125 | |||
126 | $this->printTrail('schema'); |
||
127 | $this->printTitle($lang['strcreateaggregate'], 'pg.aggregate.create'); |
||
128 | $this->printMsg($msg); |
||
129 | |||
130 | echo '<form action="' . \SUBFOLDER . "/src/views/aggregates.php\" method=\"post\">\n"; |
||
131 | echo "<table>\n"; |
||
132 | echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strname']}</th>\n"; |
||
133 | echo "\t\t<td class=\"data\"><input name=\"name\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
||
134 | htmlspecialchars($_REQUEST['name']), "\" /></td>\n\t</tr>\n"; |
||
135 | echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['straggrbasetype']}</th>\n"; |
||
136 | echo "\t\t<td class=\"data\"><input name=\"basetype\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
||
137 | htmlspecialchars($_REQUEST['basetype']), "\" /></td>\n\t</tr>\n"; |
||
138 | echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['straggrsfunc']}</th>\n"; |
||
139 | echo "\t\t<td class=\"data\"><input name=\"sfunc\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
||
140 | htmlspecialchars($_REQUEST['sfunc']), "\" /></td>\n\t</tr>\n"; |
||
141 | echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['straggrstype']}</th>\n"; |
||
142 | echo "\t\t<td class=\"data\"><input name=\"stype\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
||
143 | htmlspecialchars($_REQUEST['stype']), "\" /></td>\n\t</tr>\n"; |
||
144 | echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['straggrffunc']}</th>\n"; |
||
145 | echo "\t\t<td class=\"data\"><input name=\"ffunc\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
||
146 | htmlspecialchars($_REQUEST['ffunc']), "\" /></td>\n\t</tr>\n"; |
||
147 | echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['straggrinitcond']}</th>\n"; |
||
148 | echo "\t\t<td class=\"data\"><input name=\"initcond\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
||
149 | htmlspecialchars($_REQUEST['initcond']), "\" /></td>\n\t</tr>\n"; |
||
150 | echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['straggrsortop']}</th>\n"; |
||
151 | echo "\t\t<td class=\"data\"><input name=\"sortop\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", |
||
152 | htmlspecialchars($_REQUEST['sortop']), "\" /></td>\n\t</tr>\n"; |
||
153 | echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strcomment']}</th>\n"; |
||
154 | echo "\t\t<td><textarea name=\"aggrcomment\" rows=\"3\" cols=\"32\">", |
||
155 | htmlspecialchars($_REQUEST['aggrcomment']), "</textarea></td>\n\t</tr>\n"; |
||
156 | |||
157 | echo "</table>\n"; |
||
158 | echo "<p><input type=\"hidden\" name=\"action\" value=\"save_create\" />\n"; |
||
159 | echo $this->misc->form; |
||
160 | echo "<input type=\"submit\" value=\"{$lang['strcreate']}\" />\n"; |
||
161 | echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n"; |
||
162 | echo "</form>\n"; |
||
163 | } |
||
164 | |||
165 | /** |
||
166 | * Function to save after altering an aggregate. |
||
167 | */ |
||
168 | public function doSaveAlter() |
||
169 | { |
||
170 | $lang = $this->lang; |
||
171 | $data = $this->misc->getDatabaseAccessor(); |
||
172 | |||
173 | // Check inputs |
||
174 | if ('' == trim($_REQUEST['aggrname'])) { |
||
175 | $this->doAlter($lang['straggrneedsname']); |
||
176 | |||
177 | return; |
||
178 | } |
||
179 | |||
180 | $status = $data->alterAggregate( |
||
181 | $_REQUEST['aggrname'], |
||
182 | $_REQUEST['aggrtype'], |
||
183 | $_REQUEST['aggrowner'], |
||
184 | $_REQUEST['aggrschema'], |
||
185 | $_REQUEST['aggrcomment'], |
||
186 | $_REQUEST['newaggrname'], |
||
187 | $_REQUEST['newaggrowner'], |
||
188 | $_REQUEST['newaggrschema'], |
||
189 | $_REQUEST['newaggrcomment'] |
||
190 | ); |
||
191 | if (0 == $status) { |
||
192 | $this->doDefault($lang['straggraltered']); |
||
193 | } else { |
||
194 | $this->doAlter($lang['straggralteredbad']); |
||
195 | |||
196 | return; |
||
197 | } |
||
198 | } |
||
199 | |||
200 | /** |
||
201 | * Function to allow editing an aggregate function. |
||
202 | * |
||
203 | * @param mixed $msg |
||
1 ignored issue
–
show
|
|||
204 | */ |
||
205 | public function doAlter($msg = '') |
||
245 | } |
||
246 | |||
247 | /** |
||
248 | * Show confirmation of drop and perform actual drop of the aggregate function selected. |
||
249 | * |
||
250 | * @param mixed $confirm |
||
1 ignored issue
–
show
|
|||
251 | */ |
||
252 | public function doDrop($confirm) |
||
279 | } |
||
280 | } |
||
281 | } |
||
282 | |||
283 | /** |
||
284 | * Show the properties of an aggregate. |
||
285 | * |
||
286 | * @param mixed $msg |
||
1 ignored issue
–
show
|
|||
287 | */ |
||
288 | public function doProperties($msg = '') |
||
380 | } |
||
381 | } |
||
382 |