1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* PHPPgAdmin 6.1.3 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace PHPPgAdmin\Controller; |
8
|
|
|
|
9
|
|
|
use PHPPgAdmin\Decorators\Decorator; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Base controller class. |
13
|
|
|
*/ |
14
|
|
|
class AggregatesController extends BaseController |
15
|
|
|
{ |
16
|
|
|
public $table_place = 'aggregates-aggregates'; |
17
|
|
|
|
18
|
|
|
public $controller_title = 'straggregates'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Default method to render the controller according to the action parameter. |
22
|
|
|
*/ |
23
|
|
|
public function render() |
24
|
|
|
{ |
25
|
|
|
if ('tree' === $this->action) { |
26
|
|
|
return $this->doTree(); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
\ob_start(); |
30
|
|
|
|
31
|
|
|
switch ($this->action) { |
32
|
|
|
case 'create': |
33
|
|
|
$this->doCreate(); |
34
|
|
|
|
35
|
|
|
break; |
36
|
|
|
case 'save_create': |
37
|
|
|
if (null !== $this->getPostParam('cancel')) { |
38
|
|
|
$this->doDefault(); |
39
|
|
|
} else { |
40
|
|
|
$this->doSaveCreate(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
break; |
44
|
|
|
case 'alter': |
45
|
|
|
$this->doAlter(); |
46
|
|
|
|
47
|
|
|
break; |
48
|
|
|
case 'save_alter': |
49
|
|
|
if (null !== $this->getPostParam('alter')) { |
50
|
|
|
$this->doSaveAlter(); |
51
|
|
|
} else { |
52
|
|
|
$this->doProperties(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
break; |
56
|
|
|
case 'drop': |
57
|
|
|
if (null !== $this->getPostParam('drop')) { |
58
|
|
|
$this->doDrop(false); |
59
|
|
|
} else { |
60
|
|
|
$this->doDefault(); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
break; |
64
|
|
|
case 'confirm_drop': |
65
|
|
|
$this->doDrop(true); |
66
|
|
|
|
67
|
|
|
break; |
68
|
|
|
|
69
|
|
|
default: |
70
|
|
|
$this->doDefault(); |
71
|
|
|
|
72
|
|
|
break; |
73
|
|
|
case 'properties': |
74
|
|
|
$this->doProperties(); |
75
|
|
|
|
76
|
|
|
break; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
$output = \ob_get_clean(); |
80
|
|
|
|
81
|
|
|
$this->printHeader($this->headerTitle()); |
82
|
|
|
$this->printBody(); |
83
|
|
|
echo $output; |
84
|
|
|
|
85
|
|
|
return $this->printFooter(); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Show default list of aggregate functions in the database. |
90
|
|
|
* |
91
|
|
|
* @param mixed $msg |
92
|
|
|
*/ |
93
|
|
|
public function doDefault($msg = ''): void |
94
|
|
|
{ |
95
|
|
|
$this->printTrail('schema'); |
96
|
|
|
$this->printTabs('schema', 'aggregates'); |
97
|
|
|
$this->printMsg($msg); |
98
|
|
|
|
99
|
|
|
$aggregates = $this->data->getAggregates(); |
100
|
|
|
$columns = [ |
101
|
|
|
'aggrname' => [ |
102
|
|
|
'title' => $this->lang['strname'], |
103
|
|
|
'field' => Decorator::field('proname'), |
104
|
|
|
'url' => "redirect.php?subject=aggregate&action=properties&{$this->misc->href}&", |
105
|
|
|
'vars' => ['aggrname' => 'proname', 'aggrtype' => 'proargtypes'], |
106
|
|
|
], |
107
|
|
|
'aggrtype' => [ |
108
|
|
|
'title' => $this->lang['strtype'], |
109
|
|
|
'field' => Decorator::field('proargtypes'), |
110
|
|
|
], |
111
|
|
|
'aggrtransfn' => [ |
112
|
|
|
'title' => $this->lang['straggrsfunc'], |
113
|
|
|
'field' => Decorator::field('aggtransfn'), |
114
|
|
|
], |
115
|
|
|
'owner' => [ |
116
|
|
|
'title' => $this->lang['strowner'], |
117
|
|
|
'field' => Decorator::field('usename'), |
118
|
|
|
], |
119
|
|
|
'actions' => [ |
120
|
|
|
'title' => $this->lang['stractions'], |
121
|
|
|
], |
122
|
|
|
'comment' => [ |
123
|
|
|
'title' => $this->lang['strcomment'], |
124
|
|
|
'field' => Decorator::field('aggrcomment'), |
125
|
|
|
], |
126
|
|
|
]; |
127
|
|
|
|
128
|
|
|
$actions = [ |
129
|
|
|
'alter' => [ |
130
|
|
|
'content' => $this->lang['stralter'], |
131
|
|
|
'attr' => [ |
132
|
|
|
'href' => [ |
133
|
|
|
'url' => 'aggregates.php', |
134
|
|
|
'urlvars' => [ |
135
|
|
|
'action' => 'alter', |
136
|
|
|
'aggrname' => Decorator::field('proname'), |
137
|
|
|
'aggrtype' => Decorator::field('proargtypes'), |
138
|
|
|
], |
139
|
|
|
], |
140
|
|
|
], |
141
|
|
|
], |
142
|
|
|
'drop' => [ |
143
|
|
|
'content' => $this->lang['strdrop'], |
144
|
|
|
'attr' => [ |
145
|
|
|
'href' => [ |
146
|
|
|
'url' => 'aggregates.php', |
147
|
|
|
'urlvars' => [ |
148
|
|
|
'action' => 'confirm_drop', |
149
|
|
|
'aggrname' => Decorator::field('proname'), |
150
|
|
|
'aggrtype' => Decorator::field('proargtypes'), |
151
|
|
|
], |
152
|
|
|
], |
153
|
|
|
], |
154
|
|
|
], |
155
|
|
|
]; |
156
|
|
|
|
157
|
|
|
if (!$this->data->hasAlterAggregate()) { |
158
|
|
|
unset($actions['alter']); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
echo $this->printTable($aggregates, $columns, $actions, $this->table_place, $this->lang['strnoaggregates']); |
162
|
|
|
|
163
|
|
|
$navlinks = [ |
164
|
|
|
'create' => [ |
165
|
|
|
'attr' => [ |
166
|
|
|
'href' => [ |
167
|
|
|
'url' => 'aggregates.php', |
168
|
|
|
'urlvars' => [ |
169
|
|
|
'action' => 'create', |
170
|
|
|
'server' => $_REQUEST['server'], |
171
|
|
|
'database' => $_REQUEST['database'], |
172
|
|
|
'schema' => $_REQUEST['schema'], |
173
|
|
|
], |
174
|
|
|
], |
175
|
|
|
], |
176
|
|
|
'content' => $this->lang['strcreateaggregate'], |
177
|
|
|
], |
178
|
|
|
]; |
179
|
|
|
$this->printNavLinks($navlinks, $this->table_place, \get_defined_vars()); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
public function doTree() |
183
|
|
|
{ |
184
|
|
|
$this->data = $this->misc->getDatabaseAccessor(); |
185
|
|
|
|
186
|
|
|
$aggregates = $this->data->getAggregates(); |
187
|
|
|
$proto = Decorator::concat(Decorator::field('proname'), ' (', Decorator::field('proargtypes'), ')'); |
188
|
|
|
$reqvars = $this->misc->getRequestVars('aggregate'); |
189
|
|
|
|
190
|
|
|
$attrs = [ |
191
|
|
|
'text' => $proto, |
192
|
|
|
'icon' => 'Aggregate', |
193
|
|
|
'toolTip' => Decorator::field('aggcomment'), |
194
|
|
|
'action' => Decorator::redirecturl( |
195
|
|
|
'redirect', |
196
|
|
|
$reqvars, |
197
|
|
|
[ |
198
|
|
|
'action' => 'properties', |
199
|
|
|
'aggrname' => Decorator::field('proname'), |
200
|
|
|
'aggrtype' => Decorator::field('proargtypes'), |
201
|
|
|
] |
202
|
|
|
), |
203
|
|
|
]; |
204
|
|
|
|
205
|
|
|
return $this->printTree($aggregates, $attrs, 'aggregates'); |
|
|
|
|
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* Actually creates the new aggregate in the database. |
210
|
|
|
*/ |
211
|
|
|
public function doSaveCreate() |
212
|
|
|
{ |
213
|
|
|
$this->data = $this->misc->getDatabaseAccessor(); |
214
|
|
|
// Check inputs |
215
|
|
|
if ('' === \trim($_REQUEST['name'])) { |
216
|
|
|
return $this->doCreate($this->lang['straggrneedsname']); |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
if ('' === \trim($_REQUEST['basetype'])) { |
220
|
|
|
return $this->doCreate($this->lang['straggrneedsbasetype']); |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
if ('' === \trim($_REQUEST['sfunc'])) { |
224
|
|
|
return $this->doCreate($this->lang['straggrneedssfunc']); |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
if ('' === \trim($_REQUEST['stype'])) { |
228
|
|
|
return $this->doCreate($this->lang['straggrneedsstype']); |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
$status = $this->data->createAggregate( |
232
|
|
|
$_REQUEST['name'], |
233
|
|
|
$_REQUEST['basetype'], |
234
|
|
|
$_REQUEST['sfunc'], |
235
|
|
|
$_REQUEST['stype'], |
236
|
|
|
$_REQUEST['ffunc'], |
237
|
|
|
$_REQUEST['initcond'], |
238
|
|
|
$_REQUEST['sortop'], |
239
|
|
|
$_REQUEST['aggrcomment'] |
240
|
|
|
); |
241
|
|
|
|
242
|
|
|
if (0 === $status) { |
243
|
|
|
$this->view->setReloadBrowser(true); |
244
|
|
|
$this->doDefault($this->lang['straggrcreated']); |
245
|
|
|
} else { |
246
|
|
|
$this->doCreate($this->lang['straggrcreatedbad']); |
247
|
|
|
} |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* Displays a screen for create a new aggregate function. |
252
|
|
|
* |
253
|
|
|
* @param mixed $msg |
254
|
|
|
*/ |
255
|
|
|
public function doCreate($msg = ''): void |
256
|
|
|
{ |
257
|
|
|
$this->data = $this->misc->getDatabaseAccessor(); |
258
|
|
|
|
259
|
|
|
$this->coalesceArr($_REQUEST, 'name', ''); |
260
|
|
|
|
261
|
|
|
$this->coalesceArr($_REQUEST, 'basetype', ''); |
262
|
|
|
|
263
|
|
|
$this->coalesceArr($_REQUEST, 'sfunc', ''); |
264
|
|
|
|
265
|
|
|
$this->coalesceArr($_REQUEST, 'stype', ''); |
266
|
|
|
|
267
|
|
|
$this->coalesceArr($_REQUEST, 'ffunc', ''); |
268
|
|
|
|
269
|
|
|
$this->coalesceArr($_REQUEST, 'initcond', ''); |
270
|
|
|
|
271
|
|
|
$this->coalesceArr($_REQUEST, 'sortop', ''); |
272
|
|
|
|
273
|
|
|
$this->coalesceArr($_REQUEST, 'aggrcomment', ''); |
274
|
|
|
|
275
|
|
|
$this->printTrail('schema'); |
276
|
|
|
$this->printTitle($this->lang['strcreateaggregate'], 'pg.aggregate.create'); |
277
|
|
|
$this->printMsg($msg); |
278
|
|
|
|
279
|
|
|
echo '<form action="' . \containerInstance()->subFolder . '/src/views/aggregates" method="post">' . \PHP_EOL; |
280
|
|
|
echo '<table>' . \PHP_EOL; |
281
|
|
|
echo "\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['strname']}</th>" . \PHP_EOL; |
282
|
|
|
echo "\t\t<td class=\"data\"><input name=\"name\" size=\"32\" maxlength=\"{$this->data->_maxNameLen}\" value=\"", |
283
|
|
|
\htmlspecialchars($_REQUEST['name']), "\" /></td>\n\t</tr>" . \PHP_EOL; |
284
|
|
|
echo "\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['straggrbasetype']}</th>" . \PHP_EOL; |
285
|
|
|
echo "\t\t<td class=\"data\"><input name=\"basetype\" size=\"32\" maxlength=\"{$this->data->_maxNameLen}\" value=\"", |
286
|
|
|
\htmlspecialchars($_REQUEST['basetype']), "\" /></td>\n\t</tr>" . \PHP_EOL; |
287
|
|
|
echo "\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['straggrsfunc']}</th>" . \PHP_EOL; |
288
|
|
|
echo "\t\t<td class=\"data\"><input name=\"sfunc\" size=\"32\" maxlength=\"{$this->data->_maxNameLen}\" value=\"", |
289
|
|
|
\htmlspecialchars($_REQUEST['sfunc']), "\" /></td>\n\t</tr>" . \PHP_EOL; |
290
|
|
|
echo "\t<tr>\n\t\t<th class=\"data left required\">{$this->lang['straggrstype']}</th>" . \PHP_EOL; |
291
|
|
|
echo "\t\t<td class=\"data\"><input name=\"stype\" size=\"32\" maxlength=\"{$this->data->_maxNameLen}\" value=\"", |
292
|
|
|
\htmlspecialchars($_REQUEST['stype']), "\" /></td>\n\t</tr>" . \PHP_EOL; |
293
|
|
|
echo "\t<tr>\n\t\t<th class=\"data left\">{$this->lang['straggrffunc']}</th>" . \PHP_EOL; |
294
|
|
|
echo "\t\t<td class=\"data\"><input name=\"ffunc\" size=\"32\" maxlength=\"{$this->data->_maxNameLen}\" value=\"", |
295
|
|
|
\htmlspecialchars($_REQUEST['ffunc']), "\" /></td>\n\t</tr>" . \PHP_EOL; |
296
|
|
|
echo "\t<tr>\n\t\t<th class=\"data left\">{$this->lang['straggrinitcond']}</th>" . \PHP_EOL; |
297
|
|
|
echo "\t\t<td class=\"data\"><input name=\"initcond\" size=\"32\" maxlength=\"{$this->data->_maxNameLen}\" value=\"", |
298
|
|
|
\htmlspecialchars($_REQUEST['initcond']), "\" /></td>\n\t</tr>" . \PHP_EOL; |
299
|
|
|
echo "\t<tr>\n\t\t<th class=\"data left\">{$this->lang['straggrsortop']}</th>" . \PHP_EOL; |
300
|
|
|
echo "\t\t<td class=\"data\"><input name=\"sortop\" size=\"32\" maxlength=\"{$this->data->_maxNameLen}\" value=\"", |
301
|
|
|
\htmlspecialchars($_REQUEST['sortop']), "\" /></td>\n\t</tr>" . \PHP_EOL; |
302
|
|
|
echo "\t<tr>\n\t\t<th class=\"data left\">{$this->lang['strcomment']}</th>" . \PHP_EOL; |
303
|
|
|
echo "\t\t<td><textarea name=\"aggrcomment\" rows=\"3\" cols=\"32\">", |
304
|
|
|
\htmlspecialchars($_REQUEST['aggrcomment']), "</textarea></td>\n\t</tr>" . \PHP_EOL; |
305
|
|
|
|
306
|
|
|
echo '</table>' . \PHP_EOL; |
307
|
|
|
echo '<p><input type="hidden" name="action" value="save_create" />' . \PHP_EOL; |
308
|
|
|
echo $this->view->form; |
309
|
|
|
echo "<input type=\"submit\" value=\"{$this->lang['strcreate']}\" />" . \PHP_EOL; |
310
|
|
|
echo \sprintf('<input type="submit" name="cancel" value="%s" /></p>%s', $this->lang['strcancel'], \PHP_EOL); |
311
|
|
|
echo '</form>' . \PHP_EOL; |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
/** |
315
|
|
|
* Function to save after altering an aggregate. |
316
|
|
|
*/ |
317
|
|
|
public function doSaveAlter(): void |
318
|
|
|
{ |
319
|
|
|
$this->data = $this->misc->getDatabaseAccessor(); |
320
|
|
|
|
321
|
|
|
// Check inputs |
322
|
|
|
if ('' === \trim($_REQUEST['aggrname'])) { |
323
|
|
|
$this->doAlter($this->lang['straggrneedsname']); |
324
|
|
|
|
325
|
|
|
return; |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
$status = $this->data->alterAggregate( |
329
|
|
|
$_REQUEST['aggrname'], |
330
|
|
|
$_REQUEST['aggrtype'], |
331
|
|
|
$_REQUEST['aggrowner'], |
332
|
|
|
$_REQUEST['aggrschema'], |
333
|
|
|
$_REQUEST['aggrcomment'], |
334
|
|
|
$_REQUEST['newaggrname'], |
335
|
|
|
$_REQUEST['newaggrowner'], |
336
|
|
|
$_REQUEST['newaggrschema'], |
337
|
|
|
$_REQUEST['newaggrcomment'] |
338
|
|
|
); |
339
|
|
|
|
340
|
|
|
if (0 === $status) { |
341
|
|
|
$this->doDefault($this->lang['straggraltered']); |
342
|
|
|
} else { |
343
|
|
|
$this->doAlter($this->lang['straggralteredbad']); |
344
|
|
|
|
345
|
|
|
return; |
346
|
|
|
} |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
/** |
350
|
|
|
* Function to allow editing an aggregate function. |
351
|
|
|
* |
352
|
|
|
* @param mixed $msg |
353
|
|
|
*/ |
354
|
|
|
public function doAlter($msg = ''): void |
355
|
|
|
{ |
356
|
|
|
$this->data = $this->misc->getDatabaseAccessor(); |
357
|
|
|
|
358
|
|
|
$this->printTrail('aggregate'); |
359
|
|
|
$this->printTitle($this->lang['stralter'], 'pg.aggregate.alter'); |
360
|
|
|
$this->printMsg($msg); |
361
|
|
|
|
362
|
|
|
echo '<form action="' . \containerInstance()->subFolder . '/src/views/aggregates" method="post">' . \PHP_EOL; |
363
|
|
|
$aggrdata = $this->data->getAggregate($_REQUEST['aggrname'], $_REQUEST['aggrtype']); |
364
|
|
|
|
365
|
|
|
if (0 < $aggrdata->recordCount()) { |
366
|
|
|
// Output table header |
367
|
|
|
echo '<table>' . \PHP_EOL; |
368
|
|
|
echo "\t<tr>\n\t\t<th class=\"data required\">{$this->lang['strname']}</th>"; |
369
|
|
|
echo "<th class=\"data required\">{$this->lang['strowner']}</th>"; |
370
|
|
|
echo "<th class=\"data required\">{$this->lang['strschema']}</th>\n\t</tr>" . \PHP_EOL; |
371
|
|
|
|
372
|
|
|
// Display aggregate's name, owner and schema |
373
|
|
|
echo "\t<tr>\n\t\t<td><input name=\"newaggrname\" size=\"32\" maxlength=\"32\" value=\"", \htmlspecialchars($_REQUEST['aggrname']), '" /></td>'; |
374
|
|
|
echo '<td><input name="newaggrowner" size="32" maxlength="32" value="', \htmlspecialchars($aggrdata->fields['usename']), '" /></td>'; |
375
|
|
|
echo '<td><input name="newaggrschema" size="32" maxlength="32" value="', \htmlspecialchars($_REQUEST['schema']), "\" /></td>\n\t</tr>" . \PHP_EOL; |
376
|
|
|
echo "\t<tr>\n\t\t<th class=\"data left\">{$this->lang['strcomment']}</th>" . \PHP_EOL; |
377
|
|
|
echo "\t\t<td><textarea name=\"newaggrcomment\" rows=\"3\" cols=\"32\">", |
378
|
|
|
\htmlspecialchars($aggrdata->fields['aggrcomment']), "</textarea></td>\n\t</tr>" . \PHP_EOL; |
379
|
|
|
echo '</table>' . \PHP_EOL; |
380
|
|
|
echo '<p><input type="hidden" name="action" value="save_alter" />' . \PHP_EOL; |
381
|
|
|
echo $this->view->form; |
382
|
|
|
echo '<input type="hidden" name="aggrname" value="', \htmlspecialchars($_REQUEST['aggrname']), '" />' . \PHP_EOL; |
383
|
|
|
echo '<input type="hidden" name="aggrtype" value="', \htmlspecialchars($_REQUEST['aggrtype']), '" />' . \PHP_EOL; |
384
|
|
|
echo '<input type="hidden" name="aggrowner" value="', \htmlspecialchars($aggrdata->fields['usename']), '" />' . \PHP_EOL; |
385
|
|
|
echo '<input type="hidden" name="aggrschema" value="', \htmlspecialchars($_REQUEST['schema']), '" />' . \PHP_EOL; |
386
|
|
|
echo '<input type="hidden" name="aggrcomment" value="', \htmlspecialchars($aggrdata->fields['aggrcomment']), '" />' . \PHP_EOL; |
387
|
|
|
echo "<input type=\"submit\" name=\"alter\" value=\"{$this->lang['stralter']}\" />" . \PHP_EOL; |
388
|
|
|
echo \sprintf('<input type="submit" name="cancel" value="%s" /></p>%s', $this->lang['strcancel'], \PHP_EOL); |
389
|
|
|
} else { |
390
|
|
|
echo "<p>{$this->lang['strnodata']}</p>" . \PHP_EOL; |
391
|
|
|
echo "<input type=\"submit\" name=\"cancel\" value=\"{$this->lang['strback']}\" /></p>" . \PHP_EOL; |
392
|
|
|
} |
393
|
|
|
echo '</form>' . \PHP_EOL; |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
/** |
397
|
|
|
* Show confirmation of drop and perform actual drop of the aggregate function selected. |
398
|
|
|
* |
399
|
|
|
* @param mixed $confirm |
400
|
|
|
*/ |
401
|
|
|
public function doDrop($confirm): void |
402
|
|
|
{ |
403
|
|
|
$this->data = $this->misc->getDatabaseAccessor(); |
404
|
|
|
|
405
|
|
|
if ($confirm) { |
406
|
|
|
$this->printTrail('aggregate'); |
407
|
|
|
$this->printTitle($this->lang['strdrop'], 'pg.aggregate.drop'); |
408
|
|
|
|
409
|
|
|
echo '<p>', \sprintf($this->lang['strconfdropaggregate'], \htmlspecialchars($_REQUEST['aggrname'])), '</p>' . \PHP_EOL; |
410
|
|
|
|
411
|
|
|
echo '<form action="' . \containerInstance()->subFolder . '/src/views/aggregates" method="post">' . \PHP_EOL; |
412
|
|
|
echo "<p><input type=\"checkbox\" id=\"cascade\" name=\"cascade\" /> <label for=\"cascade\">{$this->lang['strcascade']}</label></p>" . \PHP_EOL; |
413
|
|
|
echo '<p><input type="hidden" name="action" value="drop" />' . \PHP_EOL; |
414
|
|
|
echo '<input type="hidden" name="aggrname" value="', \htmlspecialchars($_REQUEST['aggrname']), '" />' . \PHP_EOL; |
415
|
|
|
echo '<input type="hidden" name="aggrtype" value="', \htmlspecialchars($_REQUEST['aggrtype']), '" />' . \PHP_EOL; |
416
|
|
|
echo $this->view->form; |
417
|
|
|
echo "<input type=\"submit\" name=\"drop\" value=\"{$this->lang['strdrop']}\" />" . \PHP_EOL; |
418
|
|
|
echo \sprintf('<input type="submit" name="cancel" value="%s" /></p>%s', $this->lang['strcancel'], \PHP_EOL); |
419
|
|
|
echo '</form>' . \PHP_EOL; |
420
|
|
|
} else { |
421
|
|
|
$status = $this->data->dropAggregate($_POST['aggrname'], $_POST['aggrtype'], isset($_POST['cascade'])); |
422
|
|
|
|
423
|
|
|
if (0 === $status) { |
424
|
|
|
$this->view->setReloadBrowser(true); |
425
|
|
|
$this->doDefault($this->lang['straggregatedropped']); |
426
|
|
|
} else { |
427
|
|
|
$this->doDefault($this->lang['straggregatedroppedbad']); |
428
|
|
|
} |
429
|
|
|
} |
430
|
|
|
} |
431
|
|
|
|
432
|
|
|
/** |
433
|
|
|
* Show the properties of an aggregate. |
434
|
|
|
* |
435
|
|
|
* @param mixed $msg |
436
|
|
|
*/ |
437
|
|
|
public function doProperties($msg = ''): void |
438
|
|
|
{ |
439
|
|
|
$this->data = $this->misc->getDatabaseAccessor(); |
440
|
|
|
|
441
|
|
|
$this->printTrail('aggregate'); |
442
|
|
|
$this->printTitle($this->lang['strproperties'], 'pg.aggregate'); |
443
|
|
|
$this->printMsg($msg); |
444
|
|
|
|
445
|
|
|
$aggrdata = $this->data->getAggregate($_REQUEST['aggrname'], $_REQUEST['aggrtype']); |
446
|
|
|
|
447
|
|
|
if (0 < $aggrdata->recordCount()) { |
448
|
|
|
// Display aggregate's info |
449
|
|
|
echo '<table>' . \PHP_EOL; |
450
|
|
|
echo "<tr>\n\t<th class=\"data left\">{$this->lang['strname']}</th>" . \PHP_EOL; |
451
|
|
|
echo "\t<td class=\"data1\">", \htmlspecialchars($_REQUEST['aggrname']), "</td>\n</tr>" . \PHP_EOL; |
452
|
|
|
echo "<tr>\n\t<th class=\"data left\">{$this->lang['straggrbasetype']}</th>" . \PHP_EOL; |
453
|
|
|
echo "\t<td class=\"data1\">", \htmlspecialchars($_REQUEST['aggrtype']), "</td>\n</tr>" . \PHP_EOL; |
454
|
|
|
echo "<tr>\n\t<th class=\"data left\">{$this->lang['straggrsfunc']}</th>" . \PHP_EOL; |
455
|
|
|
echo "\t<td class=\"data1\">", \htmlspecialchars($aggrdata->fields['aggtransfn']), "</td>\n</tr>" . \PHP_EOL; |
456
|
|
|
echo "<tr>\n\t<th class=\"data left\">{$this->lang['straggrstype']}</th>" . \PHP_EOL; |
457
|
|
|
echo "\t<td class=\"data1\">", \htmlspecialchars($aggrdata->fields['aggstype']), "</td>\n</tr>" . \PHP_EOL; |
458
|
|
|
echo "<tr>\n\t<th class=\"data left\">{$this->lang['straggrffunc']}</th>" . \PHP_EOL; |
459
|
|
|
echo "\t<td class=\"data1\">", \htmlspecialchars($aggrdata->fields['aggfinalfn']), "</td>\n</tr>" . \PHP_EOL; |
460
|
|
|
echo "<tr>\n\t<th class=\"data left\">{$this->lang['straggrinitcond']}</th>" . \PHP_EOL; |
461
|
|
|
echo "\t<td class=\"data1\">", \htmlspecialchars($aggrdata->fields['agginitval']), "</td>\n</tr>" . \PHP_EOL; |
462
|
|
|
|
463
|
|
|
if ($this->data->hasAggregateSortOp()) { |
464
|
|
|
echo "<tr>\n\t<th class=\"data left\">{$this->lang['straggrsortop']}</th>" . \PHP_EOL; |
465
|
|
|
echo "\t<td class=\"data1\">", \htmlspecialchars($aggrdata->fields['aggsortop']), "</td>\n</tr>" . \PHP_EOL; |
466
|
|
|
} |
467
|
|
|
echo "<tr>\n\t<th class=\"data left\">{$this->lang['strowner']}</th>" . \PHP_EOL; |
468
|
|
|
echo "\t<td class=\"data1\">", \htmlspecialchars($aggrdata->fields['usename']), "</td>\n</tr>" . \PHP_EOL; |
469
|
|
|
echo "<tr>\n\t<th class=\"data left\">{$this->lang['strcomment']}</th>" . \PHP_EOL; |
470
|
|
|
echo "\t<td class=\"data1\">", $this->misc->printVal($aggrdata->fields['aggrcomment']), "</td>\n</tr>" . \PHP_EOL; |
471
|
|
|
echo '</table>' . \PHP_EOL; |
472
|
|
|
} else { |
473
|
|
|
echo "<p>{$this->lang['strnodata']}</p>" . \PHP_EOL; |
474
|
|
|
} |
475
|
|
|
|
476
|
|
|
$navlinks = [ |
477
|
|
|
'showall' => [ |
478
|
|
|
'attr' => [ |
479
|
|
|
'href' => [ |
480
|
|
|
'url' => 'aggregates', |
481
|
|
|
'urlvars' => [ |
482
|
|
|
'server' => $_REQUEST['server'], |
483
|
|
|
'database' => $_REQUEST['database'], |
484
|
|
|
'schema' => $_REQUEST['schema'], |
485
|
|
|
], |
486
|
|
|
], |
487
|
|
|
], |
488
|
|
|
'content' => $this->lang['straggrshowall'], |
489
|
|
|
], |
490
|
|
|
]; |
491
|
|
|
|
492
|
|
|
if ($this->data->hasAlterAggregate()) { |
493
|
|
|
$navlinks['alter'] = [ |
494
|
|
|
'attr' => [ |
495
|
|
|
'href' => [ |
496
|
|
|
'url' => 'aggregates', |
497
|
|
|
'urlvars' => [ |
498
|
|
|
'action' => 'alter', |
499
|
|
|
'server' => $_REQUEST['server'], |
500
|
|
|
'database' => $_REQUEST['database'], |
501
|
|
|
'schema' => $_REQUEST['schema'], |
502
|
|
|
'aggrname' => $_REQUEST['aggrname'], |
503
|
|
|
'aggrtype' => $_REQUEST['aggrtype'], |
504
|
|
|
], |
505
|
|
|
], |
506
|
|
|
], |
507
|
|
|
'content' => $this->lang['stralter'], |
508
|
|
|
]; |
509
|
|
|
} |
510
|
|
|
|
511
|
|
|
$navlinks['drop'] = [ |
512
|
|
|
'attr' => [ |
513
|
|
|
'href' => [ |
514
|
|
|
'url' => 'aggregates', |
515
|
|
|
'urlvars' => [ |
516
|
|
|
'action' => 'confirm_drop', |
517
|
|
|
'server' => $_REQUEST['server'], |
518
|
|
|
'database' => $_REQUEST['database'], |
519
|
|
|
'schema' => $_REQUEST['schema'], |
520
|
|
|
'aggrname' => $_REQUEST['aggrname'], |
521
|
|
|
'aggrtype' => $_REQUEST['aggrtype'], |
522
|
|
|
], |
523
|
|
|
], |
524
|
|
|
], |
525
|
|
|
'content' => $this->lang['strdrop'], |
526
|
|
|
]; |
527
|
|
|
|
528
|
|
|
$this->printNavLinks($navlinks, 'aggregates-properties', \get_defined_vars()); |
529
|
|
|
} |
530
|
|
|
} |
531
|
|
|
|