Test Failed
Pull Request — develop (#380)
by Felipe
03:42
created

AlldbController::doAlter()   C

Complexity

Conditions 10
Paths 11

Size

Total Lines 78
Code Lines 62

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 10
eloc 62
nc 11
nop 1
dl 0
loc 78
rs 6.9624
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

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:

1
<?php
2
3
/**
4
 * PHPPgAdmin 6.1.3
5
 */
6
7
namespace PHPPgAdmin\Controller;
8
9
use PHPPgAdmin\Decorators\Decorator;
10
use PHPPgAdmin\Traits\ExportTrait;
11
12
/**
13
 * Base controller class.
14
 */
15
class AlldbController extends BaseController
16
{
17
    use ExportTrait;
0 ignored issues
show
Bug introduced by
The trait PHPPgAdmin\Traits\ExportTrait requires the property $subFolder which is not provided by PHPPgAdmin\Controller\AlldbController.
Loading history...
18
19
    public $table_place = 'alldb-databases';
20
21
    public $controller_title = 'strdatabases';
22
23
    /**
24
     * Default method to render the controller according to the action parameter.
25
     */
26
    public function render()
27
    {
28
        if ('tree' === $this->action) {
29
            return $this->doTree();
30
        }
31
32
        $header_template = 'header.twig';
33
34
        \ob_start();
35
36
        switch ($this->action) {
37
            case 'export':
38
                $this->doExport();
39
40
                break;
41
            case 'save_create':
42
                if (null !== $this->getPostParam('cancel')) {
43
                    $this->doDefault();
44
                } else {
45
                    $this->doSaveCreate();
46
                }
47
48
                break;
49
            case 'create':
50
                $this->doCreate();
51
52
                break;
53
            case 'drop':
54
                if (isset($_REQUEST['drop'])) {
55
                    $this->doDrop(false);
56
                } else {
57
                    $this->doDefault();
58
                }
59
60
                break;
61
            case 'confirm_drop':
62
                $this->doDrop(true);
63
64
                break;
65
            case 'alter':
66
                if (isset($_POST['oldname'], $_POST['newname']) && !isset($_POST['cancel'])) {
67
                    $this->doAlter(false);
68
                } else {
69
                    $this->doDefault();
70
                }
71
72
                break;
73
            case 'confirm_alter':
74
                $this->doAlter(true);
75
76
                break;
77
78
            default:
79
                $header_template = 'header_datatables.twig';
80
                $this->doDefault();
81
82
                break;
83
        }
84
        $output = \ob_get_clean();
85
86
        $this->printHeader($this->headerTitle(), null, true, $header_template);
87
        $this->printBody(true,'flexbox_body',false,true);
88
        echo $output;
89
90
        return $this->printFooter();
91
    }
92
93
    /**
94
     * Show default list of databases in the server.
95
     *
96
     * @param mixed $msg
97
     */
98
    public function doDefault($msg = ''): void
99
    {
100
        $this->printTrail('server');
101
        $this->printTabs('server', 'databases');
102
        $this->printMsg($msg);
103
        $data = $this->misc->getDatabaseAccessor();
104
105
        $databases = $data->getDatabases();
106
107
        $this->view->setReloadBrowser(true);
108
109
        $href = $this->misc->getHREF();
110
        $redirecturl = $this->container->getDestinationWithLastTab('database');
111
112
        $columns = [
113
            'database' => [
114
                'title' => $this->lang['strdatabase'],
115
                'field' => Decorator::field('datname'),
116
                'url' =>   $redirecturl . '&amp;',
117
                'vars' => ['database' => 'datname'],
118
            ],
119
            'owner' => [
120
                'title' => $this->lang['strowner'],
121
                'field' => Decorator::field('datowner'),
122
            ],
123
            'encoding' => [
124
                'title' => $this->lang['strencoding'],
125
                'field' => Decorator::field('datencoding'),
126
            ],
127
128
            'tablespace' => [
129
                'title' => $this->lang['strtablespace'],
130
                'field' => Decorator::field('tablespace'),
131
            ],
132
            'dbsize' => [
133
                'title' => $this->lang['strsize'],
134
                'field' => Decorator::field('dbsize'),
135
                'type' => 'prettysize',
136
            ],
137
            'lc_collate' => [
138
                'title' => $this->lang['strcollation'],
139
                'field' => Decorator::field('datcollate'),
140
            ],
141
            'lc_ctype' => [
142
                'title' => $this->lang['strctype'],
143
                'field' => Decorator::field('datctype'),
144
            ],
145
            'actions' => [
146
                'title' => $this->lang['stractions'],
147
            ],
148
            'comment' => [
149
                'title' => $this->lang['strcomment'],
150
                'field' => Decorator::field('datcomment'),
151
            ],
152
        ];
153
154
        $actions = [
155
            'multiactions' => [
156
                'keycols' => ['database' => 'datname'],
157
                'url' => 'alldb',
158
                'default' => null,
159
            ],
160
            'drop' => [
161
                'content' => $this->lang['strdrop'],
162
                'attr' => [
163
                    'href' => [
164
                        'url' => 'alldb',
165
                        'urlvars' => [
166
                            'subject' => 'database',
167
                            'action' => 'confirm_drop',
168
                            'dropdatabase' => Decorator::field('datname'),
169
                        ],
170
                    ],
171
                ],
172
                'multiaction' => 'confirm_drop',
173
            ],
174
            'privileges' => [
175
                'content' => $this->lang['strprivileges'],
176
                'attr' => [
177
                    'href' => [
178
                        'url' => 'privileges',
179
                        'urlvars' => [
180
                            'subject' => 'database',
181
                            'database' => Decorator::field('datname'),
182
                        ],
183
                    ],
184
                ],
185
            ],
186
        ];
187
188
        if ($data->hasAlterDatabase()) {
189
            $actions['alter'] = [
190
                'content' => $this->lang['stralter'],
191
                'attr' => [
192
                    'href' => [
193
                        'url' => 'alldb',
194
                        'urlvars' => [
195
                            'subject' => 'database',
196
                            'action' => 'confirm_alter',
197
                            'alterdatabase' => Decorator::field('datname'),
198
                        ],
199
                    ],
200
                ],
201
            ];
202
        }
203
204
        if (!$data->hasTablespaces()) {
205
            unset($columns['tablespace']);
206
        }
207
208
        if (!$data->hasServerAdminFuncs()) {
209
            unset($columns['dbsize']);
210
        }
211
212
        if (!$data->hasDatabaseCollation()) {
213
            unset($columns['lc_collate'], $columns['lc_ctype']);
214
        }
215
216
        if (!isset($data->privlist['database'])) {
217
            unset($actions['privileges']);
218
        }
219
220
        echo $this->printTable($databases, $columns, $actions, $this->table_place, $this->lang['strnodatabases']);
221
222
        $navlinks = [
223
            'create' => [
224
                'attr' => [
225
                    'href' => [
226
                        'url' => 'alldb',
227
                        'urlvars' => [
228
                            'action' => 'create',
229
                            'server' => $_REQUEST['server'],
230
                        ],
231
                    ],
232
                ],
233
                'content' => $this->lang['strcreatedatabase'],
234
            ],
235
        ];
236
        $this->printNavLinks($navlinks, $this->table_place, \get_defined_vars());
237
    }
238
239
    /**
240
     * @return \Slim\Http\Response|string
241
     */
242
    public function doTree()
243
    {
244
        $data = $this->misc->getDatabaseAccessor();
245
246
        $databases = $data->getDatabases();
247
248
        $reqvars = $this->misc->getRequestVars('database');
249
250
        $attrs = [
251
            'text' => Decorator::field('datname'),
252
            'icon' => 'Database',
253
            'toolTip' => Decorator::field('datcomment'),
254
            'action' => Decorator::redirecturl('redirect', $reqvars, ['subject' => 'database', 'database' => Decorator::field('datname')]),
255
            'branch' => Decorator::url('/src/views/database', $reqvars, ['action' => 'tree', 'database' => Decorator::field('datname')]),
256
        ];
257
        return $this->printTree($databases, $attrs, 'databases');
258
    }
259
260
    /**
261
     * Display a form for alter and perform actual alter.
262
     *
263
     * @param mixed $confirm
264
     */
265
    public function doAlter($confirm): void
266
    {
267
        $data = $this->misc->getDatabaseAccessor();
268
269
        if ($confirm) {
270
            $this->printTrail('database');
271
            $this->printTitle($this->lang['stralter'], 'pg.database.alter');
272
273
            echo '<form action="' . \containerInstance()->subFolder . '/src/views/alldb" method="post">' . \PHP_EOL;
274
            echo '<table>' . \PHP_EOL;
275
            echo \sprintf(
276
                '<tr><th class="data left required">%s</th>',
277
                $this->lang['strname']
278
            ) . \PHP_EOL;
279
            echo '<td class="data1">';
280
            echo \sprintf(
281
                '<input name="newname" size="32" maxlength="%s" value="',
282
                $data->_maxNameLen
283
            ),
284
            \htmlspecialchars($_REQUEST['alterdatabase']), '" /></td></tr>' . \PHP_EOL;
285
286
            if ($data->hasAlterDatabaseOwner() && $data->isSuperUser()) {
287
                // Fetch all users
288
289
                $rs = $data->getDatabaseOwner($_REQUEST['alterdatabase']);
290
                $owner = isset($rs->fields['usename']) ? $rs->fields['usename'] : '';
291
                $users = $data->getUsers();
292
293
                echo \sprintf(
294
                    '<tr><th class="data left required">%s</th>',
295
                    $this->lang['strowner']
296
                ) . \PHP_EOL;
297
                echo '<td class="data1"><select name="owner">';
298
299
                while (!$users->EOF) {
300
                    $uname = $users->fields['usename'];
301
                    echo '<option value="', \htmlspecialchars($uname), '"',
302
                    ($uname === $owner) ? ' selected="selected"' : '', '>', \htmlspecialchars($uname), '</option>' . \PHP_EOL;
303
                    $users->MoveNext();
304
                }
305
                echo '</select></td></tr>' . \PHP_EOL;
306
            }
307
308
            if ($data->hasSharedComments()) {
309
                $rs = $data->getDatabaseComment($_REQUEST['alterdatabase']);
310
                $comment = isset($rs->fields['description']) ? $rs->fields['description'] : '';
311
                echo \sprintf(
312
                    '<tr><th class="data left">%s</th>',
313
                    $this->lang['strcomment']
314
                ) . \PHP_EOL;
315
                echo '<td class="data1">';
316
                echo '<textarea rows="3" cols="32" name="dbcomment">',
317
                \htmlspecialchars($comment), '</textarea></td></tr>' . \PHP_EOL;
318
            }
319
            echo '</table>' . \PHP_EOL;
320
            echo '<input type="hidden" name="action" value="alter" />' . \PHP_EOL;
321
            echo $this->view->form;
322
            echo '<input type="hidden" name="oldname" value="',
323
            \htmlspecialchars($_REQUEST['alterdatabase']), '" />' . \PHP_EOL;
324
            echo \sprintf(
325
                '<input type="submit" name="alter" value="%s" />',
326
                $this->lang['stralter']
327
            ) . \PHP_EOL;
328
            echo \sprintf(
329
                '<input type="submit" name="cancel" value="%s" />',
330
                $this->lang['strcancel']
331
            ) . \PHP_EOL;
332
            echo '</form>' . \PHP_EOL;
333
        } else {
334
            $this->coalesceArr($_POST, 'owner', '');
335
336
            $this->coalesceArr($_POST, 'dbcomment', '');
337
338
            if (0 === $data->alterDatabase($_POST['oldname'], $_POST['newname'], $_POST['owner'], $_POST['dbcomment'])) {
339
                $this->view->setReloadBrowser(true);
340
                $this->doDefault($this->lang['strdatabasealtered']);
341
            } else {
342
                $this->doDefault($this->lang['strdatabasealteredbad']);
343
            }
344
        }
345
    }
346
347
    /**
348
     * Show confirmation of drop and perform actual drop.
349
     *
350
     * @param mixed $confirm
351
     */
352
    public function doDrop($confirm)
353
    {
354
        $data = $this->misc->getDatabaseAccessor();
355
356
        if (empty($_REQUEST['dropdatabase']) && empty($_REQUEST['ma'])) {
357
            return $this->doDefault($this->lang['strspecifydatabasetodrop']);
358
        }
359
360
        if ($confirm) {
361
            $this->printTrail('database');
362
            $this->printTitle($this->lang['strdrop'], 'pg.database.drop');
363
364
            echo '<form action="' . \containerInstance()->subFolder . '/src/views/alldb" method="post">' . \PHP_EOL;
365
            //If multi drop
366
            if (isset($_REQUEST['ma'])) {
367
                foreach ($_REQUEST['ma'] as $v) {
368
                    $a = \unserialize(\htmlspecialchars_decode($v, \ENT_QUOTES));
369
                    echo '<p>', \sprintf(
370
                        $this->lang['strconfdropdatabase'],
371
                        $this->misc->printVal($a['database'])
372
                    ), '</p>' . \PHP_EOL;
373
                    \printf('<input type="hidden" name="dropdatabase[]" value="%s" />', \htmlspecialchars($a['database']));
374
                }
375
            } else {
376
                echo '<p>', \sprintf(
377
                    $this->lang['strconfdropdatabase'],
378
                    $this->misc->printVal($_REQUEST['dropdatabase'])
379
                ), '</p>' . \PHP_EOL;
380
                echo '<input type="hidden" name="dropdatabase" value="', \htmlspecialchars($_REQUEST['dropdatabase']), '" />' . \PHP_EOL;
381
                // END if multi drop
382
            }
383
384
            echo '<input type="hidden" name="action" value="drop" />' . \PHP_EOL;
385
386
            echo $this->view->form;
387
            echo \sprintf(
388
                '<input type="submit" name="drop" value="%s" />',
389
                $this->lang['strdrop']
390
            ) . \PHP_EOL;
391
            echo \sprintf(
392
                '<input type="submit" name="cancel" value="%s" />',
393
                $this->lang['strcancel']
394
            ) . \PHP_EOL;
395
            echo "</form>\n"; //  END confirm
396
        } else {
397
            //If multi drop
398
            if (\is_array($_REQUEST['dropdatabase'])) {
399
                $msg = '';
400
401
                foreach ($_REQUEST['dropdatabase'] as $d) {
402
                    $status = $data->dropDatabase($d);
403
404
                    if (0 === $status) {
405
                        $msg .= \sprintf(
406
                            '%s: %s<br />',
407
                            \htmlentities($d, \ENT_QUOTES, 'UTF-8'),
408
                            $this->lang['strdatabasedropped']
409
                        );
410
                    } else {
411
                        $this->doDefault(\sprintf(
412
                            '%s%s: %s<br />',
413
                            $msg,
414
                            \htmlentities($d, \ENT_QUOTES, 'UTF-8'),
415
                            $this->lang['strdatabasedroppedbad']
416
                        ));
417
418
                        return;
419
                    }
420
                    // Everything went fine, back to Default page...
421
                }
422
                $this->setReloadDropDatabase(true);
423
                $this->doDefault($msg);
424
            } else {
425
                $status = $data->dropDatabase($_POST['dropdatabase']);
426
427
                if (0 === $status) {
428
                    $this->setReloadDropDatabase(true);
429
                    $this->doDefault($this->lang['strdatabasedropped']);
430
                } else {
431
                    $this->doDefault($this->lang['strdatabasedroppedbad']);
432
                }
433
            }
434
            //END DROP
435
        }
436
    }
437
438
    // END FUNCTION
439
440
    /**
441
     * Displays a screen where they can enter a new database.
442
     *
443
     * @param mixed $msg
444
     */
445
    public function doCreate($msg = ''): void
446
    {
447
        $data = $this->misc->getDatabaseAccessor();
448
449
        $this->printTrail('server');
450
        $this->printTitle($this->lang['strcreatedatabase'], 'pg.database.create');
451
        $this->printMsg($msg);
452
453
        $this->coalesceArr($_POST, 'formName', '');
454
455
        // Default encoding is that in language file
456
        $this->coalesceArr($_POST, 'formEncoding', '');
457
        $this->coalesceArr($_POST, 'formTemplate', 'template1');
458
459
        $this->coalesceArr($_POST, 'formSpc', '');
460
461
        $this->coalesceArr($_POST, 'formComment', '');
462
463
        // Fetch a list of databases in the cluster
464
        $templatedbs = $data->getDatabases(false);
465
466
        $tablespaces = null;
467
        // Fetch all tablespaces from the database
468
        if ($data->hasTablespaces()) {
469
            $tablespaces = $data->getTablespaces();
470
        }
471
472
        echo '<form action="' . \containerInstance()->subFolder . '/src/views/alldb" method="post">' . \PHP_EOL;
473
        echo '<table>' . \PHP_EOL;
474
        echo \sprintf(
475
            '	<tr>
476
		<th class="data left required">%s</th>',
477
            $this->lang['strname']
478
        ) . \PHP_EOL;
479
        echo \sprintf(
480
            '		<td class="data1"><input name="formName" size="32" maxlength="%s" value="',
481
            $data->_maxNameLen
482
        ),
483
        \htmlspecialchars($_POST['formName']), "\" /></td>\n\t</tr>" . \PHP_EOL;
484
485
        echo \sprintf(
486
            '	<tr>
487
		<th class="data left required">%s</th>',
488
            $this->lang['strtemplatedb']
489
        ) . \PHP_EOL;
490
        echo "\t\t<td class=\"data1\">" . \PHP_EOL;
491
        echo "\t\t\t<select name=\"formTemplate\">" . \PHP_EOL;
492
        // Always offer template0 and template1
493
        echo "\t\t\t\t<option value=\"template0\"",
494
        ('template0' === $_POST['formTemplate']) ? ' selected="selected"' : '', '>template0</option>' . \PHP_EOL;
495
        echo "\t\t\t\t<option value=\"template1\"",
496
        ('template1' === $_POST['formTemplate']) ? ' selected="selected"' : '', '>template1</option>' . \PHP_EOL;
497
498
        while (!$templatedbs->EOF) {
499
            $dbname = \htmlspecialchars($templatedbs->fields['datname']);
500
501
            if ('template1' !== $dbname) {
502
                // filter out for $this->conf[show_system] users so we dont get duplicates
503
                echo \sprintf(
504
                    '				<option value="%s"',
505
                    $dbname
506
                ),
507
                ($dbname === $_POST['formTemplate']) ? ' selected="selected"' : '', \sprintf(
508
                    '>%s</option>',
509
                    $dbname
510
                ) . \PHP_EOL;
511
            }
512
            $templatedbs->MoveNext();
513
        }
514
        echo "\t\t\t</select>" . \PHP_EOL;
515
        echo "\t\t</td>\n\t</tr>" . \PHP_EOL;
516
517
        // ENCODING
518
        echo \sprintf(
519
            '	<tr>
520
		<th class="data left required">%s</th>',
521
            $this->lang['strencoding']
522
        ) . \PHP_EOL;
523
        echo "\t\t<td class=\"data1\">" . \PHP_EOL;
524
        echo "\t\t\t<select name=\"formEncoding\">" . \PHP_EOL;
525
        echo "\t\t\t\t<option value=\"\"></option>" . \PHP_EOL;
526
527
        foreach ($data->codemap as $key) {
528
            echo "\t\t\t\t<option value=\"", \htmlspecialchars($key), '"',
529
            ($key === $_POST['formEncoding']) ? ' selected="selected"' : '', '>',
530
            $this->misc->printVal($key), '</option>' . \PHP_EOL;
531
        }
532
        echo "\t\t\t</select>" . \PHP_EOL;
533
        echo "\t\t</td>\n\t</tr>" . \PHP_EOL;
534
535
        if ($data->hasDatabaseCollation()) {
536
            $this->coalesceArr($_POST, 'formCollate', '');
537
538
            $this->coalesceArr($_POST, 'formCType', '');
539
540
            // LC_COLLATE
541
            echo \sprintf(
542
                '	<tr>
543
		<th class="data left">%s</th>',
544
                $this->lang['strcollation']
545
            ) . \PHP_EOL;
546
            echo "\t\t<td class=\"data1\">" . \PHP_EOL;
547
            echo "\t\t\t<input name=\"formCollate\" value=\"", \htmlspecialchars($_POST['formCollate']), '" />' . \PHP_EOL;
548
            echo "\t\t</td>\n\t</tr>" . \PHP_EOL;
549
550
            // LC_CTYPE
551
            echo \sprintf(
552
                '	<tr>
553
		<th class="data left">%s</th>',
554
                $this->lang['strctype']
555
            ) . \PHP_EOL;
556
            echo "\t\t<td class=\"data1\">" . \PHP_EOL;
557
            echo "\t\t\t<input name=\"formCType\" value=\"", \htmlspecialchars($_POST['formCType']), '" />' . \PHP_EOL;
558
            echo "\t\t</td>\n\t</tr>" . \PHP_EOL;
559
        }
560
561
        // Tablespace (if there are any)
562
        if ($data->hasTablespaces() && 0 < $tablespaces->RecordCount()) {
563
            echo \sprintf(
564
                '	<tr>
565
		<th class="data left">%s</th>',
566
                $this->lang['strtablespace']
567
            ) . \PHP_EOL;
568
            echo "\t\t<td class=\"data1\">\n\t\t\t<select name=\"formSpc\">" . \PHP_EOL;
569
            // Always offer the default (empty) option
570
            echo "\t\t\t\t<option value=\"\"",
571
            ('' === $_POST['formSpc']) ? ' selected="selected"' : '', '></option>' . \PHP_EOL;
572
            // Display all other tablespaces
573
            while (!$tablespaces->EOF) {
574
                $spcname = \htmlspecialchars($tablespaces->fields['spcname'] ?? '');
575
                echo \sprintf(
576
                    '				<option value="%s"',
577
                    $spcname
578
                ),
579
                ($spcname === $_POST['formSpc']) ? ' selected="selected"' : '', \sprintf(
580
                    '>%s</option>',
581
                    $spcname
582
                ) . \PHP_EOL;
583
                $tablespaces->MoveNext();
584
            }
585
            echo "\t\t\t</select>\n\t\t</td>\n\t</tr>" . \PHP_EOL;
586
        }
587
588
        // Comments (if available)
589
        if ($data->hasSharedComments()) {
590
            echo \sprintf(
591
                '	<tr>
592
		<th class="data left">%s</th>',
593
                $this->lang['strcomment']
594
            ) . \PHP_EOL;
595
            echo "\t\t<td><textarea name=\"formComment\" rows=\"3\" cols=\"32\">",
596
            \htmlspecialchars($_POST['formComment']), "</textarea></td>\n\t</tr>" . \PHP_EOL;
597
        }
598
599
        echo '</table>' . \PHP_EOL;
600
        echo '<p><input type="hidden" name="action" value="save_create" />' . \PHP_EOL;
601
        echo $this->view->form;
602
        echo \sprintf(
603
            '<input type="submit" value="%s" />',
604
            $this->lang['strcreate']
605
        ) . \PHP_EOL;
606
        echo \sprintf(
607
            '<input type="submit" name="cancel" value="%s"  /></p>%s',
608
            $this->lang['strcancel'],
609
            \PHP_EOL
610
        );
611
        echo '</form>' . \PHP_EOL;
612
    }
613
614
    /**
615
     * Actually creates the new view in the database.
616
     */
617
    public function doSaveCreate(): void
618
    {
619
        $data = $this->misc->getDatabaseAccessor();
620
621
        // Default tablespace to null if it isn't set
622
        $this->coalesceArr($_POST, 'formSpc', '');
623
624
        // Default comment to blank if it isn't set
625
        $this->coalesceArr($_POST, 'formComment', '');
626
627
        // Default collate to blank if it isn't set
628
        $this->coalesceArr($_POST, 'formCollate', '');
629
630
        // Default ctype to blank if it isn't set
631
        $this->coalesceArr($_POST, 'formCType', '');
632
633
        // Check that they've given a name and a definition
634
        if ('' === $_POST['formName']) {
635
            $this->doCreate($this->lang['strdatabaseneedsname']);
636
        } else {
637
            $status = $data->createDatabase(
638
                $_POST['formName'],
639
                $_POST['formEncoding'],
640
                $_POST['formSpc'],
641
                $_POST['formComment'],
642
                $_POST['formTemplate'],
643
                $_POST['formCollate'],
644
                $_POST['formCType']
645
            );
646
647
            if (0 === $status) {
648
                $this->view->setReloadBrowser(true);
649
                $this->doDefault($this->lang['strdatabasecreated']);
650
            } else {
651
                $this->doCreate($this->lang['strdatabasecreatedbad']);
652
            }
653
        }
654
    }
655
656
    /**
657
     * Displays options for cluster download.
658
     *
659
     * @param mixed $msg
660
     */
661
    public function doExport($msg = ''): void
662
    {
663
        $this->printTrail('server');
664
        $this->printTabs('server', 'export');
665
        $this->printMsg($msg);
666
667
        $subject = 'server';
668
        $object = $_REQUEST['server'];
669
670
        echo $this->formHeader('dbexport');
671
672
        echo $this->dataOnly(true, true);
673
674
        echo $this->structureOnly();
675
676
        echo $this->structureAndData(true);
677
678
        $server_info = $this->misc->getServerInfo();
679
680
        echo $this->offerNoRoleExport(isset($server_info['pgVersion']) && 10 <= (float) (\mb_substr($server_info['pgVersion'], 0, 3)));
681
682
        // dumpall doesn't support gzip
683
        echo $this->displayOrDownload(false);
684
685
        echo $this->formFooter($subject, $object);
686
    }
687
}
688