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